Skip to content

Commit 57b7a17

Browse files
Updates
1 parent ca035dc commit 57b7a17

File tree

9 files changed

+120
-36
lines changed

9 files changed

+120
-36
lines changed

data/com.ml4w.dotfilesinstaller.metainfo.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<description translate="no">
6464
<p>Release 0.9.8</p>
6565
<ul>
66+
<li>Add more developer tools</li>
6667
<li>Add "Info" menu button to load configuration overview to installed dotfiles with "Open Homepage" and "Check for Updates" if remote source.</li>
6768
</ul>
6869
</description>

docs/.vitepress/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default {
2323
{ text: "Home", link: "/" },
2424
{ text: "About", link: "/getting-started/overview" },
2525
{
26-
text: "0.9.7",
26+
text: "0.9.8",
2727
items: [
2828
{
2929
// todo; add CHANGELOG.md in dotfiles-installer repo

src/classes/information.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def show_information(self):
5959
self.config_homepage.set_visible(True)
6060
self.config_dependencies.set_visible(True)
6161
self.props.progress_bar.set_visible(True)
62+
self.props.progress_bar.set_visible(True)
63+
self.props.btn_dev_menu.set_visible(False)
6264

6365
if not "description" in self.props.config_json:
6466
self.config_description.set_visible(False)
@@ -75,8 +77,12 @@ def show_information(self):
7577
else:
7678
self.config_dependencies.set_subtitle(self.props.config_json["dependencies"])
7779

78-
self.config_source.set_subtitle(self.props.config_json["source"])
79-
self.config_subfolder.set_subtitle(self.props.config_json["subfolder"])
80+
if ".git" in self.props.config_json["source"]:
81+
self.config_source.set_subtitle(self.props.config_json["source"])
82+
self.config_subfolder.set_subtitle(self.props.config_json["subfolder"])
83+
else:
84+
self.config_source.set_subtitle(home_folder + self.props.config_json["source"])
85+
self.config_subfolder.set_subtitle(self.props.config_json["subfolder"])
8086

8187
if ".git" in self.props.config_json["source"]:
8288
if "tag" in self.props.config_json and not self.props.config_json["tag"] == "":
@@ -103,7 +109,7 @@ def get_source(self):
103109
shutil.rmtree(self.props.original_folder)
104110

105111
# Download or copy source into downloads folder
106-
if ".git" in self.config_source.get_subtitle():
112+
if ".git" in self.props.config_json["source"]:
107113
task = Gio.Task.new(self, self.current_cancellable, self.on_clone_source_sepository_completed, None)
108114
# task.set_task_data("task_data", None) # Pass our custom data instance to the task
109115
task.run_in_thread(self.clone_source_sepository)
@@ -183,6 +189,15 @@ def on_get_source_completed(self):
183189
self.show_replacement = True
184190
self.props.updateProgressBar(0.2)
185191

192+
def get_next(self):
193+
self.props.config_backup.load()
194+
195+
def clean_install(self):
196+
printLog("Clean installation for " + self.props.config_json["id"])
197+
if os.path.exists(self.props.dotfiles_folder):
198+
# shutil.rmtree(self.props.dotfiles_folder) # For deleting non-empty directories
199+
printLog(self.props.dotfiles_folder + " folder removed successfully")
200+
186201
def writeProjectConfig(self):
187202
# Add additional information to config.dotinst
188203
self.props.config_json["dotinst"] = self.props.source_dotinst

src/classes/installation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ class Installation(Gtk.Box):
3737
def __init__(self, **kwargs):
3838
self.activate_now.connect("notify::active",self.change_activate_now)
3939

40+
4041
def load(self):
4142
printLog("Show installation page")
4243
if self.props.install_mode == "update":
4344
self.page_title.set_label("Update")
4445
self.page_subtitle.set_label("The dotfiles are now prepared for the update.")
4546

4647
self.activate_now.set_active(True)
48+
self.props.btn_dev_menu.set_visible(False)
4749

4850
if not get_symlink_enabled():
4951
self.activate_now.set_active(False)

src/classes/loadconfiguration.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def create_row(self,item):
113113
menu_button.set_icon_name("info-outline-symbolic")
114114
menu_button.set_menu_model(main_menu)
115115
menu_button.set_valign(3)
116-
row.add_suffix(menu_button)
116+
row.add_prefix(menu_button)
117117

118118
if ".git" in item.source and item.dotinst:
119119
btn = Gtk.Button()
@@ -125,15 +125,11 @@ def create_row(self,item):
125125
btn = Gtk.Button()
126126
btn.set_valign(3)
127127
btn.set_icon_name("arrow3-left-symbolic")
128+
btn.get_style_context().add_class("suggested-action")
129+
128130
btn.connect("clicked",self.sync_dotfiles, item.id + ";" + item.source + "/" + item.subfolder + ";" + item.dotinst)
129131
row.add_suffix(btn)
130132

131-
btn = Gtk.Button()
132-
btn.set_valign(3)
133-
btn.set_label("Activate")
134-
btn.connect("clicked",self.activate_dotfiles,item.id)
135-
row.add_suffix(btn)
136-
137133
if get_dev_enabled():
138134
main_menu = Gio.Menu.new()
139135
file_section = Gio.Menu.new()
@@ -159,11 +155,19 @@ def create_row(self,item):
159155
main_menu.append_section(None, dev_section)
160156

161157
menu_button = Gtk.MenuButton.new()
162-
menu_button.set_icon_name("code-symbolic")
158+
menu_button.set_label("Dev")
159+
menu_button.get_style_context().add_class("suggested-action")
160+
# menu_button.set_icon_name("code-symbolic")
163161
menu_button.set_menu_model(main_menu)
164162
menu_button.set_valign(3)
165163
row.add_suffix(menu_button)
166164

165+
btn = Gtk.Button()
166+
btn.set_valign(3)
167+
btn.set_label("Activate")
168+
btn.connect("clicked",self.activate_dotfiles,item.id)
169+
row.add_suffix(btn)
170+
167171
if item.settings:
168172
del_btn = Gtk.Button()
169173
del_btn.set_valign(3)
@@ -251,16 +255,15 @@ def load_installed_dotfiles(self):
251255
printLog(dot_json["id"] + " installed")
252256
item = DotfilesItem()
253257
if "type" in dot_json and "dotinst" in dot_json and dot_json["type"] == "local":
254-
if os.path.exists(home_folder + dot_json["dotinst"]):
255-
printLog("Using local dotinst file: " + home_folder + dot_json["dotinst"])
256-
item.dotinst = home_folder + dot_json["dotinst"]
257-
dot_json = json.load(open(home_folder + dot_json["dotinst"]))
258+
if os.path.exists(dot_json["dotinst"]):
259+
printLog("Using local dotinst file: " + dot_json["dotinst"])
260+
item.dotinst = dot_json["dotinst"]
261+
dot_json = json.load(open(dot_json["dotinst"]))
258262
else:
259263
printLog("Local dotinst file not exists")
260264

261265
if "type" in dot_json and "dotinst" in dot_json and dot_json["type"] == "remote":
262266
item.dotinst = dot_json["dotinst"]
263-
print(item.dotinst)
264267

265268
if "settings" in dot_json:
266269
item.settings = True
@@ -325,7 +328,9 @@ def load_configuration(self,_):
325328

326329
# Loads JSON content from a local file in the user's home directory asynchronously.
327330
def _load_json_from_local_file(self):
328-
file_path = home_folder + self.config_source
331+
file_path = self.config_source
332+
#####
333+
print(file_path)
329334
local_file = Gio.File.new_for_path(file_path)
330335
printLog("Attempting to load file from: " + file_path)
331336

src/classes/preferences.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ def change_dev_log_file(self, switch, GParamBoolean):
7272
def change_dev(self, switch, GParamBoolean):
7373
if switch.get_active():
7474
self.settings.set_boolean("my-enable-dev",True)
75-
self.props.btn_add_project.set_visible(True)
75+
self.props.btn_dev_menu.set_visible(True)
7676
else:
7777
self.settings.set_boolean("my-enable-dev",False)
78-
self.props.btn_add_project.set_visible(False)
78+
self.props.btn_dev_menu.set_visible(False)
7979
self.props.config_configuration.load_installed_dotfiles()
8080

src/ui/information.ui

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,8 @@
153153
<property name="title" translatable="yes">Subfolder</property>
154154
</object>
155155
</child>
156-
157156
</object>
158157
</child>
159-
160158
</template>
161159

162160
</interface>

src/ui/window.ui

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@
1212
<object class="AdwToolbarView">
1313
<child type="top">
1414
<object class="AdwHeaderBar">
15-
<child type="start">
16-
<object class="GtkButton" id="btn_add_project">
17-
<property name="label" translatable="yes">Create Project</property>
18-
<property name="visible">false</property>
19-
<property name="css-classes">suggested-action</property>
20-
<signal name="clicked" handler="on_add_project_action"/>
21-
</object>
22-
</child>
2315
<child type="end">
2416
<object class="GtkMenuButton">
2517
<property name="primary">True</property>
@@ -28,6 +20,17 @@
2820
<property name="menu-model">primary_menu</property>
2921
</object>
3022
</child>
23+
<child type="start">
24+
<object class="GtkMenuButton" id="btn_dev_menu">
25+
<property name="visible">false</property>
26+
<property name="label">Dev</property>
27+
<property name="tooltip-text" translatable="yes">Main Menu</property>
28+
<property name="menu-model">dev_menu</property>
29+
<style>
30+
<class name="suggested-action"/>
31+
</style>
32+
</object>
33+
</child>
3134
</object>
3235
</child>
3336
<child type="bottom">
@@ -236,6 +239,20 @@
236239
</object>
237240
</property>
238241
</template>
242+
<menu id="dev_menu">
243+
<section>
244+
<item>
245+
<attribute name="label" translatable="yes">_Create Project</attribute>
246+
<attribute name="action">win.create_project</attribute>
247+
</item>
248+
</section>
249+
<section>
250+
<item>
251+
<attribute name="label" translatable="yes">_Load Project</attribute>
252+
<attribute name="action">win.load_project</attribute>
253+
</item>
254+
</section>
255+
</menu>
239256
<menu id="primary_menu">
240257
<section>
241258
<item>
@@ -275,3 +292,4 @@
275292
</section>
276293
</menu>
277294
</interface>
295+

src/window.py

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ class DotfilesInstallerWindow(Adw.ApplicationWindow):
5050
config_finish = Gtk.Template.Child()
5151
config_configuration = Gtk.Template.Child()
5252
spinner = Gtk.Template.Child()
53-
btn_add_project = Gtk.Template.Child()
5453
toast_overlay = Gtk.Template.Child()
5554
progress_bar = Gtk.Template.Child()
55+
btn_dev_menu = Gtk.Template.Child()
56+
5657
install_mode = "install"
5758

5859
def __init__(self, **kwargs):
@@ -80,7 +81,7 @@ def __init__(self, **kwargs):
8081
self.progress_bar.set_visible(False)
8182

8283
if get_dev_enabled():
83-
self.btn_add_project.set_visible(True)
84+
self.btn_dev_menu.set_visible(True)
8485

8586
# self.config_finish.load()
8687
# self.wizzard_stack.set_visible_child_name("page_finish")
@@ -100,6 +101,8 @@ def create_actions(self):
100101
self.create_action("dev_push_to_repo",self.on_dev_push_to_repo)
101102
self.create_action("dev_pull_from_repo",self.on_dev_pull_from_repo)
102103
self.create_action("run_setup_script",self.on_run_setup_script)
104+
self.create_action("create_project",self.on_create_project)
105+
self.create_action("load_project",self.on_load_project)
103106

104107
self.open_dotfiles_action = Gio.SimpleAction.new("dev_open_dotfiles_folder", GLib.VariantType.new('s'))
105108
self.open_dotfiles_action.connect("activate", self.on_dev_open_dotfiles_folder)
@@ -168,6 +171,8 @@ def reset_app(self):
168171
self.updateProgressBar(0.0)
169172
self.install_mode = "install"
170173
self.progress_bar.set_visible(False)
174+
if get_dev_enabled():
175+
self.btn_dev_menu.set_visible(True)
171176

172177
@Gtk.Template.Callback()
173178
def on_wizzard_next_action(self, widget):
@@ -176,7 +181,7 @@ def on_wizzard_next_action(self, widget):
176181
if self.config_information.show_replacement == False:
177182
self.config_information.get_source()
178183
else:
179-
self.config_backup.load()
184+
self.config_information.get_next()
180185
case "page_backup":
181186
self.config_backup.create_backup()
182187
case "page_settings":
@@ -194,10 +199,50 @@ def on_wizzard_next_action(self, widget):
194199
case "page_finish":
195200
self.reset_app()
196201

197-
@Gtk.Template.Callback()
198-
def on_add_project_action(self, widget):
202+
def on_create_project(self, widget, _):
199203
self.add_project.present(self)
200204

205+
def on_load_project(self, widget, _):
206+
self.file_chooser = Gtk.FileChooserNative.new(
207+
title="Open .dotinst File",
208+
parent=None,
209+
action=Gtk.FileChooserAction.OPEN,
210+
accept_label="Open",
211+
cancel_label="Cancel"
212+
)
213+
214+
# Add a file filter for .dotinst extension
215+
file_filter = Gtk.FileFilter()
216+
file_filter.set_name(".dotinst Files")
217+
file_filter.add_pattern("*.dotinst")
218+
self.file_chooser.add_filter(file_filter)
219+
220+
# Add an "All Files" filter
221+
all_files_filter = Gtk.FileFilter()
222+
all_files_filter.set_name("All Files")
223+
all_files_filter.add_pattern("*")
224+
self.file_chooser.add_filter(all_files_filter)
225+
226+
self.file_chooser.connect("response", self.on_dialog_response)
227+
self.file_chooser.show()
228+
229+
def on_dialog_response(self, dialog, response):
230+
if response == Gtk.ResponseType.ACCEPT:
231+
# Get the GFile object
232+
file = dialog.get_file()
233+
if file:
234+
# Get the path from the GFile object
235+
file_path = file.get_path()
236+
if file_path:
237+
print(f"Selected file path: {file_path}")
238+
self.config_configuration.entry_dotinst.set_text(file_path)
239+
self.config_configuration.load_configuration(None)
240+
else:
241+
print("Could not get local path for selected file.")
242+
243+
dialog.destroy()
244+
self.file_chooser = None
245+
201246
def updateProgressBar(self,v):
202247
self.progress_bar.set_fraction(v)
203248

@@ -332,7 +377,7 @@ def on_dev_open_project_folder(self, widget, param):
332377

333378
def on_dev_reinstall_dotfiles(self, widget, param):
334379
self.install_mode = "update"
335-
local_dotinst = param.get_string().replace(home_folder,"")
380+
local_dotinst = param.get_string()
336381
self.config_configuration.entry_dotinst.set_text(local_dotinst)
337382
self.config_configuration.load_configuration(widget)
338383

0 commit comments

Comments
 (0)