[cairo-commit] goocanvas/src goocanvasgroup.c, 1.24, 1.25 goocanvasitem.c, 1.31, 1.32 goocanvasitemsimple.c, 1.34, 1.35 goocanvastable.c, 1.13, 1.14

Damon Chaplin commit at pdx.freedesktop.org
Mon Aug 13 04:18:41 PDT 2007


Committed by: damon

Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv11183/src

Modified Files:
	goocanvasgroup.c goocanvasitem.c goocanvasitemsimple.c 
	goocanvastable.c 
Log Message:
2007-08-13  Damon Chaplin  <damon at gnome.org>

	* src/goocanvastable.c: use static goo_canvas_table_parent_iface
	and goo_canvas_table_model_parent_iface variables which are set in
	the class_init functions. That makes it much easier to call the
	GooCanvasGroup methods when needed.

	* src/goocanvasitemsimple.c (goo_canvas_item_simple_set_parent): call
	goo_canvas_item_set_canvas() so items can do whatever is needed
	(e.g. groups can pass the canvas on to children).

	* src/goocanvasitem.c (goo_canvas_item_request_update): don't use
	return here as it is a void function.

	* src/goocanvastable.c (goo_canvas_table_remove_child): 
	* src/goocanvasgroup.c (goo_canvas_group_remove_child): check the
	child_num arg is valid.



Index: goocanvasgroup.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasgroup.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- goocanvasgroup.c	25 Apr 2007 13:24:38 -0000	1.24
+++ goocanvasgroup.c	13 Aug 2007 11:18:23 -0000	1.25
@@ -204,6 +204,8 @@
   GooCanvasItem *child;
   GooCanvasBounds bounds;
 
+  g_return_if_fail (child_num < group->items->len);
+
   /* Request a redraw of the item's bounds. */
   child = group->items->pdata[child_num];
   if (simple->canvas)

Index: goocanvasitem.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- goocanvasitem.c	25 Apr 2007 13:24:38 -0000	1.31
+++ goocanvasitem.c	13 Aug 2007 11:18:23 -0000	1.32
@@ -1310,9 +1310,9 @@
   GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
 
   if (iface->request_update)
-    return iface->request_update (item);
+    iface->request_update (item);
   else
-    return goo_canvas_item_request_update (iface->get_parent (item));
+    goo_canvas_item_request_update (iface->get_parent (item));
 }
 
 

Index: goocanvasitemsimple.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemsimple.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- goocanvasitemsimple.c	11 May 2007 16:30:49 -0000	1.34
+++ goocanvasitemsimple.c	13 Aug 2007 11:18:23 -0000	1.35
@@ -840,8 +840,11 @@
 				   GooCanvasItem  *parent)
 {
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
+  GooCanvas *canvas;
+
   simple->parent = parent;
-  simple->canvas = parent ? goo_canvas_item_get_canvas (parent) : NULL;
+  canvas = parent ? goo_canvas_item_get_canvas (parent) : NULL;
+  goo_canvas_item_set_canvas (item, canvas);
   simple->need_update = TRUE;
   simple->need_entire_subtree_update = TRUE;
 }

Index: goocanvastable.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvastable.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- goocanvastable.c	19 Jun 2007 11:22:53 -0000	1.13
+++ goocanvastable.c	13 Aug 2007 11:18:23 -0000	1.14
@@ -163,7 +163,7 @@
   gdouble last_width;
 };
 
-
+static GooCanvasItemIface *goo_canvas_table_parent_iface;
 
 static void item_interface_init           (GooCanvasItemIface *iface);
 static void goo_canvas_table_finalize     (GObject            *object);
@@ -343,6 +343,8 @@
 {
   GObjectClass *gobject_class = (GObjectClass*) klass;
 
+  goo_canvas_table_parent_iface = g_type_interface_peek (goo_canvas_table_parent_class, GOO_TYPE_CANVAS_ITEM);
+
   gobject_class->finalize = goo_canvas_table_finalize;
   gobject_class->get_property = goo_canvas_table_get_property;
   gobject_class->set_property = goo_canvas_table_set_property;
@@ -351,7 +353,7 @@
 }
 
 
-/* This frees the contents of the table data, but not the struct itself. */
+/* This initializes the common table data. */
 static void
 goo_canvas_table_init_data (GooCanvasTableData *table_data)
 {
@@ -663,8 +665,6 @@
 				GooCanvasItem  *child,
 				gint            position)
 {
-  GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
-  GooCanvasItemIface *parent_iface = g_type_interface_peek_parent (iface);
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
   GooCanvasTable *table = (GooCanvasTable*) item;
 
@@ -672,7 +672,7 @@
     goo_canvas_table_add_child_internal (table->table_data, position);
 
   /* Let the parent GooCanvasGroup code do the rest. */
-  parent_iface->add_child (item, child, position);
+  goo_canvas_table_parent_iface->add_child (item, child, position);
 }
 
 
@@ -719,8 +719,6 @@
 				gint	        old_position,
 				gint            new_position)
 {
-  GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
-  GooCanvasItemIface *parent_iface = g_type_interface_peek_parent (iface);
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
   GooCanvasTable *table = (GooCanvasTable*) item;
 
@@ -729,7 +727,7 @@
 					  new_position);
 
   /* Let the parent GooCanvasGroup code do the rest. */
-  parent_iface->move_child (item, old_position, new_position);
+  goo_canvas_table_parent_iface->move_child (item, old_position, new_position);
 }
 
 
@@ -737,16 +735,17 @@
 goo_canvas_table_remove_child  (GooCanvasItem  *item,
 				gint            child_num)
 {
-  GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
-  GooCanvasItemIface *parent_iface = g_type_interface_peek_parent (iface);
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
+  GooCanvasGroup *group = (GooCanvasGroup*) item;
   GooCanvasTable *table = (GooCanvasTable*) item;
 
+  g_return_if_fail (child_num < group->items->len);
+
   if (!simple->model)
     g_array_remove_index (table->table_data->children, child_num);
 
   /* Let the parent GooCanvasGroup code do the rest. */
-  parent_iface->remove_child (item, child_num);
+  goo_canvas_table_parent_iface->remove_child (item, child_num);
 }
 
 
@@ -968,8 +967,6 @@
 goo_canvas_table_set_model    (GooCanvasItem      *item,
 			       GooCanvasItemModel *model)
 {
-  GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
-  GooCanvasItemIface *parent_iface = g_type_interface_peek_parent (iface);
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
   GooCanvasTable *table = (GooCanvasTable*) item;
   GooCanvasTableModel *tmodel = (GooCanvasTableModel*) model;
@@ -985,7 +982,7 @@
   table->table_data = &tmodel->table_data;
 
   /* Let the parent GooCanvasGroup code do the rest. */
-  parent_iface->set_model (item, model);
+  goo_canvas_table_parent_iface->set_model (item, model);
 }
 
 
@@ -2330,6 +2327,8 @@
  * g_object_get() and g_object_set().
  */
 
+static GooCanvasItemModelIface *goo_canvas_table_model_parent_iface;
+
 static void item_model_interface_init (GooCanvasItemModelIface *iface);
 static void goo_canvas_table_model_finalize (GObject *object);
 static void goo_canvas_table_model_get_property (GObject            *object,
@@ -2352,6 +2351,8 @@
 {
   GObjectClass *gobject_class = (GObjectClass*) klass;
 
+  goo_canvas_table_model_parent_iface = g_type_interface_peek (goo_canvas_table_model_parent_class, GOO_TYPE_CANVAS_ITEM_MODEL);
+
   gobject_class->finalize = goo_canvas_table_model_finalize;
 
   gobject_class->get_property = goo_canvas_table_model_get_property;
@@ -2491,14 +2492,12 @@
 				      GooCanvasItemModel *child,
 				      gint                position)
 {
-  GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
-  GooCanvasItemModelIface *parent_iface = g_type_interface_peek_parent (iface);
   GooCanvasTableModel *tmodel = (GooCanvasTableModel*) model;
 
   goo_canvas_table_add_child_internal (&tmodel->table_data, position);
 
   /* Let the parent GooCanvasGroupModel code do the rest. */
-  parent_iface->add_child (model, child, position);
+  goo_canvas_table_model_parent_iface->add_child (model, child, position);
 }
 
 
@@ -2507,15 +2506,14 @@
 				      gint	          old_position,
 				      gint                new_position)
 {
-  GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
-  GooCanvasItemModelIface *parent_iface = g_type_interface_peek_parent (iface);
   GooCanvasTableModel *tmodel = (GooCanvasTableModel*) model;
 
   goo_canvas_table_move_child_internal (&tmodel->table_data, old_position,
 					new_position);
 
   /* Let the parent GooCanvasGroupModel code do the rest. */
-  parent_iface->move_child (model, old_position, new_position);
+  goo_canvas_table_model_parent_iface->move_child (model, old_position,
+						   new_position);
 }
 
 
@@ -2523,14 +2521,12 @@
 goo_canvas_table_model_remove_child  (GooCanvasItemModel *model,
 				      gint                child_num)
 {
-  GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
-  GooCanvasItemModelIface *parent_iface = g_type_interface_peek_parent (iface);
   GooCanvasTableModel *tmodel = (GooCanvasTableModel*) model;
 
   g_array_remove_index (tmodel->table_data.children, child_num);
 
   /* Let the parent GooCanvasGroupModel code do the rest. */
-  parent_iface->remove_child (model, child_num);
+  goo_canvas_table_model_parent_iface->remove_child (model, child_num);
 }
 
 



More information about the cairo-commit mailing list