[cairo-commit]
goocanvas/demo Makefile.am, 1.5, 1.6 demo-arrowhead.c,
1.1, 1.2 demo-events.c, 1.2, 1.3 demo-features.c, 1.1,
1.2 demo-fifteen.c, 1.2, 1.3 demo-focus.c, 1.2,
1.3 demo-grabs.c, 1.1, 1.2 demo-paths.c, 1.2,
1.3 demo-scalability.c, 1.2, 1.3 demo.c, 1.8,
1.9 scalability-demo.c, 1.3, 1.4 simple-demo.c, 1.2,
1.3 units-demo.c, 1.1, 1.2
Damon Chaplin
commit at pdx.freedesktop.org
Wed Nov 29 10:47:06 PST 2006
Committed by: damon
Update of /cvs/cairo/goocanvas/demo
In directory kemper:/tmp/cvs-serv24034/demo
Modified Files:
Makefile.am demo-arrowhead.c demo-events.c demo-features.c
demo-fifteen.c demo-focus.c demo-grabs.c demo-paths.c
demo-scalability.c demo.c scalability-demo.c simple-demo.c
units-demo.c
Log Message:
Updated demo and docs for new code
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am 31 Aug 2006 15:45:09 -0000 1.5
+++ Makefile.am 29 Nov 2006 18:47:02 -0000 1.6
@@ -7,20 +7,32 @@
-I$(top_srcdir)/src \
@PACKAGE_CFLAGS@
-noinst_PROGRAMS = demo simple-demo scalability-demo units-demo
+noinst_PROGRAMS = demo simple-demo scalability-demo units-demo widgets-demo mv-demo mv-simple-demo
demo_SOURCES = \
demo.c demo-fifteen.c demo-scalability.c demo-grabs.c \
- demo-arrowhead.c demo-features.c demo-events.c demo-paths.c \
- demo-focus.c
+ demo-arrowhead.c demo-features.c demo-events.c \
+ demo-paths.c demo-focus.c
demo_LDADD = $(top_builddir)/src/libgoocanvas.la @PACKAGE_LIBS@ $(INTLLIBS)
+mv_demo_SOURCES = \
+ mv-demo.c mv-demo-fifteen.c mv-demo-scalability.c mv-demo-grabs.c \
+ mv-demo-arrowhead.c mv-demo-features.c mv-demo-events.c \
+ mv-demo-paths.c mv-demo-focus.c
+
+mv_demo_LDADD = $(top_builddir)/src/libgoocanvas.la @PACKAGE_LIBS@ $(INTLLIBS)
+
simple_demo_SOURCES = \
simple-demo.c
simple_demo_LDADD = $(top_builddir)/src/libgoocanvas.la @PACKAGE_LIBS@ $(INTLLIBS)
+mv_simple_demo_SOURCES = \
+ mv-simple-demo.c
+
+mv_simple_demo_LDADD = $(top_builddir)/src/libgoocanvas.la @PACKAGE_LIBS@ $(INTLLIBS)
+
scalability_demo_SOURCES = \
scalability-demo.c
@@ -31,5 +43,10 @@
units_demo_LDADD = $(top_builddir)/src/libgoocanvas.la @PACKAGE_LIBS@ $(INTLLIBS)
+widgets_demo_SOURCES = \
+ widgets-demo.c
+
+widgets_demo_LDADD = $(top_builddir)/src/libgoocanvas.la @PACKAGE_LIBS@ $(INTLLIBS)
+
EXTRA_DIST = flower.png toroid.png
Index: demo-arrowhead.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo-arrowhead.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- demo-arrowhead.c 12 Apr 2006 10:45:52 -0000 1.1
+++ demo-arrowhead.c 29 Nov 2006 18:47:02 -0000 1.2
@@ -3,6 +3,7 @@
#include <gtk/gtk.h>
#include <goocanvas.h>
+
#define LEFT 50.0
#define RIGHT 350.0
#define MIDDLE 150.0
@@ -13,7 +14,7 @@
static void
-set_dimension (GooCanvasView *canvas, char *arrow_name, char *text_name,
+set_dimension (GooCanvas *canvas, char *arrow_name, char *text_name,
double x1, double y1, double x2, double y2,
double tx, double ty, int dim)
{
@@ -51,7 +52,7 @@
static void
-set_arrow_shape (GooCanvasView *canvas)
+set_arrow_shape (GooCanvas *canvas)
{
int width;
int shape_a, shape_b, shape_c;
@@ -187,22 +188,6 @@
static void
-create_drag_box (GtkWidget *canvas,
- GooCanvasItem *root,
- char *box_name)
-{
- GooCanvasItem *box;
-
- box = goo_canvas_rect_new (root, 0, 0, 10, 10,
- "fill_color", "black",
- "stroke_color", "black",
- "line_width", 1.0,
- NULL);
- g_object_set_data (G_OBJECT (canvas), box_name, box);
-}
-
-
-static void
create_dimension (GtkWidget *canvas,
GooCanvasItem *root,
char *arrow_name,
@@ -261,13 +246,11 @@
static gboolean
-on_enter_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_enter_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventCrossing *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (target);
-
g_object_set (item,
"fill_color", "red",
NULL);
@@ -277,13 +260,11 @@
static gboolean
-on_leave_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_leave_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEvent *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (target);
-
g_object_set (item,
"fill_color", "black",
NULL);
@@ -293,20 +274,20 @@
static gboolean
-on_button_press (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_button_press (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
- GooCanvasView *canvas_view;
+ GooCanvas *canvas;
GdkCursor *fleur;
fleur = gdk_cursor_new (GDK_FLEUR);
- canvas_view = goo_canvas_item_view_get_canvas_view (view);
- goo_canvas_view_pointer_grab (canvas_view, view,
- GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
- fleur,
- event->time);
+ canvas = goo_canvas_item_get_canvas (item);
+ goo_canvas_pointer_grab (canvas, item,
+ GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
+ fleur,
+ event->time);
gdk_cursor_unref (fleur);
return TRUE;
@@ -314,28 +295,27 @@
static gboolean
-on_button_release (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_button_release (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
- GooCanvasView *canvas_view;
+ GooCanvas *canvas;
- canvas_view = goo_canvas_item_view_get_canvas_view (view);
- goo_canvas_view_pointer_ungrab (canvas_view, view, event->time);
+ canvas = goo_canvas_item_get_canvas (item);
+ goo_canvas_pointer_ungrab (canvas, item, event->time);
return TRUE;
}
static gboolean
-on_motion (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_motion (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventMotion *event,
gpointer data)
{
- GooCanvasView *canvas = goo_canvas_item_view_get_canvas_view (view);
- GooCanvasItem *item = goo_canvas_item_view_get_item (target);
+ GooCanvas *canvas = goo_canvas_item_get_canvas (item);
int x, y, width, shape_a, shape_b, shape_c;
gboolean change = FALSE;
@@ -391,29 +371,34 @@
static void
-on_item_view_created (GooCanvasView *view,
- GooCanvasItemView *item_view,
- GooCanvasItem *item,
- gpointer data)
+create_drag_box (GtkWidget *canvas,
+ GooCanvasItem *root,
+ char *box_name)
{
- if (GOO_IS_CANVAS_RECT (item))
- {
- g_signal_connect (item_view, "enter_notify_event",
- (GtkSignalFunc) on_enter_notify,
- NULL);
- g_signal_connect (item_view, "leave_notify_event",
- (GtkSignalFunc) on_leave_notify,
- NULL);
- g_signal_connect (item_view, "button_press_event",
- (GtkSignalFunc) on_button_press,
- NULL);
- g_signal_connect (item_view, "button_release_event",
- (GtkSignalFunc) on_button_release,
- NULL);
- g_signal_connect (item_view, "motion_notify_event",
- (GtkSignalFunc) on_motion,
- NULL);
- }
+ GooCanvasItem *item;
+
+ item = goo_canvas_rect_new (root, 0, 0, 10, 10,
+ "fill_color", "black",
+ "stroke_color", "black",
+ "line_width", 1.0,
+ NULL);
+ g_object_set_data (G_OBJECT (canvas), box_name, item);
+
+ g_signal_connect (item, "enter_notify_event",
+ (GtkSignalFunc) on_enter_notify,
+ NULL);
+ g_signal_connect (item, "leave_notify_event",
+ (GtkSignalFunc) on_leave_notify,
+ NULL);
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) on_button_press,
+ NULL);
+ g_signal_connect (item, "button_release_event",
+ (GtkSignalFunc) on_button_release,
+ NULL);
+ g_signal_connect (item, "motion_notify_event",
+ (GtkSignalFunc) on_motion,
+ NULL);
}
@@ -424,7 +409,6 @@
GtkWidget *w;
GtkWidget *frame;
GtkWidget *canvas;
- GooCanvasModelSimple *canvas_model;
GooCanvasItem *root, *item;
vbox = gtk_vbox_new (FALSE, 4);
@@ -446,21 +430,11 @@
gtk_container_add (GTK_CONTAINER (w), frame);
gtk_widget_show (frame);
- canvas = goo_canvas_view_new ();
-
- g_signal_connect (canvas, "item_view_created",
- (GtkSignalFunc) on_item_view_created,
- NULL);
-
- canvas_model = goo_canvas_model_simple_new ();
-
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas),
- GOO_CANVAS_MODEL (canvas_model));
- g_object_unref (canvas_model);
+ canvas = goo_canvas_new ();
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
gtk_widget_set_size_request (canvas, 500, 350);
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas), 0, 0, 500, 350);
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 500, 350);
gtk_container_add (GTK_CONTAINER (frame), canvas);
gtk_widget_show (canvas);
@@ -531,6 +505,6 @@
/* Done! */
- set_arrow_shape (GOO_CANVAS_VIEW (canvas));
+ set_arrow_shape (GOO_CANVAS (canvas));
return vbox;
}
Index: demo-events.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo-events.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- demo-events.c 14 Apr 2006 12:49:10 -0000 1.2
+++ demo-events.c 29 Nov 2006 18:47:02 -0000 1.3
@@ -5,19 +5,15 @@
static gboolean
-on_motion_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_motion_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventMotion *event,
gpointer data)
{
- GooCanvasItem *item = NULL;
char *item_id = NULL;
if (target)
- item = goo_canvas_item_view_get_item (target);
-
- if (item)
- item_id = g_object_get_data (G_OBJECT (item), "id");
+ item_id = g_object_get_data (G_OBJECT (target), "id");
if (item_id)
g_print ("%s item received 'motion-notify' signal\n", item_id);
@@ -27,18 +23,15 @@
static void
-on_item_view_created (GooCanvasView *view,
- GooCanvasItemView *item_view,
- GooCanvasItem *item,
- gpointer data)
+setup_item_signals (GooCanvasItem *item)
{
- g_signal_connect (item_view, "motion_notify_event",
+ g_signal_connect (item, "motion_notify_event",
(GtkSignalFunc) on_motion_notify, NULL);
}
static void
-create_events_area (GooCanvasModelSimple *canvas_model,
+create_events_area (GtkWidget *canvas,
gint area_num,
GooCanvasPointerEvents pointer_events,
gchar *label)
@@ -49,7 +42,7 @@
char *view_id;
GooCanvasLineDash *dash;
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
dash = goo_canvas_line_dash_new (2, 5.0, 5.0);
@@ -62,6 +55,7 @@
NULL);
view_id = g_strdup_printf ("%s invisible", label);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
+ setup_item_signals (rect);
/* Display a thin rect around it to indicate it is there. */
#if 1
@@ -80,6 +74,7 @@
NULL);
view_id = g_strdup_printf ("%s unpainted", label);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
+ setup_item_signals (rect);
/* Display a thin rect around it to indicate it is there. */
#if 1
@@ -97,6 +92,7 @@
NULL);
view_id = g_strdup_printf ("%s stroked", label);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
+ setup_item_signals (rect);
/* Create filled item. */
rect = goo_canvas_rect_new (root, x + 60, y + 75, 30, 30,
@@ -107,6 +103,7 @@
NULL);
view_id = g_strdup_printf ("%s filled", label);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
+ setup_item_signals (rect);
/* Create stroked & filled item. */
rect = goo_canvas_rect_new (root, x + 100, y + 75, 30, 30,
@@ -116,6 +113,7 @@
NULL);
view_id = g_strdup_printf ("%s stroked & filled", label);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
+ setup_item_signals (rect);
goo_canvas_text_new (root, label, x + 100, y + 130, -1, GTK_ANCHOR_CENTER,
"font", "Sans 12",
@@ -130,7 +128,6 @@
create_events_page (void)
{
GtkWidget *vbox, *alignment, *frame, *label, *canvas;
- GooCanvasModelSimple *canvas_model;
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
@@ -153,32 +150,22 @@
gtk_container_add (GTK_CONTAINER (alignment), frame);
gtk_widget_show (frame);
- canvas = goo_canvas_view_new ();
-
- g_signal_connect (canvas, "item_view_created",
- (GtkSignalFunc) on_item_view_created,
- NULL);
-
- canvas_model = goo_canvas_model_simple_new ();
+ canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 600, 450);
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas), 0, 0, 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_model, 0, GOO_CANVAS_EVENTS_NONE, "none");
- create_events_area (canvas_model, 1, GOO_CANVAS_EVENTS_VISIBLE_PAINTED, "visible-painted");
- create_events_area (canvas_model, 2, GOO_CANVAS_EVENTS_VISIBLE_FILL, "visible-fill");
- create_events_area (canvas_model, 3, GOO_CANVAS_EVENTS_VISIBLE_STROKE, "visible-stroke");
- create_events_area (canvas_model, 4, GOO_CANVAS_EVENTS_VISIBLE, "visible");
- create_events_area (canvas_model, 5, GOO_CANVAS_EVENTS_PAINTED, "painted");
- create_events_area (canvas_model, 6, GOO_CANVAS_EVENTS_FILL, "fill");
- create_events_area (canvas_model, 7, GOO_CANVAS_EVENTS_STROKE, "stroke");
- create_events_area (canvas_model, 8, GOO_CANVAS_EVENTS_ALL, "all");
-
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas),
- GOO_CANVAS_MODEL (canvas_model));
- g_object_unref (canvas_model);
+ 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");
return vbox;
}
Index: demo-features.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo-features.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- demo-features.c 12 Apr 2006 10:45:52 -0000 1.1
+++ demo-features.c 29 Nov 2006 18:47:02 -0000 1.2
@@ -3,20 +3,27 @@
#include <gtk/gtk.h>
#include <goocanvas.h>
+#include <goocanvastext.h>
+#include <goocanvasgroup.h>
+#include <goocanvasellipse.h>
+#include <goocanvaspolyline.h>
+#include <goocanvasrect.h>
+#include <goocanvasimage.h>
static gboolean
-on_button_press (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_button_press (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (view);
GooCanvasItem *parent1, *parent2, *parent;
int child_num;
- if (event->button != 1)
+ if (event->button != 1 || event->type != GDK_BUTTON_PRESS)
return FALSE;
+ g_print ("In on_button_press\n");
+
parent1 = g_object_get_data (G_OBJECT (item), "parent1");
parent2 = g_object_get_data (G_OBJECT (item), "parent2");
@@ -34,20 +41,6 @@
}
-static void
-on_item_view_created (GooCanvasView *view,
- GooCanvasItemView *item_view,
- GooCanvasItem *item,
- gpointer data)
-{
- if (g_object_get_data (G_OBJECT (item), "parent1"))
- {
- g_signal_connect (item_view, "button_press_event",
- (GtkSignalFunc) on_button_press, NULL);
- }
-}
-
-
GtkWidget *
create_canvas_features (void)
{
@@ -56,7 +49,6 @@
GtkWidget *alignment;
GtkWidget *frame;
GtkWidget *canvas;
- GooCanvasModelSimple *canvas_model;
GooCanvasItem *root, *item;
GooCanvasItem *parent1;
GooCanvasItem *parent2;
@@ -83,23 +75,17 @@
gtk_container_add (GTK_CONTAINER (alignment), frame);
gtk_widget_show (frame);
- canvas = goo_canvas_view_new ();
-
- g_signal_connect (canvas, "item_view_created",
- (GtkSignalFunc) on_item_view_created,
- NULL);
-
- canvas_model = goo_canvas_model_simple_new ();
+ canvas = goo_canvas_new ();
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
gtk_widget_set_size_request (canvas, 400, 200);
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas), 0, 0, 300, 200);
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 300, 200);
gtk_container_add (GTK_CONTAINER (frame), canvas);
gtk_widget_show (canvas);
/* First parent and box */
- parent1 = goo_canvas_group_new (root);
+ parent1 = goo_canvas_group_new (root, NULL);
goo_canvas_rect_new (parent1, 0, 0, 200, 200,
"fill_color", "tan",
@@ -107,7 +93,7 @@
/* Second parent and box */
- parent2 = goo_canvas_group_new (root);
+ parent2 = goo_canvas_group_new (root, NULL);
goo_canvas_item_translate (parent2, 200, 0);
goo_canvas_rect_new (parent2, 0, 0, 200, 200,
@@ -123,15 +109,12 @@
NULL);
g_object_set_data (G_OBJECT (item), "parent1", parent1);
g_object_set_data (G_OBJECT (item), "parent2", parent2);
-#if 0
- g_signal_connect (G_OBJECT (item), "event",
- (GtkSignalFunc) item_event,
- NULL);
-#endif
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) on_button_press, NULL);
/* A group to be reparented */
- group = goo_canvas_group_new (parent2);
+ group = goo_canvas_group_new (parent2, NULL);
goo_canvas_item_translate (group, 100, 100);
goo_canvas_ellipse_new (group, 0, 0, 50, 50,
@@ -145,19 +128,8 @@
g_object_set_data (G_OBJECT (group), "parent1", parent1);
g_object_set_data (G_OBJECT (group), "parent2", parent2);
-#if 0
- g_signal_connect (G_OBJECT (group), "event",
- (GtkSignalFunc) item_event,
- NULL);
-#endif
-
-
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas),
- GOO_CANVAS_MODEL (canvas_model));
- g_object_unref (canvas_model);
-
-
- /* Done */
+ g_signal_connect (group, "button_press_event",
+ (GtkSignalFunc) on_button_press, NULL);
return vbox;
}
Index: demo-fifteen.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo-fifteen.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- demo-fifteen.c 19 Jul 2006 13:42:33 -0000 1.2
+++ demo-fifteen.c 29 Nov 2006 18:47:02 -0000 1.3
@@ -56,18 +56,17 @@
}
static gboolean
-piece_enter_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+piece_enter_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventCrossing *event,
gpointer data)
{
- GooCanvasItem *item, *text;
+ GooCanvasItem *text;
#if 0
g_print ("In piece_enter_notify\n");
#endif
- item = goo_canvas_item_view_get_item (view);
text = g_object_get_data (G_OBJECT (item), "text");
g_object_set (text,
@@ -79,18 +78,17 @@
static gboolean
-piece_leave_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+piece_leave_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEvent *event,
gpointer data)
{
- GooCanvasItem *item, *text;
+ GooCanvasItem *text;
#if 0
g_print ("In piece_leave_notify\n");
#endif
- item = goo_canvas_item_view_get_item (view);
text = g_object_get_data (G_OBJECT (item), "text");
g_object_set (text,
@@ -102,21 +100,20 @@
static gboolean
-piece_button_press (GooCanvasItemView *view,
- GooCanvasItemView *target,
+piece_button_press (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
- GooCanvasView *canvas;
+ GooCanvas *canvas;
GooCanvasItem **board;
- GooCanvasItem *item, *text;
+ GooCanvasItem *text;
int num, pos, newpos;
int x, y;
double dx = 0.0, dy = 0.0;
int move;
- item = goo_canvas_item_view_get_item (view);
- canvas = goo_canvas_item_view_get_canvas_view (view);
+ canvas = goo_canvas_item_get_canvas (item);
board = g_object_get_data (G_OBJECT (canvas), "board");
num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "piece_num"));
pos = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "piece_pos"));
@@ -166,32 +163,25 @@
static void
-on_item_view_created (GooCanvasView *view,
- GooCanvasItemView *item_view,
- GooCanvasItem *item,
- gpointer data)
+setup_item_signals (GooCanvasItem *item)
{
- if (goo_canvas_item_get_parent (item) && GOO_IS_CANVAS_GROUP (item))
- {
- g_signal_connect (item_view, "enter_notify_event",
- (GtkSignalFunc) piece_enter_notify,
- NULL);
- g_signal_connect (item_view, "leave_notify_event",
- (GtkSignalFunc) piece_leave_notify,
- NULL);
- g_signal_connect (item_view, "button_press_event",
- (GtkSignalFunc) piece_button_press,
- NULL);
- }
+ g_signal_connect (item, "enter_notify_event",
+ (GtkSignalFunc) piece_enter_notify,
+ NULL);
+ g_signal_connect (item, "leave_notify_event",
+ (GtkSignalFunc) piece_leave_notify,
+ NULL);
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) piece_button_press,
+ NULL);
}
-
#define SCRAMBLE_MOVES 256
static void
scramble (GtkObject *object, gpointer data)
{
- GooCanvasView *canvas;
+ GooCanvas *canvas;
GooCanvasItem **board;
int i;
int pos, oldpos;
@@ -248,7 +238,6 @@
GtkWidget *frame;
GtkWidget *canvas;
GtkWidget *button;
- GooCanvasModelSimple *canvas_model;
GooCanvasItem **board;
GooCanvasItem *root, *rect, *text;
int i, x, y;
@@ -269,23 +258,13 @@
/* Create the canvas and board */
- canvas = goo_canvas_view_new ();
-
- g_signal_connect (canvas, "item_view_created",
- (GtkSignalFunc) on_item_view_created,
- NULL);
-
- canvas_model = goo_canvas_model_simple_new ();
-
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas),
- GOO_CANVAS_MODEL (canvas_model));
- g_object_unref (canvas_model);
+ canvas = goo_canvas_new ();
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
gtk_widget_set_size_request (canvas,
PIECE_SIZE * 4 + 1, PIECE_SIZE * 4 + 1);
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas), 0, 0,
- PIECE_SIZE * 4 + 1, PIECE_SIZE * 4 + 1);
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0,
+ PIECE_SIZE * 4 + 1, PIECE_SIZE * 4 + 1);
gtk_container_add (GTK_CONTAINER (frame), canvas);
gtk_widget_show (canvas);
@@ -299,9 +278,10 @@
y = i / 4;
x = i % 4;
- board[i] = goo_canvas_group_new (root);
+ board[i] = goo_canvas_group_new (root, NULL);
goo_canvas_item_translate (board[i], x * PIECE_SIZE,
y * PIECE_SIZE);
+ setup_item_signals (board[i]);
rect = goo_canvas_rect_new (board[i], 0, 0,
PIECE_SIZE, PIECE_SIZE,
@@ -312,12 +292,10 @@
sprintf (buf, "%d", i + 1);
- text = goo_canvas_item_new (board[i], GOO_TYPE_CANVAS_TEXT,
- "text", buf,
- "x", (double) PIECE_SIZE / 2.0,
- "y", (double) PIECE_SIZE / 2.0,
+ text = goo_canvas_text_new (board[i], buf,
+ PIECE_SIZE / 2.0, PIECE_SIZE / 2.0,
+ -1, GTK_ANCHOR_CENTER,
"font", "Sans bold 24",
- "anchor", GTK_ANCHOR_CENTER,
"fill_color", "black",
NULL);
Index: demo-focus.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo-focus.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- demo-focus.c 23 Apr 2006 11:32:08 -0000 1.2
+++ demo-focus.c 29 Nov 2006 18:47:02 -0000 1.3
@@ -5,15 +5,13 @@
static gboolean
-on_focus_in (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_focus_in (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventFocus *event,
gpointer data)
{
- GooCanvasItem *item;
gchar *id;
- item = goo_canvas_item_view_get_item (view);
id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s received focus-in event\n", id ? id : "unknown");
@@ -27,15 +25,13 @@
static gboolean
-on_focus_out (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_focus_out (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventFocus *event,
gpointer data)
{
- GooCanvasItem *item;
gchar *id;
- item = goo_canvas_item_view_get_item (view);
id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s received focus-out event\n", id ? id : "unknown");
@@ -49,37 +45,33 @@
static gboolean
-on_button_press (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_button_press (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
- GooCanvasItem *item;
- GooCanvasView *canvas_view;
+ GooCanvas *canvas;
gchar *id;
- item = goo_canvas_item_view_get_item (view);
id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s received button-press event\n", id ? id : "unknown");
- canvas_view = goo_canvas_item_view_get_canvas_view (view);
- goo_canvas_view_grab_focus (canvas_view, view);
+ canvas = goo_canvas_item_get_canvas (item);
+ goo_canvas_grab_focus (canvas, item);
return TRUE;
}
static gboolean
-on_key_press (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_key_press (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventKey *event,
gpointer data)
{
- GooCanvasItem *item;
gchar *id;
- item = goo_canvas_item_view_get_item (view);
id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s received key-press event\n", id ? id : "unknown");
@@ -89,145 +81,55 @@
static void
-on_item_view_created (GooCanvasView *view,
- GooCanvasItemView *item_view,
- GooCanvasItem *item,
- gpointer data)
-{
- if (GOO_IS_CANVAS_RECT (item))
- {
- g_object_set (item_view, "can-focus", TRUE, NULL);
-
- g_signal_connect (item_view, "focus_in_event",
- (GtkSignalFunc) on_focus_in, NULL);
- g_signal_connect (item_view, "focus_out_event",
- (GtkSignalFunc) on_focus_out, NULL);
-
- g_signal_connect (item_view, "button_press_event",
- (GtkSignalFunc) on_button_press, NULL);
-
- g_signal_connect (item_view, "key_press_event",
- (GtkSignalFunc) on_key_press, NULL);
- }
-}
-
-
-static GooCanvasModelSimple*
-create_canvas_model (void)
+create_focus_box (GtkWidget *canvas,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ gchar *color)
{
- GooCanvasModelSimple *canvas_model;
GooCanvasItem *root, *item;
- canvas_model = goo_canvas_model_simple_new ();
-
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
-
- item = goo_canvas_rect_new (root, 110, 80, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "red",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "red");
-
- item = goo_canvas_rect_new (root, 300, 160, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "orange",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "orange");
-
- item = goo_canvas_rect_new (root, 500, 50, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "yellow",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "yellow");
-
- item = goo_canvas_rect_new (root, 70, 400, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "blue",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "blue");
-
- item = goo_canvas_rect_new (root, 130, 200, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "magenta",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "magenta");
-
- item = goo_canvas_rect_new (root, 200, 160, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "green",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "green");
-
- item = goo_canvas_rect_new (root, 450, 450, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "cyan",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "cyan");
-
- item = goo_canvas_rect_new (root, 300, 350, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "grey",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "grey");
-
- item = goo_canvas_rect_new (root, 900, 900, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "gold",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "gold");
-
- item = goo_canvas_rect_new (root, 800, 150, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "thistle",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "thistle");
-
- item = goo_canvas_rect_new (root, 600, 800, 50, 30,
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
+ item = goo_canvas_rect_new (root, x, y, width, height,
"stroke-pattern", NULL,
- "fill-color", "azure",
+ "fill-color", color,
"line-width", 5.0,
+ "can-focus", TRUE,
NULL);
- g_object_set_data (G_OBJECT (item), "id", "azure");
+ g_object_set_data (G_OBJECT (item), "id", color);
- item = goo_canvas_rect_new (root, 700, 250, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "moccasin",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "moccasin");
+ g_signal_connect (item, "focus_in_event",
+ (GtkSignalFunc) on_focus_in, NULL);
+ g_signal_connect (item, "focus_out_event",
+ (GtkSignalFunc) on_focus_out, NULL);
- item = goo_canvas_rect_new (root, 500, 100, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "cornsilk",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "cornsilk");
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) on_button_press, NULL);
- item = goo_canvas_rect_new (root, 200, 750, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "plum",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "plum");
+ g_signal_connect (item, "key_press_event",
+ (GtkSignalFunc) on_key_press, NULL);
+}
- item = goo_canvas_rect_new (root, 400, 800, 50, 30,
- "stroke-pattern", NULL,
- "fill-color", "orchid",
- "line-width", 5.0,
- NULL);
- g_object_set_data (G_OBJECT (item), "id", "orchid");
- return canvas_model;
+static void
+setup_canvas (GtkWidget *canvas)
+{
+ create_focus_box (canvas, 110, 80, 50, 30, "red");
+ create_focus_box (canvas, 300, 160, 50, 30, "orange");
+ create_focus_box (canvas, 500, 50, 50, 30, "yellow");
+ create_focus_box (canvas, 70, 400, 50, 30, "blue");
+ create_focus_box (canvas, 130, 200, 50, 30, "magenta");
+ create_focus_box (canvas, 200, 160, 50, 30, "green");
+ create_focus_box (canvas, 450, 450, 50, 30, "cyan");
+ create_focus_box (canvas, 300, 350, 50, 30, "grey");
+ create_focus_box (canvas, 900, 900, 50, 30, "gold");
+ create_focus_box (canvas, 800, 150, 50, 30, "thistle");
+ create_focus_box (canvas, 600, 800, 50, 30, "azure");
+ create_focus_box (canvas, 700, 250, 50, 30, "moccasin");
+ create_focus_box (canvas, 500, 100, 50, 30, "cornsilk");
+ create_focus_box (canvas, 200, 750, 50, 30, "plum");
+ create_focus_box (canvas, 400, 800, 50, 30, "orchid");
}
@@ -235,7 +137,6 @@
create_focus_page (void)
{
GtkWidget *vbox, *label, *scrolled_win, *canvas;
- GooCanvasModelSimple *canvas_model;
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
@@ -251,21 +152,14 @@
gtk_widget_show (scrolled_win);
gtk_container_add (GTK_CONTAINER (vbox), scrolled_win);
- canvas = goo_canvas_view_new ();
+ canvas = goo_canvas_new ();
GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
gtk_widget_set_size_request (canvas, 600, 450);
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas), 0, 0, 1000, 1000);
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
gtk_widget_show (canvas);
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
- g_signal_connect (canvas, "item_view_created",
- (GtkSignalFunc) on_item_view_created,
- NULL);
-
- canvas_model = create_canvas_model ();
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas),
- GOO_CANVAS_MODEL (canvas_model));
- g_object_unref (canvas_model);
+ setup_canvas (canvas);
return vbox;
}
Index: demo-grabs.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo-grabs.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- demo-grabs.c 12 Apr 2006 10:45:52 -0000 1.1
+++ demo-grabs.c 29 Nov 2006 18:47:02 -0000 1.2
@@ -106,12 +106,11 @@
static gboolean
-on_enter_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_enter_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventCrossing *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (target);
char *item_id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s received 'enter-notify' signal\n", item_id);
@@ -120,12 +119,11 @@
static gboolean
-on_leave_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_leave_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventCrossing *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (target);
char *item_id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s received 'leave-notify' signal\n", item_id);
@@ -134,12 +132,11 @@
static gboolean
-on_motion_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_motion_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventMotion *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (target);
char *item_id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s received 'motion-notify' signal\n", item_id);
@@ -148,19 +145,18 @@
static gboolean
-on_button_press (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_button_press (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (target);
char *item_id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s received 'button-press' signal\n", item_id);
if (strstr (item_id, "explicit"))
{
- GooCanvasView *canvas_view;
+ GooCanvas *canvas;
GdkGrabStatus status;
GdkEventMask mask = GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
@@ -169,9 +165,8 @@
| GDK_ENTER_NOTIFY_MASK
| GDK_LEAVE_NOTIFY_MASK;
- canvas_view = goo_canvas_item_view_get_canvas_view (view);
- status = goo_canvas_view_pointer_grab (canvas_view, view, mask, NULL,
- event->time);
+ canvas = goo_canvas_item_get_canvas (item);
+ status = goo_canvas_pointer_grab (canvas, item, mask, NULL, event->time);
if (status == GDK_GRAB_SUCCESS)
g_print ("grabbed pointer\n");
else
@@ -183,22 +178,21 @@
static gboolean
-on_button_release (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_button_release (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (target);
char *item_id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s received 'button-release' signal\n", item_id);
if (strstr (item_id, "explicit"))
{
- GooCanvasView *canvas_view;
+ GooCanvas *canvas;
- canvas_view = goo_canvas_item_view_get_canvas_view (view);
- goo_canvas_view_pointer_ungrab (canvas_view, view, event->time);
+ canvas = goo_canvas_item_get_canvas (item);
+ goo_canvas_pointer_ungrab (canvas, item, event->time);
g_print ("released pointer grab\n");
}
@@ -319,24 +313,18 @@
static void
-on_item_view_created (GooCanvasView *view,
- GooCanvasItemView *item_view,
- GooCanvasItem *item,
- gpointer data)
+setup_item_signals (GooCanvasItem *item)
{
- if (GOO_IS_CANVAS_RECT (item))
- {
- g_signal_connect (item_view, "enter_notify_event",
- (GtkSignalFunc) on_enter_notify, NULL);
- g_signal_connect (item_view, "leave_notify_event",
- (GtkSignalFunc) on_leave_notify, NULL);
- g_signal_connect (item_view, "motion_notify_event",
- (GtkSignalFunc) on_motion_notify, NULL);
- g_signal_connect (item_view, "button_press_event",
- (GtkSignalFunc) on_button_press, NULL);
- g_signal_connect (item_view, "button_release_event",
- (GtkSignalFunc) on_button_release, NULL);
- }
+ g_signal_connect (item, "enter_notify_event",
+ (GtkSignalFunc) on_enter_notify, NULL);
+ g_signal_connect (item, "leave_notify_event",
+ (GtkSignalFunc) on_leave_notify, NULL);
+ g_signal_connect (item, "motion_notify_event",
+ (GtkSignalFunc) on_motion_notify, NULL);
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) on_button_press, NULL);
+ g_signal_connect (item, "button_release_event",
+ (GtkSignalFunc) on_button_release, NULL);
}
@@ -344,39 +332,29 @@
create_canvas (GtkTable *table, gint row, gchar *text, gchar *id)
{
GtkWidget *label, *canvas;
- GooCanvasModelSimple *canvas_model;
GooCanvasItem *root, *rect;
char *view_id;
label = gtk_label_new (text);
- gtk_table_attach (table, label, 0, 1, row, row + 1,
- 0, 0, 0, 0);
+ gtk_table_attach (table, label, 0, 1, row, row + 1, 0, 0, 0, 0);
gtk_widget_show (label);
- canvas = goo_canvas_view_new ();
-
- g_signal_connect (canvas, "item_view_created",
- (GtkSignalFunc) on_item_view_created,
- NULL);
+ canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 200, 100);
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas), 0, 0, 200, 100);
- gtk_table_attach (table, canvas, 1, 2, row, row + 1,
- 0, 0, 0, 0);
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 200, 100);
+ gtk_table_attach (table, canvas, 1, 2, row, row + 1, 0, 0, 0, 0);
gtk_widget_show (canvas);
- canvas_model = goo_canvas_model_simple_new ();
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas),
- GOO_CANVAS_MODEL (canvas_model));
- g_object_unref (canvas_model);
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
rect = goo_canvas_rect_new (root, 0, 0, 200, 100,
"stroke-pattern", NULL,
"fill-color", "yellow",
NULL);
view_id = g_strdup_printf ("%s-yellow", id);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
+ setup_item_signals (rect);
rect = goo_canvas_rect_new (root, 20, 20, 60, 60,
"stroke-pattern", NULL,
@@ -384,6 +362,7 @@
NULL);
view_id = g_strdup_printf ("%s-blue", id);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
+ setup_item_signals (rect);
rect = goo_canvas_rect_new (root, 120, 20, 60, 60,
"stroke-pattern", NULL,
@@ -391,6 +370,7 @@
NULL);
view_id = g_strdup_printf ("%s-red", id);
g_object_set_data_full (G_OBJECT (rect), "id", view_id, g_free);
+ setup_item_signals (rect);
}
Index: demo-paths.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo-paths.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- demo-paths.c 16 Apr 2006 21:00:54 -0000 1.2
+++ demo-paths.c 29 Nov 2006 18:47:02 -0000 1.3
@@ -4,15 +4,12 @@
#include <goocanvas.h>
-static GooCanvasModelSimple*
-create_canvas_model (void)
+static void
+setup_canvas (GtkWidget *canvas)
{
- GooCanvasModelSimple *canvas_model;
GooCanvasItem *root, *path;
- canvas_model = goo_canvas_model_simple_new ();
-
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
/* Test the simple commands like moveto and lineto: MmZzLlHhVv. */
path = goo_canvas_path_new (root, "M 20 20 L 40 40", NULL);
@@ -96,8 +93,6 @@
"stroke-color", "red",
"line-width", 5.0,
NULL);
-
- return canvas_model;
}
@@ -105,7 +100,6 @@
create_paths_page (void)
{
GtkWidget *vbox, *scrolled_win, *canvas;
- GooCanvasModelSimple *canvas_model;
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
@@ -117,16 +111,13 @@
gtk_widget_show (scrolled_win);
gtk_container_add (GTK_CONTAINER (vbox), scrolled_win);
- canvas = goo_canvas_view_new ();
+ canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 600, 450);
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas), 0, 0, 1000, 1000);
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
gtk_widget_show (canvas);
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
- canvas_model = create_canvas_model ();
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas),
- GOO_CANVAS_MODEL (canvas_model));
- g_object_unref (canvas_model);
+ setup_canvas (canvas);
return vbox;
}
Index: demo-scalability.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo-scalability.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- demo-scalability.c 16 Apr 2006 22:29:44 -0000 1.2
+++ demo-scalability.c 29 Nov 2006 18:47:02 -0000 1.3
@@ -20,7 +20,6 @@
GtkWidget *scrolled_win, *canvas;
GtkWidget *table;
GdkPixbuf *pixbuf;
- GooCanvasModelSimple *canvas_model;
GooCanvasItem *root, *item;
int i, j, width, height;
@@ -54,19 +53,14 @@
height = 19;
#endif
- canvas = goo_canvas_view_new ();
- canvas_model = goo_canvas_model_simple_new ();
-
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas),
- GOO_CANVAS_MODEL (canvas_model));
- g_object_unref (canvas_model);
+ canvas = goo_canvas_new ();
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
gtk_widget_set_size_request (canvas, 600, 450);
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas), 0, 0,
- N_COLS * (width + PADDING),
- N_ROWS * (height + PADDING));
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0,
+ N_COLS * (width + PADDING),
+ N_ROWS * (height + PADDING));
gtk_widget_show (canvas);
@@ -80,17 +74,15 @@
for (i = 0; i < N_COLS; i++) {
for (j = 0; j < N_ROWS; j++) {
#ifdef USE_PIXMAP
- item = goo_canvas_item_new (root, GOO_TYPE_CANVAS_IMAGE,
- "x", (double) i * (width + PADDING),
- "y", (double) j * (height + PADDING),
- "pixbuf", pixbuf,
+ item = goo_canvas_image_new (root, pixbuf,
+ i * (width + PADDING),
+ j * (height + PADDING),
NULL);
#else
- item = goo_canvas_polyline_new_rect (root,
- i * (width + PADDING),
- j * (height + PADDING),
- i * (width + PADDING) + width,
- j * (height + PADDING) + height);
+ item = goo_canvas_rect_new (root,
+ i * (width + PADDING),
+ j * (height + PADDING),
+ width, height);
g_object_set (item,
"fill_color", (j%2)?"mediumseagreen":"steelblue",
NULL);
Index: demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- demo.c 11 Sep 2006 11:09:15 -0000 1.8
+++ demo.c 29 Nov 2006 18:47:02 -0000 1.9
@@ -16,11 +16,13 @@
#endif
#include <goocanvas.h>
+
GooCanvasItem *ellipse2, *textitem;
gboolean dragging = FALSE;
double drag_x, drag_y;
+static void setup_canvas (GooCanvas *canvas);
GtkWidget *create_canvas_fifteen (void);
GtkWidget *create_canvas_features (void);
GtkWidget *create_canvas_arrowhead (void);
@@ -32,7 +34,7 @@
#if CAIRO_HAS_PDF_SURFACE
static void
-write_pdf_clicked (GtkWidget *button, GooCanvasView *canvas_view)
+write_pdf_clicked (GtkWidget *button, GooCanvas *canvas)
{
cairo_surface_t *surface;
cairo_t *cr;
@@ -45,7 +47,7 @@
/* Place it in the middle of our 9x10 page. */
cairo_translate (cr, 20, 130);
- goo_canvas_view_render (canvas_view, cr, NULL, 1.0);
+ goo_canvas_render (canvas, cr, NULL, 1.0);
cairo_show_page (cr);
@@ -55,9 +57,9 @@
#endif
static void
-zoom_changed (GtkAdjustment *adj, GooCanvasView *canvas_view)
+zoom_changed (GtkAdjustment *adj, GooCanvas *canvas)
{
- goo_canvas_view_set_scale (canvas_view, adj->value);
+ goo_canvas_set_scale (canvas, adj->value);
}
@@ -70,40 +72,40 @@
static void
-anchor_toggled (GtkWidget *button, GooCanvasView *canvas_view)
+anchor_toggled (GtkWidget *button, GooCanvas *canvas)
{
GtkAnchorType anchor;
anchor = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "anchor"));
if (GTK_TOGGLE_BUTTON (button)->active)
- g_object_set (canvas_view, "anchor", anchor, NULL);
+ g_object_set (canvas, "anchor", anchor, NULL);
}
static void
-scroll_to_50_50_clicked (GtkWidget *button, GooCanvasView *canvas_view)
+scroll_to_50_50_clicked (GtkWidget *button, GooCanvas *canvas)
{
- goo_canvas_view_scroll_to (canvas_view, 50, 50);
+ goo_canvas_scroll_to (canvas, 50, 50);
}
static void
-scroll_to_500_500_clicked (GtkWidget *button, GooCanvasView *canvas_view)
+scroll_to_500_500_clicked (GtkWidget *button, GooCanvas *canvas)
{
- goo_canvas_view_scroll_to (canvas_view, 500, 500);
+ goo_canvas_scroll_to (canvas, 500, 500);
}
static void
-scroll_to_250_250_clicked (GtkWidget *button, GooCanvasView *canvas_view)
+scroll_to_250_250_clicked (GtkWidget *button, GooCanvas *canvas)
{
- goo_canvas_view_scroll_to (canvas_view, 250, 250);
+ goo_canvas_scroll_to (canvas, 250, 250);
}
static void
-animate_ellipse_clicked (GtkWidget *button, GooCanvasView *canvas_view)
+animate_ellipse_clicked (GtkWidget *button, GooCanvas *canvas)
{
#if 1
goo_canvas_item_animate (ellipse2, 100, 100, 1, 90, 1000, 40,
@@ -117,14 +119,14 @@
static void
-stop_animation_clicked (GtkWidget *button, GooCanvasView *canvas_view)
+stop_animation_clicked (GtkWidget *button, GooCanvas *canvas)
{
goo_canvas_item_stop_animation (ellipse2);
}
static void
-move_ellipse_clicked (GtkWidget *button, GooCanvasView *canvas_view)
+move_ellipse_clicked (GtkWidget *button, GooCanvas *canvas)
{
static int last_state = 0;
@@ -180,13 +182,11 @@
static gboolean
-on_motion_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_motion_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventMotion *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (view);
-
#if 0
g_print ("received 'motion-notify' signal at %g, %g\n",
event->x, event->y);
@@ -205,18 +205,17 @@
static gboolean
-on_button_press (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_button_press (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (view);
- GooCanvasView *canvas_view;
+ GooCanvas *canvas;
GdkCursor *fleur;
#if 0
g_print ("%p received 'button-press' signal at %g, %g (root: %g, %g)\n",
- view, event->x, event->y, event->x_root, event->y_root);
+ item, event->x, event->y, event->x_root, event->y_root);
#endif
switch (event->button)
@@ -237,11 +236,11 @@
drag_y = event->y;
fleur = gdk_cursor_new (GDK_FLEUR);
- canvas_view = goo_canvas_item_view_get_canvas_view (view);
- goo_canvas_view_pointer_grab (canvas_view, view,
- GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
- fleur,
- event->time);
+ canvas = goo_canvas_item_get_canvas (item);
+ goo_canvas_pointer_grab (canvas, item,
+ GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
+ fleur,
+ event->time);
gdk_cursor_unref (fleur);
dragging = TRUE;
}
@@ -264,19 +263,19 @@
static gboolean
-on_button_release (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_button_release (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
- GooCanvasView *canvas_view;
+ GooCanvas *canvas;
#if 0
g_print ("received 'button-release' signal\n");
#endif
- canvas_view = goo_canvas_item_view_get_canvas_view (view);
- goo_canvas_view_pointer_ungrab (canvas_view, view, event->time);
+ canvas = goo_canvas_item_get_canvas (item);
+ goo_canvas_pointer_ungrab (canvas, item, event->time);
dragging = FALSE;
return TRUE;
@@ -284,13 +283,13 @@
static gboolean
-on_background_button_press (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_background_button_press (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
#if 1
- g_print ("background item view received 'button-press' signal\n");
+ g_print ("background received 'button-press' signal\n");
#endif
return TRUE;
@@ -298,35 +297,24 @@
static void
-on_item_view_created (GooCanvasView *view,
- GooCanvasItemView *item_view,
- GooCanvasItem *item,
- gpointer data)
+setup_item_signals (GooCanvasItem *item)
{
- if (!goo_canvas_item_get_parent (item))
- {
- g_signal_connect (item_view, "button_press_event",
- (GtkSignalFunc) on_background_button_press, NULL);
- }
- else if (!g_object_get_data (G_OBJECT (item), "skip-signal-connection"))
- {
- g_signal_connect (item_view, "motion_notify_event",
- (GtkSignalFunc) on_motion_notify, NULL);
- g_signal_connect (item_view, "button_press_event",
- (GtkSignalFunc) on_button_press, NULL);
- g_signal_connect (item_view, "button_release_event",
- (GtkSignalFunc) on_button_release, NULL);
- }
+ g_signal_connect (item, "motion_notify_event",
+ (GtkSignalFunc) on_motion_notify, NULL);
+ g_signal_connect (item, "button_press_event",
+ (GtkSignalFunc) on_button_press, NULL);
+ g_signal_connect (item, "button_release_event",
+ (GtkSignalFunc) on_button_release, NULL);
}
GtkWidget *
-create_canvas_primitives (GooCanvasModelSimple *canvas_model)
+create_canvas_primitives ()
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *w;
- GtkWidget *scrolled_win, *canvas_view;
+ GtkWidget *scrolled_win, *canvas;
GtkAdjustment *adj;
GSList *group = NULL;
GdkColor bg_color = { 0, 50000, 50000, 65535 };
@@ -345,16 +333,9 @@
/* Create the canvas */
- canvas_view = goo_canvas_view_new ();
-
- gtk_widget_modify_base (canvas_view, GTK_STATE_NORMAL, &bg_color);
-
- g_signal_connect (canvas_view, "item_view_created",
- (GtkSignalFunc) on_item_view_created,
- NULL);
-
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas_view),
- 0, 0, 604, 454);
+ canvas = goo_canvas_new ();
+ gtk_widget_modify_base (canvas, GTK_STATE_NORMAL, &bg_color);
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 604, 454);
/* Zoom */
@@ -366,7 +347,7 @@
w = gtk_spin_button_new (adj, 0.0, 2);
g_signal_connect (adj, "value_changed",
(GtkSignalFunc) zoom_changed,
- canvas_view);
+ canvas);
gtk_widget_set_size_request (w, 50, -1);
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
@@ -378,7 +359,7 @@
/*gtk_widget_show (w);*/
g_signal_connect (w, "toggled",
(GtkSignalFunc) center_toggled,
- canvas_view);
+ canvas);
/* Move Ellipse */
@@ -387,7 +368,7 @@
gtk_widget_show (w);
g_signal_connect (w, "clicked",
(GtkSignalFunc) move_ellipse_clicked,
- canvas_view);
+ canvas);
/* Animate Ellipse */
@@ -396,7 +377,7 @@
gtk_widget_show (w);
g_signal_connect (w, "clicked",
(GtkSignalFunc) animate_ellipse_clicked,
- canvas_view);
+ canvas);
/* Stop Animation */
@@ -405,7 +386,7 @@
gtk_widget_show (w);
g_signal_connect (w, "clicked",
(GtkSignalFunc) stop_animation_clicked,
- canvas_view);
+ canvas);
#if CAIRO_HAS_PDF_SURFACE
@@ -416,7 +397,7 @@
gtk_widget_show (w);
g_signal_connect (w, "clicked",
(GtkSignalFunc) write_pdf_clicked,
- canvas_view);
+ canvas);
#endif
hbox = gtk_hbox_new (FALSE, 4);
@@ -434,21 +415,21 @@
gtk_widget_show (w);
g_signal_connect (w, "clicked",
(GtkSignalFunc) scroll_to_50_50_clicked,
- canvas_view);
+ canvas);
w = gtk_button_new_with_label("250,250");
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
g_signal_connect (w, "clicked",
(GtkSignalFunc) scroll_to_250_250_clicked,
- canvas_view);
+ canvas);
w = gtk_button_new_with_label("500,500");
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
g_signal_connect (w, "clicked",
(GtkSignalFunc) scroll_to_500_500_clicked,
- canvas_view);
+ canvas);
/* Scroll anchor */
@@ -462,7 +443,7 @@
gtk_widget_show (w);
g_signal_connect (w, "toggled",
(GtkSignalFunc) anchor_toggled,
- canvas_view);
+ canvas);
g_object_set_data (G_OBJECT (w), "anchor",
GINT_TO_POINTER (GTK_ANCHOR_NW));
@@ -472,7 +453,7 @@
gtk_widget_show (w);
g_signal_connect (w, "toggled",
(GtkSignalFunc) anchor_toggled,
- canvas_view);
+ canvas);
g_object_set_data (G_OBJECT (w), "anchor",
GINT_TO_POINTER (GTK_ANCHOR_N));
@@ -482,7 +463,7 @@
gtk_widget_show (w);
g_signal_connect (w, "toggled",
(GtkSignalFunc) anchor_toggled,
- canvas_view);
+ canvas);
g_object_set_data (G_OBJECT (w), "anchor",
GINT_TO_POINTER (GTK_ANCHOR_NE));
@@ -492,7 +473,7 @@
gtk_widget_show (w);
g_signal_connect (w, "toggled",
(GtkSignalFunc) anchor_toggled,
- canvas_view);
+ canvas);
g_object_set_data (G_OBJECT (w), "anchor",
GINT_TO_POINTER (GTK_ANCHOR_W));
@@ -502,7 +483,7 @@
gtk_widget_show (w);
g_signal_connect (w, "toggled",
(GtkSignalFunc) anchor_toggled,
- canvas_view);
+ canvas);
g_object_set_data (G_OBJECT (w), "anchor",
GINT_TO_POINTER (GTK_ANCHOR_CENTER));
@@ -512,7 +493,7 @@
gtk_widget_show (w);
g_signal_connect (w, "toggled",
(GtkSignalFunc) anchor_toggled,
- canvas_view);
+ canvas);
g_object_set_data (G_OBJECT (w), "anchor",
GINT_TO_POINTER (GTK_ANCHOR_E));
@@ -522,7 +503,7 @@
gtk_widget_show (w);
g_signal_connect (w, "toggled",
(GtkSignalFunc) anchor_toggled,
- canvas_view);
+ canvas);
g_object_set_data (G_OBJECT (w), "anchor",
GINT_TO_POINTER (GTK_ANCHOR_SW));
@@ -532,7 +513,7 @@
gtk_widget_show (w);
g_signal_connect (w, "toggled",
(GtkSignalFunc) anchor_toggled,
- canvas_view);
+ canvas);
g_object_set_data (G_OBJECT (w), "anchor",
GINT_TO_POINTER (GTK_ANCHOR_S));
@@ -542,7 +523,7 @@
gtk_widget_show (w);
g_signal_connect (w, "toggled",
(GtkSignalFunc) anchor_toggled,
- canvas_view);
+ canvas);
g_object_set_data (G_OBJECT (w), "anchor",
GINT_TO_POINTER (GTK_ANCHOR_SE));
@@ -553,14 +534,11 @@
gtk_widget_show (scrolled_win);
gtk_box_pack_start (GTK_BOX (vbox), scrolled_win, TRUE, TRUE, 0);
- gtk_widget_show (canvas_view);
- gtk_container_add (GTK_CONTAINER (scrolled_win), canvas_view);
+ gtk_widget_show (canvas);
+ gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
- /* Set the model on the canvas view. The canvas view will then create
- item views to render each of the items. */
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas_view),
- GOO_CANVAS_MODEL (canvas_model));
- g_object_unref (canvas_model);
+ /* Add all the canvas items. */
+ setup_canvas (GOO_CANVAS (canvas));
#if 0
g_signal_connect_after (canvas, "key_press_event",
@@ -594,36 +572,29 @@
setup_divisions (GooCanvasItem *root)
{
GooCanvasItem *group, *item;
- GooCanvasStyle *style;
- group = goo_canvas_group_new (root);
+ group = goo_canvas_group_new (root, NULL);
goo_canvas_item_translate (group, 2, 2);
- style = goo_canvas_style_new ();
- style->mask = GOO_CANVAS_STYLE_LINE_WIDTH;
- style->line_width = 4;
-
- item = goo_canvas_rect_new (group, 0, 0, 600, 450, NULL);
- g_object_set_data (G_OBJECT (item), "skip-signal-connection", "TRUE");
- goo_canvas_item_simple_set_style (GOO_CANVAS_ITEM_SIMPLE (item), style);
-
- item = goo_canvas_polyline_new_line (group, 0, 150, 600, 150, NULL);
- g_object_set_data (G_OBJECT (item), "skip-signal-connection", "TRUE");
- goo_canvas_item_simple_set_style (GOO_CANVAS_ITEM_SIMPLE (item), style);
+ item = goo_canvas_rect_new (group, 0, 0, 600, 450,
+ "line-width", 4.0,
+ NULL);
- item = goo_canvas_polyline_new_line (group, 0, 300, 600, 300, NULL);
- g_object_set_data (G_OBJECT (item), "skip-signal-connection", "TRUE");
- goo_canvas_item_simple_set_style (GOO_CANVAS_ITEM_SIMPLE (item), style);
+ item = goo_canvas_polyline_new_line (group, 0, 150, 600, 150,
+ "line-width", 4.0,
+ NULL);
- item = goo_canvas_polyline_new_line (group, 200, 0, 200, 450, NULL);
- g_object_set_data (G_OBJECT (item), "skip-signal-connection", "TRUE");
- goo_canvas_item_simple_set_style (GOO_CANVAS_ITEM_SIMPLE (item), style);
+ item = goo_canvas_polyline_new_line (group, 0, 300, 600, 300,
+ "line-width", 4.0,
+ NULL);
- item = goo_canvas_polyline_new_line (group, 400, 0, 400, 450, NULL);
- g_object_set_data (G_OBJECT (item), "skip-signal-connection", "TRUE");
- goo_canvas_item_simple_set_style (GOO_CANVAS_ITEM_SIMPLE (item), style);
+ item = goo_canvas_polyline_new_line (group, 200, 0, 200, 450,
+ "line-width", 4.0,
+ NULL);
- goo_canvas_style_unref (style);
+ item = goo_canvas_polyline_new_line (group, 400, 0, 400, 450,
+ "line-width", 4.0,
+ NULL);
#if 1
setup_heading (group, "Rectangles", 0);
@@ -674,6 +645,7 @@
"stroke-color", "red",
"line-width", 8.0,
NULL);
+ setup_item_signals (item);
pattern = create_stipple ("mediumseagreen", stipple_data);
item = goo_canvas_rect_new (root, 90, 40, 90, 60,
@@ -682,16 +654,19 @@
"line-width", 4.0,
NULL);
cairo_pattern_destroy (pattern);
+ setup_item_signals (item);
item = goo_canvas_rect_new (root, 10, 80, 70, 60,
"fill-color", "steelblue",
NULL);
+ setup_item_signals (item);
item = goo_canvas_rect_new (root, 20, 90, 70, 60,
"fill-color-rgba", 0x3cb37180,
"stroke-color", "blue",
"line-width", 2.0,
NULL);
+ setup_item_signals (item);
item = goo_canvas_rect_new (root, 110, 80, 50, 30,
"radius-x", 20.0,
@@ -699,6 +674,7 @@
"stroke-color", "yellow",
"fill-color-rgba", 0x3cb3f180,
NULL);
+ setup_item_signals (item);
}
@@ -716,6 +692,7 @@
"stroke-color", "goldenrod",
"line-width", 8.0,
NULL);
+ setup_item_signals (ellipse1);
ellipse2 = goo_canvas_ellipse_new (root, 335, 70, 45, 30,
"fill-color", "wheat",
@@ -726,6 +703,7 @@
#if 0
goo_canvas_item_rotate (ellipse2, 45, 335, 70);
#endif
+ setup_item_signals (ellipse2);
pattern = create_stipple ("cadetblue", stipple_data);
ellipse3 = goo_canvas_ellipse_new (root, 245, 110, 35, 30,
@@ -734,6 +712,7 @@
"line-width", 1.0,
NULL);
cairo_pattern_destroy (pattern);
+ setup_item_signals (ellipse3);
#if 0
@@ -752,19 +731,15 @@
polish_diamond (GooCanvasItem *root)
{
GooCanvasItem *group, *item;
- GooCanvasStyle *style;
int i, j;
double a, x1, y1, x2, y2;
- style = goo_canvas_style_new ();
- style->mask = GOO_CANVAS_STYLE_STROKE_PATTERN | GOO_CANVAS_STYLE_LINE_WIDTH
- | GOO_CANVAS_STYLE_LINE_CAP;
- style->stroke_pattern = cairo_pattern_create_rgb (0, 0, 0);
- style->line_width = 1;
- style->line_cap = CAIRO_LINE_CAP_ROUND;
-
- group = goo_canvas_group_new (root);
+ group = goo_canvas_group_new (root,
+ "line-width", 1.0,
+ "line-cap", CAIRO_LINE_CAP_ROUND,
+ NULL);
goo_canvas_item_translate (group, 270, 230);
+ setup_item_signals (group);
for (i = 0; i < VERTICES; i++) {
a = 2.0 * M_PI * i / VERTICES;
@@ -776,12 +751,8 @@
x2 = RADIUS * cos (a);
y2 = RADIUS * sin (a);
item = goo_canvas_polyline_new_line (group, x1, y1, x2, y2, NULL);
- g_object_set_data (G_OBJECT (item), "skip-signal-connection", "TRUE");
- goo_canvas_item_simple_set_style (GOO_CANVAS_ITEM_SIMPLE (item), style);
}
}
-
- goo_canvas_style_unref (style);
}
@@ -829,14 +800,15 @@
}
pattern = create_stipple ("red", stipple_data);
- item = goo_canvas_item_new (root, GOO_TYPE_CANVAS_POLYLINE,
- "points", points,
- "line-width", 4.0,
- "stroke-pattern", pattern,
- "line-cap", CAIRO_LINE_CAP_SQUARE,
- "line-join", CAIRO_LINE_JOIN_MITER,
- NULL);
+ item = goo_canvas_polyline_new (root, FALSE, 0,
+ "points", points,
+ "line-width", 4.0,
+ "stroke-pattern", pattern,
+ "line-cap", CAIRO_LINE_CAP_SQUARE,
+ "line-join", CAIRO_LINE_JOIN_MITER,
+ NULL);
cairo_pattern_destroy (pattern);
+ setup_item_signals (item);
goo_canvas_points_unref (points);
}
@@ -864,6 +836,7 @@
"arrow-length", 4.0,
"arrow-width", 3.5,
NULL);
+ setup_item_signals (polyline1);
polyline2 = goo_canvas_polyline_new (root, FALSE, 2,
356.0, 180.0,
@@ -876,6 +849,7 @@
"arrow-length", 6.0,
"arrow-width", 6.0,
NULL);
+ setup_item_signals (polyline2);
polyline3 = goo_canvas_polyline_new (root, FALSE, 2,
356.0, 220.0,
@@ -888,10 +862,12 @@
"arrow-length", 6.0,
"arrow-width", 6.0,
NULL);
+ setup_item_signals (polyline3);
/* Test polyline without any coords. */
polyline4 = goo_canvas_polyline_new (root, FALSE, 0,
NULL);
+ setup_item_signals (polyline4);
/* Test polyline with 1 coord and arrows. */
polyline5 = goo_canvas_polyline_new (root, FALSE, 1,
@@ -899,6 +875,7 @@
"start-arrow", TRUE,
"end-arrow", TRUE,
NULL);
+ setup_item_signals (polyline5);
}
@@ -920,15 +897,15 @@
points->coords[4] = 260.0;
points->coords[5] = 350.0;
pattern = create_stipple ("blue", stipple_data);
- polyline1 = goo_canvas_item_new (root, GOO_TYPE_CANVAS_POLYLINE,
- "line-width", 1.0,
- "points", points,
- "fill_pattern", pattern,
- "stroke_color", "black",
- "close-path", TRUE,
- NULL);
+ polyline1 = goo_canvas_polyline_new (root, TRUE, 0,
+ "line-width", 1.0,
+ "points", points,
+ "fill_pattern", pattern,
+ "stroke_color", "black",
+ NULL);
cairo_pattern_destroy (pattern);
goo_canvas_points_unref (points);
+ setup_item_signals (polyline1);
points = goo_canvas_points_new (14);
points->coords[0] = 270.0;
@@ -959,14 +936,14 @@
points->coords[25] = 410.0;
points->coords[26] = 290.0;
points->coords[27] = 330.0;
- polyline2 = goo_canvas_item_new (root, GOO_TYPE_CANVAS_POLYLINE,
- "points", points,
- "fill_color", "tan",
- "stroke_color", "black",
- "line-width", 3.0,
- "close-path", TRUE,
- NULL);
+ polyline2 = goo_canvas_polyline_new (root, TRUE, 0,
+ "points", points,
+ "fill_color", "tan",
+ "stroke_color", "black",
+ "line-width", 3.0,
+ NULL);
goo_canvas_points_unref (points);
+ setup_item_signals (polyline2);
}
@@ -976,7 +953,7 @@
GooCanvasItem *group, *item;
cairo_matrix_t transform = { 0.8, 0.2, -0.3, 0.5, x, y };
- group = goo_canvas_group_new (root);
+ group = goo_canvas_group_new (root, NULL);
goo_canvas_item_translate (group, x, y);
#if 1
g_object_set (group,
@@ -987,6 +964,7 @@
item = goo_canvas_rect_new (group, -2.5, -2.5, 4, 4,
"line-width", 1.0,
NULL);
+ setup_item_signals (item);
return group;
}
@@ -994,6 +972,7 @@
static void
setup_texts (GooCanvasItem *root)
{
+ GooCanvasItem *item;
cairo_pattern_t *pattern;
static guchar stipple_data[16] = {
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255
@@ -1001,33 +980,36 @@
#if 1
pattern = create_stipple ("blue", stipple_data);
- goo_canvas_text_new (make_anchor (root, 420, 20),
- "Anchor NW", 0, 0, -1, GTK_ANCHOR_NW,
- "font", "Sans Bold 24",
- "fill_pattern", pattern,
- NULL);
+ item = goo_canvas_text_new (make_anchor (root, 420, 20),
+ "Anchor NW", 0, 0, -1, GTK_ANCHOR_NW,
+ "font", "Sans Bold 24",
+ "fill_pattern", pattern,
+ NULL);
cairo_pattern_destroy (pattern);
+ setup_item_signals (item);
- goo_canvas_text_new (make_anchor (root, 470, 75),
- "Anchor center\nJustify center\nMultiline text\nb8bit text Ã
ÃÃåäö",
- 0, 0, -1, GTK_ANCHOR_CENTER,
- "font", "monospace bold 14",
- "alignment", PANGO_ALIGN_CENTER,
- "fill_color", "firebrick",
- NULL);
+ item = goo_canvas_text_new (make_anchor (root, 470, 75),
+ "Anchor center\nJustify center\nMultiline text\nb8bit text Ã
ÃÃåäö",
+ 0, 0, -1, GTK_ANCHOR_CENTER,
+ "font", "monospace bold 14",
+ "alignment", PANGO_ALIGN_CENTER,
+ "fill_color", "firebrick",
+ NULL);
+ setup_item_signals (item);
#endif
#if 0
- goo_canvas_text_new (make_anchor (root, 590, 140),
- "Clipped text\nClipped text\nClipped text\nClipped text\nClipped text\nClipped text",
- 0, 0, -1, GTK_ANCHOR_SE,
- "font", "Sans 12",
- /*"clip", TRUE,*/
- /*"clip_width", 50.0,*/
- /*"clip_height", 55.0,*/
- /*"x_offset", 10.0,*/
- "fill_color", "darkgreen",
- NULL);
+ item = goo_canvas_text_new (make_anchor (root, 590, 140),
+ "Clipped text\nClipped text\nClipped text\nClipped text\nClipped text\nClipped text",
+ 0, 0, -1, GTK_ANCHOR_SE,
+ "font", "Sans 12",
+ /*"clip", TRUE,*/
+ /*"clip_width", 50.0,*/
+ /*"clip_height", 55.0,*/
+ /*"x_offset", 10.0,*/
+ "fill_color", "darkgreen",
+ NULL);
+ setup_item_signals (item);
#endif
#if 1
@@ -1037,6 +1019,7 @@
"font", "Sans 12",
"fill_color", "goldenrod",
NULL);
+ setup_item_signals (textitem);
#endif
}
@@ -1104,14 +1087,13 @@
pattern = cairo_pattern_create_for_surface (surface);
cairo_surface_destroy (surface);
- image = goo_canvas_item_new (root, GOO_TYPE_CANVAS_IMAGE,
+ image = goo_canvas_image_new (root, NULL, x, y,
"pattern", pattern,
- "x", x,
- "y", y,
"width", w,
"height", h,
NULL);
cairo_pattern_destroy (pattern);
+ setup_item_signals (image);
}
static void
@@ -1126,15 +1108,13 @@
{
double w = gdk_pixbuf_get_width (im);
double h = gdk_pixbuf_get_height (im);
- image = goo_canvas_item_new (root, GOO_TYPE_CANVAS_IMAGE,
- "pixbuf", im,
- "x", 100.0 - w / 2,
- "y", 225.0 - h / 2,
+ image = goo_canvas_image_new (root, im, 100.0 - w / 2, 225.0 - h / 2,
"width", w,
"height", h,
/* "anchor", GTK_ANCHOR_CENTER, */
NULL);
g_object_unref(im);
+ setup_item_signals (image);
}
else
g_warning ("Could not find the toroid.png sample file");
@@ -1146,14 +1126,14 @@
}
-static GooCanvasModelSimple*
-create_model (void)
+static void
+setup_canvas (GooCanvas *canvas)
{
- GooCanvasModelSimple *canvas_model;
GooCanvasItem *root;
- canvas_model = goo_canvas_model_simple_new ();
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
+ root = goo_canvas_get_root_item (canvas);
+ g_signal_connect (root, "button_press_event",
+ (GtkSignalFunc) on_background_button_press, NULL);
/* Setup canvas items */
#if 1
@@ -1166,11 +1146,6 @@
setup_images (root);
setup_invisible_texts (root);
#endif
-#if 0
- setup_widgets (root);
-#endif
-
- return canvas_model;
}
@@ -1184,7 +1159,7 @@
static GtkWidget*
-create_window (GooCanvasModelSimple *canvas_model)
+create_window ()
{
GtkWidget *window, *notebook;
@@ -1199,7 +1174,7 @@
gtk_container_add (GTK_CONTAINER (window), notebook);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
- create_canvas_primitives (canvas_model),
+ create_canvas_primitives (),
gtk_label_new ("Primitives"));
#if 1
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
@@ -1249,19 +1224,12 @@
int
main (int argc, char *argv[])
{
- GooCanvasModelSimple *canvas_model;
GtkWidget *window;
gtk_set_locale ();
gtk_init (&argc, &argv);
- canvas_model = create_model ();
-
- /* Create 2 windows to show off multiple views. */
- window = create_window (canvas_model);
-#if 1
- window = create_window (canvas_model);
-#endif
+ window = create_window ();
gtk_main ();
return 0;
Index: scalability-demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/scalability-demo.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- scalability-demo.c 31 Aug 2006 15:45:09 -0000 1.3
+++ scalability-demo.c 29 Nov 2006 18:47:02 -0000 1.4
@@ -30,12 +30,11 @@
char ids[N_TOTAL_ID_ITEMS][MAX_ID_LEN];
static gboolean
-on_motion_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_motion_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventMotion *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (target);
gchar *id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s item received 'motion-notify' signal\n", id ? id : "Unknown");
@@ -45,23 +44,8 @@
static void
-on_item_view_created (GooCanvasView *view,
- GooCanvasItemView *item_view,
- GooCanvasItem *item,
- gpointer data)
-{
- if (GOO_IS_CANVAS_RECT (item) || GOO_IS_CANVAS_IMAGE (item))
- {
- g_signal_connect (item_view, "motion_notify_event",
- (GtkSignalFunc) on_motion_notify, NULL);
- }
-}
-
-
-GooCanvasModel*
-create_model (void)
+setup_canvas (GtkWidget *canvas)
{
- GooCanvasModelSimple *canvas_model;
GooCanvasItem *root, *group, *item;
GdkPixbuf *pixbuf = NULL;
cairo_pattern_t *pattern = NULL;
@@ -70,11 +54,11 @@
double cell_width, cell_height;
double group_width, group_height;
int total_items = 0, id_item_num = 0;;
- GooCanvasStyle *style, *style2;
GdkColor color = { 0, 0, 0, 0, };
+ GooCanvasStyle *style, *style2;
+ GValue tmpval = { 0 };
- canvas_model = goo_canvas_model_simple_new ();
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
#ifdef USE_PIXMAP
pixbuf = gdk_pixbuf_new_from_file("toroid.png", NULL);
@@ -101,16 +85,24 @@
top_offset = -total_height / 2;
style = goo_canvas_style_new ();
- style->mask |= GOO_CANVAS_STYLE_FILL_PATTERN;
gdk_color_parse ("mediumseagreen", &color);
- style->fill_pattern = cairo_pattern_create_rgb
- (color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0);
+ pattern = cairo_pattern_create_rgb (color.red / 65535.0,
+ color.green / 65535.0,
+ color.blue / 65535.0);
+ g_value_init (&tmpval, GOO_TYPE_CAIRO_PATTERN);
+ g_value_take_boxed (&tmpval, pattern);
+ goo_canvas_style_set_property (style, goo_canvas_style_fill_pattern_id, &tmpval);
+ g_value_unset (&tmpval);
style2 = goo_canvas_style_new ();
- style2->mask |= GOO_CANVAS_STYLE_FILL_PATTERN;
gdk_color_parse ("steelblue", &color);
- style2->fill_pattern = cairo_pattern_create_rgb
- (color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0);
+ pattern = cairo_pattern_create_rgb (color.red / 65535.0,
+ color.green / 65535.0,
+ color.blue / 65535.0);
+ g_value_init (&tmpval, GOO_TYPE_CAIRO_PATTERN);
+ g_value_take_boxed (&tmpval, pattern);
+ goo_canvas_style_set_property (style2, goo_canvas_style_fill_pattern_id, &tmpval);
+ g_value_unset (&tmpval);
for (group_i = 0; group_i < N_GROUP_COLS; group_i++)
{
@@ -119,7 +111,7 @@
double group_x = left_offset + (group_i * group_width);
double group_y = top_offset + (group_j * group_height);
- group = goo_canvas_group_new (root);
+ group = goo_canvas_group_new (root, NULL);
total_items++;
goo_canvas_item_translate (group, group_x, group_y);
@@ -146,12 +138,15 @@
item = goo_canvas_rect_new (group, item_x, item_y,
item_width, item_height,
NULL);
- goo_canvas_item_simple_set_style ((GooCanvasItemSimple*) item, (j % 2) ? style : style2);
+ goo_canvas_item_set_style (item, (j % 2) ? style : style2);
goo_canvas_item_rotate (item, rotation, rotation_x, rotation_y);
#endif
g_object_set_data (G_OBJECT (item), "id",
ids[id_item_num]);
+ g_signal_connect (item, "motion_notify_event",
+ (GtkSignalFunc) on_motion_notify, NULL);
+
item = goo_canvas_text_new (group, ids[id_item_num],
item_x + item_width / 2,
item_y + item_height / 2,
@@ -185,8 +180,6 @@
cairo_pattern_destroy (pattern);
g_print ("Total items: %i\n", total_items);
-
- return (GooCanvasModel*) canvas_model;
}
@@ -194,32 +187,19 @@
create_canvas (void)
{
GtkWidget *canvas;
- GooCanvasModel *canvas_model;
clock_t start;
/* Create the canvas. */
- canvas = goo_canvas_view_new ();
+ canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 600, 450);
- g_signal_connect (canvas, "item_view_created",
- (GtkSignalFunc) on_item_view_created,
- NULL);
-
- start = clock();
- canvas_model = create_model ();
- printf ("Create Model Time Used: %g\n",
- (double) (clock() - start) / CLOCKS_PER_SEC);
start = clock();
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas), canvas_model);
- printf ("Create Views Time Used: %g\n",
+ setup_canvas (canvas);
+ printf ("Create Canvas Time Used: %g\n",
(double) (clock() - start) / CLOCKS_PER_SEC);
- g_object_unref (canvas_model);
-
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas),
- left_offset, top_offset,
- left_offset + total_width,
- top_offset + total_height);
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), left_offset, top_offset,
+ left_offset + total_width, top_offset + total_height);
gtk_widget_show (canvas);
return canvas;
Index: simple-demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/simple-demo.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- simple-demo.c 23 Aug 2006 11:56:05 -0000 1.2
+++ simple-demo.c 29 Nov 2006 18:47:02 -0000 1.3
@@ -2,22 +2,20 @@
#include <goocanvas.h>
-static gboolean on_rect_button_press (GooCanvasItemView *view,
- GooCanvasItemView *target,
- GdkEventButton *event,
- gpointer data);
+static gboolean on_rect_button_press (GooCanvasItem *view,
+ GooCanvasItem *target,
+ GdkEventButton *event,
+ gpointer data);
-static gboolean on_delete_event (GtkWidget *window,
- GdkEvent *event,
- gpointer unused_data);
+static gboolean on_delete_event (GtkWidget *window,
+ GdkEvent *event,
+ gpointer unused_data);
int
main (int argc, char *argv[])
{
GtkWidget *window, *scrolled_win, *canvas;
- GooCanvasModelSimple *canvas_model;
- GooCanvasItemView *item_view;
GooCanvasItem *root, *rect_item, *text_item;
/* Initialize GTK+. */
@@ -37,16 +35,13 @@
gtk_widget_show (scrolled_win);
gtk_container_add (GTK_CONTAINER (window), scrolled_win);
- canvas = goo_canvas_view_new ();
+ canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 600, 450);
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas), 0, 0, 1000, 1000);
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
gtk_widget_show (canvas);
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
- /* Create the canvas model */
- canvas_model = goo_canvas_model_simple_new ();
-
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
/* Add a few simple items. */
rect_item = goo_canvas_rect_new (root, 100, 100, 400, 400,
@@ -63,16 +58,8 @@
NULL);
goo_canvas_item_rotate (text_item, 45, 300, 300);
- /* Set the model of the canvas view. This will create item views for all the
- items in the model. */
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas),
- GOO_CANVAS_MODEL (canvas_model));
- g_object_unref (canvas_model);
-
- /* Connect a signal handler for the item view of the rectangle item. */
- item_view = goo_canvas_view_get_item_view (GOO_CANVAS_VIEW (canvas),
- rect_item);
- g_signal_connect (item_view, "button_press_event",
+ /* Connect a signal handler for the rectangle item. */
+ g_signal_connect (rect_item, "button_press_event",
(GtkSignalFunc) on_rect_button_press, NULL);
/* Pass control to the GTK+ main event loop. */
@@ -85,10 +72,10 @@
/* This handles button presses in item views. We simply output a message to
the console. */
static gboolean
-on_rect_button_press (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_rect_button_press (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventButton *event,
- gpointer data)
+ gpointer data)
{
g_print ("rect item received button press event\n");
return TRUE;
Index: units-demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/units-demo.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- units-demo.c 31 Aug 2006 15:45:09 -0000 1.1
+++ units-demo.c 29 Nov 2006 18:47:02 -0000 1.2
@@ -3,12 +3,11 @@
static gboolean
-on_motion_notify (GooCanvasItemView *view,
- GooCanvasItemView *target,
+on_motion_notify (GooCanvasItem *item,
+ GooCanvasItem *target,
GdkEventMotion *event,
gpointer data)
{
- GooCanvasItem *item = goo_canvas_item_view_get_item (target);
gchar *id = g_object_get_data (G_OBJECT (item), "id");
g_print ("%s item received 'motion-notify' signal\n", id ? id : "Unknown");
@@ -18,24 +17,10 @@
static void
-on_item_view_created (GooCanvasView *view,
- GooCanvasItemView *item_view,
- GooCanvasItem *item,
- gpointer data)
-{
- if (GOO_IS_CANVAS_RECT (item) || GOO_IS_CANVAS_IMAGE (item))
- {
- g_signal_connect (item_view, "motion_notify_event",
- (GtkSignalFunc) on_motion_notify, NULL);
- }
-}
-
-
-GooCanvasModel*
-create_model (GtkUnit units,
+setup_canvas (GtkWidget *canvas,
+ GtkUnit units,
gchar *units_name)
{
- GooCanvasModelSimple *canvas_model;
GooCanvasItem *root, *item;
gchar buffer[256], font_desc[64];
double *d;
@@ -59,11 +44,12 @@
d = data[units];
- canvas_model = goo_canvas_model_simple_new ();
- root = goo_canvas_model_get_root_item (GOO_CANVAS_MODEL (canvas_model));
+ root = goo_canvas_get_root_item (GOO_CANVAS (canvas));
item = goo_canvas_rect_new (root, d[0], d[1], d[2], d[3],
NULL);
+ g_signal_connect (item, "motion_notify_event",
+ (GtkSignalFunc) on_motion_notify, NULL);
sprintf (buffer, "This box is %gx%g %s", d[2], d[3], units_name);
sprintf (font_desc, "Sans %gpx", d[4]);
@@ -79,15 +65,13 @@
GTK_ANCHOR_CENTER,
"font", font_desc,
NULL);
-
- return (GooCanvasModel*) canvas_model;
}
static void
-zoom_changed (GtkAdjustment *adj, GooCanvasView *canvas_view)
+zoom_changed (GtkAdjustment *adj, GooCanvas *canvas)
{
- goo_canvas_view_set_scale (canvas_view, adj->value);
+ goo_canvas_set_scale (canvas, adj->value);
}
@@ -96,7 +80,6 @@
gchar *units_name)
{
GtkWidget *vbox, *hbox, *w, *scrolled_win, *canvas;
- GooCanvasModel *canvas_model;
GtkAdjustment *adj;
vbox = gtk_vbox_new (FALSE, 4);
@@ -107,7 +90,7 @@
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
- canvas = goo_canvas_view_new ();
+ canvas = goo_canvas_new ();
w = gtk_label_new ("Zoom:");
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
@@ -128,16 +111,9 @@
/* Create the canvas. */
gtk_widget_set_size_request (canvas, 600, 450);
- g_signal_connect (canvas, "item_view_created",
- (GtkSignalFunc) on_item_view_created,
- NULL);
-
- canvas_model = create_model (units, units_name);
- goo_canvas_view_set_model (GOO_CANVAS_VIEW (canvas), canvas_model);
- g_object_unref (canvas_model);
+ setup_canvas (canvas, units, units_name);
- goo_canvas_view_set_bounds (GOO_CANVAS_VIEW (canvas),
- 0, 0, 1000, 1000);
+ goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
g_object_set (canvas,
"units", units,
"anchor", GTK_ANCHOR_CENTER,
More information about the cairo-commit
mailing list