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

fix login launch. test locales in click_on_letter add get global (profile

fix login launch.
test locales in click_on_letter
add get global (profile but not board dependant)  conf in get_conf
parent 080bcb6a
2005-08-20 Yves Combe <yves@ycombe.net>
fix login launch.
test locales in click_on_letter
add get global (profile but not board dependant) conf in get_conf
* src/boards/click_on_letter.c: (start_board), (end_board),
(save_table), (conf_ok), (config_start), (config_stop):
* src/gcompris/board_config.c: (check_key),
(gcompris_close_board_conf), (gcompris_boolean_box),
(gcompris_combo_box), (gcompris_radio_buttons),
(gcompris_spin_int), (gcompris_combo_locales),
(gcompris_change_locale), (gcompris_combo_locales_asset):
* src/gcompris/gcompris.c: (setup_window):
* src/gcompris/gcompris_db.c: (gcompris_get_conf):
2005-08-20 Bruno coudoin <bruno.coudoin@free.fr>
......
......@@ -43,6 +43,10 @@ static void process_ok(void);
static void highlight_selected(GnomeCanvasItem *);
static void game_won(void);
static void repeat(void);
static void config_start(GcomprisBoard *agcomprisBoard,
GcomprisProfile *aProfile);
static void config_stop(void);
#define VERTICAL_SEPARATION 408
#define HORIZONTAL_SEPARATION 0
......@@ -93,8 +97,8 @@ static BoardPlugin menu_bp =
set_level,
NULL,
repeat,
NULL,
NULL
config_start,
config_stop
};
/*
......@@ -127,6 +131,13 @@ static void pause_board (gboolean pause)
static void start_board (GcomprisBoard *agcomprisBoard)
{
GHashTable *config = gcompris_get_board_conf();
gcompris_change_locale(g_hash_table_lookup( config, "locale"));
g_hash_table_destroy(config);
if(!sounds_are_fine("a"))
return;
......@@ -160,6 +171,9 @@ static void end_board ()
gcompris_score_end();
click_on_letter_destroy_all_items();
}
gcompris_reset_locale();
gcomprisBoard = NULL;
}
......@@ -482,3 +496,65 @@ static void highlight_selected(GnomeCanvasItem * item) {
}
}
/* ************************************* */
/* * Configuration * */
/* ************************************* */
/* ======================= */
/* = config_start = */
/* ======================= */
static GcomprisProfile *profile_conf;
static GcomprisBoard *board_conf;
GHFunc save_table (gpointer key,
gpointer value,
gpointer user_data)
{
gcompris_set_board_conf ( profile_conf,
board_conf,
(gchar *) key,
(gchar *) value);
}
static GcomprisConfCallback conf_ok(GHashTable *table)
{
g_hash_table_foreach(table, (GHFunc) save_table, NULL);
board_conf = NULL;
profile_conf = NULL;
}
static void
config_start(GcomprisBoard *agcomprisBoard,
GcomprisProfile *aProfile)
{
board_conf = agcomprisBoard;
profile_conf = aProfile;
gcompris_configuration_window( g_strdup_printf("<b>%s</b> configuration\n for profile <b>%s</b>",
agcomprisBoard->name,
aProfile->name),
(GcomprisConfCallback )conf_ok);
/* init the combo to previously saved value */
GHashTable *config = gcompris_get_conf( profile_conf, board_conf);
gchar *locale = g_hash_table_lookup( config, "locale");
gcompris_combo_locales("locale", locale);
}
/* ======================= */
/* = config_stop = */
/* ======================= */
static void
config_stop()
{
}
/* gcompris - board_config.c
*
* Time-stamp: <2005/08/19 02:21:14 yves>
* Time-stamp: <2005/08/19 23:18:57 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -69,6 +69,13 @@ static GHashTable *hash_conf = NULL;
static GcomprisConfCallback Confcallback = NULL;
static gchar *label_markup = NULL;
static void check_key(gchar *key)
{
if (strncmp(key, "__", 2) == 0)
g_error(" Key beginning by __ are forbiden ! Change %s !", key);
}
void gcompris_close_board_conf (GtkButton *button,
gpointer user_data)
{
......@@ -77,7 +84,7 @@ void gcompris_close_board_conf (GtkButton *button,
hash_conf = NULL;
Confcallback = NULL;
g_free(label_markup);
}
}
void gcompris_apply_board_conf (GtkButton *button,
gpointer user_data)
......@@ -199,6 +206,8 @@ void gcompris_boolean_box_toggled (GtkToggleButton *togglebutton,
GtkCheckButton *gcompris_boolean_box(const gchar *label, gchar *key, gboolean initial_value)
{
check_key( key);
GtkWidget *CheckBox = gtk_check_button_new_with_label (label);
gtk_widget_show(CheckBox);
......@@ -235,6 +244,8 @@ inline int my_strcmp(gchar *a, gchar *b) { return strcmp( a, b); }
GtkComboBox *gcompris_combo_box(const gchar *label, GList *strings, gchar *key, gchar *init)
{
check_key( key);
GtkWidget *combobox;
GtkWidget *hbox = gtk_hbox_new (FALSE, 8);
GList *list;
......@@ -366,6 +377,8 @@ GHashTable *gcompris_radio_buttons(const gchar *label,
GHashTable *buttons_label,
gchar *init)
{
check_key( key);
GtkWidget *radio_label;
GHashTable *buttons = g_hash_table_new_full (g_str_hash,
......@@ -421,6 +434,8 @@ void spin_changed (GtkSpinButton *spinbutton,
GtkSpinButton *gcompris_spin_int(const gchar *label, gchar *key, gint min, gint max, gint step, gint init)
{
check_key( key);
GtkWidget *spin;
GtkWidget *hbox = gtk_hbox_new (FALSE, 8);
GtkWidget *label_spin;
......@@ -546,6 +561,8 @@ void gcompris_combo_locales_changed(GtkComboBox *combobox,
GtkComboBox *gcompris_combo_locales(gchar *key, gchar *init)
{
check_key( key);
GtkWidget *combobox;
GtkWidget *hbox = gtk_hbox_new (FALSE, 8);
GList *list, *strings;
......@@ -620,7 +637,7 @@ GtkComboBox *gcompris_combo_locales(gchar *key, gchar *init)
static gchar *current_locale = NULL;
void gcompris_change_locale(gchar *locale)
{
if (strcmp(locale, "NULL") == 0)
if ((!locale) || strcmp(locale, "NULL") == 0)
return;
current_locale = g_strdup(gcompris_get_locale());
......@@ -670,6 +687,8 @@ GList *gcompris_get_locales_asset_list(gchar *dataset, gchar* categories,
GtkComboBox *gcompris_combo_locales_asset(const gchar *label, gchar *key, gchar *init, gchar *dataset, gchar* categories, gchar* mimetype, gchar *file)
{
check_key( key);
GtkWidget *combobox;
GtkWidget *hbox = gtk_hbox_new (FALSE, 8);
GList *list, *strings;
......
......@@ -639,14 +639,24 @@ static void setup_window ()
* (the login screen is a board that uppon login completion
* starts the menu)
*/
if(properties->profile)
{
board_to_start = gcompris_get_board_from_section("/login/login");
}
else
if(properties->profile && properties->profile->group_ids)
{
gboolean found = FALSE;
GList *group_id;
for (group_id = properties->profile->group_ids; group_id != NULL; group_id = group_id->next)
if (g_list_length(gcompris_get_users_from_group( *((int *) group_id->data))) > 0){
found = TRUE;
break;
}
/* No profile start normally */
board_to_start = gcompris_get_board_from_section(properties->root_menu);
if (found)
board_to_start = gcompris_get_board_from_section("/login/login");
else
board_to_start = gcompris_get_board_from_section(properties->root_menu);
}
}
......
/* gcompris - gcompris_db.c
*
* Time-stamp: <2005/07/25 00:29:30 bruno>
* Time-stamp: <2005/08/19 23:34:48 yves>
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -1182,7 +1182,6 @@ 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)
{
char *zErrMsg;
......@@ -1222,6 +1221,37 @@ 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;
}
......
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