[gnome-themes-standard] switch: render the switch grip on top of the slider background



commit 8b85710999737c5a3f09fc85d74cd9b40b538fdb
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Mar 16 17:17:24 2011 -0400

    switch: render the switch grip on top of the slider background

 src/adwaita_engine.c           |   55 ++++++++++++++++++++++++++++++++++++++++
 themes/Adwaita/gtk-3.0/gtk.css |    2 +
 2 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/src/adwaita_engine.c b/src/adwaita_engine.c
index fb46f68..f50dfc9 100644
--- a/src/adwaita_engine.c
+++ b/src/adwaita_engine.c
@@ -1280,6 +1280,52 @@ draw_mark_slider (cairo_t *cr,
 }
 
 static void
+render_switch_lines (GtkThemingEngine *engine,
+		     cairo_t *cr,
+		     gdouble x,
+		     gdouble y,
+		     gdouble width,
+		     gdouble height,
+		     GtkOrientation orientation)
+{
+	GtkStateFlags state;
+	GdkRGBA *lines_color;
+
+	state = gtk_theming_engine_get_state (engine);
+
+	if (state & GTK_STATE_FLAG_INSENSITIVE) {
+		return;
+	}
+
+	gtk_theming_engine_get (engine, state,
+				"-adwaita-switch-grip-color", &lines_color,
+				NULL);
+
+	cairo_save (cr);
+
+	cairo_translate (cr,
+			 x + width / 2.0 - 4.0,
+			 y + height / 2.0 - 3.0);
+
+	cairo_move_to (cr, 0.0, 0.0);
+	cairo_set_line_width (cr, 2.0);
+	cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+
+	cairo_line_to (cr, 0.0, 6.0);
+	cairo_move_to (cr, 4.0, 0.0);
+	cairo_line_to (cr, 4.0, 6.0);
+	cairo_move_to (cr, 8.0, 0.0);
+	cairo_line_to (cr, 8.0, 6.0);
+
+	gdk_cairo_set_source_rgba (cr, lines_color);
+	cairo_stroke (cr);
+
+	cairo_restore (cr);
+
+	gdk_rgba_free (lines_color);
+}
+
+static void
 adwaita_engine_render_slider (GtkThemingEngine *engine,
 			      cairo_t          *cr,
 			      gdouble           x,
@@ -1365,6 +1411,10 @@ adwaita_engine_render_slider (GtkThemingEngine *engine,
 		GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_slider (engine, cr,
 										       x, y, width, height,
 										       orientation);
+
+		if (gtk_widget_path_is_type (path, GTK_TYPE_SWITCH)) {
+			render_switch_lines (engine, cr, x, y, width, height, orientation);
+		}
 	}
 
 	cairo_restore (cr);
@@ -1741,6 +1791,11 @@ adwaita_engine_class_init (AdwaitaEngineClass *klass)
 								  "Menuitem arrow color",
 								  "Menuitem arrow color",
 								  GDK_TYPE_RGBA, 0));
+	gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
+					      g_param_spec_boxed ("switch-grip-color",
+								  "Switch grip color",
+								  "Switch grip color",
+								  GDK_TYPE_RGBA, 0));
 }
 
 static void
diff --git a/themes/Adwaita/gtk-3.0/gtk.css b/themes/Adwaita/gtk-3.0/gtk.css
index 3378728..a76d0bb 100644
--- a/themes/Adwaita/gtk-3.0/gtk.css
+++ b/themes/Adwaita/gtk-3.0/gtk.css
@@ -916,6 +916,8 @@ GtkSwitch.slider {
                                      color-stop (0.85, @switch_slider_color),
                                      color-stop (0.86, shade (@switch_slider_color, 1.03)),
                                      to (shade (@switch_slider_color, 1.03)));
+
+    -adwaita-switch-grip-color: shade (@switch_slider_color, 0.97);
 }
 
 GtkSwitch.slider:active {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]