]> saetta.ns0.it Git - libgdaexgrid/commitdiff
Added function Grid::get_column_by_field_name. html
authorAndrea Zagli <andrea.zagli@email.it>
Sun, 28 Mar 2021 18:39:17 +0000 (20:39 +0200)
committerAndrea Zagli <andrea.zagli@email.it>
Sun, 28 Mar 2021 18:39:17 +0000 (20:39 +0200)
src/grid.c
src/grid.h

index e069bbe1063f7ed1e0c635b64e80be2f31f92e83..eaeda439ae5d6de225dc1a072d1fd45992beac14 100644 (file)
@@ -457,6 +457,41 @@ gdaex_grid_add_columns (GdaExGrid *grid, GSList *columns)
                }
 }
 
+/**
+ * gdaex_grid_get_column_by_field_name:
+ * @grid:
+ * @field_name:
+ *
+ * Returns: the #GdaExGridColumn with the specified @field_name.
+ */
+GdaExGridColumn
+*gdaex_grid_get_column_by_field_name (GdaExGrid *grid, const gchar *field_name)
+
+{
+       GdaExGridPrivate *priv;
+
+       GdaExGridColumn *gcol;
+
+       guint col;
+
+       g_return_val_if_fail (GDAEX_IS_GRID (grid), NULL);
+
+       priv = gdaex_grid_get_instance_private (grid);
+
+       gcol = NULL;
+
+       for (col = 0; priv->columns->len; col++)
+               {
+                       if (g_strcmp0 (gdaex_grid_column_get_field_name ((GdaExGridColumn *)g_ptr_array_index (priv->columns, col)), field_name) == 0)
+                               {
+                                       gcol = (GdaExGridColumn *)g_ptr_array_index (priv->columns, col);
+                                       break;
+                               }
+               }
+
+       return gcol;
+}
+
 /**
  * gdaex_grid_clear:
  * @grid: a #GdaExGrid object.
index 09bdcc88aacf4c2a881edb69555dd547b049269b..2dcf438a76446d7ace455b5798163e93766c5ac5 100644 (file)
@@ -71,6 +71,8 @@ const gchar *gdaex_grid_get_title (GdaExGrid *grid);
 void gdaex_grid_add_column (GdaExGrid *grid, GdaExGridColumn *column);
 void gdaex_grid_add_columns (GdaExGrid *grid, GSList *columns);
 
+GdaExGridColumn *gdaex_grid_get_column_by_field_name (GdaExGrid *grid, const gchar *field_name);
+
 void gdaex_grid_clear (GdaExGrid *grid);
 
 GtkWidget *gdaex_grid_get_widget (GdaExGrid *grid);