[evince/wip/recent-view: 10/11] ev-window: Integrate the recent view toolbar



commit 4fa6a431a827cc55b3567201aee93cd503b7daed
Author: Aakash Goenka <aakash goenka gmail com>
Date:   Sun May 4 08:34:38 2014 -0700

    ev-window: Integrate the recent view toolbar

 shell/ev-toolbar.c |    2 +-
 shell/ev-window.c  |   97 +++++++++++++++++++++++++++++++++++++++++-----------
 shell/ev-window.h  |    1 +
 3 files changed, 79 insertions(+), 21 deletions(-)
---
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index 1bc270f..3413d32 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -160,7 +160,7 @@ ev_toolbar_constructed (GObject *object)
 
        /* View of recent items */
        action = gtk_action_group_get_action (action_group, "RecentViewShow");
-       button = ev_toolbar_create_toggle_button (ev_toolbar, action);
+       button = ev_toolbar_create_button (ev_toolbar, action);
        tool_item = GTK_WIDGET (gtk_tool_item_new ());
        gtk_container_add (GTK_CONTAINER (tool_item), button);
        gtk_widget_show (button);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 2d8aba5..2317ecb 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -51,7 +51,6 @@
 #include "ev-document-images.h"
 #include "ev-document-links.h"
 #include "ev-document-annotations.h"
-#include "ev-document-type-builtins.h"
 #include "ev-document-misc.h"
 #include "ev-file-exporter.h"
 #include "ev-file-helpers.h"
@@ -92,6 +91,7 @@
 #include "ev-zoom-action.h"
 #include "ev-toolbar.h"
 #include "ev-recent-view.h"
+#include "ev-recent-view-toolbar.h"
 
 #ifdef ENABLE_DBUS
 #include "ev-gdbus-generated.h"
@@ -172,6 +172,7 @@ struct _EvWindowPrivate {
 
        /* UI Builders */
        GtkActionGroup   *action_group;
+       GtkActionGroup   *recent_view_toolbar_action_group;
        GtkActionGroup   *view_popup_action_group;
        GtkActionGroup   *attachment_popup_action_group;
        GtkActionGroup   *zoom_selector_popup_action_group;
@@ -194,6 +195,7 @@ struct _EvWindowPrivate {
 
        /* For bookshelf view of recent items*/
        EvRecentView *recent_view;
+       GtkWidget *recent_view_toolbar;
        
        /* Document */
        EvDocumentModel *model;
@@ -517,6 +519,7 @@ ev_window_update_actions_sensitivity (EvWindow *ev_window)
        gboolean presentation_mode;
        gboolean can_find_in_page = FALSE;
        gboolean dual_mode = FALSE;
+       gboolean fullscreen_mode = FALSE;
 
        if (ev_window->priv->document && !ev_window->priv->recent_view) {
                page = ev_document_model_get_page (ev_window->priv->model);
@@ -525,9 +528,11 @@ ev_window_update_actions_sensitivity (EvWindow *ev_window)
                dual_mode = ev_document_model_get_dual_page (ev_window->priv->model);
        }
 
-       ev_window_set_action_sensitive (ev_window, "RecentViewShow", 
-                                       ev_window->priv->document ||
-                                       !ev_window->priv->recent_view);
+       fullscreen_mode = ev_document_model_get_fullscreen (ev_window->priv->model);
+       ev_window_set_action_sensitive (ev_window, "RecentViewShow",
+                                       ev_window->priv->document &&
+                                       !ev_window->priv->recent_view &&
+                                       !fullscreen_mode);
        can_find_in_page = (ev_window->priv->find_job &&
                            ev_job_find_has_results (EV_JOB_FIND (ev_window->priv->find_job)));
 
@@ -4242,6 +4247,7 @@ ev_window_run_fullscreen (EvWindow *window)
 
        if (window->priv->metadata && !ev_window_is_empty (window))
                ev_metadata_set_boolean (window->priv->metadata, "fullscreen", TRUE);
+       ev_window_update_actions_sensitivity (window);
 }
 
 static void
@@ -4288,6 +4294,7 @@ ev_window_stop_fullscreen (EvWindow *window,
 
        if (window->priv->metadata && !ev_window_is_empty (window))
                ev_metadata_set_boolean (window->priv->metadata, "fullscreen", FALSE);
+       ev_window_update_actions_sensitivity (window);
 }
 
 static void
@@ -4715,16 +4722,18 @@ ev_window_cmd_bookmark_activate (GtkAction *action,
 }
 
 static void
-ev_window_cmd_toggle_recent_view (GtkAction *action,
+ev_window_cmd_show_recent_view (GtkAction *action,
                                   EvWindow  *ev_window)
 {
-       if (!ev_window->priv->recent_view)
-               ev_window_show_recent_view (ev_window);
-       else {
+       ev_window_show_recent_view (ev_window);
+}
+
+static void
+ev_window_cmd_hide_recent_view (GtkAction *action,
+                                EvWindow  *ev_window)
+{
+       if (ev_window->priv->uri)
                ev_window_try_swap_out_recent_view (ev_window);
-               ev_window_setup_action_sensitivity (ev_window);
-       }
-       return;
 }
 
 static gint
@@ -5385,10 +5394,12 @@ ev_window_try_swap_out_recent_view (EvWindow *ev_window)
        if (ev_window->priv->recent_view)
        {
                gtk_widget_hide (GTK_WIDGET (ev_window->priv->recent_view));
+               gtk_widget_hide (GTK_WIDGET (ev_window->priv->recent_view_toolbar));
                g_object_unref (ev_window->priv->recent_view);
                ev_window->priv->recent_view = NULL;
        }
        gtk_widget_show (ev_window->priv->hpaned);
+       gtk_widget_show (ev_window->priv->toolbar);
 }
 
 static void
@@ -5396,12 +5407,13 @@ recent_view_item_activated_cb (EvRecentView *recent_view,
                                const char   *uri,
                                EvWindow     *ev_window)
 {
-       if (ev_window->priv->uri && strcmp (ev_window->priv->uri, uri) == 0)
+       if (ev_window->priv->uri && strcmp (ev_window->priv->uri, uri) == 0) {
                ev_window_try_swap_out_recent_view (ev_window);
+               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 ());
-       return;
 }
 
 static void
@@ -5859,6 +5871,10 @@ ev_window_dispose (GObject *object)
                priv->action_group = NULL;
        }
 
+       if (priv->recent_view_toolbar_action_group) {
+               g_object_unref (priv->recent_view_toolbar_action_group);
+               priv->recent_view_toolbar_action_group = NULL;
+       }
        if (priv->view_popup_action_group) {
                g_object_unref (priv->view_popup_action_group);
                priv->view_popup_action_group = NULL;
@@ -6134,10 +6150,10 @@ static const GtkActionEntry entries[] = {
        { "ViewAutoscroll", GTK_STOCK_MEDIA_PLAY, N_("Auto_scroll"), NULL, NULL,
          G_CALLBACK (ev_window_cmd_view_autoscroll) },
 
-       /* View of recent items */
-       { "RecentViewShow", "view-grid-symbolic", N_("Recent Items"), NULL,
-         N_("Toggle between view of recent items and open document"),
-         G_CALLBACK (ev_window_cmd_toggle_recent_view) },
+       /* View of recent documents */
+       { "RecentViewShow", "view-grid-symbolic", N_("Recent Documents"), NULL,
+         N_("Show recent documents"),
+         G_CALLBACK (ev_window_cmd_show_recent_view) },
 
         /* Go menu */
         { "GoBackHistory", NULL, "", "<alt>P", NULL,
@@ -6298,6 +6314,23 @@ static const GtkToggleActionEntry zoom_selector_popup_actions[] = {
          G_CALLBACK (ev_window_cmd_view_zoom_automatic) }
 };
 
+/* Items for the recent view toolbar */
+static const GtkActionEntry recent_view_toolbar_entries [] = {
+       { "RecentViewHide", "view-grid-symbolic", N_("Recent Documents"), NULL,
+         N_("Hide recent documents"),
+         G_CALLBACK (ev_window_cmd_hide_recent_view) },
+
+       { "ToolbarOpenDocument", "document-open-symbolic", N_("_Open…"), NULL,
+         N_("Open an existing document"),
+         G_CALLBACK (ev_window_cmd_file_open) },
+       { "ToolbarAbout", "dialog-information-symbolic", N_("_About"), NULL,
+         N_("About "),
+         G_CALLBACK (ev_window_cmd_help_about) },
+       { "ToolbarCloseWindow", "window-close-symbolic", N_("Close"), NULL,
+         N_("Close this window"),
+         G_CALLBACK (ev_window_cmd_file_close_window) },
+};
+
 static void
 sidebar_links_link_activated_cb (EvSidebarLinks *sidebar_links, EvLink *link, EvWindow *window)
 {
@@ -7457,6 +7490,12 @@ ev_window_init (EvWindow *ev_window)
                gtk_ui_manager_get_accel_group (ev_window->priv->ui_manager);
        gtk_window_add_accel_group (GTK_WINDOW (ev_window), accel_group);
 
+       action_group = gtk_action_group_new ("RecentViewToolbarActions");
+       ev_window->priv->recent_view_toolbar_action_group = action_group;
+       gtk_action_group_set_translation_domain (action_group, NULL);
+       gtk_action_group_add_actions (action_group, recent_view_toolbar_entries,
+                                     G_N_ELEMENTS (recent_view_toolbar_entries), ev_window);
+
        action_group = gtk_action_group_new ("ViewPopupActions");
        ev_window->priv->view_popup_action_group = action_group;
        gtk_action_group_set_translation_domain (action_group, NULL);
@@ -7525,6 +7564,13 @@ ev_window_init (EvWindow *ev_window)
        gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
                            ev_window->priv->find_bar,
                            FALSE, TRUE, 0);
+       
+       ev_window->priv->recent_view_toolbar = ev_recent_view_toolbar_new (ev_window);
+       gtk_widget_set_halign (ev_window->priv->recent_view_toolbar, GTK_ALIGN_FILL);
+       gtk_widget_set_valign (ev_window->priv->recent_view_toolbar, GTK_ALIGN_START);
+       gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
+                           ev_window->priv->recent_view_toolbar,
+                           FALSE, TRUE, 0);
 
        /* Add the main area */
        ev_window->priv->hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
@@ -7856,7 +7902,11 @@ ev_window_new (void)
 void
 ev_window_show_recent_view (EvWindow *ev_window)
 {
+       GtkAction *action = gtk_action_group_get_action (ev_window->priv->recent_view_toolbar_action_group,
+                                                        "RecentViewHide");
        gtk_widget_hide (ev_window->priv->hpaned);
+       gtk_widget_hide (ev_window->priv->toolbar);
+       gtk_widget_hide (ev_window->priv->find_bar);
        if (!ev_window->priv->recent_view) {
                ev_window->priv->recent_view = ev_recent_view_new ();
                g_object_ref (ev_window->priv->recent_view);
@@ -7869,10 +7919,9 @@ ev_window_show_recent_view (EvWindow *ev_window)
                                    TRUE, TRUE, 0);
        }
 
+       gtk_action_set_sensitive (action, ev_window->priv->document != NULL);
+       gtk_widget_show (ev_window->priv->recent_view_toolbar);
        gtk_widget_show (GTK_WIDGET (ev_window->priv->recent_view));
-       ev_window_setup_action_sensitivity (ev_window);
-
-       return;
 }
 
 const gchar *
@@ -7908,3 +7957,11 @@ ev_window_get_zoom_selector_action_group (EvWindow *ev_window)
 
        return ev_window->priv->zoom_selector_popup_action_group;
 }
+
+GtkActionGroup *
+ev_window_get_recent_view_toolbar_action_group (EvWindow *ev_window)
+{
+       g_return_val_if_fail (EV_WINDOW (ev_window), NULL);
+
+       return ev_window->priv->recent_view_toolbar_action_group;
+}
diff --git a/shell/ev-window.h b/shell/ev-window.h
index 3dc1f2c..27adcfa 100644
--- a/shell/ev-window.h
+++ b/shell/ev-window.h
@@ -90,6 +90,7 @@ GtkUIManager   *ev_window_get_ui_manager                 (EvWindow       *ev_win
 GtkActionGroup *ev_window_get_main_action_group          (EvWindow       *ev_window);
 GtkActionGroup *ev_window_get_zoom_selector_action_group (EvWindow       *ev_window);
 void            ev_window_show_recent_view               (EvWindow       *ev_window);
+GtkActionGroup *ev_window_get_recent_view_toolbar_action_group (EvWindow     *ev_window);
 
 G_END_DECLS
 


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