aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-06-22 16:26:13 -0400
committerWilliam Hua <william.hua@canonical.com>2013-06-22 16:26:13 -0400
commit932273ca5caeb544567a3c3dfba95e5771ecfc7e (patch)
tree5ad37baa4dc93e1685d61bcb8ce5ea4fdc7ffdca /lib
parentf0a27935a36b371d095001ba2f42633761630ef8 (diff)
downloadayatana-indicator-keyboard-932273ca5caeb544567a3c3dfba95e5771ecfc7e.tar.gz
ayatana-indicator-keyboard-932273ca5caeb544567a3c3dfba95e5771ecfc7e.tar.bz2
ayatana-indicator-keyboard-932273ca5caeb544567a3c3dfba95e5771ecfc7e.zip
Experimental non-null support.
Diffstat (limited to 'lib')
-rw-r--r--lib/main.vala30
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/main.vala b/lib/main.vala
index 88b2e738..b49d9f3b 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -172,8 +172,10 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
protected virtual Icon create_icon (string? text, uint subscript) {
- const int W = 20;
- const int H = 20;
+ const int W = 22;
+ const int H = 22;
+ const int w = 20;
+ const int h = 20;
const double R = 2.0;
const double TEXT_SIZE = 12.0;
const double SUBSCRIPT_SIZE = 8.0;
@@ -181,16 +183,19 @@ public class Indicator.Keyboard.Service : Object {
Pango.FontDescription description;
var style = get_style_context ();
var colour = style.get_color (Gtk.StateFlags.NORMAL);
+ colour = { 0.5, 0.5, 0.5, 1.0 };
style.get (Gtk.StateFlags.NORMAL, Gtk.STYLE_PROPERTY_FONT, out description);
var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, W, H);
var context = new Cairo.Context (surface);
+ context.translate (0.5 * (W - w), 0.5 * (H - h));
+
context.new_sub_path ();
context.arc (R, R, R, Math.PI, -0.5 * Math.PI);
- context.arc (W - R, R, R, -0.5 * Math.PI, 0);
- context.arc (W - R, H - R, R, 0, 0.5 * Math.PI);
- context.arc (R, H - R, R, 0.5 * Math.PI, Math.PI);
+ context.arc (w - R, R, R, -0.5 * Math.PI, 0);
+ context.arc (w - R, h - R, R, 0, 0.5 * Math.PI);
+ context.arc (R, h - R, R, 0.5 * Math.PI, Math.PI);
context.close_path ();
context.set_source_rgba (colour.red, colour.green, colour.blue, colour.alpha);
@@ -219,20 +224,23 @@ public class Indicator.Keyboard.Service : Object {
int subscript_height;
subscript_layout.get_pixel_size (out subscript_width, out subscript_height);
- context.identity_matrix ();
- context.translate ((W - (text_width + subscript_width)) / 2, (H - text_height) / 2);
+ context.save ();
+ context.translate ((w - (text_width + subscript_width)) / 2, (h - text_height) / 2);
Pango.cairo_layout_path (context, text_layout);
context.fill ();
+ context.restore ();
- context.identity_matrix ();
- context.translate ((W + (text_width - subscript_width)) / 2, (H + text_height) / 2 - subscript_height);
+ context.save ();
+ context.translate ((w + (text_width - subscript_width)) / 2, (h + text_height) / 2 - subscript_height);
Pango.cairo_layout_path (context, subscript_layout);
context.fill ();
+ context.restore ();
} else {
- context.identity_matrix ();
- context.translate ((W - text_width) / 2, (H - text_height) / 2);
+ context.save ();
+ context.translate ((w - text_width) / 2, (h - text_height) / 2);
Pango.cairo_layout_path (context, text_layout);
context.fill ();
+ context.restore ();
}
}