[evince] shell: Move recent view to the App Menu



commit 906f3d2fa4a6f3c2d710eb5116b973e728a83a3f
Author: José Aliste <jaliste src gnome org>
Date:   Fri Aug 15 09:42:40 2014 -0400

    shell: Move recent view to the App Menu
    
    - Present the recent view only for empty new window.
    - Add a "New Window" action to the App Menu to create
    new empty windows.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732289

 shell/ev-application.c |   32 ++++++++++++++++++++++++++++++++
 shell/ev-toolbar.c     |   15 ---------------
 shell/ev-window.c      |   34 ----------------------------------
 shell/evince-menus.ui  |    4 ++++
 4 files changed, 36 insertions(+), 49 deletions(-)
---
diff --git a/shell/ev-application.c b/shell/ev-application.c
index c6d579a..6816c33 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -642,6 +642,15 @@ ev_application_open_uri_at_dest (EvApplication  *application,
 #endif /* ENABLE_DBUS */
 }
 
+static void
+ev_application_new_window (EvApplication *application,
+                          GdkScreen     *screen,
+                          guint32        timestamp)
+{
+        /* spawn an empty window */
+       ev_spawn (NULL, screen, NULL, EV_WINDOW_MODE_NORMAL, NULL, timestamp);
+}
+
 /**
  * ev_application_open_recent_view:
  * @application: The instance of the application.
@@ -931,6 +940,28 @@ ev_application_migrate_config_dir (EvApplication *application)
 }
 
 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
 app_help_cb (GSimpleAction *action,
              GVariant      *parameter,
              gpointer       user_data)
@@ -1012,6 +1043,7 @@ 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 }
         };
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index 4c586e2..34fa586 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -50,7 +50,6 @@ struct _EvToolbarPrivate {
         GtkWidget *page_selector;
         GtkWidget *navigation_action;
         GtkWidget *find_button;
-        GtkWidget *recent_view_button;
         GtkWidget *open_button;
         GMenu *bookmarks_section;
 
@@ -200,17 +199,6 @@ ev_toolbar_constructed (GObject *object)
 
         builder = gtk_builder_new_from_resource ("/org/gnome/evince/shell/ui/menus.ui");
 
-        /* View of recent items */
-        button = ev_toolbar_create_toggle_button (ev_toolbar, "win.recent-view",
-                                                  "view-grid-symbolic",
-                                                  _("Toggle between view of recent items and open 
document"));
-        ev_toolbar->priv->recent_view_button = button;
-        if (rtl)
-                gtk_widget_set_margin_left (button, 6);
-        else
-                gtk_widget_set_margin_right (button, 6);
-        gtk_container_add (GTK_CONTAINER (ev_toolbar), button);
-
         button = ev_toolbar_create_button (ev_toolbar, "win.open",
                                            "document-open-symbolic",
                                            _("Open an existing document"));
@@ -392,7 +380,6 @@ ev_toolbar_set_mode (EvToolbar     *ev_toolbar,
                 gtk_widget_show (priv->zoom_action);
                 gtk_widget_show (priv->page_selector);
                 gtk_widget_show (priv->find_button);
-                gtk_widget_show (priv->recent_view_button);
                 gtk_widget_hide (priv->open_button);
                 break;
         case EV_TOOLBAR_MODE_FULLSCREEN:
@@ -402,7 +389,6 @@ ev_toolbar_set_mode (EvToolbar     *ev_toolbar,
                 gtk_widget_show (priv->zoom_action);
                 gtk_widget_show (priv->page_selector);
                 gtk_widget_show (priv->find_button);
-                gtk_widget_hide (priv->recent_view_button);
                 gtk_widget_hide (priv->open_button);
                 break;
        case EV_TOOLBAR_MODE_RECENT_VIEW:
@@ -412,7 +398,6 @@ ev_toolbar_set_mode (EvToolbar     *ev_toolbar,
                 gtk_widget_hide (priv->zoom_action);
                 gtk_widget_hide (priv->page_selector);
                 gtk_widget_hide (priv->find_button);
-                gtk_widget_show (priv->recent_view_button);
                 gtk_widget_show (priv->open_button);
                 break;
         }
diff --git a/shell/ev-window.c b/shell/ev-window.c
index f53e994..06533e3 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -424,7 +424,6 @@ ev_window_update_actions_sensitivity (EvWindow *ev_window)
        gboolean can_find = FALSE;
        gboolean can_find_in_page = FALSE;
        gboolean presentation_mode;
-       gboolean fullscreen_mode;
        gboolean recent_view_mode;
        gboolean dual_mode = FALSE;
        gboolean has_pages = FALSE;
@@ -477,7 +476,6 @@ ev_window_update_actions_sensitivity (EvWindow *ev_window)
 
        /* Get modes */
        presentation_mode = EV_WINDOW_IS_PRESENTATION (ev_window);
-       fullscreen_mode = ev_document_model_get_fullscreen (ev_window->priv->model);
        recent_view_mode = ev_window_is_recent_view (ev_window);
 
        /* File menu */
@@ -528,10 +526,6 @@ ev_window_update_actions_sensitivity (EvWindow *ev_window)
                                      has_pages && ev_window->priv->bookmarks &&
                                      !recent_view_mode);
 
-       /* Recent View */
-       ev_window_set_action_enabled (ev_window, "recent-view", has_document &&
-                                     !fullscreen_mode);
-
        /* Other actions that must be disabled in recent view, in
         * case they have a shortcut or gesture associated
         */
@@ -4618,21 +4612,6 @@ ev_window_cmd_go_backwards (GSimpleAction *action,
        }
 }
 
-static void
-ev_window_cmd_toggle_recent_view (GSimpleAction *action,
-                                  GVariant      *state,
-                                  gpointer      user_data)
-{
-       EvWindow *ev_window = user_data;
-
-       if (g_variant_get_boolean (state))
-               ev_window_show_recent_view (ev_window);
-       else
-               ev_window_hide_recent_view (ev_window);
-
-       g_simple_action_set_state (action, state);
-}
-
 static gint
 compare_bookmarks (EvBookmark *a,
                   EvBookmark *b)
@@ -5124,17 +5103,6 @@ recent_view_item_activated_cb (EvRecentView *recent_view,
                                const char   *uri,
                                EvWindow     *ev_window)
 {
-       GAction *action;
-
-       if (g_strcmp0 (ev_window->priv->uri, uri) == 0) {
-               ev_window_hide_recent_view (ev_window);
-               action = g_action_map_lookup_action (G_ACTION_MAP (ev_window),
-                                                    "recent-view");
-               g_simple_action_set_state (G_SIMPLE_ACTION (action),
-                                          g_variant_new_boolean (FALSE));
-               return;
-       }
-
        ev_application_open_uri_at_dest (EV_APP, uri,
                                         gtk_window_get_screen (GTK_WINDOW (ev_window)),
                                         NULL, 0, NULL, gtk_get_current_event_time ());
@@ -5816,8 +5784,6 @@ static const GActionEntry actions[] = {
        { "escape", ev_window_cmd_escape },
        { "open-menu", ev_window_cmd_action_menu },
        { "caret-navigation", NULL, NULL, "false", ev_window_cmd_view_toggle_caret_navigation },
-       { "recent-view", NULL, NULL, "false", ev_window_cmd_toggle_recent_view },
-
        /* Popups specific items */
        { "open-link", ev_window_popup_cmd_open_link },
        { "open-link-new-window", ev_window_popup_cmd_open_link_new_window },
diff --git a/shell/evince-menus.ui b/shell/evince-menus.ui
index a62821c..c9c0346 100644
--- a/shell/evince-menus.ui
+++ b/shell/evince-menus.ui
@@ -21,6 +21,10 @@
   <menu id="appmenu">
     <section>
       <item>
+        <attribute name="label" translatable="yes">_New Window</attribute>
+        <attribute name="action">app.new</attribute>
+      </item>
+      <item>
         <attribute name="label" translatable="yes">_Help</attribute>
         <attribute name="action">app.help</attribute>
         <attribute name="accel">F1</attribute>


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