gtk-css-engine r128 - in trunk: . libccd/ccd libccd/doc libccd/doc/tmpl libccd/examples src themes/Gilouche-CSS/gtk-2.0 themes/gtk-css-test/gtk-2.0
- From: robsta svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk-css-engine r128 - in trunk: . libccd/ccd libccd/doc libccd/doc/tmpl libccd/examples src themes/Gilouche-CSS/gtk-2.0 themes/gtk-css-test/gtk-2.0
- Date: Thu, 25 Sep 2008 13:26:58 +0000 (UTC)
Author: robsta
Date: Thu Sep 25 13:26:58 2008
New Revision: 128
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=128&view=rev
Log:
* TODO: remember how to improve list iterations.
* libccd/ccd/ccd-selector-group.c:
* libccd/ccd/ccd-selector-group.h:
Add convenience API for simple uses w/o a node implementation.
* libccd/ccd/ccd-style.c:
* libccd/ccd/ccd-style.h:
Add convenience API to retrieve a style's colors.
* libccd/ccd/exports.sym:
* libccd/doc/ccd-sections.txt:
* libccd/doc/tmpl/selector_group.sgml:
* libccd/examples/example1.c:
Update auxiliary files after the changes above.
* src/Makefile.am:
* src/gce-parser.c:
* src/gce-parser.h:
Start implementing css/gtkrc infrastructure, not hooked up yet.
* themes/Gilouche-CSS/gtk-2.0/styles.css:
- Fix background-color for check- and option-primitives.
- Fix border-color for extension primitives.
Added:
trunk/src/gce-parser.c
trunk/src/gce-parser.h
Modified:
trunk/ (props changed)
trunk/ChangeLog
trunk/TODO
trunk/libccd/ccd/ccd-selector-group.c
trunk/libccd/ccd/ccd-selector-group.h
trunk/libccd/ccd/ccd-style.c
trunk/libccd/ccd/ccd-style.h
trunk/libccd/ccd/exports.sym
trunk/libccd/doc/ccd-sections.txt
trunk/libccd/doc/tmpl/selector_group.sgml
trunk/libccd/examples/example1.c
trunk/src/Makefile.am
trunk/themes/Gilouche-CSS/gtk-2.0/styles.css
trunk/themes/gtk-css-test/gtk-2.0/styles.css
Modified: trunk/TODO
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Thu Sep 25 13:26:58 2008
@@ -24,6 +24,8 @@
* Make all string comparisons case insensitive?
* Get rid of the _match() functions all toghether?
* Check 80 column code width.
+* Use `for' to iterate over GSList, e.g
+ "for (GSList const *iter = list; iter != NULL; iter = iter->next) { ... }"
Done:
* Have an internal instance of `block' with default values, ccd_style_init()
Modified: trunk/libccd/ccd/ccd-selector-group.c
==============================================================================
--- trunk/libccd/ccd/ccd-selector-group.c (original)
+++ trunk/libccd/ccd/ccd-selector-group.c Thu Sep 25 13:26:58 2008
@@ -369,17 +369,43 @@
return info.ret;
}
+typedef struct {
+ char const *type_name;
+ ccd_style_t *style;
+ bool ret;
+} traverse_apply_info_t;
+
static bool
traverse_apply (size_t specificity,
ccd_selector_set_t *set,
- ccd_style_t *style)
+ traverse_apply_info_t *info)
{
- GSList const *iter;
+ ccd_selector_t const *selector;
- iter = set->selectors;
- while (iter) {
- ccd_selector_apply ((ccd_selector_t const *) iter->data, style);
- iter = iter->next;
+ for (GSList const *iter = set->selectors; iter != NULL; iter = iter->next) {
+
+ selector = (ccd_selector_t const *) iter->data;
+ if (info->type_name) {
+
+ /* Apply only if it's a specific type. */
+ char const *key;
+ unsigned int a, b, c, d, e;
+
+ key = ccd_selector_get_key (selector);
+ ccd_selector_get_specificity_values (selector,
+ &a, &b, &c, &d, &e);
+
+ if (ccd_selector_is_type (selector) &&
+ 0 == g_ascii_strcasecmp (info->type_name, key) &&
+ a == 0 && b == 0 && c == 0 && d == 1 && e == 0) {
+
+ info->ret |= ccd_selector_apply (selector,
+ info->style);
+ }
+
+ } else {
+ info->ret |= ccd_selector_apply (selector, info->style);
+ }
}
return false;
@@ -392,13 +418,49 @@
*
* Apply the styling information held by #self to #style.
**/
-void
+bool
ccd_selector_group_apply (ccd_selector_group_t const *self,
ccd_style_t *style)
{
+ traverse_apply_info_t info;
+
+ g_assert (self && self->sets && style);
+
+ info.type_name = NULL;
+ info.style = style;
+ info.ret = false;
+
+ g_tree_foreach (self->sets, (GTraverseFunc) traverse_apply, &info);
+
+ return info.ret;
+}
+
+/**
+ * ccd_selector_group_apply_type:
+ * @self: a #ccd_selector_group_t.
+ * @type: style information matching exactly this type name will be applied.
+ * @style: a #ccd_style_t.
+ *
+ * Apply the styling information held by #self to #style.
+ *
+ * Returns: %TRUE if applicable style information available.
+ **/
+bool
+ccd_selector_group_apply_type (ccd_selector_group_t const *self,
+ char const *type_name,
+ ccd_style_t *style)
+{
+ traverse_apply_info_t info;
+
g_assert (self && self->sets && style);
- g_tree_foreach (self->sets, (GTraverseFunc) traverse_apply, style);
+ info.type_name = type_name;
+ info.style = style;
+ info.ret = false;
+
+ g_tree_foreach (self->sets, (GTraverseFunc) traverse_apply, &info);
+
+ return info.ret;
}
#ifdef CCD_DEBUG
Modified: trunk/libccd/ccd/ccd-selector-group.h
==============================================================================
--- trunk/libccd/ccd/ccd-selector-group.h (original)
+++ trunk/libccd/ccd/ccd-selector-group.h Thu Sep 25 13:26:58 2008
@@ -34,9 +34,12 @@
ccd_selector_group_t * ccd_selector_group_new (void);
void ccd_selector_group_free (ccd_selector_group_t *self);
-void ccd_selector_group_apply (ccd_selector_group_t const *self,
+bool ccd_selector_group_apply (ccd_selector_group_t const *self,
ccd_style_t *style);
+bool ccd_selector_group_apply_type (ccd_selector_group_t const *self,
+ char const *type, ccd_style_t *style);
+
#ifdef CCD_DEBUG
void ccd_selector_group_dump (ccd_selector_group_t const *self);
#endif
Modified: trunk/libccd/ccd/ccd-style.c
==============================================================================
--- trunk/libccd/ccd/ccd-style.c (original)
+++ trunk/libccd/ccd/ccd-style.c Thu Sep 25 13:26:58 2008
@@ -243,6 +243,54 @@
cr, x, y, width, height);
}
+bool
+ccd_style_get_color (ccd_style_t const *self,
+ double *red,
+ double *green,
+ double *blue)
+{
+ g_return_val_if_fail (self, FALSE);
+
+ if (NULL == self->color) {
+ return FALSE;
+ }
+
+ if (red)
+ *red = self->color->red;
+
+ if (green)
+ *red = self->color->green;
+
+ if (blue)
+ *red = self->color->blue;
+
+ return TRUE;
+}
+
+bool
+ccd_style_get_background_color (ccd_style_t const *self,
+ double *red,
+ double *green,
+ double *blue)
+{
+ g_return_val_if_fail (self, FALSE);
+
+ if (NULL == self->bg_color) {
+ return FALSE;
+ }
+
+ if (red)
+ *red = self->bg_color->red;
+
+ if (green)
+ *red = self->bg_color->green;
+
+ if (blue)
+ *red = self->bg_color->blue;
+
+ return TRUE;
+}
+
#ifdef CCD_DEBUG
/**
Modified: trunk/libccd/ccd/ccd-style.h
==============================================================================
--- trunk/libccd/ccd/ccd-style.h (original)
+++ trunk/libccd/ccd/ccd-style.h Thu Sep 25 13:26:58 2008
@@ -69,6 +69,15 @@
void ccd_style_draw_rectangle (ccd_style_t const *self, cairo_t *cr,
int32_t x, int32_t y, int32_t width, int32_t height);
+/* Somewhat obscure, undocumented API, primarily for the css engine.
+ * Maybe we should return a cairo pattern instead? */
+
+bool ccd_style_get_color (ccd_style_t const *self,
+ double *red, double *green, double *blue);
+
+bool ccd_style_get_background_color (ccd_style_t const *self,
+ double *red, double *green, double *blue);
+
#ifdef CCD_DEBUG
void ccd_style_dump (ccd_style_t const *self);
#endif
Modified: trunk/libccd/ccd/exports.sym
==============================================================================
--- trunk/libccd/ccd/exports.sym (original)
+++ trunk/libccd/ccd/exports.sym Thu Sep 25 13:26:58 2008
@@ -4,6 +4,8 @@
ccd_style_draw_line
ccd_style_draw_outline
ccd_style_draw_rectangle
+ccd_style_get_color
+ccd_style_get_background_color
ccd_stylesheet_new_from_buffer
ccd_stylesheet_new_from_file
ccd_stylesheet_free
@@ -13,5 +15,6 @@
ccd_selector_group_new
ccd_selector_group_free
ccd_selector_group_apply
+ccd_selector_group_apply_type
ccd_style_draw_gap
ccd_style_draw_polygon
Modified: trunk/libccd/doc/ccd-sections.txt
==============================================================================
--- trunk/libccd/doc/ccd-sections.txt (original)
+++ trunk/libccd/doc/ccd-sections.txt Thu Sep 25 13:26:58 2008
@@ -51,6 +51,7 @@
ccd_selector_group_new
ccd_selector_group_free
ccd_selector_group_apply
+ccd_selector_group_apply_type
ccd_selector_group_dump
</SECTION>
Modified: trunk/libccd/doc/tmpl/selector_group.sgml
==============================================================================
--- trunk/libccd/doc/tmpl/selector_group.sgml (original)
+++ trunk/libccd/doc/tmpl/selector_group.sgml Thu Sep 25 13:26:58 2008
@@ -46,6 +46,18 @@
@self:
@style:
+ Returns:
+
+
+<!-- ##### FUNCTION ccd_selector_group_apply_type ##### -->
+<para>
+
+</para>
+
+ self:
+ type:
+ style:
+ Returns:
<!-- ##### FUNCTION ccd_selector_group_dump ##### -->
Modified: trunk/libccd/examples/example1.c
==============================================================================
--- trunk/libccd/examples/example1.c (original)
+++ trunk/libccd/examples/example1.c Thu Sep 25 13:26:58 2008
@@ -50,7 +50,7 @@
g_assert (group);
ccd_style_init (&style);
- ccd_selector_group_apply (group, &style);
+ ccd_selector_group_apply_type (group, "box", &style);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 160, 90);
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Thu Sep 25 13:26:58 2008
@@ -25,6 +25,8 @@
gce-maps.h \
gce-node.c \
gce-node.h \
+ gce-parser.c \
+ gce-parser.h \
gce-rc-style.c \
gce-rc-style.h \
gce-style.c \
Added: trunk/src/gce-parser.c
==============================================================================
--- (empty file)
+++ trunk/src/gce-parser.c Thu Sep 25 13:26:58 2008
@@ -0,0 +1,103 @@
+/* The CSS Theme Engine for Gtk+.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#include <libcroco/libcroco.h>
+#include "gce-parser.h"
+
+typedef struct {
+ ccd_stylesheet_t const *stylesheet;
+} gce_parser_info_t;
+
+#define HANDLER_GET_INFO(handler_) ((gce_parser_info_t *) handler->app_data)
+
+static void
+start_selector_cb (CRDocHandler *handler,
+ CRSelector *cr_sel)
+{
+}
+
+static void
+property_cb (CRDocHandler *handler,
+ CRString *name,
+ CRTerm *values,
+ gboolean is_important)
+{
+#if 0
+ gce_parser_info_t *info;
+ char const *property;
+
+ info = HANDLER_GET_INFO (handler);
+
+ g_assert (info);
+
+ /* TODO parse style properties. */
+#endif
+}
+
+static void
+end_selector_cb (CRDocHandler *handler,
+ CRSelector *cr_sel)
+{
+ CRSimpleSel const *simple_sel;
+ char const *type_name;
+
+ /* TODO write a simple node implementation to query what we want. */
+
+ for (CRSelector const *iter = cr_sel; iter != NULL; iter = iter->next) {
+ simple_sel = iter->simple_sel;
+ if (TYPE_SELECTOR & simple_sel->type_mask &&
+ NULL == simple_sel->next) {
+
+ type_name = cr_string_peek_raw_str (simple_sel->name);
+ // TODO
+ }
+ }
+}
+
+gboolean
+gce_parser_setup_gtkrc (ccd_stylesheet_t const *stylesheet,
+ char const *css_file)
+{
+
+ CRParser *parser;
+ CRDocHandler *handler;
+ gce_parser_info_t info;
+ enum CRStatus ret;
+
+ g_return_val_if_fail (stylesheet && css_file, FALSE);
+
+ parser = cr_parser_new_from_file ((guchar *) css_file, CR_UTF_8);
+
+ handler = cr_doc_handler_new ();
+ handler->app_data = (gpointer) &info;
+ info.stylesheet = stylesheet;
+
+ handler->start_selector = start_selector_cb;
+ handler->property = property_cb;
+ handler->end_selector = end_selector_cb;
+
+ cr_parser_set_sac_handler (parser, handler);
+ ret = cr_parser_parse (parser);
+
+ cr_doc_handler_destroy (handler);
+ cr_parser_destroy (parser);
+
+ return CR_OK == ret;
+}
+
Added: trunk/src/gce-parser.h
==============================================================================
--- (empty file)
+++ trunk/src/gce-parser.h Thu Sep 25 13:26:58 2008
@@ -0,0 +1,34 @@
+/* The CSS Theme Engine for Gtk+.
+ * Copyright (C) 2008 Robert Staudinger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef GCE_PARSER_H
+#define GCE_PARSER_H
+
+#include <ccd/ccd.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gboolean gce_parser_setup_gtkrc (ccd_stylesheet_t const *stylesheet,
+ char const *css_file);
+
+G_END_DECLS
+
+#endif /* GCE_PARSER_H */
+
Modified: trunk/themes/Gilouche-CSS/gtk-2.0/styles.css
==============================================================================
--- trunk/themes/Gilouche-CSS/gtk-2.0/styles.css (original)
+++ trunk/themes/Gilouche-CSS/gtk-2.0/styles.css Thu Sep 25 13:26:58 2008
@@ -16,11 +16,13 @@
/* Checkboxes */
check {
+ background-color: white;
border: 1px solid #948156;
border-radius: 2px;
}
check:insensitive {
+ background-color: #fbf8f1;
border: 1px solid #c6b182;
}
@@ -36,11 +38,13 @@
/* radiobuttons */
option {
+ background-color: white;
border: 1px solid #948156;
border-radius: 50%;
}
option:insensitive {
+ background-color: #fbf8f1;
border: 1px solid #c6b182;
}
@@ -155,13 +159,12 @@
border: 1px solid #c6b182;
}
-extension[gap=bottom], extension[gap=right], extension[gap=left], extension[gap=top] {
+extension {
border: 1px solid #c6b182;
background-color: #ebdfc4;
}
extension[gap=bottom]:normal {
- border: 1px solid #a28f62;
background-color: #fbf8f1;
background-image: url(tab-back.png);
background-position: left top;
@@ -169,7 +172,6 @@
}
extension[gap=left]:normal {
- border: 1px solid #a28f62;
background-color: #fbf8f1;
background-image: url(tab-back-right.png);
background-position: right top;
@@ -177,7 +179,6 @@
}
extension[gap=top]:normal {
- border: 1px solid #a28f62;
background-color: #fbf8f1;
background-image: url(tab-back-down.png);
background-position: left bottom;
@@ -185,7 +186,6 @@
}
extension[gap=right]:normal {
- border: 1px solid #a28f62;
background-color: #fbf8f1;
background-image: url(tab-back-left.png);
background-position: left top;
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 Sep 25 13:26:58 2008
@@ -1,4 +1,9 @@
-/*
+
+arrow {
+ background-position: center;
+ background-repeat: no-repeat;
+}
+
arrow[orientation=up] {
background-image: url(arrow-up.png);
}
@@ -21,12 +26,22 @@
option {
background-image: url(arrow-down.png);
+ background-position: center;
+ background-repeat: no-repeat;
}
check {
background-color: green;
}
+check:insensitive {
+ background-color: gray;
+}
+
+GtkCheckButton check[shadow=in]:insensitive {
+ background-color: black;
+}
+
box {
background-color: darkkhaki;
border: 1px solid black;
@@ -101,59 +116,4 @@
GtkProgressBar:prelight {
background-color: yellow;
}
-*/
-
-/*
-check {
- background-image: url(nordic.svg#CheckMarkOn.Shape);
-}
-*/
-extension {
- background: khaki;
- border: 1px solid black;
-}
-
-box {
- background: khaki;
- border: 2px solid black;
- border-radius: 60;
-}
-
-extension[gap=left]:normal {
- border: 1px solid #a28f62;
- background-image: url(tab-back-right.png);
- background-repeat: repeat-y;
- background-position: right top;
-}
-
-box[gap=top] {
- background-image: url(foo.png);
- background-position: right top;
- background-repeat: no-repeat;
-}
-
-box[gap=bottom] {/*
- background-image: url(foo.png);
- background-repeat: no-repeat;
- background-position: center;
- background-size: contain;
-*/}
-
-box[gap=left] {/*
- background-image: url(foo.png);
- background-repeat: repeat-y;
-*/}
-
-box[gap=right] {/*
- background-image: url(foo.png);
- background-repeat: no-repeat;
- background-position: 32% 32%;
- background-size: 100% 100%;
-*/}
-
-shadow {
- background: khaki;
- border: 1px solid black;
- border-radius: 15;
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]