gtk-css-engine r178 - in trunk: . src themes/gtk-css-test/gtk-2.0



Author: robsta
Date: Thu Oct 30 13:13:05 2008
New Revision: 178
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=178&view=rev

Log:
* src/gce-node.c (gce_node_cache_fetch_node), (get_viewport):
* src/gce-node.h:
* src/gce-style.c (rectangle), (gap), (line), (draw_hline),
(draw_vline), (draw_shadow), (draw_box), (draw_flat_box),
(draw_check), (draw_option), (draw_shadow_gap), (draw_box_gap),
(draw_extension), (draw_slider), (draw_handle), (draw_resize_grip),
(draw_focus), (draw_expander), (draw_diamond), (draw_arrow),
(draw_tab):
Switch to libccss' node-based viewport API.



Modified:
   trunk/ChangeLog
   trunk/src/gce-node.c
   trunk/src/gce-node.h
   trunk/src/gce-style.c
   trunk/themes/gtk-css-test/gtk-2.0/styles.css

Modified: trunk/src/gce-node.c
==============================================================================
--- trunk/src/gce-node.c	(original)
+++ trunk/src/gce-node.c	Thu Oct 30 13:13:05 2008
@@ -77,7 +77,7 @@
 	return node;
 }
 
-static GceNode *
+GceNode *
 gce_node_cache_fetch_node (GtkWidget	*widget, 
 			   char const	*class_name,
 			   char const	*pseudo_class,
@@ -85,7 +85,8 @@
 			   char const	*orientation,
 			   char const	*gap,
 			   char const	*edge,
-			   char const	*expander_style)
+			   char const	*expander_style,
+			   char const	*primitive)
 {
 	GceNode *node;
 
@@ -99,27 +100,6 @@
 	node->orientation = orientation;
 	node->edge = edge;
 	node->expander_style = expander_style;
-	node->flavor = UNSET;	
-
-	return node;
-}
-
-GceNode *
-gce_node_cache_fetch_primitive_node (GtkWidget	*widget, 
-				     char const	*class_name,
-				     char const	*pseudo_class,
-				     char const	*shadow,
-				     char const	*orientation,
-				     char const	*gap,
-				     char const	*edge,
-				     char const	*expander_style,
-				     char const	*primitive)
-{
-	GceNode *node;
-
-	node = gce_node_cache_fetch_node (widget, class_name, pseudo_class,
-					  shadow, orientation, gap, edge, 
-					  expander_style);
 	node->flavor = PRIMITIVE;	
 	node->impl.primitive = primitive;
 
@@ -344,7 +324,7 @@
 }
 
 static char *
-get_attribute (GceNode const	*node, 
+get_attribute (GceNode const	*node,
 	       char const	*name)
 {
 	GParamSpec	*param;
@@ -393,6 +373,32 @@
 	return NULL;
 }
 
+static gboolean
+get_viewport (GceNode const	*node,
+	      uint32_t		*x,
+	      uint32_t		*y,
+	      uint32_t		*width,
+	      uint32_t		*height)
+{
+	switch (node->flavor) {
+	case UNSET:
+	case PRIMITIVE:
+	case TYPE:
+		*x = node->widget->allocation.x;
+		*y = node->widget->allocation.y;
+		*width = node->widget->allocation.width;
+		*height = node->widget->allocation.height;
+		break;
+	case CONTAINER:
+	default:
+		g_warning ("Unknown flavor %d\n", node->flavor);
+		g_assert_not_reached ();
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
 static void
 release (GceNode *node)
 {
@@ -414,6 +420,7 @@
 	.get_class		= (ccss_node_get_class_f) get_class,
 	.get_pseudo_class	= (ccss_node_get_pseudo_class_f) get_pseudo_class,
 	.get_attribute		= (ccss_node_get_attribute_f) get_attribute,
+	.get_viewport		= (ccss_node_get_viewport_f) get_viewport,
 	.release		= (ccss_node_release_f) release
 };
 

Modified: trunk/src/gce-node.h
==============================================================================
--- trunk/src/gce-node.h	(original)
+++ trunk/src/gce-node.h	Thu Oct 30 13:13:05 2008
@@ -30,15 +30,15 @@
 
 typedef struct GceNode_ GceNode;
 
-GceNode * gce_node_cache_fetch_primitive_node (GtkWidget *widget, 
-					       char const *class_name,
-					       char const *pseudo_class,
-					       char const *shadow,
-					       char const *orientation,
-					       char const *gap,
-					       char const *edge,
-					       char const *expander_style,
-					       char const *primitive);
+GceNode * gce_node_cache_fetch_node (GtkWidget	*widget, 
+				     char const	*class_name,
+				     char const *pseudo_class,
+				     char const *shadow,
+				     char const *orientation,
+				     char const *gap,
+				     char const *edge,
+				     char const *expander_style,
+				     char const *primitive);
 
 GceNode * gce_node_cache_get_top_node (void);
 void gce_node_cache_release_node (GceNode *node);

Modified: trunk/src/gce-style.c
==============================================================================
--- trunk/src/gce-style.c	(original)
+++ trunk/src/gce-style.c	Thu Oct 30 13:13:05 2008
@@ -38,7 +38,7 @@
 
 static void
 rectangle (GtkStyle		*self, 
-	   GceNode const	*base,
+	   GceNode const	*node,
 	   GdkWindow		*window, 
 	   GdkRectangle		*area, 
 	   GtkWidget		*widget, 
@@ -55,7 +55,7 @@
 
 	stylesheet = gce_rc_style_get_stylesheet ();
 	style = ccss_style_new ();
-	ret = ccss_stylesheet_query (stylesheet, (ccss_node_t const *) base, style);
+	ret = ccss_stylesheet_query (stylesheet, (ccss_node_t const *) node, style);
 	if (ret) {
 		cr = gdk_cairo_create (window);
 
@@ -72,11 +72,6 @@
 			height = height == -1 ? h : height;
 		}
 
-		/* Hackishly support "background-attachment: fixed". */
-		ccss_style_set_viewport (style,
-			widget->allocation.x, widget->allocation.y,
-			widget->allocation.width, widget->allocation.height);
-
 		if (fill) {
 			ccss_style_draw_rectangle (style, cr, x, y, width, height);
 		} else {
@@ -90,7 +85,7 @@
 
 static void
 gap (GtkStyle		*self,
-     GceNode const	*base,
+     GceNode const	*node,
      GdkWindow		*window, 
      GdkRectangle	*area, 
      GtkWidget		*widget, 
@@ -109,7 +104,7 @@
 
 	stylesheet = gce_rc_style_get_stylesheet ();
 	style = ccss_style_new ();
-	ret = ccss_stylesheet_query (stylesheet, (ccss_node_t const *) base, style);
+	ret = ccss_stylesheet_query (stylesheet, (ccss_node_t const *) node, style);
 	if (ret) {
 		cr = gdk_cairo_create (window);
 
@@ -126,11 +121,6 @@
 			height = height == -1 ? h : height;
 		}
 
-		/* Hackishly support "background-attachment: fixed". */
-		ccss_style_set_viewport (style,
-			widget->allocation.x, widget->allocation.y,
-			widget->allocation.width, widget->allocation.height);
-
 		ccss_style_draw_gap (style, cr, x, y, width, height, gap_side, gap_start, gap_width);
 
 		cairo_destroy (cr), cr = NULL;
@@ -140,7 +130,7 @@
 
 static void
 line (GtkStyle		*self,
-      GceNode		*base,
+      GceNode		*node,
       GdkWindow		*window, 
       GdkRectangle	*area, 
       GtkWidget		*widget, 
@@ -156,7 +146,7 @@
 
 	stylesheet = gce_rc_style_get_stylesheet ();
 	style = ccss_style_new ();
-	ret = ccss_stylesheet_query (stylesheet, (ccss_node_t const *) base, style);
+	ret = ccss_stylesheet_query (stylesheet, (ccss_node_t const *) node, style);
 	if (ret) {
 		cr = gdk_cairo_create (window);
 
@@ -165,11 +155,6 @@
 			cairo_clip (cr);
 		}
 
-		/* Hackishly support "background-attachment: fixed". */
-		ccss_style_set_viewport (style,
-			widget->allocation.x, widget->allocation.y,
-			widget->allocation.width, widget->allocation.height);
-
 		ccss_style_draw_line (style, cr, x1, x2, y1, y2);
 
 		cairo_destroy (cr), cr = NULL;
@@ -188,17 +173,17 @@
 	    gint		 x2, 
 	    gint		 y)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget, 
+	node = gce_node_cache_fetch_node (widget, 
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			NULL, NULL, NULL, NULL, NULL,
 			"hline");
 
-	line (self, base, window, area, widget, x1, x2, y, y);
+	line (self, node, window, area, widget, x1, x2, y, y);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -212,17 +197,17 @@
 	    gint		 y2, 
 	    gint		 x)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget, 
+	node = gce_node_cache_fetch_node (widget, 
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			NULL, NULL, NULL, NULL, NULL,
 			"vline");
 
-	line (self, base, window, area, widget, x, x, y1, y2);
+	line (self, node, window, area, widget, x, x, y1, y2);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 
 }
 
@@ -239,19 +224,19 @@
 	     gint		 width, 
 	     gint		 height)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget, 
+	node = gce_node_cache_fetch_node (widget, 
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
 			NULL, NULL, NULL, NULL,
 			"shadow");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -267,19 +252,19 @@
 	  gint			 width,
 	  gint			 height)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget, 
+	node = gce_node_cache_fetch_node (widget, 
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
 			NULL, NULL, NULL, NULL,
 			"box");
 
-	rectangle (self, base, window, area, widget,
+	rectangle (self, node, window, area, widget,
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -295,19 +280,19 @@
 	       gint		 width,
 	       gint		 height)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget, 
+	node = gce_node_cache_fetch_node (widget, 
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
 			NULL, NULL, NULL, NULL,
 			"flatbox");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -323,19 +308,19 @@
 	    gint		 width,
 	    gint		 height)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget, 
+	node = gce_node_cache_fetch_node (widget, 
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
 			NULL, NULL, NULL, NULL,
 			"check");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -351,19 +336,19 @@
 	     gint		 width,
 	     gint		 height)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget, 
+	node = gce_node_cache_fetch_node (widget, 
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
 			NULL, NULL, NULL, NULL,
 			"option");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -382,19 +367,19 @@
 		 gint			 gap_start,
 		 gint			 gap_width)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget, 
+	node = gce_node_cache_fetch_node (widget, 
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
 			NULL, gce_maps_get_position (gap_side), NULL, NULL,
 			"shadow");
 
-	gap (self, base, window, area, widget, 
+	gap (self, node, window, area, widget, 
 	     x, y, width, height, gap_side, gap_start, gap_width);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -413,19 +398,19 @@
 	      gint			 gap_start,
 	      gint			 gap_width)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget, 
+	node = gce_node_cache_fetch_node (widget, 
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
 			NULL, gce_maps_get_position (gap_side), NULL, NULL,
 			"box");
 
-	gap (self, base, window, area, widget, 
+	gap (self, node, window, area, widget, 
 	     x, y, width, height, gap_side, gap_start, gap_width);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -442,10 +427,10 @@
 		gint		 height,
 		GtkPositionType	 gap_side)
 {
-	GceNode *base;
+	GceNode *node;
 	gint	 gap_width;
 
-	base = gce_node_cache_fetch_primitive_node (widget, 
+	node = gce_node_cache_fetch_node (widget, 
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
@@ -463,10 +448,10 @@
 		break;
 	}
 
-	gap (self, base, window, area, widget, 
+	gap (self, node, window, area, widget, 
 	     x, y, width, height, gap_side, 0, gap_width);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -483,9 +468,9 @@
 	     gint		 height,
 	     GtkOrientation	 orientation)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget,
+	node = gce_node_cache_fetch_node (widget,
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
@@ -493,10 +478,10 @@
 			NULL, NULL, NULL,
 			"slider");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -513,9 +498,9 @@
 	     gint		 height,
 	     GtkOrientation	 orientation)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget,
+	node = gce_node_cache_fetch_node (widget,
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
@@ -523,10 +508,10 @@
 			NULL, NULL, NULL,
 			"handle");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -542,18 +527,18 @@
 		  gint			 width,
 		  gint			 height)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget,
+	node = gce_node_cache_fetch_node (widget,
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			NULL, NULL, NULL, gce_maps_get_window_edge (edge), NULL,
 			"resizegrip");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 
@@ -568,18 +553,18 @@
 	    gint		 width,
 	    gint		 height)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget,
+	node = gce_node_cache_fetch_node (widget,
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			NULL, NULL, NULL, NULL, NULL,
 			"focus");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, FALSE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void
@@ -594,7 +579,7 @@
 	       GtkExpanderStyle	 style)
 {
 #define DEFAULT_EXPANDER_SIZE 12
-	GceNode *base;
+	GceNode *node;
 	gint	 expander_size;
 
 	if (widget &&
@@ -607,16 +592,16 @@
 		expander_size = DEFAULT_EXPANDER_SIZE;
 	}
 
-	base = gce_node_cache_fetch_primitive_node (widget,
+	node = gce_node_cache_fetch_node (widget,
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			NULL, NULL, NULL, NULL, gce_maps_get_expander_style (style),
 			"expander");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, expander_size, expander_size, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 #undef DEFAULT_EXPANDER_SIZE
 }
 
@@ -633,19 +618,19 @@
 	      gint		 width,
 	      gint		 height)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget,
+	node = gce_node_cache_fetch_node (widget,
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
 			NULL, NULL, NULL, NULL,
 			"diamond");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 /*
@@ -666,9 +651,9 @@
 	    gint		 width,
 	    gint		 height)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget,
+	node = gce_node_cache_fetch_node (widget,
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
@@ -676,10 +661,10 @@
 			NULL, NULL, NULL,
 			"arrow");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void
@@ -695,19 +680,19 @@
 	  gint			 width,
 	  gint			 height)
 {
-	GceNode *base;
+	GceNode *node;
 
-	base = gce_node_cache_fetch_primitive_node (widget,
+	node = gce_node_cache_fetch_node (widget,
 			gce_maps_get_detail (detail),
 			gce_maps_get_state (state),
 			gce_maps_get_shadow (shadow),
 			NULL, NULL, NULL, NULL,
 			"tab");
 
-	rectangle (self, base, window, area, widget, 
+	rectangle (self, node, window, area, widget, 
 		   x, y, width, height, TRUE);
 
-	gce_node_cache_release_node (base);
+	gce_node_cache_release_node (node), node = NULL;
 }
 
 static void 

Modified: trunk/themes/gtk-css-test/gtk-2.0/styles.css
==============================================================================
--- trunk/themes/gtk-css-test/gtk-2.0/styles.css	(original)
+++ trunk/themes/gtk-css-test/gtk-2.0/styles.css	Thu Oct 30 13:13:05 2008
@@ -114,6 +114,7 @@
 }
 
 resizegrip[edge=south-east] {
+	background-color: darkgrey;
 	border-right: 2px solid blue;
 	border-bottom: 2px solid blue;
 }



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