gtk-css-engine r159 - in trunk: . libccss/cccss libccss/ccss src themes/gtk-css-test/gtk-2.0



Author: robsta
Date: Fri Oct  3 11:06:03 2008
New Revision: 159
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=159&view=rev

Log:
* TODO:
* libccss/ccss/ccss-color.c:
* src/gce-functions.c:
Gtk color scheme support.




Modified:
   trunk/ChangeLog
   trunk/TODO
   trunk/libccss/cccss/example-2.c
   trunk/libccss/ccss/ccss-color.c
   trunk/src/gce-functions.c
   trunk/themes/gtk-css-test/gtk-2.0/styles.css

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	(original)
+++ trunk/TODO	Fri Oct  3 11:06:03 2008
@@ -9,7 +9,6 @@
 * Improve gtkrc export.
 * Add a fixup stage when the stylesheet is loaded, handle things like 
   single `background-size: <length>;` there.
-* Background attachment.
 * Store type-name, type-id and selector-group in the GtkStyle and use that
   information if no widget is passed.
 * Border images, c.f. [border-image in Firefox](http://ejohn.org/blog/border-image-in-firefox/).
@@ -28,9 +27,12 @@
   Can be used to implement custom inactive scrollbars, c.f. 
   [Link](http://mail.gnome.org/archives/usability/2008-August/msg00037.html).
 * Animated images APNG, MNG, animated GIF, whatever gdk-pixbuf supports.
-* Support system gtk system colors.
 * [CSS Transitions](http://webkit.org/specs/CSSVisualEffects/CSSTransitions.html)
 
+#### Done:
+* Support system gtk system colors, e.g. `color: gtk-color(bg_color);`.
+* Background attachment.
+
 ### Internals ###
 * Embed the "property" struct in all properties, implement `ccss_selector_apply()`
   in a generic manner.

Modified: trunk/libccss/cccss/example-2.c
==============================================================================
--- trunk/libccss/cccss/example-2.c	(original)
+++ trunk/libccss/cccss/example-2.c	Fri Oct  3 11:06:03 2008
@@ -74,7 +74,6 @@
 	/* Load the stylesheet. */
 	ccss_init (_functions);
 	stylesheet = ccss_stylesheet_new_from_file ("example-2.css");
-	/* ccss_stylesheet_dump (stylesheet); */
 
 	stage = clutter_stage_get_default ();
 	clutter_actor_set_size (stage, 480, 320);

Modified: trunk/libccss/ccss/ccss-color.c
==============================================================================
--- trunk/libccss/ccss/ccss-color.c	(original)
+++ trunk/libccss/ccss/ccss-color.c	Fri Oct  3 11:06:03 2008
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "ccss-color.h"
+#include "ccss-function.h"
 
 static const struct {
 	char const		*name;
@@ -267,7 +268,9 @@
        CRTerm	const	**value)
 {
 	ccss_property_spec_t	 type;
+	char const		*function;
 	char const		*str;
+	char			*color;
 	bool			 ret;
 
 	g_return_val_if_fail (self, CCSS_PROPERTY_SPEC_UNSET);
@@ -304,10 +307,23 @@
 		self->blue = (*value)->content.rgb->blue;
 		*value = (*value)->next;
 		return CCSS_PROPERTY_SPEC_SET;
+	case TERM_FUNCTION:
+		/* FIXME: ATM only "hex" representation can be fed back. */
+		function = cr_string_peek_raw_str ((*value)->content.str);
+		color = ccss_function_invoke (function, (*value)->ext_content.func_param);
+		if (color) {
+			ret = parse_hex (self, color);
+			if (ret) {
+				*value = (*value)->next;
+				g_free (color), color = NULL;
+				return CCSS_PROPERTY_SPEC_SET;
+			}
+			g_free (color), color = NULL;
+		}
+		return CCSS_PROPERTY_SPEC_UNSET;
 	/* fall thru for all other enum values to prevent compiler warnings */
 	case TERM_NO_TYPE:
 	case TERM_NUMBER:
-	case TERM_FUNCTION:
 	case TERM_STRING:
 	case TERM_URI:
 	case TERM_UNICODERANGE:

Modified: trunk/src/gce-functions.c
==============================================================================
--- trunk/src/gce-functions.c	(original)
+++ trunk/src/gce-functions.c	Fri Oct  3 11:06:03 2008
@@ -61,9 +61,31 @@
 	return ret;
 }
 
+static char *
+lookup_color (GSList const *args)
+{
+	GtkSettings	*settings;
+	GHashTable	*colors;
+	GdkColor	*color;
+
+	settings = gtk_settings_get_default ();
+	colors = NULL;
+	g_object_get (G_OBJECT (settings), "color-hash", &colors, NULL);
+	g_return_val_if_fail (colors, NULL);
+
+	g_return_val_if_fail (args && args->data, NULL);
+	color = (GdkColor *) g_hash_table_lookup (colors, args->data);
+	g_return_val_if_fail (color, NULL);
+
+	return g_strdup_printf ("#%0x%0x%0x", color->red >> 8, 
+					      color->green >> 8,
+					      color->blue >> 8);
+}
+
 static ccss_function_t const _functions[] = 
 {
 	{ "url", url },
+	{ "gtk-color", lookup_color },
 	{ NULL }
 };
 

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	Fri Oct  3 11:06:03 2008
@@ -1,6 +1,7 @@
 
 * {
-	background-color: khaki;
+	background-color: gtk-color(bg_color);
+/*	background-color: khaki;
 	color: black;
 }
 
@@ -143,4 +144,4 @@
 GtkButton:normal {
 	background-color: darkkhaki;
 }
-
+*/



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