gtk-css-engine r205 - in trunk: . src
- From: robsta svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk-css-engine r205 - in trunk: . src
- Date: Tue, 2 Dec 2008 14:50:56 +0000 (UTC)
Author: robsta
Date: Tue Dec 2 14:50:55 2008
New Revision: 205
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=205&view=rev
Log:
* src/css2gtkrc.c (main):
* src/gce-rc-style.c (create_style), (parse), (merge), (finalize),
(instance_init):
* src/gce-rc-style.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), (finalize), (instance_init), (class_init):
* src/gce-style.h:
Get rid of global stylesheet, pass it between style instances instead.
Modified:
trunk/ChangeLog
trunk/src/css2gtkrc.c
trunk/src/gce-rc-style.c
trunk/src/gce-rc-style.h
trunk/src/gce-style.c
trunk/src/gce-style.h
Modified: trunk/src/css2gtkrc.c
==============================================================================
--- trunk/src/css2gtkrc.c (original)
+++ trunk/src/css2gtkrc.c Tue Dec 2 14:50:55 2008
@@ -40,7 +40,8 @@
ccss_cairo_init ();
grammar = ccss_cairo_grammar_create ();
- ccss_grammar_add_properties (grammar, gce_properties_get_ptable ());
+// ccss_grammar_add_properties (grammar, gce_properties_get_ptable ());
+// ccss_grammar_add_functions (grammar, gce_functions_get_vtable ());
stylesheet = ccss_grammar_create_stylesheet_from_file (grammar, argv[1],
NULL);
Modified: trunk/src/gce-rc-style.c
==============================================================================
--- trunk/src/gce-rc-style.c (original)
+++ trunk/src/gce-rc-style.c Tue Dec 2 14:50:55 2008
@@ -26,32 +26,36 @@
#include "gce-style.h"
#include "config.h"
-static ccss_stylesheet_t *_stylesheet = NULL;
-gpointer *_stylesheet_owner = NULL;
-
-ccss_stylesheet_t const *
-gce_rc_style_get_stylesheet (void)
-{
- return _stylesheet;
-}
-
-struct _GceRcStyle
-{
- GtkRcStyle parent;
+struct _GceRcStyle {
+ GtkRcStyle parent;
+ ccss_stylesheet_t *stylesheet;
};
-struct _GceRcStyleClass
-{
+struct _GceRcStyleClass {
GtkRcStyleClass parent;
};
static GType gce_rc_style_type = 0;
static GtkRcStyleClass *gce_rc_style_parent_class = NULL;
-static GtkStyle*
-create_style (GtkRcStyle *rc_style)
+static GtkStyle *
+create_style (GtkRcStyle *gtk_rc_style)
{
- return GTK_STYLE (g_object_new (GCE_TYPE_STYLE, NULL));
+ GceRcStyle *rc_style;
+ GceStyle *style;
+
+ rc_style = GCE_RC_STYLE (gtk_rc_style);
+ style = GCE_STYLE (g_object_new (GCE_TYPE_STYLE, NULL));
+
+ if (rc_style && rc_style->stylesheet) {
+ style->stylesheet = ccss_stylesheet_reference (rc_style->stylesheet);
+ } else {
+ g_warning ("%s() rc-style %p, stylesheet %p", __FUNCTION__,
+ (void *) rc_style,
+ rc_style ? (void *) rc_style->stylesheet : NULL);
+ }
+
+ return GTK_STYLE (style);
}
static guint
@@ -61,7 +65,8 @@
{
static GQuark scope_id = 0;
- ccss_grammar_t *grammar;
+ ccss_grammar_t *grammar;
+ ccss_stylesheet_t *stylesheet;
char *gce_file;
guint old_scope;
@@ -84,47 +89,50 @@
token = g_scanner_get_next_token (scanner);
g_assert (token == G_TOKEN_STRING);
- g_assert (_stylesheet == NULL);
+
gce_file = gtk_rc_find_pixmap_in_path (gtk_settings_get_default (),
scanner, scanner->value.v_string);
- // FIXME: get rid of global stylesheet, assign it to rc-style
- // and pass on to style.
grammar = ccss_cairo_grammar_create ();
ccss_grammar_add_properties (grammar, gce_properties_get_ptable ());
ccss_grammar_add_functions (grammar, gce_functions_get_vtable ());
-
- _stylesheet = ccss_grammar_create_stylesheet_from_file (grammar,
- gce_file,
- NULL);
- if (_stylesheet) {
+ stylesheet = ccss_grammar_create_stylesheet_from_file (grammar,
+ gce_file, NULL);
+ if (stylesheet) {
ccss_grammar_destroy (grammar), grammar = NULL;
} else {
g_critical ("Could not create stylesheet `%s'", gce_file);
}
+ g_free (gce_file), gce_file = NULL;
/* ccss_stylesheet_dump (_stylesheet); */
/* User-agent stylesheet */
- _stylesheet = ccss_stylesheet_add_from_file (_stylesheet, GCE_UA_STYLESHEET,
- CCSS_STYLESHEET_USER_AGENT,
- NULL);
-
- if (!_stylesheet) {
+ stylesheet = ccss_stylesheet_add_from_file (stylesheet, GCE_UA_STYLESHEET,
+ CCSS_STYLESHEET_USER_AGENT,
+ NULL);
+ if (stylesheet) {
+ GceRcStyle *gce_rc_style;
+ gce_rc_style = GCE_RC_STYLE (rc_style);
+ if (gce_rc_style) {
+ gce_rc_style->stylesheet = ccss_stylesheet_reference (stylesheet);
+ }
+ ccss_stylesheet_destroy (stylesheet), stylesheet = NULL;
+ } else {
g_critical ("Could not add user-agent stylesheet `%s'",
GCE_UA_STYLESHEET);
}
+/* TODO
#ifdef GCE_RAPID_DEVELOPMENT
G_STMT_START{
char *rc_string;
- rc_string = gce_serialize (_stylesheet);
+ rc_string = gce_serialize (stylesheet);
if (rc_string) {
gtk_rc_parse_string (rc_string);
g_free (rc_string), rc_string = NULL;
}
}G_STMT_END;
#endif
- _stylesheet_owner = (gpointer) rc_style;
- g_free (gce_file), gce_file = NULL;
+*/
}
g_scanner_get_next_token (scanner);
@@ -134,22 +142,39 @@
}
static void
-merge (GtkRcStyle *dst,
+merge (GtkRcStyle *dest,
GtkRcStyle *src)
{
- gce_rc_style_parent_class->merge (dst, src);
+ if (GCE_IS_RC_STYLE (dest) &&
+ GCE_IS_RC_STYLE (src)) {
+
+ GceRcStyle *from;
+ GceRcStyle *to;
+
+ from = GCE_RC_STYLE (src);
+ to = GCE_RC_STYLE (dest);
+
+ if (from->stylesheet != NULL &&
+ to->stylesheet == NULL) {
+ to->stylesheet = ccss_stylesheet_reference (from->stylesheet);
+ } else if (from->stylesheet == NULL) {
+ g_warning ("no stylesheet");
+ }
+ }
+
+ gce_rc_style_parent_class->merge (dest, src);
}
static void
finalize (GObject *instance)
{
- /*
GceRcStyle *self;
+
self = GCE_RC_STYLE (instance);
- */
- if (_stylesheet_owner == (gpointer) instance) {
- ccss_stylesheet_destroy (_stylesheet);
+ if (self->stylesheet) {
+ ccss_stylesheet_destroy (self->stylesheet);
+ self->stylesheet = NULL;
}
G_OBJECT_CLASS (gce_rc_style_parent_class)->finalize (instance);
@@ -158,6 +183,7 @@
static void
instance_init (GceRcStyle *self)
{
+ self->stylesheet = NULL;
}
static void
Modified: trunk/src/gce-rc-style.h
==============================================================================
--- trunk/src/gce-rc-style.h (original)
+++ trunk/src/gce-rc-style.h Tue Dec 2 14:50:55 2008
@@ -39,8 +39,6 @@
void gce_rc_style_register_type (GTypeModule *module);
GType gce_rc_style_get_type (void) G_GNUC_CONST;
-ccss_stylesheet_t const * gce_rc_style_get_stylesheet (void);
-
G_END_DECLS
#endif /* GCE_RC_STYLE_H */
Modified: trunk/src/gce-style.c
==============================================================================
--- trunk/src/gce-style.c (original)
+++ trunk/src/gce-style.c Tue Dec 2 14:50:55 2008
@@ -20,25 +20,14 @@
#include <gtk/gtk.h>
#include "gce-maps.h"
#include "gce-node.h"
-#include "gce-rc-style.h"
#include "gce-style.h"
#include "config.h"
-struct GceStyle_
-{
- GtkStyle parent;
-};
-
-struct GceStyleClass_
-{
- GtkStyleClass parent;
-};
-
static GType gce_style_type = 0;
static GtkStyleClass *gce_style_parent_class = NULL;
static void
-rectangle (GtkStyle *self,
+rectangle (GceStyle *self,
GceNode const *node,
GdkWindow *window,
GdkRectangle *area,
@@ -49,14 +38,14 @@
gint height,
gboolean fill)
{
- ccss_stylesheet_t const *stylesheet;
ccss_style_t *style;
cairo_t *cr;
gboolean ret;
- stylesheet = gce_rc_style_get_stylesheet ();
+ g_return_if_fail (self);
+
style = ccss_style_create ();
- ret = ccss_stylesheet_query (stylesheet, (ccss_node_t const *) node, style);
+ ret = ccss_stylesheet_query (self->stylesheet, (ccss_node_t const *) node, style);
if (ret) {
cr = gdk_cairo_create (window);
@@ -85,7 +74,7 @@
}
static void
-gap (GtkStyle *self,
+gap (GceStyle *self,
GceNode const *node,
GdkWindow *window,
GdkRectangle *area,
@@ -98,14 +87,14 @@
gint gap_start,
gint gap_width)
{
- ccss_stylesheet_t const *stylesheet;
ccss_style_t *style;
cairo_t *cr;
gboolean ret;
- stylesheet = gce_rc_style_get_stylesheet ();
+ g_return_if_fail (self);
+
style = ccss_style_create ();
- ret = ccss_stylesheet_query (stylesheet, (ccss_node_t const *) node, style);
+ ret = ccss_stylesheet_query (self->stylesheet, (ccss_node_t const *) node, style);
if (ret) {
cr = gdk_cairo_create (window);
@@ -132,7 +121,7 @@
}
static void
-line (GtkStyle *self,
+line (GceStyle *self,
GceNode *node,
GdkWindow *window,
GdkRectangle *area,
@@ -142,14 +131,14 @@
gint y1,
gint y2)
{
- ccss_stylesheet_t const *stylesheet;
ccss_style_t *style;
cairo_t *cr;
gboolean ret;
- stylesheet = gce_rc_style_get_stylesheet ();
+ g_return_if_fail (self);
+
style = ccss_style_create ();
- ret = ccss_stylesheet_query (stylesheet, (ccss_node_t const *) node, style);
+ ret = ccss_stylesheet_query (self->stylesheet, (ccss_node_t const *) node, style);
if (ret) {
cr = gdk_cairo_create (window);
@@ -188,7 +177,7 @@
NULL, NULL, NULL, NULL, NULL,
role ? role : "hline");
- line (self, node, window, area, widget, x1, x2, y, y);
+ line (GCE_STYLE (self), node, window, area, widget, x1, x2, y, y);
gce_node_cache_release_node (node), node = NULL;
}
@@ -216,7 +205,7 @@
NULL, NULL, NULL, NULL, NULL,
role ? role : "vline");
- line (self, node, window, area, widget, x, x, y1, y2);
+ line (GCE_STYLE (self), node, window, area, widget, x, x, y1, y2);
gce_node_cache_release_node (node), node = NULL;
@@ -248,7 +237,7 @@
NULL, NULL, NULL, NULL,
role ? role : "shadow");
- rectangle (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;
@@ -280,7 +269,7 @@
NULL, NULL, NULL, NULL,
role ? role : "box");
- rectangle (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;
@@ -312,7 +301,7 @@
NULL, NULL, NULL, NULL,
role ? role : "flatbox");
- rectangle (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;
@@ -344,7 +333,7 @@
NULL, NULL, NULL, NULL,
role ? role : "check");
- rectangle (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;
@@ -376,7 +365,7 @@
NULL, NULL, NULL, NULL,
role ? role : "option");
- rectangle (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;
@@ -411,7 +400,7 @@
NULL, gce_maps_get_position (gap_side), NULL, NULL,
role ? role : "shadow");
- gap (self, node, window, area, widget,
+ gap (GCE_STYLE (self), node, window, area, widget,
x, y, width, height, gap_side, gap_start, gap_width);
gce_node_cache_release_node (node), node = NULL;
@@ -446,7 +435,7 @@
NULL, gce_maps_get_position (gap_side), NULL, NULL,
role ? role : "box");
- gap (self, node, window, area, widget,
+ gap (GCE_STYLE (self), node, window, area, widget,
x, y, width, height, gap_side, gap_start, gap_width);
gce_node_cache_release_node (node), node = NULL;
@@ -491,7 +480,7 @@
break;
}
- gap (self, node, window, area, widget,
+ gap (GCE_STYLE (self), node, window, area, widget,
x, y, width, height, gap_side, 0, gap_width);
gce_node_cache_release_node (node), node = NULL;
@@ -525,7 +514,7 @@
NULL, NULL, NULL,
role ? role : "slider");
- rectangle (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;
@@ -559,7 +548,7 @@
NULL, NULL, NULL,
role ? role : "handle");
- rectangle (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;
@@ -590,7 +579,7 @@
NULL, NULL, NULL, gce_maps_get_window_edge (edge), NULL,
role ? role : "resizegrip");
- rectangle (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;
@@ -620,7 +609,7 @@
NULL, NULL, NULL, NULL, NULL,
role ? role : "focus");
- rectangle (self, node, window, area, widget,
+ rectangle (GCE_STYLE (self), node, window, area, widget,
x, y, width, height, FALSE);
gce_node_cache_release_node (node), node = NULL;
@@ -661,7 +650,7 @@
NULL, NULL, NULL, NULL, gce_maps_get_expander_style (style),
role ? role : "expander");
- rectangle (self, node, window, area, widget,
+ rectangle (GCE_STYLE (self), node, window, area, widget,
x, y, expander_size, expander_size, TRUE);
gce_node_cache_release_node (node), node = NULL;
@@ -694,7 +683,7 @@
NULL, NULL, NULL, NULL,
role ? role : "diamond");
- rectangle (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;
@@ -732,7 +721,7 @@
NULL, NULL, NULL,
role ? role : "arrow");
- rectangle (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;
@@ -764,25 +753,45 @@
NULL, NULL, NULL, NULL,
role ? role : "tab");
- rectangle (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;
}
+static void
+finalize (GObject *instance)
+{
+ GceStyle *self;
+
+ self = GCE_STYLE (instance);
+
+ if (self->stylesheet) {
+ ccss_stylesheet_destroy (self->stylesheet);
+ self->stylesheet = NULL;
+ }
+
+ G_OBJECT_CLASS (gce_style_parent_class)->finalize (instance);
+}
+
static void
instance_init (GceStyle *self)
{
-
+ self->stylesheet = NULL;
}
static void
class_init (GceStyleClass *klass)
{
- GtkStyleClass *style_class = GTK_STYLE_CLASS (klass);
+ GObjectClass *go_class;
+ GtkStyleClass *style_class;
gce_style_parent_class = g_type_class_peek_parent (klass);
+ go_class = G_OBJECT_CLASS (klass);
+ go_class->finalize = finalize;
+
+ style_class = GTK_STYLE_CLASS (klass);
style_class->draw_hline = draw_hline;
style_class->draw_vline = draw_vline;
style_class->draw_shadow = draw_shadow;
Modified: trunk/src/gce-style.h
==============================================================================
--- trunk/src/gce-style.h (original)
+++ trunk/src/gce-style.h Tue Dec 2 14:50:55 2008
@@ -20,6 +20,7 @@
#ifndef GCE_STYLE_H
#define GCE_STYLE_H
+#include <ccss-cairo/ccss-cairo.h>
#include <glib.h>
#include <glib-object.h>
@@ -35,6 +36,15 @@
typedef struct GceStyle_ GceStyle;
typedef struct GceStyleClass_ GceStyleClass;
+struct GceStyle_ {
+ GtkStyle parent;
+ ccss_stylesheet_t *stylesheet;
+};
+
+struct GceStyleClass_ {
+ GtkStyleClass parent;
+};
+
void gce_style_register_type (GTypeModule *module);
GType gce_style_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]