diff options
author | José Aliste <jaliste@src.gnome.org> | 2012-12-08 10:33:21 -0300 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2012-12-08 20:30:53 +0100 |
commit | e5008bdb26df0135edfbd30a811df2332f4e036c (patch) | |
tree | b3b3d78cfc361bba00e4aa401e2e5628e355c0d7 /glib | |
parent | 8cd5cae953de374276c11711dc106de15c8dcad0 (diff) |
glib-demo: Update the demo to modify flags of annotations
https://bugs.freedesktop.org/show_bug.cgi?id=58015
Diffstat (limited to 'glib')
-rw-r--r-- | glib/demo/annots.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/glib/demo/annots.c b/glib/demo/annots.c index 4d39ba3f..3ff7f12c 100644 --- a/glib/demo/annots.c +++ b/glib/demo/annots.c @@ -669,6 +669,62 @@ pgd_annots_selection_changed (GtkTreeSelection *treeselection, } static void +pgd_annots_flags_toggled (GtkCellRendererToggle *renderer, + gchar *path_str, + PgdAnnotsDemo *demo, + gint column, + PopplerAnnotFlag flag_bit) +{ + GtkTreeIter iter; + gboolean fixed; + PopplerAnnot *annot; + PopplerAnnotFlag flags; + GtkTreePath *path = gtk_tree_path_new_from_string (path_str); + GtkTreeModel *model = GTK_TREE_MODEL (demo->model); + + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, column, &fixed, ANNOTS_COLUMN, &annot,-1); + + fixed ^= 1; + flags = poppler_annot_get_flags (annot); + + if (fixed) + flags |= flag_bit; + else + flags &= ~flag_bit; + + poppler_annot_set_flags (annot, flags); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, fixed, -1); + + pgd_annot_view_set_annot (demo, annot); + gtk_tree_path_free (path); +} + +static void +pgd_annots_hidden_flag_toggled (GtkCellRendererToggle *renderer, + gchar *path_str, + PgdAnnotsDemo *demo) +{ + pgd_annots_flags_toggled (renderer, path_str, demo, ANNOTS_FLAG_HIDDEN_COLUMN, POPPLER_ANNOT_FLAG_HIDDEN); +} + +static void +pgd_annots_print_flag_toggled (GtkCellRendererToggle *renderer, + gchar *path_str, + PgdAnnotsDemo *demo) +{ + pgd_annots_flags_toggled (renderer, path_str, demo, ANNOTS_FLAG_PRINT_COLUMN, POPPLER_ANNOT_FLAG_PRINT); +} + +static void +pgd_annots_invisible_flag_toggled (GtkCellRendererToggle *renderer, + gchar *path_str, + PgdAnnotsDemo *demo) +{ + pgd_annots_flags_toggled (renderer, path_str, demo, ANNOTS_FLAG_INVISIBLE_COLUMN, POPPLER_ANNOT_FLAG_INVISIBLE); +} + +static void pgd_annots_add_annot (GtkWidget *button, PgdAnnotsDemo *demo) { @@ -898,6 +954,9 @@ pgd_annots_create_widget (PopplerDocument *document) NULL); renderer = gtk_cell_renderer_toggle_new (); + g_signal_connect (renderer, "toggled", + G_CALLBACK (pgd_annots_invisible_flag_toggled), + (gpointer) demo); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), ANNOTS_FLAG_INVISIBLE_COLUMN, "Invisible", renderer, @@ -905,6 +964,9 @@ pgd_annots_create_widget (PopplerDocument *document) NULL); renderer = gtk_cell_renderer_toggle_new (); + g_signal_connect (renderer, "toggled", + G_CALLBACK (pgd_annots_hidden_flag_toggled), + (gpointer) demo); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), ANNOTS_FLAG_HIDDEN_COLUMN, "Hidden", renderer, @@ -912,6 +974,9 @@ pgd_annots_create_widget (PopplerDocument *document) NULL); renderer = gtk_cell_renderer_toggle_new (); + g_signal_connect (renderer, "toggled", + G_CALLBACK (pgd_annots_print_flag_toggled), + (gpointer) demo); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), ANNOTS_FLAG_PRINT_COLUMN, "Print", renderer, |