summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/fs.c2
-rw-r--r--src/internal.h2
-rw-r--r--src/librcc.c1
-rw-r--r--src/lng.c21
-rw-r--r--src/lngconfig.c34
-rw-r--r--src/lngconfig.h3
-rw-r--r--src/rccconfig.c4
-rw-r--r--src/rccxml.c2
-rw-r--r--ui/gtk.c20
-rw-r--r--ui/librccui.c9
10 files changed, 77 insertions, 21 deletions
diff --git a/src/fs.c b/src/fs.c
index 2906850..1f61a9e 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -152,7 +152,6 @@ int rccFS1(rcc_context ctx, const char *fspath, char **prefix, char **name) {
}
}
- puts("--");
if (rccFS0(ctx, fspath, result, prefix, name)) {
*prefix = NULL;
*name = result;
@@ -160,7 +159,6 @@ int rccFS1(rcc_context ctx, const char *fspath, char **prefix, char **name) {
if ((path)&&(filename)) return 0;
return 2;
}
- puts("++");
if ((path)&&(filename)) free(result);
diff --git a/src/internal.h b/src/internal.h
index 8a99ca0..258e6b0 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -44,6 +44,8 @@ struct rcc_context_t {
unsigned char configure;
rcc_language_config current_config;
rcc_language_id current_language;
+
+ rcc_language_id default_language;
db4_context db4ctx;
diff --git a/src/librcc.c b/src/librcc.c
index 2e2a49e..34e0e3d 100644
--- a/src/librcc.c
+++ b/src/librcc.c
@@ -164,6 +164,7 @@ rcc_context rccCreateContext(const char *locale_variable, unsigned int max_langu
}
ctx->current_language = 0;
+ ctx->default_language = 0;
if (locale_variable) {
if (strlen(locale_variable)>=RCC_MAX_VARIABLE_CHARS) {
diff --git a/src/lng.c b/src/lng.c
index e6b5a73..8625fb8 100644
--- a/src/lng.c
+++ b/src/lng.c
@@ -39,14 +39,31 @@ rcc_language_id rccGetLanguageByName(rcc_context ctx, const char *name) {
static rcc_language_id rccGetDefaultLanguage(rcc_context ctx) {
int err;
unsigned int i;
+ rcc_option_value clo;
+ rcc_engine_ptr *engines;
+ rcc_language_config config;
char stmp[RCC_MAX_LANGUAGE_CHARS+1];
+ printf("DL: %lu\n", ctx->default_language);
+ if (ctx->default_language) return ctx->default_language;
+
if (!rccLocaleGetLanguage(stmp, ctx->locale_variable, RCC_MAX_LANGUAGE_CHARS)) {
for (i=0;ctx->languages[i];i++) {
if (!strcmp(ctx->languages[i]->sn, stmp)) {
- if (rccGetOption(ctx, RCC_CONFIGURED_LANGUAGES_ONLY)) {
- if (!rccCheckConfig(ctx, (rcc_language_id)i)) break;
+ clo = rccGetOption(ctx, RCC_CONFIGURED_LANGUAGES_ONLY);
+ printf("CLO: %lu\n", clo);
+ if (clo) {
+ config = rccCheckConfig(ctx, (rcc_language_id)i);
+ if ((!config)||(!config->configured)) {
+ if (clo == 1) {
+ engines = ctx->languages[i]->engines;
+ printf("%p",engines[0]);
+ printf("%p",engines[1]);
+ if ((!engines[0])||(!engines[1])) break;
+ } else break;
+ }
}
+ ctx->default_language = (rcc_language_id)i;
return (rcc_language_id)i;
}
}
diff --git a/src/lngconfig.c b/src/lngconfig.c
index 4ac16c1..eded9da 100644
--- a/src/lngconfig.c
+++ b/src/lngconfig.c
@@ -157,6 +157,8 @@ int rccConfigInit(rcc_language_config config, rcc_context ctx) {
config->language = NULL;
config->charset = charsets;
config->engine = -1;
+ config->default_charset = 0;
+ config->configured = 0;
return 0;
}
@@ -308,12 +310,20 @@ rcc_charset_id rccConfigGetCurrentCharset(rcc_language_config config, rcc_class_
}
} else defvalue = config->ctx->locale_variable;
+ if (config->default_charset) return config->default_charset;
+
charset_id = rccConfigGetLocaleCharset(config, defvalue);
- if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) return charset_id;
+ if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) {
+ config->default_charset = charset_id;
+ return charset_id;
+ }
if (cl->defvalue) {
charset_id = rccConfigGetCharsetByName(config, defvalue);
- if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) return charset_id;
+ if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) {
+ config->default_charset = charset_id;
+ return charset_id;
+ }
}
defcharset = cl->defcharset;
@@ -321,13 +331,21 @@ rcc_charset_id rccConfigGetCurrentCharset(rcc_language_config config, rcc_class_
lang = config->language->sn;
for (i = 0; cl->defcharset[i].lang; i++) {
- if (!strcasecmp(lang, defcharset[i].lang))
- return rccConfigGetCharsetByName(config, defcharset[i].charset);
+ if (!strcasecmp(lang, defcharset[i].lang)) {
+ charset_id = rccConfigGetCharsetByName(config, defcharset[i].charset);
+ if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) {
+ config->default_charset = charset_id;
+ return charset_id;
+ } else break;
+ }
}
}
charsets=language->charsets;
- if ((charsets[0])&&(charsets[1])) return (rcc_charset_id)1;
+ if ((charsets[0])&&(charsets[1])) {
+ config->default_charset=(rcc_charset_id)1;
+ return (rcc_charset_id)1;
+ }
return (rcc_charset_id)-1;
}
@@ -346,6 +364,8 @@ int rccConfigSetEngine(rcc_language_config config, rcc_engine_id engine_id) {
if ((!config)||(!config->language)||(engine_id < -1)) return -1;
+ config->configured = 1;
+
if (engine_id != (rcc_engine_id)-1) {
for (i=0;config->language->engines[i];i++);
if (engine_id >= i) return -1;
@@ -362,7 +382,7 @@ int rccConfigSetEngineByName(rcc_language_config config, const char *name) {
rcc_engine_id engine_id;
if (!config) return -1;
-
+
if ((!name)||(!strcasecmp(name,rcc_engine_nonconfigured)))
return rccConfigSetEngine(config, (rcc_engine_id)-1);
@@ -377,6 +397,8 @@ int rccConfigSetCharset(rcc_language_config config, rcc_class_id class_id, rcc_c
if ((!config)||(!config->language)||(class_id < 0)||(class_id >= config->ctx->n_classes)||(charset_id<0)) return -1;
+ config->configured = 1;
+
for (i=0;config->language->charsets[i];i++);
if (charset_id >= i) return -1;
diff --git a/src/lngconfig.h b/src/lngconfig.h
index 64ca523..d583ab6 100644
--- a/src/lngconfig.h
+++ b/src/lngconfig.h
@@ -8,6 +8,9 @@ struct rcc_language_config_t {
rcc_engine_id engine;
rcc_charset_id *charset;
+
+ rcc_charset_id default_charset;
+ unsigned char configured;
};
typedef struct rcc_language_config_t rcc_language_config_s;
diff --git a/src/rccconfig.c b/src/rccconfig.c
index 100a7fc..e2a0740 100644
--- a/src/rccconfig.c
+++ b/src/rccconfig.c
@@ -101,10 +101,10 @@ rcc_option_value_name rcc_sn_learning[] = { "OFF", "ON", "RELEARN", "LEARN", NUL
rcc_option_value_name rcc_sn_clo[] = { "ALL", "CONFIGURED_AND_AUTO", "CONFIGURED_ONLY", NULL };
rcc_option_description rcc_option_descriptions[] = {
- {RCC_LEARNING_MODE, 0, { RCC_OPTION_RANGE_TYPE_MENU, 0, 3, 1 }, RCC_OPTION_TYPE_STANDARD, "LEARNING_MODE", rcc_sn_learning },
+ {RCC_LEARNING_MODE, 1, { RCC_OPTION_RANGE_TYPE_MENU, 0, 3, 1 }, RCC_OPTION_TYPE_STANDARD, "LEARNING_MODE", rcc_sn_learning },
{RCC_AUTODETECT_FS_NAMES, 1, { RCC_OPTION_RANGE_TYPE_BOOLEAN, 0, 0, 0}, RCC_OPTION_TYPE_STANDARD, "AUTODETECT_FS_NAMES", rcc_sn_boolean},
{RCC_AUTODETECT_FS_TITLES, 1, { RCC_OPTION_RANGE_TYPE_BOOLEAN, 0, 0, 0}, RCC_OPTION_TYPE_INVISIBLE, "AUTODETECT_FS_TITLES", rcc_sn_boolean},
- {RCC_CONFIGURED_LANGUAGES_ONLY, 0, { RCC_OPTION_RANGE_TYPE_MENU, 0, 2, 1}, RCC_OPTION_TYPE_INVISIBLE, "CONFIGURED_LANGUAGES_ONLY", rcc_sn_clo},
+ {RCC_CONFIGURED_LANGUAGES_ONLY, 1, { RCC_OPTION_RANGE_TYPE_MENU, 0, 2, 1}, RCC_OPTION_TYPE_INVISIBLE, "CONFIGURED_LANGUAGES_ONLY", rcc_sn_clo},
{RCC_MAX_OPTIONS}
};
diff --git a/src/rccxml.c b/src/rccxml.c
index 7fc9430..bbeff42 100644
--- a/src/rccxml.c
+++ b/src/rccxml.c
@@ -294,7 +294,7 @@ int rccSave(rcc_context ctx, const char *name) {
for (i=1;languages[i];i++) {
language = languages[i];
cfg = rccCheckConfig(ctx, (rcc_language_id)i);
- if (!cfg) continue;
+ if ((!cfg)||(!cfg->configured)) continue;
if (llflag) lnode = rccNodeFind(xpathctx, XPATH_SELECTED_LANG, language->sn);
else lnode = NULL;
diff --git a/ui/gtk.c b/ui/gtk.c
index 22854ab..2ae0622 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -32,8 +32,9 @@ rcc_ui_id rccUiMenuGet(rcc_ui_menu_context ctx) {
GtkWidget *menu;
if (!ctx) return (rcc_ui_id)-1;
+ printf("Widget: %p\n", ctx->widget);
- if (ctx->type == RCC_UI_MENU_OPTION)
+ if ((ctx->type == RCC_UI_MENU_OPTION)&&(rccUiMenuGetRangeType(ctx)==RCC_OPTION_RANGE_TYPE_BOOLEAN))
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ctx->widget));
menu = gtk_option_menu_get_menu(ctx->widget);
@@ -45,7 +46,16 @@ int rccUiMenuSet(rcc_ui_menu_context ctx, rcc_ui_id id) {
switch (ctx->type) {
case RCC_UI_MENU_OPTION:
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctx->widget),id);
+ switch (rccUiMenuGetRangeType(ctx)) {
+ case RCC_OPTION_RANGE_TYPE_BOOLEAN:
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctx->widget),id);
+ break;
+ case RCC_OPTION_RANGE_TYPE_MENU:
+ gtk_option_menu_set_history(ctx->widget, id);
+ break;
+ default:
+ return -1;
+ }
break;
default:
gtk_option_menu_set_history(ctx->widget, id);
@@ -170,8 +180,7 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
item = gtk_check_button_new_with_label(rccUiGetOptionName(uictx, rccUiMenuGetOption(ctx)));
ctx->widget = item;
}
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(item), rccGetOption(rccctx, rccUiMenuGetOption(ctx)));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctx->widget), rccGetOption(rccctx, rccUiMenuGetOption(ctx)));
break;
case RCC_OPTION_RANGE_TYPE_MENU:
if (!ctx->widget) {
@@ -193,8 +202,7 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
gtk_option_menu_remove_menu(GTK_OPTION_MENU(menu));
gtk_option_menu_set_menu(GTK_OPTION_MENU(menu), list);
}
-
- gtk_option_menu_set_history(GTK_OPTION_MENU(menu), rccGetOption(rccctx, rccUiMenuGetOption(ctx)));
+ gtk_option_menu_set_history(GTK_OPTION_MENU(ctx->widget), rccGetOption(rccctx, rccUiMenuGetOption(ctx)));
break;
default:
return -1;
diff --git a/ui/librccui.c b/ui/librccui.c
index 9f4dc49..2c7c632 100644
--- a/ui/librccui.c
+++ b/ui/librccui.c
@@ -438,8 +438,11 @@ int rccUiRestore(rcc_ui_context ctx) {
language_id = rccGetSelectedLanguage(rccctx);
rccUiMenuSet(ctx->language, (rcc_ui_id)language_id);
- for (i=0;i<RCC_MAX_OPTIONS;i++)
+ for (i=0;i<RCC_MAX_OPTIONS;i++) {
+ if (rccUiMenuGetType(ctx->options[i]) == RCC_OPTION_TYPE_INVISIBLE) continue;
+
rccUiMenuSet(ctx->options[i], rccGetOption(rccctx, (rcc_option)i));
+ }
return 0;
}
@@ -455,8 +458,10 @@ int rccUiUpdate(rcc_ui_context ctx) {
rccSetLanguage(rccctx, (rcc_language_id)rccUiMenuGet(ctx->language));
- for (i=0;i<RCC_MAX_OPTIONS;i++)
+ for (i=0;i<RCC_MAX_OPTIONS;i++) {
+ if (rccUiMenuGetType(ctx->options[i]) == RCC_OPTION_TYPE_INVISIBLE) continue;
rccSetOption(rccctx, (rcc_option)i, (rcc_option_value)rccUiMenuGet(ctx->options[i]));
+ }
rccSetEngine(rccctx, (rcc_language_id)rccUiMenuGet(ctx->engine));