Rerotate next/previous engines without global engine.
authorfujiwarat <takao.fujiwara1@gmail.com>
Wed, 2 Nov 2011 05:17:50 +0000 (14:17 +0900)
committerfujiwarat <takao.fujiwara1@gmail.com>
Wed, 2 Nov 2011 05:17:50 +0000 (14:17 +0900)
BUG=http://code.google.com/p/ibus/issues/detail?id=1331
TEST=Linux desktop

Review URL: http://codereview.appspot.com/5321067

bus/ibusimpl.c

index 0a4f3fbd343da3356382bc097348a3ee17689859..059d6602f9c33b78b0b9c3c5fbdef363bb786eef 100644 (file)
@@ -1056,7 +1056,7 @@ bus_ibus_impl_context_request_rotate_engine_in_menu (BusIBusImpl     *ibus,
     BusEngineProxy *engine;
     IBusEngineDesc *desc;
     IBusEngineDesc *next_desc = NULL;
-    GList *p;
+    GList *p = NULL;
 
     engine = bus_input_context_get_engine (context);
     if (engine == NULL) {
@@ -1074,21 +1074,46 @@ bus_ibus_impl_context_request_rotate_engine_in_menu (BusIBusImpl     *ibus,
     if (p != NULL) {
         if (is_next) {
             p = p->next;
-        } else if (p->prev) {
+        } else {
             p = p->prev;
         }
     }
+
+    /* Rotate register_engine_list and engine_list. */
+    if (p == NULL && g_list_find (ibus->register_engine_list, desc) != NULL) {
+        if (is_next) {
+            p = ibus->engine_list;
+        } else {
+            p = g_list_last (ibus->engine_list);
+        }
+    }
+
     if (p == NULL) {
         p = g_list_find (ibus->engine_list, desc);
         if (p != NULL) {
             if (is_next) {
                 p = p->next;
-            } else if (p->prev) {
+            } else {
                 p = p->prev;
             }
         }
     }
 
+    /* Rerotate register_engine_list and engine_list. */
+    if (p == NULL && g_list_find (ibus->engine_list, desc) != NULL) {
+        if (is_next) {
+            p = ibus->register_engine_list;
+            if (p == NULL) {
+                p = ibus->engine_list;
+            }
+        } else {
+            p = g_list_last (ibus->register_engine_list);
+            if (p == NULL) {
+                p = g_list_last (ibus->engine_list);
+            }
+        }
+    }
+
     if (p != NULL) {
         next_desc = (IBusEngineDesc*) p->data;
     }