From 5f9889908b4a33bbb852367d4bc4de9c7b219b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Poo-Caama=C3=B1o?= Date: Mon, 28 Oct 2013 22:41:41 -0700 Subject: [PATCH] glib-demo: Simplify annotations list and its properties * Move the annotation's rectangle to properties to make the list view of annotations cleaner. * Remove duplicated information: flags and page are already present in the UI. https://bugs.freedesktop.org/show_bug.cgi?id=70982 --- glib/demo/annots.c | 56 ++++------------------------------------------------ 1 file changed, 4 insertions(+), 52 deletions(-) diff --git a/glib/demo/annots.c b/glib/demo/annots.c index b6c1c14..dfd2dda 100644 --- a/glib/demo/annots.c +++ b/glib/demo/annots.c @@ -23,10 +23,6 @@ #include "utils.h" enum { - ANNOTS_X1_COLUMN, - ANNOTS_Y1_COLUMN, - ANNOTS_X2_COLUMN, - ANNOTS_Y2_COLUMN, ANNOTS_TYPE_COLUMN, ANNOTS_COLOR_COLUMN, ANNOTS_FLAG_INVISIBLE_COLUMN, @@ -585,6 +581,7 @@ pgd_annot_view_set_annot (PgdAnnotsDemo *demo, gint row = 0; gchar *text; time_t timet; + PopplerRectangle rect; alignment = gtk_bin_get_child (GTK_BIN (demo->annot_view)); if (alignment) { @@ -619,12 +616,9 @@ pgd_annot_view_set_annot (PgdAnnotsDemo *demo, pgd_table_add_property (GTK_GRID (table), "Modified:", text, &row); g_free (text); - text = g_strdup_printf ("%d", poppler_annot_get_flags (annot)); - pgd_table_add_property (GTK_GRID (table), "Flags:", text, &row); - g_free (text); - - text = g_strdup_printf ("%d", poppler_annot_get_page_index (annot)); - pgd_table_add_property (GTK_GRID (table), "Page:", text, &row); + poppler_annot_get_rectangle (annot, &rect); + text = g_strdup_printf ("(%.1f,%.1f) (%.1f,%.1f)", rect.x1, rect.y1, rect.x2, rect.y2); + pgd_table_add_property (GTK_GRID (table), "Coords:", text, &row); g_free (text); if (POPPLER_IS_ANNOT_MARKUP (annot)) @@ -665,22 +659,12 @@ pgd_annots_add_annot_to_model (PgdAnnotsDemo *demo, GtkTreePath *path; GdkPixbuf *pixbuf; PopplerAnnotFlag flags; - gchar *x1, *y1, *x2, *y2; - - x1 = g_strdup_printf ("%.2f", area.x1); - y1 = g_strdup_printf ("%.2f", area.y1); - x2 = g_strdup_printf ("%.2f", area.x2); - y2 = g_strdup_printf ("%.2f", area.y2); pixbuf = get_annot_color (annot); flags = poppler_annot_get_flags (annot); gtk_list_store_append (demo->model, &iter); gtk_list_store_set (demo->model, &iter, - ANNOTS_X1_COLUMN, x1, - ANNOTS_Y1_COLUMN, y1, - ANNOTS_X2_COLUMN, x2, - ANNOTS_Y2_COLUMN, y2, ANNOTS_TYPE_COLUMN, get_annot_type (annot), ANNOTS_COLOR_COLUMN, pixbuf, ANNOTS_FLAG_INVISIBLE_COLUMN, (flags & POPPLER_ANNOT_FLAG_INVISIBLE), @@ -697,11 +681,6 @@ pgd_annots_add_annot_to_model (PgdAnnotsDemo *demo, if (pixbuf) g_object_unref (pixbuf); - - g_free (x1); - g_free (y1); - g_free (x2); - g_free (y2); } static void @@ -1191,39 +1170,12 @@ pgd_annots_create_widget (PopplerDocument *document) GTK_POLICY_AUTOMATIC); demo->model = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_OBJECT); treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (demo->model)); demo->tree_view = treeview; - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), - ANNOTS_X1_COLUMN, "X1", - renderer, - "text", ANNOTS_X1_COLUMN, - NULL); - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), - ANNOTS_Y1_COLUMN, "Y1", - renderer, - "text", ANNOTS_Y1_COLUMN, - NULL); - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), - ANNOTS_X2_COLUMN, "X2", - renderer, - "text", ANNOTS_X2_COLUMN, - NULL); - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), - ANNOTS_Y2_COLUMN, "Y2", - renderer, - "text", ANNOTS_Y2_COLUMN, - NULL); - column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, "Type"); gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); -- 1.7.9.5