[cairo-commit] goocanvas/src goocanvasitem.c, 1.35, 1.36 goocanvasitemmodel.c, 1.18, 1.19 goocanvasitemsimple.c, 1.37, 1.38

Damon Chaplin commit at pdx.freedesktop.org
Fri Apr 4 04:04:16 PDT 2008


Committed by: damon

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

Modified Files:
	goocanvasitem.c goocanvasitemmodel.c goocanvasitemsimple.c 
Log Message:
2008-04-04  Damon Chaplin  <damon at gnome.org>

	    * docs/coordinates.xml: 
	    * docs/architecture.xml: new sections.

	    * docs/creating-items.xml: rewritten.

	    * src/goocanvasitemmodel.c (goo_canvas_item_model_set_parent): 
	    * src/goocanvasitem.c (goo_canvas_item_set_parent): note in the docs
	    that the "parent" property can be used to set the parent, but that
	    these functions are only for implementing new items (a bit confusing).

	    * src/goocanvasitem.c (goo_canvas_item_is_visible): fixed a bug
	    where if the item doesn't support the method it would just return
	    TRUE, but it should also check the ancestors are visible.

	    * src/goocanvasitemsimple.c (goo_canvas_item_simple_set_property)
	    (goo_canvas_item_model_simple_set_property): use the _remove()
	    functions instead of the find_child()/remove_child() code.



Index: goocanvasitem.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- goocanvasitem.c	27 Mar 2008 14:08:55 -0000	1.35
+++ goocanvasitem.c	4 Apr 2008 11:08:22 -0000	1.36
@@ -663,17 +663,7 @@
  * <note><para>
  * This function cannot be used to add an item to a group
  * or to change the parent of an item.
- *
- * To add an item to a group use goo_canvas_item_add_child().
- *
- * To move an item from one parent to another do something like this:
- *
- * <informalexample><programlisting>
- *  g_object_ref (item);
- *  goo_canvas_item_remove (item);
- *  goo_canvas_item_add_child (new_parent, item, -1);
- *  g_object_unref (item);
- * </programlisting></informalexample>
+ * To do that use the #GooCanvasItem:parent property.
  * </para></note>
  **/
 void
@@ -1464,9 +1454,18 @@
 goo_canvas_item_is_visible  (GooCanvasItem   *item)
 {
   GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
+  GooCanvasItem *parent;
 
-  /* If the item doesn't implement this method assume it is visible. */
-  return iface->is_visible ? iface->is_visible (item) : TRUE;
+  if (iface->is_visible)
+    return iface->is_visible (item);
+
+  /* If the item doesn't implement the is_visible method we assume it is
+     visible and check its ancestors. */
+  parent = goo_canvas_item_get_parent (item);
+  if (parent)
+    return goo_canvas_item_is_visible (parent);
+
+  return TRUE;
 }
 
 

Index: goocanvasitemmodel.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemmodel.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- goocanvasitemmodel.c	27 Mar 2008 14:08:55 -0000	1.18
+++ goocanvasitemmodel.c	4 Apr 2008 11:08:22 -0000	1.19
@@ -421,7 +421,15 @@
  * @model: an item model.
  * @parent: the new parent item model.
  * 
- * Sets the parent of the model.
+ * This function is only intended to be used when implementing new canvas
+ * item models (specifically container models such as #GooCanvasGroupModel).
+ * It sets the parent of the child model.
+ * <!--PARAMETERS-->
+ * <note><para>
+ * This function cannot be used to add a model to a group
+ * or to change the parent of a model.
+ * To do that use the #GooCanvasItemModel:parent property.
+ * </para></note>
  **/
 void
 goo_canvas_item_model_set_parent (GooCanvasItemModel *model,

Index: goocanvasitemsimple.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemsimple.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- goocanvasitemsimple.c	23 Mar 2008 23:33:41 -0000	1.37
+++ goocanvasitemsimple.c	4 Apr 2008 11:08:22 -0000	1.38
@@ -842,7 +842,6 @@
   GooCanvasItem *parent;
   AtkObject *accessible;
   gboolean recompute_bounds;
-  gint child_num;
 
   if (simple->model)
     {
@@ -854,11 +853,7 @@
     {
     case PROP_PARENT:
       parent = g_value_get_object (value);
-      if (simple->parent)
-	{
-	  child_num = goo_canvas_item_find_child (simple->parent, item);
-	  goo_canvas_item_remove_child (simple->parent, child_num);
-	}
+      goo_canvas_item_remove (item);
       goo_canvas_item_add_child (parent, item, -1);
       break;
     case PROP_TITLE:
@@ -1992,17 +1987,12 @@
   GooCanvasItemSimpleData *simple_data = &smodel->simple_data;
   GooCanvasItemModel *parent;
   gboolean recompute_bounds;
-  gint child_num;
 
   switch (prop_id)
     {
     case PROP_PARENT:
       parent = g_value_get_object (value);
-      if (smodel->parent)
-	{
-	  child_num = goo_canvas_item_model_find_child (smodel->parent, model);
-	  goo_canvas_item_model_remove_child (smodel->parent, child_num);
-	}
+      goo_canvas_item_model_remove (model);
       goo_canvas_item_model_add_child (parent, model, -1);
       break;
     case PROP_TITLE:



More information about the cairo-commit mailing list