[evince] Move New window from App menu to Window menu



commit b14f7e9761bca4e8788802583fb3523b6420546a
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Mon Jul 9 17:12:33 2018 -0400

    Move New window from App menu to Window menu
    
    Get rid off the AppMenu.
    
    Remove "Open" from the window because that is a duplicate
    action of New window, where there is an action to open a
    new document. Additionally, "Open" a document actually
    opens a new window, thus having an explicit action to
    open a new window, and in that window a new document will
    be opened.

 shell/ev-application.c | 34 ++--------------------------------
 shell/ev-application.h |  3 +++
 shell/ev-window.c      | 17 +++++++++++++++++
 shell/evince-menus.ui  | 12 ++++--------
 4 files changed, 26 insertions(+), 40 deletions(-)
---
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 04a61e8e..953964ef 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -646,7 +646,7 @@ ev_application_open_uri_at_dest (EvApplication  *application,
 #endif /* ENABLE_DBUS */
 }
 
-static void
+void
 ev_application_new_window (EvApplication *application,
                           GdkScreen     *screen,
                           guint32        timestamp)
@@ -938,37 +938,11 @@ ev_application_migrate_config_dir (EvApplication *application)
         g_free (old_accels);
 }
 
-static void
-app_new_cb (GSimpleAction *action,
-            GVariant      *parameter,
-            gpointer       user_data)
-{
-       EvApplication *application = user_data;
-        GList         *windows, *l;
-        GtkWindow     *window = NULL;
-
-        windows = gtk_application_get_windows (GTK_APPLICATION (application));
-        for (l = windows; l != NULL; l = l->next) {
-                if (EV_IS_WINDOW (l->data)) {
-                        window = GTK_WINDOW (l->data);
-                        break;
-                }
-        }
-
-       ev_application_new_window (application,
-                                   window ? gtk_window_get_screen (window) : gdk_screen_get_default (),
-                                   gtk_get_current_event_time ());
-}
-
 static void
 ev_application_startup (GApplication *gapplication)
 {
-        const GActionEntry app_menu_actions[] = {
-               { "new",  app_new_cb, NULL, NULL, NULL },
-        };
-
         const gchar *action_accels[] = {
-          "win.open",                   "<Ctrl>O", NULL,
+          "win.win",                    "<Ctrl>O", NULL,
           "win.open-copy",              "<Ctrl>N", NULL,
           "win.save-as",                "<Ctrl>S", NULL,
           "win.print",                  "<Ctrl>P", NULL,
@@ -1017,10 +991,6 @@ ev_application_startup (GApplication *gapplication)
 
         G_APPLICATION_CLASS (ev_application_parent_class)->startup (gapplication);
 
-        g_action_map_add_action_entries (G_ACTION_MAP (application),
-                                         app_menu_actions, G_N_ELEMENTS (app_menu_actions),
-                                         application);
-
         for (it = action_accels; it[0]; it += g_strv_length ((gchar **)it) + 1)
                 gtk_application_set_accels_for_action (GTK_APPLICATION (application), it[0], &it[1]);
 }
diff --git a/shell/ev-application.h b/shell/ev-application.h
index 61c77eee..00a7a18b 100644
--- a/shell/ev-application.h
+++ b/shell/ev-application.h
@@ -70,6 +70,9 @@ GObject                *ev_application_get_media_keys      (EvApplication   *application);
 
 const gchar      *ev_application_get_dot_dir         (EvApplication   *application,
                                                       gboolean         create);
+void              ev_application_new_window          (EvApplication *application,
+                                                      GdkScreen     *screen,
+                                                      guint32        timestamp);
 
 G_END_DECLS
 
diff --git a/shell/ev-window.c b/shell/ev-window.c
index e2b5463a..3a02c2f1 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -2616,6 +2616,22 @@ file_open_dialog_response_cb (GtkWidget *chooser,
        gtk_widget_destroy (chooser);
 }
 
+static void
+ev_window_cmd_new_window (GSimpleAction *action,
+                         GVariant      *parameter,
+                         gpointer       user_data)
+{
+
+       EvWindow  *window = user_data;
+       GdkScreen *screen;
+       guint32    timestamp;
+
+       screen = gtk_window_get_screen (GTK_WINDOW (window));
+        timestamp = gtk_get_current_event_time ();
+
+       ev_application_new_window (EV_APP, screen, timestamp);
+}
+
 static void
 ev_window_cmd_file_open (GSimpleAction *action,
                         GVariant      *parameter,
@@ -5912,6 +5928,7 @@ ev_window_class_init (EvWindowClass *ev_window_class)
 }
 
 static const GActionEntry actions[] = {
+       { "new", ev_window_cmd_new_window },
        { "open", ev_window_cmd_file_open },
        { "open-copy", ev_window_cmd_file_open_copy },
        { "save-as", ev_window_cmd_save_as },
diff --git a/shell/evince-menus.ui b/shell/evince-menus.ui
index a6f81bad..704c86d0 100644
--- a/shell/evince-menus.ui
+++ b/shell/evince-menus.ui
@@ -19,12 +19,6 @@
 -->
 <interface>
   <menu id="app-menu">
-    <section>
-      <item>
-        <attribute name="label" translatable="yes">_New Window</attribute>
-        <attribute name="action">app.new</attribute>
-      </item>
-    </section>
   </menu>
 
   <menu id="action-menu">
@@ -48,9 +42,11 @@
     </section>
     <section>
       <item>
-        <attribute name="label" translatable="yes">_Open…</attribute>
-        <attribute name="action">win.open</attribute>
+        <attribute name="label" translatable="yes">_New Window</attribute>
+        <attribute name="action">win.new</attribute>
       </item>
+    </section>
+    <section>
       <item>
         <attribute name="label" translatable="yes">Op_en a Copy</attribute>
         <attribute name="action">win.open-copy</attribute>


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