[gcompris/gcomprixogoo] Added the option --disable-level. Some teacher want to be sure the children don't skip a level.



commit d99bbe9c8adb956bf4a612876e6d037fed0ced6b
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Wed Nov 10 12:49:44 2010 -0200

    Added the option --disable-level. Some teacher want to be sure the children don't skip a level.

 src/gcompris/bar.c        |   36 ++++++++++++++++++++----------------
 src/gcompris/gcompris.c   |   10 ++++++++++
 src/gcompris/properties.c |    4 ++++
 src/gcompris/properties.h |    1 +
 4 files changed, 35 insertions(+), 16 deletions(-)
---
diff --git a/src/gcompris/bar.c b/src/gcompris/bar.c
index 06966fd..73c1b29 100644
--- a/src/gcompris/bar.c
+++ b/src/gcompris/bar.c
@@ -216,8 +216,8 @@ bar_start (GooCanvas *theCanvas)
   // LEVEL (Multiple buttons for this one)
   GooCanvasItem *rootitem_level = goo_canvas_group_new (rootitem, NULL);
   g_object_set (rootitem_level,
-                "visibility", GOO_CANVAS_ITEM_INVISIBLE,
-                NULL);
+		"visibility", GOO_CANVAS_ITEM_VISIBLE,
+		NULL);
   g_object_set_data (G_OBJECT(rootitem_level), "flag",
 		     GUINT_TO_POINTER(GC_BAR_LEVEL));
   buttons = g_slist_append(buttons, rootitem_level);
@@ -228,30 +228,34 @@ bar_start (GooCanvas *theCanvas)
 				   "#LEVEL_DOWN");
 
   g_object_set (item,
-                "visibility", GOO_CANVAS_ITEM_VISIBLE,
-                NULL);
+		"visibility", (properties->disable_level ?
+			       GOO_CANVAS_ITEM_INVISIBLE :
+			       GOO_CANVAS_ITEM_VISIBLE),
+		NULL);
 
   item = new_button(rootitem_level,
 		    svg_handle,
-                    GC_BAR_LEVEL,
-                    "#LEVEL_UP");
+		    GC_BAR_LEVEL,
+		    "#LEVEL_UP");
   goo_canvas_item_translate(item, 50, 0);
   g_object_set (item,
-                "visibility", GOO_CANVAS_ITEM_VISIBLE,
-                NULL);
+		"visibility", (properties->disable_level ?
+			       GOO_CANVAS_ITEM_INVISIBLE :
+			       GOO_CANVAS_ITEM_VISIBLE),
+		NULL);
 
   goo_canvas_item_get_bounds(item, &bounds);
 
   level_item =
     goo_canvas_text_new (rootitem_level,
-                         "",
-                         bounds.x1 - 10,
-                         (bounds.y2 - bounds.y1) / 2 + 8,
-                         -1,
-                         GTK_ANCHOR_CENTER,
-                         "font", gc_skin_font_board_title_bold,
-                         "fill-color-rgba", gc_skin_color_text_button,
-                         NULL);
+			 "",
+			 bounds.x1 - 10,
+			 (bounds.y2 - bounds.y1) / 2 + 8,
+			 -1,
+			 GTK_ANCHOR_CENTER,
+			 "font", gc_skin_font_board_title_bold,
+			 "fill-color-rgba", gc_skin_color_text_button,
+			 NULL);
   current_level = 1;
 
   // REPEAT (Default)
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index 7684c97..240db79 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -141,6 +141,7 @@ static gchar *popt_user_dir	   = NULL;
 static gint  popt_experimental     = FALSE;
 static gint  popt_no_quit	   = FALSE;
 static gint  popt_no_config        = FALSE;
+static gint  popt_no_level         = FALSE;
 static gchar *popt_server          = NULL;
 static gint  *popt_web_only        = NULL;
 static gchar *popt_cache_dir       = NULL;
@@ -236,6 +237,9 @@ static GOptionEntry options[] = {
   {"disable-config",'\0', 0, G_OPTION_ARG_NONE, &popt_no_config,
    N_("Disable the config button"), NULL},
 
+  {"disable-level",'\0', 0, G_OPTION_ARG_NONE, &popt_no_level,
+   N_("Disable the level button"), NULL},
+
   {"server", '\0', 0, G_OPTION_ARG_STRING, &popt_server,
    N_("GCompris will get images, sounds and activity data from this server if not found locally."), NULL},
 
@@ -1631,6 +1635,12 @@ main (int argc, char *argv[])
       properties->disable_config = TRUE;
     }
 
+  if (popt_no_level)
+    {
+      g_message("Disable level button");
+      properties->disable_level = TRUE;
+    }
+
   if (popt_difficulty_filter>=0)
     {
       /* This option provide less capacity than the GUI since we cannot set the filter_style */
diff --git a/src/gcompris/properties.c b/src/gcompris/properties.c
index 826b346..29e43dd 100644
--- a/src/gcompris/properties.c
+++ b/src/gcompris/properties.c
@@ -156,6 +156,7 @@ gc_prop_new ()
   tmp->difficulty_filter = 1;				/* No difficulty filter by default */
   tmp->disable_quit      = 0;				/* Used to remove the quit button from the bar. Use it for kiosk mode */
   tmp->disable_config    = 0;				/* Used to remove the config button from the bar. Use it for kiosk mode */
+  tmp->disable_level     = 0;				/* Used to remove the level button from the bar */
   tmp->display_resource  = 0;
   tmp->root_menu         = g_strdup("/");
   tmp->profile           = NULL;
@@ -399,6 +400,9 @@ gc_prop_load (GcomprisProperties *props, GCPropSourceConf source_conf)
 	} else if(!strcmp(value.v_identifier, "disable_config")) {
 	  if(!scan_get_int(scanner, &props->disable_config))
 	    g_warning("Config file parsing error on token %s", token);
+	} else if(!strcmp(value.v_identifier, "disable_level")) {
+	  if(!scan_get_int(scanner, &props->disable_level))
+	    g_warning("Config file parsing error on token %s", token);
 	} else if(!strcmp(value.v_identifier, "filter_style")) {
 	  if(!scan_get_int(scanner, &props->filter_style))
 	    g_warning("Config file parsing error on token %s", token);
diff --git a/src/gcompris/properties.h b/src/gcompris/properties.h
index 5682a21..e95e697 100644
--- a/src/gcompris/properties.h
+++ b/src/gcompris/properties.h
@@ -39,6 +39,7 @@ typedef struct {
   gint		difficulty_max;
   gint		disable_quit;
   gint		disable_config;
+  gint		disable_level;
   gint		display_resource;
   gchar        *root_menu;
   gchar        *package_data_dir;



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