shorne's intl work! :)

SVN revision: 17575
This commit is contained in:
Carsten Haitzler 2005-10-15 10:49:54 +00:00
parent d4c5a2fef0
commit 027e5afb18
6 changed files with 219 additions and 8 deletions

View File

@ -359,6 +359,7 @@ e_config_init(void)
E_CONFIG_VAL(D, T, menu_eap_name_show, INT); /**/
E_CONFIG_VAL(D, T, menu_eap_generic_show, INT); /**/
E_CONFIG_VAL(D, T, menu_eap_comment_show, INT); /**/
E_CONFIG_VAL(D, T, input_method, STR); /**/
e_config = e_config_domain_load("e", _e_config_edd);
if (e_config)
@ -487,6 +488,7 @@ e_config_init(void)
e_config->menu_eap_name_show = 1;
e_config->menu_eap_generic_show = 1;
e_config->menu_eap_comment_show = 0;
e_config->input_method = NULL;
{
E_Config_Module *em;
@ -1450,6 +1452,9 @@ e_config_init(void)
if ((e_config->language) && (strlen(e_config->language) > 0))
e_intl_language_set(e_config->language);
if ((e_config->input_method) && (strlen(e_config->input_method) > 0))
e_intl_input_method_set(e_config->input_method);
return 1;
}

View File

@ -172,6 +172,7 @@ struct _E_Config
int cursor_size;
int menu_autoscroll_margin;
int menu_autoscroll_cursor_margin;
char *input_method;
struct {
int move;
int resize;

View File

@ -6,8 +6,6 @@
/* TODO List:
*
* * load/save language in config so u can change language runtime via a gui and/or ipc
* * add ipc to get/set/list languages, get language name, simplified language string, etc. (so a config tool can be written to display supported languages and be able to select from them)
* * add more language names to the language name list list in e_intl_language_name_get()
* * as we get translations add languages to the simplified lang list (C and en are currently the same, ja is a test translation - incomplete)
*/
@ -19,12 +17,21 @@ static char *_e_intl_orig_lang = NULL;
static char *_e_intl_language = NULL;
static Evas_List *_e_intl_languages = NULL;
static char *_e_intl_orig_gtk_im_module_file = NULL;
static char *_e_intl_orig_xmodifiers = NULL;
static char *_e_intl_orig_qt_im_module = NULL;
static char *_e_intl_orig_gtk_im_module = NULL;
static char *_e_intl_input_method = NULL;
static Evas_List *_e_intl_input_methods = NULL;
#define ADD_LANG(lang) _e_intl_languages = evas_list_append(_e_intl_languages, lang)
#define ADD_IM(method) _e_intl_input_methods = evas_list_append(_e_intl_input_methods, method)
int
e_intl_init(void)
{
char *s;
E_Language_Pack *elp;
if (_e_intl_languages) return 1;
@ -73,9 +80,38 @@ e_intl_init(void)
if ((s = getenv("LANGUAGE"))) _e_intl_orig_language = strdup(s);
if ((s = getenv("LC_ALL"))) _e_intl_orig_lc_all = strdup(s);
if ((s = getenv("LANG"))) _e_intl_orig_lang = strdup(s);
if ((s = getenv("GTK_IM_MODULE"))) _e_intl_orig_gtk_im_module = strdup(s);
if ((s = getenv("QT_IM_MODULE"))) _e_intl_orig_qt_im_module = strdup(s);
if ((s = getenv("XMODIFIERS"))) _e_intl_orig_xmodifiers = strdup(s);
if ((s = getenv("GTK_IM_MODULE_FILE"))) _e_intl_orig_gtk_im_module_file = strdup(s);
/* FIXME: NULL == use LANG. make this read a config value if it exists */
/* Exception: NULL == use LANG. this will get setup in e_config */
e_intl_language_set(NULL);
elp = malloc(sizeof(E_Language_Pack));
elp->version = 1;
elp->e_im_name = strdup("scim");
elp->gtk_im_module = strdup("scim");
elp->qt_im_module = strdup("scim");
elp->xmodifiers = strdup("@im=SCIM");
elp->e_im_exec = strdup("scim");
elp->gtk_im_module_file = NULL;
ADD_IM(elp);
elp = malloc(sizeof(E_Language_Pack));
elp->version = 1;
elp->e_im_name = strdup("uim");
elp->gtk_im_module = strdup("uim");
elp->qt_im_module = strdup("uim");
elp->xmodifiers = strdup("@im=uim");
elp->gtk_im_module_file = NULL;
elp->e_im_exec = strdup("uim-xim");
ADD_IM(elp);
return 1;
}
@ -172,3 +208,71 @@ e_intl_language_list(void)
/* FIXME: hunt dirs for locales */
return _e_intl_languages;
}
void
e_intl_input_method_set(const char *method)
{
E_Language_Pack *elp;
Evas_List *next;
if (_e_intl_input_method) free(_e_intl_input_method);
if (!method)
{
e_util_env_set("GTK_IM_MODULE", _e_intl_orig_gtk_im_module);
e_util_env_set("QT_IM_MODULE", _e_intl_orig_qt_im_module);
e_util_env_set("XMODIFIERS", _e_intl_orig_xmodifiers);
e_util_env_set("GTK_IM_MODULE_FILE", _e_intl_orig_gtk_im_module_file);
}
if (method)
{
_e_intl_input_method = strdup(method);
for (next = _e_intl_input_methods; next; next = next->next)
{
elp = next->data;
if (!strcmp(elp->e_im_name, _e_intl_input_method))
{
e_util_env_set("GTK_IM_MODULE", elp->gtk_im_module);
e_util_env_set("QT_IM_MODULE", elp->qt_im_module);
e_util_env_set("XMODIFIERS", elp->xmodifiers);
e_util_env_set("GTK_IM_MODULE_FILE", elp->gtk_im_module_file);
if (elp->e_im_exec != NULL)
{
/* FIXME: first check ok exec availability */
ecore_exe_run(elp->e_im_exec, NULL);
}
break;
}
}
}
else
{
_e_intl_input_method = NULL;
}
}
const char *
e_intl_input_method_get(void)
{
return _e_intl_input_method;
}
const Evas_List *
e_intl_input_method_list(void)
{
Evas_List *im_list;
Evas_List *next;
E_Language_Pack *elp;
im_list = NULL;
for (next = _e_intl_input_methods; next; next = next->next)
{
elp = next->data;
im_list = evas_list_append(im_list, elp->e_im_name);
}
return im_list;
}

View File

@ -9,15 +9,33 @@
#define _(str) gettext(str)
#define d_(str, dom) dgettext(PACKAGE dom, str)
typedef struct _E_Language_Pack E_Language_Pack;
#else
#ifndef E_INTL_H
#define E_INTL_H
EAPI int e_intl_init(void);
EAPI int e_intl_shutdown(void);
EAPI void e_intl_language_set(const char *lang);
EAPI const char *e_intl_language_get(void);
EAPI const Evas_List *e_intl_language_list(void);
struct _E_Language_Pack
{
int version;
char *e_im_name;
char *gtk_im_module;
char *qt_im_module;
char *xmodifiers;
char *gtk_im_module_file;
char *e_im_exec;
};
EAPI int e_intl_init(void);
EAPI int e_intl_shutdown(void);
/* Setting & Getting Language */
EAPI void e_intl_language_set(const char *lang);
EAPI const char *e_intl_language_get(void);
EAPI const Evas_List *e_intl_language_list(void);
/* Setting & Getting Input Method */
EAPI void e_intl_input_method_set(const char *method);
EAPI const char *e_intl_input_method_get(void);
EAPI const Evas_List *e_intl_input_method_list(void);
#endif
#endif

View File

@ -5447,7 +5447,84 @@ break;
END_INT;
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_IM_LIST
#if (TYPE == E_REMOTE_OPTIONS)
OP("-input-method-list", 0, "List all available input methods", 1, HDL)
#elif (TYPE == E_REMOTE_OUT)
REQ_NULL(HDL);
#elif (TYPE == E_WM_IN)
GENERIC(HDL);
LIST_DATA();
ENCODE((Evas_List *)e_intl_input_method_list(), e_ipc_codec_str_list_enc);
SEND_DATA(E_IPC_OP_IM_LIST_REPLY);
END_GENERIC();
#elif (TYPE == E_REMOTE_IN)
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_IM_LIST_REPLY
#if (TYPE == E_REMOTE_OPTIONS)
#elif (TYPE == E_REMOTE_OUT)
#elif (TYPE == E_WM_IN)
#elif (TYPE == E_REMOTE_IN)
GENERIC(HDL);
LIST();
DECODE(e_ipc_codec_str_list_dec) {
FOR(dat) {
printf("REPLY: \"%s\"\n", (char *)(l->data));
}
FREE_LIST(dat);
}
END_GENERIC();
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_IM_SET
#if (TYPE == E_REMOTE_OPTIONS)
OP("-input-method-set", 1, "Set the current input method to 'OPT1'", 0, HDL)
#elif (TYPE == E_REMOTE_OUT)
REQ_STRING(params[0], HDL);
#elif (TYPE == E_WM_IN)
STRING(s, HDL);
E_FREE(e_config->input_method);
e_config->input_method = strdup(s);
if ((e_config->input_method) && (strlen(e_config->input_method) > 0))
e_intl_input_method_set(e_config->input_method);
else
e_intl_input_method_set(NULL);
SAVE;
END_STRING(s);
#elif (TYPE == E_REMOTE_IN)
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_IM_GET
#if (TYPE == E_REMOTE_OPTIONS)
OP("-input-method-get", 0, "Get the current input method", 1, HDL)
#elif (TYPE == E_REMOTE_OUT)
REQ_NULL(HDL);
#elif (TYPE == E_WM_IN)
SEND_STRING(e_config->input_method, E_IPC_OP_IM_GET_REPLY, HDL);
#elif (TYPE == E_REMOTE_IN)
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_IM_GET_REPLY
#if (TYPE == E_REMOTE_OPTIONS)
#elif (TYPE == E_REMOTE_OUT)
#elif (TYPE == E_WM_IN)
#elif (TYPE == E_REMOTE_IN)
STRING(s, HDL);
printf("REPLY: \"%s\"\n", s);
END_STRING(s);
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_WINDOW_PLACEMENT_POLICY_SET

View File

@ -329,3 +329,9 @@
#define E_IPC_OP_MENU_EAP_COMMENT_SHOW_GET 313
#define E_IPC_OP_MENU_EAP_COMMENT_SHOW_GET_REPLY 314
#define E_IPC_OP_IM_LIST 315
#define E_IPC_OP_IM_LIST_REPLY 316
#define E_IPC_OP_IM_SET 317
#define E_IPC_OP_IM_GET 318
#define E_IPC_OP_IM_GET_REPLY 319