[gtk-theme-engine-clearlooks] Implement render_focus()



commit bc01d1e7dbdc7c18e46c8770b1be88407beee2f4
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 16 00:59:07 2010 +0100

    Implement render_focus()

 src/clearlooks_engine.c |   73 ++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 56 insertions(+), 17 deletions(-)
---
diff --git a/src/clearlooks_engine.c b/src/clearlooks_engine.c
index 63c1cb2..051233f 100644
--- a/src/clearlooks_engine.c
+++ b/src/clearlooks_engine.c
@@ -1304,26 +1304,49 @@ clearlooks_style_realize (GtkStyle * style)
 		ge_gdk_color_to_cairo (&style->text[i], &clearlooks_style->colors.text[i]);
 	}
 }
+#endif
 
 static void
-clearlooks_style_draw_focus (GtkStyle *style, cairo_t *cr, GtkStateType state_type,
-                             GtkWidget *widget, const gchar *detail,
-                             gint x, gint y, gint width, gint height)
+clearlooks_engine_render_focus (GtkThemingEngine *engine,
+				cairo_t          *cr,
+				gdouble           x,
+				gdouble           y,
+				gdouble           width,
+				gdouble           height)
 {
-	ClearlooksStyle  *clearlooks_style = CLEARLOOKS_STYLE (style);
-	ClearlooksColors *colors = &clearlooks_style->colors;
-	WidgetParameters params;
+	ClearlooksStyleFunctions *style_functions;
+	CairoColor *focus_color, *bg_color;
+	const GtkWidgetPath *path;
 	FocusParameters focus;
+	GtkStateFlags state;
+	gboolean disable_focus;
 	guint8* dash_list;
 
-	CHECK_ARGS
+	GE_CAIRO_INIT
+
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get (engine, state,
+				"-clearlooks-disable-focus", &disable_focus,
+				NULL);
+
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, NULL);
+
+	path = gtk_theming_engine_get_path (engine);
 
 	/* Just return if focus drawing is disabled. */
-	if (clearlooks_style->disable_focus)
+	if (disable_focus)
 		return;
 
-	clearlooks_set_widget_parameters (widget, style, state_type, &params);
+	gtk_theming_engine_get (engine, state,
+				"-clearlooks-focus-color", &focus_color,
+				NULL);
+
+	gtk_theming_engine_get (engine, GTK_STATE_FLAG_SELECTED,
+				"background-color", &bg_color,
+				NULL);
 
+#if 0
 	/* Corners */
 	params.corners = CR_CORNER_ALL;
 	if (CHECK_HINT (GE_HINT_COMBOBOX_ENTRY))
@@ -1340,6 +1363,7 @@ clearlooks_style_draw_focus (GtkStyle *style, cairo_t *cr, GtkStateType state_ty
 			width++;
 		}
 	}
+#endif
 
 	focus.has_color = FALSE;
 	focus.interior = FALSE;
@@ -1347,6 +1371,7 @@ clearlooks_style_draw_focus (GtkStyle *style, cairo_t *cr, GtkStateType state_ty
 	focus.padding = 1;
 	dash_list = NULL;
 
+#if 0
 	if (widget)
 	{
 		gtk_widget_style_get (widget,
@@ -1359,27 +1384,33 @@ clearlooks_style_draw_focus (GtkStyle *style, cairo_t *cr, GtkStateType state_ty
 	if (dash_list)
 		focus.dash_list = dash_list;
 	else
+#endif
 		focus.dash_list = (guint8*) g_strdup ("\1\1");
 
 	/* Focus type */
-	if (DETAIL("button"))
+	if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_BUTTON))
 	{
+#if 0
 		if (CHECK_HINT (GE_HINT_TREEVIEW_HEADER))
 		{
 			focus.type = CL_FOCUS_TREEVIEW_HEADER;
 		}
 		else
+#endif
 		{
 			GtkReliefStyle relief = GTK_RELIEF_NORMAL;
+#if 0
 			/* Check for the shadow type. */
 			if (widget && GTK_IS_BUTTON (widget))
 				g_object_get (G_OBJECT (widget), "relief", &relief, NULL);
+#endif
 
 			if (relief == GTK_RELIEF_NORMAL)
 				focus.type = CL_FOCUS_BUTTON;
 			else
 				focus.type = CL_FOCUS_BUTTON_FLAT;
 
+#if 0
 			/* This is a workaround for the bogus focus handling that
 			 * clearlooks has currently.
 			 * I truely dislike putting it here, but I guess it is better
@@ -1387,8 +1418,10 @@ clearlooks_style_draw_focus (GtkStyle *style, cairo_t *cr, GtkStateType state_ty
 			 * next unstable release cycle.  -- Benjamin */
 			if (ge_object_is_a (G_OBJECT (widget), "ButtonWidget"))
 				focus.type = CL_FOCUS_LABEL;
+#endif
 		}
 	}
+#if 0
 	else if (detail && g_str_has_prefix (detail, "treeview"))
 	{
 		/* Focus in a treeview, and that means a lot of different detail strings. */
@@ -1415,14 +1448,17 @@ clearlooks_style_draw_focus (GtkStyle *style, cairo_t *cr, GtkStateType state_ty
 		}
 
 	}
-	else if (detail && g_str_has_prefix (detail, "trough") && CHECK_HINT (GE_HINT_SCALE))
+#endif
+	else if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
+		 gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH))
 	{
 		focus.type = CL_FOCUS_SCALE;
 	}
-	else if (DETAIL("tab"))
+	else if (gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_TAB, NULL))
 	{
 		focus.type = CL_FOCUS_TAB;
 	}
+#if 0
 	else if (detail && g_str_has_prefix (detail, "colorwheel"))
 	{
 		if (DETAIL ("colorwheel_dark"))
@@ -1442,25 +1478,27 @@ clearlooks_style_draw_focus (GtkStyle *style, cairo_t *cr, GtkStateType state_ty
 	{
 		focus.type = CL_FOCUS_ICONVIEW;
 	}
+#endif
 	else
 	{
 		focus.type = CL_FOCUS_UNKNOWN; /* Custom widgets (Beagle) and something unknown */
 	}
 
 	/* Focus color */
-	if (clearlooks_style->has_focus_color)
+	if (focus_color)
 	{
-		ge_gdk_color_to_cairo (&clearlooks_style->focus_color, &focus.color);
+		focus.color = *focus_color;
 		focus.has_color = TRUE;
 	}
 	else
-		focus.color = colors->bg[GTK_STATE_SELECTED];
+		focus.color = *bg_color;
 
-	STYLE_FUNCTION(draw_focus) (cr, colors, &params, &focus, x, y, width, height);
+	style_functions->draw_focus (cr, engine, &focus, x, y, width, height);
 
 	g_free (focus.dash_list);
+	gdk_rgba_free ((GdkRGBA *) focus_color);
+	gdk_rgba_free ((GdkRGBA *) bg_color);
 }
-#endif
 
 static GdkPixbuf *
 set_transparency (const GdkPixbuf *pixbuf, gdouble alpha_percent)
@@ -1678,6 +1716,7 @@ clearlooks_engine_class_init (ClearlooksEngineClass * klass)
 	engine_class->render_frame_gap = clearlooks_engine_render_frame_gap;
 	engine_class->render_handle = clearlooks_engine_render_handle;
 	engine_class->render_layout = clearlooks_engine_render_layout;
+	engine_class->render_focus = clearlooks_engine_render_focus;
 	engine_class->render_icon_pixbuf = clearlooks_engine_render_icon_pixbuf;
 
         gtk_theming_engine_register_property (CLEARLOOKS_NAMESPACE, NULL,



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