Apply CandidatePanel orientation change request from IME.
authorDaiki Ueno <ueno@unixuser.org>
Fri, 1 Jan 2010 04:22:58 +0000 (13:22 +0900)
committerPeng Huang <shawn.p.huang@gmail.com>
Fri, 1 Jan 2010 08:18:54 +0000 (16:18 +0800)
This version also saves the system orientation setting for a later IME switch.

ui/gtk/candidatepanel.py
ui/gtk/panel.py

index 2aaf0ff5377b66735d1a050c8b3c3c2f721e2da9..690a23234d50e7659335034ae7bf0c0d7c033c4e 100644 (file)
@@ -211,8 +211,8 @@ class CandidatePanel(gtk.VBox):
         # self.__toplevel.connect("motion-notify-event", self.__motion_notify_event_cb)
         self.__toplevel.connect("size-allocate", lambda w, a: self.__check_position())
 
-        self.__orientation = gtk.ORIENTATION_HORIZONTAL
         self.__orientation = gtk.ORIENTATION_VERTICAL
+        self.__system_orientation = self.__orientation
         self.__preedit_visible = False
         self.__aux_string_visible = False
         self.__lookup_table_visible = False
@@ -393,6 +393,12 @@ class CandidatePanel(gtk.VBox):
         self.__lookup_table = lookup_table
         self.__refresh_candidates()
         self.__refresh_labels()
+        orientation = self.__lookup_table.get_orientation()
+        if orientation in (0, 1):
+            self.set_orientation((gtk.ORIENTATION_HORIZONTAL,
+                                  gtk.ORIENTATION_VERTICAL)[orientation])
+        else:
+            self.set_orientation(self.__system_orientation)
 
     def show_lookup_table(self):
         self.__lookup_table_visible = True
@@ -450,6 +456,10 @@ class CandidatePanel(gtk.VBox):
         if self.__toplevel.flags() & gtk.VISIBLE:
             self.show_all()
 
+    def set_system_orientation(self, orientation):
+        self.__system_orientation = orientation
+        self.set_orientation(orientation)
+
     def get_orientation(self):
         return self.__orientation
 
index 555960f148e845cc89a28f8401f1b5ed134932a7..e93b7af0299da3e741238559426082288f53d5f6 100644 (file)
@@ -259,9 +259,9 @@ class Panel(ibus.PanelBase):
         if value != 0 and value != 1:
             value = 0
         if value == 0:
-            self.__candidate_panel.set_orientation(gtk.ORIENTATION_HORIZONTAL)
+            self.__candidate_panel.set_system_orientation(gtk.ORIENTATION_HORIZONTAL)
         else:
-            self.__candidate_panel.set_orientation(gtk.ORIENTATION_VERTICAL)
+            self.__candidate_panel.set_system_orientation(gtk.ORIENTATION_VERTICAL)
 
     def __config_load_show(self):
         show = self.__config.get_value("panel", "show", 1)