From f671355e97f7de3e866f942e5c69f72b0c97fddb Mon Sep 17 00:00:00 2001 From: Fuminobu TAKEYAMA Date: Sun, 6 Oct 2013 15:29:43 +0900 Subject: [PATCH] If icons for input modes are available, use those icons instead of engine's icons. --- ui/gtk3/panel.vala | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala index 9c1fef5..51864c4 100644 --- a/ui/gtk3/panel.vala +++ b/ui/gtk3/panel.vala @@ -1098,10 +1098,49 @@ class Panel : IBus.PanelService { public override void register_properties(IBus.PropList props) { m_property_manager.set_properties(props); + int i = 0; + while (true) { + IBus.Property prop = props.get(i); + if (prop == null) + break; + if (prop.key == "InputMode") { + update_input_mode_icon(prop.icon); + break; + } + } } public override void update_property(IBus.Property prop) { m_property_manager.update_property(prop); + if (prop.key == "InputMode") { + update_input_mode_icon(prop.icon); + } + } + + // If InputMode has an icon, use it instead of engine's icon. + public void update_input_mode_icon(string icon) { + var icon_name = icon; + if (icon == "") { + var engine = m_bus.get_global_engine(); + icon_name = engine.get_icon(); + } + + if (icon_name[0] == '/') { + try { + // resize icon because icons were desinged for ibus tool bar of 1.4.x + var icon_img = new Gdk.Pixbuf.from_file_at_size(icon_name, m_status_icon.size, m_status_icon.size); + m_status_icon.set_from_pixbuf(icon_img); + } catch (Error e) { + warning("could not load icon: %s", icon_name); + } + } else { + var theme = Gtk.IconTheme.get_default(); + if (theme.lookup_icon(icon_name, 48, 0) != null) { + m_status_icon.set_from_icon_name(icon_name); + } else { + m_status_icon.set_from_icon_name("ibus-engine"); + } + } } public override void update_preedit_text(IBus.Text text, -- 1.8.4