Commit ab21485a authored by Yves Combe's avatar Yves Combe
Browse files

gcompris_combo_box (gcompris.combo_box) configuration fonction for text combobox.

parent 1458f650
2005-07-26 Yves Combe <yves@ycombe.net>
gcompris_combo_box (gcompris.combo_box) configuration fonction for text combobox.
* src/boards/colors.c: (colors_config_start):
* src/boards/py-mod-gcompris.c: (py_gcompris_boolean_box),
(py_gcompris_combo_box):
* src/boards/python/tuxpaint.py:
* src/gcompris/board_config.c: (gcompris_configuration_window),
(gcompris_boolean_box), (gcompris_combo_box_changed),
(gcompris_combo_box):
* src/gcompris/board_config.h:
2005-07-25 Yves Combe <yves@ycombe.net>
fix compilation error (GComprisProfile in py-gcompris-properties.c)
......
......@@ -121,11 +121,18 @@ colors_config_start(GcomprisBoard *agcomprisBoard,
label = g_strdup_printf("<b>%s</b> configuration\n for profile <b>%s</b>",
agcomprisBoard->name, aProfile->name);
gcompris_configuration_window(label, conf_apply);
gcompris_configuration_window(label, (GcomprisConfCallback )conf_apply);
g_free(label);
gcompris_boolean_box("Test Check Box", "key1", TRUE);
GList *list = NULL;
int i;
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);
}
/* ======================= */
......
......@@ -1110,10 +1110,49 @@ py_gcompris_boolean_box(PyObject* self, PyObject* args)
return NULL;
/* Call the corresponding C function */
return (PyObject *)pygobject_new(gcompris_boolean_box((const gchar *)label, key, PyObject_IsTrue(py_bool)));
return (PyObject *)pygobject_new((GObject*) \
gcompris_boolean_box((const gchar *)label, key, PyObject_IsTrue(py_bool)));
}
/* GtkComboBox *gcompris_combo_box(const gchar *label, GList *strings, gchar *key, gint index); */
static PyObject*
py_gcompris_combo_box(PyObject* self, PyObject* args)
{
PyObject *py_list;
gchar *label;
gchar *key;
gchar *item;
gint index;
GList *list = NULL;
int i, size;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "sOsi:gcompris_combo_box", &label, &py_list, &key, &index))
return NULL;
if (!PyList_Check(py_list)){
PyErr_SetString(PyExc_TypeError,
"gcompris_combo_box second argument must be a list");
return NULL;
}
size = PyList_Size (py_list);
for (i=0; i < size; i ++)
list = g_list_append( list,
PyString_AsString( PyList_GetItem( py_list, i)));
/* Call the corresponding C function */
return (PyObject *)pygobject_new((GObject*) \
gcompris_combo_box((const gchar *)label,
list,
key,
index));
}
......@@ -1163,6 +1202,7 @@ static PyMethodDef PythonGcomprisModule[] = {
{ "get_current_user", py_gcompris_get_current_user, METH_VARARGS, "gcompris_get_current_user" },
{ "configuration_window", py_gcompris_configuration_window, METH_VARARGS, "gcompris_configuration_window" },
{ "boolean_box", py_gcompris_boolean_box, METH_VARARGS, "gcompris_boolean_box" },
{ "combo_box", py_gcompris_combo_box, METH_VARARGS, "gcompris_combo_box" },
{ NULL, NULL, 0, NULL}
};
......
......@@ -170,8 +170,10 @@ class Gcompris_tuxpaint:
gcompris.boolean_box('Disable stamps', 'disable_stamps', self.configuration('disable_stamps'))
gcompris.boolean_box('Disable stamps control', 'disable_stamps_control', self.configuration('disable_stamps_control'))
gcompris.combo_box('ComboBox Test ', ['red', 'blue', 'green'], 'combo_test', 1)
def apply_callback(self,table):
print table
for key,value in table.iteritems():
gcompris.set_board_conf(self.configure_profile, self.gcomprisBoard, key, value)
......
/* gcompris - board_config.c
*
* Time-stamp: <2005/07/25 16:23:19 yves>
* Time-stamp: <2005/07/26 00:04:05 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -87,7 +87,7 @@ GtkVBox *gcompris_configuration_window(gchar *label, GcomprisConfCallback callba
{
GtkButton *button;
GtkHBox *footer;
GtkLabel *header;
GtkWidget *header;
/* init static values or callbacks */
Confcallback = callback;
......@@ -147,7 +147,7 @@ GtkVBox *gcompris_configuration_window(gchar *label, GcomprisConfCallback callba
/* Label header */
header = gtk_label_new (NULL);
header = gtk_label_new ((gchar *)NULL);
gtk_widget_show(header);
gtk_box_pack_start (GTK_BOX(main_conf_box),
header,
......@@ -201,6 +201,74 @@ GtkCheckButton *gcompris_boolean_box(const gchar *label, gchar *key, gboolean in
return GTK_CHECK_BUTTON(CheckBox);
}
void gcompris_combo_box_changed(GtkComboBox *combobox,
gpointer key)
{
gchar *the_key = g_strdup((gchar *)key);
gchar *value = 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)
{
GtkWidget *combobox;
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
GList *list;
GtkWidget *label_combo;
gtk_widget_show(hbox);
gtk_box_pack_start (GTK_BOX(main_conf_box),
hbox,
FALSE,
FALSE,
0);
/* Label */
label_combo = gtk_label_new ((gchar *)NULL);
gtk_widget_show(label_combo);
gtk_box_pack_start (GTK_BOX(hbox),
label_combo,
FALSE,
FALSE,
0);
gtk_label_set_justify (GTK_LABEL(label_combo),
GTK_JUSTIFY_RIGHT);
gtk_label_set_markup (GTK_LABEL(label_combo),
(const gchar *)label);
combobox = gtk_combo_box_new_text();
gtk_widget_show(combobox);
gtk_box_pack_start (GTK_BOX(hbox),
combobox,
FALSE,
FALSE,
0);
for (list = strings; list != NULL; list = list->next)
gtk_combo_box_append_text (GTK_COMBO_BOX(combobox),
list->data);
gtk_combo_box_set_active (GTK_COMBO_BOX(combobox),
index);
g_signal_connect(G_OBJECT(combobox),
"changed",
G_CALLBACK(gcompris_combo_box_changed),
key);
return GTK_COMBO_BOX(combobox);
}
/* Local Variables: */
/* mode:c */
/* eval:(load-library "time-stamp") */
......
/* gcompris - board_config.h
*
* Time-stamp: <2005/07/25 15:33:43 yves>
* Time-stamp: <2005/07/26 00:04:29 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -41,6 +41,8 @@ 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);
#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