gcompris r3621 - in branches/gcomprixogoo: . src/boards src/goocanvas/src src/watercycle-activity



Author: bcoudoin
Date: Wed Nov 19 01:00:13 2008
New Revision: 3621
URL: http://svn.gnome.org/viewvc/gcompris?rev=3621&view=rev

Log:
	- In progress watercycle.
	- Grabed code from goocanvas trunk by Damon Chaplin to have
	a signal "animation-finished"
	- Removed hiy_detection to use pointer_events=None instead.



Modified:
   branches/gcomprixogoo/ChangeLog
   branches/gcomprixogoo/src/boards/goocanvas.defs
   branches/gcomprixogoo/src/boards/py-mod-utils.c
   branches/gcomprixogoo/src/goocanvas/src/goocanvasitem.c
   branches/gcomprixogoo/src/goocanvas/src/goocanvasitem.h
   branches/gcomprixogoo/src/goocanvas/src/goocanvasitemmodel.c
   branches/gcomprixogoo/src/goocanvas/src/goocanvasitemmodel.h
   branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.c
   branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.h
   branches/gcomprixogoo/src/watercycle-activity/watercycle.py

Modified: branches/gcomprixogoo/src/boards/goocanvas.defs
==============================================================================
--- branches/gcomprixogoo/src/boards/goocanvas.defs	(original)
+++ branches/gcomprixogoo/src/boards/goocanvas.defs	Wed Nov 19 01:00:13 2008
@@ -734,7 +734,6 @@
     '("GooCanvasItem*" "parent")
     '("RsvgHandle*" "svg_handle")
     '("const-gchar*" "svg_id")
-    '("gboolean" "hit_detection")
   )
   (varargs #t)
 )

Modified: branches/gcomprixogoo/src/boards/py-mod-utils.c
==============================================================================
--- branches/gcomprixogoo/src/boards/py-mod-utils.c	(original)
+++ branches/gcomprixogoo/src/boards/py-mod-utils.c	Wed Nov 19 01:00:13 2008
@@ -126,6 +126,35 @@
 }
 
 
+/* gint	gc_item_focus_remove(GooCanvasItem *source_item,
+                           GooCanvasItem *target_item);
+*/
+static PyObject*
+py_gc_item_focus_remove(PyObject* self, PyObject* args)
+{
+  PyObject* pyitem;
+  PyObject* pytarget;
+  GooCanvasItem* item;
+  GooCanvasItem* target = NULL;
+
+  /* Parse arguments */
+  if(!PyArg_ParseTuple(args, "OO:gc_item_focus_remove",
+		       &pyitem, &pytarget))
+    return NULL;
+
+  item = (GooCanvasItem*) pygobject_get(pyitem);
+  if(pytarget != Py_None)
+    target = (GooCanvasItem*) pygobject_get(pytarget);
+
+  /* Call the corresponding C function */
+  gc_item_focus_remove(item, target);
+
+  /* Create and return the result */
+  Py_INCREF(Py_None);
+  return Py_None;
+}
+
+
 /* void gc_item_absolute_move(GooCanvasItem *item, int x, int y); */
 static PyObject*
 py_gc_item_absolute_move(PyObject* self, PyObject* args)
@@ -392,6 +421,7 @@
   { "load_svg",  py_gc_svg_load, METH_VARARGS, "gc_svg_load" },
   { "find_file_absolute",  py_gc_file_find_absolute, METH_VARARGS, "gc_file_find_absolute" },
   { "item_focus_init",  py_gc_item_focus_init, METH_VARARGS, "gc_item_focus_init" },
+  { "item_focus_remove",  py_gc_item_focus_remove, METH_VARARGS, "gc_item_focus_remove" },
   { "item_absolute_move",  py_gc_item_absolute_move, METH_VARARGS, "gc_item_absolute_move" },
   { "item_rotate",  py_gc_item_rotate, METH_VARARGS, "gc_item_rotate" },
   { "item_rotate_relative",  py_gc_item_rotate_relative, METH_VARARGS, "gc_item_rotate_relative" },

Modified: branches/gcomprixogoo/src/goocanvas/src/goocanvasitem.c
==============================================================================
--- branches/gcomprixogoo/src/goocanvas/src/goocanvasitem.c	(original)
+++ branches/gcomprixogoo/src/goocanvas/src/goocanvasitem.c	Wed Nov 19 01:00:13 2008
@@ -47,6 +47,7 @@
   /* Miscellaneous signals. */
   GRAB_BROKEN_EVENT,
   CHILD_NOTIFY,
+  ANIMATION_FINISHED,
 
   LAST_SIGNAL
 };
@@ -100,7 +101,7 @@
 {
   static GObjectNotifyContext cpn_context = { 0, NULL, NULL };
   static gboolean initialized = FALSE;
-  
+
   if (!initialized)
     {
       GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
@@ -361,7 +362,7 @@
        * @pspec: the #GParamSpec of the changed child property.
        *
        * Emitted for each child property that has changed.
-       * The signal's detail holds the property name. 
+       * The signal's detail holds the property name.
        */
       canvas_item_signals[CHILD_NOTIFY] =
 	g_signal_new ("child_notify",
@@ -374,6 +375,23 @@
 		      G_TYPE_PARAM);
 
 
+      /**
+       * GooCanvasItem::animation-finished
+       * @item: the item that received the signal.
+       * @stopped: if the animation was explicitly stopped.
+       *
+       * Emitted when the item animation has finished.
+       */
+      canvas_item_signals[ANIMATION_FINISHED] =
+	g_signal_new ("animation-finished",
+		      iface_type,
+		      G_SIGNAL_RUN_LAST,
+		      G_STRUCT_OFFSET (GooCanvasItemIface, animation_finished),
+		      NULL, NULL,
+		      g_cclosure_marshal_VOID__BOOLEAN,
+		      G_TYPE_NONE, 1,
+		      G_TYPE_BOOLEAN);
+
       g_object_interface_install_property (g_iface,
 					   g_param_spec_object ("parent",
 								_("Parent"),
@@ -444,9 +462,9 @@
 /**
  * goo_canvas_item_get_canvas:
  * @item: a #GooCanvasItem.
- * 
+ *
  * Returns the #GooCanvas containing the given #GooCanvasItem.
- * 
+ *
  * Returns: the #GooCanvas.
  **/
 GooCanvas*
@@ -473,7 +491,7 @@
  * goo_canvas_item_set_canvas:
  * @item: a #GooCanvasItem.
  * @canvas: a #GooCanvas
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * items, specifically container items such as #GooCanvasGroup.
  *
@@ -496,7 +514,7 @@
  * @child: the item to add.
  * @position: the position of the item, or -1 to place it last (at the top of
  *  the stacking order).
- * 
+ *
  * Adds a child item to a container item at the given stack position.
  **/
 void
@@ -518,7 +536,7 @@
  * @item: a container item.
  * @old_position: the current position of the child item.
  * @new_position: the new position of the child item.
- * 
+ *
  * Moves a child item to a new stack position within the container.
  **/
 void
@@ -538,7 +556,7 @@
  * goo_canvas_item_remove_child:
  * @item: a container item.
  * @child_num: the position of the child item to remove.
- * 
+ *
  * Removes the child item at the given position.
  **/
 void
@@ -557,9 +575,9 @@
  * goo_canvas_item_find_child:
  * @item: a container item.
  * @child: the child item to find.
- * 
+ *
  * Attempts to find the given child item with the container's stack.
- * 
+ *
  * Returns: the position of the given @child item, or -1 if it isn't found.
  **/
 gint
@@ -584,9 +602,9 @@
 /**
  * goo_canvas_item_is_container:
  * @item: an item.
- * 
+ *
  * Tests to see if the given item is a container.
- * 
+ *
  * Returns: %TRUE if the item is a container.
  **/
 gboolean
@@ -601,9 +619,9 @@
 /**
  * goo_canvas_item_get_n_children:
  * @item: a container item.
- * 
+ *
  * Gets the number of children of the container.
- * 
+ *
  * Returns: the number of children.
  **/
 gint
@@ -619,9 +637,9 @@
  * goo_canvas_item_get_child:
  * @item: a container item.
  * @child_num: the position of a child in the container's stack.
- * 
+ *
  * Gets the child item at the given stack position.
- * 
+ *
  * Returns: the child item at the given stack position.
  **/
 GooCanvasItem*
@@ -637,9 +655,9 @@
 /**
  * goo_canvas_item_get_parent:
  * @item: an item.
- * 
+ *
  * Gets the parent of the given item.
- * 
+ *
  * Returns: the parent item, or %NULL if the item has no parent.
  **/
 GooCanvasItem*
@@ -655,7 +673,7 @@
  * goo_canvas_item_set_parent:
  * @item: an item.
  * @parent: the new parent 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 child item.
@@ -677,7 +695,7 @@
 /**
  * goo_canvas_item_remove:
  * @item: an item.
- * 
+ *
  * Removes an item from its parent. If the item is in a canvas it will be
  * removed.
  *
@@ -706,7 +724,7 @@
  * @item: an item.
  * @above: the item to raise @item above, or %NULL to raise @item to the top
  *  of the stack.
- * 
+ *
  * Raises an item in the stacking order.
  **/
 void
@@ -749,7 +767,7 @@
  * @item: an item.
  * @below: the item to lower @item below, or %NULL to lower @item to the
  *  bottom of the stack.
- * 
+ *
  * Lowers an item in the stacking order.
  **/
 void
@@ -791,9 +809,9 @@
  * goo_canvas_item_get_transform:
  * @item: an item.
  * @transform: the place to store the transform.
- * 
+ *
  * Gets the transformation matrix of an item.
- * 
+ *
  * Returns: %TRUE if a transform is set.
  **/
 gboolean
@@ -811,11 +829,11 @@
  * @item: an item.
  * @child: a child of @item.
  * @transform: the place to store the transform.
- * 
+ *
  * Gets the transformation matrix of an item combined with any special
  * transform needed for the given child. These special transforms are used
  * by layout items such as #GooCanvasTable.
- * 
+ *
  * Returns: %TRUE if a transform is set.
  **/
 gboolean
@@ -841,7 +859,7 @@
  * @item: an item.
  * @transform: the new transformation matrix, or %NULL to reset the
  *  transformation to the identity matrix.
- * 
+ *
  * Sets the transformation matrix of an item.
  **/
 void
@@ -859,13 +877,13 @@
  * @y: returns the y coordinate of the origin of the item's coordinate space.
  * @scale: returns the scale of the item.
  * @rotation: returns the clockwise rotation of the item, in degrees (0-360).
- * 
+ *
  * This function can be used to get the position, scale and rotation of an
  * item, providing that the item has a simple transformation matrix
  * (e.g. set with goo_canvas_item_set_simple_transform(), or using a
  * combination of simple translate, scale and rotate operations). If the item
  * has a complex transformation matrix the results will be incorrect.
- * 
+ *
  * Returns: %TRUE if a transform is set.
  **/
 gboolean
@@ -914,7 +932,7 @@
  * @y: the y coordinate of the origin of the item's coordinate space.
  * @scale: the scale of the item.
  * @rotation: the clockwise rotation of the item, in degrees.
- * 
+ *
  * A convenience function to set the item's transformation matrix.
  **/
 void
@@ -939,7 +957,7 @@
  * @item: an item.
  * @tx: the amount to move the origin in the horizontal direction.
  * @ty: the amount to move the origin in the vertical direction.
- * 
+ *
  * Translates the origin of the item's coordinate system by the given amounts.
  **/
 void
@@ -961,7 +979,7 @@
  * @item: an item.
  * @sx: the amount to scale the horizontal axis.
  * @sy: the amount to scale the vertical axis.
- * 
+ *
  * Scales the item's coordinate system by the given amounts.
  **/
 void
@@ -984,7 +1002,7 @@
  * @degrees: the clockwise angle of rotation.
  * @cx: the x coordinate of the origin of the rotation.
  * @cy: the y coordinate of the origin of the rotation.
- * 
+ *
  * Rotates the item's coordinate system by the given amount, about the given
  * origin.
  **/
@@ -1012,7 +1030,7 @@
  * @degrees: the skew angle.
  * @cx: the x coordinate of the origin of the skew transform.
  * @cy: the y coordinate of the origin of the skew transform.
- * 
+ *
  * Skews the item's coordinate system along the x axis by the given amount,
  * about the given origin.
  **/
@@ -1041,7 +1059,7 @@
  * @degrees: the skew angle.
  * @cx: the x coordinate of the origin of the skew transform.
  * @cy: the y coordinate of the origin of the skew transform.
- * 
+ *
  * Skews the item's coordinate system along the y axis by the given amount,
  * about the given origin.
  **/
@@ -1067,10 +1085,10 @@
 /**
  * goo_canvas_item_get_style:
  * @item: an item.
- * 
+ *
  * Gets the item's style. If the item doesn't have its own style it will return
  * its parent's style.
- * 
+ *
  * Returns: the item's style.
  **/
 GooCanvasStyle*
@@ -1086,7 +1104,7 @@
  * goo_canvas_item_set_style:
  * @item: an item.
  * @style: a style.
- * 
+ *
  * Sets the item's style, by copying the properties from the given style.
  **/
 void
@@ -1167,9 +1185,15 @@
 	  /* This will result in a call to goo_canvas_item_free_animation()
 	     above. We've set the timeout_id to 0 so it isn't removed twice. */
 	  if (model)
-	    g_object_set_data (G_OBJECT (model), animation_key, NULL);
+	    {
+	      g_signal_emit_by_name (model, "animation-finished", FALSE);
+	      g_object_set_data (G_OBJECT (model), animation_key, NULL);
+	    }
 	  else
-	    g_object_set_data (G_OBJECT (item), animation_key, NULL);
+	    {
+	      g_signal_emit_by_name (item, "animation-finished", FALSE);
+	      g_object_set_data (G_OBJECT (item), animation_key, NULL);
+	    }
 	  break;
 
 	case GOO_CANVAS_ANIMATE_RESTART:
@@ -1318,7 +1342,7 @@
  *  second).
  * @step_time: the time between each animation step, in milliseconds.
  * @type: specifies what happens when the animation finishes.
- * 
+ *
  * Animates an item from its current position to the given offsets, scale
  * and rotation.
  **/
@@ -1341,13 +1365,15 @@
 /**
  * goo_canvas_item_stop_animation:
  * @item: an item.
- * 
+ *
  * Stops any current animation for the given item, leaving it at its current
  * position.
  **/
 void
 goo_canvas_item_stop_animation (GooCanvasItem *item)
 {
+  g_signal_emit_by_name (item, "animation-finished", TRUE);
+
   /* This will result in a call to goo_canvas_item_free_animation() above. */
   g_object_set_data (G_OBJECT (item), animation_key, NULL);
 }
@@ -1358,7 +1384,7 @@
 /**
  * goo_canvas_item_request_update:
  * @item: a #GooCanvasItem.
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * items.
  *
@@ -1381,7 +1407,7 @@
  * goo_canvas_item_get_bounds:
  * @item: a #GooCanvasItem.
  * @bounds: a #GooCanvasBounds to return the bounds in.
- * 
+ *
  * Gets the bounds of the item.
  *
  * Note that the bounds includes the entire fill and stroke extents of the
@@ -1408,12 +1434,12 @@
  * @parent_is_visible: %TRUE if the parent item is visible (which
  *  implies that all ancestors are also visible).
  * @found_items: the list of items found so far.
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * items, specifically container items such as #GooCanvasGroup.
  *
  * It gets the items at the given point.
- * 
+ *
  * Returns: the @found_items list, with any more found items added onto
  *  the start of the list, leaving the top item first.
  **/
@@ -1439,7 +1465,7 @@
 /**
  * goo_canvas_item_is_visible:
  * @item: a #GooCanvasItem.
- * 
+ *
  * Checks if the item is visible.
  *
  * This entails checking the item's own visibility setting, as well as those
@@ -1447,7 +1473,7 @@
  *
  * Note that the item may be scrolled off the screen and so may not
  * be actually visible to the user.
- * 
+ *
  * Returns: %TRUE if the item is visible.
  **/
 gboolean
@@ -1472,9 +1498,9 @@
 /**
  * goo_canvas_item_get_model:
  * @item: a #GooCanvasItem.
- * 
+ *
  * Gets the model of the given canvas item.
- * 
+ *
  * Returns: the item's model, or %NULL if it has no model.
  **/
 GooCanvasItemModel*
@@ -1490,7 +1516,7 @@
  * goo_canvas_item_set_model:
  * @item: a #GooCanvasItem.
  * @model: a #GooCanvasItemModel.
- * 
+ *
  * Sets the model of the given canvas item.
  **/
 void
@@ -1507,7 +1533,7 @@
 /**
  * goo_canvas_item_ensure_updated:
  * @item: a #GooCanvasItem.
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * items.
  *
@@ -1531,7 +1557,7 @@
  * @entire_tree: if the entire subtree should be updated.
  * @cr: a cairo context.
  * @bounds: a #GooCanvasBounds to return the new bounds in.
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * items, specifically container items such as #GooCanvasGroup.
  *
@@ -1556,7 +1582,7 @@
  * @bounds: the bounds that need to be repainted.
  * @scale: the scale to use to determine whether an item should be painted.
  *  See #GooCanvasItem:visibility-threshold.
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * items, specifically container items such as #GooCanvasGroup.
  *
@@ -1583,12 +1609,12 @@
  * @cr: a cairo context.
  * @requested_area: a #GooCanvasBounds to return the requested area in, in the
  *  parent's coordinate space.
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * items, specifically layout items such as #GooCanvasTable.
  *
  * It gets the requested area of a child item.
- * 
+ *
  * Returns: %TRUE if the item should be allocated space.
  **/
 gboolean
@@ -1607,14 +1633,14 @@
  * @item: a #GooCanvasItem.
  * @cr: a cairo context.
  * @width: the width that the item may be allocated.
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * items, specifically layout items such as #GooCanvasTable.
  *
  * It gets the requested height of a child item, assuming it is allocated the
  * given width. This is useful for text items whose requested height may change
  * depending on the allocated width.
- * 
+ *
  * Returns: the requested height of the item, given the allocated width,
  *  or %-1 if the item doesn't support this method or its height doesn't
  *  change when allocated different widths.
@@ -1645,7 +1671,7 @@
  *  the device coordinate space.
  * @y_offset: the y offset of the allocated area from the requested area in
  *  the device coordinate space.
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * items, specifically layout items such as #GooCanvasTable.
  *
@@ -1988,7 +2014,7 @@
  * @child: a child #GooCanvasItem.
  * @property_name: the name of the child property to get.
  * @value: a location to return the value.
- * 
+ *
  * Gets a child property of @child.
  **/
 void
@@ -2012,7 +2038,7 @@
  * @child: a child #GooCanvasItem.
  * @property_name: the name of the child property to set.
  * @value: the value to set the property to.
- * 
+ *
  * Sets a child property of @child.
  **/
 void
@@ -2036,7 +2062,7 @@
  * @child: a child #GooCanvasItem.
  * @var_args: pairs of property names and value pointers, and a terminating
  *  %NULL.
- * 
+ *
  * Gets the values of one or more child properties of @child.
  **/
 void
@@ -2056,7 +2082,7 @@
  * @item: a #GooCanvasItem.
  * @child: a child #GooCanvasItem.
  * @var_args: pairs of property names and values, and a terminating %NULL.
- * 
+ *
  * Sets the values of one or more child properties of @child.
  **/
 void
@@ -2076,7 +2102,7 @@
  * @item: a #GooCanvasItem.
  * @child: a child #GooCanvasItem.
  * @...: pairs of property names and value pointers, and a terminating %NULL.
- * 
+ *
  * Gets the values of one or more child properties of @child.
  **/
 void
@@ -2085,7 +2111,7 @@
 					     ...)
 {
   va_list var_args;
-  
+
   va_start (var_args, child);
   goo_canvas_item_get_child_properties_valist (item, child, var_args);
   va_end (var_args);
@@ -2097,7 +2123,7 @@
  * @item: a #GooCanvasItem.
  * @child: a child #GooCanvasItem.
  * @...: pairs of property names and values, and a terminating %NULL.
- * 
+ *
  * Sets the values of one or more child properties of @child.
  **/
 void
@@ -2106,7 +2132,7 @@
 					     ...)
 {
   va_list var_args;
-  
+
   va_start (var_args, child);
   goo_canvas_item_set_child_properties_valist (item, child, var_args);
   va_end (var_args);
@@ -2119,11 +2145,11 @@
  * @iclass: a #GObjectClass
  * @property_id: the id for the property
  * @pspec: the #GParamSpec for the property
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * items, specifically layout container items such as #GooCanvasTable.
  *
- * It installs a child property on a canvas item class. 
+ * It installs a child property on a canvas item class.
  **/
 void
 goo_canvas_item_class_install_child_property (GObjectClass *iclass,
@@ -2177,7 +2203,7 @@
  * goo_canvas_item_class_list_child_properties:
  * @iclass: a #GObjectClass
  * @n_properties: location to return the number of child properties found
- * @returns: a newly allocated array of #GParamSpec*. The array must be 
+ * @returns: a newly allocated array of #GParamSpec*. The array must be
  *           freed with g_free().
  *
  * This function is only intended to be used when implementing new canvas

Modified: branches/gcomprixogoo/src/goocanvas/src/goocanvasitem.h
==============================================================================
--- branches/gcomprixogoo/src/goocanvas/src/goocanvasitem.h	(original)
+++ branches/gcomprixogoo/src/goocanvas/src/goocanvasitem.h	Wed Nov 19 01:00:13 2008
@@ -126,6 +126,7 @@
  * @key_release_event: signal emitted when a key is released.
  * @grab_broken_event: signal emitted when a grab that the item has is lost.
  * @child_notify: signal emitted when a child property is changed.
+ * @animation_finished: signal emitted when the item's animation has finished.
  *
  * #GooCanvasItemIFace holds the virtual methods that make up the
  * #GooCanvasItem interface.
@@ -280,6 +281,8 @@
 							 gboolean		 keyboard_tooltip,
 							 gpointer /*GtkTooltip*/		*tooltip);
 
+  void			(* animation_finished)		(GooCanvasItem           *item,
+							 gboolean                 stopped);
 
   /* Padding for future expansion */
   void (*_goo_canvas_reserved1) (void);

Modified: branches/gcomprixogoo/src/goocanvas/src/goocanvasitemmodel.c
==============================================================================
--- branches/gcomprixogoo/src/goocanvas/src/goocanvasitemmodel.c	(original)
+++ branches/gcomprixogoo/src/goocanvas/src/goocanvasitemmodel.c	Wed Nov 19 01:00:13 2008
@@ -37,6 +37,7 @@
   CHANGED,
 
   CHILD_NOTIFY,
+  ANIMATION_FINISHED,
 
   LAST_SIGNAL
 };
@@ -97,7 +98,7 @@
 {
   static GObjectNotifyContext cpn_context = { 0, NULL, NULL };
   static gboolean initialized = FALSE;
-  
+
   if (!initialized)
     {
       GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
@@ -183,7 +184,7 @@
        * @pspec: the #GParamSpec of the changed child property.
        *
        * Emitted for each child property that has changed.
-       * The signal's detail holds the property name. 
+       * The signal's detail holds the property name.
        */
       item_model_signals[CHILD_NOTIFY] =
 	g_signal_new ("child_notify",
@@ -195,6 +196,22 @@
 		      G_TYPE_NONE, 1,
 		      G_TYPE_PARAM);
 
+      /**
+       * GooCanvasItemModel::animation-finished
+       * @item: the item model that received the signal.
+       * @stopped: if the animation was explicitly stopped.
+       *
+       * Emitted when the item model animation has finished.
+       */
+      item_model_signals[ANIMATION_FINISHED] =
+	g_signal_new ("animation-finished",
+		      iface_type,
+		      G_SIGNAL_RUN_LAST,
+		      G_STRUCT_OFFSET (GooCanvasItemModelIface, animation_finished),
+		      NULL, NULL,
+		      g_cclosure_marshal_VOID__BOOLEAN,
+		      G_TYPE_NONE, 1,
+		      G_TYPE_BOOLEAN);
 
       g_object_interface_install_property (g_iface,
 					   g_param_spec_object ("parent",
@@ -269,7 +286,7 @@
  * @child: the child to add.
  * @position: the position of the child, or -1 to place it last (at the top of
  *  the stacking order).
- * 
+ *
  * Adds a child at the given stack position.
  **/
 void
@@ -291,7 +308,7 @@
  * @model: an item model.
  * @old_position: the current position of the child.
  * @new_position: the new position of the child.
- * 
+ *
  * Moves a child to a new stack position.
  **/
 void
@@ -311,7 +328,7 @@
  * goo_canvas_item_model_remove_child:
  * @model: an item model.
  * @child_num: the position of the child to remove.
- * 
+ *
  * Removes the child at the given position.
  **/
 void
@@ -330,9 +347,9 @@
  * goo_canvas_item_model_find_child:
  * @model: an item model.
  * @child: the child to find.
- * 
+ *
  * Attempts to find the given child with the container's stack.
- * 
+ *
  * Returns: the position of the given @child, or -1 if it isn't found.
  **/
 gint
@@ -357,9 +374,9 @@
 /**
  * goo_canvas_item_model_is_container:
  * @model: an item model.
- * 
+ *
  * Tests to see if the given item model is a container.
- * 
+ *
  * Returns: %TRUE if the item model is a container.
  **/
 gboolean
@@ -374,9 +391,9 @@
 /**
  * goo_canvas_item_model_get_n_children:
  * @model: an item model.
- * 
+ *
  * Gets the number of children of the container.
- * 
+ *
  * Returns: the number of children.
  **/
 gint
@@ -392,9 +409,9 @@
  * goo_canvas_item_model_get_child:
  * @model: an item model.
  * @child_num: the position of a child in the container's stack.
- * 
+ *
  * Gets the child at the given stack position.
- * 
+ *
  * Returns: the child at the given stack position.
  **/
 GooCanvasItemModel*
@@ -410,9 +427,9 @@
 /**
  * goo_canvas_item_model_get_parent:
  * @model: an item model.
- * 
+ *
  * Gets the parent of the given model.
- * 
+ *
  * Returns: the parent model, or %NULL if the model has no parent.
  **/
 GooCanvasItemModel*
@@ -426,7 +443,7 @@
  * goo_canvas_item_model_set_parent:
  * @model: an item model.
  * @parent: the new parent item 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.
@@ -448,7 +465,7 @@
 /**
  * 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.
  *
@@ -477,7 +494,7 @@
  * @model: an item model.
  * @above: the item model to raise @model above, or %NULL to raise @model to the top
  *  of the stack.
- * 
+ *
  * Raises a model in the stacking order.
  **/
 void
@@ -520,7 +537,7 @@
  * @model: an item model.
  * @below: the item model to lower @model below, or %NULL to lower @model to the
  *  bottom of the stack.
- * 
+ *
  * Lowers a model in the stacking order.
  **/
 void
@@ -562,9 +579,9 @@
  * goo_canvas_item_model_get_transform:
  * @model: an item model.
  * @transform: the place to store the transform.
- * 
+ *
  * Gets the transformation matrix of an item model.
- * 
+ *
  * Returns: %TRUE if a transform is set.
  **/
 gboolean
@@ -582,7 +599,7 @@
  * @model: an item model.
  * @transform: the new transformation matrix, or %NULL to reset the
  *  transformation to the identity matrix.
- * 
+ *
  * Sets the transformation matrix of an item model.
  **/
 void
@@ -600,13 +617,13 @@
  * @y: returns the y coordinate of the origin of the model's coordinate space.
  * @scale: returns the scale of the model.
  * @rotation: returns the clockwise rotation of the model, in degrees (0-360).
- * 
+ *
  * This function can be used to get the position, scale and rotation of an
  * item model, providing that the model has a simple transformation matrix
  * (e.g. set with goo_canvas_item_model_set_simple_transform(), or using a
  * combination of simple translate, scale and rotate operations). If the model
  * has a complex transformation matrix the results will be incorrect.
- * 
+ *
  * Returns: %TRUE if a transform is set.
  **/
 gboolean
@@ -655,7 +672,7 @@
  * @y: the y coordinate of the origin of the model's coordinate space.
  * @scale: the scale of the model.
  * @rotation: the clockwise rotation of the model, in degrees.
- * 
+ *
  * A convenience function to set the item model's transformation matrix.
  **/
 void
@@ -680,7 +697,7 @@
  * @model: an item model.
  * @tx: the amount to move the origin in the horizontal direction.
  * @ty: the amount to move the origin in the vertical direction.
- * 
+ *
  * Translates the origin of the model's coordinate system by the given amounts.
  **/
 void
@@ -702,7 +719,7 @@
  * @model: an item model.
  * @sx: the amount to scale the horizontal axis.
  * @sy: the amount to scale the vertical axis.
- * 
+ *
  * Scales the model's coordinate system by the given amounts.
  **/
 void
@@ -725,7 +742,7 @@
  * @degrees: the clockwise angle of rotation.
  * @cx: the x coordinate of the origin of the rotation.
  * @cy: the y coordinate of the origin of the rotation.
- * 
+ *
  * Rotates the model's coordinate system by the given amount, about the given
  * origin.
  **/
@@ -753,7 +770,7 @@
  * @degrees: the skew angle.
  * @cx: the x coordinate of the origin of the skew transform.
  * @cy: the y coordinate of the origin of the skew transform.
- * 
+ *
  * Skews the model's coordinate system along the x axis by the given amount,
  * about the given origin.
  **/
@@ -782,7 +799,7 @@
  * @degrees: the skew angle.
  * @cx: the x coordinate of the origin of the skew transform.
  * @cy: the y coordinate of the origin of the skew transform.
- * 
+ *
  * Skews the model's coordinate system along the y axis by the given amount,
  * about the given origin.
  **/
@@ -808,10 +825,10 @@
 /**
  * goo_canvas_item_model_get_style:
  * @model: an item model.
- * 
+ *
  * Gets the model's style. If the model doesn't have its own style it will
  * return its parent's style.
- * 
+ *
  * Returns: the model's style.
  **/
 GooCanvasStyle*
@@ -827,7 +844,7 @@
  * goo_canvas_item_model_set_style:
  * @model: an item model.
  * @style: a style.
- * 
+ *
  * Sets the model's style, by copying the properties from the given style.
  **/
 void
@@ -868,7 +885,7 @@
  *  second).
  * @step_time: the time between each animation step, in milliseconds.
  * @type: specifies what happens when the animation finishes.
- * 
+ *
  * Animates a model from its current position to the given offsets, scale
  * and rotation.
  **/
@@ -891,13 +908,15 @@
 /**
  * goo_canvas_item_model_stop_animation:
  * @model: an item model.
- * 
+ *
  * Stops any current animation for the given model, leaving it at its current
  * position.
  **/
 void
 goo_canvas_item_model_stop_animation (GooCanvasItemModel *model)
 {
+  g_signal_emit_by_name (model, "animation-finished", TRUE);
+
   /* This will result in a call to goo_canvas_item_free_animation() above. */
   g_object_set_data (G_OBJECT (model), animation_key, NULL);
 }
@@ -920,7 +939,7 @@
  * @child: a child #GooCanvasItemModel.
  * @property_name: the name of the child property to get.
  * @value: a location to return the value.
- * 
+ *
  * Gets a child property of @child.
  **/
 void
@@ -944,7 +963,7 @@
  * @child: a child #GooCanvasItemModel.
  * @property_name: the name of the child property to set.
  * @value: the value to set the property to.
- * 
+ *
  * Sets a child property of @child.
  **/
 void
@@ -968,7 +987,7 @@
  * @child: a child #GooCanvasItemModel.
  * @var_args: pairs of property names and value pointers, and a terminating
  *  %NULL.
- * 
+ *
  * Gets the values of one or more child properties of @child.
  **/
 void
@@ -988,7 +1007,7 @@
  * @model: a #GooCanvasItemModel.
  * @child: a child #GooCanvasItemModel.
  * @var_args: pairs of property names and values, and a terminating %NULL.
- * 
+ *
  * Sets the values of one or more child properties of @child.
  **/
 void
@@ -1008,7 +1027,7 @@
  * @model: a #GooCanvasItemModel.
  * @child: a child #GooCanvasItemModel.
  * @...: pairs of property names and value pointers, and a terminating %NULL.
- * 
+ *
  * Gets the values of one or more child properties of @child.
  **/
 void
@@ -1017,7 +1036,7 @@
 					     ...)
 {
   va_list var_args;
-  
+
   va_start (var_args, child);
   goo_canvas_item_model_get_child_properties_valist (model, child, var_args);
   va_end (var_args);
@@ -1029,7 +1048,7 @@
  * @model: a #GooCanvasItemModel.
  * @child: a child #GooCanvasItemModel.
  * @...: pairs of property names and values, and a terminating %NULL.
- * 
+ *
  * Sets the values of one or more child properties of @child.
  **/
 void
@@ -1038,7 +1057,7 @@
 					     ...)
 {
   va_list var_args;
-  
+
   va_start (var_args, child);
   goo_canvas_item_model_set_child_properties_valist (model, child, var_args);
   va_end (var_args);
@@ -1051,12 +1070,12 @@
  * @mclass: a #GObjectClass
  * @property_id: the id for the property
  * @pspec: the #GParamSpec for the property
- * 
+ *
  * This function is only intended to be used when implementing new canvas
  * item models, specifically layout container item models such as
  * #GooCanvasTableModel.
  *
- * It installs a child property on a canvas item class. 
+ * It installs a child property on a canvas item class.
  **/
 void
 goo_canvas_item_model_class_install_child_property (GObjectClass *mclass,
@@ -1111,7 +1130,7 @@
  * goo_canvas_item_model_class_list_child_properties:
  * @mclass: a #GObjectClass
  * @n_properties: location to return the number of child properties found
- * @returns: a newly allocated array of #GParamSpec*. The array must be 
+ * @returns: a newly allocated array of #GParamSpec*. The array must be
  *           freed with g_free().
  *
  * This function is only intended to be used when implementing new canvas

Modified: branches/gcomprixogoo/src/goocanvas/src/goocanvasitemmodel.h
==============================================================================
--- branches/gcomprixogoo/src/goocanvas/src/goocanvasitemmodel.h	(original)
+++ branches/gcomprixogoo/src/goocanvas/src/goocanvasitemmodel.h	Wed Nov 19 01:00:13 2008
@@ -55,6 +55,7 @@
  * @child_removed: signal emitted when a child is removed.
  * @changed: signal emitted when the model has changed.
  * @child_notify: signal emitted when a child property has changed.
+ * @animation_finished: signal emitted when the model's animation has finished.
  *
  * #GooCanvasItemModelIFace holds the virtual methods that make up the
  * #GooCanvasItemModel interface.
@@ -135,6 +136,9 @@
   void                 (* child_notify)			(GooCanvasItemModel	*model,
 							 GParamSpec		*pspec);
 
+  void		       (* animation_finished)		(GooCanvasItemModel     *model,
+							 gboolean                stopped);
+
   /*< private >*/
 
   /* Padding for future expansion */

Modified: branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.c
==============================================================================
--- branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.c	(original)
+++ branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.c	Wed Nov 19 01:00:13 2008
@@ -13,7 +13,6 @@
   /* Convenience properties. */
   PROP_SVGHANDLE,
   PROP_SVG_ID,
-  PROP_HIT_DETECTION
 };
 
 static void goo_canvas_svg_finalize     (GObject            *object);
@@ -45,13 +44,6 @@
 							NULL,
 							G_PARAM_WRITABLE));
 
-  g_object_class_install_property (gobject_class, PROP_HIT_DETECTION,
-				   g_param_spec_boolean ("hit-detection",
-                                                         "Hit detection",
-                                                         "Set to false to disable hit detection",
-                                                         TRUE,
-                                                         G_PARAM_WRITABLE));
-
 }
 
 static void _init_surface(GooCanvasSvg *canvas_svg,
@@ -118,7 +110,6 @@
   canvas_svg->id = NULL;
   canvas_svg->cr = NULL;
   canvas_svg->pattern = NULL;
-  canvas_svg->hit_detection = TRUE;
 }
 
 
@@ -235,9 +226,6 @@
       else
         canvas_svg->id = g_value_dup_string(value);
       break;
-    case PROP_HIT_DETECTION:
-      canvas_svg->hit_detection = g_value_get_boolean (value);
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -279,9 +267,6 @@
 {
   GooCanvasSvg *canvas_svg = (GooCanvasSvg*) simple;
 
-  if (!canvas_svg->hit_detection)
-    return FALSE;
-
   if ( x < canvas_svg->x1 || x > canvas_svg->x2
        || y < canvas_svg->y1 || y > canvas_svg->y2 )
     return FALSE;

Modified: branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.h
==============================================================================
--- branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.h	(original)
+++ branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.h	Wed Nov 19 01:00:13 2008
@@ -38,7 +38,6 @@
   double y1;
   double x2;
   double y2;
-  gboolean hit_detection;
 };
 
 struct _GooCanvasSvgClass

Modified: branches/gcomprixogoo/src/watercycle-activity/watercycle.py
==============================================================================
--- branches/gcomprixogoo/src/watercycle-activity/watercycle.py	(original)
+++ branches/gcomprixogoo/src/watercycle-activity/watercycle.py	Wed Nov 19 01:00:13 2008
@@ -43,8 +43,6 @@
     self.timerinc = 50
 
     # Need to manage the timers to quit properly
-    self.boat_timer = 0
-    self.sun_timer = 0
     self.vapor_timer = 0
     self.cloud_timer = 0
     self.waterlevel_timer = 0
@@ -64,7 +62,7 @@
       parent = self.rootitem,
       svg_handle = svghandle,
       svg_id = "#BACKGROUND",
-      hit_detection = False
+      pointer_events = goocanvas.EVENTS_NONE
       )
 
     # Take care, the items are stacked on each other in the order you add them.
@@ -107,6 +105,9 @@
     gcompris.utils.item_focus_init(self.sunitem, None)
     self.sun_direction = -1
     self.sun_on = 0
+    self.sunitem_orig_y1 = self.sunitem.get_bounds().y1
+    self.sunitem_target_y1 = 10
+    self.sun_connect_handler = 0
 
     # The Snow
     self.snowitem = goocanvas.Svg(
@@ -177,37 +178,39 @@
     self.boatitem_parked = goocanvas.Svg(
       parent = self.rootitem,
       svg_handle = svghandle,
-      svg_id = "#BOAT_PARKED"
+      svg_id = "#BOAT_PARKED",
+      visibility = goocanvas.ITEM_INVISIBLE
       )
-    self.boatitem_parked.props.visibility = goocanvas.ITEM_INVISIBLE
 
     # Tux in the shower (without water)
     self.tuxshoweritem = goocanvas.Svg(
       parent = self.rootitem,
       svg_handle = svghandle,
-      svg_id = "#SHOWER"
+      svg_id = "#SHOWER",
+      visibility = goocanvas.ITEM_INVISIBLE
       )
-    self.tuxshoweritem.props.visibility = goocanvas.ITEM_INVISIBLE
+
     self.shower_tux = goocanvas.Svg(
       parent = self.rootitem,
       svg_handle = svghandle,
-      svg_id = "#SHOWER_TUX"
+      svg_id = "#SHOWER_TUX",
+      visibility = goocanvas.ITEM_INVISIBLE
       )
-    self.shower_tux.props.visibility = goocanvas.ITEM_INVISIBLE
 
     # Tux in the shower with the water
     self.tuxshowerwateritem = goocanvas.Svg(
       parent = self.rootitem,
       svg_handle = svghandle,
-      svg_id = "#SHOWER_ON"
+      svg_id = "#SHOWER_ON",
+      visibility = goocanvas.ITEM_INVISIBLE
       )
-    self.tuxshowerwateritem.props.visibility = goocanvas.ITEM_INVISIBLE
 
     # The shower on/off button (I need to get the 2 buttons to manage the focus)
     self.showerbuttonitem_on = goocanvas.Svg(
       parent = self.rootitem,
       svg_handle = svghandle,
-      svg_id = "#SHOWER_BUTTON_ON"
+      svg_id = "#SHOWER_BUTTON_ON",
+      visibility = goocanvas.ITEM_INVISIBLE
       )
 
     self.showerbuttonitem_on.connect("button_press_event", self.showerbutton_item_event)
@@ -219,7 +222,8 @@
     self.showerbuttonitem_off = goocanvas.Svg(
       parent = self.rootitem,
       svg_handle = svghandle,
-      svg_id = "#SHOWER_BUTTON_OFF"
+      svg_id = "#SHOWER_BUTTON_OFF",
+      visibility = goocanvas.ITEM_INVISIBLE
       )
     self.showerbuttonitem_off.connect("button_press_event", self.showerbutton_item_event)
     # This item is clickeable and it must be seen
@@ -244,7 +248,7 @@
       parent = self.rootitem,
       svg_handle = svghandle,
       svg_id = "#FOREGROUND",
-      hit_detection = False
+      pointer_events = goocanvas.EVENTS_NONE
       )
 
     # Some item ordering
@@ -254,8 +258,7 @@
     # Ready GO
     target_x = 700
     trip_x = int(target_x - self.boatitem.get_bounds().x1)
-    print self.boatitem.get_bounds().x1
-    print trip_x
+    self.boatitem.connect("animation-finished", self.boat_arrived)
     self.boatitem.animate(target_x,
                           0,
                           1,
@@ -264,15 +267,10 @@
                           40*trip_x,
                           40,
                           goocanvas.ANIMATE_FREEZE)
-    self.boat_timer = gobject.timeout_add(40 * trip_x + 4000, self.boat_arrived)
 
 
   def end(self):
     # Remove all the timer first
-    if self.boat_timer :
-      gobject.source_remove(self.boat_timer)
-    if self.sun_timer :
-      gobject.source_remove(self.sun_timer)
     if self.vapor_timer :
       gobject.source_remove(self.vapor_timer)
     if self.cloud_timer :
@@ -339,16 +337,56 @@
     self.cleanwaterstatus = status
 
 
-  def boat_arrived(self):
-    # We are parked, change the boat to remove tux
+  def boat_arrived(self, item, status):
+    # park the boat, change the boat to remove tux
     self.boatitem_parked.props.visibility = goocanvas.ITEM_VISIBLE
-#    self.boatitem.props.visibility = goocanvas.ITEM_INVISIBLE
+    self.boatitem.props.visibility = goocanvas.ITEM_INVISIBLE
     gcompris.sound.play_ogg("sounds/Harbor3.wav")
 
     # Now display tux in the shower
     self.tuxshoweritem.props.visibility = goocanvas.ITEM_VISIBLE
     self.shower_tux.props.visibility = goocanvas.ITEM_VISIBLE
 
+  def sun_down(self):
+    # Move the sun down
+    print "sun_down"
+    trip_y = self.sunitem_orig_y1 - self.sunitem_target_y1
+    print trip_y
+    if self.sun_connect_handler:
+      self.sunitem.disconnect(self.sun_connect_handler)
+    self.sun_connect_handler = self.sunitem.connect("animation-finished", self.sun_down_arrived)
+    self.sunitem.animate(0,
+                         0,
+                         1,
+                         1,
+                         True,
+                         int(40*abs(trip_y)),
+                         40,
+                         goocanvas.ANIMATE_FREEZE)
+    return False
+
+  def sun_up_arrived(self, item, status):
+    print "sun_up_arrived"
+    gobject.timeout_add(10, self.sun_down)
+    # Start the vapor
+    self.vapor_timer = gobject.timeout_add(5000 , self.init_vapor)
+    self.vapor_on = 1
+        # Start the cloud
+    if(not self.cloud_on):
+      self.cloud_timer = gobject.timeout_add(10000, self.move_cloud)
+      self.cloud_on = 1
+    # Remove the snow
+    self.snowitem.props.visibility = goocanvas.ITEM_INVISIBLE
+
+  def sun_down_arrived(self, item, status):
+    print "sun_down_arrived"
+    self.sun_on = 0
+    gcompris.utils.item_focus_init(self.sunitem, None)
+    # Stop the vapor
+    self.vapor_on = 0
+    self.vaporitem.props.visibility = goocanvas.ITEM_INVISIBLE
+    # Stop the sun
+    self.sun_on = 0
 
   def move_cloud(self):
     if(self.cloud_on):
@@ -394,36 +432,6 @@
 
     self.vapor_timer = gobject.timeout_add(self.timerinc, self.move_vapor)
 
-  def move_sun(self):
-    gcompris.utils.item_focus_init(self.sunitem, None)
-    self.sunitem.translate(0, self.sun_direction);
-    if( (self.sunitem.get_bounds().y1 > 0 and
-         self.sunitem.get_bounds().y1 < 70 ) ) :
-      self.sun_timer = gobject.timeout_add(self.timerinc, self.move_sun)
-    else :
-      # The sun is at is top
-      if(self.sun_direction < 0) :
-        # Stop the sun
-        self.sun_timer = gobject.timeout_add(15000, self.move_sun)
-        # Start the vapor
-        self.vapor_timer = gobject.timeout_add(5000 , self.init_vapor)
-        self.vapor_on = 1
-        # Start the cloud
-        if(not self.cloud_on):
-          self.cloud_timer = gobject.timeout_add(10000, self.move_cloud)
-          self.cloud_on = 1
-        # Remove the snow
-        self.snowitem.props.visibility = goocanvas.ITEM_INVISIBLE
-
-      else :
-        # Stop the vapor
-        self.vapor_on = 0
-        self.vaporitem.props.visibility = goocanvas.ITEM_INVISIBLE
-        # Stop the sun
-        self.sun_on = 0
-
-      self.sun_direction = self.sun_direction * -1
-
   def pause(self, pause):
     pass
 
@@ -434,8 +442,21 @@
     if event.type == gtk.gdk.BUTTON_PRESS:
       if event.button == 1:
         if not self.sun_on :
+          gcompris.utils.item_focus_remove(self.sunitem, None)
           gcompris.sound.play_ogg("sounds/bleep.wav")
-          self.sun_timer = gobject.timeout_add(self.timerinc, self.move_sun)
+          trip_y = self.sunitem_target_y1 - self.sunitem_orig_y1
+          if self.sun_connect_handler:
+            self.sunitem.disconnect(self.sun_connect_handler)
+          self.sun_connect_handler = self.sunitem.connect("animation-finished", self.sun_up_arrived)
+          self.sunitem.animate(0,
+                               trip_y,
+                               1,
+                               1,
+                               True,
+                               int(40*abs(trip_y)),
+                               40,
+                               goocanvas.ANIMATE_FREEZE)
+
           self.sun_on = 1
         return True
     return False



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]