[cairo-commit] goocanvas/src goocanvasitem.c, 1.27, 1.28 goocanvasitem.h, 1.19, 1.20 goocanvasitemmodel.c, 1.13, 1.14 goocanvasitemmodel.h, 1.10, 1.11

Damon Chaplin commit at pdx.freedesktop.org
Thu Mar 8 05:58:52 PST 2007


Committed by: damon

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

Modified Files:
	goocanvasitem.c goocanvasitem.h goocanvasitemmodel.c 
	goocanvasitemmodel.h 
Log Message:
2007-03-08  Damon Chaplin  <damon at gnome.org>

	* src/goocanvasitemmodel.c (goo_canvas_item_model_remove): 
	* src/goocanvasitem.c (goo_canvas_item_remove): new convenience
	functions to easily remove items & models from the canvas.

	* demo/mv-demo-features.c (on_button_press): 
	* demo/demo-features.c (on_button_press): 
	* demo/demo.c (on_button_press): 
	* demo/mv-demo.c (on_button_press): 
	* demo/widgets-demo.c (remove_widget_clicked): use new remove()
	functions to test them.

	* docs/goocanvas-sections.txt: rearranged GooCanvasItem/Model to put
	commonly-used functions first, and added remove() functions.



Index: goocanvasitem.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- goocanvasitem.c	7 Mar 2007 16:07:11 -0000	1.27
+++ goocanvasitem.c	8 Mar 2007 13:58:45 -0000	1.28
@@ -474,10 +474,10 @@
  * @item: a #GooCanvasItem.
  * @canvas: a #GooCanvas
  * 
- * Sets the canvas of the item.
+ * This function is only intended to be used when implementing new canvas
+ * items, specifically container items such as #GooCanvasGroup.
  *
- * This is only needed for setting the canvas of the root item, as the other
- * items can get the canvas from their parents.
+ * It sets the canvas of the item.
  **/
 void
 goo_canvas_item_set_canvas     (GooCanvasItem   *item,
@@ -655,7 +655,10 @@
  * @item: an item.
  * @parent: the new parent item.
  * 
- * Sets the parent of the item.
+ * This function is only intended to be used when implementing new canvas
+ * items, specifically container items such as #GooCanvasGroup.
+ *
+ * It sets the parent of the item.
  **/
 void
 goo_canvas_item_set_parent (GooCanvasItem *item,
@@ -666,6 +669,33 @@
 
 
 /**
+ * goo_canvas_item_remove:
+ * @item: an item.
+ * 
+ * Removes an item from its parent. If the item is in a canvas it will be
+ * removed.
+ *
+ * This would normally also result in the item being freed.
+ **/
+void
+goo_canvas_item_remove (GooCanvasItem *item)
+{
+  GooCanvasItem *parent;
+  gint child_num;
+
+  parent = goo_canvas_item_get_parent (item);
+  if (!parent)
+    return;
+
+  child_num = goo_canvas_item_find_child (parent, item);
+  if (child_num == -1)
+    return;
+
+  goo_canvas_item_remove_child (parent, child_num);
+}
+
+
+/**
  * goo_canvas_item_raise:
  * @item: an item.
  * @above: the item to raise @item above, or %NULL to raise @item to the top

Index: goocanvasitem.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- goocanvasitem.h	6 Mar 2007 13:39:16 -0000	1.19
+++ goocanvasitem.h	8 Mar 2007 13:58:45 -0000	1.20
@@ -325,6 +325,7 @@
 GooCanvasItem*     goo_canvas_item_get_parent     (GooCanvasItem   *item);
 void               goo_canvas_item_set_parent	  (GooCanvasItem   *item,
 						   GooCanvasItem   *parent);
+void               goo_canvas_item_remove         (GooCanvasItem   *item);
 gboolean           goo_canvas_item_is_container   (GooCanvasItem   *item);
 
 void               goo_canvas_item_raise          (GooCanvasItem   *item,

Index: goocanvasitemmodel.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemmodel.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- goocanvasitemmodel.c	7 Mar 2007 16:07:11 -0000	1.13
+++ goocanvasitemmodel.c	8 Mar 2007 13:58:45 -0000	1.14
@@ -431,6 +431,33 @@
 
 
 /**
+ * goo_canvas_item_model_remove:
+ * @model: an item model.
+ * 
+ * Removes a model from its parent. If the model is in a canvas it will be
+ * removed.
+ *
+ * This would normally also result in the model being freed.
+ **/
+void
+goo_canvas_item_model_remove         (GooCanvasItemModel *model)
+{
+  GooCanvasItemModel *parent;
+  gint child_num;
+
+  parent = goo_canvas_item_model_get_parent (model);
+  if (!parent)
+    return;
+
+  child_num = goo_canvas_item_model_find_child (parent, model);
+  if (child_num == -1)
+    return;
+
+  goo_canvas_item_model_remove_child (parent, child_num);
+}
+
+
+/**
  * goo_canvas_item_model_raise:
  * @model: an item model.
  * @above: the item model to raise @model above, or %NULL to raise @model to the top

Index: goocanvasitemmodel.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemmodel.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- goocanvasitemmodel.h	6 Mar 2007 13:21:26 -0000	1.10
+++ goocanvasitemmodel.h	8 Mar 2007 13:58:45 -0000	1.11
@@ -185,6 +185,7 @@
 GooCanvasItemModel* goo_canvas_item_model_get_parent     (GooCanvasItemModel *model);
 void                goo_canvas_item_model_set_parent	 (GooCanvasItemModel *model,
 							  GooCanvasItemModel *parent);
+void                goo_canvas_item_model_remove         (GooCanvasItemModel *model);
 gboolean            goo_canvas_item_model_is_container   (GooCanvasItemModel *model);
 
 void                goo_canvas_item_model_raise          (GooCanvasItemModel *model,



More information about the cairo-commit mailing list