Skip to content

Commit f8fd757

Browse files
committed
fix: update back functionality
1 parent da021c7 commit f8fd757

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/builder_page.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

src/builder_page.ui

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
<!-- Back: navigates to FormConfig, pre-seeding the saved JSON -->
8989
<object class="GtkButton" id="back_button">
9090
<property name="halign">fill</property>
91-
<property name="sensitive">0</property>
9291
<property name="tooltip-text" translatable="yes">Go back to the forms page with this config selected</property>
9392
<signal name="clicked" handler="on_back_clicked"/>
9493
<property name="child">

0 commit comments

Comments
 (0)