diff options
author | Jasmine Hassan <[email protected]> | 2012-10-31 07:16:33 +0200 |
---|---|---|
committer | Jasmine Hassan <[email protected]> | 2012-11-02 16:25:25 +0200 |
commit | ea7bc87871154c2239f25d84191add2d4b630022 (patch) | |
tree | cc0b5ae5daec37c715d4cfa3f60eea8be72b7811 | |
parent | ec92a520965f420af7d00ad8e347f62106bbc578 (diff) | |
download | caja-ea7bc87871154c2239f25d84191add2d4b630022.tar.bz2 caja-ea7bc87871154c2239f25d84191add2d4b630022.tar.xz |
[eel] Use GdkRegion on GTK2, cairo_region_t on GTK3
http://git.gnome.org/browse/nautilus/commit/?id=3b671558f1d8ac1ee72e8af13d4ede6ab549a400
-rw-r--r-- | eel/eel-canvas-rect-ellipse.c | 24 | ||||
-rw-r--r-- | eel/eel-canvas.c | 8 | ||||
-rw-r--r-- | eel/eel-editable-label.c | 14 |
3 files changed, 32 insertions, 14 deletions
diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c index c637769d..b78c47a7 100644 --- a/eel/eel-canvas-rect-ellipse.c +++ b/eel/eel-canvas-rect-ellipse.c @@ -1012,9 +1012,8 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose { if ((re->fill_color & 0xff) != 255) { - GdkRectangle *rectangles; gint i, n_rectangles; - GdkRectangle draw_rect; + GdkRectangle draw_rect, rect; GdkRectangle part; draw_rect.x = cx1; @@ -1024,13 +1023,19 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose /* For alpha mode, only render the parts of the region that are actually exposed */ - gdk_region_get_rectangles (expose->region, - &rectangles, - &n_rectangles); - +#if GTK_CHECK_VERSION(3, 0, 0) + n_rectangles = cairo_region_num_rectangles (expose->region); +#else + gdk_region_get_rectangles (expose->region, &rect, &n_rectangles); +#endif for (i = 0; i < n_rectangles; i++) { - if (gdk_rectangle_intersect (&rectangles[i], +#if GTK_CHECK_VERSION(3, 0, 0) + cairo_region_get_rectangle (expose->region, i, &rect); +#else + rect = &rect[i]; +#endif + if (gdk_rectangle_intersect (&rect, &draw_rect, &part)) { @@ -1041,8 +1046,9 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose re->fill_color); } } - - g_free (rectangles); +#if !GTK_CHECK_VERSION(3, 0, 0) + g_free (rect); +#endif } else { diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index a4d6612d..43c111f6 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -73,6 +73,12 @@ #include "eel-marshal.h" +/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */ +#if !GTK_CHECK_VERSION (3, 0, 0) +#define cairo_region_contains_rectangle gdk_region_rect_in +#define CAIRO_REGION_OVERLAP_OUT GDK_OVERLAP_RECTANGLE_OUT +#endif + static void eel_canvas_request_update (EelCanvas *canvas); static void group_add (EelCanvasGroup *group, EelCanvasItem *item); @@ -1553,7 +1559,7 @@ eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable, child_rect.width = child->x2 - child->x1 + 1; child_rect.height = child->y2 - child->y1 + 1; - if (gdk_region_rect_in (expose->region, &child_rect) != GDK_OVERLAP_RECTANGLE_OUT) + if (cairo_region_contains_rectangle (expose->region, &child_rect) != CAIRO_REGION_OVERLAP_OUT) (* EEL_CANVAS_ITEM_GET_CLASS (child)->draw) (child, drawable, expose); } } diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index 7780fe7f..2c7ea7b0 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -37,6 +37,12 @@ #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */ +#if !GTK_CHECK_VERSION (3, 0, 0) +#define cairo_region_t GdkRegion +#define cairo_region_destroy gdk_region_destroy +#endif + enum { MOVE_CURSOR, @@ -1580,7 +1586,7 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof } else /* Block cursor */ { - GdkRegion *clip; + cairo_region_t *clip; gdk_draw_rectangle (gtk_widget_get_window (widget), label->primary_cursor_gc, TRUE, xoffset + PANGO_PIXELS (strong_pos.x), @@ -1608,7 +1614,7 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof NULL); gdk_gc_set_clip_region (label->primary_cursor_gc, NULL); - gdk_region_destroy (clip); + cairo_region_destroy (clip); } } } @@ -1650,7 +1656,7 @@ eel_editable_label_expose (GtkWidget *widget, { gint range[2]; const char *text; - GdkRegion *clip; + cairo_region_t *clip; GtkStateType state; range[0] = label->selection_anchor; @@ -1695,7 +1701,7 @@ eel_editable_label_expose (GtkWidget *widget, &style->base[state]); gdk_gc_set_clip_region (style->black_gc, NULL); - gdk_region_destroy (clip); + cairo_region_destroy (clip); } else if (gtk_widget_has_focus (widget)) eel_editable_label_draw_cursor (label, x, y); |