[evince] shell: Menu reorganization



commit d7d42efda24045105752d9f7a8adcc46e17a7c20
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Tue Jul 3 13:24:48 2018 -0400

    shell: Menu reorganization
    
    Reduce two "main menu" in the header in one, and distribute
    menu items according to their function:
    * Page info: Nagivational information and actions
    * Zoom info: Zooming information and actions
    * Primary menu: Other actions
    * Remove the view-menu
    
    Reorder the icons, balancing left and right sides of the toolbar.
    Follow major ideas proposed in issue #475:
    https://gitlab.gnome.org/GNOME/evince/issues/475#note_259392

 shell/ev-application.c |  90 +------------------------------
 shell/ev-application.h |   4 --
 shell/ev-toolbar.c     |  35 +++++-------
 shell/ev-window.c      |  88 ++++++++++++++++++++++++++++++
 shell/evince-menus.ui  | 144 ++++++++++++++++++++-----------------------------
 5 files changed, 162 insertions(+), 199 deletions(-)
---
diff --git a/shell/ev-application.c b/shell/ev-application.c
index f173d7a4..04a61e8e 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -960,71 +960,11 @@ app_new_cb (GSimpleAction *action,
                                    gtk_get_current_event_time ());
 }
 
-static void
-app_help_cb (GSimpleAction *action,
-             GVariant      *parameter,
-             gpointer       user_data)
-{
-        EvApplication *application = user_data;
-
-        ev_application_show_help (application, NULL, NULL);
-}
-
-static void
-app_about_cb (GSimpleAction *action,
-              GVariant      *parameter,
-              gpointer       user_data)
-{
-        EvApplication *application = user_data;
-
-        const char *authors[] = {
-                "Martin Kretzschmar <m_kretzschmar gmx net>",
-                "Jonathan Blandford <jrb gnome org>",
-                "Marco Pesenti Gritti <marco gnome org>",
-                "Nickolay V. Shmyrev <nshmyrev yandex ru>",
-                "Bryan Clark <clarkbw gnome org>",
-                "Carlos Garcia Campos <carlosgc gnome org>",
-                "Wouter Bolsterlee <wbolster gnome org>",
-                "Christian Persch <chpe" "\100" "gnome.org>",
-                NULL
-        };
-        const char *documenters[] = {
-                "Nickolay V. Shmyrev <nshmyrev yandex ru>",
-                "Phil Bull <philbull gmail com>",
-                "Tiffany Antpolski <tiffany antopolski gmail com>",
-                NULL
-        };
-#ifdef ENABLE_NLS
-        const char **p;
-
-        for (p = authors; *p; ++p)
-                *p = _(*p);
-
-        for (p = documenters; *p; ++p)
-                *p = _(*p);
-#endif
-
-        gtk_show_about_dialog (gtk_application_get_active_window (GTK_APPLICATION (application)),
-                               "name", _("Evince"),
-                               "version", VERSION,
-                               "copyright", _("© 1996–2017 The Evince authors"),
-                               "license-type", GTK_LICENSE_GPL_2_0,
-                               "website", "https://wiki.gnome.org/Apps/Evince";,
-                               "comments", _("Document Viewer"),
-                               "authors", authors,
-                               "documenters", documenters,
-                               "translator-credits", _("translator-credits"),
-                               "logo-icon-name", "evince",
-                               NULL);
-}
-
 static void
 ev_application_startup (GApplication *gapplication)
 {
         const GActionEntry app_menu_actions[] = {
                { "new",  app_new_cb, NULL, NULL, NULL },
-                { "help", app_help_cb, NULL, NULL, NULL },
-                { "about", app_about_cb, NULL, NULL, NULL }
         };
 
         const gchar *action_accels[] = {
@@ -1065,6 +1005,8 @@ ev_application_startup (GApplication *gapplication)
           "win.rotate-right",           "<Ctrl>Right", NULL,
           "win.inverted-colors",        "<Ctrl>I", NULL,
           "win.reload",                 "<Ctrl>R", NULL,
+          "win.help",                   "F1", NULL,
+          "win.about",                  NULL, NULL,
           NULL
         };
 
@@ -1274,31 +1216,3 @@ ev_application_get_dot_dir (EvApplication *application,
 
        return application->dot_dir;
 }
-
-/**
- * ev_application_show_help:
- * @application: the #EvApplication
- * @screen: (allow-none): a #GdkScreen, or %NULL to use the default screen
- * @topic: (allow-none): the help topic, or %NULL to show the index
- *
- * Launches the help viewer on @screen to show the evince help.
- * If @topic is %NULL, shows the help index; otherwise the topic.
- */
-void
-ev_application_show_help (EvApplication *application,
-                          GdkScreen     *screen,
-                          const char    *topic)
-{
-        char *escaped_topic, *uri;
-
-        if (topic != NULL) {
-                escaped_topic = g_uri_escape_string (topic, NULL, TRUE);
-                uri = g_strdup_printf ("help:evince/%s", escaped_topic);
-                g_free (escaped_topic);
-        } else {
-                uri = g_strdup ("help:evince");
-        }
-
-        gtk_show_uri (screen, uri, gtk_get_current_event_time (), NULL);
-        g_free (uri);
-}
diff --git a/shell/ev-application.h b/shell/ev-application.h
index f81a64f9..61c77eee 100644
--- a/shell/ev-application.h
+++ b/shell/ev-application.h
@@ -71,10 +71,6 @@ GObject               *ev_application_get_media_keys      (EvApplication   *application);
 const gchar      *ev_application_get_dot_dir         (EvApplication   *application,
                                                       gboolean         create);
 
-void              ev_application_show_help           (EvApplication   *application,
-                                                      GdkScreen       *screen,
-                                                      const char      *topic);
-
 G_END_DECLS
 
 #endif /* !EV_APPLICATION_H */
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index 47da0143..ba608d37 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -42,7 +42,6 @@ enum
 struct _EvToolbarPrivate {
         EvWindow  *window;
 
-        GtkWidget *view_menu_button;
         GtkWidget *action_menu_button;
         GtkWidget *zoom_action;
         GtkWidget *page_selector;
@@ -50,6 +49,7 @@ struct _EvToolbarPrivate {
         GtkWidget *find_button;
         GtkWidget *open_button;
         GtkWidget *annots_button;
+        GtkWidget *sidebar_button;
         GMenu *bookmarks_section;
 
         EvToolbarMode toolbar_mode;
@@ -206,6 +206,13 @@ ev_toolbar_constructed (GObject *object)
         ev_toolbar->priv->open_button = button;
         gtk_container_add (GTK_CONTAINER (ev_toolbar), button);
 
+        /* Sidebar */
+        button = ev_toolbar_create_toggle_button (ev_toolbar, "win.show-side-pane",
+                                                  "view-grid-symbolic",
+                                                  _("Side pane"));
+        ev_toolbar->priv->sidebar_button = button;
+        gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), button);
+
         /* Page selector */
         /* Use EvPageActionWidget for now, since the page selector action is also used by the previewer */
         tool_item = ev_page_action_widget_new (G_MENU (gtk_builder_get_object (builder, "navigation-menu")));
@@ -216,12 +223,6 @@ ev_toolbar_constructed (GObject *object)
                                          ev_window_get_document_model (ev_toolbar->priv->window));
         gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), tool_item);
 
-        /* Find */
-        button = ev_toolbar_create_toggle_button (ev_toolbar, "win.toggle-find", "edit-find-symbolic",
-                                                  _("Find a word or phrase in the document"));
-        ev_toolbar->priv->find_button = button;
-        gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), button);
-
         /* Edit Annots */
         button = ev_toolbar_create_toggle_button (ev_toolbar, "win.toggle-edit-annots", 
"document-edit-symbolic",
                                                   _("Annotate the document"));
@@ -238,13 +239,10 @@ ev_toolbar_constructed (GObject *object)
         ev_toolbar->priv->action_menu_button = button;
         gtk_header_bar_pack_end (GTK_HEADER_BAR (ev_toolbar), button);
 
-        /* View Menu */
-        menu = G_MENU_MODEL (gtk_builder_get_object (builder, "view-menu"));
-        button = ev_toolbar_create_menu_button (ev_toolbar, "document-properties-symbolic",
-                                                menu, GTK_ALIGN_END);
-        gtk_widget_set_tooltip_text (button, _("View options"));
-        atk_object_set_name (gtk_widget_get_accessible (button), _("View options"));
-        ev_toolbar->priv->view_menu_button = button;
+        /* Find */
+        button = ev_toolbar_create_toggle_button (ev_toolbar, "win.toggle-find", "edit-find-symbolic",
+                                                  _("Find a word or phrase in the document"));
+        ev_toolbar->priv->find_button = button;
         gtk_header_bar_pack_end (GTK_HEADER_BAR (ev_toolbar), button);
 
         /* Zoom selector */
@@ -264,7 +262,6 @@ ev_toolbar_constructed (GObject *object)
                           G_CALLBACK (ev_toolbar_bookmarks_menu_model_changed),
                           ev_toolbar);
         ev_toolbar_setup_bookmarks_menu (ev_toolbar, bookmarks_submenu_model);
-
         g_object_unref (builder);
 }
 
@@ -333,10 +330,6 @@ ev_toolbar_has_visible_popups (EvToolbar *ev_toolbar)
 
         priv = ev_toolbar->priv;
 
-        popover = gtk_menu_button_get_popover (GTK_MENU_BUTTON (priv->view_menu_button));
-        if (gtk_widget_get_visible (GTK_WIDGET (popover)))
-                return TRUE;
-
         popover = gtk_menu_button_get_popover (GTK_MENU_BUTTON (priv->action_menu_button));
         if (gtk_widget_get_visible (GTK_WIDGET (popover)))
                 return TRUE;
@@ -381,7 +374,7 @@ ev_toolbar_set_mode (EvToolbar     *ev_toolbar,
         switch (mode) {
         case EV_TOOLBAR_MODE_NORMAL:
         case EV_TOOLBAR_MODE_FULLSCREEN:
-                gtk_widget_show (priv->view_menu_button);
+                gtk_widget_show (priv->sidebar_button);
                 gtk_widget_show (priv->action_menu_button);
                 gtk_widget_show (priv->zoom_action);
                 gtk_widget_show (priv->page_selector);
@@ -390,7 +383,7 @@ ev_toolbar_set_mode (EvToolbar     *ev_toolbar,
                 gtk_widget_hide (priv->open_button);
                 break;
        case EV_TOOLBAR_MODE_RECENT_VIEW:
-                gtk_widget_hide (priv->view_menu_button);
+                gtk_widget_hide (priv->sidebar_button);
                 gtk_widget_hide (priv->action_menu_button);
                 gtk_widget_hide (priv->zoom_action);
                 gtk_widget_hide (priv->page_selector);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 6a99f4fb..e964b1b7 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -3816,6 +3816,92 @@ ev_window_cmd_file_close_window (GSimpleAction *action,
                gtk_widget_destroy (GTK_WIDGET (ev_window));
 }
 
+/**
+ * ev_window_show_help:
+ * @window: the #EvWindow
+ * @screen: (allow-none): a #GdkScreen, or %NULL to use the default screen
+ * @topic: (allow-none): the help topic, or %NULL to show the index
+ *
+ * Launches the help viewer on @screen to show the evince help.
+ * If @topic is %NULL, shows the help index; otherwise the topic.
+ */
+static void
+ev_window_show_help (EvWindow   *window,
+                     GdkScreen  *screen,
+                     const char *topic)
+{
+        char *escaped_topic, *uri;
+
+        if (topic != NULL) {
+                escaped_topic = g_uri_escape_string (topic, NULL, TRUE);
+                uri = g_strdup_printf ("help:evince/%s", escaped_topic);
+                g_free (escaped_topic);
+        } else {
+                uri = g_strdup ("help:evince");
+        }
+
+        gtk_show_uri (screen, uri, gtk_get_current_event_time (), NULL);
+        g_free (uri);
+}
+
+static void
+ev_window_cmd_help (GSimpleAction *action,
+                   GVariant      *parameter,
+                   gpointer       user_data)
+{
+       EvWindow *ev_window = user_data;
+
+        ev_window_show_help (ev_window, NULL, NULL);
+}
+
+static void
+ev_window_cmd_about (GSimpleAction *action,
+                    GVariant      *parameter,
+                    gpointer       user_data)
+{
+       EvWindow *ev_window = user_data;
+
+        const char *authors[] = {
+                "Martin Kretzschmar <m_kretzschmar gmx net>",
+                "Jonathan Blandford <jrb gnome org>",
+                "Marco Pesenti Gritti <marco gnome org>",
+                "Nickolay V. Shmyrev <nshmyrev yandex ru>",
+                "Bryan Clark <clarkbw gnome org>",
+                "Carlos Garcia Campos <carlosgc gnome org>",
+                "Wouter Bolsterlee <wbolster gnome org>",
+                "Christian Persch <chpe" "\100" "gnome.org>",
+                NULL
+        };
+        const char *documenters[] = {
+                "Nickolay V. Shmyrev <nshmyrev yandex ru>",
+                "Phil Bull <philbull gmail com>",
+                "Tiffany Antpolski <tiffany antopolski gmail com>",
+                NULL
+        };
+#ifdef ENABLE_NLS
+        const char **p;
+
+        for (p = authors; *p; ++p)
+                *p = _(*p);
+
+        for (p = documenters; *p; ++p)
+                *p = _(*p);
+#endif
+
+        gtk_show_about_dialog (GTK_WINDOW (ev_window),
+                               "name", _("Evince"),
+                               "version", VERSION,
+                               "copyright", _("© 1996–2017 The Evince authors"),
+                               "license-type", GTK_LICENSE_GPL_2_0,
+                               "website", "https://wiki.gnome.org/Apps/Evince";,
+                               "comments", _("Document Viewer"),
+                               "authors", authors,
+                               "documenters", documenters,
+                               "translator-credits", _("translator-credits"),
+                               "logo-icon-name", "evince",
+                               NULL);
+}
+
 static void
 ev_window_cmd_focus_page_selector (GSimpleAction *action,
                                   GVariant      *parameter,
@@ -5881,6 +5967,8 @@ static const GActionEntry actions[] = {
        { "open-menu", ev_window_cmd_action_menu },
        { "caret-navigation", NULL, NULL, "false", ev_window_cmd_view_toggle_caret_navigation },
        { "toggle-edit-annots", NULL, NULL, "false", ev_window_cmd_toggle_edit_annots },
+       { "about", ev_window_cmd_about },
+       { "help", ev_window_cmd_help },
        /* Popups specific items */
        { "annotate-selected-text", ev_window_popup_cmd_annotate_selected_text },
        { "open-link", ev_window_popup_cmd_open_link },
diff --git a/shell/evince-menus.ui b/shell/evince-menus.ui
index 6f7bad70..a6f81bad 100644
--- a/shell/evince-menus.ui
+++ b/shell/evince-menus.ui
@@ -25,113 +25,75 @@
         <attribute name="action">app.new</attribute>
       </item>
     </section>
+  </menu>
+
+  <menu id="action-menu">
     <section>
+      <attribute name="display-hint">horizontal-buttons</attribute>
       <item>
-        <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
-        <attribute name="action">win.show-help-overlay</attribute>
+        <attribute name="label" translatable="yes">_Print…</attribute>
+        <attribute name="action">win.print</attribute>
+        <attribute name="verb-icon">printer-symbolic</attribute>
       </item>
       <item>
-        <attribute name="label" translatable="yes">_Help</attribute>
-        <attribute name="action">app.help</attribute>
-        <attribute name="accel">F1</attribute>
+        <attribute name="label" translatable="yes">_Fullscreen</attribute>
+        <attribute name="action">win.fullscreen</attribute>
+        <attribute name="verb-icon">view-fullscreen-symbolic</attribute>
       </item>
       <item>
-        <attribute name="label" translatable="yes">_About</attribute>
-        <attribute name="action">app.about</attribute>
+        <attribute name="label" translatable="yes">Send _To…</attribute>
+        <attribute name="action">win.send-to</attribute>
+        <attribute name="verb-icon">send-to-symbolic</attribute>
       </item>
     </section>
-  </menu>
-
-  <menu id="view-menu">
     <section>
       <item>
-        <attribute name="label" translatable="yes">_Continuous</attribute>
-        <attribute name="action">win.continuous</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">_Dual</attribute>
-        <attribute name="action">win.dual-page</attribute>
+        <attribute name="label" translatable="yes">_Open…</attribute>
+        <attribute name="action">win.open</attribute>
       </item>
-    </section>
-    <section>
       <item>
-        <attribute name="label" translatable="yes">Side _Pane</attribute>
-        <attribute name="action">win.show-side-pane</attribute>
+        <attribute name="label" translatable="yes">Op_en a Copy</attribute>
+        <attribute name="action">win.open-copy</attribute>
       </item>
-    </section>
-    <section>
       <item>
-        <attribute name="label" translatable="yes">_Fullscreen</attribute>
-        <attribute name="action">win.fullscreen</attribute>
+        <attribute name="label" translatable="yes">_Save As…</attribute>
+        <attribute name="action">win.save-as</attribute>
       </item>
       <item>
-        <attribute name="label" translatable="yes">Pre_sentation</attribute>
-        <attribute name="action">win.presentation</attribute>
+        <attribute name="label" translatable="yes">Open Containing _Folder</attribute>
+        <attribute name="action">win.open-containing-folder</attribute>
       </item>
     </section>
     <section>
       <item>
-        <attribute name="label" translatable="yes">Rotat_e ⤴</attribute>
-        <attribute name="action">win.rotate-left</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Rota_te ⤵</attribute>
-        <attribute name="action">win.rotate-right</attribute>
+        <attribute name="label" translatable="yes">Pre_sent as Slideshow</attribute>
+        <attribute name="action">win.presentation</attribute>
       </item>
     </section>
     <section>
       <item>
-        <attribute name="label" translatable="yes">Zoom _In</attribute>
-        <attribute name="action">win.zoom-in</attribute>
+        <attribute name="label" translatable="yes">_Continuous</attribute>
+        <attribute name="action">win.continuous</attribute>
       </item>
       <item>
-        <attribute name="label" translatable="yes">Zoom _Out</attribute>
-        <attribute name="action">win.zoom-out</attribute>
+        <attribute name="label" translatable="yes">_Dual</attribute>
+        <attribute name="action">win.dual-page</attribute>
       </item>
-    </section>
-    <section>
       <item>
         <attribute name="label" translatable="yes">_Odd Pages Left</attribute>
         <attribute name="action">win.dual-odd-left</attribute>
       </item>
-      <item>
-        <attribute name="label" translatable="yes">_Inverted Colors</attribute>
-        <attribute name="action">win.inverted-colors</attribute>
-      </item>
     </section>
     <section>
       <item>
-        <attribute name="label" translatable="yes">_Reload</attribute>
-        <attribute name="action">win.reload</attribute>
+        <attribute name="label" translatable="yes">_Rotate ⤵</attribute>
+        <attribute name="action">win.rotate-right</attribute>
       </item>
     </section>
-  </menu>
-
-  <menu id="action-menu">
     <section>
       <item>
-        <attribute name="label" translatable="yes">_Open…</attribute>
-        <attribute name="action">win.open</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Op_en a Copy</attribute>
-        <attribute name="action">win.open-copy</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">_Save As…</attribute>
-        <attribute name="action">win.save-as</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Send _To…</attribute>
-        <attribute name="action">win.send-to</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Open Containing _Folder</attribute>
-        <attribute name="action">win.open-containing-folder</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">_Print…</attribute>
-        <attribute name="action">win.print</attribute>
+        <attribute name="label" translatable="yes">_Night Mode</attribute>
+        <attribute name="action">win.inverted-colors</attribute>
       </item>
     </section>
     <section>
@@ -142,35 +104,39 @@
     </section>
     <section>
       <item>
-        <attribute name="label" translatable="yes">_Copy</attribute>
-        <attribute name="action">win.copy</attribute>
+        <attribute name="label" translatable="yes">Save Current Settings as _Default</attribute>
+        <attribute name="action">win.save-settings</attribute>
       </item>
       <item>
-        <attribute name="label" translatable="yes">Select _All</attribute>
-        <attribute name="action">win.select-all</attribute>
+        <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+        <attribute name="action">win.show-help-overlay</attribute>
       </item>
-    </section>
-    <section>
       <item>
-        <attribute name="label" translatable="yes">Save Current Settings as _Default</attribute>
-        <attribute name="action">win.save-settings</attribute>
+        <attribute name="label" translatable="yes">_Help</attribute>
+        <attribute name="action">win.help</attribute>
+        <attribute name="accel">F1</attribute>
       </item>
-    </section>
-    <section id="bookmarks">
       <item>
-        <attribute name="label" translatable="yes">_Add Bookmark</attribute>
-        <attribute name="action">win.add-bookmark</attribute>
+        <attribute name="label" translatable="yes">_About</attribute>
+        <attribute name="action">win.about</attribute>
       </item>
     </section>
+  </menu>
+
+  <menu id="zoom-menu">
     <section>
+      <attribute name="display-hint">horizontal-buttons</attribute>
       <item>
-        <attribute name="label" translatable="yes">_Close</attribute>
-        <attribute name="action">win.close</attribute>
+        <attribute name="label" translatable="yes">Zoom _In</attribute>
+        <attribute name="action">win.zoom-in</attribute>
+        <attribute name="verb-icon">zoom-in-symbolic</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Zoom _Out</attribute>
+        <attribute name="action">win.zoom-out</attribute>
+        <attribute name="verb-icon">zoom-out-symbolic</attribute>
       </item>
     </section>
-  </menu>
-
-  <menu id="zoom-menu">
     <section>
       <item>
         <attribute name="label" translatable="yes">Fit Pa_ge</attribute>
@@ -323,6 +289,12 @@
         <attribute name="action">win.go-forward-history</attribute>
       </item>
     </section>
+    <section id="bookmarks">
+      <item>
+        <attribute name="label" translatable="yes">_Add Bookmark</attribute>
+        <attribute name="action">win.add-bookmark</attribute>
+      </item>
+    </section>
   </menu>
 
   <menu id="attachments-popup">


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