gcompris r3250 - in branches/gcomprixogoo: . src/babymatch-activity



Author: bcoudoin
Date: Fri Feb 15 21:55:38 2008
New Revision: 3250
URL: http://svn.gnome.org/viewvc/gcompris?rev=3250&view=rev

Log:
Added a continue button to let children enjoy the paintings
or the work they just accomplished


Modified:
   branches/gcomprixogoo/ChangeLog
   branches/gcomprixogoo/src/babymatch-activity/shapegame.c

Modified: branches/gcomprixogoo/src/babymatch-activity/shapegame.c
==============================================================================
--- branches/gcomprixogoo/src/babymatch-activity/shapegame.c	(original)
+++ branches/gcomprixogoo/src/babymatch-activity/shapegame.c	Fri Feb 15 21:55:38 2008
@@ -114,9 +114,13 @@
 /* The tooltip */
 static GooCanvasItem	*tooltip_root_item;
 static GooCanvasItem	*tooltip_text_item;
-static GooCanvasItem	*tooltip_text_item_s;
 static GooCanvasItem	*tooltip_bg_item;
 
+/* The continue button */
+static GooCanvasItem	*continue_root_item;
+static GooCanvasItem	*continue_text_item;
+static GooCanvasItem	*continue_bg_item;
+
 static void		 start_board (GcomprisBoard *agcomprisBoard);
 static void 		 pause_board (gboolean pause);
 static void 		 end_board (void);
@@ -173,7 +177,7 @@
     end_board,
     is_our_board,
     key_press,
-    process_ok,
+    NULL,
     set_level,
     NULL,
     NULL,
@@ -371,8 +375,7 @@
       return FALSE;
     case GDK_KP_Enter:
     case GDK_Return:
-      process_ok();
-      return TRUE;
+      return FALSE;
     case GDK_Right:
     case GDK_Delete:
     case GDK_BackSpace:
@@ -444,30 +447,13 @@
 
 static void process_ok()
 {
-  GList *list;
-  gboolean done = TRUE;
-
-  /* Loop through all the shapes to find if all target are found */
-  for(list = shape_list; list != NULL; list = list->next) {
-    Shape *shape = list->data;
-
-    if(shape->type==SHAPE_TARGET)
-      {
-	if(shape->placed!=shape)
-	  done=FALSE;
-      }
-  }
-
-  if(done)
-    {
-      gamewon = TRUE;
-      gc_bonus_display(gamewon, GC_BONUS_FLOWER);
-    }
-  else
-    {
-      gc_bonus_display(gamewon, GC_BONUS_FLOWER);
-    }
+  gamewon = TRUE;
 
+  /* Show the tooltip to let the user continue the game */
+  g_object_set(continue_text_item,
+	       "text", _("Continue"),
+	       NULL);
+  g_object_set (continue_root_item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
 }
 
 static void destroy_shape (Shape *shape)
@@ -509,6 +495,9 @@
       goo_canvas_item_remove(tooltip_root_item);
       tooltip_root_item = NULL;
 
+      goo_canvas_item_remove(continue_root_item);
+      continue_root_item = NULL;
+
       g_hash_table_destroy (shapelist_table);
       shapelist_table=NULL;
 
@@ -529,12 +518,12 @@
 
   shape_list_root_item = goo_canvas_group_new (parent, NULL);
 
+  /* Create the tooltip area */
   tooltip_root_item = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
 					    NULL);
   goo_canvas_item_translate(tooltip_root_item, 10, gcomprisBoard->height-70);
 
 
-  /* Create the tooltip area */
   pixmap = gc_skin_pixmap_load("button_large.png");
   tooltip_bg_item = \
     goo_canvas_image_new (tooltip_root_item,
@@ -544,18 +533,38 @@
 			  NULL);
   gdk_pixbuf_unref(pixmap);
 
-  tooltip_text_item_s = \
+  tooltip_text_item = \
     goo_canvas_text_new (tooltip_root_item,
 			 "",
-			 (double)gdk_pixbuf_get_width(pixmap)/2 + 1.0,
-			 24.0 + 1.0,
+			 (double)gdk_pixbuf_get_width(pixmap)/2,
+			 24.0,
 			 -1,
 			 GTK_ANCHOR_CENTER,
 			 "font", gc_skin_font_board_small,
-			 "fill_color_rgba", gc_skin_color_shadow,
+			 "fill_color_rgba", gc_skin_color_text_button,
 			 NULL);
-  tooltip_text_item = \
-    goo_canvas_text_new (tooltip_root_item,
+
+  /* Hide the tooltip */
+  g_object_set (tooltip_root_item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
+
+
+  /* Create the continue button */
+  continue_root_item = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
+					    NULL);
+  goo_canvas_item_translate(continue_root_item, 5, 5);
+
+
+  pixmap = gc_skin_pixmap_load("button_large.png");
+  continue_bg_item = \
+    goo_canvas_image_new (continue_root_item,
+			  pixmap,
+			  0,
+			  0,
+			  NULL);
+  gdk_pixbuf_unref(pixmap);
+
+  continue_text_item = \
+    goo_canvas_text_new (continue_root_item,
 			 "",
 			 (double)gdk_pixbuf_get_width(pixmap)/2,
 			 24.0,
@@ -565,8 +574,17 @@
 			 "fill_color_rgba", gc_skin_color_text_button,
 			 NULL);
 
-  /* Hide the tooltip */
-  g_object_set (tooltip_root_item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
+  g_signal_connect(continue_root_item,
+		   "button_press_event",
+		   (GtkSignalFunc) item_event_ok,
+		   "continue_click");
+  g_signal_connect(continue_text_item,
+		   "button_press_event",
+		   (GtkSignalFunc) item_event_ok,
+		   "continue_click");
+
+  /* Hide the continue */
+  g_object_set (continue_root_item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
 
 }
 
@@ -1085,9 +1103,6 @@
     {
     case GDK_ENTER_NOTIFY:
       if(shape->tooltip) {
-	g_object_set(tooltip_text_item_s,
-		     "text", shape->tooltip,
-		     NULL);
 	g_object_set(tooltip_text_item,
 		     "text", shape->tooltip,
 		     NULL);
@@ -1229,6 +1244,9 @@
 	  current_shapelistgroup_index = get_no_void_group(1);
 	  update_shapelist_item();
 	}
+      else if(!strcmp(data, "continue_click"))
+	if(gamewon == TRUE)
+	  gc_bonus_display(gamewon, GC_BONUS_FLOWER);
 
       root_item = g_list_nth_data(shape_list_group, current_shapelistgroup_index);
       g_object_set (root_item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);



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