@@ -45,6 +45,8 @@ def __init__(self, **kwargs):
4545
4646 self .model = FormModel ()
4747 self ._rows : list [FieldEditorRow ] = []
48+ # If set, Save will suggest this path (used when editing an existing file)
49+ self ._save_path : str | None = None
4850
4951 # Wire the form-name entry (declared in UI template)
5052 self .form_name_row .connect ("changed" , self ._on_form_name_changed )
@@ -173,8 +175,7 @@ def _on_save_finish(self, dialog, result):
173175 if hasattr (self , "page" ) and self .page and hasattr (self .page , "tab_page" ):
174176 self .page .tab_page .set_title (os .path .basename (path ))
175177
176- # Unlock Back now that there is a saved file to return with
177- self .back_button .set_sensitive (True )
178+ self ._save_path = path
178179
179180 @Gtk .Template .Callback ()
180181 def on_back_clicked (self , * _ ):
@@ -183,9 +184,6 @@ def on_back_clicked(self, *_):
183184 The user just needs to pick a CSV and hit Open Form.
184185 Only reachable after at least one successful Save.
185186 """
186- if not self ._save_path :
187- return
188-
189187 from .form_config import FormConfig
190188
191189 self .page .remove (self )
@@ -194,10 +192,11 @@ def on_back_clicked(self, *_):
194192 form_config .set_page (self .page )
195193 self .page .append (form_config )
196194
197- saved_file = Gio .File .new_for_path (self ._save_path )
198- form_config .preselect_config (saved_file )
195+ if self ._save_path :
196+ saved_file = Gio .File .new_for_path (self ._save_path )
197+ form_config .preselect_config (saved_file )
199198
200- self .page .tab_page .set_title (os .path .basename (self ._save_path ))
199+ self .page .tab_page .set_title (os .path .basename (self ._save_path ))
201200
202201 def _show_toast (self , message : str , timeout : int = 3 ):
203202 toast = Adw .Toast .new (message )
0 commit comments