[gnome-themes-standard] adwaita: remove fallback code paths for checkboxes/radiobuttons



commit 2099ba3b2dd53267f7a00172422922a0b9e0c5a3
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Apr 28 16:17:50 2011 -0400

    adwaita: remove fallback code paths for checkboxes/radiobuttons
    
    No point in using a fallback different from the GTK+ one.

 src/adwaita_engine.c |  161 ++++----------------------------------------------
 1 files changed, 12 insertions(+), 149 deletions(-)
---
diff --git a/src/adwaita_engine.c b/src/adwaita_engine.c
index 883a61a..b0bb15a 100644
--- a/src/adwaita_engine.c
+++ b/src/adwaita_engine.c
@@ -349,11 +349,7 @@ adwaita_engine_render_check (GtkThemingEngine *engine,
 			     gdouble	       width,
 			     gdouble	       height)
 {
-	GdkRGBA *bg, *border, *fg;
-	gboolean inconsistent = FALSE;
-	gboolean draw_bullet;
-	GtkStateFlags state;
-	gint radius;
+	gboolean res;
 
 	if (gtk_theming_engine_has_class (engine,
 					  GTK_STYLE_CLASS_MENUITEM))
@@ -364,69 +360,13 @@ adwaita_engine_render_check (GtkThemingEngine *engine,
 		return;
 	}
 
-	if (render_from_assets_common (engine, cr,
-				       x, y + 2.0, width, height)) {
-		return;
-	}
-
-	/* fallback to old code path */
-	state = gtk_theming_engine_get_state (engine);
-	inconsistent = (state & GTK_STATE_FLAG_INCONSISTENT) != 0;
-	draw_bullet = (state & GTK_STATE_FLAG_ACTIVE);
-	draw_bullet |= inconsistent;
-
-	cairo_save (cr);
-
-	gtk_theming_engine_get (engine, state,
-				"border-radius", &radius,
-				"background-color", &bg,
-				"border-color", &border,
-				"color", &fg,
-				NULL);
+	res = render_from_assets_common (engine, cr,
+					 x, y + 2.0, width, height);
 
-	cairo_translate (cr, x, y);
-	cairo_set_line_width (cr, 1);
-
-	_cairo_round_rectangle (cr, 0.5, 0.5, width-1, height-1, 2);
-
-	if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
-	{
-		gdk_cairo_set_source_rgba (cr, bg);
-		cairo_fill_preserve (cr);
+	if (!res) {
+		GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_check
+			(engine, cr, x, y, width, height);
 	}
-
-	gdk_cairo_set_source_rgba (cr, border);
-	cairo_stroke (cr);
-
-	if (draw_bullet)
-	{
-		if (inconsistent) /* Inconsistent */
-		{
-			cairo_set_line_width (cr, 2.0);
-			cairo_move_to (cr, 3, height*0.5);
-			cairo_line_to (cr, width-3, height*0.5);
-		}
-		else
-		{
-			cairo_set_line_width (cr, 1.7);
-			cairo_move_to (cr, 0.5 + (width*0.2), (height*0.5));
-			cairo_line_to (cr, 0.5 + (width*0.4), (height*0.7));
-
-			cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7),
-					    0.5 + (width*0.5), (height*0.4),
-					    0.5 + (width*0.70), (height*0.25));
-
-		}
-
-		gdk_cairo_set_source_rgba (cr, fg);
-		cairo_stroke (cr);
-	}
-
-	cairo_restore (cr);
-
-	gdk_rgba_free (bg);
-	gdk_rgba_free (fg);
-	gdk_rgba_free (border);
 }
 
 static void
@@ -472,12 +412,7 @@ adwaita_engine_render_option (GtkThemingEngine *engine,
 			      gdouble		width,
 			      gdouble		height)
 {
-	GdkRGBA *bg, *border, *fg, highlight;
-	GtkSymbolicColor *sym, *shade;
-	gboolean inconsistent;
-	gboolean draw_bullet;
-	gdouble cx, cy, radius;
-	GtkStateFlags state;
+	gboolean res;
 
 	if (gtk_theming_engine_has_class (engine,
 					  GTK_STYLE_CLASS_MENUITEM))
@@ -486,85 +421,13 @@ adwaita_engine_render_option (GtkThemingEngine *engine,
 		return;
 	}
 
-	if (render_from_assets_common (engine, cr,
-				       x, y + 2.0, width, height)) {
-		return;
-	}
-
-	/* fallback to old code path */
-	cx = width / 2.0;
-	cy = height / 2.0;
-	radius = MIN (width, height) / 2.0;
-
-	cairo_save (cr);
-
-	state = gtk_theming_engine_get_state (engine);
-
-	gtk_theming_engine_get (engine, state,
-				"background-color", &bg,
-				"border-color", &border,
-				"color", &fg,
-				NULL);
-
-	inconsistent = (state & GTK_STATE_FLAG_INCONSISTENT) != 0;
-	draw_bullet = (state & GTK_STATE_FLAG_ACTIVE) != 0;
-	draw_bullet |= inconsistent;
+	res = render_from_assets_common (engine, cr,
+					 x, y + 2.0, width, height);
 
-	sym = gtk_symbolic_color_new_literal (bg);
-	shade = gtk_symbolic_color_new_shade (sym, 1.1);
-	gtk_symbolic_color_resolve (shade, NULL, &highlight);
-
-	cairo_translate (cr, x, y);
-	cairo_set_line_width (cr, MAX (1.0, floor (radius/6)));
-
-	cairo_new_sub_path (cr);
-	cairo_arc (cr, ceil (cx), ceil (cy), MAX (1.0, ceil (radius) - 1.5), 0, G_PI*2);
-
-	if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
-	{
-		gdk_cairo_set_source_rgba (cr, bg);
-		cairo_fill_preserve (cr);
+	if (!res) {
+		GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_option
+			(engine, cr, x, y, width, height);
 	}
-
-	gdk_cairo_set_source_rgba (cr, border);
-	cairo_stroke (cr);
-
-	if (draw_bullet)
-	{
-		if (inconsistent)
-		{
-			gdouble line_width = floor (radius * 2 / 3);
-
-			cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
-			cairo_set_line_width (cr, line_width);
-
-			cairo_move_to (cr, ceil (cx - radius/3.0 - line_width) + line_width, ceil (cy - line_width) + line_width);
-			cairo_line_to (cr, floor (cx + radius/3.0 + line_width) - line_width, ceil (cy - line_width) + line_width);
-
-			gdk_cairo_set_source_rgba (cr, fg);
-			cairo_stroke (cr);
-		}
-		else
-		{
-			cairo_new_sub_path (cr);
-			cairo_arc (cr, ceil (cx), ceil (cy), floor (radius/2.0), 0, G_PI*2);
-			gdk_cairo_set_source_rgba (cr, fg);
-			cairo_fill (cr);
-
-			cairo_arc (cr, floor (cx - radius/10.0), floor (cy - radius/10.0), floor (radius/6.0), 0, G_PI*2);
-			cairo_set_source_rgba (cr, highlight.red, highlight.green, highlight.blue, 0.5);
-			cairo_fill (cr);
-		}
-	}
-
-	cairo_restore (cr);
-
-	gdk_rgba_free (bg);
-	gdk_rgba_free (fg);
-	gdk_rgba_free (border);
-
-	gtk_symbolic_color_unref (sym);
-	gtk_symbolic_color_unref (shade);
 }
 
 static void



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