From 51ecd47ed922b1beba9c54734ea5cb9b6d067254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Poo-Caama=C3=B1o?= Date: Mon, 28 Oct 2013 22:52:22 -0700 Subject: [PATCH 6/9] glib-demo: Add Square and Circle annotations demo --- glib/demo/annots.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/glib/demo/annots.c b/glib/demo/annots.c index c34ebbb..10c1c8b 100644 --- a/glib/demo/annots.c +++ b/glib/demo/annots.c @@ -363,6 +363,8 @@ pgd_annots_start_add_annot (GtkWidget *button, pgd_annots_update_cursor (demo, GDK_TCROSS); break; case POPPLER_ANNOT_LINE: + case POPPLER_ANNOT_SQUARE: + case POPPLER_ANNOT_CIRCLE: demo->mode = MODE_DRAWING; pgd_annots_update_cursor (demo, GDK_TCROSS); break; @@ -878,6 +880,12 @@ pgd_annots_add_annotation (PgdAnnotsDemo *demo) rect.x1, rect.y1, rect.x2, rect.y2); break; + case POPPLER_ANNOT_SQUARE: + annot = poppler_annot_geometry_new_square (demo->doc, &rect); + break; + case POPPLER_ANNOT_CIRCLE: + annot = poppler_annot_geometry_new_circle (demo->doc, &rect); + break; default: g_printerr ("Annotation not implemented: %d\n", demo->annot_type); return; @@ -1042,9 +1050,12 @@ pgd_annots_drawing_area_motion_notify (GtkWidget *area, rect.y2 = height - demo->stop.y; poppler_annot_set_rectangle (demo->active_annot, rect); - poppler_annot_line_set_vertices (POPPLER_ANNOT_LINE (demo->active_annot), - rect.x1, rect.y1, - rect.x2, rect.y2); + + if (demo->annot_type == POPPLER_ANNOT_LINE) { + poppler_annot_line_set_vertices (POPPLER_ANNOT_LINE (demo->active_annot), + rect.x1, rect.y1, + rect.x2, rect.y2); + } pgd_annot_view_set_annot (demo, demo->active_annot); if (demo->annotations_idle == 0) { @@ -1164,6 +1175,19 @@ pgd_annots_create_widget (PopplerDocument *document) SELECTED_TYPE_COLUMN, POPPLER_ANNOT_LINE, SELECTED_LABEL_COLUMN, "Line", -1); + + gtk_list_store_append (model, &iter); + gtk_list_store_set (model, &iter, + SELECTED_TYPE_COLUMN, POPPLER_ANNOT_SQUARE, + SELECTED_LABEL_COLUMN, "Square", + -1); + + gtk_list_store_append (model, &iter); + gtk_list_store_set (model, &iter, + SELECTED_TYPE_COLUMN, POPPLER_ANNOT_CIRCLE, + SELECTED_LABEL_COLUMN, "Circle", + -1); + demo->type_selector = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model)); g_object_unref (model); -- 1.7.9.5