[goocanvas/new-api] 2010-06-28 Damon Chaplin <damon gnome org>



commit 3fe09c3a3a02e8638bf89e6ce5be235dd7aa5e91
Author: Damon Chaplin <damon gnome org>
Date:   Mon Jun 28 21:37:49 2010 +0100

    2010-06-28  Damon Chaplin  <damon gnome org>
    
    	    * demo/demo-events.c: added tooltips to explain which items should
    	    be getting events.

 ChangeLog          |    5 +++++
 demo/demo-events.c |   52 ++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 45 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fce75ad..3abfc79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-06-28  Damon Chaplin  <damon gnome org>
 
+	* demo/demo-events.c: added tooltips to explain which items should
+	be getting events.
+
+2010-06-28  Damon Chaplin  <damon gnome org>
+
 	* src/goocanvastable.c (goo_canvas_table_size_allocate_pass3):
 	handle RTL direction when clipping children. Though it should
 	possibly clip off the left of the child rather than the left.
diff --git a/demo/demo-events.c b/demo/demo-events.c
index 73aab6f..9bf3336 100644
--- a/demo/demo-events.c
+++ b/demo/demo-events.c
@@ -10,13 +10,15 @@ on_motion_notify (GooCanvasItem *item,
 		  GdkEventMotion *event,
 		  gpointer data)
 {
+  static gint message_id = 0;
   char *item_id = NULL;
 
   if (target)
     item_id = g_object_get_data (G_OBJECT (target), "id");
 
   if (item_id)
-    g_print ("%s item received 'motion-notify' signal\n", item_id);
+    g_print ("%i: %s item received 'motion-notify' signal\n", message_id++,
+	     item_id);
 
   return FALSE;
 }
@@ -34,7 +36,8 @@ static void
 create_events_area (GtkWidget              *canvas,
 		    gint                    area_num,
 		    GooCanvasPointerEvents  pointer_events,
-		    gchar                  *label)
+		    gchar                  *label,
+		    gchar                  *tooltip)
 {
   gint row = area_num / 3, col = area_num % 3;
   gdouble x = col * 200, y = row * 150;
@@ -46,8 +49,16 @@ create_events_area (GtkWidget              *canvas,
 
   dash = goo_canvas_line_dash_new (2, 5.0, 5.0);
 
+  /* Create an invisible rect just to show the tooltip. */
+  rect = goo_canvas_rect_new (root, x, y, 200, 150,
+			      "tooltip", tooltip,
+			      /*"stroke-pattern", NULL,*/
+			      "pointer-events", GOO_CANVAS_EVENTS_ALL,
+			      NULL);
+
   /* Create invisible item. */
   rect = goo_canvas_rect_new (root, x + 45, y + 35, 30, 30,
+			      "tooltip", tooltip,
 			      "fill-color", "red",
 			      "visibility", GOO_CANVAS_ITEM_INVISIBLE,
 			      "line-width", 5.0,
@@ -68,6 +79,7 @@ create_events_area (GtkWidget              *canvas,
 
   /* Create unpainted item. */
   rect = goo_canvas_rect_new (root, x + 85, y + 35, 30, 30,
+			      "tooltip", tooltip,
 			      "stroke-pattern", NULL,
 			      "line-width", 5.0,
 			      "pointer-events", pointer_events,
@@ -87,6 +99,7 @@ create_events_area (GtkWidget              *canvas,
 
   /* Create stroked item. */
   rect = goo_canvas_rect_new (root, x + 125, y + 35, 30, 30,
+			      "tooltip", tooltip,
 			      "line-width", 5.0,
 			      "pointer-events", pointer_events,
 			      NULL);
@@ -96,6 +109,7 @@ create_events_area (GtkWidget              *canvas,
 
   /* Create filled item. */
   rect = goo_canvas_rect_new (root, x + 60, y + 75, 30, 30,
+			      "tooltip", tooltip,
 			      "fill-color", "red",
 			      "stroke-pattern", NULL,
 			      "line-width", 5.0,
@@ -107,6 +121,7 @@ create_events_area (GtkWidget              *canvas,
 
   /* Create stroked & filled item. */
   rect = goo_canvas_rect_new (root, x + 100, y + 75, 30, 30,
+			      "tooltip", tooltip,
 			      "fill-color", "red",
 			      "line-width", 5.0,
 			      "pointer-events", pointer_events,
@@ -116,6 +131,7 @@ create_events_area (GtkWidget              *canvas,
   setup_item_signals (rect);
 
   goo_canvas_text_new (root, label, x + 100, y + 130, -1, GTK_ANCHOR_CENTER,
+		       "tooltip", tooltip,
 		       "font", "Sans 12",
 		       "fill-color", "blue",
 		       NULL);
@@ -135,7 +151,7 @@ create_events_page (void)
 
   /* Instructions */
 
-  label = gtk_label_new ("Move the mouse over the items to check they receive the right motion events.\nThe first 2 items in each group are 1) invisible and 2) visible but unpainted.");
+  label = gtk_label_new ("Move the mouse over the items to check they receive the right motion events.\nThe first 2 items in each group are 1) invisible and 2) visible but unpainted.\nThe tooltips explain what events each group of items should be receiving.");
   gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
   gtk_widget_show (label);
 
@@ -151,21 +167,33 @@ create_events_page (void)
   gtk_widget_show (frame);
 
   canvas = goo_canvas_new ();
+  g_object_set (G_OBJECT (canvas),
+		"has-tooltip", TRUE,
+		NULL);
 
   gtk_widget_set_size_request (canvas, 600, 450);
   goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 600, 450);
   gtk_container_add (GTK_CONTAINER (frame), canvas);
   gtk_widget_show (canvas);
 
-  create_events_area (canvas, 0, GOO_CANVAS_EVENTS_NONE, "none");
-  create_events_area (canvas, 1, GOO_CANVAS_EVENTS_VISIBLE_PAINTED, "visible-painted");
-  create_events_area (canvas, 2, GOO_CANVAS_EVENTS_VISIBLE_FILL, "visible-fill");
-  create_events_area (canvas, 3, GOO_CANVAS_EVENTS_VISIBLE_STROKE, "visible-stroke");
-  create_events_area (canvas, 4, GOO_CANVAS_EVENTS_VISIBLE, "visible");
-  create_events_area (canvas, 5, GOO_CANVAS_EVENTS_PAINTED, "painted");
-  create_events_area (canvas, 6, GOO_CANVAS_EVENTS_FILL, "fill");
-  create_events_area (canvas, 7, GOO_CANVAS_EVENTS_STROKE, "stroke");
-  create_events_area (canvas, 8, GOO_CANVAS_EVENTS_ALL, "all");
+  create_events_area (canvas, 0, GOO_CANVAS_EVENTS_NONE, "none",
+		      "These items should receive no events at all");
+  create_events_area (canvas, 1, GOO_CANVAS_EVENTS_VISIBLE_PAINTED, "visible-painted",
+		      "These items should receive events in all painted areas, but only when the item is visible (i.e. not the top-left item)");
+  create_events_area (canvas, 2, GOO_CANVAS_EVENTS_VISIBLE_FILL, "visible-fill",
+		      "These items should receive events in the filled area, but only when the item is visible (i.e. not the top-left item)");
+  create_events_area (canvas, 3, GOO_CANVAS_EVENTS_VISIBLE_STROKE, "visible-stroke",
+		      "These items should receive events in the stroked area, but only when the item is visible (i.e. not the top-left item)");
+  create_events_area (canvas, 4, GOO_CANVAS_EVENTS_VISIBLE, "visible",
+		      "These items should receive events in the filled or stroked area, but only when the item is visible (i.e. not the top-left item)");
+  create_events_area (canvas, 5, GOO_CANVAS_EVENTS_PAINTED, "painted",
+		      "These items should receive events in all painted areas, whether the item is visible or not (i.e. the top-middle item should get no events)");
+  create_events_area (canvas, 6, GOO_CANVAS_EVENTS_FILL, "fill",
+		      "These items should always receive events in the filled area");
+  create_events_area (canvas, 7, GOO_CANVAS_EVENTS_STROKE, "stroke",
+		      "These items should always receive events in the stroked area");
+  create_events_area (canvas, 8, GOO_CANVAS_EVENTS_ALL, "all",
+		      "These items should always receive events in the filled and stroked area");
 
   return vbox;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]