コード例 #1
0
ファイル: canal_lock.c プロジェクト: afenkart/gcompris-devel
/* ==================================== */
static gboolean
animate_step()
{

  if(!gcomprisBoard)
    return FALSE;

  GooCanvasBounds bounds;
  goo_canvas_item_get_bounds(timer_item, &bounds);

  if(GOO_IS_CANVAS_SVG(timer_item))
    goo_canvas_item_translate(timer_item, timer_step_x1, timer_step_y1);
  else if(GOO_IS_CANVAS_RECT(timer_item))
    g_object_set(timer_item,
		 "x", bounds.x1 + timer_step_x1,
		 "y", bounds.y1 + timer_step_y1,
		 "height", bounds.y2 - bounds.y1 - timer_step_y1,
		 NULL);

  /* Special case for raising/lowering the boat */
  if(boat_position==BOAT_POS_MIDDLE && timer_item==canal_middle_item)
    {
      goo_canvas_item_translate(tuxboat_item, 0, timer_step_y1);
      gc_item_focus_remove(tuxboat_item, NULL);
    }

  if((bounds.y1 >= timer_item_limit_y && timer_step_y1 > 0) ||
     (bounds.y1 <= timer_item_limit_y && timer_step_y1 < 0))
    {
      gtk_timeout_remove (timer_id);
      timer_id = 0;
      animation = FALSE;
      update_water();
      gc_item_focus_init(tuxboat_item, NULL);
      g_object_set (tuxboat_item,
		    "svg-id", "#BOAT_NO_SAIL", NULL);
    }
  else if((bounds.x1 >= timer_item_limit_x && timer_step_x1 > 0) ||
     (bounds.x1 <= timer_item_limit_x && timer_step_x1 < 0))
    {
      gtk_timeout_remove (timer_id);
      timer_id = 0;
      animation = FALSE;
      update_water();
      if (gamewon)
        {
          gc_bonus_display(TRUE, GC_BONUS_FLOWER);
          gamewon = FALSE;
        }
      gc_item_focus_init(tuxboat_item, NULL);
      g_object_set (tuxboat_item,
		    "svg-id", "#BOAT_NO_SAIL", NULL);
    }

  return TRUE;
}
コード例 #2
0
static void
on_item_created (GooCanvas          *canvas,
		 GooCanvasItem      *item,
		 GooCanvasItemModel *model,
		 gpointer            data)
{
  if (GOO_IS_CANVAS_RECT (model))
    {
      g_signal_connect (item, "enter_notify_event",
			G_CALLBACK (on_enter_notify), NULL);
      g_signal_connect (item, "leave_notify_event",
			G_CALLBACK (on_leave_notify), NULL);
      g_signal_connect (item, "motion_notify_event",
			G_CALLBACK (on_motion_notify), NULL);
      g_signal_connect (item, "button_press_event",
			G_CALLBACK (on_button_press), NULL);
      g_signal_connect (item, "button_release_event",
			G_CALLBACK (on_button_release), NULL);
    }
}