]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktable.c
Merge branch 'master' into toolpalette
[~andy/gtk] / gtk / gtktable.c
index d8bf67e4233757a6db3aa47486b363005808ff8b..a5d4b95f640f10a081b787e5f3e9129b5d9eb325 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <config.h>
-#include "gtkalias.h"
+#include "config.h"
 #include "gtktable.h"
+#include "gtkprivate.h"
 #include "gtkintl.h"
+#include "gtkalias.h"
 
 enum
 {
@@ -53,8 +54,6 @@ enum
 };
   
 
-static void gtk_table_class_init    (GtkTableClass  *klass);
-static void gtk_table_init         (GtkTable       *table);
 static void gtk_table_finalize     (GObject        *object);
 static void gtk_table_size_request  (GtkWidget     *widget,
                                     GtkRequisition *requisition);
@@ -99,35 +98,7 @@ static void gtk_table_size_allocate_pass1 (GtkTable *table);
 static void gtk_table_size_allocate_pass2 (GtkTable *table);
 
 
-static GtkContainerClass *parent_class = NULL;
-
-
-GType
-gtk_table_get_type (void)
-{
-  static GType table_type = 0;
-  
-  if (!table_type)
-    {
-      static const GTypeInfo table_info =
-      {
-       sizeof (GtkTableClass),
-       NULL,
-       NULL,
-       (GClassInitFunc) gtk_table_class_init,
-       NULL,
-       NULL,
-       sizeof (GtkTable),
-       0,
-       (GInstanceInitFunc) gtk_table_init,
-      };
-      
-      table_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkTable",
-                                          &table_info, 0);
-    }
-  
-  return table_type;
-}
+G_DEFINE_TYPE (GtkTable, gtk_table, GTK_TYPE_CONTAINER)
 
 static void
 gtk_table_class_init (GtkTableClass *class)
@@ -136,8 +107,6 @@ gtk_table_class_init (GtkTableClass *class)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
   
-  parent_class = g_type_class_peek_parent (class);
-
   gobject_class->finalize = gtk_table_finalize;
 
   gobject_class->get_property = gtk_table_get_property;
@@ -156,104 +125,104 @@ gtk_table_class_init (GtkTableClass *class)
 
   g_object_class_install_property (gobject_class,
                                    PROP_N_ROWS,
-                                   g_param_spec_uint ("n_rows",
+                                   g_param_spec_uint ("n-rows",
                                                     P_("Rows"),
                                                     P_("The number of rows in the table"),
-                                                    0,
-                                                    G_MAXUINT,
-                                                    0,
-                                                    G_PARAM_READWRITE));
+                                                    1,
+                                                    65535,
+                                                    1,
+                                                    GTK_PARAM_READWRITE));
   g_object_class_install_property (gobject_class,
                                    PROP_N_COLUMNS,
-                                   g_param_spec_uint ("n_columns",
+                                   g_param_spec_uint ("n-columns",
                                                     P_("Columns"),
                                                     P_("The number of columns in the table"),
-                                                    0,
-                                                    G_MAXUINT,
-                                                    0,
-                                                    G_PARAM_READWRITE));
+                                                    1,
+                                                    65535,
+                                                    1,
+                                                    GTK_PARAM_READWRITE));
   g_object_class_install_property (gobject_class,
                                    PROP_ROW_SPACING,
-                                   g_param_spec_uint ("row_spacing",
+                                   g_param_spec_uint ("row-spacing",
                                                     P_("Row spacing"),
                                                     P_("The amount of space between two consecutive rows"),
                                                     0,
-                                                    G_MAXUINT,
+                                                    65535,
                                                     0,
-                                                    G_PARAM_READWRITE));
+                                                    GTK_PARAM_READWRITE));
   g_object_class_install_property (gobject_class,
                                    PROP_COLUMN_SPACING,
-                                   g_param_spec_uint ("column_spacing",
+                                   g_param_spec_uint ("column-spacing",
                                                     P_("Column spacing"),
                                                     P_("The amount of space between two consecutive columns"),
                                                     0,
-                                                    G_MAXUINT,
+                                                    65535,
                                                     0,
-                                                    G_PARAM_READWRITE));
+                                                    GTK_PARAM_READWRITE));
   g_object_class_install_property (gobject_class,
                                    PROP_HOMOGENEOUS,
                                    g_param_spec_boolean ("homogeneous",
-                                                        P_("Homogenous"),
-                                                        P_("If TRUE this means the table cells are all the same width/height"),
+                                                        P_("Homogeneous"),
+                                                        P_("If TRUE, the table cells are all the same width/height"),
                                                         FALSE,
-                                                        G_PARAM_READWRITE));
+                                                        GTK_PARAM_READWRITE));
 
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_LEFT_ATTACH,
-                                             g_param_spec_uint ("left_attach", 
+                                             g_param_spec_uint ("left-attach", 
                                                                 P_("Left attachment"), 
                                                                 P_("The column number to attach the left side of the child to"),
                                                                 0, 65535, 0,
-                                                                G_PARAM_READWRITE));
+                                                                GTK_PARAM_READWRITE));
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_RIGHT_ATTACH,
-                                             g_param_spec_uint ("right_attach", 
+                                             g_param_spec_uint ("right-attach", 
                                                                 P_("Right attachment"), 
                                                                 P_("The column number to attach the right side of a child widget to"),
                                                                 1, 65535, 1,
-                                                                G_PARAM_READWRITE));
+                                                                GTK_PARAM_READWRITE));
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_TOP_ATTACH,
-                                             g_param_spec_uint ("top_attach", 
+                                             g_param_spec_uint ("top-attach", 
                                                                 P_("Top attachment"), 
                                                                 P_("The row number to attach the top of a child widget to"),
                                                                 0, 65535, 0,
-                                                                G_PARAM_READWRITE));
+                                                                GTK_PARAM_READWRITE));
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_BOTTOM_ATTACH,
-                                             g_param_spec_uint ("bottom_attach",
+                                             g_param_spec_uint ("bottom-attach",
                                                                 P_("Bottom attachment"), 
                                                                 P_("The row number to attach the bottom of the child to"),
                                                                 1, 65535, 1,
-                                                                G_PARAM_READWRITE));
+                                                                GTK_PARAM_READWRITE));
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_X_OPTIONS,
-                                             g_param_spec_flags ("x_options", 
+                                             g_param_spec_flags ("x-options", 
                                                                  P_("Horizontal options"), 
                                                                  P_("Options specifying the horizontal behaviour of the child"),
                                                                  GTK_TYPE_ATTACH_OPTIONS, GTK_EXPAND | GTK_FILL,
-                                                                 G_PARAM_READWRITE));
+                                                                 GTK_PARAM_READWRITE));
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_Y_OPTIONS,
-                                             g_param_spec_flags ("y_options", 
+                                             g_param_spec_flags ("y-options", 
                                                                  P_("Vertical options"), 
                                                                  P_("Options specifying the vertical behaviour of the child"),
                                                                  GTK_TYPE_ATTACH_OPTIONS, GTK_EXPAND | GTK_FILL,
-                                                                 G_PARAM_READWRITE));
+                                                                 GTK_PARAM_READWRITE));
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_X_PADDING,
-                                             g_param_spec_uint ("x_padding", 
+                                             g_param_spec_uint ("x-padding", 
                                                                 P_("Horizontal padding"), 
                                                                 P_("Extra space to put between the child and its left and right neighbors, in pixels"),
                                                                 0, 65535, 0,
-                                                                G_PARAM_READWRITE));
+                                                                GTK_PARAM_READWRITE));
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_Y_PADDING,
-                                             g_param_spec_uint ("y_padding", 
+                                             g_param_spec_uint ("y-padding", 
                                                                 P_("Vertical padding"), 
                                                                 P_("Extra space to put between the child and its upper and lower neighbors, in pixels"),
                                                                 0, 65535, 0,
-                                                                G_PARAM_READWRITE));
+                                                                GTK_PARAM_READWRITE));
 }
 
 static GType
@@ -513,8 +482,8 @@ gtk_table_resize (GtkTable *table,
                  guint     n_cols)
 {
   g_return_if_fail (GTK_IS_TABLE (table));
-  g_return_if_fail (n_rows > 0 && n_rows < 65536);
-  g_return_if_fail (n_cols > 0 && n_cols < 65536);
+  g_return_if_fail (n_rows > 0 && n_rows <= 65535);
+  g_return_if_fail (n_cols > 0 && n_cols <= 65535);
 
   n_rows = MAX (n_rows, 1);
   n_cols = MAX (n_cols, 1);
@@ -553,7 +522,7 @@ gtk_table_resize (GtkTable *table,
              table->rows[i].shrink = 0;
            }
 
-         g_object_notify (G_OBJECT (table), "n_rows");
+         g_object_notify (G_OBJECT (table), "n-rows");
        }
 
       if (n_cols != table->ncols)
@@ -575,7 +544,7 @@ gtk_table_resize (GtkTable *table,
              table->cols[i].shrink = 0;
            }
 
-         g_object_notify (G_OBJECT (table), "n_columns");
+         g_object_notify (G_OBJECT (table), "n-columns");
        }
     }
 }
@@ -734,7 +703,7 @@ gtk_table_set_row_spacings (GtkTable *table,
   if (GTK_WIDGET_VISIBLE (table))
     gtk_widget_queue_resize (GTK_WIDGET (table));
 
-  g_object_notify (G_OBJECT (table), "row_spacing");
+  g_object_notify (G_OBJECT (table), "row-spacing");
 }
 
 /**
@@ -745,7 +714,7 @@ gtk_table_set_row_spacings (GtkTable *table,
  * the spacing that will be used for newly added rows.
  * (See gtk_table_set_row_spacings())
  *
- * Returns value: the default row spacing
+ * Return value: the default row spacing
  **/
 guint
 gtk_table_get_default_row_spacing (GtkTable *table)
@@ -770,7 +739,7 @@ gtk_table_set_col_spacings (GtkTable *table,
   if (GTK_WIDGET_VISIBLE (table))
     gtk_widget_queue_resize (GTK_WIDGET (table));
 
-  g_object_notify (G_OBJECT (table), "column_spacing");
+  g_object_notify (G_OBJECT (table), "column-spacing");
 }
 
 /**
@@ -781,7 +750,7 @@ gtk_table_set_col_spacings (GtkTable *table,
  * the spacing that will be used for newly added columns.
  * (See gtk_table_set_col_spacings())
  *
- * Returns value: the default column spacing
+ * Return value: the default column spacing
  **/
 guint
 gtk_table_get_default_col_spacing (GtkTable *table)
@@ -829,30 +798,21 @@ gtk_table_get_homogeneous (GtkTable *table)
 static void
 gtk_table_finalize (GObject *object)
 {
-  GtkTable *table;
-  
-  g_return_if_fail (GTK_IS_TABLE (object));
-  
-  table = GTK_TABLE (object);
-  
+  GtkTable *table = GTK_TABLE (object);
+
   g_free (table->rows);
   g_free (table->cols);
   
-  G_OBJECT_CLASS (parent_class)->finalize (object);
+  G_OBJECT_CLASS (gtk_table_parent_class)->finalize (object);
 }
 
 static void
 gtk_table_size_request (GtkWidget      *widget,
                        GtkRequisition *requisition)
 {
-  GtkTable *table;
+  GtkTable *table = GTK_TABLE (widget);
   gint row, col;
-  
-  g_return_if_fail (GTK_IS_TABLE (widget));
-  g_return_if_fail (requisition != NULL);
-  
-  table = GTK_TABLE (widget);
-  
+
   requisition->width = 0;
   requisition->height = 0;
   
@@ -880,14 +840,10 @@ static void
 gtk_table_size_allocate (GtkWidget     *widget,
                         GtkAllocation *allocation)
 {
-  GtkTable *table;
-  
-  g_return_if_fail (GTK_IS_TABLE (widget));
-  g_return_if_fail (allocation != NULL);
-  
+  GtkTable *table = GTK_TABLE (widget);
+
   widget->allocation = *allocation;
-  table = GTK_TABLE (widget);
-  
+
   gtk_table_size_allocate_init (table);
   gtk_table_size_allocate_pass1 (table);
   gtk_table_size_allocate_pass2 (table);
@@ -897,9 +853,6 @@ static void
 gtk_table_add (GtkContainer *container,
               GtkWidget    *widget)
 {
-  g_return_if_fail (GTK_IS_TABLE (container));
-  g_return_if_fail (widget != NULL);
-  
   gtk_table_attach_defaults (GTK_TABLE (container), widget, 0, 1, 0, 1);
 }
 
@@ -907,14 +860,10 @@ static void
 gtk_table_remove (GtkContainer *container,
                  GtkWidget    *widget)
 {
-  GtkTable *table;
+  GtkTable *table = GTK_TABLE (container);
   GtkTableChild *child;
   GList *children;
-  
-  g_return_if_fail (GTK_IS_TABLE (container));
-  g_return_if_fail (widget != NULL);
-  
-  table = GTK_TABLE (container);
+
   children = table->children;
   
   while (children)
@@ -944,14 +893,10 @@ gtk_table_forall (GtkContainer *container,
                  GtkCallback   callback,
                  gpointer      callback_data)
 {
-  GtkTable *table;
+  GtkTable *table = GTK_TABLE (container);
   GtkTableChild *child;
   GList *children;
-  
-  g_return_if_fail (GTK_IS_TABLE (container));
-  g_return_if_fail (callback != NULL);
-  
-  table = GTK_TABLE (container);
+
   children = table->children;
   
   while (children)
@@ -1666,3 +1611,6 @@ gtk_table_size_allocate_pass2 (GtkTable *table)
        }
     }
 }
+
+#define __GTK_TABLE_C__
+#include "gtkaliasdef.c"