Add property orientation of IBusLookupTable.
authorPeng Huang <shawn.p.huang@gmail.com>
Sat, 12 Dec 2009 06:29:21 +0000 (14:29 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Sat, 12 Dec 2009 06:29:21 +0000 (14:29 +0800)
ibus/common.py
ibus/lookuptable.py
src/ibuslookuptable.c
src/ibuslookuptable.h
src/ibustypes.h

index 1499a20..9694b5d 100644 (file)
@@ -30,6 +30,9 @@ __all__ = (
         "IBUS_IFACE_ENGINE_FACTORY",
         "IBUS_IFACE_INPUT_CONTEXT",
         "IBUS_IFACE_NOTIFICATIONS",
+        "ORIENTATION_HORIZONTAL",
+        "ORIENTATION_VERTICAL",
+        "ORIENTATION_SYSTEM",
         "default_reply_handler",
         "default_error_handler",
         "DEFAULT_ASYNC_HANDLERS",
@@ -121,6 +124,11 @@ IBUS_IFACE_ENGINE_FACTORY   = "org.freedesktop.IBus.EngineFactory"
 IBUS_IFACE_INPUT_CONTEXT    = "org.freedesktop.IBus.InputContext"
 IBUS_IFACE_NOTIFICATIONS    = "org.freedesktop.IBus.Notifications"
 
+# define orientation
+ORIENTATION_HORIZONTAL  = 0
+ORIENTATION_VERTICAL    = 1
+ORIENTATION_SYSTEM      = 2
+
 def default_reply_handler( *args):
     pass
 
index e2020b4..8c65d1c 100644 (file)
@@ -31,11 +31,12 @@ from exception import *
 class LookupTable(Serializable):
     __gtype_name__ = "PYIBusLookupTable"
     __NAME__ = "IBusLookupTable"
-    def __init__(self, page_size=5, cursor_pos=0, coursor_visible=True, round=False, candidates=None, labels=None):
+    def __init__(self, page_size=5, cursor_pos=0, coursor_visible=True, round=False, orientation=2, candidates=None, labels=None):
         super(LookupTable, self).__init__()
         self.__cursor_pos = cursor_pos
         self.__cursor_visible = True
         self.__round = round
+        self.__orientation = orientation
         if candidates == None:
             self.__candidates = list()
         else:
@@ -66,7 +67,7 @@ class LookupTable(Serializable):
     def get_labels(self):
         return self.__labels
 
-    def show_cursor(self, show = True):
+    def show_cursor(self, show=True):
         self.__cursor_visible = show
 
     def is_cursor_visible(self):
@@ -96,7 +97,11 @@ class LookupTable(Serializable):
             return False
         self.__cursor_pos = pos
         return True
+    def set_orientation(self, orientation):
+        self.__orientation = orientation
 
+    def get_orientation(self):
+        return self.__orientation
 
     def page_up(self):
         if self.__cursor_pos < self.__page_size:
@@ -191,6 +196,7 @@ class LookupTable(Serializable):
         struct.append(dbus.UInt32(self.__cursor_pos))
         struct.append(dbus.Boolean(self.__cursor_visible))
         struct.append(dbus.Boolean(self.__round))
+        struct.append(dbus.Int32(self.__orientation))
         candidates = map(lambda c: serialize_object(c), self.__candidates)
         struct.append(dbus.Array(candidates, signature="v"))
         labels = map(lambda c: serialize_object(c), self.__labels)
@@ -203,6 +209,7 @@ class LookupTable(Serializable):
                            self.__cursor_pos % self.__page_size,
                            self.__cursor_visible,
                            self.__round,
+                           self.__orientation,
                            candidates,
                            self.__labels)
 
@@ -213,6 +220,7 @@ class LookupTable(Serializable):
         self.__cursor_pos = struct.pop(0)
         self.__cursor_visible = struct.pop(0)
         self.__round = struct.pop(0)
+        self.__orientation = struct.pop(0)
         self.__candidates = map(deserialize_object, struct.pop(0))
         self.__labels = map(deserialize_object, struct.pop(0))
 
index da7afd2..a237485 100644 (file)
@@ -74,7 +74,7 @@ ibus_lookup_table_class_init (IBusLookupTableClass *klass)
     serializable_class->deserialize = (IBusSerializableDeserializeFunc) ibus_lookup_table_deserialize;
     serializable_class->copy        = (IBusSerializableCopyFunc) ibus_lookup_table_copy;
 
-    g_string_append (serializable_class->signature, "uubbavav");
+    g_string_append (serializable_class->signature, "uubbiavav");
 }
 
 static void
@@ -137,6 +137,9 @@ ibus_lookup_table_serialize (IBusLookupTable *table,
     retval = ibus_message_iter_append (iter, G_TYPE_BOOLEAN, &table->round);
     g_return_val_if_fail (retval, FALSE);
 
+    retval = ibus_message_iter_append (iter, G_TYPE_INT, &table->orientation);
+    g_return_val_if_fail (retval, FALSE);
+
     // append candidates
     retval = ibus_message_iter_open_container (iter,
                                                IBUS_TYPE_ARRAY,
@@ -210,6 +213,10 @@ ibus_lookup_table_deserialize (IBusLookupTable *table,
     g_return_val_if_fail (retval, FALSE);
     ibus_message_iter_next (iter);
 
+    retval = ibus_message_iter_get (iter, G_TYPE_INT, &table->orientation);
+    g_return_val_if_fail (retval, FALSE);
+    ibus_message_iter_next (iter);
+
     // deserialize candidates
     retval = ibus_message_iter_recurse (iter, IBUS_TYPE_ARRAY, &array_iter);
     g_return_val_if_fail (retval, FALSE);
@@ -306,6 +313,7 @@ ibus_lookup_table_new (guint page_size,
     table->cursor_pos = cursor_pos;
     table->cursor_visible = cursor_visible;
     table->round = round;
+    table->orientation = IBUS_ORIENTATION_SYSTEM;
 
     return table;
 }
index 1ba2bfb..71175e3 100644 (file)
@@ -65,6 +65,7 @@ typedef struct _IBusLookupTableClass IBusLookupTableClass;
  * @cursor_pos: position index of cursor.
  * @cursor_visible: whether the cursor is visible.
  * @round: TRUE for lookup table wrap around.
+ * @orientation: orientation of the table.
  * @candidates: Candidate words/phrases.
  * @labels: Candidate labels which identify individual candidates in the same page. Default is 1, 2, 3, 4 ...
  *
@@ -82,6 +83,7 @@ struct _IBusLookupTable {
     guint cursor_pos;
     gboolean cursor_visible;
     gboolean round;
+    gint orientation;
 
     GArray *candidates;
     GArray *labels;
index ba8a556..b7002df 100644 (file)
@@ -112,6 +112,20 @@ typedef enum {
 } IBusCapabilite;
 
 /**
+ * IBusOrientation:
+ * @IBUS_ORIENTATION_HORIZONTAL: Horizontal orientation.
+ * @IBUS_ORIENTATION_VERTICAL: Vertival orientation.
+ * @IBUS_ORIENTATION_SYSTEM: Use ibus global orientation setup.
+ *
+ * Orientation of UI.
+ */
+typedef enum {
+    IBUS_ORIENTATION_HORIZONTAL = 0,
+    IBUS_ORIENTATION_VERTICAL   = 1,
+    IBUS_ORIENTATION_SYSTEM     = 2,
+} IBusOrientation;
+
+/**
  * IBusRectangle:
  * @x: x coordinate.
  * @y: y coordinate.