[gcompris/gcomprixogoo] Patch from Miguel that fixes the configuration



commit c9fe35a6656be45a6f1ecace4240c11a6b7d36e2
Author: Bruno Coudoin <bcoudoin src gnome org>
Date:   Tue Mar 10 20:25:02 2009 +0000

    	Patch from Miguel that fixes the configuration
    	of python activities (tuxpaint and login was crashing).
    
    svn path=/trunk/; revision=3765

 ChangeLog                             |   28 ++++++++++++
 src/boards/Makefile.am                |    1 +
 src/boards/py-mod-gcompris.c          |   79 +++++++++++++++++++++-----------
 src/gcompris/board_config_radio.c     |    3 +-
 src/login-activity/login.py           |    8 ++--
 src/pythontest-activity/pythontest.py |   24 +++++-----
 src/tuxpaint-activity/tuxpaint.py     |   22 +++++-----
 7 files changed, 110 insertions(+), 55 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 191d665..23e3995 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,34 @@
 
 
 
+
+
+
+
+
+
+
+
+2009-06-21  Bruno coudoin  <bruno coudoin free fr>
+
+	- From trunk
+	Patch from Miguel that fixes the configuration
+	of python activities (tuxpaint and login was crashing).
+
+	* src/boards/Makefile.am:
+	* src/boards/py-mod-gcompris.c:
+	(py_gc_board_config_window_display),
+	(py_gc_board_config_boolean_box), (py_gc_board_config_combo_box),
+	(py_gc_board_config_radio_buttons), (py_gc_board_config_spin_int),
+	(py_gc_board_conf_separator), (py_gc_board_config_combo_locales),
+	(py_gc_board_config_combo_locales_asset),
+	(py_gc_board_config_textview):
+	* src/boards/python/login.py:
+	* src/boards/python/pythontest.py:
+	* src/boards/python/tuxpaint.py:
+	* src/gcompris/board_config_radio.c:
+	(gc_board_config_radio_buttons):
+
 2009-06-21  Bruno coudoin  <bruno coudoin free fr>
 
 	- From trunk
diff --git a/src/boards/Makefile.am b/src/boards/Makefile.am
index 04c3ca9..7ec9441 100644
--- a/src/boards/Makefile.am
+++ b/src/boards/Makefile.am
@@ -64,6 +64,7 @@ libpython_la_SOURCES = python.c \
 	py-gcompris-properties.c	py-gcompris-properties.h	\
 	py-gcompris-profile.c	py-gcompris-profile.h	\
 	py-gcompris-wordlist.c	py-gcompris-wordlist.h	\
+	py-gcompris-boardconfig.c py-gcompris-boardconfig.h \
 	py-gcompris-user.c	\
 	py-gcompris-class.c	\
 	py-gcompris-group.c	\
diff --git a/src/boards/py-mod-gcompris.c b/src/boards/py-mod-gcompris.c
index c368160..368c1f4 100644
--- a/src/boards/py-mod-gcompris.c
+++ b/src/boards/py-mod-gcompris.c
@@ -30,6 +30,7 @@ typedef int Py_ssize_t;
 #include "py-gcompris-properties.h"
 #include "py-gcompris-profile.h"
 #include "py-gcompris-wordlist.h"
+#include "py-gcompris-boardconfig.h"
 
 /* submodules includes */
 #include "py-mod-bonus.h"
@@ -1114,10 +1115,9 @@ py_gc_board_config_window_display(PyObject* self, PyObject* args){
   Py_INCREF(pyGcomprisConfCallbackFunc);
 
 
-  return (PyObject *) \
-             pygobject_new((GObject*) \
-			   gc_board_config_window_display( label,
-							  (GcomprisConfCallback )pyGcomprisConfCallback));
+  return gcompris_new_pyGcomprisBoardConfigObject(
+		  gc_board_config_window_display( label,
+			  (GcomprisConfCallback )pyGcomprisConfCallback));
 
 }
 
@@ -1126,17 +1126,20 @@ py_gc_board_config_window_display(PyObject* self, PyObject* args){
 static PyObject*
 py_gc_board_config_boolean_box(PyObject* self, PyObject* args)
 {
-  PyObject *py_bool;
+  PyObject *py_bool, *py_bconf;
+  pyGcomprisBoardConfigObject * bconf;
   gchar *label;
   gchar *key;
 
   /* Parse arguments */
-  if(!PyArg_ParseTuple(args, "ssO:gc_board_config_boolean_box", &label, &key, &py_bool))
+  if(!PyArg_ParseTuple(args, "OssO:gc_board_config_boolean_box", &py_bconf, &label, &key, &py_bool))
     return NULL;
 
+  bconf = (pyGcomprisBoardConfigObject*)py_bconf;
+
   /* Call the corresponding C function */
   return (PyObject *)pygobject_new((GObject*) \
-				    gc_board_config_boolean_box(NULL,(const gchar *)label, key, PyObject_IsTrue(py_bool)));
+				    gc_board_config_boolean_box(bconf->cdata,(const gchar *)label, key, PyObject_IsTrue(py_bool)));
 
 }
 
@@ -1144,7 +1147,8 @@ py_gc_board_config_boolean_box(PyObject* self, PyObject* args)
 static PyObject*
 py_gc_board_config_combo_box(PyObject* self, PyObject* args)
 {
-  PyObject *py_list;
+  pyGcomprisBoardConfigObject * bconf;
+  PyObject *py_list, *py_bconf;
   gchar *label;
   gchar *key;
   gchar *init;
@@ -1154,7 +1158,7 @@ py_gc_board_config_combo_box(PyObject* self, PyObject* args)
   int i, size;
 
   /* Parse arguments */
-  if(!PyArg_ParseTuple(args, "sOss:gc_board_config_combo_box", &label, &py_list, &key, &init))
+  if(!PyArg_ParseTuple(args, "OsOss:gc_board_config_combo_box", &py_bconf, &label, &py_list, &key, &init))
     return NULL;
 
   if (!PyList_Check(py_list)){
@@ -1169,9 +1173,11 @@ py_gc_board_config_combo_box(PyObject* self, PyObject* args)
     list = g_list_append( list,
 			  PyString_AsString( PyList_GetItem( py_list, i)));
 
+  bconf = (pyGcomprisBoardConfigObject*)py_bconf;
+
   /* Call the corresponding C function */
   return (PyObject *)pygobject_new((GObject*) \
-				    gc_board_config_combo_box(NULL, (const gchar *)label,
+				    gc_board_config_combo_box(bconf->cdata, (const gchar *)label,
 						       list,
 						       key,
 						       init));
@@ -1226,14 +1232,15 @@ PyObject* hash_object_to_dict(GHashTable *table)
 static PyObject*
 py_gc_board_config_radio_buttons(PyObject* self, PyObject* args)
 {
-  PyObject *py_dict;
+  PyObject *py_dict, *py_bconf;
+  pyGcomprisBoardConfigObject *bconf;
   GHashTable *buttons_label, *result;
   gchar *label;
   gchar *key;
   gchar *init;
 
   /* Parse arguments */
-  if(!PyArg_ParseTuple(args, "ssOs:gc_board_config_radio_buttons", &label, &key, &py_dict, &init))
+  if(!PyArg_ParseTuple(args, "OssOs:gc_board_config_radio_buttons", &py_bconf, &label, &key, &py_dict, &init))
     return NULL;
 
   if (!PyDict_Check(py_dict)){
@@ -1241,6 +1248,7 @@ py_gc_board_config_radio_buttons(PyObject* self, PyObject* args)
 		      "gc_board_config_radio_buttons second argument must be a dict");
     return NULL;
   }
+  bconf = (pyGcomprisBoardConfigObject*) py_bconf;
 
   PyObject *pykey, *pyvalue;
   Py_ssize_t pos = 0;
@@ -1256,7 +1264,7 @@ py_gc_board_config_radio_buttons(PyObject* self, PyObject* args)
 			  g_strdup(PyString_AsString(pyvalue)));
   }
 
-  result = gc_board_config_radio_buttons(NULL,label,
+  result = gc_board_config_radio_buttons(bconf->cdata,label,
 				  key,
 				  buttons_label,
 				  init);
@@ -1269,16 +1277,20 @@ py_gc_board_config_radio_buttons(PyObject* self, PyObject* args)
 static PyObject*
 py_gc_board_config_spin_int(PyObject* self, PyObject* args)
 {
+  pyGcomprisBoardConfigObject *bconf;
+  PyObject *py_bconf;
   gchar *label;
   gchar *key;
   gint min, max, step, init;
 
   /* Parse arguments */
-  if(!PyArg_ParseTuple(args, "ssiiii:gc_board_config_radio_buttons", &label, &key, &min, &max, &step, &init))
+  if(!PyArg_ParseTuple(args, "Ossiiii:gc_board_config_radio_buttons", &py_bconf, &label, &key, &min, &max, &step, &init))
     return NULL;
-
+  
+  bconf = (pyGcomprisBoardConfigObject*)py_bconf;
+  
   return (PyObject *)pygobject_new((GObject*) \
-				   gc_board_config_spin_int(NULL, (const gchar *)label,
+				   gc_board_config_spin_int(bconf->cdata, (const gchar *)label,
 						     key,
 						     min,
 						     max,
@@ -1292,12 +1304,17 @@ py_gc_board_config_spin_int(PyObject* self, PyObject* args)
 static PyObject*
 py_gc_board_conf_separator(PyObject* self, PyObject* args)
 {
+  PyObject *py_bconf;
+  pyGcomprisBoardConfigObject * bconf; 
+
   /* Parse arguments */
-  if(!PyArg_ParseTuple(args, ":gc_board_conf_separator"))
+  if(!PyArg_ParseTuple(args, "O:gc_board_conf_separator", &py_bconf))
     return NULL;
 
+  bconf = (pyGcomprisBoardConfigObject*)py_bconf;
+
   /* Create and return the result */
-  return (PyObject *)pygobject_new((GObject*) gc_board_conf_separator(NULL));
+  return (PyObject *)pygobject_new((GObject*) gc_board_conf_separator(bconf->cdata));
 
 }
 
@@ -1305,14 +1322,17 @@ py_gc_board_conf_separator(PyObject* self, PyObject* args)
 static PyObject*
 py_gc_board_config_combo_locales(PyObject* self, PyObject* args)
 {
+  pyGcomprisBoardConfigObject *bconf;
+  PyObject *py_bconf;
   gchar *init;
 
   /* Parse arguments */
-  if(!PyArg_ParseTuple(args, "s:gc_board_config_combo_locales", &init))
+  if(!PyArg_ParseTuple(args, "Os:gc_board_config_combo_locales", &py_bconf, &init))
     return NULL;
-
+  bconf = (pyGcomprisBoardConfigObject*)py_bconf;
+  
   return (PyObject *)pygobject_new((GObject*) \
-				   gc_board_config_combo_locales(NULL, init));
+				   gc_board_config_combo_locales(bconf->cdata, init));
 }
 
 
@@ -1343,19 +1363,21 @@ py_gc_locale_gets_list(PyObject* self, PyObject* args)
 static PyObject*
 py_gc_board_config_combo_locales_asset(PyObject* self, PyObject* args)
 {
+  pyGcomprisBoardConfigObject *bconf;
+  PyObject *py_bconf;
   gchar *init;
   gchar *label;
   gchar *file;
 
   /* Parse arguments */
-  if(!PyArg_ParseTuple(args, "ssz:gc_board_config_combo_locales",
+  if(!PyArg_ParseTuple(args, "Ossz:gc_board_config_combo_locales", &py_bconf,
 		       &label,
 		       &init,
 		       &file))
     return NULL;
-
+  bconf = (pyGcomprisBoardConfigObject*)py_bconf;
   return (PyObject *)pygobject_new((GObject*) \
-				   gc_board_config_combo_locales_asset(NULL, label, init, file ));
+				   gc_board_config_combo_locales_asset(bconf->cdata, label, init, file ));
 }
 
 
@@ -1475,7 +1497,8 @@ static gboolean pyGcomprisTextCallback(gchar *key, gchar *text, GtkLabel *label)
 
 static PyObject*
 py_gc_board_config_textview(PyObject* self, PyObject* args){
-  PyObject* pyCallback;
+  pyGcomprisBoardConfigObject *bconf;
+  PyObject* pyCallback, *py_bconf;
   gchar *label;
   gchar *key;
   gchar *desc = NULL;
@@ -1483,7 +1506,8 @@ py_gc_board_config_textview(PyObject* self, PyObject* args){
 
   /* Parse arguments */
   if(!PyArg_ParseTuple(args,
-		       "sszzO:gc_board_config_window_display",
+		       "OsszzO:gc_board_config_window_display",
+		       &py_bconf,
 		       &label,
 		       &key,
 		       &desc,
@@ -1503,10 +1527,11 @@ py_gc_board_config_textview(PyObject* self, PyObject* args){
   g_hash_table_replace (text_callbacks, key, pyCallback);
 
   Py_INCREF(pyCallback);
+  bconf = (pyGcomprisBoardConfigObject*)py_bconf;
 
   return (PyObject *) \
              pygobject_new((GObject*) \
-			   gc_board_config_textview(NULL, label,
+			   gc_board_config_textview(bconf->cdata, label,
 					      key,
 					      desc,
 					      init_text,
diff --git a/src/gcompris/board_config_radio.c b/src/gcompris/board_config_radio.c
index 555bdd3..47f45e3 100644
--- a/src/gcompris/board_config_radio.c
+++ b/src/gcompris/board_config_radio.c
@@ -120,6 +120,7 @@ gc_board_config_radio_buttons(GcomprisBoardConf *conf, const gchar *label,
 					       NULL);
   Gconfig_radio *u = g_malloc0(sizeof(Gconfig_radio));
   u->hash_radio = buttons;
+  u->config = conf;
 
   u->radio_box = gtk_vbox_new (TRUE, 2);
   gtk_widget_show (GTK_WIDGET (u->radio_box));
@@ -152,7 +153,7 @@ gc_board_config_radio_buttons(GcomprisBoardConf *conf, const gchar *label,
 
   g_hash_table_foreach( buttons_label,
 			(GHFunc) create_radio_buttons,
-			(gpointer) buttons);
+			(gpointer) u);
 
   g_signal_connect (G_OBJECT(u->radio_box), "destroy", G_CALLBACK(radio_box_destroy), (gpointer) u);
 
diff --git a/src/login-activity/login.py b/src/login-activity/login.py
index 7de7c31..8070a75 100644
--- a/src/login-activity/login.py
+++ b/src/login-activity/login.py
@@ -472,23 +472,23 @@ class Gcompris_login:
     # the returned value is the main GtkVBox of the window,
     #we can add what you want in it.
 
-    self.main_vbox = gcompris.configuration_window ( \
+    bconf = gcompris.configuration_window ( \
       _('<b>%s</b> configuration\n for profile <b>%s</b>') % ('Login', profile.name ),
       self.ok_callback
       )
 
     # toggle box
-    uppercase = gcompris.boolean_box(_('Uppercase only text'),
+    uppercase = gcompris.boolean_box(bconf, _('Uppercase only text'),
                                         'uppercase_only',
                                         eval(self.config_dict['uppercase_only'])
                                         )
 
     #uppercase.set_sensitive(False)
 
-    gcompris.separator()
+    gcompris.separator(bconf)
 
     # toggle box
-    entry_text = gcompris.boolean_box(_('Enter login to log in'),
+    entry_text = gcompris.boolean_box(bconf, _('Enter login to log in'),
                                         'entry_text',
                                         eval(self.config_dict['entry_text'])
                                         )
diff --git a/src/pythontest-activity/pythontest.py b/src/pythontest-activity/pythontest.py
index 3137425..074e911 100644
--- a/src/pythontest-activity/pythontest.py
+++ b/src/pythontest-activity/pythontest.py
@@ -450,13 +450,13 @@ class Gcompris_pythontest:
     # the returned value is the main GtkVBox of the window,
     #we can add what you want in it.
 
-    self.main_vbox = gcompris.configuration_window ( \
+    bconf = gcompris.configuration_window ( \
       _('<b>%s</b> configuration\n for profile <b>%s</b>') % ('Pythontest', profile.name ),
       self.ok_callback
       )
 
     # toggle box
-    control_line = gcompris.boolean_box(_('Disable line drawing in circle'),
+    control_line = gcompris.boolean_box(bconf, _('Disable line drawing in circle'),
                                         'disable_line',
                                         eval(self.config_dict['disable_line'])
                                         )
@@ -465,18 +465,18 @@ class Gcompris_pythontest:
 
     # combo box
     self.color_choice = \
-       gcompris.combo_box(_('Color of the line'),
+       gcompris.combo_box(bconf, _('Color of the line'),
                           self.config_colors_list,
                           'color_line',
                           self.config_dict['color_line']
                           )
     self.color_choice.set_sensitive(not eval(self.config_dict['disable_line']))
 
-    gcompris.separator()
+    gcompris.separator(bconf)
 
     #spin button for int
     self.distance_box = \
-       gcompris.spin_int(_('Distance between circles'),
+       gcompris.spin_int(bconf, _('Distance between circles'),
                          'distance_circle',
                          20,
                          200,
@@ -484,14 +484,14 @@ class Gcompris_pythontest:
                          eval(self.config_dict['distance_circle'])
                          )
 
-    gcompris.separator()
+    gcompris.separator(bconf)
 
     #radio buttons for circle or rectangle
     patterns = { 'circle': _('Use circles'),
                  'rectangle': _('Use rectangles')
                  }
 
-    gcompris.radio_buttons(_('Choice of pattern'),
+    gcompris.radio_buttons(bconf, _('Choice of pattern'),
                            'pattern',
                            patterns,
                            self.config_dict['pattern']
@@ -500,11 +500,11 @@ class Gcompris_pythontest:
     print "List of locales shown in gcompris.combo_locale :"
     print gcompris.get_locales_list()
 
-    gcompris.separator()
+    gcompris.separator(bconf)
 
-    gcompris.combo_locales( self.config_dict['locale'])
+    gcompris.combo_locales(bconf, self.config_dict['locale'])
 
-    gcompris.separator()
+    gcompris.separator(bconf)
 
     print "List of locales shown in gcompris.combo_locales_asset :"
     locales_purple = gcompris.get_locales_asset_list( "gcompris colors", None, "audio/x-ogg", "purple.ogg")
@@ -513,9 +513,9 @@ class Gcompris_pythontest:
     label = gtk.Label()
     label.set_markup('<i>-- unused, but here for test --</i>')
     label.props.visibility = goocanvas.ITEM_VISIBLE
-    self.main_vbox.pack_start (label, False, False, 8)
+#    self.main_vbox.pack_start (label, False, False, 8)
 
-    gcompris.combo_locales_asset( _("Select sound locale"), self.config_dict['locale_sound'], "gcompris colors", None, "audio/x-ogg", "purple.ogg" )
+    gcompris.combo_locales_asset(bconf, _("Select sound locale"), self.config_dict['locale_sound'], "gcompris colors", None, "audio/x-ogg", "purple.ogg" )
 
     print gcompris.utils.get_asset_file ("gcompris colors", None, "audio/x-ogg", "purple.ogg")
     print gcompris.utils.get_asset_file_locale ("gcompris colors", None, "audio/x-ogg", "purple.ogg", None)
diff --git a/src/tuxpaint-activity/tuxpaint.py b/src/tuxpaint-activity/tuxpaint.py
index a0af2a7..98fed69 100644
--- a/src/tuxpaint-activity/tuxpaint.py
+++ b/src/tuxpaint-activity/tuxpaint.py
@@ -182,30 +182,30 @@ class Gcompris_tuxpaint:
     #set already configured values
     self.config_dict.update(gcompris.get_conf(profile, self.gcomprisBoard))
 
-    self.main_vbox = gcompris.configuration_window(_('<b>%s</b> configuration\n for profile <b>%s</b>') % ('Tuxpaint', profile.name ),
+    bconfig = gcompris.configuration_window(_('<b>%s</b> configuration\n for profile <b>%s</b>') % ('Tuxpaint', profile.name ),
                                                    self.apply_callback)
 
 
-    gcompris.boolean_box(_('Inherit fullscreen setting from GCompris'), 'fullscreen', eval(self.config_dict['fullscreen']))
+    gcompris.boolean_box(bconfig, _('Inherit fullscreen setting from GCompris'), 'fullscreen', eval(self.config_dict['fullscreen']))
 
-    gcompris.separator()
+    gcompris.separator(bconfig)
 
-    gcompris.boolean_box(_('Inherit size setting from GCompris (800x600, 640x480)'), 'size', eval(self.config_dict['size']))
+    gcompris.boolean_box(bconfig, _('Inherit size setting from GCompris (800x600, 640x480)'), 'size', eval(self.config_dict['size']))
 
-    gcompris.separator()
+    gcompris.separator(bconfig)
 
-    gcompris.boolean_box(_('Disable shape rotation'), 'disable_shape_rotation', eval(self.config_dict['disable_shape_rotation']))
+    gcompris.boolean_box(bconfig, _('Disable shape rotation'), 'disable_shape_rotation', eval(self.config_dict['disable_shape_rotation']))
 
-    gcompris.separator()
+    gcompris.separator(bconfig)
 
-    gcompris.boolean_box(_('Show Uppercase text only'), 'uppercase_text', eval(self.config_dict['uppercase_text']))
+    gcompris.boolean_box(bconfig, _('Show Uppercase text only'), 'uppercase_text', eval(self.config_dict['uppercase_text']))
 
-    gcompris.separator()
+    gcompris.separator(bconfig)
 
-    stamps = gcompris.boolean_box(_('Disable stamps'), 'disable_stamps', eval(self.config_dict['disable_stamps']))
+    stamps = gcompris.boolean_box(bconfig, _('Disable stamps'), 'disable_stamps', eval(self.config_dict['disable_stamps']))
     stamps.connect("toggled", self.stamps_changed)
 
-    self.stamps_control = gcompris.boolean_box('Disable stamps control', 'disable_stamps_control', eval(self.config_dict['disable_stamps_control']))
+    self.stamps_control = gcompris.boolean_box(bconfig, 'Disable stamps control', 'disable_stamps_control', eval(self.config_dict['disable_stamps_control']))
     self.stamps_control.set_sensitive(not eval(self.config_dict['disable_stamps']))
 
   def stamps_changed(self, button):



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