summaryrefslogtreecommitdiff
path: root/gtk-3.0
diff options
context:
space:
mode:
authorPeter de Ridder <peter@xfce.org>2011-12-30 16:26:04 +0100
committerPeter de Ridder <peter@xfce.org>2011-12-30 16:26:04 +0100
commit63da31624c2def06cc051f91e55a4c58e46625c6 (patch)
treedd8113cc10198ad0fb8927b13eeb6f7beb8f2958 /gtk-3.0
parent3c38beab1fefbfd072201241a5ebdb7e31b712fe (diff)
downloadgtk-xfce-engine-63da31624c2def06cc051f91e55a4c58e46625c6.tar.gz
Added Gtk 3 background render function
Diffstat (limited to 'gtk-3.0')
-rw-r--r--gtk-3.0/xfce_engine.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/gtk-3.0/xfce_engine.c b/gtk-3.0/xfce_engine.c
index 1c2640e..c8ce045 100644
--- a/gtk-3.0/xfce_engine.c
+++ b/gtk-3.0/xfce_engine.c
@@ -147,6 +147,7 @@ parts[] =
static void xfce_draw_grips(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdouble y, gdouble width, gdouble height, GtkOrientation orientation);
static void render_line(GtkThemingEngine * engine, cairo_t * cr, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
+static void render_background(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdouble y, gdouble width, gdouble height);
static void render_frame(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdouble y, gdouble width, gdouble height);
static void render_check(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdouble y, gdouble width, gdouble height);
@@ -411,6 +412,66 @@ static void render_line(GtkThemingEngine * engine, cairo_t * cr, gdouble x1, gdo
}
}
+static void render_background(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdouble y, gdouble width, gdouble height)
+{
+ GdkRGBA bg_color;
+ cairo_pattern_t *pattern;
+ gint xthick, ythick;
+ gint xt, yt;
+ GtkStateFlags state;
+ GtkBorder border;
+ gboolean smooth_edge;
+
+ state = gtk_theming_engine_get_state(engine);
+
+ gtk_theming_engine_get_background_color(engine, state, &bg_color);
+ gtk_theming_engine_get(engine, state, GTK_STYLE_PROPERTY_BACKGROUND_IMAGE, &pattern, NULL);
+
+ gtk_theming_engine_get(engine, state, XFCE_SMOOTH_EDGE, &smooth_edge, NULL);
+ gtk_theming_engine_get_border (engine, state, &border);
+
+ xthick = border.left;
+ ythick = border.top;
+
+ cairo_save(cr);
+ cairo_translate(cr, x, y);
+
+ xt = MIN(xthick, width - 1);
+ yt = MIN(ythick, height - 1);
+ if(smooth_edge && gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_PROGRESSBAR))
+ {
+ xt = 1;
+ yt = 1;
+ }
+ else
+ {
+ xt = MIN(xt, 2);
+ yt = MIN(yt, 2);
+ }
+
+ cairo_rectangle(cr, xt, yt, width - xt * 2, height - yt * 2);
+
+ if(pattern)
+ {
+ cairo_scale(cr, width, height);
+ cairo_set_source(cr, pattern);
+ cairo_scale(cr, 1.0 / width, 1.0 / height);
+ }
+ else
+ {
+ gdk_cairo_set_source_rgba(cr, &bg_color);
+ }
+
+ cairo_fill(cr);
+
+ if(pattern)
+ {
+ cairo_pattern_destroy (pattern);
+ }
+
+ cairo_restore(cr);
+}
+
static void render_frame(GtkThemingEngine * engine, cairo_t * cr, gdouble x, gdouble y, gdouble width, gdouble height)
{
gint xt, yt;
@@ -1685,6 +1746,7 @@ static void xfce_engine_class_init(XfceEngineClass * klass)
GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS(klass);
engine_class->render_line = render_line;
+ engine_class->render_background = render_background;
engine_class->render_frame = render_frame;
engine_class->render_check = render_check;
engine_class->render_option = render_option;