[master 1/1] Fix the help button mnemonic display on spokes

dashea installerbot-noreply at redhat.com
Wed Mar 4 15:24:30 UTC 2015


From: David Shea <dshea at redhat.com>

Setup the help button label modifier every time the screen changes
instead of only when entering a hub or standalone spoke.
---
 pyanaconda/ui/gui/__init__.py | 55 +++++++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 25 deletions(-)

diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index 8b88484..e4e22e1 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -328,6 +328,11 @@ def __init__(self, fullscreen):
 
         self._current_action = None
 
+        # Help button mnemonics handling
+        self._mnemonic_signal = None
+        # we have a sensible initial value, just in case
+        self._saved_help_button_label = _("Help!")
+
     def _on_delete_event(self, widget, event, user_data=None):
         # Use the quit-clicked signal on the the current standalone, even if the
         # standalone is not currently displayed.
@@ -347,6 +352,20 @@ def _on_overlay_get_child_position(self, overlay_container, overlayed_widget, al
         # Return False to indicate that the child allocation is not yet set
         return False
 
+    def _on_mnemonics_visible_changed(self, window, property_type, obj):
+        # mnemonics display has been activated or deactivated,
+        # add or remove the F1 mnemonics display from the help button
+        help_button = obj.window.get_help_button()
+        if window.props.mnemonics_visible:
+            # save current label
+            old_label = help_button.get_label()
+            self._saved_help_button_label = old_label
+            # add the (F1) "mnemonics" to the help button
+            help_button.set_label("%s (F1)" % old_label)
+        else:
+            # restore the old label
+            help_button.set_label(self._saved_help_button_label)
+
     @property
     def current_action(self):
         return self._current_action
@@ -370,17 +389,20 @@ def _setVisibleChild(self, child):
         if isinstance(child.window, AnacondaWidgets.BaseStandalone):
             child.window.add_accelerator("continue-clicked", self._accel_group,
                     Gdk.KEY_F12, 0, 0)
-            child.window.add_accelerator("help-button-clicked", self._accel_group,
-                    Gdk.KEY_F1, 0, 0)
-            child.window.add_accelerator("help-button-clicked", self._accel_group,
-                    Gdk.KEY_F1, Gdk.ModifierType.MOD1_MASK, 0)
         elif isinstance(child.window, AnacondaWidgets.SpokeWindow):
             child.window.add_accelerator("button-clicked", self._accel_group,
                     Gdk.KEY_F12, 0, 0)
-            child.window.add_accelerator("help-button-clicked", self._accel_group,
-                    Gdk.KEY_F1, 0, 0)
-            child.window.add_accelerator("help-button-clicked", self._accel_group,
-                    Gdk.KEY_F1, Gdk.ModifierType.MOD1_MASK, 0)
+
+        # Configure the help button
+        child.window.add_accelerator("help-button-clicked", self._accel_group,
+                Gdk.KEY_F1, 0, 0)
+        child.window.add_accelerator("help-button-clicked", self._accel_group,
+                Gdk.KEY_F1, Gdk.ModifierType.MOD1_MASK, 0)
+
+        # Connect to mnemonics-visible to add the (F1) mnemonic to the button label
+        if self._mnemonic_signal:
+            self.disconnect(self._mnemonic_signal)
+        self._mnemonic_signal = self.connect("notify::mnemonics-visible", self._on_mnemonics_visible_changed, child)
 
         self._stack.set_visible_child(child.window)
 
@@ -479,8 +501,6 @@ def __init__(self, storage, payload, instclass,
                                     self.mainWindow.lightbox_on)
 
         ANACONDA_WINDOW_GROUP.add_window(self.mainWindow)
-        # we have a sensible initial value, just in case
-        self._saved_help_button_label = _("Help!")
 
     basemask = "pyanaconda.ui"
     basepath = os.path.dirname(__file__)
@@ -631,7 +651,6 @@ def _instantiateAction(self, actionClass):
         # Use connect_after so classes can add actions before we change screens
         obj.window.connect_after("continue-clicked", self._on_continue_clicked)
         obj.window.connect_after("help-button-clicked", self._on_help_clicked, obj)
-        self.mainWindow.connect("notify::mnemonics-visible", self._on_mnemonics_visible_changed, obj)
         obj.window.connect_after("quit-clicked", self._on_quit_clicked)
 
         return obj
@@ -817,20 +836,6 @@ def _on_help_clicked(self, window, obj):
         # content for the current screen
         ihelp.start_yelp(ihelp.get_help_path(obj.helpFile, self.instclass))
 
-    def _on_mnemonics_visible_changed(self, window, property_type, obj):
-        # mnemonics display has been activated or deactivated,
-        # add or remove the F1 mnemonics display from the help button
-        help_button = obj.window.get_help_button()
-        if window.props.mnemonics_visible:
-            # save current label
-            old_label = help_button.get_label()
-            self._saved_help_button_label = old_label
-            # add the (F1) "mnemonics" to the help button
-            help_button.set_label("%s (F1)" % old_label)
-        else:
-            # restore the old label
-            help_button.set_label(self._saved_help_button_label)
-
     def _on_quit_clicked(self, win, userData=None):
         if not win.get_quit_button():
             return


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/1646e32f0060a2f0bf02f2babbb6f9ec2843570c


More information about the anaconda-patches mailing list