gtk-css-engine r16 - in bzr-playground: . libccd/ccd src themes/gtk-css-test/gtk-2.0
- From: robsta svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk-css-engine r16 - in bzr-playground: . libccd/ccd src themes/gtk-css-test/gtk-2.0
- Date: Mon, 18 Aug 2008 13:50:56 +0000 (UTC)
Author: robsta
Date: Mon Aug 18 13:50:56 2008
New Revision: 16
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=16&view=rev
Log:
Fix wildcard selectors.
Modified:
bzr-playground/ (props changed)
bzr-playground/TODO
bzr-playground/libccd/ccd/ccd-background.c
bzr-playground/libccd/ccd/ccd-color.c
bzr-playground/libccd/ccd/ccd-color.h
bzr-playground/libccd/ccd/ccd-selector-group.c
bzr-playground/libccd/ccd/ccd-style.c
bzr-playground/libccd/ccd/ccd-stylesheet.c
bzr-playground/src/gce-style.c
bzr-playground/themes/gtk-css-test/gtk-2.0/styles.css
Modified: bzr-playground/TODO
==============================================================================
--- bzr-playground/TODO (original)
+++ bzr-playground/TODO Mon Aug 18 13:50:56 2008
@@ -56,7 +56,8 @@
* Support widget mimicking by creating Gtk[Rc]Style style information and
feeding it back into gtk, e.g. using gtk_rc_parse(). Maybe we would end up
with two drawing modes, the `normal' one and the GtkStyle based one. In any
- case gtk_rc_get_style_by_paths() should work.
+ case gtk_rc_get_style_by_paths() should work. This is very apparent e.g. with
+ the empty treeview in TWF. Maybe need to fix this earlier, at least partially.
More 0. releases go here if needed ...
Modified: bzr-playground/libccd/ccd/ccd-background.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-background.c (original)
+++ bzr-playground/libccd/ccd/ccd-background.c Mon Aug 18 13:50:56 2008
@@ -32,6 +32,27 @@
g_free (self);
}
+/*
+static bool
+bg_color_parse (ccd_background_color_t *self,
+ CRTerm const *values)
+{
+ ccd_property_spec_t spec;
+
+ spec = ccd_color_parse (self->color, values);
+ if (CCD_PROPERTY_SPEC_UNSET == spec) {
+
+ }
+}
+
+static bool
+bg_image_parse (ccd_background_image_t *self,
+ CRTerm const *values)
+{
+
+}
+*/
+
bool
ccd_background_parse (ccd_background_t *self,
char const *property,
Modified: bzr-playground/libccd/ccd/ccd-color.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-color.c (original)
+++ bzr-playground/libccd/ccd/ccd-color.c Mon Aug 18 13:50:56 2008
@@ -1,7 +1,7 @@
/* The Cairo CSS Drawing Library.
* Copyright (C) 2008 Robert Staudinger
*
- * Functions ccd_color_parse_hex() and hex() were taken from pango,
+ * Functions parse_hex() and hex() were derived from pango-1.21.3,
* Copyright (C) 2000 Red Hat Software, License: LGPL 2 or later.
*
* This library is free software; you can redistribute it and/or
@@ -178,17 +178,17 @@
{ "yellowgreen", { 0x9a/255., 0xcd/255., 0x32/255. } },
};
-bool
-ccd_color_parse_name (char const *css_color_name,
- ccd_color_t *color)
+static bool
+parse_name (ccd_color_t *self,
+ char const *css_color_name)
{
- g_return_val_if_fail (css_color_name && color, false);
+ g_return_val_if_fail (css_color_name && self, false);
for (unsigned int i = 0; i < G_N_ELEMENTS (_color_map); i++) {
if (0 == g_ascii_strcasecmp (_color_map[i].name, css_color_name)) {
- color->red = _color_map[i].color.red;
- color->green = _color_map[i].color.green;
- color->blue = _color_map[i].color.blue;
+ self->red = _color_map[i].color.red;
+ self->green = _color_map[i].color.green;
+ self->blue = _color_map[i].color.blue;
return true;
}
}
@@ -197,43 +197,45 @@
}
static gboolean
-hex (char const *spec,
+hex (char const *color,
int len,
unsigned int *c)
{
const char *end;
*c = 0;
- for (end = spec + len; spec != end; spec++)
- if (g_ascii_isxdigit (*spec))
- *c = (*c << 4) | g_ascii_xdigit_value (*spec);
- else
- return false;
+ for (end = color + len; color != end; color++) {
+ if (g_ascii_isxdigit (*color)) {
+ *c = (*c << 4) | g_ascii_xdigit_value (*color);
+ } else {
+ return false;
+ }
+ }
return true;
}
-bool
-ccd_color_parse_hex (char const *spec,
- ccd_color_t *color)
+static bool
+parse_hex (ccd_color_t *self,
+ char const *color)
{
size_t len;
unsigned int r, g, b;
- g_return_val_if_fail (spec, false);
+ g_return_val_if_fail (color, false);
- len = strlen (spec);
+ len = strlen (color);
if (len % 3 || len < 3 || len > 12)
return false;
len /= 3;
- if (!hex (spec, len, &r) ||
- !hex (spec + len, len, &g) ||
- !hex (spec + len * 2, len, &b))
+ if (!hex (color, len, &r) ||
+ !hex (color + len, len, &g) ||
+ !hex (color + len * 2, len, &b))
return false;
- if (color) {
+ if (self) {
int bits = len * 4;
r <<= 16 - bits;
g <<= 16 - bits;
@@ -244,9 +246,9 @@
b |= (b >> bits);
bits *= 2;
}
- color->red = r / 65535.;
- color->green = g / 65535.;
- color->blue = b / 65535.;
+ self->red = r / 65535.;
+ self->green = g / 65535.;
+ self->blue = b / 65535.;
}
return true;
@@ -268,12 +270,12 @@
return type;
}
str = cr_string_peek_raw_str (value->content.str);
- return ccd_color_parse_name (str, self) ?
+ return parse_name (self, str) ?
CCD_PROPERTY_SPEC_SET :
CCD_PROPERTY_SPEC_UNSET;
case TERM_HASH:
str = cr_string_peek_raw_str (value->content.str);
- return ccd_color_parse_hex (str, self) ?
+ return parse_hex (self, str) ?
CCD_PROPERTY_SPEC_SET :
CCD_PROPERTY_SPEC_UNSET;
case TERM_RGB:
Modified: bzr-playground/libccd/ccd/ccd-color.h
==============================================================================
--- bzr-playground/libccd/ccd/ccd-color.h (original)
+++ bzr-playground/libccd/ccd/ccd-color.h Mon Aug 18 13:50:56 2008
@@ -34,10 +34,6 @@
double blue;
} ccd_color_t;
-bool ccd_color_parse_name (char const *css_color_name, ccd_color_t *color);
-
-bool ccd_color_parse_hex (char const *OxRRGGBB, ccd_color_t *color);
-
ccd_property_spec_t ccd_color_parse (ccd_color_t *self, CRTerm const *value);
void ccd_color_dump (ccd_color_t const *self);
Modified: bzr-playground/libccd/ccd/ccd-selector-group.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-selector-group.c (original)
+++ bzr-playground/libccd/ccd/ccd-selector-group.c Mon Aug 18 13:50:56 2008
@@ -288,11 +288,11 @@
if (ret) {
if (info->as_base) {
new_selector = ccd_selector_copy_as_base (selector, info->specificity_e);
+ info->specificity_e++;
} else {
new_selector = ccd_selector_copy (selector);
}
ccd_selector_group_add_selector (info->result_group, new_selector);
- info->specificity_e++;
info->ret = true;
}
iter = iter->next;
@@ -314,7 +314,10 @@
info.node = node;
info.result_group = result_group;
info.as_base = as_base;
- info.specificity_e = calculate_min_specificity_e (result_group, g_tree_nnodes (self->sets));
+ if (as_base) {
+ info.specificity_e = calculate_min_specificity_e (result_group,
+ g_tree_nnodes (self->sets));
+ }
info.ret = false;
g_tree_foreach (self->sets, (GTraverseFunc) traverse_query, &info);
Modified: bzr-playground/libccd/ccd/ccd-style.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-style.c (original)
+++ bzr-playground/libccd/ccd/ccd-style.c Mon Aug 18 13:50:56 2008
@@ -51,26 +51,32 @@
int32_t y1,
int32_t y2)
{
- double off;
+ ccd_border_stroke_t const *stroke;
+ double off;
if (y1 == y2) {
- /* horizontal */
+ /* Horizontal: try to use top, then bottom border. */
+ stroke = self->top ? self->top : self->bottom;
+ if (stroke) {
+ /* Unlike borders, lines are not drawn inside the box,
+ * account for that. */
+ off =stroke->width / 2.;
- /* Unlike borders, lines are not drawn inside the box,
- * account for that. */
- off = self->top->width / 2.;
+ ccd_border_draw (NULL, stroke, NULL, NULL,
+ cr, x1, y1 - off, x2 - x1, 0);
- ccd_border_draw (NULL, self->top, NULL, NULL,
- cr, x1, y1 - off, x2 - x1, 0);
+ }
} else {
- /* vertical */
-
- /* Unlike borders, lines are not drawn inside the box,
- * account for that. */
- off = self->left->width / 2.;
-
- ccd_border_draw (self->left, NULL, NULL, NULL,
- cr, x1 - off, y1, 0, y2 - y1);
+ /* Vertical: try to use left, then right border. */
+ stroke = self->left ? self->left : self->right;
+ if (stroke) {
+ /* Unlike borders, lines are not drawn inside the box,
+ * account for that. */
+ off = self->left->width / 2.;
+
+ ccd_border_draw (stroke, NULL, NULL, NULL,
+ cr, x1 - off, y1, 0, y2 - y1);
+ }
}
}
Modified: bzr-playground/libccd/ccd/ccd-stylesheet.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-stylesheet.c (original)
+++ bzr-playground/libccd/ccd/ccd-stylesheet.c Mon Aug 18 13:50:56 2008
@@ -235,7 +235,6 @@
ret |= collect_type_r (self, node, base, result_group, true);
node_class->release (base);
}
-
} else {
g_warning ("No type name");
}
@@ -260,29 +259,35 @@
ccd_selector_group_t *result_group,
bool as_base)
{
- ccd_node_class_t const *node_class;
- bool have_type;
- bool have_class;
- bool have_id;
+ ccd_node_class_t const *node_class;
+ ccd_selector_group_t const *group;
+ bool ret;
node_class = ccd_node_get_class ();
g_return_val_if_fail (self && node && result_group, false);
+ ret = false;
+
+ /* Match wildcard styles. */
+ group = g_hash_table_lookup (self->type_rules, "*");
+ if (group) {
+ ret |= ccd_selector_group_query_collect (group, node,
+ result_group, false);
+ }
+
/* match style by type information */
- have_type = collect_type_r (self, node, node, result_group, as_base);
+ ret |= collect_type_r (self, node, node, result_group, as_base);
/* match by class name
- have_class = match_class (self, node, style);
+ ret |= match_class (self, node, style);
*/
- have_class = false;
/* match by id
- have_id = query_id (self, node, style);
+ ret |= query_id (self, node, style);
*/
- have_id = false;
- return have_type || have_class || have_id;
+ return ret;
}
/*
Modified: bzr-playground/src/gce-style.c
==============================================================================
--- bzr-playground/src/gce-style.c (original)
+++ bzr-playground/src/gce-style.c Mon Aug 18 13:50:56 2008
@@ -91,6 +91,14 @@
cairo_clip (cr);
}
+ /* sanitise */
+ if (width == -1 || height == -1) {
+ gint w, h;
+ gdk_drawable_get_size (GDK_DRAWABLE (window), &w, &h);
+ width = width == -1 ? w : width;
+ height = height == -1 ? h : height;
+ }
+
ccd_selector_group_apply (group, &style);
if (fill) {
ccd_style_draw_rectangle (&style, cr, x, y, width, height);
@@ -132,6 +140,14 @@
cairo_clip (cr);
}
+ /* sanitise */
+ if (width == -1 || height == -1) {
+ gint w, h;
+ gdk_drawable_get_size (GDK_DRAWABLE (window), &w, &h);
+ width = width == -1 ? w : width;
+ height = height == -1 ? h : height;
+ }
+
ccd_selector_group_apply (group, &style);
ccd_style_draw_gap (&style, cr, x, y, width, height, gap_side, gap_start, gap_width);
Modified: bzr-playground/themes/gtk-css-test/gtk-2.0/styles.css
==============================================================================
--- bzr-playground/themes/gtk-css-test/gtk-2.0/styles.css (original)
+++ bzr-playground/themes/gtk-css-test/gtk-2.0/styles.css Mon Aug 18 13:50:56 2008
@@ -91,6 +91,10 @@
border: 1px solid black;
}
+GtkWindow flatbox {
+ background-color: khaki;
+}
+
GtkEntry flatbox {
background-color: darkkhaki;
border: none;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]