summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-09 11:54:19 +0100
committerinfirit <[email protected]>2014-12-09 23:02:27 +0100
commit83ca334c004a0464322b7bba3f7aa4c83e63945d (patch)
treed1291c6cc9c63148bd8ce48d239eb5c4f93678d2 /shell
parenta81dc81efad42fb0c8752bd7d33a0c3f0e81c3bd (diff)
downloadatril-83ca334c004a0464322b7bba3f7aa4c83e63945d.tar.bz2
atril-83ca334c004a0464322b7bba3f7aa4c83e63945d.tar.xz
[shell] Update layers sidebar page when layers have changed
Based on evince commit: b151de0dab3a7c3355f8206b8f95548d11714e9e From: Carlos Garcia Campos <[email protected]>
Diffstat (limited to 'shell')
-rw-r--r--shell/ev-sidebar-layers.c43
-rw-r--r--shell/ev-sidebar-layers.h5
-rw-r--r--shell/ev-window.c10
3 files changed, 56 insertions, 2 deletions
diff --git a/shell/ev-sidebar-layers.c b/shell/ev-sidebar-layers.c
index 4d201bbd..80afd0ef 100644
--- a/shell/ev-sidebar-layers.c
+++ b/shell/ev-sidebar-layers.c
@@ -332,6 +332,49 @@ ev_sidebar_layers_new (void)
}
static void
+update_layers_state (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EvDocumentLayers *document_layers)
+{
+ EvLayer *layer;
+ gboolean visible;
+ GtkTreeIter child_iter;
+
+ do {
+ gtk_tree_model_get (model, iter,
+ EV_DOCUMENT_LAYERS_COLUMN_VISIBLE, &visible,
+ EV_DOCUMENT_LAYERS_COLUMN_LAYER, &layer,
+ -1);
+ if (layer) {
+ gboolean layer_visible;
+
+ layer_visible = ev_document_layers_layer_is_visible (document_layers, layer);
+ if (layer_visible != visible) {
+ gtk_tree_store_set (GTK_TREE_STORE (model), iter,
+ EV_DOCUMENT_LAYERS_COLUMN_VISIBLE, layer_visible,
+ -1);
+ }
+ }
+
+ if (gtk_tree_model_iter_children (model, &child_iter, iter))
+ update_layers_state (model, &child_iter, document_layers);
+ } while (gtk_tree_model_iter_next (model, iter));
+}
+
+void
+ev_sidebar_layers_update_layers_state (EvSidebarLayers *sidebar_layers)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ EvDocumentLayers *document_layers;
+
+ document_layers = EV_DOCUMENT_LAYERS (sidebar_layers->priv->document);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (sidebar_layers->priv->tree_view));
+ if (gtk_tree_model_get_iter_first (model, &iter))
+ update_layers_state (model, &iter, document_layers);
+}
+
+static void
job_finished_callback (EvJobLayers *job,
EvSidebarLayers *sidebar_layers)
{
diff --git a/shell/ev-sidebar-layers.h b/shell/ev-sidebar-layers.h
index be861500..1c7ef3f7 100644
--- a/shell/ev-sidebar-layers.h
+++ b/shell/ev-sidebar-layers.h
@@ -50,8 +50,9 @@ struct _EvSidebarLayersClass {
void (* layers_visibility_changed) (EvSidebarLayers *ev_layers);
};
-GType ev_sidebar_layers_get_type (void) G_GNUC_CONST;
-GtkWidget *ev_sidebar_layers_new (void);
+GType ev_sidebar_layers_get_type (void) G_GNUC_CONST;
+GtkWidget *ev_sidebar_layers_new (void);
+void ev_sidebar_layers_update_layers_state (EvSidebarLayers *sidebar_layers);
G_END_DECLS
diff --git a/shell/ev-window.c b/shell/ev-window.c
index e7fed16e..f4600d92 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -963,6 +963,13 @@ web_view_selection_changed_cb(EvWebView *webview,
#endif
static void
+view_layers_changed_cb (EvView *view,
+ EvWindow *window)
+{
+ ev_sidebar_layers_update_layers_state (EV_SIDEBAR_LAYERS (window->priv->sidebar_layers));
+}
+
+static void
ev_window_page_changed_cb (EvWindow *ev_window,
gint old_page,
gint new_page,
@@ -7375,6 +7382,9 @@ ev_window_init (EvWindow *ev_window)
g_signal_connect_object (ev_window->priv->view, "annot-added",
G_CALLBACK (view_annot_added),
ev_window, 0);
+ g_signal_connect_object (ev_window->priv->view, "layers-changed",
+ G_CALLBACK (view_layers_changed_cb),
+ ev_window, 0);
#ifdef ENABLE_DBUS
g_signal_connect_swapped (ev_window->priv->view, "sync-source",
G_CALLBACK (ev_window_sync_source),