[uim-commit] r1867 - trunk/xim

ekato at freedesktop.org ekato at freedesktop.org
Sat Oct 22 07:31:19 PDT 2005


Author: ekato
Date: 2005-10-22 07:30:44 -0700 (Sat, 22 Oct 2005)
New Revision: 1867

Modified:
   trunk/xim/main.cpp
   trunk/xim/ximserver.cpp
   trunk/xim/ximserver.h
Log:
* xim/ximserver.h (class InputContext) : Add
  configuration_changed() public member.  Add
  configuration_changed_cb() static member.  Add review_im()
  private member.
* xim/ximserver.cpp : Include uim-im-switcher.h.
(InputContext::createUimContext) : Set configuration_changed_cb.
(InputContext::configuration_changed) : New function.  Call
  review_im() to check input method.
(InputContext::review_im) : New function.  Review newly switched
  input method if it is matched with a encoding of the client.
(InputContext::configuration_changed_cb) : New.
* xim/main.cpp (reload_uim) : Don't print information.


Modified: trunk/xim/main.cpp
===================================================================
--- trunk/xim/main.cpp	2005-10-22 14:17:10 UTC (rev 1866)
+++ trunk/xim/main.cpp	2005-10-22 14:30:44 UTC (rev 1867)
@@ -533,7 +533,7 @@
     uim_quit();
     clear_uim_info();
     get_uim_info();
-    print_uim_info();
+    //print_uim_info();
 
     for (it = XimServer::gServerMap.begin(); it != XimServer::gServerMap.end(); it++) {
 	XimServer *xs = it->second;

Modified: trunk/xim/ximserver.cpp
===================================================================
--- trunk/xim/ximserver.cpp	2005-10-22 14:17:10 UTC (rev 1866)
+++ trunk/xim/ximserver.cpp	2005-10-22 14:30:44 UTC (rev 1867)
@@ -53,6 +53,7 @@
 #include "helper.h"
 
 #include "uim/uim-helper.h"
+#include "uim/uim-im-switcher.h"
 #include "uim/uim-compat-scm.h"
 
 #ifndef __GNUC__
@@ -407,6 +408,7 @@
 				InputContext::update_prop_list_cb);
     uim_set_prop_label_update_cb(uc,
 				 InputContext::update_prop_label_cb);
+    uim_set_configuration_changed_cb(uc, InputContext::configuration_changed_cb);
 
     if (mFocusedContext == this)
 	uim_prop_list_update(uc);
@@ -438,6 +440,45 @@
     }
 }
 
+void InputContext::configuration_changed()
+{
+    const char *engine = uim_get_current_im_name(mUc);
+
+    review_im(engine);
+}
+
+void InputContext::review_im(const char *engine)
+{
+    char *locale;
+    const char *client_locale, *engine_locales;
+    const char *encoding;
+
+    encoding = mXic->get_encoding();
+    client_locale = mXic->get_lang_region();
+    engine_locales = compose_localenames_from_im_lang(get_im_lang_from_engine(engine));
+
+    if (!strcmp(encoding, "UTF-8")) {
+	if (is_locale_included(engine_locales, client_locale))
+	    locale = strdup(client_locale);
+	else
+	    locale = get_prefered_locale(engine_locales);
+	locale = (char *)realloc(locale, strlen(locale) + strlen(".UTF-8") + 1);
+	strcat(locale, ".UTF-8");
+	setlocale(LC_CTYPE, locale);
+	free(mLocaleName);
+	mLocaleName = locale;
+	free(mEngineName);
+	mEngineName = strdup(engine);
+    } else {
+	if (!is_locale_included(engine_locales, client_locale))
+	    changeContext(mEngineName);
+	else {
+	    free(mEngineName);
+	    mEngineName = strdup(engine);
+	}
+    }
+}
+
 void
 InputContext::customContext(const char *custom, const char *val)
 {
@@ -569,6 +610,13 @@
       ic->update_prop_label(str);
 }
 
+void InputContext::configuration_changed_cb(void *ptr)
+{
+    InputContext *ic = (InputContext *)ptr;
+
+    ic->configuration_changed();
+}
+
 void InputContext::clear_pe_stat()
 {
     m_pe->clear();

Modified: trunk/xim/ximserver.h
===================================================================
--- trunk/xim/ximserver.h	2005-10-22 14:17:10 UTC (rev 1866)
+++ trunk/xim/ximserver.h	2005-10-22 14:30:44 UTC (rev 1867)
@@ -181,22 +181,25 @@
     void changeContext(const char *engine);
     void customContext(const char *custom, const char *val);
     void createUimContext(const char *engine);
+    void configuration_changed();
 public:
-    static void commit_cb(void *, const char *);
-    static void clear_cb(void *);
-    static void pushback_cb(void *, int attr, const char *str);
-    static void update_cb(void *);
+    static void commit_cb(void *ptr, const char *str);
+    static void clear_cb(void *ptr);
+    static void pushback_cb(void *ptr, int attr, const char *str);
+    static void update_cb(void *ptr);
     static void candidate_activate_cb(void *ptr, int nr, int index);
     static void candidate_select_cb(void *ptr, int index);
     static void candidate_shift_page_cb(void *ptr, int direction);
     static void candidate_deactivate_cb(void *ptr);
     static void update_prop_list_cb(void *ptr, const char *str);
     static void update_prop_label_cb(void *ptr, const char *str);
+    static void configuration_changed_cb(void *ptr);
     static InputContext *focusedContext();
     static void deletefocusedContext();
 private:
     void commit_string(char *);
     void clear_pe_stat();
+    void review_im(const char *engine);
 
     XimIC *mXic;
     XimServer *mServer;



More information about the uim-commit mailing list