Commit 55bad014 authored by Yves Combe's avatar Yves Combe
Browse files

fix stripping trailing space in profile names (bruno).

fix get_user to pass None in python if user = NULL.
fix pythontest check a user is logged or not.
put buttons in boards_list to make global conf toolbox.
fix get_conf to check first global conf for profile (board_id = -1), then default conf for boards (profile_id = 1), yhen profile & board conf.
parent 5691d137
2005-08-21 Yves Combe,,, <set EMAIL_ADDRESS environment variable>
fix stripping trailing space in profile names (bruno).
fix get_user to pass None in python if user = NULL.
fix pythontest check a user is logged or not.
put buttons in boards_list to make global conf toolbox.
fix get_conf to check first global conf for profile (board_id = -1), then default conf for boards (profile_id = 1), yhen profile & board conf.
* src/boards/py-mod-admin.c: (py_gcompris_set_current_user),
(py_gcompris_get_current_user):
* src/boards/python/admin/board_list.py:
* src/boards/python/admin/profile_edit.py:
* src/boards/python/pythontest.py:
* src/gcompris/gcompris_db.c: (gcompris_get_conf_with_table),
(gcompris_get_conf), (gcompris_get_board_conf):
2005-08-21 Bruno coudoin <bruno.coudoin@free.fr>
* src/boards/python/sudoku.py: Implemented support for non 9x9 sudoku
......
#include <Python.h>
#include <pygobject.h>
#include "gcompris/gcompris.h"
......@@ -303,7 +304,7 @@ py_gcompris_set_current_user (PyObject* self, PyObject* args)
GcomprisUser *user;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "O:gcompris.get_current_user", &pyObject_user))
if(!PyArg_ParseTuple(args, "O:gcompris.set_current_user", &pyObject_user))
return NULL;
pyUser = (pyGcomprisUserObject *) pyObject_user;
......@@ -333,7 +334,12 @@ py_gcompris_get_current_user (PyObject* self, PyObject* args)
user = gcompris_get_current_user ();
/* Create and return the result */
return gcompris_new_pyGcomprisUserObject((GcomprisUser*) user);
if (!user) {
Py_INCREF(Py_None);
return Py_None;
}
else
return gcompris_new_pyGcomprisUserObject((GcomprisUser*) user);
}
static PyMethodDef PythonGcomprisAdminModule[] = {
......
......@@ -158,6 +158,21 @@ class Board_list:
self.button_unselect_all.show()
box3.pack_start(self.button_unselect_all, False, False, 0)
self.button_locales = gtk.Button('Locales')
self.button_locales.connect("clicked", self.locales)
self.button_locales.show()
box3.pack_end(self.button_locales, False, False, 0)
self.button_locales_sound = gtk.Button('Locales_sound')
self.button_locales_sound.connect("clicked", self.locales_sound)
self.button_locales_sound.show()
box3.pack_end(self.button_locales_sound, False, False, 0)
self.button_wordlist = gtk.Button('Wordlist')
self.button_wordlist.connect("clicked", self.wordlist)
self.button_wordlist.show()
box3.pack_end(self.button_wordlist, False, False, 0)
# -------------------
# Board Management
......@@ -594,3 +609,18 @@ class Board_list:
self.update_selected(row.model, row.path)
########################################################
########################################################
def locales(self, button):
print "__locales__"
def locales_sound(self, button):
print "__locales_sound__"
def wordlist(self, button):
print "__wordlist__"
......@@ -370,7 +370,7 @@ class ProfileEdit(gtk.Window):
def ok(self, button):
# Tell the user he must provide enough information
if(self.entry_profile.get_text() == ""):
if(self.entry_profile.get_text().strip() == ""):
dialog = gtk.MessageDialog(None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
......@@ -384,7 +384,7 @@ class ProfileEdit(gtk.Window):
#
profile_data = (self.profile_id,
self.entry_profile.get_text(),
self.entry_profile.get_text().strip(),
self.entry_description.get_text()
)
......
......@@ -40,8 +40,9 @@ class Gcompris_pythontest:
def start(self):
logged = gcompris.admin.get_current_user()
print "User Logged in:"
print " ", logged.login, logged.firstname, logged.lastname
if logged:
print "User Logged in:"
print " ", logged.login, logged.firstname, logged.lastname
self.gcomprisBoard.level=1
self.gcomprisBoard.maxlevel=1
......@@ -459,7 +460,7 @@ class Gcompris_pythontest:
def init_config(self):
default_config = { 'disable_line' : 'True',
default_config = { 'disable_line' : 'False',
'color_line' : 'red',
'distance_circle' : '100',
'pattern' : 'circle',
......
/* gcompris - gcompris_db.c
*
* Time-stamp: <2005/08/19 23:34:48 yves>
* Time-stamp: <2005/08/21 00:19:51 yves>
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -1182,7 +1182,7 @@ 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
GHashTable *gcompris_get_conf(GcomprisProfile *profile, GcomprisBoard *board)
GHashTable *gcompris_get_conf_with_table(int profile_id, int board_id, GHashTable *table )
{
char *zErrMsg;
char **result;
......@@ -1192,10 +1192,10 @@ GHashTable *gcompris_get_conf(GcomprisProfile *profile, GcomprisBoard *board)
gchar *request;
int i;
GHashTable *hash_conf = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
GHashTable *hash_conf = table;
request = g_strdup_printf(GET_CONF(profile->profile_id,
board->board_id));
request = g_strdup_printf(GET_CONF(profile_id,
board_id));
rc = sqlite3_get_table(gcompris_db,
request,
......@@ -1220,51 +1220,36 @@ GHashTable *gcompris_get_conf(GcomprisProfile *profile, GcomprisBoard *board)
}
sqlite3_free_table(result);
if (nrow >0) {
/* GET GENRAL CONF */
request = g_strdup_printf(GET_CONF(profile->profile_id,
-1));
rc = sqlite3_get_table(gcompris_db,
request,
&result,
&nrow,
&ncolumn,
&zErrMsg
);
if( rc!=SQLITE_OK ){
g_error("SQL error: %s\n", zErrMsg);
}
g_free(request);
i = ncolumn;
while (i < (nrow +1)*ncolumn){
g_hash_table_replace (hash_conf,
g_strdup(result[i++]),
g_strdup(result[i++]));
}
sqlite3_free_table(result);
}
return hash_conf;
}
GHashTable *gcompris_get_board_conf()
GHashTable *gcompris_get_conf(GcomprisProfile *profile, GcomprisBoard *board )
{
GHashTable *hash_result;
GHashTable *hash_result = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
hash_result = gcompris_get_conf(gcompris_get_current_profile(),
get_current_gcompris_board());
return gcompris_get_conf_with_table( profile->profile_id, board->board_id, hash_result) ;
if (g_hash_table_size(hash_result)==0)
hash_result = gcompris_get_conf(gcompris_get_profile_from_id(1),
get_current_gcompris_board());
}
GHashTable *gcompris_get_board_conf()
{
GHashTable *hash_result = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
/* conf values for profile (board independant) */
hash_result = gcompris_get_conf_with_table(gcompris_get_current_profile()->profile_id,
-1,
hash_result);
/* conf values for default profile and current board */
hash_result = gcompris_get_conf_with_table(1,
get_current_gcompris_board()->board_id,
hash_result);
/* conf value for current profile and current board */
hash_result = gcompris_get_conf_with_table(gcompris_get_current_profile()->profile_id,
get_current_gcompris_board()->board_id,
hash_result);
return hash_result;
}
......
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