[cairo-commit] cairo-gtk-engine/src Makefile.am, 1.11,
1.12 caligula-draw-grassy.c, 1.2, 1.3 caligula-draw-shadowed.c,
1.2, 1.3 caligula-draw-sketchy.c, 1.3,
1.4 caligula-draw-swirly.c, 1.2, 1.3 caligula-rc-style.c, 1.3,
1.4 caligula-rc-style.h, 1.2, 1.3 caligula-style.c, 1.7,
1.8 cge-draw.c, 1.20, 1.21
Owen Taylor
commit at pdx.freedesktop.org
Tue Jun 21 08:03:10 PDT 2005
Committed by: otaylor
Update of /cvs/cairo/cairo-gtk-engine/src
In directory gabe:/tmp/cvs-serv19844/src
Modified Files:
Makefile.am caligula-draw-grassy.c caligula-draw-shadowed.c
caligula-draw-sketchy.c caligula-draw-swirly.c
caligula-rc-style.c caligula-rc-style.h caligula-style.c
cge-draw.c
Log Message:
2005-06-21 Owen Taylor <otaylor at redhat.com>
* src/*.c: Updates for current cairo API.
* src/caligula-rc-style.[ch] src/caligula-style.c:
Make the background gradient configurable in the
RC file.
* theme/caligula-sketchy/gtkrc: Change to a
gradient that doesn't obscure the buttons as much.
* src/Makefile.am: Discable build cairo-gtk-engine
for now.
* theme/Makefile.am: Remove cairo-gtk-engine themes
from SUBDIRS.
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Makefile.am 10 Feb 2005 20:23:18 -0000 1.11
+++ Makefile.am 21 Jun 2005 15:03:07 -0000 1.12
@@ -5,16 +5,17 @@
$(CGE_CFLAGS) $(WARN_CFLAGS)
enginedir = $(libdir)/gtk-2.0/$(GTK_VERSION)/engines
-engine_LTLIBRARIES = libcairo-gtk-engine.la libcaligula.la
+#engine_LTLIBRARIES = libcairo-gtk-engine.la libcaligula.la
+engine_LTLIBRARIES = libcaligula.la
-libcairo_gtk_engine_la_SOURCES = \
- cge.c cge.h \
- cge-draw.c \
- cge-style.c cge-style.h
+#libcairo_gtk_engine_la_SOURCES = \
+# cge.c cge.h \
+# cge-draw.c \
+# cge-style.c cge-style.h
-libcairo_gtk_engine_la_LDFLAGS = \
- -avoid-version -no-undefined -module \
- $(CGE_LIBS)
+#libcairo_gtk_engine_la_LDFLAGS = \
+# -avoid-version -no-undefined -module \
+# $(CGE_LIBS)
libcaligula_la_SOURCES = \
caligula.c \
Index: caligula-draw-grassy.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/caligula-draw-grassy.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- caligula-draw-grassy.c 10 Feb 2005 16:50:32 -0000 1.2
+++ caligula-draw-grassy.c 21 Jun 2005 15:03:07 -0000 1.3
@@ -45,8 +45,7 @@
top_x, top_y);
cairo_close_path (cr);
- cairo_set_rgb_color (cr, 0, 0, 0);
- cairo_set_alpha (cr, swoosh_alpha);
+ cairo_set_source_rgba (cr, 0, 0, 0, swoosh_alpha);
cairo_fill (cr);
}
@@ -64,18 +63,18 @@
cairo_clip (cr);
#endif
- cairo_set_rgb_color (cr, 1, 1, 1);
+ cairo_set_source_rgb (cr, 1, 1, 1);
cairo_fill (cr);
/* Gradient fill */
pattern = cairo_pattern_create_linear (x, y, x, y + height);
- cairo_pattern_add_color_stop (pattern, 0, 0, 0, 0, 1);
- cairo_pattern_add_color_stop (pattern, 0.035, gray, gray, gray, 1);
- cairo_pattern_add_color_stop (pattern, 0.25, 1, 1, 1, 1);
- cairo_pattern_add_color_stop (pattern, 0.45, gray, gray, gray, 1);
- cairo_pattern_add_color_stop (pattern, 0.91, 1, 1, 1, 1);
- cairo_pattern_add_color_stop (pattern, 1, 0, 0, 0, 0);
- cairo_set_pattern (cr, pattern);
+ cairo_pattern_add_color_stop_rgba (pattern, 0, 0, 0, 0, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 0.035, gray, gray, gray, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 0.25, 1, 1, 1, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 0.45, gray, gray, gray, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 0.91, 1, 1, 1, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 1, 0, 0, 0, 0);
+ cairo_set_source (cr, pattern);
cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
@@ -85,8 +84,7 @@
swoosh (cr, x, y, width, height);
/* Outline */
- cairo_set_alpha (cr, 1);
- cairo_set_rgb_color (cr, outline_gray, outline_gray, outline_gray);
+ cairo_set_source_rgb (cr, outline_gray, outline_gray, outline_gray);
cairo_set_line_width (cr, 1);
cairo_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1);
cairo_stroke (cr);
Index: caligula-draw-shadowed.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/caligula-draw-shadowed.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- caligula-draw-shadowed.c 11 Feb 2005 15:27:26 -0000 1.2
+++ caligula-draw-shadowed.c 21 Jun 2005 15:03:07 -0000 1.3
@@ -47,11 +47,11 @@
/* Left side */
shadow = cairo_pattern_create_linear (0, 0, shadow_width, 0);
- cairo_pattern_add_color_stop (shadow, 0.0, 0, 0, 0, 0.74);
- cairo_pattern_add_color_stop (shadow, 0.5, 0, 0, 0, 0.25);
- cairo_pattern_add_color_stop (shadow, 0.75, 0, 0, 0, 0.075);
- cairo_pattern_add_color_stop (shadow, 1.0, 0, 0, 0, 0.0);
- cairo_set_pattern (cr, shadow);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.0, 0, 0, 0, 0.74);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.5, 0, 0, 0, 0.25);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.75, 0, 0, 0, 0.075);
+ cairo_pattern_add_color_stop_rgba (shadow, 1.0, 0, 0, 0, 0.0);
+ cairo_set_source (cr, shadow);
cairo_rectangle (cr, 0, 0, shadow_width, height);
cairo_fill (cr);
cairo_pattern_destroy (shadow);
@@ -64,17 +64,17 @@
/* Top */
shadow = cairo_pattern_create_linear (0, 0, 0, shadow_height);
- cairo_pattern_add_color_stop (shadow, 0.0, 0, 0, 0, 0.74);
- cairo_pattern_add_color_stop (shadow, 0.5, 0, 0, 0, 0.25);
- cairo_pattern_add_color_stop (shadow, 0.75, 0, 0, 0, 0.075);
- cairo_pattern_add_color_stop (shadow, 1.0, 0, 0, 0, 0.0);
- cairo_set_pattern (cr, shadow);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.0, 0, 0, 0, 0.74);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.5, 0, 0, 0, 0.25);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.75, 0, 0, 0, 0.075);
+ cairo_pattern_add_color_stop_rgba (shadow, 1.0, 0, 0, 0, 0.0);
+ cairo_set_source (cr, shadow);
cairo_rectangle (cr, 0, 0, width, shadow_height);
cairo_fill (cr);
cairo_pattern_destroy (shadow);
/* Put a one-pixel highlight on the right and bottom */
- cairo_set_rgb_color (cr, 1, 1, 1);
+ cairo_set_source_rgb (cr, 1, 1, 1);
cairo_rectangle (cr, width - 1, 0, 1, height);
cairo_rectangle (cr, 0, height - 1, width, 1);
cairo_fill (cr);
@@ -94,22 +94,22 @@
/* Right side */
shadow = cairo_pattern_create_linear (width, 0, width - shadow_width, 0);
- cairo_pattern_add_color_stop (shadow, 0.0, 0, 0, 0, 0.37);
- cairo_pattern_add_color_stop (shadow, 0.5, 0, 0, 0, 0.125);
- cairo_pattern_add_color_stop (shadow, 0.75, 0, 0, 0, 0.0375);
- cairo_pattern_add_color_stop (shadow, 1.0, 0, 0, 0, 0.0);
- cairo_set_pattern (cr, shadow);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.0, 0, 0, 0, 0.37);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.5, 0, 0, 0, 0.125);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.75, 0, 0, 0, 0.0375);
+ cairo_pattern_add_color_stop_rgba (shadow, 1.0, 0, 0, 0, 0.0);
+ cairo_set_source (cr, shadow);
cairo_rectangle (cr, width - shadow_width, 0, shadow_width, height);
cairo_fill (cr);
cairo_pattern_destroy (shadow);
/* Bottom */
shadow = cairo_pattern_create_linear (0, height, 0, height - shadow_height);
- cairo_pattern_add_color_stop (shadow, 0.0, 0, 0, 0, 0.37);
- cairo_pattern_add_color_stop (shadow, 0.5, 0, 0, 0, 0.125);
- cairo_pattern_add_color_stop (shadow, 0.75, 0, 0, 0, 0.0375);
- cairo_pattern_add_color_stop (shadow, 1.0, 0, 0, 0, 0.0);
- cairo_set_pattern (cr, shadow);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.0, 0, 0, 0, 0.37);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.5, 0, 0, 0, 0.125);
+ cairo_pattern_add_color_stop_rgba (shadow, 0.75, 0, 0, 0, 0.0375);
+ cairo_pattern_add_color_stop_rgba (shadow, 1.0, 0, 0, 0, 0.0);
+ cairo_set_source (cr, shadow);
cairo_rectangle (cr, 0, height - shadow_height, width, shadow_height);
cairo_fill (cr);
cairo_pattern_destroy (shadow);
Index: caligula-draw-sketchy.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/caligula-draw-sketchy.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- caligula-draw-sketchy.c 9 Feb 2005 22:49:54 -0000 1.3
+++ caligula-draw-sketchy.c 21 Jun 2005 15:03:07 -0000 1.4
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <math.h>
#include <assert.h>
+#include <glib.h>
#include "caligula-draw-sketchy.h"
#include "caligula-rand.h"
@@ -49,7 +50,7 @@
int num_polys;
} poly_list_t;
-struct ctx {
+typedef struct bend_context {
cairo_t *cr;
int first;
@@ -57,7 +58,7 @@
pt_t pt_first;
pt_t pt_prev;
-};
+} bend_context_t;
/* Return a random positive double within 0 <= value < max */
static double
@@ -116,33 +117,34 @@
}
static void
-bend_move_to(void *data, double x, double y)
+bend_move_to (bend_context_t *context,
+ double x,
+ double y)
{
- struct ctx *ctx = data;
-
- ctx->pt_first.x = x;
- ctx->pt_first.y = y;
+ context->pt_first.x = x;
+ context->pt_first.y = y;
- ctx->pt_prev.x = x;
- ctx->pt_prev.y = y;
+ context->pt_prev.x = x;
+ context->pt_prev.y = y;
- if (ctx->first) {
- cairo_new_path (ctx->cr);
- ctx->first = 0;
+ if (context->first) {
+ cairo_new_path (context->cr);
+ context->first = 0;
}
}
static void
-bend_line_to(void *data, double x, double y)
+bend_line_to (bend_context_t *context,
+ double x,
+ double y)
{
- struct ctx *ctx = data;
pt_t a, b, c, d;
double length;
- if (ctx->first)
- return bend_move_to (data, x, y);
+ if (context->first)
+ return bend_move_to (context, x, y);
- a = ctx->pt_prev;
+ a = context->pt_prev;
d.x = x;
d.y = y;
@@ -157,45 +159,64 @@
nudge (&c, 10, 0, 2*M_PI);
/*
- if (! ctx->closing)
+ if (! context->closing)
nudge (&d, 1./5. * length, direction(a, b), M_PI / 10.);
*/
}
- cairo_move_to (ctx->cr,
+ cairo_move_to (context->cr,
a.x, a.y);
- cairo_curve_to (ctx->cr,
+ cairo_curve_to (context->cr,
b.x, b.y,
c.x, c.y,
d.x, d.y);
- ctx->pt_prev.x = x;
- ctx->pt_prev.y = y;
+ context->pt_prev.x = x;
+ context->pt_prev.y = y;
}
static void
-bend_close_path(void *data)
+bend_close_path (bend_context_t *context)
{
- struct ctx *ctx = data;
- ctx->closing = 1;
+ context->closing = 1;
- bend_line_to (data, ctx->pt_first.x, ctx->pt_first.y);
+ bend_line_to (context, context->pt_first.x, context->pt_first.y);
}
static void
bend_path (cairo_t *cr)
{
- struct ctx ctx;
+ bend_context_t context;
+ cairo_path_t *path;
+ int i;
- ctx.cr = cr;
- ctx.first = 1;
- ctx.closing = 0;
+ context.cr = cr;
+ context.first = 1;
+ context.closing = 0;
+
+ path = cairo_copy_path_flat (cr);
+ for (i=0; i < path->num_data; i += path->data[i].header.length) {
+ cairo_path_data_t *data = &path->data[i];
- cairo_current_path_flat (cr,
- bend_move_to,
- bend_line_to,
- bend_close_path,
- &ctx);
+ switch (data->header.type) {
+ case CAIRO_PATH_MOVE_TO:
+ bend_move_to (&context,
+ data[1].point.x, data[1].point.y);
+ break;
+ case CAIRO_PATH_LINE_TO:
+ bend_line_to (&context,
+ data[1].point.x, data[1].point.y);
+ break;
+ case CAIRO_PATH_CURVE_TO:
+ g_assert_not_reached ();
+ break;
+ case CAIRO_PATH_CLOSE_PATH:
+ bend_close_path (&context);
+ break;
+ }
+ }
+
+ cairo_path_destroy (path);
}
/* The static MAX_PTS and MAX_POLYS limits are pretty lame, but at
@@ -211,9 +232,10 @@
}
static void
-path_to_poly_list_move_to (void *data, double x, double y)
+path_to_poly_list_move_to (poly_list_t *poly_list,
+ double x,
+ double y)
{
- poly_list_t *poly_list = data;
poly_t *poly;
poly_list->num_polys++;
@@ -226,13 +248,14 @@
}
static void
-path_to_poly_list_line_to (void *data, double x, double y)
+path_to_poly_list_line_to (poly_list_t *poly_list,
+ double x,
+ double y)
{
- poly_list_t *poly_list = data;
poly_t *poly;
if (poly_list->num_polys == 0)
- return path_to_poly_list_move_to (data, x, y);
+ return path_to_poly_list_move_to (poly_list, x, y);
poly = &poly_list->polys[poly_list->num_polys - 1];
@@ -240,9 +263,8 @@
}
static void
-path_to_poly_list_close_path (void *data)
+path_to_poly_list_close_path (poly_list_t *poly_list)
{
- poly_list_t *poly_list = data;
poly_t *poly;
if (poly_list->num_polys == 0)
@@ -261,13 +283,34 @@
static void
path_to_poly_list (cairo_t *cr, poly_list_t *poly_list)
{
+ cairo_path_t *path;
+ int i;
+
poly_list->num_polys = 0;
- cairo_current_path_flat (cr,
- path_to_poly_list_move_to,
- path_to_poly_list_line_to,
- path_to_poly_list_close_path,
- poly_list);
+ path = cairo_copy_path_flat (cr);
+ for (i=0; i < path->num_data; i += path->data[i].header.length) {
+ cairo_path_data_t *data = &path->data[i];
+
+ switch (data->header.type) {
+ case CAIRO_PATH_MOVE_TO:
+ path_to_poly_list_move_to (poly_list,
+ data[1].point.x, data[1].point.y);
+ break;
+ case CAIRO_PATH_LINE_TO:
+ path_to_poly_list_line_to (poly_list,
+ data[1].point.x, data[1].point.y);
+ break;
+ case CAIRO_PATH_CURVE_TO:
+ g_assert_not_reached ();
+ break;
+ case CAIRO_PATH_CLOSE_PATH:
+ path_to_poly_list_close_path (poly_list);
+ break;
+ }
+ }
+
+ cairo_path_destroy (path);
}
#define NUM_BRISTLES 2
Index: caligula-draw-swirly.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/caligula-draw-swirly.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- caligula-draw-swirly.c 10 Feb 2005 16:50:32 -0000 1.2
+++ caligula-draw-swirly.c 21 Jun 2005 15:03:07 -0000 1.3
@@ -114,9 +114,9 @@
pattern = cairo_pattern_create_linear (right_x, top_y,
bottom_x, bottom_y);
- cairo_pattern_add_color_stop (pattern, 0, 0, 0, 0.5, 0.5);
- cairo_pattern_add_color_stop (pattern, 1, 0, 0, 0.2, 1);
- cairo_set_pattern (cr, pattern);
+ cairo_pattern_add_color_stop_rgba (pattern, 0, 0, 0, 0.5, 0.5);
+ cairo_pattern_add_color_stop_rgba (pattern, 1, 0, 0, 0.2, 1);
+ cairo_set_source (cr, pattern);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
@@ -165,20 +165,19 @@
/* Gradient fill */
pattern = cairo_pattern_create_linear (x, y, x, y + height);
- cairo_pattern_add_color_stop (pattern, 0, 0, 0, 0, 1);
- cairo_pattern_add_color_stop (pattern, 0.035, gray, gray, gray, 1);
- cairo_pattern_add_color_stop (pattern, 0.25, 1, 1, 1, 1);
- cairo_pattern_add_color_stop (pattern, 0.45, gray, gray, gray, 1);
- cairo_pattern_add_color_stop (pattern, 0.91, 1, 1, 1, 1);
- cairo_pattern_add_color_stop (pattern, 1, 0, 0, 0, 0);
- cairo_set_pattern (cr, pattern);
+ cairo_pattern_add_color_stop_rgba (pattern, 0, 0, 0, 0, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 0.035, gray, gray, gray, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 0.25, 1, 1, 1, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 0.45, gray, gray, gray, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 0.91, 1, 1, 1, 1);
+ cairo_pattern_add_color_stop_rgba (pattern, 1, 0, 0, 0, 0);
+ cairo_set_source (cr, pattern);
cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
/* Outline */
- cairo_set_alpha (cr, 1);
- cairo_set_rgb_color (cr, outline_gray, outline_gray, outline_gray);
+ cairo_set_source_rgb (cr, outline_gray, outline_gray, outline_gray);
cairo_set_line_width (cr, 1);
cairo_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1);
cairo_stroke (cr);
Index: caligula-rc-style.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/caligula-rc-style.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- caligula-rc-style.c 11 Feb 2005 15:52:00 -0000 1.3
+++ caligula-rc-style.c 21 Jun 2005 15:03:07 -0000 1.4
@@ -75,6 +75,8 @@
caligula_rc_style_init (CaligulaRcStyle *rc_style)
{
rc_style->drawing_style = CALIGULA_DRAWING_STYLE_DEFAULT;
+ rc_style->window_top_color.pixel = FALSE;
+ rc_style->window_bottom_color.pixel = FALSE;
}
static void
@@ -113,7 +115,9 @@
enum
{
- TOKEN_DRAWING_STYLE = G_TOKEN_LAST + 1
+ TOKEN_DRAWING_STYLE = G_TOKEN_LAST + 1,
+ TOKEN_WINDOW_TOP_COLOR,
+ TOKEN_WINDOW_BOTTOM_COLOR
};
static struct
@@ -123,7 +127,9 @@
}
theme_symbols[] =
{
- { "drawing-style", TOKEN_DRAWING_STYLE }
+ { "drawing-style", TOKEN_DRAWING_STYLE },
+ { "window-top-color", TOKEN_WINDOW_TOP_COLOR },
+ { "window-bottom-color", TOKEN_WINDOW_BOTTOM_COLOR }
};
static GTokenType
@@ -162,6 +168,56 @@
}
static GTokenType
+caligula_rc_style_parse_window_top_color (CaligulaRcStyle *rc_style,
+ GtkSettings *settings,
+ GScanner *scanner)
+{
+ GTokenType token;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != TOKEN_WINDOW_TOP_COLOR)
+ return TOKEN_WINDOW_TOP_COLOR;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_EQUAL_SIGN)
+ return G_TOKEN_EQUAL_SIGN;
+
+ token = gtk_rc_parse_color (scanner,
+ &rc_style->window_top_color);
+ if (token != G_TOKEN_NONE)
+ return token;
+
+ rc_style->window_top_color.pixel = TRUE;
+
+ return G_TOKEN_NONE;
+}
+
+static GTokenType
+caligula_rc_style_parse_window_bottom_color (CaligulaRcStyle *rc_style,
+ GtkSettings *settings,
+ GScanner *scanner)
+{
+ GTokenType token;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != TOKEN_WINDOW_BOTTOM_COLOR)
+ return TOKEN_WINDOW_BOTTOM_COLOR;
+
+ token = g_scanner_get_next_token (scanner);
+ if (token != G_TOKEN_EQUAL_SIGN)
+ return G_TOKEN_EQUAL_SIGN;
+
+ token = gtk_rc_parse_color (scanner,
+ &rc_style->window_bottom_color);
+ if (token != G_TOKEN_NONE)
+ return token;
+
+ rc_style->window_bottom_color.pixel = TRUE;
+
+ return G_TOKEN_NONE;
+}
+
+static GTokenType
caligula_rc_style_parse (GtkRcStyle *rc_style,
GtkSettings *settings,
GScanner *scanner)
@@ -203,6 +259,12 @@
case TOKEN_DRAWING_STYLE:
expected = caligula_rc_style_parse_drawing_style (caligula_style, settings, scanner);
break;
+ case TOKEN_WINDOW_TOP_COLOR:
+ expected = caligula_rc_style_parse_window_top_color (caligula_style, settings, scanner);
+ break;
+ case TOKEN_WINDOW_BOTTOM_COLOR:
+ expected = caligula_rc_style_parse_window_bottom_color (caligula_style, settings, scanner);
+ break;
default:
g_scanner_get_next_token (scanner);
expected = G_TOKEN_RIGHT_CURLY;
@@ -232,6 +294,12 @@
if (caligula_src->drawing_style != CALIGULA_DRAWING_STYLE_DEFAULT)
caligula_dest->drawing_style = caligula_src->drawing_style;
+
+ if (caligula_src->window_top_color.pixel)
+ caligula_dest->window_top_color = caligula_src->window_top_color;
+
+ if (caligula_src->window_bottom_color.pixel)
+ caligula_dest->window_bottom_color = caligula_src->window_bottom_color;
}
parent_class->merge (dest, src);
Index: caligula-rc-style.h
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/caligula-rc-style.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- caligula-rc-style.h 10 Feb 2005 20:44:33 -0000 1.2
+++ caligula-rc-style.h 21 Jun 2005 15:03:07 -0000 1.3
@@ -39,6 +39,10 @@
GtkRcStyle parent_instance;
CaligulaDrawingStyle drawing_style;
+
+ /* The pixel fields of the colors are used as a 'set' boolean */
+ GdkColor window_top_color;
+ GdkColor window_bottom_color;
} CaligulaRcStyle;
typedef struct _CaligulaRcStyleClass {
Index: caligula-style.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/caligula-style.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- caligula-style.c 13 Feb 2005 02:23:39 -0000 1.7
+++ caligula-style.c 21 Jun 2005 15:03:07 -0000 1.8
@@ -41,26 +41,9 @@
caligula_begin_paint (GdkDrawable *window,
GdkRectangle *area)
{
- Display *dpy;
- Drawable xid;
- GdkDrawable *drawable;
cairo_t *cr;
- int x_offset, y_offset;
-
- if (GDK_IS_WINDOW (window))
- gdk_window_get_internal_paint_info (window, &drawable,
- &x_offset, &y_offset);
- else
- drawable = window;
- dpy = gdk_x11_drawable_get_xdisplay (drawable);
- xid = gdk_x11_drawable_get_xid (drawable);
-
- cr = cairo_create ();
- cairo_set_target_drawable (cr, dpy, xid);
-
- if (GDK_IS_WINDOW (window))
- cairo_translate (cr, - x_offset, - y_offset);
+ cr = gdk_cairo_create (window);
if (area) {
cairo_rectangle (cr, area->x, area->y, area->width, area->height);
@@ -145,35 +128,65 @@
}
static void
-draw_window_background (GtkWidget *widget,
+draw_window_background (GtkStyle *style,
+ GtkWidget *widget,
GdkWindow *window,
GdkRectangle *area)
{
- cairo_pattern_t *pattern;
+ CaligulaRcStyle *rc_style = CALIGULA_RC_STYLE (style->rc_style);
cairo_t *cr;
- int width, height;
+ GdkColor top_color;
+ GdkColor bottom_color;
/* GtkWindow paints out of realize() to allow the
* theme to set the window background pixmap
*/
if (!GTK_WIDGET_MAPPED (widget))
return;
-
- gdk_drawable_get_size (window, &width, &height);
+
+ if (!rc_style->window_top_color.pixel)
+ top_color = style->bg[widget->state];
+ else
+ top_color = rc_style->window_top_color;
+
+ if (!rc_style->window_bottom_color.pixel)
+ bottom_color = style->bg[widget->state];
+ else
+ bottom_color = rc_style->window_bottom_color;
cr = caligula_begin_paint (window, area);
- pattern = cairo_pattern_create_linear (0, 0, 0, height);
- if (pattern) {
- cairo_pattern_add_color_stop (pattern, 0.0,
- 1.0, 1.0, 1.0, 1.0);
- cairo_pattern_add_color_stop (pattern, 1.0,
- 0.0, 0.0, 0.0, 1.0);
- cairo_set_pattern (cr, pattern);
+ if (top_color.red == bottom_color.red &&
+ top_color.green == bottom_color.green &&
+ top_color.blue == bottom_color.blue) {
- cairo_rectangle (cr, 0, 0, width, height);
- cairo_fill (cr);
+ cairo_set_source_rgb (cr,
+ top_color.red / 65535.,
+ top_color.green / 65535.,
+ top_color.blue / 65535.);
+
+ } else {
+ cairo_pattern_t *pattern;
+ int height;
+
+ gdk_drawable_get_size (window, 0, &height);
+
+ pattern = cairo_pattern_create_linear (0, 0, 0, height);
+ if (pattern) {
+ cairo_pattern_add_color_stop_rgb (pattern, 0.0,
+ top_color.red / 65535.,
+ top_color.green / 65535.,
+ top_color.blue / 65535.);
+ cairo_pattern_add_color_stop_rgb (pattern, 1.0,
+ bottom_color.red / 65535.,
+ bottom_color.green / 65535.,
+ bottom_color.blue / 65535.);
+ cairo_set_source (cr, pattern);
+ cairo_pattern_destroy (pattern);
+ }
}
+
+ cairo_paint (cr);
caligula_end_paint (cr);
}
@@ -192,7 +205,7 @@
int height)
{
if (widget && GTK_IS_WINDOW (widget)) {
- draw_window_background (widget, window, area);
+ draw_window_background (style, widget, window, area);
} else {
caligula_style_parent_class->draw_flat_box (style, window,
state_type, shadow_type,
Index: cge-draw.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/cge-draw.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- cge-draw.c 4 Feb 2005 22:13:09 -0000 1.20
+++ cge-draw.c 21 Jun 2005 15:03:07 -0000 1.21
@@ -490,9 +490,8 @@
cairo_move_to (cr, x1, y1);
cairo_line_to (cr, x2, y2);
- color_gdk_to_rgb (c,&r,&g,&b);
- cairo_set_rgb_color (cr, r, g, b);
- cairo_set_alpha (cr,alpha);
+ color_gdk_to_rgb (c, &r, &g, &b);
+ cairo_set_source_rgba (cr, r, g, b, alpha);
cairo_close_path (cr);
cairo_stroke (cr);
@@ -606,13 +605,12 @@
switch (THEME_DATA (style)->arrow_style)
{
case CGE_ARROW_NORMAL:
+ default:
rt=h/4 - h/10;
break;
case CGE_ARROW_SIMPLE:
rt=h/4;
break;
- default:
- break;
}
switch (at)
@@ -642,6 +640,7 @@
switch (THEME_DATA (style)->arrow_style)
{
case CGE_ARROW_NORMAL:
+ default:
cairo_rel_line_to (cr, (double) w/2, (double)h/2);
cairo_rel_line_to (cr, - (double)w/2, (double)h/5);
cairo_rel_line_to (cr, - (double)w/2, - (double)h/5);
@@ -650,15 +649,12 @@
cairo_rel_line_to (cr, (double) w/2, (double)h/2);
cairo_rel_line_to (cr, - (double)w,0);
break;
- default:
- break;
}
/* printf ("%i\n",THEME_DATA (style)->arrow_style); */
- color_gdk_to_rgb (c,&r,&g,&b);
- cairo_set_rgb_color (cr, r, g, b);
- cairo_set_alpha (cr,alpha);
+ color_gdk_to_rgb (c, &r, &g, &b);
+ cairo_set_source_rgba (cr, r, g, b, alpha);
cairo_close_path (cr);
if (fill)
@@ -683,9 +679,8 @@
cairo_save (cr);
cairo_translate (cr, (double)x, (double)y);
cairo_rectangle (cr,0,0, (double)w, (double)h);
- color_gdk_to_rgb (c,&r,&g,&b);
- cairo_set_alpha (cr,alpha);
- cairo_set_rgb_color (cr, r, g, b);
+ color_gdk_to_rgb (c, &r, &g, &b);
+ cairo_set_source_rgba (cr, r, g, b, alpha);
cairo_fill (cr);
cairo_restore (cr);
}
@@ -722,8 +717,7 @@
cairo_rel_line_to (cr, 0, - (double)h);
cairo_rel_line_to (cr, (double)w, 0);
color_gdk_to_rgb (c2,&r,&g,&b);
- cairo_set_rgb_color (cr, r, g, b);
- cairo_set_alpha (cr,alpha);
+ cairo_set_source_rgba (cr, r, g, b, alpha);
cairo_stroke (cr);
cairo_restore (cr);
@@ -735,8 +729,7 @@
cairo_rel_line_to (cr, 0, - (double)h);
cairo_rel_line_to (cr, (double)w, 0);
color_gdk_to_rgb (c1,&r,&g,&b);
- cairo_set_rgb_color (cr, r, g, b);
- cairo_set_alpha (cr,alpha);
+ cairo_set_source_rgba (cr, r, g, b, alpha);
cairo_stroke (cr);
cairo_restore (cr);
@@ -748,8 +741,7 @@
cairo_rel_line_to (cr, (double)w, 0);
cairo_rel_line_to (cr, 0, - (double)h);
color_gdk_to_rgb (c2,&r,&g,&b);
- cairo_set_rgb_color (cr, r, g, b);
- cairo_set_alpha (cr,alpha);
+ cairo_set_source_rgba (cr, r, g, b, alpha);
cairo_stroke (cr);
cairo_restore (cr);
/*
@@ -761,8 +753,7 @@
cairo_rel_line_to (cr, (double)w, 0);
cairo_rel_line_to (cr, 0, - (double)h);
color_gdk_to_rgb (c2,&r,&g,&b);
- cairo_set_rgb_color (cr, 0, 0, 0);
- cairo_set_alpha (cr,alpha);
+ cairo_set_source_rgba (cr, 0, 0, 0, alpha);
cairo_stroke (cr);
cairo_restore (cr);
*/
@@ -825,14 +816,12 @@
cairo_rel_line_to (cr, 0, - (double)h+ (double)2*round_size);
- color_gdk_to_rgb (c,&r,&g,&b);
-
- cairo_set_alpha (cr,alpha);
-
- cairo_set_rgb_color (cr, r, g, b);
-
- if (pattern!=NULL)
- cairo_set_pattern (cr,pattern);
+ if (pattern != NULL)
+ cairo_set_source (cr, pattern);
+ else {
+ color_gdk_to_rgb (c, &r, &g, &b);
+ cairo_set_source_rgba (cr, r, g, b, alpha);
+ }
/* cairo_close_path (cr); */
@@ -889,13 +878,12 @@
- (double)round_size,- (double)round_size/2,
- (double)round_size,- (double)round_size);
- color_gdk_to_rgb (c,&r,&g,&b);
-
- cairo_set_alpha (cr,alpha);
-
- cairo_set_rgb_color (cr, r, g, b);
- if (pattern!=NULL)
- cairo_set_pattern (cr,pattern);
+ if (pattern != NULL)
+ cairo_set_source (cr, pattern);
+ else {
+ color_gdk_to_rgb (c, &r, &g, &b);
+ cairo_set_source_rgba (cr, r, g, b, alpha);
+ }
cairo_close_path (cr);
@@ -964,14 +952,12 @@
cairo_rel_line_to (cr, 0, - (double)h);
- color_gdk_to_rgb (c,&r,&g,&b);
-
- cairo_set_alpha (cr,alpha);
-
- cairo_set_rgb_color (cr, r, g, b);
-
- if (pattern!=NULL)
- cairo_set_pattern (cr,pattern);
+ if (pattern != NULL)
+ cairo_set_source (cr, pattern);
+ else {
+ color_gdk_to_rgb (c, &r, &g, &b);
+ cairo_set_source_rgba (cr, r, g, b, alpha);
+ }
if (fill)
cairo_fill (cr);
@@ -1026,14 +1012,12 @@
cairo_rel_line_to (cr, 0, (double)h- (double)round_size);
-
- color_gdk_to_rgb (c,&r,&g,&b);
-
- cairo_set_alpha (cr,alpha);
-
- cairo_set_rgb_color (cr, r, g, b);
- if (pattern!=NULL)
- cairo_set_pattern (cr,pattern);
+ if (pattern != NULL)
+ cairo_set_source (cr, pattern);
+ else {
+ color_gdk_to_rgb (c, &r, &g, &b);
+ cairo_set_source_rgba (cr, r, g, b, alpha);
+ }
if (fill)
cairo_fill (cr);
@@ -1158,7 +1142,7 @@
cairo_translate (cr, (double)x, (double)y);
cairo_rectangle (cr,0,0, (double)width, (double)height);
if (gradient!=NULL)
- cairo_set_pattern (cr,gradient);
+ cairo_set_source (cr,gradient);
cairo_fill (cr);
cairo_restore (cr);
*/
More information about the cairo-commit
mailing list