[evince/wip/recent-view: 53/53] shell: Bring back the button to show/hide the recent view
- From: Germán Poó Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/recent-view: 53/53] shell: Bring back the button to show/hide the recent view
- Date: Sun, 4 May 2014 04:31:43 +0000 (UTC)
commit ef9e06073713e5109246a14bfd985c4dc8cd3c7e
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Sat May 3 21:18:53 2014 -0700
shell: Bring back the button to show/hide the recent view
It is the easier way to get back to the document already opened.
When suspending several times and opening multiples documents,
the first document openened can dissapear from the recent menu
and there will be not way to get it back.
shell/ev-minimal-toolbar.c | 33 +++++++++++++++++++++++++++++++++
shell/ev-toolbar.c | 2 +-
shell/ev-window.c | 17 ++++++++++++++++-
3 files changed, 50 insertions(+), 2 deletions(-)
---
diff --git a/shell/ev-minimal-toolbar.c b/shell/ev-minimal-toolbar.c
index 26a4afc..f6f1392 100644
--- a/shell/ev-minimal-toolbar.c
+++ b/shell/ev-minimal-toolbar.c
@@ -87,6 +87,26 @@ ev_minimal_toolbar_create_button (EvMinimalToolbar *ev_toolbar,
return button;
}
+static GtkWidget *
+ev_minimal_toolbar_create_toggle_button (EvMinimalToolbar *ev_toolbar,
+ GtkAction *action)
+{
+ GtkWidget *button = gtk_toggle_button_new ();
+
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_button_set_image (GTK_BUTTON (button), gtk_image_new ());
+ ev_minimal_toolbar_set_button_action (ev_toolbar, GTK_BUTTON (button), action);
+
+ return button;
+}
+
+static void
+keep_active_button_cb (GtkToggleButton *button,
+ gpointer data)
+{
+ gtk_toggle_button_set_active (button, TRUE);
+}
+
static void
ev_minimal_toolbar_constructed (GObject *object)
{
@@ -105,6 +125,19 @@ ev_minimal_toolbar_constructed (GObject *object)
action_group = ev_window_get_minimal_toolbar_action_group (ev_minimal_toolbar->priv->window);
+ /* View of recent items */
+ action = gtk_action_group_get_action (action_group, "RecentViewHide");
+ button = ev_minimal_toolbar_create_toggle_button (ev_minimal_toolbar, action);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+ 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, 6);
+ gtk_container_add (GTK_CONTAINER (ev_minimal_toolbar), tool_item);
+ g_signal_connect (button, "toggled",
+ G_CALLBACK (keep_active_button_cb), NULL);
+ gtk_widget_show (tool_item);
+
/* Button for file open dialog */
action = gtk_action_group_get_action (action_group, "ToolbarOpenDocument");
button = ev_minimal_toolbar_create_button (ev_minimal_toolbar, action);
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 1d16828..391caa6 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -4516,9 +4516,17 @@ ev_window_cmd_show_recent_view (GtkAction *action,
EvWindow *ev_window)
{
ev_window_show_recent_view (ev_window);
- return;
}
+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);
+}
+
+
static gint
compare_bookmarks (EvBookmark *a,
EvBookmark *b)
@@ -6086,6 +6094,10 @@ static const GtkToggleActionEntry zoom_selector_popup_actions[] = {
/* Items for the minimal toolbar */
static const GtkActionEntry minimal_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) },
@@ -7646,6 +7658,8 @@ ev_window_new (void)
void
ev_window_show_recent_view (EvWindow *ev_window)
{
+ GtkAction *action = gtk_action_group_get_action (ev_window->priv->minimal_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);
@@ -7661,6 +7675,7 @@ 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->minimal_toolbar);
gtk_widget_show (GTK_WIDGET (ev_window->priv->recent_view));
ev_window_setup_action_sensitivity (ev_window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]