[gtk-css-engine] [style] Update to ccss-0.5 API.



commit fc4feb67466958d52b91d2da0e959540f8eddc18
Author: Robert Staudinger <robsta gnome org>
Date:   Fri Aug 7 19:02:45 2009 +0200

    [style] Update to ccss-0.5 API.
    
    No more 'line' and 'outline' functions.
    
    Add support for 'gtk-focus' and update the 'moblesse' theme.

 src/gce-maps.c                    |    8 +++--
 src/gce-rc-style.c                |    5 ++-
 src/gce-style.c                   |   66 ++++++++++---------------------------
 themes/moblesse/gtk-2.0/gtkrc.css |    6 +++
 4 files changed, 32 insertions(+), 53 deletions(-)
---
diff --git a/src/gce-maps.c b/src/gce-maps.c
index 1363f84..c32bcce 100644
--- a/src/gce-maps.c
+++ b/src/gce-maps.c
@@ -165,7 +165,8 @@ static const struct {
   { "gtk-handle",	"GtkVScale",			"slider",	-1,		NULL,		NULL },
   { "gtk-trough",	"GtkVScrollbar",		"box",		-1,		_trough_detail,	NULL },
   { NULL,		"GtkVScrollbar",		"box",		-1,		NULL,		get_stepper },
-  { "gtk-handle",	"GtkVScrollbar",		"slider",	-1,		NULL,		NULL }
+  { "gtk-handle",	"GtkVScrollbar",		"slider",	-1,		NULL,		NULL },
+  { "gtk-focus",	NULL,				"focus",	-1,		NULL,		NULL }
 };
 
 char const *
@@ -190,9 +191,10 @@ gce_maps_match_role (GtkWidget		*widget,
 
 	had_match = FALSE;
 	for (unsigned int i = 0; i < G_N_ELEMENTS (_widgets); i++) {
-		if (0 == g_strcmp0 (type_name, _widgets[i].type_name)) {
-			had_match = TRUE;
+		if (NULL == _widgets[i].type_name ||
+		    0 == g_strcmp0 (type_name, _widgets[i].type_name)) {
 			if (0 == g_strcmp0 (primitive, _widgets[i].primitive)) {
+				had_match = TRUE;
 				if (_widgets[i].shadow > -1) {
 					/* Match by shadow. */
 					if (_widgets[i].shadow == shadow)
diff --git a/src/gce-rc-style.c b/src/gce-rc-style.c
index 47483bf..13d4125 100644
--- a/src/gce-rc-style.c
+++ b/src/gce-rc-style.c
@@ -70,6 +70,7 @@ parse_href (GtkRcStyle	*rc_style,
 	ccss_stylesheet_t	*stylesheet;
 	char			*gce_file;
 	guint			 token;
+	guint			 descriptor;
 
 	token = g_scanner_get_next_token (scanner);
 	g_assert (token == '=');
@@ -92,10 +93,10 @@ parse_href (GtkRcStyle	*rc_style,
 	g_free (gce_file), gce_file = NULL;
 
 	/* User-agent stylesheet */
-	stylesheet = ccss_stylesheet_add_from_file (stylesheet, GCE_UA_STYLESHEET,
+	descriptor = ccss_stylesheet_add_from_file (stylesheet, GCE_UA_STYLESHEET,
 						    CCSS_STYLESHEET_USER_AGENT,
 						    NULL);
-	if (stylesheet) {
+	if (descriptor) {
 
 		GceRcStyle *gce_rc_style;
 
diff --git a/src/gce-style.c b/src/gce-style.c
index 25b5574..2ff5212 100644
--- a/src/gce-style.c
+++ b/src/gce-style.c
@@ -68,11 +68,9 @@ rectangle (GceStyle		*self,
 			height = height == -1 ? h : height;
 		}
 
-		if (fill) {
-			ccss_cairo_style_draw_rectangle (style, cr, x, y, width, height);
-		} else {
-			ccss_cairo_style_draw_outline (style, cr, x, y, width, height);
-		}
+		/* FIXME: force 'background: none' by inserting/frobbing? */
+		ccss_cairo_style_draw_rectangle (style, cr, x, y, width, height);
+
 
 		cairo_destroy (cr), cr = NULL;
 		ccss_style_destroy (style), style = NULL;
@@ -130,44 +128,6 @@ gap (GceStyle		*self,
 	}
 }
 
-static void
-line (GceStyle		*self,
-      GceNode		*node,
-      GdkWindow		*window, 
-      GdkRectangle	*area, 
-      GtkWidget		*widget, 
-      gint		 x1, 
-      gint		 x2, 
-      gint		 y1, 
-      gint		 y2)
-{
-	cairo_t		*cr;
-	ccss_style_t	*style = NULL;
-
-	g_return_if_fail (self);
-	g_return_if_fail (self->stylesheet);
-
-	if (node) {
-		style = ccss_stylesheet_query (self->stylesheet, (ccss_node_t *) node);
-	} else if (self->selector) {
-		style = ccss_stylesheet_query_type (self->stylesheet, self->selector);
-	}
-
-	if (style) {
-		cr = gdk_cairo_create (window);
-
-		if (area) {
-			gdk_cairo_rectangle (cr, area);
-			cairo_clip (cr);
-		}
-
-		ccss_cairo_style_draw_line (style, cr, x1, x2, y1, y2);
-
-		cairo_destroy (cr), cr = NULL;
-		ccss_style_destroy (style), style = NULL;
-	}
-}
-
 static void 
 draw_hline (GtkStyle		*self, 
 	    GdkWindow		*window, 
@@ -181,9 +141,12 @@ draw_hline (GtkStyle		*self,
 {
 	char const	*role;
 	GceNode		*node = NULL;
+	gint		 width = x2 - x1 + 1;
+	gint		 height = 2;
 
 	detail = gce_maps_get_detail (detail);
-	role = gce_maps_match_role (widget, "hline", -1, detail, x1, y, x2 - x1, -1);
+	role = gce_maps_match_role (widget, "hline", -1, detail,
+				    x1, y, width, height);
 
 	if (widget)
 		node = gce_node_cache_fetch_node (widget, 
@@ -192,7 +155,9 @@ draw_hline (GtkStyle		*self,
 			NULL, NULL, NULL, NULL, NULL,
 			role ? role : "hline");
 
-	line (GCE_STYLE (self), node, window, area, widget, x1, x2, y, y);
+	/* FIXME: hardcode line width of 2, learn about wide separators. */
+	rectangle (GCE_STYLE (self), node, window, area, widget,
+		   x1, y, width, height, TRUE);
 
 	gce_node_cache_release_node (node), node = NULL;
 }
@@ -210,9 +175,12 @@ draw_vline (GtkStyle		*self,
 {
 	char const	*role;
 	GceNode		*node = NULL;
+	gint		 width = 2;
+	gint		 height = y2 - y1 + 1;
 
 	detail = gce_maps_get_detail (detail);
-	role = gce_maps_match_role (widget, "vline", -1, detail, x, y1, -1, y2 - y1);
+	role = gce_maps_match_role (widget, "vline", -1, detail,
+				    x, y1, width, height);
 
 	if (widget)
 		node = gce_node_cache_fetch_node (widget, 
@@ -221,7 +189,9 @@ draw_vline (GtkStyle		*self,
 			NULL, NULL, NULL, NULL, NULL,
 			role ? role : "vline");
 
-	line (GCE_STYLE (self), node, window, area, widget, x, x, y1, y2);
+	/* FIXME: hardcode line width of 2, learn about wide separators. */
+	rectangle (GCE_STYLE (self), node, window, area, widget,
+		   x, y1, width, height, TRUE);
 
 	gce_node_cache_release_node (node), node = NULL;
 
@@ -254,7 +224,7 @@ draw_shadow (GtkStyle		*self,
 			NULL, NULL, NULL, NULL,
 			role ? role : "shadow");
 
-	rectangle (GCE_STYLE (self), node, window, area, widget, 
+	rectangle (GCE_STYLE (self), node, window, area, widget,
 		   x, y, width, height, TRUE);
 
 	gce_node_cache_release_node (node), node = NULL;
diff --git a/themes/moblesse/gtk-2.0/gtkrc.css b/themes/moblesse/gtk-2.0/gtkrc.css
index 4b9fa46..303f0f2 100644
--- a/themes/moblesse/gtk-2.0/gtkrc.css
+++ b/themes/moblesse/gtk-2.0/gtkrc.css
@@ -45,6 +45,12 @@ gtk-check-mark[shadow=in] {
 	background: gtk-color(selected_bg_color);
 }
 
+gtk-focus {
+	background-color: none;
+	background-image: none;
+	border: 1px dotted gtk-color(selected_bg_color);
+}
+
 gtk-handle {
 	border: 1px solid;
   border-radius: 3px;



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