refactor(settings): consolidate dialog guard flags and widget construction (#878)
* refactor(settings): consolidate dialog guard flags and widget construction The settings dialog grew the same work in several places. This gathers the shared pieces into module helpers with no behavior change: - _suppressed(): a context manager for the try/finally flag dance the handlers used to open-code for _populating_models, _processing_language_change, _simple_syncing, and _simple_driving. The apply-guard handoff and the nested resync keep their explicit save/restore because they do not fit a lexical block. - _handlers_suppressed(): one name for the "initializing or applying" check every handler repeated on entry. - _set_no_show_all_visible(): the clear-flag / show / re-arm sequence for rows created hidden, used by the second-language row and the custom-shortcut row. - _add_switch_row(), _combo_chrome(), _new_spin(), _connect_picker_entry(): the repeated switch-row, tooltip + scroll-guard, spin-button, and picker-entry wiring. - _undownloaded_model_info() and _make_download_dialog(): the per-engine download gate both apply paths carried verbatim. Flags stay plain booleans and helpers stay module-level so existing tests keep working unchanged. * fix(settings): annotate download dialog builder and align visibility docs --------- Co-authored-by: Jatin K Malik <jatinkrmalik@gmail.com>
This commit is contained in:
co-authored by
Jatin K Malik
parent
ba721779c3
commit
004696bbe0
+420
-440
File diff suppressed because it is too large
Load Diff
@@ -145,8 +145,13 @@ class TestSettingsDialogShortcutsSection(unittest.TestCase):
|
||||
helper_start = self.source_code.index("def _set_custom_shortcut_row_visible")
|
||||
helper_end = self.source_code.index("\n def ", helper_start + 1)
|
||||
helper = self.source_code[helper_start:helper_end]
|
||||
self.assertIn("set_no_show_all(False)", helper)
|
||||
self.assertIn("show_all()", helper)
|
||||
self.assertIn("_set_no_show_all_visible(self.custom_shortcut_row, visible)", helper)
|
||||
# The shared helper itself must do the clear-then-show dance.
|
||||
shared_start = self.source_code.index("def _set_no_show_all_visible")
|
||||
shared_end = self.source_code.index("\ndef ", shared_start + 1)
|
||||
shared = self.source_code[shared_start:shared_end]
|
||||
self.assertIn("set_no_show_all(False)", shared)
|
||||
self.assertIn("show_all()", shared)
|
||||
# Call sites must go through the helper, not bare show_all on the row.
|
||||
outside = self.source_code[:helper_start] + self.source_code[helper_end:]
|
||||
self.assertNotIn("self.custom_shortcut_row.show_all()", outside)
|
||||
|
||||
Reference in New Issue
Block a user