summaryrefslogtreecommitdiffstats
path: root/ui/rccnames.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/rccnames.c')
-rw-r--r--ui/rccnames.c125
1 files changed, 113 insertions, 12 deletions
diff --git a/ui/rccnames.c b/ui/rccnames.c
index 5b3096a..933c910 100644
--- a/ui/rccnames.c
+++ b/ui/rccnames.c
@@ -3,8 +3,11 @@
#include <librcc.h>
#include "internal.h"
+#include "rccnames.h"
-rcc_language_name rcc_default_language_names[RCC_MAX_LANGUAGES+1] = {
+rcc_name rcc_default_language_names[RCC_MAX_LANGUAGES+1];
+
+rcc_name rcc_default_language_names_embeded[RCC_MAX_LANGUAGES+1] = {
{"default", "Autodetect"},
{"off", "Dissable"},
{"ru","Russian"},
@@ -28,7 +31,8 @@ rcc_option_value_name rcc_default_option_boolean_names[] = { "Off", "On", NULL }
rcc_option_value_name rcc_default_option_learning_names[] = { "Off", "On", "Relearn", "Learn", NULL };
rcc_option_value_name rcc_default_option_clo_names[] = { "All Languages", "Configured / AutoEngine", "Configured Only", NULL };
-rcc_option_name rcc_default_option_names[RCC_MAX_OPTIONS+1] = {
+rcc_option_name rcc_default_option_names[RCC_MAX_OPTIONS+1];
+rcc_option_name rcc_default_option_names_embeded[RCC_MAX_OPTIONS+1] = {
{ RCC_OPTION_LEARNING_MODE, "Recodings Cache", rcc_default_option_learning_names },
{ RCC_OPTION_AUTODETECT_FS_NAMES, "Autodetect File Names", rcc_default_option_boolean_names },
{ RCC_OPTION_AUTODETECT_FS_TITLES, "Autodetect FS Titles", rcc_default_option_boolean_names },
@@ -36,31 +40,77 @@ rcc_option_name rcc_default_option_names[RCC_MAX_OPTIONS+1] = {
{ RCC_MAX_OPTIONS }
};
+rcc_ui_page_name rcc_ui_default_page_name;
+rcc_ui_page_name rcc_ui_default_page_name_embeded = {
+ "Encodings",
+ { "Language", "Language" },
+ { "Encodings" },
+ { "AutoDetection", "Engine" }
+};
+
-rcc_language_name *rccUiGetLanguageRccName(rcc_ui_context ctx, const char *lang) {
+rcc_name *rcc_default_class_names = NULL;
+rcc_name *rcc_default_charset_names = NULL;
+rcc_name *rcc_default_engine_names = NULL;
+
+typedef enum rcc_name_type_t {
+ RCC_NAME_TYPE_CLASS = 0,
+ RCC_NAME_TYPE_CHARSET,
+ RCC_NAME_TYPE_ENGINE,
+ RCC_NAME_TYPE_LANGUAGE,
+ RCC_NAME_TYPE_MAX
+} rcc_name_type;
+
+rcc_name *rccUiGetRccName(rcc_ui_context ctx, const char *findname, unsigned char type) {
const char *res;
unsigned int i,j;
- rcc_language_name *names;
+ rcc_name *names[2], *nm;
- if (!lang) return NULL;
+ if (!findname) return NULL;
- for (j=0;j<2;j++) {
- if (j) names = rcc_default_language_names;
- else names = ctx?ctx->language_names:NULL;
+ switch (type) {
+ case RCC_NAME_TYPE_LANGUAGE:
+ names[0] = ctx?ctx->language_names:NULL;
+ names[1] = rcc_default_language_names;
+ break;
+ case RCC_NAME_TYPE_CHARSET:
+ names[0] = ctx?ctx->charset_names:NULL;
+ names[1] = rcc_default_charset_names;
+ break;
+ case RCC_NAME_TYPE_ENGINE:
+ names[0] = ctx?ctx->engine_names:NULL;
+ names[1] = rcc_default_engine_names;
+ break;
+ case RCC_NAME_TYPE_CLASS:
+ if (ctx->class_names) return NULL;
+
+ names[0] = NULL;
+ names[1] = rcc_default_class_names;
+ break;
+ default:
+ return NULL;
+ }
+
- if (names) {
- for (i=0;names[i].sn;i++)
- if (!strcmp(lang, names[i].sn)) return names+i;
+ for (j=0;j<2;j++) {
+ nm = names[j];
+ if (nm) {
+ for (i=0;nm[i].sn;i++)
+ if (!strcasecmp(findname, nm[i].sn)) return nm+i;
}
}
return NULL;
}
+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 *res;
unsigned int i,j;
- rcc_language_name *names;
+ rcc_name *names;
names = rccUiGetLanguageRccName(ctx, lang);
if ((names)&&(names->name)) return names->name;
@@ -68,6 +118,53 @@ const char *rccUiGetLanguageName(rcc_ui_context ctx, const char *lang) {
return lang;
}
+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 *res;
+ unsigned int i,j;
+ rcc_name *names;
+
+ names = rccUiGetCharsetRccName(ctx, charset);
+ if ((names)&&(names->name)) return names->name;
+
+ return charset;
+}
+
+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 *res;
+ unsigned int i,j;
+ rcc_name *names;
+
+ names = rccUiGetEngineRccName(ctx, engine);
+ if ((names)&&(names->name)) return names->name;
+
+ return engine;
+}
+
+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 *res;
+ unsigned int i,j;
+ rcc_name *names;
+
+ names = rccUiGetClassRccName(ctx, cl);
+ if ((names)&&(names->name)) return names->name;
+
+ return NULL;
+}
+
+
+
rcc_option_name *rccUiGetOptionRccName(rcc_ui_context ctx, rcc_option option) {
unsigned int i,j;
rcc_option_name *names;
@@ -109,3 +206,7 @@ const char *rccUiGetOptionValueName(rcc_ui_context ctx, rcc_option option, rcc_o
return NULL;
}
+
+rcc_ui_page_name *rccUiGetDefaultPageName() {
+ return &rcc_ui_default_page_name;
+}