diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gtk.c | 55 | ||||
-rw-r--r-- | ui/internal.h | 3 | ||||
-rw-r--r-- | ui/librccui.c | 56 | ||||
-rw-r--r-- | ui/librccui.h | 8 | ||||
-rw-r--r-- | ui/rccnames.c | 26 |
5 files changed, 82 insertions, 66 deletions
@@ -83,19 +83,21 @@ static void rccGtkMenuLanguageCB(GtkWidget * w, gpointer item) { int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) { unsigned int i; + unsigned long num; rcc_context rccctx; rcc_ui_context uictx; rcc_language_config config; - rcc_language_ptr *languages; rcc_language_id language_id; - rcc_charset *charsets; - rcc_engine_ptr *engines; - + rcc_class_id class_id; rcc_charset_id charset_id; rcc_engine_id engine_id; + + const char *language; + const char *charset; + const char *engine; rcc_option_range *range; rcc_option_name *option_name; @@ -111,12 +113,14 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) { switch (ctx->type) { case RCC_UI_MENU_LANGUAGE: - languages=rccGetLanguageList(rccctx); - if (!languages) return -1; + num = rccGetLanguageNumber(rccctx); list = gtk_menu_new(); - for (i=0; languages[i]; i++) { - item = gtk_menu_item_new_with_label(rccUiGetLanguageName(uictx, languages[i]->sn)); + for (i=0; i<(num?num:1); i++) { + language = rccUiGetLanguageName(uictx, (rcc_language_id)i); + if (!language) continue; + + item = gtk_menu_item_new_with_label(language); gtk_widget_show(item); gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(rccGtkMenuLanguageCB), ctx); gtk_menu_append(GTK_MENU(list), item); @@ -135,15 +139,21 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) { gtk_option_menu_set_history(GTK_OPTION_MENU(menu), language_id); break; case RCC_UI_MENU_CHARSET: - language_id = (rcc_language_id)rccUiMenuGet(uictx->language); - charsets = rccGetCharsetList(rccctx, language_id); - if (!charsets) return -1; + class_id = rccUiMenuGetClassId(ctx); + config = rccGetConfig(rccctx, language_id); + num = rccConfigGetClassCharsetNumber(config, class_id); list = gtk_menu_new(); - for (i=0;charsets[i];i++) { - item = gtk_menu_item_new_with_label(rccUiGetCharsetName(uictx,charsets[i])); - gtk_widget_show(item); + for (i=0;i<(num?num:1);i++) { + charset = rccUiGetCharsetName(uictx, language_id, class_id, (rcc_charset_id)i); + if (!charset) continue; + + item = gtk_menu_item_new_with_label(charset); + if (rccIsDisabledCharsetName(rccctx, class_id, charset)) + gtk_widget_set_sensitive(item, 0); + else + gtk_widget_show(item); gtk_menu_append(GTK_MENU(list), item); } @@ -156,20 +166,22 @@ 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); - config = rccGetConfig(rccctx, language_id); - charset_id = rccConfigGetSelectedCharset(config, rccUiMenuGetClassId(ctx)); + charset_id = rccConfigGetSelectedCharset(config, class_id); if (charset_id == (rcc_charset_id)-1) charset_id = 0; gtk_option_menu_set_history(GTK_OPTION_MENU(menu), charset_id); break; case RCC_UI_MENU_ENGINE: language_id = (rcc_language_id)rccUiMenuGet(uictx->language); - engines = rccGetEngineList(rccctx, language_id); - if (!engines) return -1; - + config = rccGetConfig(rccctx, language_id); + num = rccConfigGetEngineNumber(config); + list = gtk_menu_new(); - for (i=0;engines[i];i++) { - item = gtk_menu_item_new_with_label(rccUiGetEngineName(uictx,engines[i]->title)); + for (i=0;i<(num?num:1);i++) { + engine = rccUiGetEngineName(uictx, language_id, (rcc_engine_id)i); + if (!engine) continue; + + item = gtk_menu_item_new_with_label(engine); gtk_widget_show(item); gtk_menu_append(GTK_MENU(list), item); } @@ -182,7 +194,6 @@ 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); - config = rccGetConfig(rccctx, language_id); engine_id = rccConfigGetCurrentEngine(config); if (engine_id == (rcc_engine_id)-1) engine_id = 0; gtk_option_menu_set_history(GTK_OPTION_MENU(menu), engine_id); diff --git a/ui/internal.h b/ui/internal.h index e814a9f..49a932f 100644 --- a/ui/internal.h +++ b/ui/internal.h @@ -35,7 +35,8 @@ typedef void *rcc_ui_internal; struct rcc_ui_context_t { rcc_context rccctx; - + + int n_classes; rcc_ui_menu_context language; rcc_ui_menu_context engine; rcc_ui_menu_context *charsets; diff --git a/ui/librccui.c b/ui/librccui.c index c38cb58..17e7281 100644 --- a/ui/librccui.c +++ b/ui/librccui.c @@ -426,9 +426,8 @@ static void rccUiFrameFreeContext(rcc_ui_frame_context ctx) { rcc_ui_context rccUiCreateContext(rcc_context rccctx) { int err = 0; - unsigned int i; + unsigned int i, n_classes; - rcc_class_ptr *classes; rcc_ui_context ctx; rcc_ui_menu_context *charsets; rcc_ui_menu_context *options; @@ -440,11 +439,10 @@ rcc_ui_context rccUiCreateContext(rcc_context rccctx) { err = rccLockConfiguration(rccctx, RCC_UI_LOCK_CODE); if (err) return NULL; - classes = rccGetClassList(rccctx); - for (i=0; classes[i]; i++); + n_classes = rccGetClassNumber(rccctx); ctx = (rcc_ui_context)malloc(sizeof(struct rcc_ui_context_t)); - charsets = (rcc_ui_menu_context*)malloc((i+1)*sizeof(rcc_ui_menu_context)); + charsets = (rcc_ui_menu_context*)malloc((n_classes+1)*sizeof(rcc_ui_menu_context)); options = (rcc_ui_menu_context*)malloc((RCC_MAX_OPTIONS)*sizeof(rcc_ui_menu_context)); if ((!ctx)||(!charsets)) { if (ctx) free(ctx); @@ -453,6 +451,8 @@ rcc_ui_context rccUiCreateContext(rcc_context rccctx) { return NULL; } + ctx->n_classes = n_classes; + ctx->options = options; ctx->charsets = charsets; ctx->rccctx = rccctx; @@ -467,7 +467,7 @@ rcc_ui_context rccUiCreateContext(rcc_context rccctx) { ctx->language = rccUiMenuCreateContext(RCC_UI_MENU_LANGUAGE, ctx); ctx->engine = rccUiMenuCreateContext(RCC_UI_MENU_ENGINE, ctx); - for (i=0; classes[i]; i++) { + for (i=0; i<n_classes; i++) { charsets[i] = rccUiCharsetMenuCreateContext(RCC_UI_MENU_CHARSET, (rcc_charset_id)i, ctx); if (!charsets[i]) err = 1; } @@ -495,7 +495,6 @@ rcc_ui_context rccUiCreateContext(rcc_context rccctx) { void rccUiFreeContext(rcc_ui_context ctx) { unsigned int i; - rcc_class_ptr *classes; if (!ctx) return; @@ -506,8 +505,7 @@ void rccUiFreeContext(rcc_ui_context ctx) { if (ctx->language_frame) rccUiFrameFreeContext(ctx->language_frame); if (ctx->charsets) { - classes = rccGetClassList(ctx->rccctx); - for (i=0; classes[i]; i++) + for (i=0; i<ctx->n_classes; i++) if (ctx->charsets[i]) rccUiMenuFreeContext(ctx->charsets[i]); free(ctx->charsets); } @@ -585,19 +583,20 @@ int rccUiSetClassNames(rcc_ui_context ctx) { int rccUiRestoreLanguage(rcc_ui_context ctx) { unsigned int i; - rcc_class_ptr *classes; + rcc_context rccctx; rcc_language_id language_id; if (!ctx) return -1; + rccctx = ctx->rccctx; + language_id = (rcc_language_id)rccUiMenuGet(ctx->language); rccUiMenuConfigureWidget(ctx->engine); //rccUiMenuSet(ctx->engine, (rcc_ui_id)rccConfigGetSelectedEngine(config)); - classes = rccGetClassList(ctx->rccctx); - for (i=0;classes[i];i++) - if (classes[i]->fullname) { + for (i=0;i<ctx->n_classes;i++) + if (rccUiGetClassName(ctx, (rcc_class_id)i)) { rccUiMenuConfigureWidget(ctx->charsets[i]); // rccUiMenuSet(ctx->charsets[i], rccConfigGetSelectedCharset(config, (rcc_class_id)i)); } @@ -629,7 +628,6 @@ int rccUiRestore(rcc_ui_context ctx) { int rccUiUpdate(rcc_ui_context ctx) { unsigned int i; - rcc_class_ptr *classes; rcc_context rccctx; if (!ctx) return -1; @@ -645,9 +643,8 @@ int rccUiUpdate(rcc_ui_context ctx) { rccSetEngine(rccctx, (rcc_language_id)rccUiMenuGet(ctx->engine)); - classes = rccGetClassList(rccctx); - for (i=0;classes[i];i++) - if (classes[i]->fullname) + for (i=0;i<ctx->n_classes;i++) + if (rccUiGetClassName(ctx, (rcc_class_id)i)) rccSetCharset(rccctx, (rcc_class_id)i, rccUiMenuGet(ctx->charsets[i])); return 0; @@ -663,14 +660,9 @@ rcc_ui_widget rccUiGetLanguageMenu(rcc_ui_context ctx) { } rcc_ui_widget rccUiGetCharsetMenu(rcc_ui_context ctx, rcc_class_id id) { - rcc_class_ptr *classes; - unsigned int i; - if ((!ctx)||(id<0)) return NULL; - classes = rccGetClassList(ctx->rccctx); - for (i=0;classes[i];i++); - if (id>=i) return NULL; + if (id>=ctx->n_classes) return NULL; if (rccUiMenuConfigureWidget(ctx->charsets[id])) return NULL; return ctx->charsets[id]->widget; @@ -707,15 +699,11 @@ rcc_ui_box rccUiGetLanguageBox(rcc_ui_context ctx, const char *title) { } rcc_ui_box rccUiGetCharsetBox(rcc_ui_context ctx, rcc_class_id id, const char *title) { - unsigned int i; - rcc_class_ptr *classes; rcc_ui_widget charset; if (!ctx) return NULL; - classes = rccGetClassList(ctx->rccctx); - for (i=0; classes[i]; i++); - if (id>=i) return NULL; + if (id>=ctx->n_classes) return NULL; if (ctx->charsets[id]->box) return ctx->charsets[id]->box; @@ -781,12 +769,14 @@ rcc_ui_frame rccUiGetLanguageFrame(rcc_ui_context ctx, rcc_ui_language_frame_nam rcc_ui_frame rccUiGetCharsetsFrame(rcc_ui_context ctx, rcc_ui_charset_frame_name *name) { unsigned int i; const char *class_name; - rcc_class_ptr *classes; + rcc_context rccctx; rcc_ui_frame_context framectx; rcc_ui_frame frame; rcc_ui_box charset; if (!ctx) return NULL; + + rccctx = ctx->rccctx; framectx = ctx->charset_frame; if (framectx->frame) return framectx->frame; @@ -797,11 +787,9 @@ rcc_ui_frame rccUiGetCharsetsFrame(rcc_ui_context ctx, rcc_ui_charset_frame_name if (frame) framectx->frame = frame; else return NULL; - classes = rccGetClassList(ctx->rccctx); - for (i=0; classes[i]; i++) { - if (classes[i]->fullname) { - class_name = rccUiGetClassName(ctx, classes[i]->name); - if (!class_name) class_name = classes[i]->fullname; + for (i=0; i<ctx->n_classes; i++) { + class_name = rccUiGetClassName(ctx, (rcc_class_id)i); + if (class_name) { charset = rccUiGetCharsetBox(ctx, (rcc_class_id)i, class_name); rccUiFrameAdd(framectx, charset); } diff --git a/ui/librccui.h b/ui/librccui.h index 6ae36d7..b0a4cef 100644 --- a/ui/librccui.h +++ b/ui/librccui.h @@ -62,10 +62,10 @@ typedef struct rcc_ui_page_name_t rcc_ui_page_name; rcc_ui_page_name *rccUiGetDefaultPageName(); -const char *rccUiGetLanguageName(rcc_ui_context ctx, const char *lang); -const char *rccUiGetCharsetName(rcc_ui_context ctx, const char *charset); -const char *rccUiGetEngineName(rcc_ui_context ctx, const char *engine); -const char *rccUiGetClassName(rcc_ui_context ctx, const char *cl); +const char *rccUiGetLanguageName(rcc_ui_context ctx, rcc_language_id language_id); +const char *rccUiGetClassName(rcc_ui_context ctx, rcc_class_id class_id); +const char *rccUiGetCharsetName(rcc_ui_context ctx, rcc_language_id language_id, rcc_class_id class_id, rcc_charset_id charset_id); +const char *rccUiGetEngineName(rcc_ui_context ctx, rcc_language_id language_id, rcc_engine_id engine_id); const char *rccUiGetOptionName(rcc_ui_context ctx, rcc_option option); const char *rccUiGetOptionValueName(rcc_ui_context ctx, rcc_option option, rcc_option_value value); diff --git a/ui/rccnames.c b/ui/rccnames.c index 8b5b4a0..d3d54d7 100644 --- a/ui/rccnames.c +++ b/ui/rccnames.c @@ -113,9 +113,12 @@ rcc_name *rccUiGetLanguageRccName(rcc_ui_context ctx, const char *lang) { return rccUiGetRccName(ctx, lang, RCC_NAME_TYPE_LANGUAGE); } -const char *rccUiGetLanguageName(rcc_ui_context ctx, const char *lang) { +const char *rccUiGetLanguageName(rcc_ui_context ctx, rcc_language_id language_id) { + const char *lang; rcc_name *names; + lang = rccGetLanguageName(ctx->rccctx, language_id); + names = rccUiGetLanguageRccName(ctx, lang); if ((names)&&(names->name)) return names->name; @@ -126,8 +129,13 @@ rcc_name *rccUiGetCharsetRccName(rcc_ui_context ctx, const char *charset) { return rccUiGetRccName(ctx, charset, RCC_NAME_TYPE_CHARSET); } -const char *rccUiGetCharsetName(rcc_ui_context ctx, const char *charset) { +const char *rccUiGetCharsetName(rcc_ui_context ctx, rcc_language_id language_id, rcc_class_id class_id, rcc_charset_id charset_id) { + rcc_language_config config; + const char *charset; rcc_name *names; + + config = rccGetConfig(ctx->rccctx, language_id); + charset = rccConfigGetClassCharsetName(config, class_id, charset_id); names = rccUiGetCharsetRccName(ctx, charset); if ((names)&&(names->name)) return names->name; @@ -139,9 +147,14 @@ rcc_name *rccUiGetEngineRccName(rcc_ui_context ctx, const char *engine) { return rccUiGetRccName(ctx, engine, RCC_NAME_TYPE_ENGINE); } -const char *rccUiGetEngineName(rcc_ui_context ctx, const char *engine) { +const char *rccUiGetEngineName(rcc_ui_context ctx, rcc_language_id language_id, rcc_engine_id engine_id) { + rcc_language_config config; + const char *engine; rcc_name *names; + config = rccGetConfig(ctx->rccctx, language_id); + engine = rccConfigGetEngineName(config, engine_id); + names = rccUiGetEngineRccName(ctx, engine); if ((names)&&(names->name)) return names->name; @@ -152,13 +165,16 @@ rcc_name *rccUiGetClassRccName(rcc_ui_context ctx, const char *cl) { return rccUiGetRccName(ctx, cl, RCC_NAME_TYPE_CLASS); } -const char *rccUiGetClassName(rcc_ui_context ctx, const char *cl) { +const char *rccUiGetClassName(rcc_ui_context ctx, rcc_class_id class_id) { + const char *cl; rcc_name *names; + cl = rccGetClassName(ctx->rccctx, class_id); + names = rccUiGetClassRccName(ctx, cl); if ((names)&&(names->name)) return names->name; - return NULL; + return rccGetClassFullName(ctx->rccctx, (rcc_class_id)class_id); } |