[evince/wip/recent-view: 105/107] shell: Integrate recent view into the main window
- From: Germán Poó Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/recent-view: 105/107] shell: Integrate recent view into the main window
- Date: Wed, 26 Mar 2014 00:02:02 +0000 (UTC)
commit d04ad64b2e2742628b1a19710ef7354a865b8140
Author: Aakash Goenka <aakash goenka gmail com>
Date: Sun Feb 23 14:53:57 2014 -0800
shell: Integrate recent view into the main window
* Allow switching between document and bookshelf
* It seems more natural as we 'toggle' between the bookshelf the
currently open document.
shell/ev-application.c | 1 +
shell/ev-toolbar.c | 10 +++++
shell/ev-window.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++-
shell/ev-window.h | 2 +-
4 files changed, 96 insertions(+), 3 deletions(-)
---
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 475dfaf..517e785 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -655,6 +655,7 @@ ev_application_open_window (EvApplication *application,
guint32 timestamp)
{
GtkWidget *new_window = ev_window_new ();
+ ev_window_show_recent_view (EV_WINDOW (new_window));
#ifdef GDK_WINDOWING_X11
GdkWindow *gdk_window;
#endif
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index f9f87e6..1bc270f 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -158,6 +158,16 @@ ev_toolbar_constructed (GObject *object)
action_group = ev_window_get_main_action_group (ev_toolbar->priv->window);
ui_manager = ev_window_get_ui_manager (ev_toolbar->priv->window);
+ /* View of recent items */
+ action = gtk_action_group_get_action (action_group, "RecentViewShow");
+ button = ev_toolbar_create_toggle_button (ev_toolbar, action);
+ tool_item = GTK_WIDGET (gtk_tool_item_new ());
+ gtk_container_add (GTK_CONTAINER (tool_item), button);
+ gtk_widget_show (button);
+ gtk_widget_set_margin_right (tool_item, 12);
+ gtk_container_add (GTK_CONTAINER (ev_toolbar), tool_item);
+ gtk_widget_show (tool_item);
+
/* Navigation */
hbox = ev_toolbar_create_button_group (ev_toolbar);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index a4f8a8a..9f7cb12 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -91,6 +91,7 @@
#include "ev-bookmark-action.h"
#include "ev-zoom-action.h"
#include "ev-toolbar.h"
+#include "ev-recent-view.h"
#ifdef ENABLE_DBUS
#include "ev-gdbus-generated.h"
@@ -191,6 +192,9 @@ struct _EvWindowPrivate {
GtkWidget *attachment_popup;
GList *attach_list;
+ /* For bookshelf view of recent items*/
+ EvRecentView *recent_view;
+
/* Document */
EvDocumentModel *model;
char *uri;
@@ -382,6 +386,10 @@ static void ev_window_setup_bookmarks (EvWindow *windo
static void ev_window_show_find_bar (EvWindow *ev_window,
gboolean restart);
static void ev_window_close_find_bar (EvWindow *ev_window);
+static void ev_window_try_swap_out_recent_view (EvWindow *ev_window);
+static void recent_view_item_activated_cb (EvRecentView *recent_view,
+ const char *uri,
+ EvWindow *ev_window);
static gchar *nautilus_sendto = NULL;
@@ -421,7 +429,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
gboolean has_pages = FALSE;
gboolean can_find = FALSE;
- if (document) {
+ if (document && !ev_window->priv->recent_view) {
has_document = TRUE;
has_pages = ev_document_get_n_pages (document) > 0;
info = ev_document_get_info (document);
@@ -496,6 +504,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
/* Toolbar-specific actions: */
ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
ev_window_set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION, has_pages);
+ ev_window_set_action_sensitive (ev_window, HISTORY_ACTION, has_document);
ev_window_update_actions_sensitivity (ev_window);
}
@@ -510,13 +519,16 @@ ev_window_update_actions_sensitivity (EvWindow *ev_window)
gboolean can_find_in_page = FALSE;
gboolean dual_mode = FALSE;
- if (ev_window->priv->document) {
+ if (ev_window->priv->document && !ev_window->priv->recent_view) {
page = ev_document_model_get_page (ev_window->priv->model);
n_pages = ev_document_get_n_pages (ev_window->priv->document);
has_pages = n_pages > 0;
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);
can_find_in_page = (ev_window->priv->find_job &&
ev_job_find_has_results (EV_JOB_FIND (ev_window->priv->find_job)));
@@ -1656,9 +1668,11 @@ ev_window_load_job_cb (EvJob *job,
g_assert (job_load->uri);
ev_window_hide_loading_message (ev_window);
+ ev_window_try_swap_out_recent_view (ev_window);
/* Success! */
if (!ev_job_is_failed (job)) {
+
ev_document_model_set_document (ev_window->priv->model, document);
#ifdef ENABLE_DBUS
@@ -2187,6 +2201,7 @@ ev_window_open_document (EvWindow *ev_window,
ev_window_close_dialogs (ev_window);
ev_window_clear_load_job (ev_window);
ev_window_clear_local_uri (ev_window);
+ ev_window_try_swap_out_recent_view (ev_window);
if (ev_window->priv->monitor) {
g_object_unref (ev_window->priv->monitor);
@@ -4711,6 +4726,19 @@ ev_window_cmd_bookmark_activate (GtkAction *action,
ev_document_model_set_page (window->priv->model, page);
}
+static void
+ev_window_cmd_toggle_recent_view (GtkAction *action,
+ EvWindow *ev_window)
+{
+ if (!ev_window->priv->recent_view)
+ ev_window_show_recent_view (ev_window);
+ else {
+ ev_window_try_swap_out_recent_view (ev_window);
+ ev_window_setup_action_sensitivity (ev_window);
+ }
+ return;
+}
+
static gint
compare_bookmarks (EvBookmark *a,
EvBookmark *b)
@@ -5363,6 +5391,31 @@ find_sidebar_result_activated_cb (EvFindSidebar *find_sidebar,
}
static void
+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));
+ g_object_unref (ev_window->priv->recent_view);
+ ev_window->priv->recent_view = NULL;
+ }
+ gtk_widget_show (ev_window->priv->hpaned);
+}
+
+static void
+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)
+ ev_window_try_swap_out_recent_view (ev_window);
+ 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
ev_window_update_find_status_message (EvWindow *ev_window)
{
gchar *message;
@@ -6092,6 +6145,11 @@ 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) },
+
/* Go menu */
{ "GoPreviousPage", "go-up-symbolic", N_("_Previous Page"), "<control>Page_Up",
N_("Go to the previous page"),
@@ -7356,6 +7414,7 @@ ev_window_init (EvWindow *ev_window)
#endif /* ENABLE_DBUS */
ev_window->priv->model = ev_document_model_new ();
+ ev_window->priv->recent_view = NULL;
ev_window->priv->page_mode = PAGE_MODE_DOCUMENT;
ev_window->priv->chrome = EV_CHROME_NORMAL;
@@ -7766,6 +7825,7 @@ ev_window_init (EvWindow *ev_window)
NULL, 0,
GDK_ACTION_COPY);
gtk_drag_dest_add_uri_targets (GTK_WIDGET (ev_window));
+
}
/**
@@ -7789,6 +7849,28 @@ ev_window_new (void)
return ev_window;
}
+void
+ev_window_show_recent_view (EvWindow *ev_window)
+{
+ gtk_widget_hide (ev_window->priv->hpaned);
+ if (!ev_window->priv->recent_view) {
+ ev_window->priv->recent_view = ev_recent_view_new ();
+ g_object_ref (ev_window->priv->recent_view);
+ g_signal_connect_object (ev_window->priv->recent_view,
+ "item-activated",
+ G_CALLBACK (recent_view_item_activated_cb),
+ ev_window, 0);
+ gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
+ GTK_WIDGET (ev_window->priv->recent_view),
+ TRUE, TRUE, 0);
+ }
+
+ gtk_widget_show (GTK_WIDGET (ev_window->priv->recent_view));
+ ev_window_setup_action_sensitivity (ev_window);
+
+ return;
+}
+
const gchar *
ev_window_get_dbus_object_path (EvWindow *ev_window)
{
diff --git a/shell/ev-window.h b/shell/ev-window.h
index fd2d0b5..3dc1f2c 100644
--- a/shell/ev-window.h
+++ b/shell/ev-window.h
@@ -89,7 +89,7 @@ const gchar *ev_window_get_dbus_object_path (EvWindow *ev_win
GtkUIManager *ev_window_get_ui_manager (EvWindow *ev_window);
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);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]