aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-04-05 12:42:01 -0400
committerWilliam Hua <william.hua@canonical.com>2013-04-05 12:42:01 -0400
commitc651a970c8f618d698c50a15905f9496adbcc4ab (patch)
tree859cefa4a3f518b77581e001bf818c2c1978bc33
parent125fbd0aefd1c636fcc1c4af4740d83416181893 (diff)
downloadayatana-indicator-keyboard-c651a970c8f618d698c50a15905f9496adbcc4ab.tar.gz
ayatana-indicator-keyboard-c651a970c8f618d698c50a15905f9496adbcc4ab.tar.bz2
ayatana-indicator-keyboard-c651a970c8f618d698c50a15905f9496adbcc4ab.zip
Rounded corners.
-rw-r--r--lib/main.vala19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/main.vala b/lib/main.vala
index 23e4b861..99a29b44 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -37,17 +37,28 @@ public class Indicator.Keyboard.Service : Object {
[DBus (visible = false)]
protected virtual Icon create_icon (string text) {
+ const int W = 20;
+ const int H = 20;
+ const double R = 2.0;
+
Pango.FontDescription description;
var style = get_style_context ();
var colour = style.get_color (Gtk.StateFlags.NORMAL);
style.get (Gtk.StateFlags.NORMAL, Gtk.STYLE_PROPERTY_FONT, out description);
- var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, 20, 20);
+ var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, W, H);
var context = new Cairo.Context (surface);
+ 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.close_path ();
+
context.set_source_rgba (colour.red, colour.green, colour.blue, colour.alpha);
context.set_source_rgba (1.0, 0.0, 0.0, 1.0);
- context.paint ();
+ context.fill ();
context.set_operator (Cairo.Operator.CLEAR);
var layout = Pango.cairo_create_layout (context);
@@ -58,11 +69,11 @@ public class Indicator.Keyboard.Service : Object {
int width;
int height;
layout.get_pixel_size (out width, out height);
- context.translate (Posix.floor (10.0 - 0.5 * width), Posix.floor (10.0 - 0.5 * height));
+ context.translate ((W - width) / 2, (H - height) / 2);
Pango.cairo_layout_path (context, layout);
context.fill ();
- return Gdk.pixbuf_get_from_surface (surface, 0, 0, 20, 20);
+ return Gdk.pixbuf_get_from_surface (surface, 0, 0, W, H);
}
[DBus (visible = false)]