diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2019-10-10 10:34:22 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2019-10-10 10:37:54 +0200 |
| commit | 0f56dd918b022c84cba63a810c75a386a7fe38b3 (patch) | |
| tree | 2bc4458beba3f671d7c6c146301cd40db09ef1a1 /guiconfig.py | |
| parent | e016deb4bbfae014ada1808abaeeb30558cac209 (diff) | |
guiconfig: Check for visible nodes before turning off show-all in full-tree mode
If there are no visible nodes in the entire tree, guiconfig
automatically starts in show-all mode. Previously, there was no check
for visible nodes when turning off show-all in full-tree mode in this
case, leading to errors.
Fix it by checking if there are any visible nodes in the top menu when
turning off show-all in full-tree mode. If there aren't, show-all stays
on.
Diffstat (limited to 'guiconfig.py')
| -rwxr-xr-x | guiconfig.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/guiconfig.py b/guiconfig.py index 20ecfa1..d333be4 100755 --- a/guiconfig.py +++ b/guiconfig.py @@ -1475,9 +1475,8 @@ def _toggle_showall(_): def _do_showall(): # Updates the UI for the current show-all setting - # Don't allow turning off show-all if we're in single-menu mode and the - # current menu would become empty - if _single_menu and not _shown_menu_nodes(_cur_menu): + # Don't allow turning off show-all if we'd end up with no visible nodes + if _nothing_shown(): _show_all_var.set(True) return @@ -1512,6 +1511,17 @@ def _do_showall(): _tree.focus_set() +def _nothing_shown(): + # _do_showall() helper. Returns True if no nodes would get + # shown with the current show-all setting. Also handles the + # (obscure) case when there are no visible nodes in the entire + # tree, meaning guiconfig was automatically started in + # show-all mode, which mustn't be turned off. + + return not _shown_menu_nodes( + _cur_menu if _single_menu else _kconf.top_node) + + def _toggle_tree_mode(_): # Toggles single-menu mode on/off |
