[gtk+/wip/actor: 22/24] widget: Make size-request vfuncs call into actor code



commit 0d602509174e91cb7d54704259e546a44124c9a7
Author: Benjamin Otte <otte redhat com>
Date:   Sun Dec 23 15:02:36 2012 +0100

    widget: Make size-request vfuncs call into actor code

 gtk/actors/gtkwidgetactor.c        |   24 ++++++++++++++
 gtk/actors/gtkwidgetactorprivate.h |    6 +++
 gtk/gtkwidget.c                    |   61 +++++++++++++++++++++++++++++++-----
 3 files changed, 83 insertions(+), 8 deletions(-)
---
diff --git a/gtk/actors/gtkwidgetactor.c b/gtk/actors/gtkwidgetactor.c
index fcf6ca4..54bbaab 100644
--- a/gtk/actors/gtkwidgetactor.c
+++ b/gtk/actors/gtkwidgetactor.c
@@ -153,6 +153,30 @@ _gtk_widget_actor_unrealize (GtkActor *actor)
   GTK_ACTOR_CLASS (_gtk_widget_actor_parent_class)->unrealize (actor);
 }
 
+GtkSizeRequestMode
+_gtk_widget_actor_get_request_mode (GtkActor *actor)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET_ACTOR (actor), GTK_SIZE_REQUEST_CONSTANT_SIZE);
+
+  return GTK_ACTOR_CLASS (_gtk_widget_actor_parent_class)->get_request_mode (actor);
+}
+
+void
+_gtk_widget_actor_get_preferred_size (GtkActor       *actor,
+                                      GtkOrientation  orientation,
+                                      gfloat          for_size,
+                                      gfloat         *min_size_p,
+                                      gfloat         *natural_size_p)
+{
+  g_return_if_fail (GTK_IS_WIDGET_ACTOR (actor));
+
+  GTK_ACTOR_CLASS (_gtk_widget_actor_parent_class)->get_preferred_size (actor,
+                                                                        orientation,
+                                                                        for_size,
+                                                                        min_size_p,
+                                                                        natural_size_p);
+}
+
 void
 _gtk_widget_actor_screen_changed (GtkActor  *actor,
                                   GdkScreen *new_screen,
diff --git a/gtk/actors/gtkwidgetactorprivate.h b/gtk/actors/gtkwidgetactorprivate.h
index 3dfa91c..50d0231 100644
--- a/gtk/actors/gtkwidgetactorprivate.h
+++ b/gtk/actors/gtkwidgetactorprivate.h
@@ -55,6 +55,12 @@ void                        _gtk_widget_actor_map                       (GtkActo
 void                        _gtk_widget_actor_unmap                     (GtkActor       *actor);
 void                        _gtk_widget_actor_realize                   (GtkActor       *actor);
 void                        _gtk_widget_actor_unrealize                 (GtkActor       *actor);
+GtkSizeRequestMode          _gtk_widget_actor_get_request_mode          (GtkActor       *self);
+void                        _gtk_widget_actor_get_preferred_size        (GtkActor       *self,
+                                                                         GtkOrientation  orientation,
+                                                                         gfloat          for_size,
+                                                                         gfloat         *min_size_p,
+                                                                         gfloat         *natural_size_p);
 
 void                        _gtk_widget_actor_screen_changed            (GtkActor       *actor,
                                                                          GdkScreen      *new_screen,
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 08ea829..ba65104 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -12684,8 +12684,7 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
 static GtkSizeRequestMode 
 gtk_widget_real_get_request_mode (GtkWidget *widget)
 { 
-  /* By default widgets dont trade size at all. */
-  return GTK_SIZE_REQUEST_CONSTANT_SIZE;
+  return _gtk_widget_actor_get_request_mode (widget->priv->actor);
 }
 
 static void
@@ -12693,11 +12692,17 @@ gtk_widget_real_get_width (GtkWidget *widget,
 			   gint      *minimum_size,
 			   gint      *natural_size)
 {
+  gfloat min, nat;
+  
+  _gtk_widget_actor_get_preferred_size (widget->priv->actor,
+                                        GTK_ORIENTATION_HORIZONTAL,
+                                        -1,
+                                        &min, &nat);
   if (minimum_size)
-    *minimum_size = 0;
+    *minimum_size = min;
 
   if (natural_size)
-    *natural_size = 0;
+    *natural_size = nat;
 }
 
 static void
@@ -12705,11 +12710,17 @@ gtk_widget_real_get_height (GtkWidget *widget,
 			    gint      *minimum_size,
 			    gint      *natural_size)
 {
+  gfloat min, nat;
+  
+  _gtk_widget_actor_get_preferred_size (widget->priv->actor,
+                                        GTK_ORIENTATION_VERTICAL,
+                                        -1,
+                                        &min, &nat);
   if (minimum_size)
-    *minimum_size = 0;
+    *minimum_size = min;
 
   if (natural_size)
-    *natural_size = 0;
+    *natural_size = nat;
 }
 
 static void
@@ -12718,7 +12729,24 @@ gtk_widget_real_get_height_for_width (GtkWidget *widget,
                                       gint      *minimum_height,
                                       gint      *natural_height)
 {
-  GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, minimum_height, natural_height);
+  if (GTK_WIDGET_GET_CLASS (widget)->get_preferred_height == gtk_widget_real_get_height)
+    {
+      gfloat min, nat;
+      
+      _gtk_widget_actor_get_preferred_size (widget->priv->actor,
+                                            GTK_ORIENTATION_VERTICAL,
+                                            width,
+                                            &min, &nat);
+      if (minimum_height)
+        *minimum_height = min;
+
+      if (natural_height)
+        *natural_height = nat;
+    }
+  else
+    {
+      GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, minimum_height, natural_height);
+    }
 }
 
 static void
@@ -12727,7 +12755,24 @@ gtk_widget_real_get_width_for_height (GtkWidget *widget,
                                       gint      *minimum_width,
                                       gint      *natural_width)
 {
-  GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
+  if (GTK_WIDGET_GET_CLASS (widget)->get_preferred_width == gtk_widget_real_get_width)
+    {
+      gfloat min, nat;
+      
+      _gtk_widget_actor_get_preferred_size (widget->priv->actor,
+                                            GTK_ORIENTATION_HORIZONTAL,
+                                            height,
+                                            &min, &nat);
+      if (minimum_width)
+        *minimum_width = min;
+
+      if (natural_width)
+        *natural_width = nat;
+    }
+  else
+    {
+      GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
+    }
 }
 
 /**



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