[evince] [shell] Update layers sidebar page when layers have changed
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] [shell] Update layers sidebar page when layers have changed
- Date: Wed, 15 Sep 2010 15:10:41 +0000 (UTC)
commit b151de0dab3a7c3355f8206b8f95548d11714e9e
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Wed Sep 15 16:59:49 2010 +0200
[shell] Update layers sidebar page when layers have changed
shell/ev-sidebar-layers.c | 43 +++++++++++++++++++++++++++++++++++++++++++
shell/ev-sidebar-layers.h | 5 +++--
shell/ev-window.c | 10 ++++++++++
3 files changed, 56 insertions(+), 2 deletions(-)
---
diff --git a/shell/ev-sidebar-layers.c b/shell/ev-sidebar-layers.c
index 938f457..794d31f 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 bedd95e..0dd99df 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 ce43ab0..9aa3926 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -896,6 +896,13 @@ view_selection_changed_cb (EvView *view,
}
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,
@@ -7007,6 +7014,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),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]