From 982cc01c7a47641f25a17460f72ebbd308e70048 Mon Sep 17 00:00:00 2001 From: Robert Staudinger Date: Thu, 6 Aug 2009 13:25:48 +0200 Subject: [cairo-appearance] Appearance hooks return bool to signal success. If they return FALSE the built-in drawing routines are used. Also update example-8. --- ccss-cairo/Makefile.am | 1 - ccss-cairo/ccss-cairo-appearance-parser.c | 4 ++-- ccss-cairo/ccss-cairo-style.c | 6 ++++-- ccss-cairo/ccss-cairo-style.h | 8 -------- ccss-doc/tmpl/style.sgml | 9 +++++++++ examples/example-8.c | 14 ++++++++++---- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/ccss-cairo/Makefile.am b/ccss-cairo/Makefile.am index a51aeac..73d3fe1 100644 --- a/ccss-cairo/Makefile.am +++ b/ccss-cairo/Makefile.am @@ -29,7 +29,6 @@ libccss_cairo_1_la_LIBADD = \ libccss_cairo_1_la_SOURCES = \ $(headers_DATA) \ - ccss-cairo-appearance.c \ ccss-cairo-appearance.h \ ccss-cairo-appearance-parser.c \ ccss-cairo-appearance-parser.h \ diff --git a/ccss-cairo/ccss-cairo-appearance-parser.c b/ccss-cairo/ccss-cairo-appearance-parser.c index 48bc0f1..3fa62d4 100644 --- a/ccss-cairo/ccss-cairo-appearance-parser.c +++ b/ccss-cairo/ccss-cairo-appearance-parser.c @@ -117,11 +117,11 @@ module_destroy (ccss_cairo_appearance_module_t *module) } } -static ccss_cairo_style_draw_f +static ccss_cairo_appearance_draw_f module_get_symbol (ccss_cairo_appearance_module_t const *module, char const *name) { - ccss_cairo_style_draw_f draw_func = NULL; + ccss_cairo_appearance_draw_f draw_func = NULL; g_return_val_if_fail (module, NULL); g_return_val_if_fail (name, NULL); diff --git a/ccss-cairo/ccss-cairo-style.c b/ccss-cairo/ccss-cairo-style.c index e27649a..e1a2472 100644 --- a/ccss-cairo/ccss-cairo-style.c +++ b/ccss-cairo/ccss-cairo-style.c @@ -352,8 +352,10 @@ ccss_cairo_style_draw_rectangle (ccss_style_t const *self, appearance->base.state == CCSS_PROPERTY_STATE_SET && appearance->draw_function) { - ccss_cairo_appearance_draw (appearance, self, cr, x, y, width, height); - return; + bool ret = appearance->draw_function (self, cr, + x, y, width, height); + if (ret) + return; } gather_outline (self, &bottom, &left, &right, &top, diff --git a/ccss-cairo/ccss-cairo-style.h b/ccss-cairo/ccss-cairo-style.h index f8f1285..1336704 100644 --- a/ccss-cairo/ccss-cairo-style.h +++ b/ccss-cairo/ccss-cairo-style.h @@ -49,14 +49,6 @@ typedef enum { CCSS_CAIRO_GAP_SIDE_BOTTOM } ccss_cairo_gap_side_t; -typedef void -(*ccss_cairo_style_draw_f) (ccss_style_t const *self, - cairo_t *cr, - int x, - int y, - int width, - int height); - void ccss_cairo_style_draw_line (ccss_style_t const *self, cairo_t *cr, diff --git a/ccss-doc/tmpl/style.sgml b/ccss-doc/tmpl/style.sgml index 32b36cc..207f614 100644 --- a/ccss-doc/tmpl/style.sgml +++ b/ccss-doc/tmpl/style.sgml @@ -74,6 +74,15 @@ ccss_style_t @Returns: + + + + + +@self: +@Returns: + + diff --git a/examples/example-8.c b/examples/example-8.c index cb098f0..8fd103a 100644 --- a/examples/example-8.c +++ b/examples/example-8.c @@ -13,7 +13,7 @@ G_MODULE_EXPORT char const * ccss_appearance_module_get_interface_version (void); -G_MODULE_EXPORT void +G_MODULE_EXPORT bool custom_box (ccss_style_t const *self, cairo_t *cr, int x, @@ -27,7 +27,7 @@ ccss_appearance_module_get_interface_version (void) return CCSS_CAIRO_APPEARANCE_MODULE_INTERFACE_VERSION; } -G_MODULE_EXPORT void +G_MODULE_EXPORT bool custom_box (ccss_style_t const *self, cairo_t *cr, int x, @@ -37,8 +37,10 @@ custom_box (ccss_style_t const *self, { cairo_rectangle (cr, x, y, width, height); cairo_set_line_width (cr, 3); - cairo_set_line_cap (cr, CAIRO_LINE_JOIN_MITER); + cairo_set_line_cap (cr, CAIRO_LINE_JOIN_ROUND); cairo_stroke (cr); + + return true; } /* @@ -79,6 +81,7 @@ main (int argc, ccss_stylesheet_t *stylesheet; ccss_style_t *style; GtkWidget *window; + GtkWidget *area; gtk_init (&argc, &argv); @@ -98,7 +101,10 @@ main (int argc, gtk_widget_set_app_paintable (window, TRUE); g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL); - g_signal_connect (G_OBJECT (window), "expose-event", + + area = gtk_drawing_area_new (); + gtk_container_add (GTK_CONTAINER (window), area); + g_signal_connect (G_OBJECT (area), "expose-event", G_CALLBACK (expose_cb), style); gtk_widget_show_all (window); -- cgit v1.2.3