Show engines' keyboard layout in setup UI
authorPeng Huang <shawn.p.huang@gmail.com>
Mon, 15 Jun 2009 07:00:12 +0000 (15:00 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Mon, 15 Jun 2009 07:00:12 +0000 (15:00 +0800)
setup/enginetreeview.py
setup/main.py
ui/gtk/engineabout.py

index 8c7d5b09603b706c200e0ca1da9c6c8ff4d3e8ce..4af4a123611cc12bc7bd586dfb1ec2edceb9cf7e 100644 (file)
@@ -27,6 +27,10 @@ import ibus
 
 from icon import load_icon
 
+from gettext import dgettext
+_  = lambda a : dgettext("ibus", a)
+N_ = lambda a : a
+
 class EngineTreeView(gtk.TreeView):
     __gsignals__ = {
         'changed' : (
@@ -39,9 +43,11 @@ class EngineTreeView(gtk.TreeView):
         super(EngineTreeView, self).__init__()
 
         self.__engines = set([])
-
         self.__changed = False
 
+        self.set_headers_visible(True)
+        self.set_reorderable(True)
+
         self.__model = gtk.ListStore(gobject.TYPE_PYOBJECT)
         self.set_model(self.__model)
         self.__model.connect("row-changed", self.__emit_changed_delay_cb, "row-changed")
@@ -49,9 +55,9 @@ class EngineTreeView(gtk.TreeView):
         self.__model.connect("row-inserted", self.__emit_changed_delay_cb, "row-inserted")
         self.__model.connect("rows-reordered", self.__emit_changed_delay_cb, "rows-reordered")
 
-        self.set_headers_visible(False)
-
-        column = gtk.TreeViewColumn()
+        # create im name & icon column
+        column = gtk.TreeViewColumn(_("Input Method"))
+        column.set_min_width(200)
 
         renderer = gtk.CellRendererPixbuf()
         renderer.set_property("xalign", 0)
@@ -60,11 +66,22 @@ class EngineTreeView(gtk.TreeView):
 
         renderer = gtk.CellRendererText()
         renderer.set_property("xalign", 0)
+        renderer.set_property("ellipsize", pango.ELLIPSIZE_END)
         column.pack_start(renderer, True)
         column.set_cell_data_func(renderer, self.__name_cell_data_cb)
-        self.append_column (column)
+        self.append_column(column)
 
-        self.set_reorderable(True)
+        # create im keyboard layout column
+        renderer = gtk.CellRendererCombo()
+        renderer.set_property("xalign", 0)
+
+        column = gtk.TreeViewColumn(_("KBL"))
+        column.set_expand(False)
+        column.set_fixed_width(32)
+        column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
+        column.pack_start(renderer, False)
+        column.set_cell_data_func(renderer, self.__layout_cell_data_cb)
+        self.append_column (column)
 
         self.set_engines(engines)
 
@@ -97,6 +114,17 @@ class EngineTreeView(gtk.TreeView):
         renderer.set_property("sensitive", True)
         language = ibus.get_language_name(engine.language)
         renderer.set_property("text", "%s - %s" % (language, engine.longname))
+        if self.__model.get_path(iter)[0] == 0:
+            # default engine
+            renderer.set_property("weight", pango.WEIGHT_BOLD)
+        else:
+            renderer.set_property("weight", pango.WEIGHT_NORMAL)
+
+    def __layout_cell_data_cb(self, celllayout, renderer, model, iter):
+        engine = self.__model.get_value(iter, 0)
+        renderer.set_property("sensitive", True)
+        language = ibus.get_language_name(engine.language)
+        renderer.set_property("text", engine.layout)
         if self.__model.get_path(iter)[0] == 0:
             #default engine
             renderer.set_property("weight", pango.WEIGHT_BOLD)
index 243dbac030a37b94b9babc159fc4357571a875d6..10c6cbe42a2ea19644f839849707abe80991bf5f 100644 (file)
@@ -99,7 +99,9 @@ class Setup(object):
 
         button = self.__xml.get_widget("button_trigger")
         entry = self.__xml.get_widget("entry_trigger")
-        entry.set_text("; ".join(shortcuts))
+        text = "; ".join(shortcuts)
+        entry.set_text(text)
+        entry.set_tooltip_text(text)
         button.connect("clicked", self.__shortcut_button_clicked_cb,
                     N_("trigger"), "general/hotkey", "trigger", entry)
 
@@ -109,7 +111,9 @@ class Setup(object):
                         ibus.CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE_DEFAULT)
         button = self.__xml.get_widget("button_next_engine")
         entry = self.__xml.get_widget("entry_next_engine")
-        entry.set_text("; ".join(shortcuts))
+        text = "; ".join(shortcuts)
+        entry.set_text(text)
+        entry.set_tooltip_text(text)
         button.connect("clicked", self.__shortcut_button_clicked_cb,
                     N_("next input method"), "general/hotkey", "next_engine", entry)
 
@@ -119,7 +123,9 @@ class Setup(object):
                         ibus.CONFIG_GENERAL_SHORTCUT_PREV_ENGINE_DEFAULT)
         button = self.__xml.get_widget("button_prev_engine")
         entry = self.__xml.get_widget("entry_prev_engine")
-        entry.set_text("; ".join(shortcuts))
+        text = "; ".join(shortcuts)
+        entry.set_text(text)
+        entry.set_tooltip_text(text)
         button.connect("clicked", self.__shortcut_button_clicked_cb,
                     N_("previous input method"), "general/hotkey", "prev_engine", entry)
 
@@ -198,9 +204,10 @@ class Setup(object):
 
     def __button_engine_about_cb(self, button):
         engine = self.__treeview.get_select_engine()
-        about = EngineAbout(engine)
-        about.run()
-        about.destroy()
+        if engine:
+            about = EngineAbout(engine)
+            about.run()
+            about.destroy()
 
     def __treeview_changed_cb(self, treeview):
         engines = self.__treeview.get_engines()
@@ -261,7 +268,9 @@ class Setup(object):
         if id != gtk.RESPONSE_OK:
             return
         self.__config.set_list(section, _name, shortcuts, "s")
-        entry.set_text("; ".join(shortcuts))
+        text = "; ".join(shortcuts)
+        entry.set_text(text)
+        entry.set_tooltip_text(text)
 
 
     def __item_started_column_toggled_cb(self, cell, path_str, model):
index 72d05a19c357b9e4dc09a6d04fbc87615268528f..dd7bee430c71db58b0accd5083c947c64db406e9 100644 (file)
@@ -61,6 +61,8 @@ class EngineAbout(gtk.Dialog):
                                              "heading", "left_margin_16")
         text_buffer.insert_with_tags_by_name(iter, _("Language: %s\n") % ibus.get_language_name(self.__engine_desc.language),
                                             "small", "bold", "left_margin_16")
+        text_buffer.insert_with_tags_by_name(iter, _("Kayboard layout: %s\n") % self.__engine_desc.layout,
+                                            "small", "bold", "left_margin_16")
         text_buffer.insert_with_tags_by_name(iter, _("Author: %s\n") % self.__engine_desc.author,
                                             "small", "bold", "left_margin_16")
         text_buffer.insert_with_tags_by_name(iter, _("Description:\n"),