[gimp/gtk3-port: 223/226] app: port GimpCircle and subclasses to GTK+ 3
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 223/226] app: port GimpCircle and subclasses to GTK+ 3
- Date: Mon, 4 Aug 2014 06:44:36 +0000 (UTC)
commit 931a74fe991709448fa52bf4a0c2d40e6d137f28
Author: Michael Natterer <mitch gimp org>
Date: Fri May 30 02:37:25 2014 +0200
app: port GimpCircle and subclasses to GTK+ 3
app/widgets/gimpcircle.c | 66 +++++++++++++++++++++++++--------------------
app/widgets/gimpdial.c | 53 ++++++++++++++++---------------------
app/widgets/gimppolar.c | 49 ++++++++++++++-------------------
3 files changed, 81 insertions(+), 87 deletions(-)
---
diff --git a/app/widgets/gimpcircle.c b/app/widgets/gimpcircle.c
index 742aa44..8561a36 100644
--- a/app/widgets/gimpcircle.c
+++ b/app/widgets/gimpcircle.c
@@ -72,12 +72,16 @@ static void gimp_circle_realize (GtkWidget *widge
static void gimp_circle_unrealize (GtkWidget *widget);
static void gimp_circle_map (GtkWidget *widget);
static void gimp_circle_unmap (GtkWidget *widget);
-static void gimp_circle_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+static void gimp_circle_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static void gimp_circle_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
static void gimp_circle_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-static gboolean gimp_circle_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gimp_circle_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean gimp_circle_button_press_event (GtkWidget *widget,
GdkEventButton *bevent);
static gboolean gimp_circle_button_release_event (GtkWidget *widget,
@@ -118,9 +122,10 @@ gimp_circle_class_init (GimpCircleClass *klass)
widget_class->unrealize = gimp_circle_unrealize;
widget_class->map = gimp_circle_map;
widget_class->unmap = gimp_circle_unmap;
- widget_class->size_request = gimp_circle_size_request;
+ widget_class->get_preferred_width = gimp_circle_get_preferred_width;
+ widget_class->get_preferred_height = gimp_circle_get_preferred_height;
widget_class->size_allocate = gimp_circle_size_allocate;
- widget_class->expose_event = gimp_circle_expose_event;
+ widget_class->draw = gimp_circle_draw;
widget_class->button_press_event = gimp_circle_button_press_event;
widget_class->button_release_event = gimp_circle_button_release_event;
widget_class->enter_notify_event = gimp_circle_enter_notify_event;
@@ -319,13 +324,23 @@ gimp_circle_unmap (GtkWidget *widget)
}
static void
-gimp_circle_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+gimp_circle_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
{
GimpCircle *circle = GIMP_CIRCLE (widget);
- requisition->width = 2 * circle->priv->border_width + circle->priv->size;
- requisition->height = 2 * circle->priv->border_width + circle->priv->size;
+ *minimum_width = *natural_width = 2 * circle->priv->border_width + circle->priv->size;
+}
+
+static void
+gimp_circle_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ GimpCircle *circle = GIMP_CIRCLE (widget);
+
+ *minimum_height = *natural_height = 2 * circle->priv->border_width + circle->priv->size;
}
static void
@@ -351,31 +366,24 @@ gimp_circle_size_allocate (GtkWidget *widget,
}
static gboolean
-gimp_circle_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+gimp_circle_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- GimpCircle *circle = GIMP_CIRCLE (widget);
-
- if (gtk_widget_is_drawable (widget))
- {
- GtkAllocation allocation;
- gint size = circle->priv->size;
- cairo_t *cr;
+ GimpCircle *circle = GIMP_CIRCLE (widget);
+ GtkAllocation allocation;
+ gint size = circle->priv->size;
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
+ gtk_widget_get_allocation (widget, &allocation);
- gtk_widget_get_allocation (widget, &allocation);
+ cairo_save (cr);
- cairo_translate (cr,
- allocation.x + (allocation.width - size) / 2,
- allocation.y + (allocation.height - size) / 2);
+ cairo_translate (cr,
+ (allocation.width - size) / 2,
+ (allocation.height - size) / 2);
- gimp_circle_draw_background (circle, cr, size, circle->priv->background);
+ gimp_circle_draw_background (circle, cr, size, circle->priv->background);
- cairo_destroy (cr);
- }
+ cairo_restore (cr);
return FALSE;
}
diff --git a/app/widgets/gimpdial.c b/app/widgets/gimpdial.c
index 690e960..9cdf5f1 100644
--- a/app/widgets/gimpdial.c
+++ b/app/widgets/gimpdial.c
@@ -80,8 +80,8 @@ static void gimp_dial_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
-static gboolean gimp_dial_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gimp_dial_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean gimp_dial_button_press_event (GtkWidget *widget,
GdkEventButton *bevent);
static gboolean gimp_dial_motion_notify_event (GtkWidget *widget,
@@ -120,7 +120,7 @@ gimp_dial_class_init (GimpDialClass *klass)
object_class->get_property = gimp_dial_get_property;
object_class->set_property = gimp_dial_set_property;
- widget_class->expose_event = gimp_dial_expose_event;
+ widget_class->draw = gimp_dial_draw;
widget_class->button_press_event = gimp_dial_button_press_event;
widget_class->motion_notify_event = gimp_dial_motion_notify_event;
@@ -234,41 +234,34 @@ gimp_dial_get_property (GObject *object,
}
static gboolean
-gimp_dial_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+gimp_dial_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- GimpDial *dial = GIMP_DIAL (widget);
-
- GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
+ GimpDial *dial = GIMP_DIAL (widget);
+ GtkAllocation allocation;
+ gint size;
- if (gtk_widget_is_drawable (widget))
- {
- GtkAllocation allocation;
- gint size;
- cairo_t *cr;
+ GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
- g_object_get (widget,
- "size", &size,
- NULL);
+ g_object_get (widget,
+ "size", &size,
+ NULL);
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
+ gtk_widget_get_allocation (widget, &allocation);
- gtk_widget_get_allocation (widget, &allocation);
+ cairo_save (cr);
- cairo_translate (cr,
- (gdouble) allocation.x + (allocation.width - size) / 2.0,
- (gdouble) allocation.y + (allocation.height - size) / 2.0);
+ cairo_translate (cr,
+ (allocation.width - size) / 2.0,
+ (allocation.height - size) / 2.0);
- gimp_dial_draw_arrows (cr, size,
- dial->priv->alpha, dial->priv->beta,
- dial->priv->clockwise,
- dial->priv->target,
- dial->priv->draw_beta);
+ gimp_dial_draw_arrows (cr, size,
+ dial->priv->alpha, dial->priv->beta,
+ dial->priv->clockwise,
+ dial->priv->target,
+ dial->priv->draw_beta);
- cairo_destroy (cr);
- }
+ cairo_restore (cr);
return FALSE;
}
diff --git a/app/widgets/gimppolar.c b/app/widgets/gimppolar.c
index 839c65a..1b49541 100644
--- a/app/widgets/gimppolar.c
+++ b/app/widgets/gimppolar.c
@@ -70,8 +70,8 @@ static void gimp_polar_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
-static gboolean gimp_polar_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gimp_polar_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean gimp_polar_button_press_event (GtkWidget *widget,
GdkEventButton *bevent);
static gboolean gimp_polar_motion_notify_event (GtkWidget *widget,
@@ -108,7 +108,7 @@ gimp_polar_class_init (GimpPolarClass *klass)
object_class->get_property = gimp_polar_get_property;
object_class->set_property = gimp_polar_set_property;
- widget_class->expose_event = gimp_polar_expose_event;
+ widget_class->draw = gimp_polar_draw;
widget_class->button_press_event = gimp_polar_button_press_event;
widget_class->motion_notify_event = gimp_polar_motion_notify_event;
@@ -190,39 +190,32 @@ gimp_polar_get_property (GObject *object,
}
static gboolean
-gimp_polar_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+gimp_polar_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- GimpPolar *polar = GIMP_POLAR (widget);
-
- GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
+ GimpPolar *polar = GIMP_POLAR (widget);
+ GtkAllocation allocation;
+ gint size;
- if (gtk_widget_is_drawable (widget))
- {
- GtkAllocation allocation;
- gint size;
- cairo_t *cr;
+ GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
- g_object_get (widget,
- "size", &size,
- NULL);
+ g_object_get (widget,
+ "size", &size,
+ NULL);
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
+ gtk_widget_get_allocation (widget, &allocation);
- gtk_widget_get_allocation (widget, &allocation);
+ cairo_save (cr);
- cairo_translate (cr,
- (gdouble) allocation.x + (allocation.width - size) / 2.0,
- (gdouble) allocation.y + (allocation.height - size) / 2.0);
+ cairo_translate (cr,
+ (allocation.width - size) / 2.0,
+ (allocation.height - size) / 2.0);
- gimp_polar_draw_circle (cr, size,
- polar->priv->angle, polar->priv->radius,
- polar->priv->target);
+ gimp_polar_draw_circle (cr, size,
+ polar->priv->angle, polar->priv->radius,
+ polar->priv->target);
- cairo_destroy (cr);
- }
+ cairo_restore (cr);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]