Use IM icon in switcher dialog.
authorPeng Huang <shawn.p.huang@gmail.com>
Tue, 5 Jun 2012 13:59:06 +0000 (09:59 -0400)
committerPeng Huang <shawn.p.huang@gmail.com>
Tue, 5 Jun 2012 13:59:06 +0000 (09:59 -0400)
BUG=None
TEST=Manually

Review URL: https://codereview.appspot.com/6274044

ui/gtk3/Makefile.am
ui/gtk3/switcher.vala

index 87a7373..639e3ea 100644 (file)
@@ -42,6 +42,8 @@ INCLUDES = \
        -I$(top_builddir)/src \
        $(NULL)
 
+USE_SYMBOL_ICON = FALSE
+
 AM_CFLAGS = \
        @GLIB2_CFLAGS@ \
        @GIO2_CFLAGS@ \
@@ -57,6 +59,7 @@ AM_CFLAGS = \
        -DBINDIR=\"@bindir@\" \
     -DIBUS_DISABLE_DEPRECATED \
        -DIBUS_VERSION=\"@IBUS_VERSION@\" \
+       -DSWITCHER_USE_SYMBOL_ICON=$(USE_SYMBOL_ICON) \
        -Wno-unused-variable \
        -Wno-unused-but-set-variable \
        -Wno-unused-function \
index c39fc1c..1fb0431 100644 (file)
  */
 
 using Atk;
+using Cairo;
+using Gdk;
 using GLib;
 using Gtk;
 using IBus;
 using Pango;
 
 class Switcher : Gtk.Window {
+    public extern const bool USE_SYMBOL_ICON;
     private const int DEFAULT_FONT_SIZE = 16;
     private const int DESC_LABEL_MAX_LEN = 20;
+    private const int ICON_SIZE = 48;
 
     private class IBusEngineButton : Gtk.Button {
         public IBusEngineButton(IBus.EngineDesc engine) {
             GLib.Object();
-            this.longname = engine.get_longname();
-            var language = engine.get_language();
-            var symbol = engine.get_symbol();
-            var id = language;
 
-            if (id.length > 2) {
-                id = id[0:2];
-            }
-            if (symbol.length != 0) {
-                id = symbol;
-            }
+            this.longname = engine.get_longname();
 
             Gtk.Alignment align = new Gtk.Alignment(0.5f, 0.5f, 0.0f, 0.0f);
             add(align);
-            Gtk.Box box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
-            align.add(box);
 
-            Gtk.Label label = new Gtk.Label(id);
-            string id_font = "%d".printf(DEFAULT_FONT_SIZE);
-            string markup = "<span font=\"%s\">%s</span>".printf(id_font, id);
+            if (!USE_SYMBOL_ICON) {
+                IconWidget icon = new IconWidget(engine.get_icon(), ICON_SIZE);
+                align.add(icon);
+            } else {
+                var language = engine.get_language();
+                var symbol = engine.get_symbol();
+                var id = language;
 
-            label.set_markup(markup);
-            box.pack_start(label, false, false, 0);
+                if (id.length > 2) {
+                    id = id[0:2];
+                }
+
+                if (symbol.length != 0) {
+                    id = symbol;
+                }
+
+                Gtk.Label label = new Gtk.Label(id);
+                string id_font = "%d".printf(DEFAULT_FONT_SIZE);
+                string markup = "<span font=\"%s\">%s</span>".printf(id_font, id);
+
+                label.set_markup(markup);
+                align.add(label);
+            }
         }
 
         public string longname { get; set; }