[gimp/gtk3-port: 84/233] libgimpwidgets: port to the new size request API



commit fd6350e03007cdd1d0419f31ad80d2db81a6d95c
Author: Michael Natterer <mitch gimp org>
Date:   Thu Oct 28 13:26:39 2010 +0200

    libgimpwidgets: port to the new size request API

 libgimpwidgets/gimpframe.c |   63 ++++++++++++++++++++++++++++++++------------
 libgimpwidgets/gimpruler.c |   59 ++++++++++++++++++++++++++++++----------
 2 files changed, 90 insertions(+), 32 deletions(-)
---
diff --git a/libgimpwidgets/gimpframe.c b/libgimpwidgets/gimpframe.c
index 1088e9a..efcc4b1 100644
--- a/libgimpwidgets/gimpframe.c
+++ b/libgimpwidgets/gimpframe.c
@@ -48,19 +48,23 @@
 #define GIMP_FRAME_IN_EXPANDER_KEY  "gimp-frame-in-expander"
 
 
-static void      gimp_frame_size_request        (GtkWidget      *widget,
-                                                 GtkRequisition *requisition);
-static void      gimp_frame_size_allocate       (GtkWidget      *widget,
-                                                 GtkAllocation  *allocation);
-static void      gimp_frame_style_set           (GtkWidget      *widget,
-                                                 GtkStyle       *previous);
-static gboolean  gimp_frame_draw                (GtkWidget      *widget,
-                                                 cairo_t        *cr);
-static void      gimp_frame_child_allocate      (GtkFrame       *frame,
-                                                 GtkAllocation  *allocation);
-static void      gimp_frame_label_widget_notify (GtkFrame       *frame);
-static gint      gimp_frame_get_indent          (GtkWidget      *widget);
-static gint      gimp_frame_get_label_spacing   (GtkFrame       *frame);
+static void      gimp_frame_get_preferred_width  (GtkWidget      *widget,
+                                                  gint           *minimum_width,
+                                                  gint           *natural_width);
+static void      gimp_frame_get_preferred_height (GtkWidget      *widget,
+                                                  gint           *minimum_height,
+                                                  gint           *natural_height);
+static void      gimp_frame_size_allocate        (GtkWidget      *widget,
+                                                  GtkAllocation  *allocation);
+static void      gimp_frame_style_set            (GtkWidget      *widget,
+                                                  GtkStyle       *previous);
+static gboolean  gimp_frame_draw                 (GtkWidget      *widget,
+                                                  cairo_t        *cr);
+static void      gimp_frame_child_allocate       (GtkFrame       *frame,
+                                                  GtkAllocation  *allocation);
+static void      gimp_frame_label_widget_notify  (GtkFrame       *frame);
+static gint      gimp_frame_get_indent           (GtkWidget      *widget);
+static gint      gimp_frame_get_label_spacing    (GtkFrame       *frame);
 
 
 G_DEFINE_TYPE (GimpFrame, gimp_frame, GTK_TYPE_FRAME)
@@ -73,10 +77,11 @@ gimp_frame_class_init (GimpFrameClass *klass)
 {
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  widget_class->size_request  = gimp_frame_size_request;
-  widget_class->size_allocate = gimp_frame_size_allocate;
-  widget_class->style_set     = gimp_frame_style_set;
-  widget_class->draw          = gimp_frame_draw;
+  widget_class->get_preferred_width  = gimp_frame_get_preferred_width;
+  widget_class->get_preferred_height = gimp_frame_get_preferred_height;
+  widget_class->size_allocate        = gimp_frame_size_allocate;
+  widget_class->style_set            = gimp_frame_style_set;
+  widget_class->draw                 = gimp_frame_draw;
 
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_boolean ("label-bold",
@@ -143,6 +148,30 @@ gimp_frame_size_request (GtkWidget      *widget,
 }
 
 static void
+gimp_frame_get_preferred_width (GtkWidget *widget,
+                                gint      *minimum_width,
+                                gint      *natural_width)
+{
+  GtkRequisition requisition;
+
+  gimp_frame_size_request (widget, &requisition);
+
+  *minimum_width = *natural_width = requisition.width;
+}
+
+static void
+gimp_frame_get_preferred_height (GtkWidget *widget,
+                                 gint      *minimum_height,
+                                 gint      *natural_height)
+{
+  GtkRequisition requisition;
+
+  gimp_frame_size_request (widget, &requisition);
+
+  *minimum_height = *natural_height = requisition.height;
+}
+
+static void
 gimp_frame_size_allocate (GtkWidget     *widget,
                           GtkAllocation *allocation)
 {
diff --git a/libgimpwidgets/gimpruler.c b/libgimpwidgets/gimpruler.c
index c617e79..404108f 100644
--- a/libgimpwidgets/gimpruler.c
+++ b/libgimpwidgets/gimpruler.c
@@ -130,8 +130,12 @@ static void          gimp_ruler_map                   (GtkWidget      *widget);
 static void          gimp_ruler_unmap                 (GtkWidget      *widget);
 static void          gimp_ruler_size_allocate         (GtkWidget      *widget,
                                                        GtkAllocation  *allocation);
-static void          gimp_ruler_size_request          (GtkWidget      *widget,
-                                                       GtkRequisition *requisition);
+static void          gimp_ruler_get_preferred_width   (GtkWidget      *widget,
+                                                       gint           *minimum_width,
+                                                       gint           *natural_width);
+static void          gimp_ruler_get_preferred_height  (GtkWidget      *widget,
+                                                       gint           *minimum_height,
+                                                       gint           *natural_height);
 static void          gimp_ruler_style_set             (GtkWidget      *widget,
                                                        GtkStyle       *prev_style);
 static gboolean      gimp_ruler_motion_notify         (GtkWidget      *widget,
@@ -164,19 +168,20 @@ gimp_ruler_class_init (GimpRulerClass *klass)
   GObjectClass   *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  object_class->dispose             = gimp_ruler_dispose;
-  object_class->set_property        = gimp_ruler_set_property;
-  object_class->get_property        = gimp_ruler_get_property;
-
-  widget_class->realize             = gimp_ruler_realize;
-  widget_class->unrealize           = gimp_ruler_unrealize;
-  widget_class->map                 = gimp_ruler_map;
-  widget_class->unmap               = gimp_ruler_unmap;
-  widget_class->size_allocate       = gimp_ruler_size_allocate;
-  widget_class->size_request        = gimp_ruler_size_request;
-  widget_class->style_set           = gimp_ruler_style_set;
-  widget_class->motion_notify_event = gimp_ruler_motion_notify;
-  widget_class->draw                = gimp_ruler_draw;
+  object_class->dispose              = gimp_ruler_dispose;
+  object_class->set_property         = gimp_ruler_set_property;
+  object_class->get_property         = gimp_ruler_get_property;
+
+  widget_class->realize              = gimp_ruler_realize;
+  widget_class->unrealize            = gimp_ruler_unrealize;
+  widget_class->map                  = gimp_ruler_map;
+  widget_class->unmap                = gimp_ruler_unmap;
+  widget_class->get_preferred_width  = gimp_ruler_get_preferred_width;
+  widget_class->get_preferred_height = gimp_ruler_get_preferred_height;
+  widget_class->size_allocate        = gimp_ruler_size_allocate;
+  widget_class->style_set            = gimp_ruler_style_set;
+  widget_class->motion_notify_event  = gimp_ruler_motion_notify;
+  widget_class->draw                 = gimp_ruler_draw;
 
   g_type_class_add_private (object_class, sizeof (GimpRulerPrivate));
 
@@ -919,6 +924,30 @@ gimp_ruler_size_request (GtkWidget      *widget,
 }
 
 static void
+gimp_ruler_get_preferred_width (GtkWidget *widget,
+                                gint      *minimum_width,
+                                gint      *natural_width)
+{
+  GtkRequisition requisition;
+
+  gimp_ruler_size_request (widget, &requisition);
+
+  *minimum_width = *natural_width = requisition.width;
+}
+
+static void
+gimp_ruler_get_preferred_height (GtkWidget *widget,
+                                 gint      *minimum_height,
+                                 gint      *natural_height)
+{
+  GtkRequisition requisition;
+
+  gimp_ruler_size_request (widget, &requisition);
+
+  *minimum_height = *natural_height = requisition.height;
+}
+
+static void
 gimp_ruler_style_set (GtkWidget *widget,
                       GtkStyle  *prev_style)
 {


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