23 #include <glib/gi18n.h>
63 #define EV_SIDEBAR_LAYERS_GET_PRIVATE(object) \
64 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR_LAYERS, EvSidebarLayersPrivate))
67 ev_sidebar_layers_dispose (GObject *
object)
71 if (sidebar->priv->job) {
72 g_signal_handlers_disconnect_by_func (sidebar->priv->job,
76 g_object_unref (sidebar->priv->job);
77 sidebar->priv->job = NULL;
80 if (sidebar->priv->document) {
81 g_object_unref (sidebar->priv->document);
82 sidebar->priv->document = NULL;
85 G_OBJECT_CLASS (ev_sidebar_layers_parent_class)->dispose (
object);
100 g_value_set_object (value, ev_sidebar_layers->priv->tree_view);
103 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
108 static GtkTreeModel *
111 GtkTreeModel *retval;
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,
145 if (gtk_tree_store_is_ancestor (GTK_TREE_STORE (model), parent, iter)) {
148 gtk_tree_model_get (model, parent,
151 gtk_tree_store_set (GTK_TREE_STORE (model), iter,
167 gtk_tree_model_get (model, iter,
171 if (group == *rb_group) {
172 gtk_tree_store_set (GTK_TREE_STORE (model), iter,
191 model = gtk_tree_view_get_model (ev_layers->priv->tree_view);
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,
209 gtk_tree_model_foreach (model,
218 gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
223 gtk_tree_model_foreach (model,
228 gtk_tree_path_free (path);
236 GtkTreeView *tree_view;
237 GtkTreeViewColumn *column;
238 GtkCellRenderer *renderer;
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),
246 column = gtk_tree_view_column_new ();
249 gtk_tree_view_column_pack_start (column, renderer,
FALSE);
250 gtk_tree_view_column_set_attributes (column, renderer,
256 g_object_set (G_OBJECT (renderer),
260 g_signal_connect (renderer,
"toggled",
262 (gpointer)ev_layers);
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,
270 g_object_set (G_OBJECT (renderer),
"ellipsize", PANGO_ELLIPSIZE_END, NULL);
272 gtk_tree_view_append_column (tree_view, column);
285 swindow = gtk_scrolled_window_new (NULL, NULL);
286 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
288 GTK_POLICY_AUTOMATIC);
294 gtk_tree_view_set_model (ev_layers->priv->tree_view, model);
295 g_object_unref (model);
297 gtk_container_add (GTK_CONTAINER (swindow),
298 GTK_WIDGET (ev_layers->priv->tree_view));
300 gtk_box_pack_start (GTK_BOX (ev_layers), swindow,
TRUE,
TRUE, 0);
301 gtk_widget_show_all (GTK_WIDGET (ev_layers));
307 GObjectClass *g_object_class = G_OBJECT_CLASS (ev_layers_class);
310 g_object_class->dispose = ev_sidebar_layers_dispose;
314 g_object_class_override_property (g_object_class,
PROP_WIDGET,
"main-widget");
317 g_signal_new (
"layers_visibility_changed",
318 G_TYPE_FROM_CLASS (g_object_class),
319 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
322 g_cclosure_marshal_VOID__VOID,
323 G_TYPE_NONE, 0, G_TYPE_NONE);
330 "orientation", GTK_ORIENTATION_VERTICAL,
341 GtkTreeIter child_iter;
344 gtk_tree_model_get (model, iter,
349 gboolean layer_visible;
352 if (layer_visible != visible) {
353 gtk_tree_store_set (GTK_TREE_STORE (model), iter,
359 if (gtk_tree_model_iter_children (model, &child_iter, iter))
361 }
while (gtk_tree_model_iter_next (model, iter));
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))
383 priv = sidebar_layers->priv;
385 gtk_tree_view_set_model (GTK_TREE_VIEW (priv->
tree_view), job->
model);
387 g_object_unref (job);
403 gtk_tree_view_set_model (GTK_TREE_VIEW (priv->
tree_view), NULL);
407 priv->
document = g_object_ref (document);
410 g_signal_handlers_disconnect_by_func (priv->
job,
413 g_object_unref (priv->
job);
417 g_signal_connect (priv->
job,
"finished",
428 g_signal_connect (model,
"notify::document",