[gimp/gtk3-port: 8/226] libgimpwidgets: port to GtkWidget::draw()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 8/226] libgimpwidgets: port to GtkWidget::draw()
- Date: Tue, 14 May 2013 18:30:42 +0000 (UTC)
commit 3d2f25de8955c73d4dbdede957fdcc1fc76e4153
Author: Michael Natterer <mitch gimp org>
Date: Fri Oct 15 11:13:47 2010 +0200
libgimpwidgets: port to GtkWidget::draw()
libgimpwidgets/gimpcolorscale.c | 38 ++++++++++++--------------------------
1 files changed, 12 insertions(+), 26 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorscale.c b/libgimpwidgets/gimpcolorscale.c
index 608b856..14839c3 100644
--- a/libgimpwidgets/gimpcolorscale.c
+++ b/libgimpwidgets/gimpcolorscale.c
@@ -70,8 +70,8 @@ static gboolean gimp_color_scale_button_press (GtkWidget *widget,
GdkEventButton *event);
static gboolean gimp_color_scale_button_release (GtkWidget *widget,
GdkEventButton *event);
-static gboolean gimp_color_scale_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gimp_color_scale_draw (GtkWidget *widget,
+ cairo_t *cr);
static void gimp_color_scale_render (GimpColorScale *scale);
static void gimp_color_scale_render_alpha (GimpColorScale *scale);
@@ -97,7 +97,7 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
widget_class->state_changed = gimp_color_scale_state_changed;
widget_class->button_press_event = gimp_color_scale_button_press;
widget_class->button_release_event = gimp_color_scale_button_release;
- widget_class->expose_event = gimp_color_scale_expose;
+ widget_class->draw = gimp_color_scale_draw;
/**
* GimpColorScale:channel:
@@ -318,15 +318,13 @@ gimp_color_scale_button_release (GtkWidget *widget,
}
static gboolean
-gimp_color_scale_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gimp_color_scale_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GimpColorScale *scale = GIMP_COLOR_SCALE (widget);
GtkRange *range = GTK_RANGE (widget);
GtkStyle *style = gtk_widget_get_style (widget);
- GdkWindow *window = gtk_widget_get_window (widget);
gboolean sensitive = gtk_widget_is_sensitive (widget);
- GtkAllocation allocation;
GdkRectangle range_rect;
GdkRectangle area = { 0, };
cairo_surface_t *buffer;
@@ -336,18 +334,10 @@ gimp_color_scale_expose (GtkWidget *widget,
gint slider_size;
gint x, y;
gint w, h;
- cairo_t *cr;
if (! scale->buf || ! gtk_widget_is_drawable (widget))
return FALSE;
- gtk_widget_get_allocation (widget, &allocation);
-
- cr = gdk_cairo_create (window);
- gdk_cairo_region (cr, event->region);
- cairo_translate (cr, allocation.x, allocation.y);
- cairo_clip (cr);
-
gtk_widget_style_get (widget,
"trough-border", &trough_border,
NULL);
@@ -383,13 +373,11 @@ gimp_color_scale_expose (GtkWidget *widget,
scale->needs_render = FALSE;
}
- gtk_paint_box (style, window,
+ gtk_paint_box (style, cr,
sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
GTK_SHADOW_IN,
- &event->area, widget, "trough",
- x + allocation.x,
- y + allocation.y,
- w, h);
+ widget, "trough",
+ x, y, w, h);
buffer = cairo_image_surface_create_for_data (scale->buf,
CAIRO_FORMAT_RGB24,
@@ -416,10 +404,10 @@ gimp_color_scale_expose (GtkWidget *widget,
cairo_paint (cr);
if (gtk_widget_has_focus (widget))
- gtk_paint_focus (style, window, gtk_widget_get_state (widget),
- &event->area, widget, "trough",
- range_rect.x + allocation.x,
- range_rect.y + allocation.y,
+ gtk_paint_focus (style, cr, gtk_widget_get_state (widget),
+ widget, "trough",
+ range_rect.x,
+ range_rect.y,
range_rect.width,
range_rect.height);
@@ -494,8 +482,6 @@ gimp_color_scale_expose (GtkWidget *widget,
cairo_close_path (cr);
cairo_fill (cr);
- cairo_destroy (cr);
-
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]