Commit 2d06ebf0 authored by Yves Combe's avatar Yves Combe
Browse files

gcompris_spin_int configuration utility function, for integer valued spin...

gcompris_spin_int configuration utility function, for integer valued spin buttons. Binded in python (gcompris.spin_int). Sample in colors.c and tuxpaint.py.
parent bd374275
2005-08-14 Yves Combe <yves@ycombe.net>
gcompris_spin_int configuration utility function, for integer valued spin buttons. Binded in python (gcompris.spin_int). Sample in colors.c and tuxpaint.py.
* src/boards/colors.c: (colors_config_start):
* src/boards/py-mod-gcompris.c: (py_gcompris_spin_int):
* src/boards/python/tuxpaint.py:
* src/gcompris/board_config.c: (gcompris_combo_box),
(gcompris_radio_buttons), (spin_changed), (gcompris_spin_int):
* src/gcompris/board_config.h:
2005-08-14 Yves Combe <yves@ycombe.net>
gcompris_radio_buttons python binded. Test sample is in tuxpaint.py (colors.c for C sample).
......
......@@ -155,6 +155,13 @@ colors_config_start(GcomprisBoard *agcomprisBoard,
table,
"key_7");
gcompris_spin_int(" <b><i>Spin</i> Button</b> Sample ",
"color_spin",
2,
52,
5,
12);
g_hash_table_destroy( table);
}
......
......@@ -1260,6 +1260,27 @@ py_gcompris_radio_buttons(PyObject* self, PyObject* args)
return hash_object_to_dict(result);
}
static PyObject*
py_gcompris_spin_int(PyObject* self, PyObject* args)
{
gchar *label;
gchar *key;
gint min, max, step, init;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "ssiiii:gcompris_radio_buttons", &label, &key, &min, &max, &step, &init))
return NULL;
return (PyObject *)pygobject_new((GObject*) \
gcompris_spin_int((const gchar *)label,
key,
min,
max,
step,
init));
}
/****************************************************/
......@@ -1309,6 +1330,7 @@ static PyMethodDef PythonGcomprisModule[] = {
{ "boolean_box", py_gcompris_boolean_box, METH_VARARGS, "gcompris_boolean_box" },
{ "combo_box", py_gcompris_combo_box, METH_VARARGS, "gcompris_combo_box" },
{ "radio_buttons", py_gcompris_radio_buttons, METH_VARARGS, "gcompris_radio_buttons" },
{ "spin_int", py_gcompris_spin_int, METH_VARARGS, "gcompris_spin_int" },
{ NULL, NULL, 0, NULL}
};
......
......@@ -186,6 +186,13 @@ class Gcompris_tuxpaint:
stamps.connect("toggled", self.stamps_changed)
gcompris.spin_int('<b>Spin Button</b> Test',
'spin_test',
-12,
12,
2,
0)
def stamps_changed(self, button):
self.stamps_control.set_sensitive(button.get_active())
......
/* gcompris - board_config.c
*
* Time-stamp: <2005/08/14 14:29:23 yves>
* Time-stamp: <2005/08/14 17:13:47 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -213,7 +213,7 @@ void gcompris_combo_box_changed(GtkComboBox *combobox,
GtkComboBox *gcompris_combo_box(const gchar *label, GList *strings, gchar *key, gint index)
{
GtkWidget *combobox;
GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
GtkWidget *hbox = gtk_hbox_new (FALSE, 8);
GList *list;
GtkWidget *label_combo;
......@@ -273,7 +273,7 @@ static GSList *radio_group = NULL;
static GtkWidget *radio_box;
static gchar *radio_key = NULL;
static gchar *radio_text = NULL;
static radio_init = NULL;
static gchar *radio_init = NULL;
void radio_changed(GtkToggleButton *togglebutton,
gpointer key)
......@@ -377,6 +377,69 @@ GHashTable *gcompris_radio_buttons(const gchar *label,
return buttons;
}
void spin_changed (GtkSpinButton *spinbutton,
gpointer key)
{
gchar *h_key = g_strdup((gchar *) key);
gchar *h_value = g_strdup_printf("%d",gtk_spin_button_get_value_as_int (spinbutton));
g_hash_table_replace (hash_conf, h_key, h_value);
}
GtkSpinButton *gcompris_spin_int(const gchar *label, gchar *key, gint min, gint max, gint step, gint init)
{
GtkWidget *spin;
GtkWidget *hbox = gtk_hbox_new (FALSE, 8);
GtkWidget *label_spin;
gtk_widget_show(hbox);
gtk_box_pack_start (GTK_BOX(main_conf_box),
hbox,
FALSE,
FALSE,
0);
/* Label */
label_spin = gtk_label_new ((gchar *)NULL);
gtk_widget_show(label_spin);
gtk_box_pack_start (GTK_BOX(hbox),
label_spin,
FALSE,
FALSE,
0);
gtk_label_set_justify (GTK_LABEL(label_spin),
GTK_JUSTIFY_RIGHT);
gtk_label_set_markup (GTK_LABEL(label_spin),
(const gchar *)label);
spin = gtk_spin_button_new_with_range ((gdouble )min,
(gdouble )max,
(gdouble )step);
gtk_widget_show(spin);
gtk_box_pack_start (GTK_BOX(hbox),
spin,
FALSE,
FALSE,
0);
gtk_spin_button_set_wrap ( GTK_SPIN_BUTTON(spin), TRUE);
gtk_spin_button_set_numeric ( GTK_SPIN_BUTTON(spin), TRUE);
gtk_spin_button_set_digits ( GTK_SPIN_BUTTON(spin), 0);
gtk_spin_button_set_value ( GTK_SPIN_BUTTON(spin), (gdouble) init);
g_signal_connect (G_OBJECT(spin),
"value-changed",
G_CALLBACK(spin_changed),
key);
return GTK_SPIN_BUTTON(spin);
}
/* Local Variables: */
/* mode:c */
/* eval:(load-library "time-stamp") */
......
/* gcompris - board_config.h
*
* Time-stamp: <2005/08/14 02:35:18 yves>
* Time-stamp: <2005/08/14 16:31:45 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -55,6 +55,13 @@ GHashTable *gcompris_radio_buttons(const gchar *label,
GHashTable *buttons_label,
gchar *init);
GtkSpinButton *gcompris_spin_int(const gchar *label,
gchar *key,
gint min,
gint max,
gint step,
gint 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