]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcellareaboxcontext.c
spinbutton: don't override initial text in non-numeric-only spin buttons
[~andy/gtk] / gtk / gtkcellareaboxcontext.c
index c5e02bda9e8949778f8e83ac7ec6537be6fb1718..d00316578a377fdaedd3015e9c41f9c950ff016a 100644 (file)
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
 #include "gtkintl.h"
 #include "gtkcellareabox.h"
-#include "gtkcellareaboxcontext.h"
+#include "gtkcellareaboxcontextprivate.h"
 #include "gtkorientable.h"
 
 /* GObjectClass */
-static void      gtk_cell_area_box_context_finalize              (GObject               *object);
+static void      _gtk_cell_area_box_context_finalize              (GObject               *object);
 
 /* GtkCellAreaContextClass */
-static void      gtk_cell_area_box_context_reset                 (GtkCellAreaContext    *context);
-static void      gtk_cell_area_box_context_get_preferred_height_for_width (GtkCellAreaContext *context,
+static void      _gtk_cell_area_box_context_reset                 (GtkCellAreaContext    *context);
+static void      _gtk_cell_area_box_context_get_preferred_height_for_width (GtkCellAreaContext *context,
                                                                            gint                width,
                                                                            gint               *minimum_height,
                                                                            gint               *natural_height);
-static void      gtk_cell_area_box_context_get_preferred_width_for_height (GtkCellAreaContext *context,
+static void      _gtk_cell_area_box_context_get_preferred_width_for_height (GtkCellAreaContext *context,
                                                                            gint                height,
                                                                            gint               *minimum_width,
                                                                            gint               *natural_width);
@@ -44,7 +42,7 @@ static void      gtk_cell_area_box_context_get_preferred_width_for_height (GtkCe
 
 
 /* Internal functions */
-static void      gtk_cell_area_box_context_sum                  (GtkCellAreaBoxContext  *context,
+static void      _gtk_cell_area_box_context_sum                  (GtkCellAreaBoxContext  *context,
                                                                  GtkOrientation          orientation,
                                                                  gint                    for_size,
                                                                  gint                   *minimum_size,
@@ -82,7 +80,7 @@ struct _GtkCellAreaBoxContextPrivate
   gboolean  *align;
 };
 
-G_DEFINE_TYPE (GtkCellAreaBoxContext, gtk_cell_area_box_context, GTK_TYPE_CELL_AREA_CONTEXT);
+G_DEFINE_TYPE (GtkCellAreaBoxContext, _gtk_cell_area_box_context, GTK_TYPE_CELL_AREA_CONTEXT);
 
 static void
 free_cache_array (GArray *array)
@@ -165,7 +163,7 @@ count_expand_groups (GtkCellAreaBoxContext *context)
 }
 
 static void
-gtk_cell_area_box_context_init (GtkCellAreaBoxContext *box_context)
+_gtk_cell_area_box_context_init (GtkCellAreaBoxContext *box_context)
 {
   GtkCellAreaBoxContextPrivate *priv;
 
@@ -184,17 +182,17 @@ gtk_cell_area_box_context_init (GtkCellAreaBoxContext *box_context)
 }
 
 static void 
-gtk_cell_area_box_context_class_init (GtkCellAreaBoxContextClass *class)
+_gtk_cell_area_box_context_class_init (GtkCellAreaBoxContextClass *class)
 {
   GObjectClass            *object_class = G_OBJECT_CLASS (class);
   GtkCellAreaContextClass *context_class   = GTK_CELL_AREA_CONTEXT_CLASS (class);
 
   /* GObjectClass */
-  object_class->finalize = gtk_cell_area_box_context_finalize;
+  object_class->finalize = _gtk_cell_area_box_context_finalize;
 
-  context_class->reset                          = gtk_cell_area_box_context_reset;
-  context_class->get_preferred_height_for_width = gtk_cell_area_box_context_get_preferred_height_for_width;
-  context_class->get_preferred_width_for_height = gtk_cell_area_box_context_get_preferred_width_for_height;
+  context_class->reset                          = _gtk_cell_area_box_context_reset;
+  context_class->get_preferred_height_for_width = _gtk_cell_area_box_context_get_preferred_height_for_width;
+  context_class->get_preferred_width_for_height = _gtk_cell_area_box_context_get_preferred_width_for_height;
 
   g_type_class_add_private (object_class, sizeof (GtkCellAreaBoxContextPrivate));
 }
@@ -203,7 +201,7 @@ gtk_cell_area_box_context_class_init (GtkCellAreaBoxContextClass *class)
  *                      GObjectClass                         *
  *************************************************************/
 static void
-gtk_cell_area_box_context_finalize (GObject *object)
+_gtk_cell_area_box_context_finalize (GObject *object)
 {
   GtkCellAreaBoxContext        *box_context = GTK_CELL_AREA_BOX_CONTEXT (object);
   GtkCellAreaBoxContextPrivate *priv        = box_context->priv;
@@ -216,14 +214,14 @@ gtk_cell_area_box_context_finalize (GObject *object)
   g_free (priv->expand);
   g_free (priv->align);
 
-  G_OBJECT_CLASS (gtk_cell_area_box_context_parent_class)->finalize (object);
+  G_OBJECT_CLASS (_gtk_cell_area_box_context_parent_class)->finalize (object);
 }
 
 /*************************************************************
  *                    GtkCellAreaContextClass                *
  *************************************************************/
 static void
-gtk_cell_area_box_context_reset (GtkCellAreaContext *context)
+_gtk_cell_area_box_context_reset (GtkCellAreaContext *context)
 {
   GtkCellAreaBoxContext        *box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
   GtkCellAreaBoxContextPrivate *priv        = box_context->priv;
@@ -248,11 +246,11 @@ gtk_cell_area_box_context_reset (GtkCellAreaContext *context)
   g_hash_table_remove_all (priv->heights);
 
   GTK_CELL_AREA_CONTEXT_CLASS
-    (gtk_cell_area_box_context_parent_class)->reset (context);
+    (_gtk_cell_area_box_context_parent_class)->reset (context);
 }
 
 static void
-gtk_cell_area_box_context_sum (GtkCellAreaBoxContext *context,
+_gtk_cell_area_box_context_sum (GtkCellAreaBoxContext *context,
                                GtkOrientation         orientation,
                                gint                   for_size,
                                gint                  *minimum_size,
@@ -275,8 +273,8 @@ gtk_cell_area_box_context_sum (GtkCellAreaBoxContext *context,
   for (i = array->len - 1; i >= 0; i--)
     {
       if (priv->align[i] && 
-         _gtk_cell_area_box_group_visible (area, i))
-       break;
+          _gtk_cell_area_box_group_visible (area, i))
+        break;
     }
   last_aligned_group_idx = i >= 0 ? i : 0;
 
@@ -286,9 +284,9 @@ gtk_cell_area_box_context_sum (GtkCellAreaBoxContext *context,
 
       if (box_orientation == orientation)
         {
-         if (i > last_aligned_group_idx &&
-             !_gtk_cell_area_box_group_visible (area, i))
-           continue;
+          if (i > last_aligned_group_idx &&
+              !_gtk_cell_area_box_group_visible (area, i))
+            continue;
 
           /* Dont add spacing for 0 size groups, they can be 0 size because
            * they contain only invisible cells for this round of requests
@@ -324,22 +322,22 @@ gtk_cell_area_box_context_sum (GtkCellAreaBoxContext *context,
 }
 
 static void
-gtk_cell_area_box_context_get_preferred_height_for_width (GtkCellAreaContext *context,
+_gtk_cell_area_box_context_get_preferred_height_for_width (GtkCellAreaContext *context,
                                                           gint                width,
                                                           gint               *minimum_height,
                                                           gint               *natural_height)
 {
-  gtk_cell_area_box_context_sum (GTK_CELL_AREA_BOX_CONTEXT (context), GTK_ORIENTATION_VERTICAL, 
+  _gtk_cell_area_box_context_sum (GTK_CELL_AREA_BOX_CONTEXT (context), GTK_ORIENTATION_VERTICAL, 
                                  width, minimum_height, natural_height);
 }
 
 static void
-gtk_cell_area_box_context_get_preferred_width_for_height (GtkCellAreaContext *context,
+_gtk_cell_area_box_context_get_preferred_width_for_height (GtkCellAreaContext *context,
                                                           gint                height,
                                                           gint               *minimum_width,
                                                           gint               *natural_width)
 {
-  gtk_cell_area_box_context_sum (GTK_CELL_AREA_BOX_CONTEXT (context), GTK_ORIENTATION_HORIZONTAL, 
+  _gtk_cell_area_box_context_sum (GTK_CELL_AREA_BOX_CONTEXT (context), GTK_ORIENTATION_HORIZONTAL, 
                                  height, minimum_width, natural_width);
 }
 
@@ -377,7 +375,7 @@ for_size_copy (gpointer    key,
 }
 
 GtkCellAreaBoxContext *
-gtk_cell_area_box_context_copy (GtkCellAreaBox        *box,
+_gtk_cell_area_box_context_copy (GtkCellAreaBox        *box,
                                 GtkCellAreaBoxContext *context)
 {
   GtkCellAreaBoxContext *copy;
@@ -385,10 +383,10 @@ gtk_cell_area_box_context_copy (GtkCellAreaBox        *box,
   copy = g_object_new (GTK_TYPE_CELL_AREA_BOX_CONTEXT,
                        "area", box, NULL);
 
-  gtk_cell_area_box_init_groups (copy,
-                                 context->priv->base_widths->len,
-                                 context->priv->expand,
-                                context->priv->align);
+  _gtk_cell_area_box_init_groups (copy,
+                                  context->priv->base_widths->len,
+                                  context->priv->expand,
+                                  context->priv->align);
 
   /* Copy the base arrays */
   copy_size_array (context->priv->base_widths,
@@ -407,10 +405,10 @@ gtk_cell_area_box_context_copy (GtkCellAreaBox        *box,
 }
 
 void
-gtk_cell_area_box_init_groups (GtkCellAreaBoxContext *box_context,
-                               guint                  n_groups,
-                               gboolean              *expand_groups,
-                              gboolean              *align_groups)
+_gtk_cell_area_box_init_groups (GtkCellAreaBoxContext *box_context,
+                                guint                  n_groups,
+                                gboolean              *expand_groups,
+                                gboolean              *align_groups)
 {
   GtkCellAreaBoxContextPrivate *priv;
 
@@ -434,7 +432,7 @@ gtk_cell_area_box_init_groups (GtkCellAreaBoxContext *box_context,
 }
 
 void
-gtk_cell_area_box_context_push_group_width (GtkCellAreaBoxContext *box_context,
+_gtk_cell_area_box_context_push_group_width (GtkCellAreaBoxContext *box_context,
                                             gint                   group_idx,
                                             gint                   minimum_width,
                                             gint                   natural_width)
@@ -461,11 +459,11 @@ gtk_cell_area_box_context_push_group_width (GtkCellAreaBoxContext *box_context,
     }
 
   if (grew)
-    gtk_cell_area_box_context_sum (box_context, GTK_ORIENTATION_HORIZONTAL, -1, NULL, NULL);
+    _gtk_cell_area_box_context_sum (box_context, GTK_ORIENTATION_HORIZONTAL, -1, NULL, NULL);
 }
 
 void
-gtk_cell_area_box_context_push_group_height_for_width  (GtkCellAreaBoxContext *box_context,
+_gtk_cell_area_box_context_push_group_height_for_width  (GtkCellAreaBoxContext *box_context,
                                                         gint                   group_idx,
                                                         gint                   for_width,
                                                         gint                   minimum_height,
@@ -493,7 +491,7 @@ gtk_cell_area_box_context_push_group_height_for_width  (GtkCellAreaBoxContext *b
 }
 
 void
-gtk_cell_area_box_context_push_group_height (GtkCellAreaBoxContext *box_context,
+_gtk_cell_area_box_context_push_group_height (GtkCellAreaBoxContext *box_context,
                                              gint                   group_idx,
                                              gint                   minimum_height,
                                              gint                   natural_height)
@@ -520,11 +518,11 @@ gtk_cell_area_box_context_push_group_height (GtkCellAreaBoxContext *box_context,
     }
 
   if (grew)
-    gtk_cell_area_box_context_sum (box_context, GTK_ORIENTATION_VERTICAL, -1, NULL, NULL);
+    _gtk_cell_area_box_context_sum (box_context, GTK_ORIENTATION_VERTICAL, -1, NULL, NULL);
 }
 
 void
-gtk_cell_area_box_context_push_group_width_for_height (GtkCellAreaBoxContext *box_context,
+_gtk_cell_area_box_context_push_group_width_for_height (GtkCellAreaBoxContext *box_context,
                                                        gint                   group_idx,
                                                        gint                   for_height,
                                                        gint                   minimum_width,
@@ -552,7 +550,7 @@ gtk_cell_area_box_context_push_group_width_for_height (GtkCellAreaBoxContext *bo
 }
 
 void
-gtk_cell_area_box_context_get_group_width (GtkCellAreaBoxContext *box_context,
+_gtk_cell_area_box_context_get_group_width (GtkCellAreaBoxContext *box_context,
                                            gint                   group_idx,
                                            gint                  *minimum_width,
                                            gint                  *natural_width)
@@ -575,7 +573,7 @@ gtk_cell_area_box_context_get_group_width (GtkCellAreaBoxContext *box_context,
 }
 
 void
-gtk_cell_area_box_context_get_group_height_for_width (GtkCellAreaBoxContext *box_context,
+_gtk_cell_area_box_context_get_group_height_for_width (GtkCellAreaBoxContext *box_context,
                                                       gint                   group_idx,
                                                       gint                   for_width,
                                                       gint                  *minimum_height,
@@ -612,7 +610,7 @@ gtk_cell_area_box_context_get_group_height_for_width (GtkCellAreaBoxContext *box
 }
 
 void
-gtk_cell_area_box_context_get_group_height (GtkCellAreaBoxContext *box_context,
+_gtk_cell_area_box_context_get_group_height (GtkCellAreaBoxContext *box_context,
                                             gint                   group_idx,
                                             gint                  *minimum_height,
                                             gint                  *natural_height)
@@ -635,7 +633,7 @@ gtk_cell_area_box_context_get_group_height (GtkCellAreaBoxContext *box_context,
 }
 
 void
-gtk_cell_area_box_context_get_group_width_for_height (GtkCellAreaBoxContext *box_context,
+_gtk_cell_area_box_context_get_group_width_for_height (GtkCellAreaBoxContext *box_context,
                                                       gint                   group_idx,
                                                       gint                   for_height,
                                                       gint                  *minimum_width,
@@ -672,8 +670,8 @@ gtk_cell_area_box_context_get_group_width_for_height (GtkCellAreaBoxContext *box
 }
 
 static GtkRequestedSize *
-gtk_cell_area_box_context_get_requests (GtkCellAreaBoxContext *box_context,
-                                       GtkCellAreaBox        *area,
+_gtk_cell_area_box_context_get_requests (GtkCellAreaBoxContext *box_context,
+                                        GtkCellAreaBox        *area,
                                         GtkOrientation         orientation,
                                         gint                   for_size,
                                         gint                  *n_requests)
@@ -691,8 +689,8 @@ gtk_cell_area_box_context_get_requests (GtkCellAreaBoxContext *box_context,
   for (i = priv->base_widths->len - 1; i >= 0; i--)
     {
       if (priv->align[i] && 
-         _gtk_cell_area_box_group_visible (area, i))
-       break;
+          _gtk_cell_area_box_group_visible (area, i))
+        break;
     }
   last_aligned_group_idx = i >= 0 ? i : 0;
 
@@ -704,9 +702,9 @@ gtk_cell_area_box_context_get_requests (GtkCellAreaBoxContext *box_context,
       size = &g_array_index (array, CachedSize, i);
 
       if (size->nat_size > 0 &&
-         (i <= last_aligned_group_idx ||
-          _gtk_cell_area_box_group_visible (area, i)))
-       visible_groups++;
+          (i <= last_aligned_group_idx ||
+           _gtk_cell_area_box_group_visible (area, i)))
+        visible_groups++;
     }
 
   requests = g_new (GtkRequestedSize, visible_groups);
@@ -716,8 +714,8 @@ gtk_cell_area_box_context_get_requests (GtkCellAreaBoxContext *box_context,
       size = &g_array_index (array, CachedSize, i);
 
       if (size->nat_size > 0 &&
-         (i <= last_aligned_group_idx ||
-          _gtk_cell_area_box_group_visible (area, i)))
+          (i <= last_aligned_group_idx ||
+           _gtk_cell_area_box_group_visible (area, i)))
         {
           requests[j].data         = GINT_TO_POINTER (i);
           requests[j].minimum_size = size->min_size;
@@ -734,7 +732,7 @@ gtk_cell_area_box_context_get_requests (GtkCellAreaBoxContext *box_context,
 
 static GtkCellAreaBoxAllocation *
 allocate_for_orientation (GtkCellAreaBoxContext *context,
-                         GtkCellAreaBox        *area,
+                          GtkCellAreaBox        *area,
                           GtkOrientation         orientation,
                           gint                   spacing,
                           gint                   size,
@@ -744,14 +742,12 @@ allocate_for_orientation (GtkCellAreaBoxContext *context,
   GtkCellAreaBoxContextPrivate *priv = context->priv;
   GtkCellAreaBoxAllocation     *allocs;
   GtkRequestedSize             *sizes;
-  GArray                       *array;
   gint                          n_expand_groups = 0;
   gint                          i, n_groups, position, vis_position;
   gint                          extra_size, extra_extra;
   gint                          avail_size = size;
 
-  sizes           = gtk_cell_area_box_context_get_requests (context, area, orientation, for_size, &n_groups);
-  array           = get_array (context, orientation, for_size);
+  sizes           = _gtk_cell_area_box_context_get_requests (context, area, orientation, for_size, &n_groups);
   n_expand_groups = count_expand_groups (context);
 
   /* First start by naturally allocating space among groups */
@@ -780,7 +776,7 @@ allocate_for_orientation (GtkCellAreaBoxContext *context,
       allocs[i].group_idx = GPOINTER_TO_INT (sizes[i].data);
 
       if (priv->align[allocs[i].group_idx])
-       vis_position = position;
+        vis_position = position;
 
       allocs[i].position  = vis_position;
       allocs[i].size      = sizes[i].minimum_size;
@@ -799,10 +795,10 @@ allocate_for_orientation (GtkCellAreaBoxContext *context,
       position += spacing;
 
       if (_gtk_cell_area_box_group_visible (area, allocs[i].group_idx))
-       {
-         vis_position += allocs[i].size;
-         vis_position += spacing;
-       }
+        {
+          vis_position += allocs[i].size;
+          vis_position += spacing;
+        }
     }
 
   if (n_allocs)
@@ -814,25 +810,25 @@ allocate_for_orientation (GtkCellAreaBoxContext *context,
 }
 
 GtkRequestedSize *
-gtk_cell_area_box_context_get_widths (GtkCellAreaBoxContext *box_context,
+_gtk_cell_area_box_context_get_widths (GtkCellAreaBoxContext *box_context,
                                       gint                  *n_widths)
 {
   GtkCellAreaBox *area = (GtkCellAreaBox *)gtk_cell_area_context_get_area (GTK_CELL_AREA_CONTEXT (box_context));
 
-  return gtk_cell_area_box_context_get_requests (box_context, area, GTK_ORIENTATION_HORIZONTAL, -1, n_widths);
+  return _gtk_cell_area_box_context_get_requests (box_context, area, GTK_ORIENTATION_HORIZONTAL, -1, n_widths);
 }
 
 GtkRequestedSize *
-gtk_cell_area_box_context_get_heights (GtkCellAreaBoxContext *box_context,
+_gtk_cell_area_box_context_get_heights (GtkCellAreaBoxContext *box_context,
                                        gint                  *n_heights)
 {
   GtkCellAreaBox *area = (GtkCellAreaBox *)gtk_cell_area_context_get_area (GTK_CELL_AREA_CONTEXT (box_context));
 
-  return gtk_cell_area_box_context_get_requests (box_context, area, GTK_ORIENTATION_VERTICAL, -1, n_heights);
+  return _gtk_cell_area_box_context_get_requests (box_context, area, GTK_ORIENTATION_VERTICAL, -1, n_heights);
 }
 
 GtkCellAreaBoxAllocation *
-gtk_cell_area_box_context_get_orientation_allocs (GtkCellAreaBoxContext *context,
+_gtk_cell_area_box_context_get_orientation_allocs (GtkCellAreaBoxContext *context,
                                                   gint                  *n_allocs)
 {
   GtkCellAreaContext       *ctx  = GTK_CELL_AREA_CONTEXT (context);
@@ -849,12 +845,12 @@ gtk_cell_area_box_context_get_orientation_allocs (GtkCellAreaBoxContext *context
 
   if (orientation == GTK_ORIENTATION_HORIZONTAL && width > 0)
     allocs = allocate_for_orientation (context, area, orientation, 
-                                      spacing, width, height,
-                                      &alloc_count);
+                                       spacing, width, height,
+                                       &alloc_count);
   else if (orientation == GTK_ORIENTATION_VERTICAL && height > 0)
     allocs = allocate_for_orientation (context, area, orientation, 
-                                      spacing, height, width,
-                                      &alloc_count);
+                                       spacing, height, width,
+                                       &alloc_count);
 
   *n_allocs = alloc_count;