[gimp/gtk3-port: 87/226] app: port to the new size request API



commit 140d82e1deab55bef14600682c38b95f20459c76
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      |  182 +++++++++++++++++++++------------------
 app/widgets/gimphistogramview.c |   65 +++++++++------
 app/widgets/gimpmessagebox.c    |  154 +++++++++++++++++++--------------
 app/widgets/gimpoverlaydialog.c |  100 +++++++++++++---------
 app/widgets/gimpoverlayframe.c  |   77 ++++++++++-------
 app/widgets/gimpview.c          |   43 +++++++---
 7 files changed, 413 insertions(+), 287 deletions(-)
---
diff --git a/app/widgets/gimpdasheditor.c b/app/widgets/gimpdasheditor.c
index a2f1a8f..3dd0086 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;
@@ -223,14 +228,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 16260cc..5b0d282 100644
--- a/app/widgets/gimpdockable.c
+++ b/app/widgets/gimpdockable.c
@@ -83,52 +83,55 @@ 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);
-static gboolean   gimp_dockable_blink_timeout     (GimpDockable   *dockable);
+                  gimp_dockable_convert_tab_style    (GimpDockable   *dockable,
+                                                      GimpTabStyle    tab_style);
+static gboolean   gimp_dockable_blink_timeout        (GimpDockable   *dockable);
 
 
 G_DEFINE_TYPE_WITH_CODE (GimpDockable, gimp_dockable, GTK_TYPE_BIN,
@@ -147,19 +150,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,
@@ -282,18 +288,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;
@@ -302,34 +305,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 02b399a..229284c 100644
--- a/app/widgets/gimphistogramview.c
+++ b/app/widgets/gimphistogramview.c
@@ -51,26 +51,30 @@ enum
 };
 
 
-static void     gimp_histogram_view_finalize       (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_finalize             (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;
@@ -252,13 +257,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 dc36272..e88387e 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);
 
 
 G_DEFINE_TYPE (GimpMessageBox, gimp_message_box, GTK_TYPE_BOX)
@@ -86,17 +89,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_STOCK_ID,
                                    g_param_spec_string ("stock-id", NULL, NULL,
@@ -233,26 +238,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);
     }
 }
 
@@ -260,39 +289,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 efe943f..3708220 100644
--- a/app/widgets/gimpoverlaydialog.c
+++ b/app/widgets/gimpoverlaydialog.c
@@ -50,22 +50,26 @@ struct _ResponseData
 };
 
 
-static void       gimp_overlay_dialog_dispose       (GObject           *object);
+static void       gimp_overlay_dialog_dispose              (GObject           *object);
 
-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_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_forall               (GtkContainer      *container,
+                                                            gboolean           include_internals,
+                                                            GtkCallback        callback,
+                                                            gpointer           callback_data);
 
-static void       gimp_overlay_dialog_close         (GimpOverlayDialog *dialog);
+static void       gimp_overlay_dialog_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,
@@ -83,14 +87,15 @@ gimp_overlay_dialog_class_init (GimpOverlayDialogClass *klass)
   GtkWidgetClass    *widget_class    = GTK_WIDGET_CLASS (klass);
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
 
-  object_class->dispose       = gimp_overlay_dialog_dispose;
+  object_class->dispose              = gimp_overlay_dialog_dispose;
 
-  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->close                = gimp_overlay_dialog_close;
+  klass->close                       = gimp_overlay_dialog_close;
 
   signals[RESPONSE] =
     g_signal_new ("response",
@@ -140,38 +145,53 @@ gimp_overlay_dialog_dispose (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     action_requisition;
+  GimpOverlayDialog *dialog = GIMP_OVERLAY_DIALOG (widget);
+  GtkWidget         *child  = gtk_bin_get_child (GTK_BIN (widget));
   gint               border_width;
+  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->action_area,
+                                  &action_minimum, &action_natural);
+
+  *minimum_width = MAX (*minimum_width, action_minimum) + 2 * border_width;
+  *natural_width = MAX (*natural_width, action_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               action_minimum;
+  gint               action_natural;
 
-  requisition->width  = border_width * 2;
-  requisition->height = border_width * 2;
+  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->action_area, &action_requisition, NULL);
+  gtk_widget_get_preferred_height (dialog->action_area,
+                                   &action_minimum, &action_natural);
 
-  requisition->width  += MAX (child_requisition.width,
-                              action_requisition.width);
-  requisition->height += (child_requisition.height +
-                          border_width +
-                          action_requisition.height);
+  *minimum_height = MAX (*minimum_height, action_minimum) + 3 * border_width;
+  *natural_height = MAX (*natural_height, action_natural) + 3 * border_width;
 }
 
 static void
diff --git a/app/widgets/gimpoverlayframe.c b/app/widgets/gimpoverlayframe.c
index d3ca2f3..f53a5ff 100644
--- a/app/widgets/gimpoverlayframe.c
+++ b/app/widgets/gimpoverlayframe.c
@@ -30,12 +30,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)
@@ -48,9 +52,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
@@ -60,46 +65,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 80f2cda..4e13848 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 gboolean    gimp_view_draw                 (GtkWidget        *widget,
@@ -146,7 +150,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->draw                 = gimp_view_draw;
   widget_class->button_press_event   = gimp_view_button_press_event;
@@ -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]