[evince] shell: Sync toolbar's sidebar icon and side pane in use
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] shell: Sync toolbar's sidebar icon and side pane in use
- Date: Tue, 10 Jul 2018 20:20:35 +0000 (UTC)
commit 4474def20feea6b7ba5492e341b088a0a1474418
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Thu Jul 5 01:32:24 2018 -0400
shell: Sync toolbar's sidebar icon and side pane in use
Whenever the user switches a side page, the toolbar updates the
icon to display/hide the sidebar with the icon used in the sidebar.
shell/ev-toolbar.c | 38 ++++++++++++++++++++++++++++++++++++++
shell/ev-toolbar.h | 3 +++
shell/ev-window.c | 2 ++
3 files changed, 43 insertions(+)
---
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index 1d0bd98a..87bf7fb3 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -31,6 +31,7 @@
#include "ev-zoom-action.h"
#include "ev-application.h"
#include "ev-page-action-widget.h"
+#include "ev-sidebar.h"
#include <math.h>
enum
@@ -50,6 +51,7 @@ struct _EvToolbarPrivate {
GtkWidget *open_button;
GtkWidget *annots_button;
GtkWidget *sidebar_button;
+ GtkWidget *sidebar;
GMenu *bookmarks_section;
EvToolbarMode toolbar_mode;
@@ -184,6 +186,27 @@ zoom_selector_activated (GtkWidget *zoom_action,
ev_window_focus_view (toolbar->priv->window);
}
+static void
+ev_toolbar_sidebar_current_page_changed (EvSidebar *ev_sidebar,
+ GParamSpec *pspec,
+ EvToolbar *ev_toolbar)
+{
+ GtkWidget *button = ev_toolbar->priv->sidebar_button;
+ GtkWidget *image;
+ gchar *icon_name;
+
+ g_object_get (ev_sidebar, "active-icon-name", &icon_name, NULL);
+
+ if (!icon_name)
+ return;
+
+ image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_button_set_image (GTK_BUTTON (button), image);
+ g_free (icon_name);
+}
+
static void
ev_toolbar_constructed (GObject *object)
{
@@ -401,3 +424,18 @@ ev_toolbar_get_mode (EvToolbar *ev_toolbar)
return ev_toolbar->priv->toolbar_mode;
}
+
+void
+ev_toolbar_set_sidebar (EvToolbar *ev_toolbar,
+ GtkWidget *sidebar)
+{
+ g_return_if_fail (EV_IS_TOOLBAR (ev_toolbar));
+ g_return_if_fail (EV_IS_SIDEBAR (sidebar));
+
+ ev_toolbar->priv->sidebar = sidebar;
+
+ g_signal_connect (sidebar,
+ "notify::current-page",
+ G_CALLBACK (ev_toolbar_sidebar_current_page_changed),
+ ev_toolbar);
+}
diff --git a/shell/ev-toolbar.h b/shell/ev-toolbar.h
index f454376b..e3fde65d 100644
--- a/shell/ev-toolbar.h
+++ b/shell/ev-toolbar.h
@@ -2,6 +2,7 @@
* this file is part of evince, a gnome document viewer
*
* Copyright (C) 2012 Carlos Garcia Campos <carlosgc gnome org>
+ * Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
*
* Evince is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
@@ -61,6 +62,8 @@ GtkWidget *ev_toolbar_get_page_selector (EvToolbar *ev_toolbar);
void ev_toolbar_set_mode (EvToolbar *ev_toolbar,
EvToolbarMode mode);
EvToolbarMode ev_toolbar_get_mode (EvToolbar *ev_toolbar);
+void ev_toolbar_set_sidebar (EvToolbar *ev_toolbar,
+ GtkWidget *sidebar);
G_END_DECLS
diff --git a/shell/ev-window.c b/shell/ev-window.c
index bc5d2fe2..e2b5463a 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -7107,6 +7107,8 @@ ev_window_init (EvWindow *ev_window)
gtk_paned_pack1 (GTK_PANED (ev_window->priv->hpaned),
ev_window->priv->sidebar, FALSE, FALSE);
gtk_widget_show (ev_window->priv->sidebar);
+ ev_toolbar_set_sidebar (EV_TOOLBAR (ev_window->priv->toolbar),
+ ev_window->priv->sidebar);
/* Stub sidebar, for now */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]