summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2015-07-12 19:44:26 +0200
committerinfirit <[email protected]>2015-07-12 19:44:26 +0200
commit2208d0af94aeb5b68d1209ad2b11cd46c14c8d23 (patch)
tree50db1b72797858309fec008fc5fdb7f579fb9e05
parentfb522992685b334c9b5e56d3eb15f9ba2d0b3acd (diff)
downloadmate-control-center-2208d0af94aeb5b68d1209ad2b11cd46c14c8d23.tar.bz2
mate-control-center-2208d0af94aeb5b68d1209ad2b11cd46c14c8d23.tar.xz
Replace Gdk drawing with Cairo
-rw-r--r--capplets/display/scrollarea.c60
-rw-r--r--font-viewer/font-view.c24
-rw-r--r--typing-break/drw-break-window.c31
-rw-r--r--typing-break/drw-utils.c21
4 files changed, 56 insertions, 80 deletions
diff --git a/capplets/display/scrollarea.c b/capplets/display/scrollarea.c
index a160f532..711984a4 100644
--- a/capplets/display/scrollarea.c
+++ b/capplets/display/scrollarea.c
@@ -603,25 +603,6 @@ clip_to_region (cairo_t *cr, GdkRegion *region)
}
#endif
-#if !GTK_CHECK_VERSION (3, 0, 0)
-static void
-simple_draw_drawable (GdkDrawable *dst,
- GdkDrawable *src,
- int src_x,
- int src_y,
- int dst_x,
- int dst_y,
- int width,
- int height)
-{
- GdkGC *gc = gdk_gc_new (dst);
-
- gdk_draw_drawable (dst, gc, src, src_x, src_y, dst_x, dst_y, width, height);
-
- g_object_unref (gc);
-}
-#endif
-
static gboolean
#if GTK_CHECK_VERSION (3, 0, 0)
foo_scroll_area_draw (GtkWidget *widget,
@@ -634,7 +615,6 @@ foo_scroll_area_expose (GtkWidget *widget,
FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
cairo_t *cr;
#if !GTK_CHECK_VERSION (3, 0, 0)
- GdkGC *gc;
GdkRectangle extents;
GdkWindow *window = gtk_widget_get_window (widget);
#endif
@@ -710,16 +690,14 @@ foo_scroll_area_expose (GtkWidget *widget,
cairo_set_source_surface (widget_cr, scroll_area->priv->surface, widget_allocation.x, widget_allocation.y);
cairo_paint (widget_cr);
#else
- gc = gdk_gc_new (window);
-
- gdk_gc_set_clip_region (gc, expose->region);
-
gtk_widget_get_allocation (widget, &widget_allocation);
- gdk_draw_drawable (window, gc, scroll_area->priv->pixmap,
- 0, 0, widget_allocation.x, widget_allocation.y,
- widget_allocation.width, widget_allocation.height);
- g_object_unref (gc);
+ cr = gdk_cairo_create (window);
+ gdk_cairo_set_source_pixmap (cr, scroll_area->priv->pixmap,
+ widget_allocation.x, widget_allocation.y);
+ gdk_cairo_region (cr, expose->region);
+ cairo_fill (cr);
+ cairo_destroy (cr);
#endif
gdk_region_destroy (region);
@@ -894,6 +872,7 @@ create_new_pixmap (GtkWidget *widget,
cairo_surface_t *new;
#else
GdkPixmap *new;
+ cairo_t *cr;
#endif
gtk_widget_get_allocation (widget, &widget_allocation);
@@ -918,15 +897,17 @@ create_new_pixmap (GtkWidget *widget,
* That might just work, actually. We need to make sure marco uses
* static gravity for the window before this will be useful.
*/
+
#if GTK_CHECK_VERSION (3, 0, 0)
cr = cairo_create (new);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_surface (cr, old, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
#else
- simple_draw_drawable (new, old, 0, 0, 0, 0, -1, -1);
+ cr = gdk_cairo_create (new);
+ gdk_cairo_set_source_pixmap (cr, old, 0, 0);
#endif
+ cairo_paint (cr);
+ cairo_destroy (cr);
return new;
}
@@ -1264,9 +1245,13 @@ foo_scroll_area_scroll (FooScrollArea *area,
if (gdk_rectangle_intersect (&allocation, &src_area, &move_area))
{
GdkRegion *move_region;
+ cairo_t *cr;
#if GTK_CHECK_VERSION (3, 0, 0)
- cairo_t *cr = cairo_create (area->priv->surface);
+ cr = cairo_create (area->priv->surface);
+#else
+ cr = gdk_cairo_create (area->priv->pixmap);
+#endif
/* Cairo doesn't allow self-copies, so we do this little trick instead:
* 1) Clip so the group size is small.
@@ -1276,7 +1261,11 @@ foo_scroll_area_scroll (FooScrollArea *area,
cairo_clip (cr);
cairo_push_group (cr);
+#if GTK_CHECK_VERSION (3, 0, 0)
cairo_set_source_surface (cr, area->priv->surface, dx, dy);
+#else
+ gdk_cairo_set_source_pixmap (cr, area->priv->pixmap, dx, dy);
+#endif
gdk_cairo_rectangle (cr, &move_area);
cairo_fill (cr);
@@ -1284,12 +1273,7 @@ foo_scroll_area_scroll (FooScrollArea *area,
cairo_paint (cr);
cairo_destroy (cr);
-#else
- simple_draw_drawable (area->priv->pixmap, area->priv->pixmap,
- move_area.x, move_area.y,
- move_area.x + dx, move_area.y + dy,
- move_area.width, move_area.height);
-#endif
+
gtk_widget_queue_draw (GTK_WIDGET (area));
move_region = gdk_region_rectangle (&move_area);
diff --git a/font-viewer/font-view.c b/font-viewer/font-view.c
index 3c150441..54a402dd 100644
--- a/font-viewer/font-view.c
+++ b/font-viewer/font-view.c
@@ -115,6 +115,7 @@ create_text_pixmap(GtkWidget *drawing_area, FT_Face face)
XftFont *font;
gint *sizes = NULL, n_sizes, alpha_size;
FcCharSet *charset = NULL;
+ cairo_t *cr;
GdkWindow *window = gtk_widget_get_window (drawing_area);
text = pango_language_get_sample_string(NULL);
@@ -201,8 +202,10 @@ create_text_pixmap(GtkWidget *drawing_area, FT_Face face)
pixmap_width, pixmap_height, -1);
if (!pixmap)
goto end;
- gdk_draw_rectangle(pixmap, gtk_widget_get_style(drawing_area)->white_gc,
- TRUE, 0, 0, pixmap_width, pixmap_height);
+ cr = gdk_cairo_create (pixmap);
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+ cairo_destroy (cr);
xdrawable = GDK_DRAWABLE_XID(pixmap);
draw = XftDrawCreate(xdisplay, xdrawable, xvisual, xcolormap);
@@ -387,12 +390,14 @@ add_face_info(GtkWidget *table, gint *row_p, const gchar *uri, FT_Face face)
static gboolean
expose_event(GtkWidget *widget, GdkEventExpose *event, GdkPixmap *pixmap)
{
- gdk_draw_drawable(gtk_widget_get_window (widget),
- gtk_widget_get_style (widget)->fg_gc[gtk_widget_get_state (widget)],
- pixmap,
- event->area.x, event->area.y,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
+ cairo_t *cr;
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+ gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
+ gdk_cairo_region (cr, event->region);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+
return FALSE;
}
#endif
@@ -517,9 +522,6 @@ main(int argc, char **argv)
gchar *font_file, *title;
gint row;
GtkWidget *window, *hbox, *table, *swin, *drawing_area;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GdkPixmap *pixmap;
-#endif
GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
GtkWidget *button, *align;
diff --git a/typing-break/drw-break-window.c b/typing-break/drw-break-window.c
index bb9edefe..87e7ec3f 100644
--- a/typing-break/drw-break-window.c
+++ b/typing-break/drw-break-window.c
@@ -605,7 +605,7 @@ label_expose_event_cb (GtkLabel *label,
GtkWidget *widget;
GdkWindow *window;
#if !GTK_CHECK_VERSION (3, 0, 0)
- GdkGC *gc;
+ cairo_t *cr;
#endif
color.red = 0;
@@ -618,23 +618,24 @@ label_expose_event_cb (GtkLabel *label,
widget = GTK_WIDGET (label);
window = gtk_widget_get_window (widget);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gc = gdk_gc_new (window);
- gdk_gc_set_rgb_fg_color (gc, &color);
- gdk_gc_set_clip_rectangle (gc, &event->area);
-#endif
-
#if GTK_CHECK_VERSION (3, 0, 0)
pango_cairo_show_layout (cr, gtk_label_get_layout (label));
#else
- gdk_draw_layout_with_colors (window,
- gc,
- x + 1,
- y + 1,
- gtk_label_get_layout (label),
- &color,
- NULL);
- g_object_unref (gc);
+ cr = gdk_cairo_create (window);
+
+ gdk_cairo_rectangle (cr, &event->area);
+ cairo_clip (cr);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+
+ /* Can't use pango_cairo_show_layout() here as we need to override
+ * the layout's colors with our shadow color.
+ */
+ cairo_move_to (cr, x + 1, y + 1);
+ pango_cairo_layout_path (cr, gtk_label_get_layout (label));
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
#endif
gtk_paint_layout (gtk_widget_get_style (widget),
diff --git a/typing-break/drw-utils.c b/typing-break/drw-utils.c
index 0bf27c59..f5ed7e3f 100644
--- a/typing-break/drw-utils.c
+++ b/typing-break/drw-utils.c
@@ -157,14 +157,11 @@ set_pixmap_background (GtkWidget *window)
{
GdkScreen *screen;
GdkPixbuf *tmp_pixbuf, *pixbuf, *tile_pixbuf;
-#if GTK_CHECK_VERSION (3, 0, 0)
- cairo_t *cr;
-#else
GdkPixmap *pixmap;
-#endif
GdkRectangle rect;
GdkColor color;
gint width, height;
+ cairo_t *cr;
gtk_widget_realize (window);
@@ -232,18 +229,10 @@ set_pixmap_background (GtkWidget *window)
height,
-1);
- gdk_draw_pixbuf (pixmap,
- NULL,
- tmp_pixbuf,
- 0,
- 0,
- 0,
- 0,
- width,
- height,
- GDK_RGB_DITHER_NONE,
- 0,
- 0);
+ cr = gdk_cairo_create (pixmap);
+ gdk_cairo_set_source_pixbuf (cr, tmp_pixbuf, 0, 0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
#endif
g_object_unref (tmp_pixbuf);