Commit 646f4f89 authored by Yves Combe's avatar Yves Combe
Browse files

pass gcompris_combo_box init and returned values to string.

add gcompris_combo_locale to add easily a locale choice for board.
parent e5dea154
2005-08-17 Yves Combe <yves@ycombe.net>
pass gcompris_combo_box init and returned values to string.
add gcompris_combo_locale to add easily a locale choice for board.
* src/boards/colors.c: (colors_config_start):
* src/boards/py-mod-gcompris.c: (py_gcompris_combo_box):
* src/boards/python/pythontest.py:
* src/boards/python/tuxpaint.py:
* src/gcompris/board_config.c: (gcompris_combo_box_changed),
(my_strcmp), (gcompris_combo_box), (gcompris_locales_list),
(gcompris_combo_locales):
* src/gcompris/board_config.h:
2005-08-16 Yves Combe <yves@ycombe.net>
suppress previous patch for PLUGIN_DIR, it makes python plugin fail at run.
......
......@@ -145,7 +145,7 @@ colors_config_start(GcomprisBoard *agcomprisBoard,
for (i =0; i< 10; i++)
list = g_list_append( list, g_strdup_printf("value_%d", i));
gcompris_combo_box( "Gcompris ComboBox", list, "combo_key", 3);
gcompris_combo_box( "Gcompris ComboBox", list, "combo_key", NULL);
gcompris_separator();
......@@ -173,26 +173,24 @@ colors_config_start(GcomprisBoard *agcomprisBoard,
g_hash_table_destroy( table);
GList *locales = gcompris_locales_list();
GList *locale = locales;
#define LOC "LC_MESSAGES"
gchar *actual_lang = g_strdup(gcompris_get_locale());
g_warning("locale was set to %s", actual_lang);
gchar *actual_lang = gcompris_get_locale();
printf("%s was set to %s 1 of %d \n", LOC, actual_lang, g_list_length(locales));
while (locale){
gcompris_set_locale(locale->data);
while (locales){
printf("Locale %s exists for gcompris \n", locales->data);
g_warning("Brain in %s : %s",locale->data, _("Brain"));
gcompris_set_locale(locales->data);
printf("Cerveau %s\n", _("Brain"));
locales = locales->next;
locale = locale->next;
}
gcompris_set_locale(actual_lang);
g_free(actual_lang);
//segfault (list too long ? )
//gcompris_combo_box( "Gcompris locales", locales, "locale", 0);
gcompris_combo_box( "Gcompris locales", locales, "locale", "fr");
}
......
......@@ -1141,14 +1141,14 @@ py_gcompris_combo_box(PyObject* self, PyObject* args)
gchar *label;
gchar *key;
gchar *item;
gint index;
gchar *init;
GList *list = NULL;
int i, size;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "sOsi:gcompris_combo_box", &label, &py_list, &key, &index))
if(!PyArg_ParseTuple(args, "sOss:gcompris_combo_box", &label, &py_list, &key, &init))
return NULL;
if (!PyList_Check(py_list)){
......@@ -1168,7 +1168,7 @@ py_gcompris_combo_box(PyObject* self, PyObject* args)
gcompris_combo_box((const gchar *)label,
list,
key,
index));
init));
}
......
......@@ -46,7 +46,7 @@ class Gcompris_pythontest:
# self.colors['line'] s set in init.
# I put here the configuration use
color_name = self.config_colors_list[self.init_conf('color_line', 0)]
color_name = self.init_conf('color_line', 'red')
self.colors['line'] = self.config_colors[color_name]
gcompris.bar_set(0)
......@@ -367,7 +367,7 @@ class Gcompris_pythontest:
gcompris.combo_box(_('Color line'),
self.config_colors_list,
'color_line',
self.init_conf('color_line', 0)
self.init_conf_str('color_line', 'red')
)
self.color_choice.set_sensitive(not self.init_conf('disable_line', True))
......
......@@ -43,11 +43,11 @@ class Gcompris_tuxpaint:
self.gcomprisBoard = gcomprisBoard
pass
def configuration(self, value):
def configuration(self, value, init):
if self.config_dict.has_key(value):
return eval(self.config_dict[value])
else:
return False
return init
def start(self):
# line = os.sys.stdin.readline()
......@@ -72,19 +72,19 @@ class Gcompris_tuxpaint:
options = ['tuxpaint']
if (Prop.fullscreen and self.configuration('fullscreen')):
if (Prop.fullscreen and self.configuration('fullscreen', True)):
options.append('--fullscreen')
if self.configuration('disable_shape_rotation'):
if self.configuration('disable_shape_rotation', False):
options.append('--simpleshapes')
if self.configuration('uppercase_text'):
if self.configuration('uppercase_text', False):
options.append('--uppercase')
if self.configuration('disable_stamps'):
if self.configuration('disable_stamps', False):
options.append('--nostamps')
if self.configuration('disable_stamps_control'):
if self.configuration('disable_stamps_control', False):
options.append('--nostampcontrols')
gcompris.sound.close()
......@@ -164,23 +164,23 @@ class Gcompris_tuxpaint:
self.config_dict = gcompris.get_conf(profile, self.gcomprisBoard)
gcompris.boolean_box(_('Follow gcompris fullscreen'), 'fullscreen', self.configuration('fullscreen'))
gcompris.boolean_box(_('Follow gcompris fullscreen'), 'fullscreen', self.configuration('fullscreen', True))
gcompris.separator()
gcompris.boolean_box(_('Disable shape rotation'), 'disable_shape_rotation', self.configuration('disable_shape_rotation'))
gcompris.boolean_box(_('Disable shape rotation'), 'disable_shape_rotation', self.configuration('disable_shape_rotation', False))
gcompris.separator()
gcompris.boolean_box(_('Show Uppercase text only'), 'uppercase_text', self.configuration('uppercase_text'))
gcompris.boolean_box(_('Show Uppercase text only'), 'uppercase_text', self.configuration('uppercase_text', False))
gcompris.separator()
stamps = gcompris.boolean_box(_('Disable stamps'), 'disable_stamps', self.configuration('disable_stamps'))
stamps = gcompris.boolean_box(_('Disable stamps'), 'disable_stamps', self.configuration('disable_stamps', False))
stamps.connect("toggled", self.stamps_changed)
self.stamps_control = gcompris.boolean_box('Disable stamps control', 'disable_stamps_control', self.configuration('disable_stamps_control'))
self.stamps_control.set_sensitive(not self.configuration('disable_stamps'))
self.stamps_control = gcompris.boolean_box('Disable stamps control', 'disable_stamps_control', self.configuration('disable_stamps_control', False))
self.stamps_control.set_sensitive(not self.configuration('disable_stamps', False))
def stamps_changed(self, button):
self.stamps_control.set_sensitive(not button.get_active())
......
/* gcompris - board_config.c
*
* Time-stamp: <2005/08/16 00:48:51 yves>
* Time-stamp: <2005/08/17 00:04:43 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -21,6 +21,7 @@
#include "gcompris.h"
#define COMBOBOX_COL_MAX 15
static GcomprisBoard *config_board;
......@@ -220,20 +221,30 @@ void gcompris_combo_box_changed(GtkComboBox *combobox,
{
gchar *the_key = g_strdup((gchar *)key);
gchar *value = g_strdup_printf("%d", gtk_combo_box_get_active (combobox));
gchar *value = g_strdup_printf("%s", gtk_combo_box_get_active_text (combobox));
g_hash_table_replace(hash_conf, (gpointer) the_key, (gpointer) value);
}
GtkComboBox *gcompris_combo_box(const gchar *label, GList *strings, gchar *key, gint index)
inline int my_strcmp(gchar *a, gchar *b) { return strcmp( a, b); }
GtkComboBox *gcompris_combo_box(const gchar *label, GList *strings, gchar *key, gchar *init)
{
GtkWidget *combobox;
GtkWidget *hbox = gtk_hbox_new (FALSE, 8);
GList *list;
GtkWidget *label_combo;
gint init_index = 0;
gtk_widget_show(hbox);
if (init)
init_index = g_list_position ( strings, g_list_find_custom ( strings,(gconstpointer) init, (GCompareFunc) my_strcmp));
if (init_index < 0)
init_index=0;
gtk_widget_show(hbox);
gtk_box_pack_start (GTK_BOX(main_conf_box),
hbox,
FALSE,
......@@ -271,9 +282,12 @@ GtkComboBox *gcompris_combo_box(const gchar *label, GList *strings, gchar *key,
gtk_combo_box_append_text (GTK_COMBO_BOX(combobox),
list->data);
if (g_list_length(strings) > COMBOBOX_COL_MAX)
gtk_combo_box_set_wrap_width (GTK_COMBO_BOX(combobox),
g_list_length(strings) / COMBOBOX_COL_MAX +1 );
gtk_combo_box_set_active (GTK_COMBO_BOX(combobox),
index);
init_index);
g_signal_connect(G_OBJECT(combobox),
"changed",
......@@ -510,6 +524,14 @@ GList *gcompris_locales_list(){
return locales;
}
GtkComboBox *gcompris_combo_locales(gchar *key, gchar *init)
{
gcompris_combo_box(_("Select the language\n to use in the board"),
gcompris_locales_list(),
key,
init);
}
/* Local Variables: */
/* mode:c */
/* eval:(load-library "time-stamp") */
......
/* gcompris - board_config.h
*
* Time-stamp: <2005/08/15 17:27:18 yves>
* Time-stamp: <2005/08/16 23:25:14 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -41,7 +41,7 @@ GtkVBox *gcompris_configuration_window(gchar *label, GcomprisConfCallback callba
GtkCheckButton *gcompris_boolean_box(const gchar *label, gchar *key, gboolean initial_value);
GtkComboBox *gcompris_combo_box(const gchar *label, GList *strings, gchar *key, gint index);
GtkComboBox *gcompris_combo_box(const gchar *label, GList *strings, gchar *key, gchar *init);
/* Params: */
/* - Label */
......@@ -66,6 +66,8 @@ GtkHSeparator *gcompris_separator();
GList *gcompris_locales_list();
GtkComboBox *gcompris_combo_locales(gchar *key, gchar *init);
#endif
/* Local Variables: */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment