]> saetta.ns0.it Git - libgdaex/commitdiff
Implemented GdaExGrid::add_column, GdaExGrid::add_columns and GdaExGrid::clear.
authorAndrea Zagli <azagli@libero.it>
Mon, 27 Dec 2010 16:22:24 +0000 (17:22 +0100)
committerAndrea Zagli <azagli@libero.it>
Mon, 27 Dec 2010 16:22:24 +0000 (17:22 +0100)
src/grid.c

index 10cf8b4e93bc8c61229110a18d94c87a36af8e5b..765e541a64061b5fee54e36fe8eb4b27e34e1ce7 100644 (file)
@@ -70,6 +70,8 @@ static void
 gdaex_grid_init (GdaExGrid *gdaex_grid)
 {
        GdaExGridPrivate *priv = GDAEX_GRID_GET_PRIVATE (gdaex_grid);
+
+       priv->columns = g_ptr_array_new ();
 }
 
 GdaExGrid
@@ -82,6 +84,57 @@ GdaExGrid
        return gdaex_grid;
 }
 
+void
+gdaex_grid_add_column (GdaExGrid *grid, GdaExGridColumn *column)
+{
+       GdaExGridPrivate *priv;
+
+       g_return_if_fail (GDAEX_IS_GRID (grid));
+       g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+       priv = GDAEX_GRID_GET_PRIVATE (grid);
+
+       g_ptr_array_add (priv->columns, g_memdup (column, sizeof (GdaExGridColumn)))
+}
+
+void
+gdaex_grid_add_columns (GdaExGrid *grid, GSList *columns)
+{
+       GSList *first;
+
+       g_return_if_fail (GDAEX_IS_GRID (grid));
+       g_return_if_fail (G_IS_SLIST (columns));
+
+       first = columns;
+       while (first != NULL)
+               {
+                       gdaex_grid_add_column (grid, (GdaExGridColumn *)first->data);
+                       first = g_slist_next (first);
+               }
+}
+
+void
+gdaex_grid_clear (GdaExGrid *grid)
+{
+       GdaExGridPrivate *priv;
+
+       guint col;
+
+       g_return_if_fail (GDAEX_IS_GRID (grid));
+
+       priv = GDAEX_GRID_GET_PRIVATE (grid);
+
+       for (col = 0; priv->columns->len; col++)
+               {
+                       g_object_unref (g_ptr_array_index (priv->columns, col));
+               }
+
+       g_ptr_array_remove_range (priv->columns, 0, priv->columns->len);
+       g_ptr_array_unref (priv->columns);
+
+       priv->columns = g_ptr_array_new ();
+}
+
 /* PRIVATE */
 static void
 gdaex_grid_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)