[gimp/gtk3-port: 119/130] 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: 119/130] libgimpwidgets: port to the new size request API
- Date: Sun, 14 Nov 2010 22:13:14 +0000 (UTC)
commit 433734750cd8b6ac386c925d10ab87633dbbf8d7
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 | 103 ++++++++++++++++++++++++++++----------------
2 files changed, 112 insertions(+), 54 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 108f82f..070d9f8 100644
--- a/libgimpwidgets/gimpruler.c
+++ b/libgimpwidgets/gimpruler.c
@@ -87,34 +87,38 @@ static const struct
};
-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_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_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_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)
@@ -129,16 +133,17 @@ gimp_ruler_class_init (GimpRulerClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->set_property = gimp_ruler_set_property;
- object_class->get_property = gimp_ruler_get_property;
+ 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->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;
+ widget_class->realize = gimp_ruler_realize;
+ widget_class->unrealize = gimp_ruler_unrealize;
+ 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));
@@ -613,6 +618,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]