[evince] shell: Make F10 toggle the main menu



commit 94dbcb3313d9d8494d1f5ada66d92542e585d0b7
Author: herypt <70331266+herypt users noreply github com>
Date:   Fri Oct 2 16:30:00 2020 +0200

    shell: Make F10 toggle the main menu
    
    Before it only opened the main menu, but didn't close it.
    
    Closes #1328

 shell/ev-application.c | 2 +-
 shell/ev-toolbar.c     | 6 ++++--
 shell/ev-toolbar.h     | 2 +-
 shell/ev-window.c      | 6 +++---
 shell/help-overlay.ui  | 2 +-
 5 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 2085ba60..ed6ea70f 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -968,7 +968,7 @@ ev_application_startup (GApplication *gapplication)
           "win.sizing-mode::fit-width", "w", NULL,
           "win.sizing-mode::automatic", "a", NULL,
           "win.default-zoom",           "<Ctrl>0", NULL,
-          "win.open-menu",              "F10", NULL,
+          "win.toggle-menu",            "F10", NULL,
           "win.caret-navigation",       "F7", NULL,
           "win.zoom-in",                "plus", "<Ctrl>plus", "KP_Add", "<Ctrl>KP_Add", "equal", 
"<Ctrl>equal", NULL,
           "win.zoom-out",               "minus", "<Ctrl>minus", "KP_Subtract", "<Ctrl>KP_Subtract", NULL,
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index a91c7c86..4e384342 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -321,16 +321,18 @@ ev_toolbar_has_visible_popups (EvToolbar *ev_toolbar)
 }
 
 void
-ev_toolbar_action_menu_popup (EvToolbar *ev_toolbar)
+ev_toolbar_action_menu_toggle (EvToolbar *ev_toolbar)
 {
        EvToolbarPrivate *priv;
+       gboolean is_active;
 
         g_return_if_fail (EV_IS_TOOLBAR (ev_toolbar));
 
         priv = GET_PRIVATE (ev_toolbar);
+        is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->action_menu_button));
 
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->action_menu_button),
-                                      TRUE);
+                                      !is_active);
 }
 
 GtkWidget *
diff --git a/shell/ev-toolbar.h b/shell/ev-toolbar.h
index b278e9dc..97cd5c66 100644
--- a/shell/ev-toolbar.h
+++ b/shell/ev-toolbar.h
@@ -53,7 +53,7 @@ struct _EvToolbarClass {
 GType         ev_toolbar_get_type           (void);
 GtkWidget    *ev_toolbar_new                (EvWindow *window);
 gboolean      ev_toolbar_has_visible_popups (EvToolbar *ev_toolbar);
-void          ev_toolbar_action_menu_popup  (EvToolbar *ev_toolbar);
+void          ev_toolbar_action_menu_toggle (EvToolbar *ev_toolbar);
 GtkWidget    *ev_toolbar_get_page_selector  (EvToolbar *ev_toolbar);
 void          ev_toolbar_set_mode           (EvToolbar     *ev_toolbar,
                                             EvToolbarMode  mode);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 69602ca6..4b47a014 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -571,7 +571,7 @@ ev_window_update_actions_sensitivity (EvWindow *ev_window)
        ev_window_set_action_enabled (ev_window, "sizing-mode", !recent_view_mode);
        ev_window_set_action_enabled (ev_window, "zoom", !recent_view_mode);
        ev_window_set_action_enabled (ev_window, "escape", !recent_view_mode);
-       ev_window_set_action_enabled (ev_window, "open-menu", !recent_view_mode);
+       ev_window_set_action_enabled (ev_window, "toggle-menu", !recent_view_mode);
 
        /* Don't enable popup actions here because the page can change while a
         * popup is visible due to kinetic scrolling. The 'popup' functions
@@ -5515,7 +5515,7 @@ ev_window_cmd_action_menu (GSimpleAction *action,
        EvToolbar *toolbar;
 
        toolbar = priv->fs_toolbar ? EV_TOOLBAR (priv->fs_toolbar) : EV_TOOLBAR (priv->toolbar);
-       ev_toolbar_action_menu_popup (toolbar);
+       ev_toolbar_action_menu_toggle (toolbar);
 }
 
 static void
@@ -6488,7 +6488,7 @@ static const GActionEntry actions[] = {
        { "zoom", ev_window_cmd_view_zoom, "d" },
        { "default-zoom", ev_window_cmd_set_default_zoom },
        { "escape", ev_window_cmd_escape },
-       { "open-menu", ev_window_cmd_action_menu },
+       { "toggle-menu", ev_window_cmd_action_menu },
        { "caret-navigation", NULL, NULL, "false", ev_window_cmd_view_toggle_caret_navigation },
        { "add-annotation", NULL, NULL, "false", ev_window_cmd_add_annotation },
        { "highlight-annotation", NULL, NULL, "false", ev_window_cmd_add_highlight_annotation },
diff --git a/shell/help-overlay.ui b/shell/help-overlay.ui
index f12c2190..d2057348 100644
--- a/shell/help-overlay.ui
+++ b/shell/help-overlay.ui
@@ -378,7 +378,7 @@
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
-                <property name="title" translatable="yes" context="shortcut window">Show primary 
menu</property>
+                <property name="title" translatable="yes" context="shortcut window">Toggle primary 
menu</property>
                 <property name="accelerator">F10</property>
               </object>
             </child>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]