From d1c73924649cfcf6d30a5543f99af7a523c6e31b Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Tue, 8 Dec 2009 18:56:03 +0000 Subject: [PATCH] Use gtk styles --- src/fisheye.vala | 56 ++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/fisheye.vala b/src/fisheye.vala index 09a9edc..2c36102 100644 --- a/src/fisheye.vala +++ b/src/fisheye.vala @@ -154,18 +154,43 @@ public class FisheyeList : Gtk.DrawingArea protected void draw(Cairo.Context context) { - // White background (FIXME: get from style) - context.set_source_rgb(0.7, 0.7, 0.7); + Gtk.Style style = get_style(); + /* + public enum StateType { + NORMAL, + ACTIVE, + PRELIGHT, + SELECTED, + INSENSITIVE + } + style.bg[Gtk.StateType.NORMAL]; + */ + + + // Background + Gdk.cairo_set_source_color(context, style.bg[Gtk.StateType.NORMAL]); context.paint(); - context.set_source_rgb(0, 0, 0); // Normalise coordinates context.translate (0, 0); context.scale(allocation.width, allocation.height); + // Focus lock area + Gdk.cairo_set_source_color(context, style.bg[Gtk.StateType.ACTIVE]); + context.new_path(); + context.rectangle(0, focus_starts[0], 0.5, focus_starts[focus_end - focus_first]); + context.fill(); + context.stroke(); + + // Focus movement area + Gdk.cairo_set_source_color(context, style.bg[Gtk.StateType.INSENSITIVE]); + context.new_path(); + context.rectangle(0.5, 0, 1, 1); + context.fill(); + context.stroke(); + // Paint items around focus - context.set_line_width (0.001); - context.select_font_face("Sans", Cairo.FontSlant.NORMAL, Cairo.FontWeight.NORMAL); + context.select_font_face(style.font_desc.get_family(), Cairo.FontSlant.NORMAL, Cairo.FontWeight.NORMAL); for (int idx = focus_first; idx < focus_end; ++idx) { double y0 = focus_starts[idx - focus_first]; @@ -173,14 +198,17 @@ public class FisheyeList : Gtk.DrawingArea if (idx == cur_el) { - context.set_source_rgba(0.4, 0.4, 1, 1); + Gdk.cairo_set_source_color(context, style.bg[Gtk.StateType.SELECTED]); context.new_path(); context.rectangle(0, y0, 1, y1-y0); context.fill(); context.stroke(); + + Gdk.cairo_set_source_color(context, style.fg[Gtk.StateType.SELECTED]); + } else { + Gdk.cairo_set_source_color(context, style.fg[Gtk.StateType.NORMAL]); } - context.set_source_rgba(0, 0, 0, 1); context.new_path(); context.set_font_size(y1-y0); Cairo.FontExtents extents; @@ -190,20 +218,6 @@ public class FisheyeList : Gtk.DrawingArea context.fill(); context.stroke(); } - - // Paint focus lock area - context.set_source_rgba(1, 1, 1, 0.2); - context.new_path(); - context.rectangle(0, focus_starts[0], 0.5, focus_starts[focus_end - focus_first]); - context.fill(); - context.stroke(); - - // Paint focus movement area - context.set_source_rgba(0.8, 1, 1, 0.8); - context.new_path(); - context.rectangle(0.5, 0, 1, 1); - context.fill(); - context.stroke(); } /* -- 2.30.2