[PATCH] Open help when F1 is pressed

David Shea dshea at redhat.com
Thu Aug 14 20:21:09 UTC 2014


On 08/14/2014 11:33 AM, Martin Kolman wrote:
> Signed-off-by: Martin Kolman <mkolman at redhat.com>
> ---
>   pyanaconda/ui/gui/__init__.py | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
> index 7188aa6..1e5fee2 100644
> --- a/pyanaconda/ui/gui/__init__.py
> +++ b/pyanaconda/ui/gui/__init__.py
> @@ -286,6 +286,10 @@ class MainWindow(Gtk.Window):
>           # maxmizes/unmaximizes the window.
>           self.connect("window-state-event", self._on_window_state_event)
>   
> +        # Connect to the key press event so that we can open help for the
> +        # current screen when the user presses F1
> +        self.connect("key-release-event", self._on_key_released)
> +
>           # Start the window as full screen
>           self.fullscreen()
>   
> @@ -331,6 +335,15 @@ class MainWindow(Gtk.Window):
>   
>           return True
>   
> +    def _on_key_released(self, window, event):
> +        """Show help for the current screen when the F1 key is pressed"""
> +        if event.keyval != Gdk.KEY_F1:
> +            return
> +
> +        # the help button has been clicked, start the yelp viewer with
> +        # content for the current screen
> +        ihelp.start_yelp(ihelp.get_help_path(window.current_action.helpFile))
> +
>       @property
>       def current_action(self):
>           return self._current_action

current_action corresponds to GUI._currentAction, so it's the current 
active hub, not the current spoke. There is no property currently for 
the current active hub or spoke, so you may want to add one that gets 
set in _setVisibleChild. You can also use the accelerator group that 
gets manipulated in _setVisibleChild to just connect F1 to the help 
button signal and not have to duplicate that signal handler code.


More information about the anaconda-patches mailing list