From 503d68148cfbf3255c4890b8565ad4d34859c202 Mon Sep 17 00:00:00 2001 From: Bruno Coudoin Date: Tue, 10 Mar 2009 20:25:02 +0000 Subject: Patch from Miguel that fixes the configuration of python activities (tuxpaint and login was crashing). svn path=/trunk/; revision=3765 --- diff --git a/ChangeLog b/ChangeLog index 7fc5fe1..d50626a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2009-03-10 Bruno coudoin + + 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): + *** RELEASE 8.4.9 *** 2009-03-04 Bruno coudoin diff --git a/src/boards/Makefile.am b/src/boards/Makefile.am index bdf06aa..e62b52e 100644 --- a/src/boards/Makefile.am +++ b/src/boards/Makefile.am @@ -274,6 +274,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 0380f09..4908b18 100644 --- a/src/boards/py-mod-gcompris.c +++ b/src/boards/py-mod-gcompris.c @@ -32,6 +32,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" @@ -1054,10 +1055,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)); } @@ -1066,17 +1066,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))); } @@ -1084,7 +1087,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; @@ -1094,7 +1098,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)){ @@ -1109,9 +1113,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)); @@ -1166,14 +1172,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)){ @@ -1181,6 +1188,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; @@ -1196,7 +1204,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); @@ -1209,16 +1217,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, @@ -1232,12 +1244,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)); } @@ -1245,14 +1262,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)); } @@ -1283,19 +1303,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 )); } @@ -1415,7 +1437,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; @@ -1423,7 +1446,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, @@ -1443,10 +1467,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/boards/python/login.py b/src/boards/python/login.py index e39e457..c87a14d 100644 --- a/src/boards/python/login.py +++ b/src/boards/python/login.py @@ -531,23 +531,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 ( \ _('%s configuration\n for profile %s') % ('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/boards/python/pythontest.py b/src/boards/python/pythontest.py index 56170d2..fb22ab9 100644 --- a/src/boards/python/pythontest.py +++ b/src/boards/python/pythontest.py @@ -405,13 +405,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 ( \ _('%s configuration\n for profile %s') % ('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']) ) @@ -420,18 +420,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, @@ -439,14 +439,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'] @@ -455,11 +455,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") @@ -468,9 +468,9 @@ class Gcompris_pythontest: label = gtk.Label() label.set_markup('-- unused, but here for test --') label.show() - 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/boards/python/tuxpaint.py b/src/boards/python/tuxpaint.py index c2b5dd3..2f4a9bd 100644 --- a/src/boards/python/tuxpaint.py +++ b/src/boards/python/tuxpaint.py @@ -204,35 +204,35 @@ class Gcompris_tuxpaint: #set already configured values self.config_dict.update(gcompris.get_conf(profile, self.gcomprisBoard)) - self.main_vbox = gcompris.configuration_window(_('%s configuration\n for profile %s') % ('Tuxpaint', profile.name ), + bconfig = gcompris.configuration_window(_('%s configuration\n for profile %s') % ('Tuxpaint', profile.name ), self.apply_callback) - gcompris.boolean_box(_('Inherit fullscreen setting from GCompris'), '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)'), + 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', + 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', + 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', + 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', + 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'])) 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); -- cgit v0.9.1