From 1e9afd4067805cb1f2bbdfd64f1b0d93e6e39692 Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Mon, 23 Feb 2009 15:09:11 +0800 Subject: [PATCH] Use "No input method" replace "Disable" in im menu. --- ui/gtk/panel.py | 73 +++++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/ui/gtk/panel.py b/ui/gtk/panel.py index fb9ae6e..f046d23 100644 --- a/ui/gtk/panel.py +++ b/ui/gtk/panel.py @@ -296,50 +296,45 @@ class Panel(ibus.PanelBase): menu = gtk.Menu() engines = self.__bus.list_active_engines() - if not engines: - item = gtk.MenuItem(label = "no engine") - item.set_sensitive(False) - menu.add(item) - else: - tmp = {} - for engine in engines: - lang = ibus.get_language_name(engine.language) - if lang not in tmp: - tmp[lang] = [] - tmp[lang].append(engine) - - langs = tmp.keys() - other = tmp.get(_("Other"), []) - if _("Other") in tmp: - langs.remove(_("Other")) - langs.append(_("Other")) - - size = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU) - for lang in langs: - if len(tmp[lang]) == 1: - engine = tmp[lang][0] - item = gtk.ImageMenuItem("%s - %s" % (lang, engine.longname)) + tmp = {} + for engine in engines: + lang = ibus.get_language_name(engine.language) + if lang not in tmp: + tmp[lang] = [] + tmp[lang].append(engine) + + langs = tmp.keys() + other = tmp.get(_("Other"), []) + if _("Other") in tmp: + langs.remove(_("Other")) + langs.append(_("Other")) + + size = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU) + for lang in langs: + if len(tmp[lang]) == 1: + engine = tmp[lang][0] + item = gtk.ImageMenuItem("%s - %s" % (lang, engine.longname)) + if engine.icon: + item.set_image (_icon.IconWidget(engine.icon, size[0])) + else: + item.set_image (_icon.IconWidget("engine-default", size[0])) + item.connect("activate", self.__im_menu_item_activate_cb, engine) + menu.add(item) + else: + item = gtk.MenuItem(lang) + menu.add(item) + submenu = gtk.Menu() + item.set_submenu(submenu) + for engine in tmp[lang]: + item = gtk.ImageMenuItem(engine.longname) if engine.icon: item.set_image (_icon.IconWidget(engine.icon, size[0])) else: item.set_image (_icon.IconWidget("engine-default", size[0])) item.connect("activate", self.__im_menu_item_activate_cb, engine) - menu.add(item) - else: - item = gtk.MenuItem(lang) - menu.add(item) - submenu = gtk.Menu() - item.set_submenu(submenu) - for engine in tmp[lang]: - item = gtk.ImageMenuItem(engine.longname) - if engine.icon: - item.set_image (_icon.IconWidget(engine.icon, size[0])) - else: - item.set_image (_icon.IconWidget("engine-default", size[0])) - item.connect("activate", self.__im_menu_item_activate_cb, engine) - submenu.add(item) - - item = gtk.ImageMenuItem(_("Disable")) + submenu.add(item) + + item = gtk.ImageMenuItem(_("No input method")) item.set_image (_icon.IconWidget("gtk-close", size[0])) item.connect("activate", self.__im_menu_item_activate_cb, None) menu.add (item) -- 2.7.4