@@ -50,9 +50,10 @@ class DotfilesInstallerWindow(Adw.ApplicationWindow):
50
50
config_finish = Gtk .Template .Child ()
51
51
config_configuration = Gtk .Template .Child ()
52
52
spinner = Gtk .Template .Child ()
53
- btn_add_project = Gtk .Template .Child ()
54
53
toast_overlay = Gtk .Template .Child ()
55
54
progress_bar = Gtk .Template .Child ()
55
+ btn_dev_menu = Gtk .Template .Child ()
56
+
56
57
install_mode = "install"
57
58
58
59
def __init__ (self , ** kwargs ):
@@ -80,7 +81,7 @@ def __init__(self, **kwargs):
80
81
self .progress_bar .set_visible (False )
81
82
82
83
if get_dev_enabled ():
83
- self .btn_add_project .set_visible (True )
84
+ self .btn_dev_menu .set_visible (True )
84
85
85
86
# self.config_finish.load()
86
87
# self.wizzard_stack.set_visible_child_name("page_finish")
@@ -100,6 +101,8 @@ def create_actions(self):
100
101
self .create_action ("dev_push_to_repo" ,self .on_dev_push_to_repo )
101
102
self .create_action ("dev_pull_from_repo" ,self .on_dev_pull_from_repo )
102
103
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 )
103
106
104
107
self .open_dotfiles_action = Gio .SimpleAction .new ("dev_open_dotfiles_folder" , GLib .VariantType .new ('s' ))
105
108
self .open_dotfiles_action .connect ("activate" , self .on_dev_open_dotfiles_folder )
@@ -168,6 +171,8 @@ def reset_app(self):
168
171
self .updateProgressBar (0.0 )
169
172
self .install_mode = "install"
170
173
self .progress_bar .set_visible (False )
174
+ if get_dev_enabled ():
175
+ self .btn_dev_menu .set_visible (True )
171
176
172
177
@Gtk .Template .Callback ()
173
178
def on_wizzard_next_action (self , widget ):
@@ -176,7 +181,7 @@ def on_wizzard_next_action(self, widget):
176
181
if self .config_information .show_replacement == False :
177
182
self .config_information .get_source ()
178
183
else :
179
- self .config_backup . load ()
184
+ self .config_information . get_next ()
180
185
case "page_backup" :
181
186
self .config_backup .create_backup ()
182
187
case "page_settings" :
@@ -194,10 +199,50 @@ def on_wizzard_next_action(self, widget):
194
199
case "page_finish" :
195
200
self .reset_app ()
196
201
197
- @Gtk .Template .Callback ()
198
- def on_add_project_action (self , widget ):
202
+ def on_create_project (self , widget , _ ):
199
203
self .add_project .present (self )
200
204
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
+
201
246
def updateProgressBar (self ,v ):
202
247
self .progress_bar .set_fraction (v )
203
248
@@ -332,7 +377,7 @@ def on_dev_open_project_folder(self, widget, param):
332
377
333
378
def on_dev_reinstall_dotfiles (self , widget , param ):
334
379
self .install_mode = "update"
335
- local_dotinst = param .get_string (). replace ( home_folder , "" )
380
+ local_dotinst = param .get_string ()
336
381
self .config_configuration .entry_dotinst .set_text (local_dotinst )
337
382
self .config_configuration .load_configuration (widget )
338
383
0 commit comments