[cairo-commit] cairo-gtk-engine/src caligula-style.c,1.3,1.4

Owen Taylor commit at pdx.freedesktop.org
Thu Feb 10 13:02:09 PST 2005


Committed by: otaylor

Update of /cvs/cairo/cairo-gtk-engine/src
In directory gabe:/tmp/cvs-serv2780/src

Modified Files:
	caligula-style.c 
Log Message:
2005-02-10  Owen Taylor  <otaylor at redhat.com>

        * theme/caligula-{sketch,grassy,swirly}/gtkrc: Include
        the main Caligula RC file and modify from there

        * src/caligula-style.c: Draw a gradient across the window background.

        * theme/caligula/gtkrc: Turn on GtkWindow::resizable-background


Index: caligula-style.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/caligula-style.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- caligula-style.c	10 Feb 2005 20:44:33 -0000	1.3
+++ caligula-style.c	10 Feb 2005 21:02:07 -0000	1.4
@@ -24,6 +24,7 @@
 #include <cairo.h>
 #include <cairo-xlib.h>
 #include <gdk/gdkx.h>
+#include <gtk/gtkwindow.h>
 
 #include "caligula.h"
 #include "caligula-rand.h"
@@ -34,6 +35,8 @@
 #include "caligula-draw-grassy.h"
 #include "caligula-draw-shadowed.h"
 
+static GtkStyleClass *caligula_style_parent_class;
+
 static cairo_t *
 caligula_begin_paint (GdkDrawable *window, gint *x_offset, gint *y_offset)
 {
@@ -67,17 +70,20 @@
 }
 
 static void
-caligula_draw_box (GtkStyle * style,
-		   GdkWindow * window,
-		   GtkStateType state_type,
-		   GtkShadowType shadow_type,
-		   GdkRectangle * area,
-		   GtkWidget * widget,
-		   const gchar * detail,
-		   gint x, gint y, gint width, gint height)
+caligula_draw_box (GtkStyle      *style,
+		   GdkWindow     *window,
+		   GtkStateType   state_type,
+		   GtkShadowType  shadow_type,
+		   GdkRectangle  *area,
+		   GtkWidget     *widget,
+		   const gchar   *detail,
+		   int            x,
+		   int            y,
+		   int            width,
+		   int            height)
 { 
     cairo_t *cr;
-    gint x_offset, y_offset;
+    int x_offset, y_offset;
     CaligulaRcStyle *rc_style = CALIGULA_RC_STYLE (style->rc_style);
 
     caligula_srand ((unsigned)widget);
@@ -101,6 +107,58 @@
 }
 
 static void
+draw_window_background (GtkWidget    *widget,
+			GdkWindow    *window,
+			GdkRectangle *area)
+{
+    cairo_pattern_t *pattern;
+    cairo_t *cr;
+    int width, height;
+    int x_offset, y_offset;
+    
+    gdk_drawable_get_size (window, &width, &height);
+
+    cr = caligula_begin_paint (window, &x_offset, &y_offset);
+
+    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);
+
+	cairo_rectangle (cr, 0, 0, width, height);
+	cairo_fill (cr);
+    }
+    
+    caligula_end_paint (cr);
+}
+
+static void
+caligula_draw_flat_box   (GtkStyle        *style,
+			  GdkWindow       *window,
+			  GtkStateType     state_type,
+			  GtkShadowType    shadow_type,
+			  GdkRectangle    *area,
+			  GtkWidget       *widget,
+			  const gchar     *detail,
+			  int              x,
+			  int              y,
+			  int              width,
+			  int              height)
+{
+    if (widget && GTK_IS_WINDOW (widget)) {
+	draw_window_background (widget, window, area);
+    } else {
+	caligula_style_parent_class->draw_flat_box (style, window,
+						    state_type, shadow_type,
+						    area, widget, detail,
+						    x, y, width, height);
+    }
+}
+
+static void
 caligula_style_init (CaligulaStyle *style)
 {
 }
@@ -111,6 +169,9 @@
     GtkStyleClass *style_class = GTK_STYLE_CLASS (klass);
 
     style_class->draw_box = caligula_draw_box;
+    style_class->draw_flat_box = caligula_draw_flat_box;
+    
+    caligula_style_parent_class = g_type_class_peek_parent (klass);
 }
 
 GType caligula_type_style = 0;




More information about the cairo-commit mailing list