Commit 067c0454 authored by Yves Combe's avatar Yves Combe
Browse files

fix Makefile.am in src/boards/python/admin/.

fix Group struct definition.
add functions for admin submodule (gcompris_get_group_from_id and gcompris_get_groups_list).
parent 3d865ace
2005-07-19 Yves Combe <yves@ycombe.net>
fix Makefile.am in src/boards/python/admin/.
fix Group struct definition.
add functions for admin submodule (gcompris_get_group_from_id and gcompris_get_groups_list).
* src/boards/py-mod-gcompris.c: (python_gcompris_module_init):
* src/boards/python/admin/Makefile.am:
* src/boards/python/admin/board_list.py:
* src/boards/python/admin/module_boards.py:
* src/gcompris/gcompris_db.c: (gcompris_get_group_from_id),
(gcompris_get_groups_list):
* src/gcompris/profile.h:
2005-07-18 Bruno coudoin <bruno.coudoin@free.fr>
Improved the gcompris editor. Now columns are of fixed size which
......
......@@ -1059,9 +1059,7 @@ void python_gcompris_module_init(void)
python_gcompris_timer_module_init();
python_gcompris_utils_module_init();
python_gcompris_anim_module_init();
printf("python_gcompris_admin_module_init \n");
python_gcompris_admin_module_init();
printf("python_gcompris_admin_module_init END\n");
}
/* Some usefull code parts ... */
......
......@@ -10,8 +10,12 @@ dist_python_DATA= \
module_profiles.py \
module_boards.py \
user_list.py \
group_edit.py \
group_list.py \
group_user_list.py \
class_list.py \
class_edit.py \
board_list.py \
class_edit.py
constants.py
......@@ -22,6 +22,7 @@ import gnome.canvas
import gcompris
import gcompris.utils
import gcompris.skin
import gcompris.admin
import gtk
import gtk.gdk
import gobject
......@@ -194,7 +195,7 @@ class Board_list:
gobject.TYPE_STRING
)
boards_list = gcompris.get_boards_list()
boards_list = gcompris.admin.get_boards_list()
self.add_boards_in_model(model, boards_list)
return model
......
......@@ -22,6 +22,7 @@ import gnome.canvas
import gcompris
import gcompris.utils
import gcompris.skin
import gcompris.admin
import gtk
import gtk.gdk
from gettext import gettext as _
......@@ -64,7 +65,7 @@ class Boards(module.Module):
)
boards = []
for board in gcompris.get_boards_list():
for board in gcompris.admin.get_boards_list():
if board.is_configurable:
boards.append(board)
......
/* gcompris - gcompris_db.c
*
* Time-stamp: <2005/07/18 15:19:39 yves>
* Time-stamp: <2005/07/19 01:00:00 yves>
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -1312,14 +1312,118 @@ GList *gcompris_get_profiles_list()
#endif
}
#define GROUP_FROM_ID(n) \
"SELECT name, class_id, description FROM groups WHERE group_id=%d;",n
GcomprisGroup *gcompris_get_group_from_id(int group_id)
{
#ifdef USE_SQLITE
char *zErrMsg;
char **result;
int rc;
int nrow;
int ncolumn;
gchar *request;
int i;
GList *users = NULL;
GcomprisGroup *group = NULL;
request = g_strdup_printf(GROUP_FROM_ID(group_id));
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);
if (nrow == 0){
g_warning(_("No group with id %d"), group_id);
return NULL;
} else {
i = ncolumn;
group = g_malloc0(sizeof(GcomprisGroup));
group->group_id = group_id;
group->name = g_strdup(result[i++]);
group->class_id = atoi(result[i++]);
group->description = g_strdup(result[i++]);
}
group->user_ids = gcompris_get_users_from_group(group_id);
return group ;
#else
return NULL;
#endif
}
#define GET_ALL_GROUPS \
"SELECT group_id, name, class_id, description FROM groups;"
GList *gcompris_get_groups_list()
{
#ifdef USE_SQLITE
GList *groups_list;
char *zErrMsg;
char **result;
int rc;
int nrow;
int ncolumn;
gchar *request;
int i;
GList *users = NULL;
GcomprisGroup *group = NULL;
rc = sqlite3_get_table(gcompris_db,
GET_ALL_GROUPS,
&result,
&nrow,
&ncolumn,
&zErrMsg
);
if( rc!=SQLITE_OK ){
g_error("SQL error: %s\n", zErrMsg);
}
if (nrow == 0){
g_warning(_("No groups !"));
return NULL;
} else {
i = ncolumn;
while ( i < (nrow +1)*ncolumn) {
group = g_malloc0(sizeof(GcomprisGroup));
group->group_id = atoi(result[i++]);
group->name = g_strdup(result[i++]);
group->class_id = atoi(result[i++]);
group->description = g_strdup(result[i++]);
group->user_ids = gcompris_get_users_from_group(group->group_id);
groups_list = g_list_append(groups_list, group);
}
}
return groups_list;
#else
return NULL;
#endif
}
GcomprisBoard *gcompris_get_board_from_id(int board_id)
......
/* gcompris - profile.h
*
* Time-stamp: <2005/07/11 13:17:30 yves>
* Time-stamp: <2005/07/19 00:00:32 yves>
*
* Copyright (C) 2005 Bruno Coudoin
*
......@@ -69,7 +69,7 @@ struct _GcomprisGroup {
gchar *name;
/* GcomprisClass containing the group */
gint *class_id;
gint class_id;
/* list of GComprisUser user_id */
GList *user_ids;
......
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