From 5fa1e44f16b83d1e3bcc2ba5bfe466fd4132c077 Mon Sep 17 00:00:00 2001 From: alfrix Date: Thu, 3 Aug 2023 15:53:26 -0300 Subject: [PATCH] main_menu: allow closing the keypad with the back button --- panels/base_panel.py | 11 +++++------ panels/main_menu.py | 11 +++++++++++ screen.py | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/panels/base_panel.py b/panels/base_panel.py index a33fc76c..01a45776 100644 --- a/panels/base_panel.py +++ b/panels/base_panel.py @@ -63,6 +63,7 @@ class BasePanel(ScreenPanel): self.action_bar.add(self.control['back']) self.action_bar.add(self.control['home']) self.show_back(False) + self.show_home(False) if self.buttons_showing['printer_select']: self.action_bar.add(self.control['printer_select']) self.show_macro_shortcut(self._config.get_main_config().getboolean('side_macro_shortcut', True)) @@ -255,12 +256,10 @@ class BasePanel(ScreenPanel): self.content.remove(widget) def show_back(self, show=True): - if show: - self.control['back'].set_sensitive(True) - self.control['home'].set_sensitive(True) - return - self.control['back'].set_sensitive(False) - self.control['home'].set_sensitive(False) + self.control['back'].set_sensitive(show) + + def show_home(self, show=True): + self.control['home'].set_sensitive(show) def show_macro_shortcut(self, show=True): if show is True and self.buttons_showing['macros_shortcut'] is False: diff --git a/panels/main_menu.py b/panels/main_menu.py index 549e5797..f0360e24 100644 --- a/panels/main_menu.py +++ b/panels/main_menu.py @@ -22,6 +22,7 @@ class Panel(MenuPanel): self.main_menu.set_vexpand(True) self.graph_retry = 0 scroll = self._gtk.ScrolledWindow() + self.numpad_visible = False logging.info("### Making MainMenu") @@ -263,6 +264,8 @@ class Panel(MenuPanel): self.main_menu.remove_column(1) self.main_menu.attach(self.labels['menu'], 1, 0, 1, 1) self.main_menu.show_all() + self.numpad_visible = False + self._screen.base_panel.show_back(False) def process_update(self, action, data): if action != "notify_status_update": @@ -297,7 +300,15 @@ class Panel(MenuPanel): self.main_menu.remove_column(1) self.main_menu.attach(self.labels["keypad"], 1, 0, 1, 1) self.main_menu.show_all() + self.numpad_visible = True + self._screen.base_panel.show_back(True) def update_graph(self): self.labels['da'].queue_draw() return True + + def back(self): + if self.numpad_visible: + self.hide_numpad() + return True + return False diff --git a/screen.py b/screen.py index 37a51772..7a020514 100755 --- a/screen.py +++ b/screen.py @@ -300,6 +300,7 @@ class KlipperScreen(Gtk.Window): self.base_panel.add_content(self.panels[panel]) logging.debug(f"Current panel hierarchy: {' > '.join(self._cur_panels)}") self.base_panel.show_back(len(self._cur_panels) > 1) + self.base_panel.show_home(len(self._cur_panels) > 1) if hasattr(self.panels[panel], "process_update"): self.process_update("notify_status_update", self.printer.data) self.process_update("notify_busy", self.printer.busy)