ibus/show-input-mode-icon.patch

56 lines
2.0 KiB
Diff

--- ibus-1.5.5/ui/gtk3/panel.vala.orig 2014-01-19 01:53:48.144138225 +0900
+++ ibus-1.5.5/ui/gtk3/panel.vala 2014-01-19 02:03:54.627409768 +0900
@@ -863,11 +863,52 @@
public override void register_properties(IBus.PropList props) {
m_property_manager.set_properties(props);
m_property_panel.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;
+ }
+ i++;
+ }
}
public override void update_property(IBus.Property prop) {
m_property_manager.update_property(prop);
m_property_panel.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
+ // use 22 px because icons are wrongly cropped on KDE
+ var icon_img = new Gdk.Pixbuf.from_file_at_size(icon_name, 22, 22);
+ 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,