[PATCH 2/3] Support display of the custom mnemonics on the help button

Martin Kolman mkolman at redhat.com
Wed Sep 17 13:28:26 UTC 2014


Help can be displayed by pressing the F1 key, so show the
F1 key as mnemonics on the help button if alt is pressed.

Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
 pyanaconda/ui/gui/__init__.py | 17 +++++++++++++++++
 widgets/src/BaseWindow.c      | 14 ++++++++++++++
 widgets/src/BaseWindow.h      |  1 +
 3 files changed, 32 insertions(+)

diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index 4ce1281..0ee482b 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -445,6 +445,8 @@ class GraphicalUserInterface(UserInterface):
                                     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__)
@@ -548,6 +550,7 @@ class GraphicalUserInterface(UserInterface):
         # 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
@@ -714,6 +717,20 @@ class GraphicalUserInterface(UserInterface):
         # content for the current screen
         ihelp.start_yelp(ihelp.get_help_path(obj.helpFile, self.instclass))
 
+    def _on_mnemonics_visible_changed(self, window, property, 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
diff --git a/widgets/src/BaseWindow.c b/widgets/src/BaseWindow.c
index 4611631..4793ce7 100644
--- a/widgets/src/BaseWindow.c
+++ b/widgets/src/BaseWindow.c
@@ -491,6 +491,20 @@ GtkWidget *anaconda_base_window_get_nav_area(AnacondaBaseWindow *win) {
 }
 
 /**
+ * anaconda_base_window_get_help_button:
+ * @win: a #AnacondaBaseWindow
+ *
+ * Returns the help button.
+ *
+ * Returns: (transfer none): the help button
+ *
+ * Since: 3.1
+ */
+GtkWidget *anaconda_base_window_get_help_button(AnacondaBaseWindow *win) {
+    return win->priv->help_button;
+}
+
+/**
  * anaconda_base_window_get_nav_area_background_window:
  * @win: a #AnacondaBaseWindow
  *
diff --git a/widgets/src/BaseWindow.h b/widgets/src/BaseWindow.h
index 19891c1..0e29df9 100644
--- a/widgets/src/BaseWindow.h
+++ b/widgets/src/BaseWindow.h
@@ -84,6 +84,7 @@ GtkWidget  *anaconda_base_window_get_alignment     (AnacondaBaseWindow *win);
 GtkWidget  *anaconda_base_window_get_main_box      (AnacondaBaseWindow *win);
 GtkWidget  *anaconda_base_window_get_nav_area      (AnacondaBaseWindow *win);
 GtkWidget  *anaconda_base_window_get_nav_area_background_window (AnacondaBaseWindow *win);
+GtkWidget  *anaconda_base_window_get_help_button (AnacondaBaseWindow *win);
 
 G_END_DECLS
 
-- 
1.9.3



More information about the anaconda-patches mailing list