Hello, 

A few weeks ago I started working on some code that allows E17 to setup
Input Methods.  This is usually setup in the Xsession script which setup
up all of your default env variables and starts and support programs
needed for input. 

The goal is to have support of input methods managed by enlightenment.

Design:

Currently e17 internally has a list input methods is a static list of
Language_Pack Structures.  This list can at the moment not be updated. I
intend for, some time in the future, the Language_Pack to be used for
more than just the Input Method but also setting up fonts and what not. 

When setting up Input Method we will configure the following env vars. 

GTK_IM_MODULE
QT_IM_MODULE
XMODIFIERS
GTk_IM_MODULE_FILE - This may not be needed, I think its best this
config is done by the system and not E. But raster suggested it. 

Look at the patch for more info.

Usage:

[EMAIL PROTECTED] bin]$ enlightenment_remote -input-method-list
REPLY <- BEGIN
REPLY: "scim"
REPLY: "uim"
REPLY <- END

[EMAIL PROTECTED] bin]$ enlightenment_remote -input-method-get
REPLY <- BEGIN
REPLY: "scim"
REPLY <- END

...

Anyway,  If it looks ok for now I can commit it.  I haven't had time to
work on it for a while and it has been working fine for me in setting up
scim whenever I use e. 


-- 
<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>

Do what you can to prolong your life, in the hope that someday you'll
learn what it's for.

<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>

Stafford Horne

Location: Beijing China
Contact:  [EMAIL PROTECTED]
Info:     http://shorne.homelinux.com   
? e_intl_im.patch
? e_intl_im-001.diff
Index: e_config.c
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_config.c,v
retrieving revision 1.102
diff -u -r1.102 e_config.c
--- e_config.c	22 Sep 2005 20:20:33 -0000	1.102
+++ e_config.c	25 Sep 2005 01:18:52 -0000
@@ -340,6 +340,7 @@
    E_CONFIG_VAL(D, T, transient.desktop, INT); /**/
    E_CONFIG_VAL(D, T, transient.iconify, INT); /**/
    E_CONFIG_VAL(D, T, modal_windows, INT); /**/
+   E_CONFIG_VAL(D, T, input_method, STR); /**/
 
    e_config = e_config_domain_load("e", _e_config_edd);
    if (e_config)
@@ -457,6 +458,7 @@
 	e_config->transient.desktop = 1;
 	e_config->transient.iconify = 1;
 	e_config->modal_windows = 1;
+	e_config->input_method = NULL;
 	
 	  {
 	     E_Config_Module *em;
@@ -1402,6 +1404,9 @@
    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;
 }
 
Index: e_config.h
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_config.h,v
retrieving revision 1.52
diff -u -r1.52 e_config.h
--- e_config.h	22 Sep 2005 20:20:33 -0000	1.52
+++ e_config.h	25 Sep 2005 01:18:52 -0000
@@ -150,6 +150,7 @@
    int         cursor_size;
    int         menu_autoscroll_margin;
    int         menu_autoscroll_cursor_margin;
+   char	      *input_method;
    struct {
 	int    move;
 	int    resize;
Index: e_intl.c
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_intl.c,v
retrieving revision 1.40
diff -u -r1.40 e_intl.c
--- e_intl.c	14 Sep 2005 20:19:44 -0000	1.40
+++ e_intl.c	25 Sep 2005 01:18:52 -0000
@@ -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_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;
 
@@ -72,9 +79,38 @@
    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;
 }
 
@@ -169,3 +205,69 @@
    /* 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;
+}
+ 
Index: e_intl.h
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_intl.h,v
retrieving revision 1.3
diff -u -r1.3 e_intl.h
--- e_intl.h	19 May 2005 09:23:54 -0000	1.3
+++ e_intl.h	25 Sep 2005 01:18:52 -0000
@@ -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
Index: e_ipc_handlers.h
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_ipc_handlers.h,v
retrieving revision 1.78
diff -u -r1.78 e_ipc_handlers.h
--- e_ipc_handlers.h	23 Sep 2005 06:31:33 -0000	1.78
+++ e_ipc_handlers.h	25 Sep 2005 01:18:55 -0000
@@ -5209,7 +5209,84 @@
    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
Index: e_ipc_handlers_list.h
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_ipc_handlers_list.h,v
retrieving revision 1.23
diff -u -r1.23 e_ipc_handlers_list.h
--- e_ipc_handlers_list.h	22 Sep 2005 20:20:34 -0000	1.23
+++ e_ipc_handlers_list.h	25 Sep 2005 01:18:55 -0000
@@ -258,17 +258,22 @@
 #define E_IPC_OP_MODAL_WINDOWS_GET 256
 #define E_IPC_OP_MODAL_WINDOWS_GET_REPLY 257
 
-#define E_IPC_OP_WINDOW_PLACEMENT_POLICY_SET 258
-#define E_IPC_OP_WINDOW_PLACEMENT_POLICY_GET 259
-#define E_IPC_OP_WINDOW_PLACEMENT_POLICY_GET_REPLY 260
+#define E_IPC_OP_IM_LIST 258
+#define E_IPC_OP_IM_LIST_REPLY 259
+#define E_IPC_OP_IM_SET 260
+#define E_IPC_OP_IM_GET 270
+#define E_IPC_OP_IM_GET_REPLY 271
 
-#define E_IPC_OP_CONFIG_PANEL_SHOW 261
+#define E_IPC_OP_WINDOW_PLACEMENT_POLICY_SET 272
+#define E_IPC_OP_WINDOW_PLACEMENT_POLICY_GET 273
+#define E_IPC_OP_WINDOW_PLACEMENT_POLICY_GET_REPLY 274
+#define E_IPC_OP_CONFIG_PANEL_SHOW 275
 
-#define E_IPC_OP_BINDING_SIGNAL_LIST 262
-#define E_IPC_OP_BINDING_SIGNAL_LIST_REPLY 263
-#define E_IPC_OP_BINDING_SIGNAL_ADD 264
-#define E_IPC_OP_BINDING_SIGNAL_DEL 265
-#define E_IPC_OP_BINDING_WHEEL_LIST 266
-#define E_IPC_OP_BINDING_WHEEL_LIST_REPLY 267
-#define E_IPC_OP_BINDING_WHEEL_ADD 268
-#define E_IPC_OP_BINDING_WHEEL_DEL 269
+#define E_IPC_OP_BINDING_SIGNAL_LIST 276
+#define E_IPC_OP_BINDING_SIGNAL_LIST_REPLY 277
+#define E_IPC_OP_BINDING_SIGNAL_ADD 278
+#define E_IPC_OP_BINDING_SIGNAL_DEL 279
+#define E_IPC_OP_BINDING_WHEEL_LIST 280
+#define E_IPC_OP_BINDING_WHEEL_LIST_REPLY 281
+#define E_IPC_OP_BINDING_WHEEL_ADD 282
+#define E_IPC_OP_BINDING_WHEEL_DEL 283

Reply via email to