[gtk+] sizerequest: Use GtkOrientation



commit fd6ea423190c7275c2b096d17e83846426400d78
Author: Benjamin Otte <otte redhat com>
Date:   Wed Nov 14 01:25:21 2012 +0100

    sizerequest: Use GtkOrientation
    
    ... instead of GtkSizeGroupMode. Orientation is what we're interested in
    after all. When we need a GtkSizeGroupMode, we can do the translation
    where we need it.

 gtk/gtksizegroup-private.h       |    2 +-
 gtk/gtksizegroup.c               |   22 ++++++++++---------
 gtk/gtksizerequest.c             |   42 ++++++++++++++++++-------------------
 gtk/gtksizerequestcache.c        |   24 ++++++++++----------
 gtk/gtksizerequestcacheprivate.h |    4 +-
 gtk/gtkwidgetprivate.h           |    2 +-
 6 files changed, 48 insertions(+), 48 deletions(-)
---
diff --git a/gtk/gtksizegroup-private.h b/gtk/gtksizegroup-private.h
index 4b8e1ab..148c533 100644
--- a/gtk/gtksizegroup-private.h
+++ b/gtk/gtksizegroup-private.h
@@ -38,7 +38,7 @@ typedef enum
 } GtkQueueResizeFlags;
 
 GHashTable * _gtk_size_group_get_widget_peers (GtkWidget           *for_widget,
-                                               GtkSizeGroupMode     mode);
+                                               GtkOrientation       orientation);
 void _gtk_size_group_queue_resize             (GtkWidget           *widget,
                                                GtkQueueResizeFlags  flags);
 
diff --git a/gtk/gtksizegroup.c b/gtk/gtksizegroup.c
index e5c370c..b51b824 100644
--- a/gtk/gtksizegroup.c
+++ b/gtk/gtksizegroup.c
@@ -148,9 +148,9 @@ static void gtk_size_group_buildable_custom_finished (GtkBuildable  *buildable,
 						      gpointer       user_data);
 
 static void
-add_widget_to_closure (GHashTable       *set,
-                       GtkWidget        *widget,
-		       GtkSizeGroupMode  mode)
+add_widget_to_closure (GHashTable     *set,
+                       GtkWidget      *widget,
+		       GtkOrientation  orientation)
 {
   GSList *tmp_groups, *tmp_widgets;
   gboolean hidden;
@@ -169,23 +169,25 @@ add_widget_to_closure (GHashTable       *set,
       if (tmp_priv->ignore_hidden && hidden)
         continue;
 
-      if (tmp_priv->mode != GTK_SIZE_GROUP_BOTH && tmp_priv->mode != mode)
+      if (tmp_priv->mode != GTK_SIZE_GROUP_BOTH &&
+          (!(tmp_priv->mode == GTK_SIZE_GROUP_HORIZONTAL && orientation == GTK_ORIENTATION_HORIZONTAL)) &&
+          (!(tmp_priv->mode == GTK_SIZE_GROUP_VERTICAL && orientation == GTK_ORIENTATION_VERTICAL)))
         continue;
 
       for (tmp_widgets = tmp_priv->widgets; tmp_widgets; tmp_widgets = tmp_widgets->next)
-        add_widget_to_closure (set, tmp_widgets->data, mode);
+        add_widget_to_closure (set, tmp_widgets->data, orientation);
     }
 }
 
 GHashTable *
-_gtk_size_group_get_widget_peers (GtkWidget        *for_widget,
-                                  GtkSizeGroupMode  mode)
+_gtk_size_group_get_widget_peers (GtkWidget      *for_widget,
+                                  GtkOrientation  orientation)
 {
   GHashTable *result;
 
   result = g_hash_table_new (g_direct_hash, g_direct_equal);
 
-  add_widget_to_closure (result, for_widget, mode);
+  add_widget_to_closure (result, for_widget, orientation);
 
   return result;
 }
@@ -244,7 +246,7 @@ queue_resize_on_widget (GtkWidget          *widget,
 	  continue;
 	}
 
-      widgets = _gtk_size_group_get_widget_peers (parent, GTK_SIZE_GROUP_HORIZONTAL);
+      widgets = _gtk_size_group_get_widget_peers (parent, GTK_ORIENTATION_HORIZONTAL);
 
       g_hash_table_iter_init (&iter, widgets);
       while (g_hash_table_iter_next (&iter, &current, NULL))
@@ -264,7 +266,7 @@ queue_resize_on_widget (GtkWidget          *widget,
       
       g_hash_table_destroy (widgets);
       
-      widgets = _gtk_size_group_get_widget_peers (parent, GTK_SIZE_GROUP_VERTICAL);
+      widgets = _gtk_size_group_get_widget_peers (parent, GTK_ORIENTATION_VERTICAL);
 
       g_hash_table_iter_init (&iter, widgets);
       while (g_hash_table_iter_next (&iter, &current, NULL))
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 8e7bdc7..644b47a 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -38,7 +38,7 @@ static GQuark recursion_check_quark = 0;
 
 static void
 push_recursion_check (GtkWidget       *widget,
-                      GtkSizeGroupMode orientation,
+                      GtkOrientation   orientation,
                       gint             for_size)
 {
 #ifndef G_DISABLE_CHECKS
@@ -50,7 +50,7 @@ push_recursion_check (GtkWidget       *widget,
 
   previous_method = g_object_get_qdata (G_OBJECT (widget), recursion_check_quark);
 
-  if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       method = for_size < 0 ? "get_width" : "get_width_for_height";
     }
@@ -76,7 +76,7 @@ push_recursion_check (GtkWidget       *widget,
 
 static void
 pop_recursion_check (GtkWidget       *widget,
-                     GtkSizeGroupMode orientation)
+                     GtkOrientation   orientation)
 {
 #ifndef G_DISABLE_CHECKS
   g_object_set_qdata (G_OBJECT (widget), recursion_check_quark, NULL);
@@ -84,10 +84,10 @@ pop_recursion_check (GtkWidget       *widget,
 }
 
 static const char *
-get_vfunc_name (GtkSizeGroupMode orientation,
-                gint             for_size)
+get_vfunc_name (GtkOrientation orientation,
+                gint           for_size)
 {
-  if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
     return for_size < 0 ? "get_preferred_width" : "get_preferred_width_for_height";
   else
     return for_size < 0 ? "get_preferred_height" : "get_preferred_height_for_width";
@@ -95,7 +95,7 @@ get_vfunc_name (GtkSizeGroupMode orientation,
 
 static void
 gtk_widget_query_size_for_orientation (GtkWidget        *widget,
-                                       GtkSizeGroupMode  orientation,
+                                       GtkOrientation    orientation,
                                        gint              for_size,
                                        gint             *minimum_size,
                                        gint             *natural_size)
@@ -118,7 +118,7 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
 
       gtk_widget_ensure_style (widget);
 
-      if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
         {
           if (for_size < 0 || gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE)
             {
@@ -194,9 +194,7 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
       adjusted_min     = min_size;
       adjusted_natural = nat_size;
       GTK_WIDGET_GET_CLASS (widget)->adjust_size_request (widget,
-                                                          orientation == GTK_SIZE_GROUP_HORIZONTAL ?
-                                                          GTK_ORIENTATION_HORIZONTAL :
-                                                          GTK_ORIENTATION_VERTICAL,
+                                                          orientation,
                                                           &adjusted_min,
                                                           &adjusted_natural);
 
@@ -205,7 +203,7 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
         {
           g_warning ("%s %p adjusted size %s min %d natural %d must not decrease below min %d natural %d",
                      G_OBJECT_TYPE_NAME (widget), widget,
-                     orientation == GTK_SIZE_GROUP_VERTICAL ? "vertical" : "horizontal",
+                     orientation == GTK_ORIENTATION_VERTICAL ? "vertical" : "horizontal",
                      adjusted_min, adjusted_natural,
                      min_size, nat_size);
           /* don't use the adjustment */
@@ -214,7 +212,7 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
         {
           g_warning ("%s %p adjusted size %s min %d natural %d original min %d natural %d has min greater than natural",
                      G_OBJECT_TYPE_NAME (widget), widget,
-                     orientation == GTK_SIZE_GROUP_VERTICAL ? "vertical" : "horizontal",
+                     orientation == GTK_ORIENTATION_VERTICAL ? "vertical" : "horizontal",
                      adjusted_min, adjusted_natural,
                      min_size, nat_size);
           /* don't use the adjustment */
@@ -244,7 +242,7 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
   GTK_NOTE (SIZE_REQUEST,
             g_print ("[%p] %s\t%s: %d is minimum %d and natural: %d (hit cache: %s)\n",
                      widget, G_OBJECT_TYPE_NAME (widget),
-                     orientation == GTK_SIZE_GROUP_HORIZONTAL ?
+                     orientation == GTK_ORIENTATION_HORIZONTAL ?
                      "width for height" : "height for width" ,
                      for_size, min_size, nat_size,
                      found_in_cache ? "yes" : "no"));
@@ -257,7 +255,7 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
  */
 void
 _gtk_widget_compute_size_for_orientation (GtkWidget        *widget,
-                                          GtkSizeGroupMode  mode,
+                                          GtkOrientation    orientation,
                                           gint              for_size,
                                           gint             *minimum,
                                           gint             *natural)
@@ -269,11 +267,11 @@ _gtk_widget_compute_size_for_orientation (GtkWidget        *widget,
 
   if (G_LIKELY (!_gtk_widget_get_sizegroups (widget)))
     {
-      gtk_widget_query_size_for_orientation (widget, mode, for_size, minimum, natural);
+      gtk_widget_query_size_for_orientation (widget, orientation, for_size, minimum, natural);
       return;
     }
 
-  widgets = _gtk_size_group_get_widget_peers (widget, mode);
+  widgets = _gtk_size_group_get_widget_peers (widget, orientation);
 
   g_hash_table_foreach (widgets, (GHFunc) g_object_ref, NULL);
   
@@ -283,7 +281,7 @@ _gtk_widget_compute_size_for_orientation (GtkWidget        *widget,
       GtkWidget *tmp_widget = key;
       gint min_dimension, nat_dimension;
 
-      gtk_widget_query_size_for_orientation (tmp_widget, mode, for_size, &min_dimension, &nat_dimension);
+      gtk_widget_query_size_for_orientation (tmp_widget, orientation, for_size, &min_dimension, &nat_dimension);
 
       min_result = MAX (min_result, min_dimension);
       nat_result = MAX (nat_result, nat_dimension);
@@ -362,7 +360,7 @@ gtk_widget_get_preferred_width (GtkWidget *widget,
   g_return_if_fail (minimum_width != NULL || natural_width != NULL);
 
   _gtk_widget_compute_size_for_orientation (widget,
-                                            GTK_SIZE_GROUP_HORIZONTAL,
+                                            GTK_ORIENTATION_HORIZONTAL,
                                             -1,
                                             minimum_width,
                                             natural_width);
@@ -396,7 +394,7 @@ gtk_widget_get_preferred_height (GtkWidget *widget,
   g_return_if_fail (minimum_height != NULL || natural_height != NULL);
 
   _gtk_widget_compute_size_for_orientation (widget,
-                                            GTK_SIZE_GROUP_VERTICAL,
+                                            GTK_ORIENTATION_VERTICAL,
                                             -1,
                                             minimum_height,
                                             natural_height);
@@ -433,7 +431,7 @@ gtk_widget_get_preferred_width_for_height (GtkWidget *widget,
   g_return_if_fail (height >= 0);
 
   _gtk_widget_compute_size_for_orientation (widget,
-                                            GTK_SIZE_GROUP_HORIZONTAL,
+                                            GTK_ORIENTATION_HORIZONTAL,
                                             height,
                                             minimum_width,
                                             natural_width);
@@ -468,7 +466,7 @@ gtk_widget_get_preferred_height_for_width (GtkWidget *widget,
   g_return_if_fail (width >= 0);
 
   _gtk_widget_compute_size_for_orientation (widget,
-                                            GTK_SIZE_GROUP_VERTICAL,
+                                            GTK_ORIENTATION_VERTICAL,
                                             width,
                                             minimum_height,
                                             natural_height);
diff --git a/gtk/gtksizerequestcache.c b/gtk/gtksizerequestcache.c
index f4879f2..3834520 100644
--- a/gtk/gtksizerequestcache.c
+++ b/gtk/gtksizerequestcache.c
@@ -60,11 +60,11 @@ _gtk_size_request_cache_clear (SizeRequestCache *cache)
 }
 
 void
-_gtk_size_request_cache_commit (SizeRequestCache  *cache,
-                                GtkSizeGroupMode   orientation,
-                                gint               for_size,
-                                gint               minimum_size,
-                                gint               natural_size)
+_gtk_size_request_cache_commit (SizeRequestCache *cache,
+                                GtkOrientation    orientation,
+                                gint              for_size,
+                                gint              minimum_size,
+                                gint              natural_size)
 {
   SizeRequest      **cached_sizes;
   guint              i, n_sizes;
@@ -72,7 +72,7 @@ _gtk_size_request_cache_commit (SizeRequestCache  *cache,
   /* First handle caching of the base requests */
   if (for_size < 0)
     {
-      if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
 	{
 	  cache->cached_width.minimum_size = minimum_size;
 	  cache->cached_width.natural_size = natural_size;
@@ -91,7 +91,7 @@ _gtk_size_request_cache_commit (SizeRequestCache  *cache,
    * in the cache and if this result can be used to extend
    * that cache entry 
    */
-  if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       cached_sizes = cache->widths;
       n_sizes = cache->cached_widths;
@@ -116,7 +116,7 @@ _gtk_size_request_cache_commit (SizeRequestCache  *cache,
   /* If not found, pull a new size from the cache, the returned size cache
    * will immediately be used to cache the new computed size so we go ahead
    * and increment the last_cached_width/height right away */
-  if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       if (cache->cached_widths < GTK_SIZE_REQUEST_CACHED_SIZES)
 	{
@@ -140,7 +140,7 @@ _gtk_size_request_cache_commit (SizeRequestCache  *cache,
       cache->widths[cache->last_cached_width]->cached_size.minimum_size = minimum_size;
       cache->widths[cache->last_cached_width]->cached_size.natural_size = natural_size;
     }
-  else /* GTK_SIZE_GROUP_VERTICAL */
+  else /* GTK_ORIENTATION_VERTICAL */
     {
       if (cache->cached_heights < GTK_SIZE_REQUEST_CACHED_SIZES)
 	{
@@ -173,7 +173,7 @@ _gtk_size_request_cache_commit (SizeRequestCache  *cache,
  */
 gboolean
 _gtk_size_request_cache_lookup (SizeRequestCache *cache,
-                                GtkSizeGroupMode  orientation,
+                                GtkOrientation    orientation,
                                 gint              for_size,
                                 gint             *minimum,
                                 gint             *natural)
@@ -182,7 +182,7 @@ _gtk_size_request_cache_lookup (SizeRequestCache *cache,
 
   if (for_size < 0)
     {
-      if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
 	{
           if (cache->cached_base_width)
 	    result = &cache->cached_width;
@@ -198,7 +198,7 @@ _gtk_size_request_cache_lookup (SizeRequestCache *cache,
       SizeRequest      **cached_sizes;
       guint              i, n_sizes;
 
-      if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
         {
           cached_sizes = cache->widths;
           n_sizes      = cache->cached_widths;
diff --git a/gtk/gtksizerequestcacheprivate.h b/gtk/gtksizerequestcacheprivate.h
index 328a89e..7c293d9 100644
--- a/gtk/gtksizerequestcacheprivate.h
+++ b/gtk/gtksizerequestcacheprivate.h
@@ -72,12 +72,12 @@ void            _gtk_size_request_cache_free                    (SizeRequestCach
 
 void            _gtk_size_request_cache_clear                   (SizeRequestCache       *cache);
 void            _gtk_size_request_cache_commit                  (SizeRequestCache       *cache,
-                                                                 GtkSizeGroupMode        orientation,
+                                                                 GtkOrientation          orientation,
                                                                  gint                    for_size,
                                                                  gint                    minimum_size,
                                                                  gint                    natural_size);
 gboolean        _gtk_size_request_cache_lookup                  (SizeRequestCache       *cache,
-                                                                 GtkSizeGroupMode        orientation,
+                                                                 GtkOrientation          orientation,
                                                                  gint                    for_size,
                                                                  gint                   *minimum,
                                                                  gint                   *natural);
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 78e0e35..4542580 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -66,7 +66,7 @@ void _gtk_widget_restore_size_request  (GtkWidget *widget,
                                         int        old_width,
                                         int        old_height);
 void _gtk_widget_compute_size_for_orientation  (GtkWidget         *widget,
-                                                GtkSizeGroupMode   orientation,
+                                                GtkOrientation     orientation,
                                                 gint               for_size,
                                                 gint              *minimum_size,
                                                 gint              *natural_size);



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