[gcompris] windows demo system changed so that all the icons are always displayed, but the non demo one are not



commit 54d8d362200653221802ff9c74381d4b4ba8ee4a
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Sun Oct 23 22:21:47 2011 +0200

    windows demo system changed so that all the icons are always displayed,
    but the non demo one are not clickable.

 src/boards/menu2.c      |   29 +++++++++++++++++++++++++++--
 src/gcompris/board.c    |   18 ++++++++++++------
 src/gcompris/board.h    |    1 +
 src/gcompris/gcompris.c |    2 +-
 4 files changed, 41 insertions(+), 9 deletions(-)
---
diff --git a/src/boards/menu2.c b/src/boards/menu2.c
index 5e4ab2b..040390a 100644
--- a/src/boards/menu2.c
+++ b/src/boards/menu2.c
@@ -79,6 +79,8 @@ static GooCanvasItem	*menu_difficulty_display(GooCanvasItem *parent,
 						 double x, double y,
 						 double ratio,
 						 gint difficulty);
+static GooCanvasItem	*menu_demo_display(GooCanvasItem *parent,
+					   gdouble x, gdouble y);
 
 static double current_x = 0.0;
 static double current_y = 0.0;
@@ -350,7 +352,8 @@ create_panel(GooCanvasItem *parent)
       g_signal_connect (item, "leave_notify_event",
 			(GCallback) on_leave_notify, menuitems);
 
-      gc_item_focus_init(item, NULL);
+      if ( ! gc_board_is_demo_only(board) )
+	gc_item_focus_init(item, NULL);
     }
 }
 
@@ -545,6 +548,11 @@ static void menu_create_item(GooCanvasItem *parent, MenuItems *menuitems, Gcompr
 				  (double) 0.6,
 				  difficulty);
 	}
+
+      if ( gc_board_is_demo_only(board) )
+	menu_demo_display(parent,
+			  (gdouble)(current_x - pixmap_w/2 - 20),
+			  (gdouble)(current_y - pixmap_h/2 + 60) );
     }
 
 
@@ -654,7 +662,7 @@ item_event(GooCanvasItem *item, GdkEvent *event,  MenuItems *menuitems)
       menu_position = path;
 
     }
-  else
+  else if ( ! gc_board_is_demo_only(board) )
     {
       gc_sound_play_ogg ("sounds/level.wav", NULL);
       gc_board_run_next (board);
@@ -947,6 +955,7 @@ menu_difficulty_display(GooCanvasItem *parent,
   item = goo_canvas_svg_new (stars_group,
 			     gc_skin_rsvg_get(),
 			     "svg-id", svg_id,
+			     "pointer-events", GOO_CANVAS_EVENTS_NONE,
 			     NULL);
   SET_ITEM_LOCATION(item, x, y);
 
@@ -955,3 +964,19 @@ menu_difficulty_display(GooCanvasItem *parent,
   return(stars_group);
 }
 
+/**
+ * Display the demo only icon
+ */
+static GooCanvasItem *
+menu_demo_display(GooCanvasItem *parent,
+		  gdouble x, gdouble y)
+{
+  GooCanvasItem *item = goo_canvas_svg_new (parent,
+					    gc_skin_rsvg_get(),
+					    "svg-id", "#UNCHECKED",
+					    "pointer-events", GOO_CANVAS_EVENTS_NONE,
+					    NULL);
+  SET_ITEM_LOCATION(item, x, y);
+  return(item);
+}
+
diff --git a/src/gcompris/board.c b/src/gcompris/board.c
index dbc1801..ffcab80 100644
--- a/src/gcompris/board.c
+++ b/src/gcompris/board.c
@@ -177,6 +177,18 @@ void gc_board_set_current(GcomprisBoard * gcomprisBoard)
   bp_data->current_gcompris_board = gcomprisBoard;
 }
 
+gboolean
+gc_board_is_demo_only(GcomprisBoard *gcomprisBoard)
+{
+#ifdef ACTIVATION_CODE
+  GcomprisProperties	*properties = gc_prop_get();
+  g_assert(properties->key!=NULL);
+  if ( !gcomprisBoard->demo && gc_activation_check(properties->key) <= 0 )
+    return TRUE;
+#endif
+  return FALSE;
+}
+
 #ifdef STATIC_MODULE
 gboolean
 gc_board_check_file(GcomprisBoard *gcomprisBoard)
@@ -186,7 +198,6 @@ gc_board_check_file(GcomprisBoard *gcomprisBoard)
   guint        i=0;
 
   g_assert(gcomprisBoard!=NULL);
-  g_assert(properties->key!=NULL);
 
   /* Check Already loaded */
   if(gcomprisBoard->plugin!=NULL) {
@@ -224,11 +235,6 @@ gc_board_check_file(GcomprisBoard *gcomprisBoard)
 
   g_assert(gcomprisBoard!=NULL);
 
-#ifdef ACTIVATION_CODE
-  if ( !gcomprisBoard->demo && gc_activation_check(properties->key) <= 0 )
-    return FALSE;
-#endif
-
 #if defined WIN32 || defined MAC_INTEGRATION
   /* Some activities are not relevant on some platform */
   if (strcmp("tuxpaint", gcomprisBoard->name) == 0)
diff --git a/src/gcompris/board.h b/src/gcompris/board.h
index 9073bc7..1cfad78 100644
--- a/src/gcompris/board.h
+++ b/src/gcompris/board.h
@@ -66,5 +66,6 @@ void		 gc_board_pause(int pause);
 
 void             gc_board_run_next(GcomprisBoard *board);
 guint		 gc_board_get_number_of_activity();
+gboolean	 gc_board_is_demo_only(GcomprisBoard *gcomprisBoard);
 
 #endif
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index ec9a5eb..7ab33d6 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -1260,7 +1260,7 @@ static void map_cb (GtkWidget *widget, gpointer data)
 	gchar *tmpstr= g_strdup_printf("Couldn't find the board menu %s, or plugin execution error", properties->root_menu);
 	gc_dialog(tmpstr, NULL);
 	g_free(tmpstr);
-      } else if(!gc_board_check_file(board_to_start)) {
+      } else if(!gc_board_check_file(board_to_start) || gc_board_is_demo_only(board_to_start) ) {
 	gchar *tmpstr= g_strdup_printf("Couldn't find the board menu, or plugin execution error");
 	gc_dialog(tmpstr, NULL);
 	g_free(tmpstr);



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