[cairo-commit] goocanvas/demo demo.c,1.4,1.5

Damon Chaplin commit at pdx.freedesktop.org
Mon Apr 24 08:14:35 PDT 2006


Committed by: damon

Update of /cvs/cairo/goocanvas/demo
In directory kemper:/tmp/cvs-serv28410/demo

Modified Files:
	demo.c 
Log Message:
2006-04-24  Damon Chaplin  <damon at gnome.org>

	* Released GooCanvas 0.3

2006-04-24  Damon Chaplin  <damon at gnome.org>

	* src/goocanvasview.c: added "model", "scale", "anchor", "x1", "y1",
	"x2", "y2" properties, and goo_canvas_view_get_bounds() and
	goo_canvas_view_get_scale() accessors.
	Removed goo_canvas_view_set_anchor() as the property should be enough.
	(I think we should only have accessor functions for major properties.)



Index: demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- demo.c	22 Apr 2006 19:17:28 -0000	1.4
+++ demo.c	24 Apr 2006 15:14:33 -0000	1.5
@@ -67,74 +67,14 @@
 
 
 static void
-anchor_nw_toggled (GtkWidget *button, GooCanvasView *canvas_view)
-{
-  if (GTK_TOGGLE_BUTTON (button)->active)
-    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_NW);
-}
-
-
-static void
-anchor_n_toggled (GtkWidget *button, GooCanvasView *canvas_view)
-{
-  if (GTK_TOGGLE_BUTTON (button)->active)
-    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_N);
-}
-
-
-static void
-anchor_ne_toggled (GtkWidget *button, GooCanvasView *canvas_view)
-{
-  if (GTK_TOGGLE_BUTTON (button)->active)
-    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_NE);
-}
-
-
-static void
-anchor_w_toggled (GtkWidget *button, GooCanvasView *canvas_view)
-{
-  if (GTK_TOGGLE_BUTTON (button)->active)
-    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_W);
-}
-
-
-static void
-anchor_c_toggled (GtkWidget *button, GooCanvasView *canvas_view)
-{
-  if (GTK_TOGGLE_BUTTON (button)->active)
-    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_CENTER);
-}
-
-
-static void
-anchor_e_toggled (GtkWidget *button, GooCanvasView *canvas_view)
-{
-  if (GTK_TOGGLE_BUTTON (button)->active)
-    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_E);
-}
-
-
-static void
-anchor_sw_toggled (GtkWidget *button, GooCanvasView *canvas_view)
-{
-  if (GTK_TOGGLE_BUTTON (button)->active)
-    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_SW);
-}
-
-
-static void
-anchor_s_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+anchor_toggled (GtkWidget *button, GooCanvasView *canvas_view)
 {
-  if (GTK_TOGGLE_BUTTON (button)->active)
-    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_S);
-}
+  GtkAnchorType anchor;
 
+  anchor = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "anchor"));
 
-static void
-anchor_se_toggled (GtkWidget *button, GooCanvasView *canvas_view)
-{
   if (GTK_TOGGLE_BUTTON (button)->active)
-    goo_canvas_view_set_anchor (canvas_view, GTK_ANCHOR_SE);
+    g_object_set (canvas_view, "anchor", anchor, NULL);
 }
 
 
@@ -517,72 +457,90 @@
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
 	g_signal_connect (w, "toggled",
-			  (GtkSignalFunc) anchor_nw_toggled,
+			  (GtkSignalFunc) anchor_toggled,
 			  canvas_view);
+	g_object_set_data (G_OBJECT (w), "anchor",
+			   GINT_TO_POINTER (GTK_ANCHOR_NW));
 
 	w = gtk_radio_button_new_with_label (group, "N");
 	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
 	g_signal_connect (w, "toggled",
-			  (GtkSignalFunc) anchor_n_toggled,
+			  (GtkSignalFunc) anchor_toggled,
 			  canvas_view);
+	g_object_set_data (G_OBJECT (w), "anchor",
+			   GINT_TO_POINTER (GTK_ANCHOR_N));
 
 	w = gtk_radio_button_new_with_label (group, "NE");
 	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
 	g_signal_connect (w, "toggled",
-			  (GtkSignalFunc) anchor_ne_toggled,
+			  (GtkSignalFunc) anchor_toggled,
 			  canvas_view);
+	g_object_set_data (G_OBJECT (w), "anchor",
+			   GINT_TO_POINTER (GTK_ANCHOR_NE));
 
 	w = gtk_radio_button_new_with_label (group, "W");
 	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
 	g_signal_connect (w, "toggled",
-			  (GtkSignalFunc) anchor_w_toggled,
+			  (GtkSignalFunc) anchor_toggled,
 			  canvas_view);
+	g_object_set_data (G_OBJECT (w), "anchor",
+			   GINT_TO_POINTER (GTK_ANCHOR_W));
 
 	w = gtk_radio_button_new_with_label (group, "C");
 	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
 	g_signal_connect (w, "toggled",
-			  (GtkSignalFunc) anchor_c_toggled,
+			  (GtkSignalFunc) anchor_toggled,
 			  canvas_view);
+	g_object_set_data (G_OBJECT (w), "anchor",
+			   GINT_TO_POINTER (GTK_ANCHOR_CENTER));
 
 	w = gtk_radio_button_new_with_label (group, "E");
 	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
 	g_signal_connect (w, "toggled",
-			  (GtkSignalFunc) anchor_e_toggled,
+			  (GtkSignalFunc) anchor_toggled,
 			  canvas_view);
+	g_object_set_data (G_OBJECT (w), "anchor",
+			   GINT_TO_POINTER (GTK_ANCHOR_E));
 
 	w = gtk_radio_button_new_with_label (group, "SW");
 	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
 	g_signal_connect (w, "toggled",
-			  (GtkSignalFunc) anchor_sw_toggled,
+			  (GtkSignalFunc) anchor_toggled,
 			  canvas_view);
+	g_object_set_data (G_OBJECT (w), "anchor",
+			   GINT_TO_POINTER (GTK_ANCHOR_SW));
 
 	w = gtk_radio_button_new_with_label (group, "S");
 	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
 	g_signal_connect (w, "toggled",
-			  (GtkSignalFunc) anchor_s_toggled,
+			  (GtkSignalFunc) anchor_toggled,
 			  canvas_view);
+	g_object_set_data (G_OBJECT (w), "anchor",
+			   GINT_TO_POINTER (GTK_ANCHOR_S));
 
 	w = gtk_radio_button_new_with_label (group, "SE");
 	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (w));
 	gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
 	gtk_widget_show (w);
 	g_signal_connect (w, "toggled",
-			  (GtkSignalFunc) anchor_se_toggled,
+			  (GtkSignalFunc) anchor_toggled,
 			  canvas_view);
+	g_object_set_data (G_OBJECT (w), "anchor",
+			   GINT_TO_POINTER (GTK_ANCHOR_SE));
 
 	
 	/* Layout the stuff */



More information about the cairo-commit mailing list