gcompris r3364 - in branches/GCOMPRIS_8_3: . src/gcompris



Author: bcoudoin
Date: Sat Apr 12 22:59:11 2008
New Revision: 3364
URL: http://svn.gnome.org/viewvc/gcompris?rev=3364&view=rev

Log:
	Improved the windows version so that the administration module
	is available in the demo version.
	Now python activities can be part of the demo version and
	many are there now. There are now 47 activities in the demo
	out of 107, more than twice as before. (commit trunk 3362)

	* src/gcompris/board.c: (gc_board_init), (gc_board_check_file):
	* src/gcompris/gcompris.c: (get_board_to_start), (setup_window),
	(display_activation_dialog), (activation_done):



Modified:
   branches/GCOMPRIS_8_3/ChangeLog
   branches/GCOMPRIS_8_3/src/gcompris/board.c
   branches/GCOMPRIS_8_3/src/gcompris/gcompris.c

Modified: branches/GCOMPRIS_8_3/src/gcompris/board.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/board.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/board.c	Sat Apr 12 22:59:11 2008
@@ -78,10 +78,19 @@
 static BoardPlugin *static_boards_demo[MAX_NUMBER_OF_BOARDS];
 static BoardPlugin *static_boards[MAX_NUMBER_OF_BOARDS];
 
-#endif
+static char *board_nodemo[] = /* Some boards excluded from the demo version */
+  {
+    "python:ballcatch",
+    "python:followline",
+    "python:guessnumber",
+    "python:mosaic",
+    "python:redraw",
+    "python:searace",
+    "python:sudoku",
+    "python:watercycle",
+    NULL
+  };
 
-#ifdef STATIC_MODULE
-int gc_board_number_in_demo;
 void gc_board_init(void)
 {
   guint i=0;
@@ -105,6 +114,7 @@
   static_boards_demo[i++] = get_menu_bplugin_info();
   static_boards_demo[i++] = get_money_bplugin_info();
   static_boards_demo[i++] = get_reading_bplugin_info();
+  static_boards_demo[i++] = get_python_bplugin_info();
   static_boards_demo[i++] = get_scale_bplugin_info();
   static_boards_demo[i++] = get_submarine_bplugin_info();
   static_boards_demo[i++] = get_superbrain_bplugin_info();
@@ -112,8 +122,6 @@
   static_boards_demo[i++] = get_wordprocessor_bplugin_info();
   static_boards_demo[i++] = NULL;
 
-  gc_board_number_in_demo = i - 2;
-
   i=0;
 
   static_boards[i++] = get_advanced_colors_bplugin_info();
@@ -223,7 +231,10 @@
     return TRUE;
   }
 
-  key_is_valid = gc_activation_check(properties->key);
+  if(properties->administration)
+    key_is_valid = 1;
+  else
+    key_is_valid = gc_activation_check(properties->key);
 
   i = 0;
   if(key_is_valid == 1)
@@ -253,6 +264,19 @@
 
 	if(bp->is_our_board(gcomprisBoard)) {
 	  /* Great, we found our plugin */
+
+	  /* check for excluded one */
+	  char **ptr = board_nodemo;
+	  do
+	    {
+	      if(strcmp(*ptr, gcomprisBoard->type) == 0)
+		break;
+	    }
+	  while(*++ptr);
+
+	  if(*ptr)
+	    goto notfound;
+
 	  g_warning("We found the correct plugin for board %s (type=%s)\n",
 		  gcomprisBoard->name, gcomprisBoard->type);
 
@@ -263,6 +287,8 @@
       }
     }
 
+ notfound:
+  gcomprisBoard->plugin = NULL;
   g_warning("No plugin library found for board type '%s', requested by '%s'",
 	    gcomprisBoard->type,  gcomprisBoard->filename);
 

Modified: branches/GCOMPRIS_8_3/src/gcompris/gcompris.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/gcompris.c	(original)
+++ branches/GCOMPRIS_8_3/src/gcompris/gcompris.c	Sat Apr 12 22:59:11 2008
@@ -78,11 +78,11 @@
 static void activation_enter_callback(GtkWidget *widget,
 				      GtkWidget *entry );
 static void activation_done();
-static void display_activation_dialog();
+static int display_activation_dialog();
 static GnomeCanvasItem *activation_item;
 static GtkEntry *widget_activation_entry;
 #else
-#define display_activation_dialog()
+#define display_activation_dialog() FALSE
 #endif
 
 
@@ -607,6 +607,53 @@
   }
 }
 
+static GcomprisBoard *get_board_to_start()
+{
+  GcomprisBoard *board_to_start;
+
+  /* By default, the menu will be started */
+  board_to_start = properties->menu_board;
+
+  /* Get and Run the root menu */
+  if(properties->administration)
+    {
+      board_to_start = gc_menu_section_get("/administration/administration");
+    }
+  else
+    {
+      /* If we have a profile defined, run the login screen
+       * (the login screen is a board that uppon login completion
+       * starts the menu)
+       */
+      if(properties->profile && properties->profile->group_ids)
+	{
+	  gboolean found = FALSE;
+
+	  GList *group_id;
+
+	  for (group_id = properties->profile->group_ids; group_id != NULL; group_id = group_id->next)
+	    if (g_list_length(gc_db_users_from_group_get( *((int *) group_id->data))) > 0){
+	      found = TRUE;
+	      break;
+	    }
+
+	  /* No profile start normally */
+	  if (found)
+	    board_to_start = gc_menu_section_get("/login/login");
+	  else {
+	    board_to_start = gc_menu_section_get(properties->root_menu);
+	    /* this will set user information to system one */
+	    gc_profile_set_current_user(NULL);
+	  }
+	}
+      else
+	/* this will set user information to system one */
+	gc_profile_set_current_user(NULL);
+    }
+
+  return board_to_start;
+}
+
 static void setup_window ()
 {
   GcomprisBoard *board_to_start;
@@ -732,51 +779,13 @@
   /* Save the root_menu */
   properties->menu_board = gc_menu_section_get(properties->root_menu);
 
-  /* By default, the menu will be started */
-  board_to_start = properties->menu_board;
-
-  /* Get and Run the root menu */
-  if(properties->administration)
-    {
-      board_to_start = gc_menu_section_get("/administration/administration");
-    }
-  else
-    {
-      /* If we have a profile defined, run the login screen
-       * (the login screen is a board that uppon login completion
-       * starts the menu)
-       */
-      if(properties->profile && properties->profile->group_ids)
-	{
-	  gboolean found = FALSE;
-
-	  GList *group_id;
-
-	  for (group_id = properties->profile->group_ids; group_id != NULL; group_id = group_id->next)
-	    if (g_list_length(gc_db_users_from_group_get( *((int *) group_id->data))) > 0){
-	      found = TRUE;
-	      break;
-	    }
-
-	  /* No profile start normally */
-	  if (found)
-	    board_to_start = gc_menu_section_get("/login/login");
-	  else {
-	    board_to_start = gc_menu_section_get(properties->root_menu);
-	    /* this will set user information to system one */
-	    gc_profile_set_current_user(NULL);
-	  }
-	}
-      else
-	/* this will set user information to system one */
-	gc_profile_set_current_user(NULL);
-    }
-
-    /* Run the bar */
+  /* Run the bar */
   gc_bar_start(canvas_bar);
 
   init_background();
 
+  board_to_start = get_board_to_start();
+
   if(!board_to_start) {
     gchar *tmpstr= g_strdup_printf("Couldn't find the board menu %s, or plugin execution error", properties->root_menu);
     gc_dialog(tmpstr, NULL);
@@ -787,38 +796,43 @@
     g_free(tmpstr);
   } else {
     g_warning("Fine, we got the gcomprisBoardMenu, xml boards parsing went fine");
-    gc_board_play(board_to_start);
+    if(!display_activation_dialog())
+      gc_board_play(board_to_start);
   }
 
-  display_activation_dialog();
 
 }
 
 #ifdef STATIC_MODULE
-extern int gc_board_number_in_demo;
 /** Display the activation dialog for the windows version
  *
+ * return TRUE is the dialog is display, FALSE instead.
  */
-void
+int
 display_activation_dialog()
 {
   int board_count = 0;
+  int gc_board_number_in_demo = 0;
   GList *list;
   guint  key_is_valid = 0;
 
   key_is_valid = gc_activation_check(properties->key);
 
   if(key_is_valid == 1)
-    return;
+    return FALSE;
 
   /* Count non menu boards */
   for (list = gc_menu_get_boards(); list != NULL; list = list->next)
     {
       GcomprisBoard *board = list->data;
       if (strcmp(board->type, "menu") != 0 &&
-	  strcmp(board->section, "/experimental") != 0 &&
-	  strcmp(board->section, "/administration") != 0)
-	board_count++;
+	  strncmp(board->section, "/experimental", 13) != 0)
+	{
+	  board_count++;
+	  gc_board_check_file(board);
+	  if(board->plugin)
+	      gc_board_number_in_demo++;
+	}
     }
 
   /* Entry area */
@@ -842,12 +856,12 @@
   gtk_widget_show(GTK_WIDGET(widget_activation_entry));
   gtk_entry_set_text(GTK_ENTRY(widget_activation_entry), "CODE");
 
-  gc_board_stop();
-
   char *msg = g_strdup_printf(_("GCompris is free software released under the GPL License. In order to support its development, the Windows version provides only %d of the %d activities. You can get the full version for a small fee at\n<http://gcompris.net>\nThe GNU/Linux version does not have this restriction. Note that GCompris is being developed to free schools from monopolistic software vendors. If you also believe that we should teach freedom to children, please consider using GNU/Linux. Get more information at FSF:\n<http://www.fsf.org/philosophy>"),
 			      gc_board_number_in_demo, board_count);
   gc_dialog(msg, activation_done);
   g_free(msg);
+
+  return TRUE;
 }
 
 /**
@@ -940,7 +954,7 @@
       activation_enter_callback(GTK_WIDGET(widget_activation_entry), NULL);
     }
 
-  gc_board_play(properties->menu_board);
+  gc_board_play( get_board_to_start());
   gtk_object_destroy (GTK_OBJECT(activation_item));
 }
 #endif



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