From e27893d9e6427646203a4566df9080bdb346b893 Mon Sep 17 00:00:00 2001 From: infirit Date: Wed, 15 Jul 2015 19:37:42 +0200 Subject: appearance-font: Replace Gdk drawing with cairo This unifies the drawing code between Gtk versions. But with Gtk3 the setup_font_sample is broken and requires considerable effort to fix. Maybe pango can help us here.. --- capplets/appearance/appearance-font.c | 39 ++++++++++++++--------------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'capplets/appearance') diff --git a/capplets/appearance/appearance-font.c b/capplets/appearance/appearance-font.c index 2c2cd072..78d079e1 100644 --- a/capplets/appearance/appearance-font.c +++ b/capplets/appearance/appearance-font.c @@ -80,41 +80,34 @@ static void sample_expose(GtkWidget* darea, GdkEventExpose* expose) { GtkAllocation allocation; GdkPixbuf* pixbuf = g_object_get_data(G_OBJECT(darea), "sample-pixbuf"); -#if !GTK_CHECK_VERSION (3, 0, 0) - GdkWindow* window = gtk_widget_get_window(darea); - GtkStyle* style = gtk_widget_get_style(darea); int width = gdk_pixbuf_get_width(pixbuf); int height = gdk_pixbuf_get_height(pixbuf); -#endif gtk_widget_get_allocation (darea, &allocation); - -#if !GTK_CHECK_VERSION (3, 0, 0) int x = (allocation.width - width) / 2; int y = (allocation.height - height) / 2; -#endif -#if GTK_CHECK_VERSION (3, 0, 0) - cairo_set_line_width(cr, 1); + GdkColor black, white; + gdk_color_parse ("black", &black); + gdk_color_parse ("white", &white); - cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); - cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); - cairo_stroke_preserve(cr); - cairo_fill(cr); +#if !GTK_CHECK_VERSION (3, 0, 0) + cairo_t *cr = gdk_cairo_create (expose->window); +#endif + cairo_set_line_width (cr, 1); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); - cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); - cairo_rectangle(cr, 0, 0, allocation.width - 1, allocation.height - 1); - cairo_stroke_preserve(cr); - cairo_fill(cr); + gdk_cairo_set_source_color (cr, &white); + cairo_rectangle (cr, 0, 0, allocation.width, allocation.height); + cairo_fill_preserve (cr); + gdk_cairo_set_source_color (cr, &black); + cairo_stroke (cr); - gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); + gdk_cairo_set_source_pixbuf(cr, pixbuf, x, y); cairo_paint(cr); - cairo_fill (cr); -#else - gdk_draw_rectangle(window, style->white_gc, TRUE, 0, 0, allocation.width, allocation.height); - gdk_draw_rectangle(window, style->black_gc, FALSE, 0, 0, allocation.width - 1, allocation.height - 1); - gdk_draw_pixbuf(window, NULL, pixbuf, 0, 0, x, y, width, height, GDK_RGB_DITHER_NORMAL, 0, 0); +#if !GTK_CHECK_VERSION (3, 0, 0) + cairo_destroy (cr); #endif } -- cgit v1.2.1