[gtk+] sizerequest: Move sizegroups function to different source file



commit 7501f9770fd088e1e79eb11b7790b712fdd61a71
Author: Benjamin Otte <otte redhat com>
Date:   Sun Nov 4 16:02:14 2012 +0100

    sizerequest: Move sizegroups function to different source file

 gtk/gtksizegroup-private.h |   11 ++----
 gtk/gtksizegroup.c         |   75 +++----------------------------------------
 gtk/gtksizerequest.c       |   73 +++++++++++++++++++++++++++++++++++++++---
 3 files changed, 78 insertions(+), 81 deletions(-)
---
diff --git a/gtk/gtksizegroup-private.h b/gtk/gtksizegroup-private.h
index 59ef781..4b8e1ab 100644
--- a/gtk/gtksizegroup-private.h
+++ b/gtk/gtksizegroup-private.h
@@ -37,12 +37,9 @@ typedef enum
   GTK_QUEUE_RESIZE_INVALIDATE_ONLY = 1 << 0
 } GtkQueueResizeFlags;
 
-void _gtk_size_group_bump_requisition (GtkWidget           *widget,
-                                       GtkSizeGroupMode     mode,
-                                       gint                 for_size,
-                                       gint                *minimum,
-                                       gint                *natural);
-void _gtk_size_group_queue_resize     (GtkWidget           *widget,
-                                       GtkQueueResizeFlags  flags);
+GHashTable * _gtk_size_group_get_widget_peers (GtkWidget           *for_widget,
+                                               GtkSizeGroupMode     mode);
+void _gtk_size_group_queue_resize             (GtkWidget           *widget,
+                                               GtkQueueResizeFlags  flags);
 
 #endif /* __GTK_SIZE_GROUP_PRIVATE_H__ */
diff --git a/gtk/gtksizegroup.c b/gtk/gtksizegroup.c
index 480806f..39e4b92 100644
--- a/gtk/gtksizegroup.c
+++ b/gtk/gtksizegroup.c
@@ -176,15 +176,15 @@ add_widget_to_closure (GHashTable       *set,
     }
 }
 
-static GHashTable *
-widget_get_size_group_peers (GtkWidget        *widget,
-                             GtkSizeGroupMode  mode)
+GHashTable *
+_gtk_size_group_get_widget_peers (GtkWidget        *for_widget,
+                                  GtkSizeGroupMode  mode)
 {
   GHashTable *result;
 
   result = g_hash_table_new (g_direct_hash, g_direct_equal);
 
-  add_widget_to_closure (result, widget, mode);
+  add_widget_to_closure (result, for_widget, mode);
 
   return result;
 }
@@ -244,7 +244,7 @@ queue_resize_on_widget (GtkWidget          *widget,
 	  continue;
 	}
 
-      widgets = widget_get_size_group_peers (parent, GTK_SIZE_GROUP_HORIZONTAL);
+      widgets = _gtk_size_group_get_widget_peers (parent, GTK_SIZE_GROUP_HORIZONTAL);
 
       g_hash_table_iter_init (&iter, widgets);
       while (g_hash_table_iter_next (&iter, &current, NULL))
@@ -264,7 +264,7 @@ queue_resize_on_widget (GtkWidget          *widget,
       
       g_hash_table_destroy (widgets);
       
-      widgets = widget_get_size_group_peers (parent, GTK_SIZE_GROUP_VERTICAL);
+      widgets = _gtk_size_group_get_widget_peers (parent, GTK_SIZE_GROUP_VERTICAL);
 
       g_hash_table_iter_init (&iter, widgets);
       while (g_hash_table_iter_next (&iter, &current, NULL))
@@ -625,69 +625,6 @@ gtk_size_group_get_widgets (GtkSizeGroup *size_group)
 }
 
 /**
- * _gtk_size_group_bump_requisition:
- * @widget: a #GtkWidget
- * @mode: either %GTK_SIZE_GROUP_HORIZONTAL or %GTK_SIZE_GROUP_VERTICAL, depending
- *        on the dimension in which to bump the size.
- * @for_size: Size to request minimum and natural size for
- * @minimum: a pointer to the widget's minimum size
- * @natural: a pointer to the widget's natural size
- *
- * Refreshes the sizegroup while returning the groups requested
- * value in the dimension @mode.
- *
- * This function is used both to update sizegroup minimum and natural size 
- * information and widget minimum and natural sizes in multiple passes from 
- * the size request apis.
- */
-void
-_gtk_size_group_bump_requisition (GtkWidget        *widget,
-				  GtkSizeGroupMode  mode,
-                                  gint              for_size,
-				  gint             *minimum,
-				  gint             *natural)
-{
-  GHashTable *widgets;
-  GHashTableIter iter;
-  gpointer key;
-  gint    min_result = 0, nat_result = 0;
-
-  if (!_gtk_widget_get_sizegroups (widget))
-    return;
-
-  widgets = widget_get_size_group_peers (widget, mode);
-
-  g_hash_table_foreach (widgets, (GHFunc) g_object_ref, NULL);
-  
-  g_hash_table_iter_init (&iter, widgets);
-  while (g_hash_table_iter_next (&iter, &key, NULL))
-    {
-      GtkWidget *tmp_widget = key;
-      gint min_dimension, nat_dimension;
-
-      if (tmp_widget == widget)
-        {
-          min_dimension = *minimum;
-          nat_dimension = *natural;
-        }
-      else
-        {
-          _gtk_widget_compute_size_for_orientation (tmp_widget, mode, TRUE, for_size, &min_dimension, &nat_dimension);
-        }
-
-      min_result = MAX (min_result, min_dimension);
-      nat_result = MAX (nat_result, nat_dimension);
-    }
-
-  g_hash_table_foreach (widgets, (GHFunc) g_object_unref, NULL);
-
-  g_hash_table_destroy (widgets);
-
-  *minimum = min_result;
-  *natural = nat_result;
-}
-
-/**
  * _gtk_size_group_queue_resize:
  * @widget: a #GtkWidget
  * 
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 1559be9..5ad10da 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -326,6 +326,69 @@ get_vfunc_name (GtkSizeGroupMode orientation,
     return for_size < 0 ? "get_preferred_height" : "get_preferred_height_for_width";
 }
 
+/**
+ * _gtk_size_group_bump_requisition:
+ * @widget: a #GtkWidget
+ * @mode: either %GTK_SIZE_GROUP_HORIZONTAL or %GTK_SIZE_GROUP_VERTICAL, depending
+ *        on the dimension in which to bump the size.
+ * @for_size: Size to request minimum and natural size for
+ * @minimum: a pointer to the widget's minimum size
+ * @natural: a pointer to the widget's natural size
+ *
+ * Refreshes the sizegroup while returning the groups requested
+ * value in the dimension @mode.
+ *
+ * This function is used both to update sizegroup minimum and natural size 
+ * information and widget minimum and natural sizes in multiple passes from 
+ * the size request apis.
+ */
+static void
+gtk_size_group_bump_requisition (GtkWidget        *widget,
+				 GtkSizeGroupMode  mode,
+                                 gint              for_size,
+				 gint             *minimum,
+				 gint             *natural)
+{
+  GHashTable *widgets;
+  GHashTableIter iter;
+  gpointer key;
+  gint    min_result = 0, nat_result = 0;
+
+  if (!_gtk_widget_get_sizegroups (widget))
+    return;
+
+  widgets = _gtk_size_group_get_widget_peers (widget, mode);
+
+  g_hash_table_foreach (widgets, (GHFunc) g_object_ref, NULL);
+  
+  g_hash_table_iter_init (&iter, widgets);
+  while (g_hash_table_iter_next (&iter, &key, NULL))
+    {
+      GtkWidget *tmp_widget = key;
+      gint min_dimension, nat_dimension;
+
+      if (tmp_widget == widget)
+        {
+          min_dimension = *minimum;
+          nat_dimension = *natural;
+        }
+      else
+        {
+          _gtk_widget_compute_size_for_orientation (tmp_widget, mode, TRUE, for_size, &min_dimension, &nat_dimension);
+        }
+
+      min_result = MAX (min_result, min_dimension);
+      nat_result = MAX (nat_result, nat_dimension);
+    }
+
+  g_hash_table_foreach (widgets, (GHFunc) g_object_unref, NULL);
+
+  g_hash_table_destroy (widgets);
+
+  *minimum = min_result;
+  *natural = nat_result;
+}
+
 /* This is the main function that checks for a cached size and
  * possibly queries the widget class to compute the size if it's
  * not cached. If the for_size here is -1, then get_preferred_width()
@@ -474,11 +537,11 @@ _gtk_widget_compute_size_for_orientation (GtkWidget         *widget,
     }
 
   if (!ignore_size_groups)
-    _gtk_size_group_bump_requisition (widget,
-                                      orientation,
-                                      for_size,
-                                      &min_size,
-                                      &nat_size);
+    gtk_size_group_bump_requisition (widget,
+                                     orientation,
+                                     for_size,
+                                     &min_size,
+                                     &nat_size);
 
   if (minimum_size)
     *minimum_size = min_size;



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