[gimp/gtk3-port: 88/227] libgimpwidgets: port to the new size request API
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 88/227] libgimpwidgets: port to the new size request API
- Date: Sun, 17 Feb 2013 23:59:47 +0000 (UTC)
commit 335f66bbae9521895eb7b71ff71c49b35c063390
Author: Michael Natterer <mitch gimp org>
Date: Thu Oct 28 13:26:39 2010 +0200
libgimpwidgets: port to the new size request API
libgimpwidgets/gimpframe.c | 63 +++++++++++++++++------
libgimpwidgets/gimpruler.c | 117 +++++++++++++++++++++++++++----------------
2 files changed, 119 insertions(+), 61 deletions(-)
---
diff --git a/libgimpwidgets/gimpframe.c b/libgimpwidgets/gimpframe.c
index 6316892..9d9a88d 100644
--- a/libgimpwidgets/gimpframe.c
+++ b/libgimpwidgets/gimpframe.c
@@ -47,19 +47,23 @@
#define GIMP_FRAME_IN_EXPANDER_KEY "gimp-frame-in-expander"
-static void gimp_frame_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void gimp_frame_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void gimp_frame_style_set (GtkWidget *widget,
- GtkStyle *previous);
-static gboolean gimp_frame_draw (GtkWidget *widget,
- cairo_t *cr);
-static void gimp_frame_child_allocate (GtkFrame *frame,
- GtkAllocation *allocation);
-static void gimp_frame_label_widget_notify (GtkFrame *frame);
-static gint gimp_frame_get_indent (GtkWidget *widget);
-static gint gimp_frame_get_label_spacing (GtkFrame *frame);
+static void gimp_frame_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static void gimp_frame_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
+static void gimp_frame_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+static void gimp_frame_style_set (GtkWidget *widget,
+ GtkStyle *previous);
+static gboolean gimp_frame_draw (GtkWidget *widget,
+ cairo_t *cr);
+static void gimp_frame_child_allocate (GtkFrame *frame,
+ GtkAllocation *allocation);
+static void gimp_frame_label_widget_notify (GtkFrame *frame);
+static gint gimp_frame_get_indent (GtkWidget *widget);
+static gint gimp_frame_get_label_spacing (GtkFrame *frame);
G_DEFINE_TYPE (GimpFrame, gimp_frame, GTK_TYPE_FRAME)
@@ -72,10 +76,11 @@ gimp_frame_class_init (GimpFrameClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->size_request = gimp_frame_size_request;
- widget_class->size_allocate = gimp_frame_size_allocate;
- widget_class->style_set = gimp_frame_style_set;
- widget_class->draw = gimp_frame_draw;
+ widget_class->get_preferred_width = gimp_frame_get_preferred_width;
+ widget_class->get_preferred_height = gimp_frame_get_preferred_height;
+ widget_class->size_allocate = gimp_frame_size_allocate;
+ widget_class->style_set = gimp_frame_style_set;
+ widget_class->draw = gimp_frame_draw;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("label-bold",
@@ -140,6 +145,30 @@ gimp_frame_size_request (GtkWidget *widget,
}
static void
+gimp_frame_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ GtkRequisition requisition;
+
+ gimp_frame_size_request (widget, &requisition);
+
+ *minimum_width = *natural_width = requisition.width;
+}
+
+static void
+gimp_frame_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ GtkRequisition requisition;
+
+ gimp_frame_size_request (widget, &requisition);
+
+ *minimum_height = *natural_height = requisition.height;
+}
+
+static void
gimp_frame_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
diff --git a/libgimpwidgets/gimpruler.c b/libgimpwidgets/gimpruler.c
index 9403523..f4fc69a 100644
--- a/libgimpwidgets/gimpruler.c
+++ b/libgimpwidgets/gimpruler.c
@@ -93,37 +93,41 @@ static const struct
};
-static void gimp_ruler_dispose (GObject *object);
-static void gimp_ruler_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_ruler_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gimp_ruler_realize (GtkWidget *widget);
-static void gimp_ruler_unrealize (GtkWidget *widget);
-static void gimp_ruler_map (GtkWidget *widget);
-static void gimp_ruler_unmap (GtkWidget *widget);
-static void gimp_ruler_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void gimp_ruler_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void gimp_ruler_style_set (GtkWidget *widget,
- GtkStyle *prev_style);
-static gboolean gimp_ruler_motion_notify (GtkWidget *widget,
- GdkEventMotion *event);
-static gboolean gimp_ruler_draw (GtkWidget *widget,
- cairo_t *cr);
-
-static void gimp_ruler_draw_ticks (GimpRuler *ruler);
-static void gimp_ruler_draw_pos (GimpRuler *ruler);
-static void gimp_ruler_make_pixmap (GimpRuler *ruler);
-
-static PangoLayout * gimp_ruler_get_layout (GtkWidget *widget,
- const gchar *text);
+static void gimp_ruler_dispose (GObject *object);
+static void gimp_ruler_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_ruler_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void gimp_ruler_realize (GtkWidget *widget);
+static void gimp_ruler_unrealize (GtkWidget *widget);
+static void gimp_ruler_map (GtkWidget *widget);
+static void gimp_ruler_unmap (GtkWidget *widget);
+static void gimp_ruler_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+static void gimp_ruler_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static void gimp_ruler_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
+static void gimp_ruler_style_set (GtkWidget *widget,
+ GtkStyle *prev_style);
+static gboolean gimp_ruler_motion_notify (GtkWidget *widget,
+ GdkEventMotion *event);
+static gboolean gimp_ruler_draw (GtkWidget *widget,
+ cairo_t *cr);
+
+static void gimp_ruler_draw_ticks (GimpRuler *ruler);
+static void gimp_ruler_draw_pos (GimpRuler *ruler);
+static void gimp_ruler_make_pixmap (GimpRuler *ruler);
+
+static PangoLayout * gimp_ruler_get_layout (GtkWidget *widget,
+ const gchar *text);
G_DEFINE_TYPE (GimpRuler, gimp_ruler, GTK_TYPE_WIDGET)
@@ -137,19 +141,20 @@ gimp_ruler_class_init (GimpRulerClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->dispose = gimp_ruler_dispose;
- object_class->set_property = gimp_ruler_set_property;
- object_class->get_property = gimp_ruler_get_property;
-
- widget_class->realize = gimp_ruler_realize;
- widget_class->unrealize = gimp_ruler_unrealize;
- widget_class->map = gimp_ruler_map;
- widget_class->unmap = gimp_ruler_unmap;
- widget_class->size_allocate = gimp_ruler_size_allocate;
- widget_class->size_request = gimp_ruler_size_request;
- widget_class->style_set = gimp_ruler_style_set;
- widget_class->motion_notify_event = gimp_ruler_motion_notify;
- widget_class->draw = gimp_ruler_draw;
+ object_class->dispose = gimp_ruler_dispose;
+ object_class->set_property = gimp_ruler_set_property;
+ object_class->get_property = gimp_ruler_get_property;
+
+ widget_class->realize = gimp_ruler_realize;
+ widget_class->unrealize = gimp_ruler_unrealize;
+ widget_class->map = gimp_ruler_map;
+ widget_class->unmap = gimp_ruler_unmap;
+ widget_class->get_preferred_width = gimp_ruler_get_preferred_width;
+ widget_class->get_preferred_height = gimp_ruler_get_preferred_height;
+ widget_class->size_allocate = gimp_ruler_size_allocate;
+ widget_class->style_set = gimp_ruler_style_set;
+ widget_class->motion_notify_event = gimp_ruler_motion_notify;
+ widget_class->draw = gimp_ruler_draw;
g_type_class_add_private (object_class, sizeof (GimpRulerPrivate));
@@ -850,6 +855,30 @@ gimp_ruler_size_request (GtkWidget *widget,
}
static void
+gimp_ruler_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ GtkRequisition requisition;
+
+ gimp_ruler_size_request (widget, &requisition);
+
+ *minimum_width = *natural_width = requisition.width;
+}
+
+static void
+gimp_ruler_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ GtkRequisition requisition;
+
+ gimp_ruler_size_request (widget, &requisition);
+
+ *minimum_height = *natural_height = requisition.height;
+}
+
+static void
gimp_ruler_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]