Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-sidebar-layers.c File Reference
#include "config.h"
#include <glib/gi18n.h>
#include "gimpcellrenderertoggle.h"
#include "ev-document-layers.h"
#include "ev-sidebar-page.h"
#include "ev-jobs.h"
#include "ev-job-scheduler.h"
#include "ev-stock-icons.h"
#include "ev-sidebar-layers.h"
+ Include dependency graph for ev-sidebar-layers.c:

Go to the source code of this file.

Data Structures

struct  _EvSidebarLayersPrivate
 

Macros

#define EV_SIDEBAR_LAYERS_GET_PRIVATE(object)   (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR_LAYERS, EvSidebarLayersPrivate))
 

Enumerations

enum  { PROP_0, PROP_WIDGET }
 
enum  { LAYERS_VISIBILITY_CHANGED, N_SIGNALS }
 

Functions

static void ev_sidebar_layers_page_iface_init (EvSidebarPageInterface *iface)
 
static void job_finished_callback (EvJobLayers *job, EvSidebarLayers *sidebar_layers)
 
 G_DEFINE_TYPE_EXTENDED (EvSidebarLayers, ev_sidebar_layers, GTK_TYPE_BOX, 0, G_IMPLEMENT_INTERFACE(EV_TYPE_SIDEBAR_PAGE, ev_sidebar_layers_page_iface_init))
 
static void ev_sidebar_layers_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 
static GtkTreeModel * ev_sidebar_layers_create_loading_model (void)
 
static gboolean update_kids (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GtkTreeIter *parent)
 
static gboolean clear_rb_group (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gint *rb_group)
 
static void ev_sidebar_layers_visibility_changed (GtkCellRendererToggle *cell, gchar *path_str, EvSidebarLayers *ev_layers)
 
static GtkTreeView * ev_sidebar_layers_create_tree_view (EvSidebarLayers *ev_layers)
 
static void ev_sidebar_layers_init (EvSidebarLayers *ev_layers)
 
static void ev_sidebar_layers_class_init (EvSidebarLayersClass *ev_layers_class)
 
GtkWidget * ev_sidebar_layers_new (void)
 
static void update_layers_state (GtkTreeModel *model, GtkTreeIter *iter, EvDocumentLayers *document_layers)
 
void ev_sidebar_layers_update_layers_state (EvSidebarLayers *sidebar_layers)
 
static void ev_sidebar_layers_document_changed_cb (EvDocumentModel *model, GParamSpec *pspec, EvSidebarLayers *sidebar_layers)
 
static void ev_sidebar_layers_set_model (EvSidebarPage *sidebar_page, EvDocumentModel *model)
 
static gboolean ev_sidebar_layers_support_document (EvSidebarPage *sidebar_page, EvDocument *document)
 
static const gchar * ev_sidebar_layers_get_label (EvSidebarPage *sidebar_page)
 

Variables

static guint signals [N_SIGNALS]
 

Macro Definition Documentation

#define EV_SIDEBAR_LAYERS_GET_PRIVATE (   object)    (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR_LAYERS, EvSidebarLayersPrivate))

Enumeration Type Documentation

anonymous enum
Enumerator
PROP_0 
PROP_WIDGET 

Definition at line 40 of file ev-sidebar-layers.c.

40  {
41  PROP_0,
43 };
anonymous enum
Enumerator
LAYERS_VISIBILITY_CHANGED 
N_SIGNALS 

Definition at line 45 of file ev-sidebar-layers.c.

45  {
47  N_SIGNALS
48 };

Function Documentation

static gboolean clear_rb_group ( GtkTreeModel *  model,
GtkTreePath *  path,
GtkTreeIter *  iter,
gint *  rb_group 
)
static

Definition at line 160 of file ev-sidebar-layers.c.

164 {
165  gint group;
166 
167  gtk_tree_model_get (model, iter,
169  -1);
170 
171  if (group == *rb_group) {
172  gtk_tree_store_set (GTK_TREE_STORE (model), iter,
174  -1);
175  }
176 
177  return FALSE;
178 }

+ Here is the caller graph for this function:

static void ev_sidebar_layers_class_init ( EvSidebarLayersClass ev_layers_class)
static

Definition at line 305 of file ev-sidebar-layers.c.

306 {
307  GObjectClass *g_object_class = G_OBJECT_CLASS (ev_layers_class);
308 
309  g_object_class->get_property = ev_sidebar_layers_get_property;
310  g_object_class->dispose = ev_sidebar_layers_dispose;
311 
312  g_type_class_add_private (g_object_class, sizeof (EvSidebarLayersPrivate));
313 
314  g_object_class_override_property (g_object_class, PROP_WIDGET, "main-widget");
315 
317  g_signal_new ("layers_visibility_changed",
318  G_TYPE_FROM_CLASS (g_object_class),
319  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
320  G_STRUCT_OFFSET (EvSidebarLayersClass, layers_visibility_changed),
321  NULL, NULL,
322  g_cclosure_marshal_VOID__VOID,
323  G_TYPE_NONE, 0, G_TYPE_NONE);
324 }
static GtkTreeModel* ev_sidebar_layers_create_loading_model ( void  )
static

Definition at line 109 of file ev-sidebar-layers.c.

110 {
111  GtkTreeModel *retval;
112  GtkTreeIter iter;
113  gchar *markup;
114 
115  /* Creates a fake model to indicate that we're loading */
116  retval = (GtkTreeModel *)gtk_list_store_new (EV_DOCUMENT_LAYERS_N_COLUMNS,
117  G_TYPE_STRING,
118  G_TYPE_OBJECT,
119  G_TYPE_BOOLEAN,
120  G_TYPE_BOOLEAN,
121  G_TYPE_BOOLEAN,
122  G_TYPE_INT);
123 
124  gtk_list_store_append (GTK_LIST_STORE (retval), &iter);
125  markup = g_strdup_printf ("<span size=\"larger\" style=\"italic\">%s</span>", _("Loading…"));
126  gtk_list_store_set (GTK_LIST_STORE (retval), &iter,
133  -1);
134  g_free (markup);
135 
136  return retval;
137 }

+ Here is the caller graph for this function:

static GtkTreeView* ev_sidebar_layers_create_tree_view ( EvSidebarLayers ev_layers)
static

Definition at line 234 of file ev-sidebar-layers.c.

235 {
236  GtkTreeView *tree_view;
237  GtkTreeViewColumn *column;
238  GtkCellRenderer *renderer;
239 
240  tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
241  gtk_tree_view_set_headers_visible (tree_view, FALSE);
242  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (tree_view),
243  GTK_SELECTION_NONE);
244 
245 
246  column = gtk_tree_view_column_new ();
247 
249  gtk_tree_view_column_pack_start (column, renderer, FALSE);
250  gtk_tree_view_column_set_attributes (column, renderer,
252  "activatable", EV_DOCUMENT_LAYERS_COLUMN_ENABLED,
255  NULL);
256  g_object_set (G_OBJECT (renderer),
257  "xpad", 0,
258  "ypad", 0,
259  NULL);
260  g_signal_connect (renderer, "toggled",
262  (gpointer)ev_layers);
263 
264  renderer = gtk_cell_renderer_text_new ();
265  gtk_tree_view_column_pack_start (column, renderer, TRUE);
266  gtk_tree_view_column_set_attributes (column, renderer,
269  NULL);
270  g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
271 
272  gtk_tree_view_append_column (tree_view, column);
273 
274  return tree_view;
275 }

+ Here is the caller graph for this function:

static void ev_sidebar_layers_document_changed_cb ( EvDocumentModel model,
GParamSpec *  pspec,
EvSidebarLayers sidebar_layers 
)
static

Definition at line 392 of file ev-sidebar-layers.c.

395 {
396  EvDocument *document = ev_document_model_get_document (model);
397  EvSidebarLayersPrivate *priv = sidebar_layers->priv;
398 
399  if (!EV_IS_DOCUMENT_LAYERS (document))
400  return;
401 
402  if (priv->document) {
403  gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), NULL);
404  g_object_unref (priv->document);
405  }
406 
407  priv->document = g_object_ref (document);
408 
409  if (priv->job) {
410  g_signal_handlers_disconnect_by_func (priv->job,
412  sidebar_layers);
413  g_object_unref (priv->job);
414  }
415 
416  priv->job = ev_job_layers_new (document);
417  g_signal_connect (priv->job, "finished",
418  G_CALLBACK (job_finished_callback),
419  sidebar_layers);
420  /* The priority doesn't matter for this job */
422 }

+ Here is the caller graph for this function:

static const gchar* ev_sidebar_layers_get_label ( EvSidebarPage sidebar_page)
static

Definition at line 442 of file ev-sidebar-layers.c.

443 {
444  return _("Layers");
445 }

+ Here is the caller graph for this function:

static void ev_sidebar_layers_get_property ( GObject *  object,
guint  prop_id,
GValue *  value,
GParamSpec *  pspec 
)
static

Definition at line 89 of file ev-sidebar-layers.c.

93 {
94  EvSidebarLayers *ev_sidebar_layers;
95 
96  ev_sidebar_layers = EV_SIDEBAR_LAYERS (object);
97 
98  switch (prop_id) {
99  case PROP_WIDGET:
100  g_value_set_object (value, ev_sidebar_layers->priv->tree_view);
101  break;
102  default:
103  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
104  break;
105  }
106 }

+ Here is the caller graph for this function:

static void ev_sidebar_layers_init ( EvSidebarLayers ev_layers)
static

Definition at line 278 of file ev-sidebar-layers.c.

279 {
280  GtkWidget *swindow;
281  GtkTreeModel *model;
282 
283  ev_layers->priv = EV_SIDEBAR_LAYERS_GET_PRIVATE (ev_layers);
284 
285  swindow = gtk_scrolled_window_new (NULL, NULL);
286  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
287  GTK_POLICY_NEVER,
288  GTK_POLICY_AUTOMATIC);
289  /* Data Model */
291 
292  /* Layers list */
293  ev_layers->priv->tree_view = ev_sidebar_layers_create_tree_view (ev_layers);
294  gtk_tree_view_set_model (ev_layers->priv->tree_view, model);
295  g_object_unref (model);
296 
297  gtk_container_add (GTK_CONTAINER (swindow),
298  GTK_WIDGET (ev_layers->priv->tree_view));
299 
300  gtk_box_pack_start (GTK_BOX (ev_layers), swindow, TRUE, TRUE, 0);
301  gtk_widget_show_all (GTK_WIDGET (ev_layers));
302 }
GtkWidget* ev_sidebar_layers_new ( void  )

Definition at line 327 of file ev-sidebar-layers.c.

328 {
329  return GTK_WIDGET (g_object_new (EV_TYPE_SIDEBAR_LAYERS,
330  "orientation", GTK_ORIENTATION_VERTICAL,
331  NULL));
332 }

+ Here is the caller graph for this function:

static void ev_sidebar_layers_page_iface_init ( EvSidebarPageInterface iface)
static

Definition at line 448 of file ev-sidebar-layers.c.

static void ev_sidebar_layers_set_model ( EvSidebarPage sidebar_page,
EvDocumentModel model 
)
static

Definition at line 425 of file ev-sidebar-layers.c.

427 {
428  g_signal_connect (model, "notify::document",
430  sidebar_page);
431 }

+ Here is the caller graph for this function:

static gboolean ev_sidebar_layers_support_document ( EvSidebarPage sidebar_page,
EvDocument document 
)
static

Definition at line 434 of file ev-sidebar-layers.c.

436 {
437  return (EV_IS_DOCUMENT_LAYERS (document) &&
439 }

+ Here is the caller graph for this function:

void ev_sidebar_layers_update_layers_state ( EvSidebarLayers sidebar_layers)

Definition at line 365 of file ev-sidebar-layers.c.

366 {
367  GtkTreeModel *model;
368  GtkTreeIter iter;
369  EvDocumentLayers *document_layers;
370 
371  document_layers = EV_DOCUMENT_LAYERS (sidebar_layers->priv->document);
372  model = gtk_tree_view_get_model (GTK_TREE_VIEW (sidebar_layers->priv->tree_view));
373  if (gtk_tree_model_get_iter_first (model, &iter))
374  update_layers_state (model, &iter, document_layers);
375 }

+ Here is the caller graph for this function:

static void ev_sidebar_layers_visibility_changed ( GtkCellRendererToggle *  cell,
gchar *  path_str,
EvSidebarLayers ev_layers 
)
static

Definition at line 181 of file ev-sidebar-layers.c.

184 {
185  GtkTreeModel *model;
186  GtkTreePath *path;
187  GtkTreeIter iter;
188  gboolean visible;
189  EvLayer *layer;
190 
191  model = gtk_tree_view_get_model (ev_layers->priv->tree_view);
192 
193  path = gtk_tree_path_new_from_string (path_str);
194  gtk_tree_model_get_iter (model, &iter, path);
195  gtk_tree_model_get (model, &iter,
198  -1);
199 
200  visible = !visible;
201  if (visible) {
202  gint rb_group;
203 
204  ev_document_layers_show_layer (EV_DOCUMENT_LAYERS (ev_layers->priv->document),
205  layer);
206 
207  rb_group = ev_layer_get_rb_group (layer);
208  if (rb_group) {
209  gtk_tree_model_foreach (model,
210  (GtkTreeModelForeachFunc)clear_rb_group,
211  &rb_group);
212  }
213  } else {
214  ev_document_layers_hide_layer (EV_DOCUMENT_LAYERS (ev_layers->priv->document),
215  layer);
216  }
217 
218  gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
220  -1);
221 
222  if (ev_layer_is_parent (layer)) {
223  gtk_tree_model_foreach (model,
224  (GtkTreeModelForeachFunc)update_kids,
225  &iter);
226  }
227 
228  gtk_tree_path_free (path);
229 
230  g_signal_emit (ev_layers, signals[LAYERS_VISIBILITY_CHANGED], 0);
231 }

+ Here is the caller graph for this function:

G_DEFINE_TYPE_EXTENDED ( EvSidebarLayers  ,
ev_sidebar_layers  ,
GTK_TYPE_BOX  ,
,
G_IMPLEMENT_INTERFACE(EV_TYPE_SIDEBAR_PAGE,ev_sidebar_layers_page_iface_init  
)

Definition at line 56 of file ev-sidebar-layers.c.

68 {
69  EvSidebarLayers *sidebar = EV_SIDEBAR_LAYERS (object);
70 
71  if (sidebar->priv->job) {
72  g_signal_handlers_disconnect_by_func (sidebar->priv->job,
74  sidebar);
75  ev_job_cancel (sidebar->priv->job);
76  g_object_unref (sidebar->priv->job);
77  sidebar->priv->job = NULL;
78  }
79 
80  if (sidebar->priv->document) {
81  g_object_unref (sidebar->priv->document);
82  sidebar->priv->document = NULL;
83  }
84 
85  G_OBJECT_CLASS (ev_sidebar_layers_parent_class)->dispose (object);
86 }
static void job_finished_callback ( EvJobLayers job,
EvSidebarLayers sidebar_layers 
)
static

Definition at line 378 of file ev-sidebar-layers.c.

380 {
382 
383  priv = sidebar_layers->priv;
384 
385  gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), job->model);
386 
387  g_object_unref (job);
388  priv->job = NULL;
389 }

+ Here is the caller graph for this function:

static gboolean update_kids ( GtkTreeModel *  model,
GtkTreePath *  path,
GtkTreeIter *  iter,
GtkTreeIter *  parent 
)
static

Definition at line 140 of file ev-sidebar-layers.c.

144 {
145  if (gtk_tree_store_is_ancestor (GTK_TREE_STORE (model), parent, iter)) {
146  gboolean visible;
147 
148  gtk_tree_model_get (model, parent,
150  -1);
151  gtk_tree_store_set (GTK_TREE_STORE (model), iter,
153  -1);
154  }
155 
156  return FALSE;
157 }

+ Here is the caller graph for this function:

static void update_layers_state ( GtkTreeModel *  model,
GtkTreeIter *  iter,
EvDocumentLayers document_layers 
)
static

Definition at line 335 of file ev-sidebar-layers.c.

338 {
339  EvLayer *layer;
340  gboolean visible;
341  GtkTreeIter child_iter;
342 
343  do {
344  gtk_tree_model_get (model, iter,
347  -1);
348  if (layer) {
349  gboolean layer_visible;
350 
351  layer_visible = ev_document_layers_layer_is_visible (document_layers, layer);
352  if (layer_visible != visible) {
353  gtk_tree_store_set (GTK_TREE_STORE (model), iter,
354  EV_DOCUMENT_LAYERS_COLUMN_VISIBLE, layer_visible,
355  -1);
356  }
357  }
358 
359  if (gtk_tree_model_iter_children (model, &child_iter, iter))
360  update_layers_state (model, &child_iter, document_layers);
361  } while (gtk_tree_model_iter_next (model, iter));
362 }

+ Here is the caller graph for this function:

Variable Documentation

guint signals[N_SIGNALS]
static

Definition at line 54 of file ev-sidebar-layers.c.