Use gtk styles
authorEnrico Zini <enrico@enricozini.org>
Tue, 8 Dec 2009 18:56:03 +0000 (18:56 +0000)
committerEnrico Zini <enrico@enricozini.org>
Tue, 8 Dec 2009 18:56:03 +0000 (18:56 +0000)
src/fisheye.vala

index 09a9edc2b92d9634ac6b03c2c00b2f2698d238c8..2c3610255e4fee67e0fae43119007c40b6494702 100644 (file)
@@ -154,18 +154,43 @@ public class FisheyeList : Gtk.DrawingArea
 
        protected void draw(Cairo.Context context)
        {
 
        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.paint();
-               context.set_source_rgb(0, 0, 0);
 
                // Normalise coordinates
                context.translate (0, 0);
                context.scale(allocation.width, allocation.height);
 
 
                // 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
                // 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];
                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)
                        {
 
                        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();
                                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;
                        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();
                }
                        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();
        }
 
     /*
        }
 
     /*