From a8f1aa183bc408b87794a52b6d8dfdf5dab20f9d 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 1c8c1e3..7dd82d6 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, @@ -619,6 +615,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) { @@ -653,12 +650,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)) @@ -700,22 +694,12 @@ pgd_annots_add_annot_to_model (PgdAnnotsDemo *demo, GtkTreeIter iter; 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), @@ -727,11 +711,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); - return iter; } @@ -1235,39 +1214,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