[gimp/gtk3-port: 85/233] app: port to the new size request API



commit 42c41854c2a637e5cbe1eb3573ecb331f3ff201a
Author: Michael Natterer <mitch gimp org>
Date:   Thu Oct 28 13:27:46 2010 +0200

    app: port to the new size request API

 app/widgets/gimpdasheditor.c    |   79 ++++++++++-------
 app/widgets/gimpdockable.c      |  180 +++++++++++++++++++++------------------
 app/widgets/gimphistogramview.c |   65 +++++++++------
 app/widgets/gimpmessagebox.c    |  154 +++++++++++++++++++--------------
 app/widgets/gimpoverlaydialog.c |  106 ++++++++++++++---------
 app/widgets/gimpoverlayframe.c  |   77 ++++++++++-------
 app/widgets/gimpview.c          |   43 +++++++---
 7 files changed, 417 insertions(+), 287 deletions(-)
---
diff --git a/app/widgets/gimpdasheditor.c b/app/widgets/gimpdasheditor.c
index 15d0c49..aa2345f 100644
--- a/app/widgets/gimpdasheditor.c
+++ b/app/widgets/gimpdasheditor.c
@@ -49,33 +49,37 @@ enum
 };
 
 
-static void gimp_dash_editor_finalize           (GObject        *object);
-static void gimp_dash_editor_set_property       (GObject        *object,
-                                                 guint           property_id,
-                                                 const GValue   *value,
-                                                 GParamSpec     *pspec);
-static void gimp_dash_editor_get_property       (GObject        *object,
-                                                 guint           property_id,
-                                                 GValue         *value,
-                                                 GParamSpec     *pspec);
-
-static void gimp_dash_editor_size_request       (GtkWidget      *widget,
-                                                 GtkRequisition *requisition);
-static gboolean gimp_dash_editor_draw           (GtkWidget      *widget,
-                                                 cairo_t        *cr);
-static gboolean gimp_dash_editor_button_press   (GtkWidget      *widget,
-                                                 GdkEventButton *bevent);
-static gboolean gimp_dash_editor_button_release (GtkWidget      *widget,
-                                                 GdkEventButton *bevent);
-static gboolean gimp_dash_editor_motion_notify  (GtkWidget      *widget,
-                                                 GdkEventMotion *bevent);
+static void     gimp_dash_editor_finalize             (GObject        *object);
+static void     gimp_dash_editor_set_property         (GObject        *object,
+                                                       guint           property_id,
+                                                       const GValue   *value,
+                                                       GParamSpec     *pspec);
+static void     gimp_dash_editor_get_property         (GObject        *object,
+                                                       guint           property_id,
+                                                       GValue         *value,
+                                                       GParamSpec     *pspec);
+
+static void     gimp_dash_editor_get_preferred_width  (GtkWidget      *widget,
+                                                       gint           *minimum_width,
+                                                       gint           *natural_width);
+static void     gimp_dash_editor_get_preferred_height (GtkWidget      *widget,
+                                                       gint           *minimum_height,
+                                                       gint           *natural_height);
+static gboolean gimp_dash_editor_draw                 (GtkWidget      *widget,
+                                                       cairo_t        *cr);
+static gboolean gimp_dash_editor_button_press         (GtkWidget      *widget,
+                                                       GdkEventButton *bevent);
+static gboolean gimp_dash_editor_button_release       (GtkWidget      *widget,
+                                                       GdkEventButton *bevent);
+static gboolean gimp_dash_editor_motion_notify        (GtkWidget      *widget,
+                                                       GdkEventMotion *bevent);
 
 /* helper function */
-static void update_segments_from_options        (GimpDashEditor *editor);
-static void update_options_from_segments        (GimpDashEditor *editor);
-static void update_blocksize                    (GimpDashEditor *editor);
-static gint dash_x_to_index                     (GimpDashEditor *editor,
-                                                 gint            x);
+static void     update_segments_from_options          (GimpDashEditor *editor);
+static void     update_options_from_segments          (GimpDashEditor *editor);
+static void     update_blocksize                      (GimpDashEditor *editor);
+static gint     dash_x_to_index                       (GimpDashEditor *editor,
+                                                       gint            x);
 
 
 G_DEFINE_TYPE (GimpDashEditor, gimp_dash_editor, GTK_TYPE_DRAWING_AREA)
@@ -93,7 +97,8 @@ gimp_dash_editor_class_init (GimpDashEditorClass *klass)
   object_class->get_property = gimp_dash_editor_get_property;
   object_class->set_property = gimp_dash_editor_set_property;
 
-  widget_class->size_request         = gimp_dash_editor_size_request;
+  widget_class->get_preferred_width  = gimp_dash_editor_get_preferred_width;
+  widget_class->get_preferred_height = gimp_dash_editor_get_preferred_height;
   widget_class->draw                 = gimp_dash_editor_draw;
   widget_class->button_press_event   = gimp_dash_editor_button_press;
   widget_class->button_release_event = gimp_dash_editor_button_release;
@@ -214,14 +219,26 @@ gimp_dash_editor_get_property (GObject      *object,
 }
 
 static void
-gimp_dash_editor_size_request (GtkWidget      *widget,
-                               GtkRequisition *requisition)
+gimp_dash_editor_get_preferred_width (GtkWidget *widget,
+                                      gint      *minimum_width,
+                                      gint      *natural_width)
 {
   GimpDashEditor *editor = GIMP_DASH_EDITOR (widget);
 
-  requisition->width  = MAX (editor->block_width * editor->n_segments + 20,
-                             MIN_WIDTH);
-  requisition->height = MAX (editor->block_height + 10, MIN_HEIGHT);
+  *minimum_width = *natural_width = MAX (editor->block_width *
+                                         editor->n_segments + 20,
+                                         MIN_WIDTH);
+}
+
+static void
+gimp_dash_editor_get_preferred_height (GtkWidget *widget,
+                                       gint      *minimum_height,
+                                       gint      *natural_height)
+{
+  GimpDashEditor *editor = GIMP_DASH_EDITOR (widget);
+
+  *minimum_height = *natural_height = MAX (editor->block_height + 10,
+                                           MIN_HEIGHT);
 }
 
 static gboolean
diff --git a/app/widgets/gimpdockable.c b/app/widgets/gimpdockable.c
index 122f85d..373f830 100644
--- a/app/widgets/gimpdockable.c
+++ b/app/widgets/gimpdockable.c
@@ -78,51 +78,54 @@ struct _GimpDockablePrivate
 
 
 static void       gimp_dockable_session_managed_iface_init
-                                                  (GimpSessionManagedInterface
-                                                                  *iface);
-static void       gimp_dockable_dispose           (GObject        *object);
-static void       gimp_dockable_set_property      (GObject        *object,
-                                                   guint           property_id,
-                                                   const GValue   *value,
-                                                   GParamSpec     *pspec);
-static void       gimp_dockable_get_property      (GObject        *object,
-                                                   guint           property_id,
-                                                   GValue         *value,
-                                                   GParamSpec     *pspec);
-
-static void       gimp_dockable_size_request      (GtkWidget      *widget,
-                                                   GtkRequisition *requisition);
-static void       gimp_dockable_size_allocate     (GtkWidget      *widget,
-                                                   GtkAllocation  *allocation);
-static void       gimp_dockable_drag_leave        (GtkWidget      *widget,
-                                                   GdkDragContext *context,
-                                                   guint           time);
-static gboolean   gimp_dockable_drag_motion       (GtkWidget      *widget,
-                                                   GdkDragContext *context,
-                                                   gint            x,
-                                                   gint            y,
-                                                   guint           time);
-static gboolean   gimp_dockable_drag_drop         (GtkWidget      *widget,
-                                                   GdkDragContext *context,
-                                                   gint            x,
-                                                   gint            y,
-                                                   guint           time);
-
-static void       gimp_dockable_style_set         (GtkWidget      *widget,
-                                                   GtkStyle       *prev_style);
-
-static void       gimp_dockable_add               (GtkContainer   *container,
-                                                   GtkWidget      *widget);
-static GType      gimp_dockable_child_type        (GtkContainer   *container);
-static GList    * gimp_dockable_get_aux_info      (GimpSessionManaged
-                                                                  *session_managed);
-static void       gimp_dockable_set_aux_info      (GimpSessionManaged
-                                                                  *session_managed,
-                                                   GList          *aux_info);
-
+                                                     (GimpSessionManagedInterface
+                                                                     *iface);
+static void       gimp_dockable_dispose              (GObject        *object);
+static void       gimp_dockable_set_property         (GObject        *object,
+                                                      guint           property_id,
+                                                      const GValue   *value,
+                                                      GParamSpec     *pspec);
+static void       gimp_dockable_get_property         (GObject        *object,
+                                                      guint           property_id,
+                                                      GValue         *value,
+                                                      GParamSpec     *pspec);
+
+static void       gimp_dockable_get_preferred_width  (GtkWidget      *widget,
+                                                      gint           *minimum_width,
+                                                      gint           *natural_width);
+static void       gimp_dockable_get_preferred_height (GtkWidget      *widget,
+                                                      gint           *minimum_height,
+                                                      gint           *natural_height);
+static void       gimp_dockable_size_allocate        (GtkWidget      *widget,
+                                                      GtkAllocation  *allocation);
+static void       gimp_dockable_drag_leave           (GtkWidget      *widget,
+                                                      GdkDragContext *context,
+                                                      guint           time);
+static gboolean   gimp_dockable_drag_motion          (GtkWidget      *widget,
+                                                      GdkDragContext *context,
+                                                      gint            x,
+                                                      gint            y,
+                                                      guint           time);
+static gboolean   gimp_dockable_drag_drop            (GtkWidget      *widget,
+                                                      GdkDragContext *context,
+                                                      gint            x,
+                                                      gint            y,
+                                                      guint           time);
+
+static void       gimp_dockable_style_set            (GtkWidget      *widget,
+                                                      GtkStyle       *prev_style);
+
+static void       gimp_dockable_add                  (GtkContainer   *container,
+                                                      GtkWidget      *widget);
+static GType      gimp_dockable_child_type           (GtkContainer   *container);
+static GList    * gimp_dockable_get_aux_info         (GimpSessionManaged
+                                                                     *session_managed);
+static void       gimp_dockable_set_aux_info         (GimpSessionManaged
+                                                                     *session_managed,
+                                                      GList          *aux_info);
 static GimpTabStyle
-                  gimp_dockable_convert_tab_style (GimpDockable   *dockable,
-                                                   GimpTabStyle    tab_style);
+                  gimp_dockable_convert_tab_style    (GimpDockable   *dockable,
+                                                      GimpTabStyle    tab_style);
 
 
 G_DEFINE_TYPE_WITH_CODE (GimpDockable, gimp_dockable, GTK_TYPE_BIN,
@@ -141,19 +144,22 @@ gimp_dockable_class_init (GimpDockableClass *klass)
   GtkWidgetClass    *widget_class    = GTK_WIDGET_CLASS (klass);
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
 
-  object_class->dispose       = gimp_dockable_dispose;
-  object_class->set_property  = gimp_dockable_set_property;
-  object_class->get_property  = gimp_dockable_get_property;
+  object_class->dispose              = gimp_dockable_dispose;
+  object_class->set_property         = gimp_dockable_set_property;
+  object_class->get_property         = gimp_dockable_get_property;
+
+  widget_class->get_preferred_width  = gimp_dockable_get_preferred_width;
+  widget_class->get_preferred_height = gimp_dockable_get_preferred_height;
+  widget_class->size_allocate        = gimp_dockable_size_allocate;
+  widget_class->style_set            = gimp_dockable_style_set;
+  widget_class->drag_leave           = gimp_dockable_drag_leave;
+  widget_class->drag_motion          = gimp_dockable_drag_motion;
+  widget_class->drag_drop            = gimp_dockable_drag_drop;
 
-  widget_class->size_request  = gimp_dockable_size_request;
-  widget_class->size_allocate = gimp_dockable_size_allocate;
-  widget_class->style_set     = gimp_dockable_style_set;
-  widget_class->drag_leave    = gimp_dockable_drag_leave;
-  widget_class->drag_motion   = gimp_dockable_drag_motion;
-  widget_class->drag_drop     = gimp_dockable_drag_drop;
+  container_class->add               = gimp_dockable_add;
+  container_class->child_type        = gimp_dockable_child_type;
 
-  container_class->add        = gimp_dockable_add;
-  container_class->child_type = gimp_dockable_child_type;
+  gtk_container_class_handle_border_width (container_class);
 
   g_object_class_install_property (object_class, PROP_LOCKED,
                                    g_param_spec_boolean ("locked", NULL, NULL,
@@ -274,18 +280,15 @@ static void
 gimp_dockable_size_request (GtkWidget      *widget,
                             GtkRequisition *requisition)
 {
-  GtkContainer   *container = GTK_CONTAINER (widget);
-  GtkWidget      *child     = gtk_bin_get_child (GTK_BIN (widget));
-  GtkRequisition  child_requisition;
-  gint            border_width;
-
-  border_width = gtk_container_get_border_width (container);
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
 
-  requisition->width  = border_width * 2;
-  requisition->height = border_width * 2;
+  requisition->width  = 0;
+  requisition->height = 0;
 
   if (child && gtk_widget_get_visible (child))
     {
+      GtkRequisition child_requisition;
+
       gtk_widget_get_preferred_size (child, &child_requisition, NULL);
 
       requisition->width  += child_requisition.width;
@@ -294,34 +297,45 @@ gimp_dockable_size_request (GtkWidget      *widget,
 }
 
 static void
-gimp_dockable_size_allocate (GtkWidget     *widget,
-                             GtkAllocation *allocation)
+gimp_dockable_get_preferred_width (GtkWidget *widget,
+                                   gint      *minimum_width,
+                                   gint      *natural_width)
 {
-  GtkContainer   *container = GTK_CONTAINER (widget);
-  GtkWidget      *child     = gtk_bin_get_child (GTK_BIN (widget));
+  GtkRequisition requisition;
 
-  GtkRequisition  button_requisition = { 0, };
-  GtkAllocation   child_allocation;
-  gint            border_width;
+  gimp_dockable_size_request (widget, &requisition);
 
+  *minimum_width = *natural_width = requisition.width;
+}
 
-  gtk_widget_set_allocation (widget, allocation);
+static void
+gimp_dockable_get_preferred_height (GtkWidget *widget,
+                                    gint      *minimum_height,
+                                    gint      *natural_height)
+{
+  GtkRequisition requisition;
 
-  border_width = gtk_container_get_border_width (container);
+  gimp_dockable_size_request (widget, &requisition);
+
+  *minimum_height = *natural_height = requisition.height;
+}
+
+static void
+gimp_dockable_size_allocate (GtkWidget     *widget,
+                             GtkAllocation *allocation)
+{
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
+
+  gtk_widget_set_allocation (widget, allocation);
 
   if (child && gtk_widget_get_visible (child))
     {
-      child_allocation.x      = allocation->x + border_width;
-      child_allocation.y      = allocation->y + border_width;
-      child_allocation.width  = MAX (allocation->width  -
-                                     border_width * 2,
-                                     0);
-      child_allocation.height = MAX (allocation->height -
-                                     border_width * 2 -
-                                     button_requisition.height,
-                                     0);
-
-      child_allocation.y += button_requisition.height;
+      GtkAllocation child_allocation;
+
+      child_allocation.x      = allocation->x;
+      child_allocation.y      = allocation->y;
+      child_allocation.width  = allocation->width;
+      child_allocation.height = allocation->height;
 
       gtk_widget_size_allocate (child, &child_allocation);
     }
diff --git a/app/widgets/gimphistogramview.c b/app/widgets/gimphistogramview.c
index 9adff0d..95a4e80 100644
--- a/app/widgets/gimphistogramview.c
+++ b/app/widgets/gimphistogramview.c
@@ -51,26 +51,30 @@ enum
 };
 
 
-static void     gimp_histogram_view_dispose        (GObject        *object);
-static void     gimp_histogram_view_set_property   (GObject        *object,
-                                                    guint           property_id,
-                                                    const GValue   *value,
-                                                    GParamSpec     *pspec);
-static void     gimp_histogram_view_get_property   (GObject        *object,
-                                                    guint           property_id,
-                                                    GValue         *value,
-                                                    GParamSpec     *pspec);
-
-static void     gimp_histogram_view_size_request   (GtkWidget      *widget,
-                                                    GtkRequisition *requisition);
-static gboolean gimp_histogram_view_draw           (GtkWidget      *widget,
-                                                    cairo_t        *cr);
-static gboolean gimp_histogram_view_button_press   (GtkWidget      *widget,
-                                                    GdkEventButton *bevent);
-static gboolean gimp_histogram_view_button_release (GtkWidget      *widget,
-                                                    GdkEventButton *bevent);
-static gboolean gimp_histogram_view_motion_notify  (GtkWidget      *widget,
-                                                    GdkEventMotion *bevent);
+static void     gimp_histogram_view_dispose              (GObject        *object);
+static void     gimp_histogram_view_set_property         (GObject        *object,
+                                                          guint           property_id,
+                                                          const GValue   *value,
+                                                          GParamSpec     *pspec);
+static void     gimp_histogram_view_get_property         (GObject        *object,
+                                                          guint           property_id,
+                                                          GValue         *value,
+                                                          GParamSpec     *pspec);
+
+static void     gimp_histogram_view_get_preferred_width  (GtkWidget      *widget,
+                                                          gint           *minimum_width,
+                                                          gint           *natural_width);
+static void     gimp_histogram_view_get_preferred_height (GtkWidget      *widget,
+                                                          gint           *minimum_height,
+                                                          gint           *natural_height);
+static gboolean gimp_histogram_view_draw                 (GtkWidget      *widget,
+                                                          cairo_t        *cr);
+static gboolean gimp_histogram_view_button_press         (GtkWidget      *widget,
+                                                          GdkEventButton *bevent);
+static gboolean gimp_histogram_view_button_release       (GtkWidget      *widget,
+                                                          GdkEventButton *bevent);
+static gboolean gimp_histogram_view_motion_notify        (GtkWidget      *widget,
+                                                          GdkEventMotion *bevent);
 
 static void     gimp_histogram_view_notify      (GimpHistogram        *histogram,
                                                  const GParamSpec     *pspec,
@@ -121,7 +125,8 @@ gimp_histogram_view_class_init (GimpHistogramViewClass *klass)
   object_class->get_property         = gimp_histogram_view_get_property;
   object_class->set_property         = gimp_histogram_view_set_property;
 
-  widget_class->size_request         = gimp_histogram_view_size_request;
+  widget_class->get_preferred_width  = gimp_histogram_view_get_preferred_width;
+  widget_class->get_preferred_height = gimp_histogram_view_get_preferred_height;
   widget_class->draw                 = gimp_histogram_view_draw;
   widget_class->button_press_event   = gimp_histogram_view_button_press;
   widget_class->button_release_event = gimp_histogram_view_button_release;
@@ -243,13 +248,23 @@ gimp_histogram_view_get_property (GObject      *object,
 }
 
 static void
-gimp_histogram_view_size_request (GtkWidget      *widget,
-                                  GtkRequisition *requisition)
+gimp_histogram_view_get_preferred_width (GtkWidget *widget,
+                                         gint      *minimum_width,
+                                         gint      *natural_width)
 {
   GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget);
 
-  requisition->width  = MIN_WIDTH  + 2 * view->border_width;
-  requisition->height = MIN_HEIGHT + 2 * view->border_width;
+  *minimum_width = *natural_width = MIN_WIDTH + 2 * view->border_width;
+}
+
+static void
+gimp_histogram_view_get_preferred_height (GtkWidget *widget,
+                                          gint      *minimum_height,
+                                          gint      *natural_height)
+{
+  GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget);
+
+  *minimum_height = *natural_height = MIN_HEIGHT + 2 * view->border_width;
 }
 
 static gdouble
diff --git a/app/widgets/gimpmessagebox.c b/app/widgets/gimpmessagebox.c
index 1ee4f7a..5ff6c50 100644
--- a/app/widgets/gimpmessagebox.c
+++ b/app/widgets/gimpmessagebox.c
@@ -42,36 +42,39 @@ enum
 };
 
 
-static void   gimp_message_box_constructed      (GObject        *object);
-static void   gimp_message_box_dispose          (GObject        *object);
-static void   gimp_message_box_finalize         (GObject        *object);
-static void   gimp_message_box_set_property     (GObject        *object,
-                                                 guint           property_id,
-                                                 const GValue   *value,
-                                                 GParamSpec     *pspec);
-static void   gimp_message_box_get_property     (GObject        *object,
-                                                 guint           property_id,
-                                                 GValue         *value,
-                                                 GParamSpec     *pspec);
-
-static void   gimp_message_box_forall           (GtkContainer   *container,
-                                                 gboolean        include_internals,
-                                                 GtkCallback     callback,
-                                                 gpointer        callback_data);
-
-static void   gimp_message_box_size_request     (GtkWidget      *widget,
-                                                 GtkRequisition *requisition);
-static void   gimp_message_box_size_allocate    (GtkWidget      *widget,
-                                                 GtkAllocation  *allocation);
-
-static void   gimp_message_box_set_label_text   (GimpMessageBox *box,
-                                                 gint            n,
-                                                 const gchar    *format,
-                                                 va_list         args) G_GNUC_PRINTF (3, 0);
-static void   gimp_message_box_set_label_markup (GimpMessageBox *box,
-                                                 gint            n,
-                                                 const gchar    *format,
-                                                 va_list         args) G_GNUC_PRINTF (3, 0);
+static void   gimp_message_box_constructed          (GObject        *object);
+static void   gimp_message_box_dispose              (GObject        *object);
+static void   gimp_message_box_finalize             (GObject        *object);
+static void   gimp_message_box_set_property         (GObject        *object,
+                                                     guint           property_id,
+                                                     const GValue   *value,
+                                                     GParamSpec     *pspec);
+static void   gimp_message_box_get_property         (GObject        *object,
+                                                     guint           property_id,
+                                                     GValue         *value,
+                                                     GParamSpec     *pspec);
+
+static void   gimp_message_box_get_preferred_width  (GtkWidget      *widget,
+                                                     gint           *minimum_width,
+                                                     gint           *natural_width);
+static void   gimp_message_box_get_preferred_height (GtkWidget      *widget,
+                                                     gint           *minimum_height,
+                                                     gint           *natural_height);
+static void   gimp_message_box_size_allocate        (GtkWidget      *widget,
+                                                     GtkAllocation  *allocation);
+
+static void   gimp_message_box_forall               (GtkContainer   *container,
+                                                     gboolean        include_internals,
+                                                     GtkCallback     callback,
+                                                     gpointer        callback_data);
+static void   gimp_message_box_set_label_text       (GimpMessageBox *box,
+                                                     gint            n,
+                                                     const gchar    *format,
+                                                     va_list         args) G_GNUC_PRINTF (3, 0);
+static void   gimp_message_box_set_label_markup     (GimpMessageBox *box,
+                                                     gint            n,
+                                                     const gchar    *format,
+                                                     va_list         args) G_GNUC_PRINTF (3, 0);
 
 static gboolean gimp_message_box_update         (gpointer        data);
 
@@ -87,17 +90,19 @@ gimp_message_box_class_init (GimpMessageBoxClass *klass)
   GtkWidgetClass    *widget_class    = GTK_WIDGET_CLASS (klass);
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
 
-  object_class->constructed   = gimp_message_box_constructed;
-  object_class->dispose       = gimp_message_box_dispose;
-  object_class->finalize      = gimp_message_box_finalize;
-  object_class->set_property  = gimp_message_box_set_property;
-  object_class->get_property  = gimp_message_box_get_property;
+  object_class->constructed          = gimp_message_box_constructed;
+  object_class->dispose              = gimp_message_box_dispose;
+  object_class->finalize             = gimp_message_box_finalize;
+  object_class->set_property         = gimp_message_box_set_property;
+  object_class->get_property         = gimp_message_box_get_property;
 
+  widget_class->get_preferred_width  = gimp_message_box_get_preferred_width;
+  widget_class->get_preferred_height = gimp_message_box_get_preferred_height;
+  widget_class->size_allocate        = gimp_message_box_size_allocate;
 
-  widget_class->size_request  = gimp_message_box_size_request;
-  widget_class->size_allocate = gimp_message_box_size_allocate;
+  container_class->forall            = gimp_message_box_forall;
 
-  container_class->forall     = gimp_message_box_forall;
+  gtk_container_class_handle_border_width (container_class);
 
   g_object_class_install_property (object_class, PROP_ICON_NAME,
                                    g_param_spec_string ("icon-name", NULL, NULL,
@@ -239,26 +244,50 @@ gimp_message_box_get_property (GObject    *object,
 }
 
 static void
-gimp_message_box_size_request (GtkWidget      *widget,
-                               GtkRequisition *requisition)
+gimp_message_box_get_preferred_width (GtkWidget *widget,
+                                      gint      *minimum_width,
+                                      gint      *natural_width)
 {
   GimpMessageBox *box = GIMP_MESSAGE_BOX (widget);
 
-  GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
+  GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget,
+                                                        minimum_width,
+                                                        natural_width);
 
   if (box->image && gtk_widget_get_visible (box->image))
     {
-      GtkRequisition  child_requisition;
-      gint            border_width;
+      gint image_minimum;
+      gint image_natural;
 
-      gtk_widget_get_preferred_size (box->image, &child_requisition, NULL);
+      gtk_widget_get_preferred_width (box->image,
+                                      &image_minimum, &image_natural);
+
+      *minimum_width += image_minimum + GIMP_MESSAGE_BOX_SPACING;
+      *natural_width += image_natural + GIMP_MESSAGE_BOX_SPACING;
+    }
+}
 
-      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+static void
+gimp_message_box_get_preferred_height (GtkWidget *widget,
+                                       gint      *minimum_height,
+                                       gint      *natural_height)
+{
+  GimpMessageBox *box = GIMP_MESSAGE_BOX (widget);
 
-      requisition->width  += child_requisition.width + GIMP_MESSAGE_BOX_SPACING;
-      requisition->height = MAX (requisition->height,
-                                 child_requisition.height +
-                                 2 * border_width);
+  GTK_WIDGET_CLASS (parent_class)->get_preferred_height (widget,
+                                                         minimum_height,
+                                                         natural_height);
+
+  if (box->image && gtk_widget_get_visible (box->image))
+    {
+      gint image_minimum;
+      gint image_natural;
+
+      gtk_widget_get_preferred_height (box->image,
+                                       &image_minimum, &image_natural);
+
+      *minimum_height = MAX (*minimum_height, image_minimum);
+      *natural_height = MAX (*natural_height, image_natural);
     }
 }
 
@@ -266,39 +295,32 @@ static void
 gimp_message_box_size_allocate (GtkWidget     *widget,
                                 GtkAllocation *allocation)
 {
-  GimpMessageBox *box       = GIMP_MESSAGE_BOX (widget);
-  GtkContainer   *container = GTK_CONTAINER (widget);
-  gint            width     = 0;
+  GimpMessageBox *box   = GIMP_MESSAGE_BOX (widget);
+  gint            width = 0;
   gboolean        rtl;
 
   rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
 
   if (box->image && gtk_widget_get_visible (box->image))
     {
-      GtkRequisition  child_requisition;
-      GtkAllocation   child_allocation;
-      gint            border_width;
-      gint            height;
+      GtkRequisition child_requisition;
+      GtkAllocation  child_allocation;
+      gint           height;
 
       gtk_widget_get_preferred_size (box->image, &child_requisition, NULL);
 
-      border_width = gtk_container_get_border_width (container);
-
-      width  = MIN (allocation->width - 2 * border_width,
+      width  = MIN (allocation->width,
                     child_requisition.width + GIMP_MESSAGE_BOX_SPACING);
       width  = MAX (1, width);
 
-      height = allocation->height - 2 * border_width;
-      height = MAX (1, height);
+      height = allocation->height;
 
       if (rtl)
-        child_allocation.x  = (allocation->width -
-                               border_width      -
-                               child_requisition.width);
+        child_allocation.x = allocation->width - child_requisition.width;
       else
-        child_allocation.x  = allocation->x + border_width;
+        child_allocation.x = allocation->x;
 
-      child_allocation.y      = allocation->y + border_width;
+      child_allocation.y      = allocation->y;
       child_allocation.width  = width;
       child_allocation.height = height;
 
diff --git a/app/widgets/gimpoverlaydialog.c b/app/widgets/gimpoverlaydialog.c
index 9bacc5f..7d03620 100644
--- a/app/widgets/gimpoverlaydialog.c
+++ b/app/widgets/gimpoverlaydialog.c
@@ -72,15 +72,19 @@ static void       gimp_overlay_dialog_get_property  (GObject           *object,
                                                      GValue            *value,
                                                      GParamSpec        *pspec);
 
-static void       gimp_overlay_dialog_size_request  (GtkWidget         *widget,
-                                                     GtkRequisition    *requisition);
-static void       gimp_overlay_dialog_size_allocate (GtkWidget         *widget,
-                                                     GtkAllocation     *allocation);
-
-static void       gimp_overlay_dialog_forall        (GtkContainer      *container,
-                                                     gboolean           include_internals,
-                                                     GtkCallback        callback,
-                                                     gpointer           callback_data);
+static void       gimp_overlay_dialog_get_preferred_width  (GtkWidget     *widget,
+                                                            gint          *minimum_width,
+                                                            gint          *natural_width);
+static void       gimp_overlay_dialog_get_preferred_height (GtkWidget     *widget,
+                                                            gint          *minimum_height,
+                                                            gint          *natural_height);
+static void       gimp_overlay_dialog_size_allocate        (GtkWidget         *widget,
+                                                            GtkAllocation     *allocation);
+
+static void       gimp_overlay_dialog_forall               (GtkContainer      *container,
+                                                            gboolean           include_internals,
+                                                            GtkCallback        callback,
+                                                            gpointer           callback_data);
 
 static void       gimp_overlay_dialog_detach        (GimpOverlayDialog *dialog);
 static void       gimp_overlay_dialog_real_detach   (GimpOverlayDialog *dialog);
@@ -88,8 +92,8 @@ static void       gimp_overlay_dialog_real_detach   (GimpOverlayDialog *dialog);
 static void       gimp_overlay_dialog_close         (GimpOverlayDialog *dialog);
 static void       gimp_overlay_dialog_real_close    (GimpOverlayDialog *dialog);
 
-static ResponseData * get_response_data             (GtkWidget         *widget,
-                                                     gboolean          create);
+static ResponseData * get_response_data                    (GtkWidget         *widget,
+                                                            gboolean          create);
 
 
 G_DEFINE_TYPE (GimpOverlayDialog, gimp_overlay_dialog,
@@ -113,10 +117,11 @@ gimp_overlay_dialog_class_init (GimpOverlayDialogClass *klass)
   object_class->get_property  = gimp_overlay_dialog_get_property;
   object_class->set_property  = gimp_overlay_dialog_set_property;
 
-  widget_class->size_request  = gimp_overlay_dialog_size_request;
-  widget_class->size_allocate = gimp_overlay_dialog_size_allocate;
+  widget_class->get_preferred_width  = gimp_overlay_dialog_get_preferred_width;
+  widget_class->get_preferred_height = gimp_overlay_dialog_get_preferred_height;
+  widget_class->size_allocate        = gimp_overlay_dialog_size_allocate;
 
-  container_class->forall     = gimp_overlay_dialog_forall;
+  container_class->forall            = gimp_overlay_dialog_forall;
 
   klass->detach               = gimp_overlay_dialog_real_detach;
   klass->close                = gimp_overlay_dialog_real_close;
@@ -336,42 +341,61 @@ gimp_overlay_dialog_get_property (GObject    *object,
 }
 
 static void
-gimp_overlay_dialog_size_request (GtkWidget      *widget,
-                                  GtkRequisition *requisition)
+gimp_overlay_dialog_get_preferred_width (GtkWidget *widget,
+                                         gint      *minimum_width,
+                                         gint      *natural_width)
 {
-  GtkContainer      *container = GTK_CONTAINER (widget);
-  GimpOverlayDialog *dialog    = GIMP_OVERLAY_DIALOG (widget);
-  GtkWidget         *child     = gtk_bin_get_child (GTK_BIN (widget));
-  GtkRequisition     child_requisition;
-  GtkRequisition     header_requisition;
-  GtkRequisition     action_requisition;
+  GimpOverlayDialog *dialog = GIMP_OVERLAY_DIALOG (widget);
+  GtkWidget         *child  = gtk_bin_get_child (GTK_BIN (widget));
   gint               border_width;
+  gint               header_minimum;
+  gint               header_natural;
+  gint               action_minimum;
+  gint               action_natural;
 
-  border_width = gtk_container_get_border_width (container);
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+  if (child && gtk_widget_get_visible (child))
+    gtk_widget_get_preferred_width (child, minimum_width, natural_width);
+  else
+    *minimum_width = *natural_width = 0;
+
+  gtk_widget_get_preferred_width (dialog->header,
+                                  &header_minimum, &header_natural);
+  gtk_widget_get_preferred_width (dialog->action_area,
+                                  &action_minimum, &action_natural);
 
-  requisition->width  = border_width * 2;
-  requisition->height = border_width * 2;
+  *minimum_width = MAX (MAX (*minimum_width, action_minimum), header_minimum) + 2 * border_width;
+  *natural_width = MAX (MAX (*natural_width, action_natural), header_natural) + 2 * border_width;
+}
+
+static void
+gimp_overlay_dialog_get_preferred_height (GtkWidget *widget,
+                                          gint      *minimum_height,
+                                          gint      *natural_height)
+{
+  GimpOverlayDialog *dialog = GIMP_OVERLAY_DIALOG (widget);
+  GtkWidget         *child  = gtk_bin_get_child (GTK_BIN (widget));
+  gint               border_width;
+  gint               header_minimum;
+  gint               header_natural;
+  gint               action_minimum;
+  gint               action_natural;
+
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
   if (child && gtk_widget_get_visible (child))
-    {
-      gtk_widget_get_preferred_size (child, &child_requisition, NULL);
-    }
+    gtk_widget_get_preferred_height (child, minimum_height, natural_height);
   else
-    {
-      child_requisition.width  = 0;
-      child_requisition.height = 0;
-    }
+    *minimum_height = *natural_height = 0;
 
-  gtk_widget_get_preferred_size (dialog->header,      &header_requisition, NULL);
-  gtk_widget_get_preferred_size (dialog->action_area, &action_requisition, NULL);
+  gtk_widget_get_preferred_height (dialog->header,
+                                   &header_minimum, &header_natural);
+  gtk_widget_get_preferred_height (dialog->action_area,
+                                   &action_minimum, &action_natural);
 
-  requisition->width  += MAX (MAX (child_requisition.width,
-                                   action_requisition.width),
-                              header_requisition.width);
-  requisition->height += (child_requisition.height +
-                          2 * border_width +
-                          header_requisition.height +
-                          action_requisition.height);
+  *minimum_height += header_minimum + action_minimum + 4 * border_width;
+  *natural_height += header_natural + action_natural + 4 * border_width;
 }
 
 static void
diff --git a/app/widgets/gimpoverlayframe.c b/app/widgets/gimpoverlayframe.c
index 667a69f..adfec7f 100644
--- a/app/widgets/gimpoverlayframe.c
+++ b/app/widgets/gimpoverlayframe.c
@@ -32,12 +32,16 @@
 #include "gimpwidgets-utils.h"
 
 
-static void       gimp_overlay_frame_size_request  (GtkWidget      *widget,
-                                                    GtkRequisition *requisition);
-static void       gimp_overlay_frame_size_allocate (GtkWidget      *widget,
-                                                    GtkAllocation  *allocation);
-static gboolean   gimp_overlay_frame_draw          (GtkWidget      *widget,
-                                                    cairo_t        *cr);
+static void       gimp_overlay_frame_get_preferred_width  (GtkWidget     *widget,
+                                                           gint          *minimum_width,
+                                                           gint          *natural_width);
+static void       gimp_overlay_frame_get_preferred_height (GtkWidget     *widget,
+                                                           gint          *minimum_height,
+                                                           gint          *natural_height);
+static void       gimp_overlay_frame_size_allocate        (GtkWidget     *widget,
+                                                           GtkAllocation *allocation);
+static gboolean   gimp_overlay_frame_draw                 (GtkWidget     *widget,
+                                                           cairo_t       *cr);
 
 
 G_DEFINE_TYPE (GimpOverlayFrame, gimp_overlay_frame, GTK_TYPE_BIN)
@@ -50,9 +54,10 @@ gimp_overlay_frame_class_init (GimpOverlayFrameClass *klass)
 {
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  widget_class->size_request  = gimp_overlay_frame_size_request;
-  widget_class->size_allocate = gimp_overlay_frame_size_allocate;
-  widget_class->draw          = gimp_overlay_frame_draw;
+  widget_class->get_preferred_width  = gimp_overlay_frame_get_preferred_width;
+  widget_class->get_preferred_height = gimp_overlay_frame_get_preferred_height;
+  widget_class->size_allocate        = gimp_overlay_frame_size_allocate;
+  widget_class->draw                 = gimp_overlay_frame_draw;
 }
 
 static void
@@ -62,46 +67,58 @@ gimp_overlay_frame_init (GimpOverlayFrame *frame)
 }
 
 static void
-gimp_overlay_frame_size_request (GtkWidget      *widget,
-                                 GtkRequisition *requisition)
+gimp_overlay_frame_get_preferred_width (GtkWidget *widget,
+                                        gint      *minimum_width,
+                                        gint      *natural_width)
 {
-  GtkWidget      *child = gtk_bin_get_child (GTK_BIN (widget));
-  GtkRequisition  child_requisition;
-  gint            border_width;
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
+  gint       border_width;
 
   border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
-  requisition->width  = border_width * 2;
-  requisition->height = border_width * 2;
+  if (child && gtk_widget_get_visible (child))
+    gtk_widget_get_preferred_width (child, minimum_width, natural_width);
+  else
+    *minimum_width = *natural_width = 0;
+
+  *minimum_width += 2 * border_width;
+  *natural_width += 2 * border_width;
+}
+
+static void
+gimp_overlay_frame_get_preferred_height (GtkWidget *widget,
+                                         gint      *minimum_height,
+                                         gint      *natural_height)
+{
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
+  gint       border_width;
+
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
   if (child && gtk_widget_get_visible (child))
-    {
-      gtk_widget_get_preferred_size (child, &child_requisition, NULL);
-    }
+    gtk_widget_get_preferred_height (child, minimum_height, natural_height);
   else
-    {
-      child_requisition.width  = 0;
-      child_requisition.height = 0;
-    }
+    *minimum_height = *natural_height = 0;
 
-  requisition->width  += child_requisition.width;
-  requisition->height += child_requisition.height;
+  *minimum_height += 2 * border_width;
+  *natural_height += 2 * border_width;
 }
 
 static void
 gimp_overlay_frame_size_allocate (GtkWidget     *widget,
                                   GtkAllocation *allocation)
 {
-  GtkWidget     *child = gtk_bin_get_child (GTK_BIN (widget));
-  GtkAllocation  child_allocation;
-  gint           border_width;
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
 
   gtk_widget_set_allocation (widget, allocation);
 
-  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
   if (child && gtk_widget_get_visible (child))
     {
+      GtkAllocation child_allocation;
+      gint          border_width;
+
+      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
       child_allocation.x      = allocation->x + border_width;
       child_allocation.y      = allocation->y + border_width;
       child_allocation.width  = MAX (allocation->width  - 2 * border_width, 0);
diff --git a/app/widgets/gimpview.c b/app/widgets/gimpview.c
index a0c0add..19be68e 100644
--- a/app/widgets/gimpview.c
+++ b/app/widgets/gimpview.c
@@ -59,8 +59,12 @@ static void        gimp_view_realize              (GtkWidget        *widget);
 static void        gimp_view_unrealize            (GtkWidget        *widget);
 static void        gimp_view_map                  (GtkWidget        *widget);
 static void        gimp_view_unmap                (GtkWidget        *widget);
-static void        gimp_view_size_request         (GtkWidget        *widget,
-                                                   GtkRequisition   *requisition);
+static void        gimp_view_get_preferred_width  (GtkWidget        *widget,
+                                                   gint             *minimum_width,
+                                                   gint             *natural_width);
+static void        gimp_view_get_preferred_height (GtkWidget        *widget,
+                                                   gint             *minimum_height,
+                                                   gint             *natural_height);
 static void        gimp_view_size_allocate        (GtkWidget        *widget,
                                                    GtkAllocation    *allocation);
 static void        gimp_view_style_updated        (GtkWidget        *widget);
@@ -149,7 +153,8 @@ gimp_view_class_init (GimpViewClass *klass)
   widget_class->unrealize            = gimp_view_unrealize;
   widget_class->map                  = gimp_view_map;
   widget_class->unmap                = gimp_view_unmap;
-  widget_class->size_request         = gimp_view_size_request;
+  widget_class->get_preferred_width  = gimp_view_get_preferred_width;
+  widget_class->get_preferred_height = gimp_view_get_preferred_height;
   widget_class->size_allocate        = gimp_view_size_allocate;
   widget_class->style_updated        = gimp_view_style_updated;
   widget_class->draw                 = gimp_view_draw;
@@ -272,22 +277,38 @@ gimp_view_unmap (GtkWidget *widget)
 }
 
 static void
-gimp_view_size_request (GtkWidget      *widget,
-                        GtkRequisition *requisition)
+gimp_view_get_preferred_width (GtkWidget *widget,
+                               gint      *minimum_width,
+                               gint      *natural_width)
 {
   GimpView *view = GIMP_VIEW (widget);
 
   if (view->expand)
     {
-      requisition->width  = 2 * view->renderer->border_width + 1;
-      requisition->height = 2 * view->renderer->border_width + 1;
+      *minimum_width = *natural_width = 2 * view->renderer->border_width + 1;
     }
   else
     {
-      requisition->width  = (view->renderer->width +
-                             2 * view->renderer->border_width);
-      requisition->height = (view->renderer->height +
-                             2 * view->renderer->border_width);
+      *minimum_width = *natural_width = (view->renderer->width +
+                                         2 * view->renderer->border_width);
+    }
+}
+
+static void
+gimp_view_get_preferred_height (GtkWidget *widget,
+                                gint      *minimum_height,
+                                gint      *natural_height)
+{
+  GimpView *view = GIMP_VIEW (widget);
+
+  if (view->expand)
+    {
+      *minimum_height = *natural_height = 2 * view->renderer->border_width + 1;
+    }
+  else
+    {
+      *minimum_height = *natural_height = (view->renderer->height +
+                                           2 * view->renderer->border_width);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]