Commit 432f7f7d authored by Yves Combe's avatar Yves Combe
Browse files

add gcompris_get_conf(profile, board) to get confs in conguration mode.

tuxpaint launcher configuration is now working ! Yeah!
parent 91a958de
2005-07-23 Yves Combe <yves@ycombe.net>
add gcompris_get_conf(profile, board) to get confs in conguration mode.
tuxpaint launcher configuration is now working ! Yeah!
* src/boards/py-mod-gcompris.c: (py_gcompris_get_conf),
(py_gcompris_set_board_conf):
* src/boards/python/tuxpaint.py:
* src/gcompris/gcompris_db.c: (gcompris_get_conf),
(gcompris_get_board_conf):
* src/gcompris/gcompris_db.h:
2005-07-22 Yves Combe <yves@ycombe.net>
board config_start function now launched correctly. Example is in tuxpaint.py
......
......@@ -901,6 +901,52 @@ py_gcompris_get_board_conf(PyObject* self, PyObject* args)
return pydict;;
}
static PyObject*
py_gcompris_get_conf(PyObject* self, PyObject* args)
{
GList *board_conf;
GList *list;
PyObject *pydict;
PyObject *value;
GcomprisConfPair *pair;
PyObject* pyBoard;
PyObject* pyProfile;
pyGcomprisBoardObject* pyGcomprisBoard;
GcomprisBoard* cGcomprisBoard;
pyGcomprisProfileObject* pyGcomprisProfile;
GcomprisProfile* cGcomprisProfile;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "OO:gcompris.get_conf", &pyProfile ,&pyBoard))
return NULL;
pyGcomprisBoard = (pyGcomprisBoardObject *) pyBoard;
pyGcomprisProfile = (pyGcomprisProfileObject *) pyProfile;
cGcomprisProfile = pyGcomprisProfile->cdata;
cGcomprisBoard = pyGcomprisBoard->cdata;
/* Call the corresponding C function */
board_conf = gcompris_get_conf(cGcomprisProfile, cGcomprisBoard);
pydict = PyDict_New();
for (list = board_conf; list != NULL; list = list->next){
pair = (GcomprisConfPair *) list->data;
if (pair->key==NULL)
continue;
if (pair->value==NULL){
Py_INCREF(Py_None);
value = Py_None;
} else
value = PyString_FromString(pair->value);
PyDict_SetItem(pydict, PyString_FromString(pair->key), value);
}
/* Create and return the result */
return pydict;;
}
/* GcomprisProfile *gcompris_get_current_profile(void); */
static PyObject*
......@@ -955,6 +1001,7 @@ py_gcompris_set_board_conf (PyObject* self, PyObject* args)
&pyProfile, &pyBoard,
&key, &value))
return NULL;
pyGcomprisBoard = (pyGcomprisBoardObject *) pyBoard;
pyGcomprisProfile = (pyGcomprisProfileObject *) pyProfile;
......@@ -1010,6 +1057,7 @@ static PyMethodDef PythonGcomprisModule[] = {
{ "spawn_async", py_gcompris_spawn_async, METH_VARARGS|METH_KEYWORDS, "gcompris_spawn_sync" },
{ "child_watch_add", py_gcompris_child_watch_add, METH_VARARGS|METH_KEYWORDS, "gcompris_child_watch_add" },
{ "get_board_conf", py_gcompris_get_board_conf, METH_VARARGS, "gcompris_get_board_conf" },
{ "get_conf", py_gcompris_get_conf, METH_VARARGS, "gcompris_get_conf" },
{ "set_board_conf", py_gcompris_set_board_conf, METH_VARARGS, "gcompris_set_board_conf" },
{ "get_current_profile", py_gcompris_get_current_profile, METH_VARARGS, "gcompris_get_current_profile" },
{ "get_current_user", py_gcompris_get_current_user, METH_VARARGS, "gcompris_get_current_user" },
......
......@@ -41,6 +41,12 @@ class Gcompris_tuxpaint:
self.gcomprisBoard = gcomprisBoard
pass
def configuration(self, value):
if self.config_dict.has_key(value):
return eval(self.config_dict[value])
else:
return False
def start(self):
# line = os.sys.stdin.readline()
# while (len(line) >1):
......@@ -53,6 +59,8 @@ class Gcompris_tuxpaint:
#board = self
Prop = gcompris.get_properties()
self.config_dict = gcompris.get_board_conf()
self.rootitem = self.gcomprisBoard.canvas.root().add(
gnome.canvas.CanvasGroup,
......@@ -61,9 +69,22 @@ class Gcompris_tuxpaint:
)
options = ['tuxpaint']
if Prop.fullscreen:
if (Prop.fullscreen and self.configuration('fullscreen')):
options.append('--fullscreen')
if self.configuration('disable_shape_rotation'):
options.append('--simpleshapes')
if self.configuration('uppercase_text'):
options.append('--uppercase')
if self.configuration('disable_stamps'):
options.append('--nostamps')
if self.configuration('disable_stamps_control'):
options.append('--nostampcontrols')
gcompris.sound.close()
......@@ -133,8 +154,10 @@ class Gcompris_tuxpaint:
pass
def config_start(self, profile, window):
self.config_window = window
print "config_start", self.gcomprisBoard.name, profile.name, window
self.config_values = {}
self.configure_window = window
self.configure_profile = profile
print "config_start", self.gcomprisBoard.name, profile.name
button_close = gtk.Button(stock=gtk.STOCK_CLOSE)
button_close.connect("clicked", self.configuration_close)
......@@ -144,25 +167,46 @@ class Gcompris_tuxpaint:
button_apply.connect("clicked", self.configuration_apply)
button_apply.show()
main_box = gtk.VBox(False, 8)
main_box.show()
window.add(main_box)
self.configure_main_box = gtk.VBox(False, 8)
self.configure_main_box.show()
window.add(self.configure_main_box)
box_bottom = gtk.HBox(False, 0)
box_bottom.show()
main_box.pack_end(box_bottom, False, False, 0)
self.configure_main_box.pack_end(box_bottom, False, False, 0)
box_bottom.pack_end(button_close, False, False, 0)
box_bottom.pack_start(button_apply, False, False, 0)
self.actual_config = gcompris.get_conf(profile, self.gcomprisBoard)
self.boolean_box('Disable shape rotation', 'disable_shape_rotation')
self.boolean_box('Follow gcompris fullscreen', 'fullscreen')
self.boolean_box('Show Uppercase text only', 'uppercase_text')
self.boolean_box('Disable stamps', 'disable_stamps')
self.boolean_box('Disable stamps control', 'disable_stamps_control')
pass
def configuration_close(self, button):
self.config_window.destroy()
self.configure_window.destroy()
def configuration_apply(self, button):
for key,value in self.config_values.iteritems():
gcompris.set_board_conf(self.configure_profile, self.gcomprisBoard, key, value)
pass
def boolean_box(self, label, value):
button = gtk.CheckButton(label)
button.connect("toggled", self.boolean_callback, value)
button.show()
self.configure_main_box.pack_start(button, False, False, 0)
if self.actual_config.has_key(value):
button.set_active(eval(self.actual_config[value]))
def boolean_callback(self, widget, value):
self.config_values[value] = str(widget.get_active())
def child_callback(fd, cond, data):
#global board
......
/* gcompris - gcompris_db.c
*
* Time-stamp: <2005/07/20 00:54:41 bruno>
* Time-stamp: <2005/07/22 21:10:04 yves>
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -1105,7 +1105,8 @@ void gcompris_set_board_conf(GcomprisProfile *profile,
#define GET_CONF(p, b) \
"SELECT key, value FROM board_profile_conf WHERE profile_id=%d AND board_id=%d;", p, b
GList *gcompris_get_board_conf()
GList *gcompris_get_conf(GcomprisProfile *profile, GcomprisBoard *board)
{
char *zErrMsg;
char **result;
......@@ -1117,8 +1118,8 @@ GList *gcompris_get_board_conf()
GList *list_conf = NULL;
request = g_strdup_printf(GET_CONF(gcompris_get_current_profile()->profile_id,
get_current_gcompris_board()->board_id));
request = g_strdup_printf(GET_CONF(profile->profile_id,
board->board_id));
rc = sqlite3_get_table(gcompris_db,
request,
......@@ -1136,51 +1137,31 @@ GList *gcompris_get_board_conf()
i = ncolumn;
if (nrow != 0){
while (i < (nrow +1)*ncolumn){
GcomprisConfPair *pair = g_malloc0(sizeof(GcomprisConfPair));
while (i < (nrow +1)*ncolumn){
GcomprisConfPair *pair = g_malloc0(sizeof(GcomprisConfPair));
pair->key = g_strdup(result[i++]);
pair->value = g_strdup(result[i++]);
pair->key = g_strdup(result[i++]);
pair->value = g_strdup(result[i++]);
list_conf = g_list_append(list_conf, pair);
}
} else {
/* Get default profile if nothing in gcompris_get_current_profile() */
request = g_strdup_printf(GET_CONF( 1,
get_current_gcompris_board()->board_id));
rc = sqlite3_get_table(gcompris_db,
request,
&result,
&nrow,
&ncolumn,
&zErrMsg
);
if( rc!=SQLITE_OK ){
g_error("SQL error: %s\n", zErrMsg);
}
list_conf = g_list_append(list_conf, pair);
}
g_free(request);
i = ncolumn;
return list_conf;
if (nrow != 0){
while (i < (nrow +1)*ncolumn){
GcomprisConfPair *pair = g_malloc0(sizeof(GcomprisConfPair));
pair->key = g_strdup(result[i++]);
pair->value = g_strdup(result[i++]);
list_conf = g_list_append(list_conf, pair);
}
}
}
}
return list_conf;
GList *gcompris_get_board_conf()
{
GList *list_result;
list_result = gcompris_get_conf(gcompris_get_current_profile(),
get_current_gcompris_board());
if (!list_result)
list_result = gcompris_get_conf(gcompris_get_profile_from_id(1),
get_current_gcompris_board());
return list_result;
}
#define GET_ALL_PROFILES \
......
/* gcompris - gcompris_db.h
*
* Time-stamp: <2005/07/11 22:39:57 yves>
* Time-stamp: <2005/07/22 19:02:14 yves>
*
* Copyright (C) 2005 Bruno Coudoin
*
......@@ -106,6 +106,9 @@ typedef struct {
/* get conf for currents profile and board */
GList *gcompris_get_board_conf();
/* get conf for specific profile and board */
GList *gcompris_get_conf(GcomprisProfile *profile, GcomprisBoard *board);
#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