From: Peng Huang Date: Tue, 9 Jun 2009 01:08:04 +0000 (+0800) Subject: Show im name on languagebar X-Git-Tag: 1.1.0.20090609~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be5bebbff7aa3de6f656a97ba34d10afd75f6dff;p=platform%2Fupstream%2Fibus.git Show im name on languagebar --- diff --git a/setup/main.py b/setup/main.py index a00644cd..243dbac0 100644 --- a/setup/main.py +++ b/setup/main.py @@ -156,6 +156,12 @@ class Setup(object): self.__fontbutton_custom_font.connect("notify::font-name", self.__fontbutton_custom_font_notify_cb) self.__fontbutton_custom_font.set_font_name(font_name) + # show ime name + self.__checkbutton_show_im_name = self.__xml.get_widget("checkbutton_show_im_name") + self.__checkbutton_show_im_name.set_active( + self.__config.get_value("panel", "show_im_name", False)) + self.__checkbutton_show_im_name.connect("toggled", self.__checkbutton_show_im_name_toggled_cb) + # init engine page self.__engines = self.__bus.list_engines() self.__combobox = EngineComboBox(self.__engines) @@ -365,6 +371,10 @@ class Setup(object): font_name = unicode(font_name, "utf-8") self.__config.set_value("panel", "custom_font", font_name) + def __checkbutton_show_im_name_toggled_cb(self, button): + value = self.__checkbutton_show_im_name.get_active() + self.__config.set_value("panel", "show_im_name", value) + def __config_value_changed_cb(self, bus, section, name, value): pass diff --git a/setup/setup.glade b/setup/setup.glade index 1436e1cd..9202f730 100644 --- a/setup/setup.glade +++ b/setup/setup.glade @@ -284,6 +284,18 @@ Always 1 + + + Show input method name on language bar + True + True + False + True + + + 2 + + Use custom font @@ -294,7 +306,7 @@ Always True - 2 + 3 @@ -322,7 +334,7 @@ Always - 3 + 4 diff --git a/ui/gtk/languagebar.py b/ui/gtk/languagebar.py index 5012733c..9a796773 100644 --- a/ui/gtk/languagebar.py +++ b/ui/gtk/languagebar.py @@ -23,6 +23,7 @@ import gtk import gtk.gdk as gdk import gobject import ibus +import icon from handle import Handle from menu import menu_position from engineabout import EngineAbout @@ -59,7 +60,9 @@ class LanguageBar(gtk.Toolbar): self.__show = 1 self.__enabled = False self.__has_focus = False - self.set_style(gtk.TOOLBAR_ICONS) + self.__show_im_name = False + self.__im_name = None + self.set_style(gtk.TOOLBAR_BOTH_HORIZ) self.set_show_arrow(False) self.set_property("icon-size", ICON_SIZE) self.__create_ui() @@ -87,8 +90,8 @@ class LanguageBar(gtk.Toolbar): handle.connect("move-end", self.__handle_move_end_cb) # create input methods menu - prop = ibus.Property(key = "", type = ibus.PROP_TYPE_TOGGLE, icon = "ibus", tooltip = _("Switch input method")) - self.__im_menu = ToggleToolButton(prop) + # prop = ibus.Property(key = "", type = ibus.PROP_TYPE_TOGGLE, icon = "ibus", tooltip = _("Switch input method")) + self.__im_menu = gtk.ToggleToolButton() self.__im_menu.set_homogeneous(False) self.__im_menu.connect("toggled", self.__im_menu_toggled_cb) self.insert(self.__im_menu, -1) @@ -144,7 +147,22 @@ class LanguageBar(gtk.Toolbar): self.__toplevel.resize(1, 1) def set_im_icon(self, icon_name): - self.__im_menu.set_icon_name(icon_name) + widget = icon.IconWidget(icon_name, 18) + self.__im_menu.set_icon_widget(widget) + + def set_show_im_name(self, show): + self.__show_im_name = show + self.set_im_name(self.__im_name) + self.__im_menu.set_is_important(show) + + def set_im_name(self, text): + self.__im_name = text + if text: + self.__im_menu.set_tooltip_text(text) + self.__im_menu.set_label(text) + else: + self.__im_menu.set_tooltip_text(_("Switch input method")) + self.__im_menu.set_label("") def reset(self): self.__remove_properties() diff --git a/ui/gtk/panel.py b/ui/gtk/panel.py index fc5fa700..bfd2ef63 100644 --- a/ui/gtk/panel.py +++ b/ui/gtk/panel.py @@ -103,6 +103,7 @@ class Panel(ibus.PanelBase): self.__config_load_lookup_table_orientation() self.__config_load_show() self.__config_load_custom_font() + self.__config_load_show_im_name() # self.__bus.request_name(ibus.panel.IBUS_SERVICE_PANEL, 0) def set_cursor_location(self, x, y, w, h): @@ -177,6 +178,9 @@ class Panel(ibus.PanelBase): else: self.__status_icon.set_from_icon_name(icon_name) + def __set_im_name(self, name): + self.__language_bar.set_im_name(name) + def focus_in(self, ic): self.reset() self.__focus_ic = ibus.InputContext(self.__bus, ic) @@ -185,12 +189,15 @@ class Panel(ibus.PanelBase): if not enabled: self.__set_im_icon(self.__ibus_icon) + self.__set_im_name(None) else: engine = self.__focus_ic.get_engine() if engine: self.__set_im_icon(engine.icon) + self.__set_im_name(engine.longname) else: self.__set_im_icon(self.__ibus_icon) + self.__set_im_name(None) self.__language_bar.focus_in() def focus_out(self, ic): @@ -199,6 +206,7 @@ class Panel(ibus.PanelBase): self.__language_bar.set_enabled(False) self.__language_bar.focus_out() self.__set_im_icon(self.__ibus_icon) + self.__set_im_name(None) def state_changed(self): if not self.__focus_ic: @@ -210,12 +218,15 @@ class Panel(ibus.PanelBase): if enabled == False: self.reset() self.__set_im_icon(self.__ibus_icon) + self.__set_im_name(None) else: engine = self.__focus_ic.get_engine() if engine: self.__set_im_icon(engine.icon) + self.__set_im_name(engine.longname) else: self.__set_im_icon(self.__ibus_icon) + self.__set_im_name(None) def reset(self): @@ -258,6 +269,10 @@ class Panel(ibus.PanelBase): settings = gtk.settings_get_default() gtk.rc_reset_styles(settings) + def __config_load_show_im_name(self): + value = self.__config.get_value("panel", "show_im_name", False) + self.__language_bar.set_show_im_name(value) + def __config_value_changed_cb(self, bus, section, name, value): if section != "panel": return @@ -267,6 +282,10 @@ class Panel(ibus.PanelBase): self.__config_load_show() elif name == "use_custom_font" or name == "custom_font": self.__config_load_custom_font() + elif name == "show_im_name": + self.__config_load_show_im_name() + else: + print >> sys.stderr, "Unknown config item [%s]" % name def __config_reloaded_cb(self, bus): pass