Re: [gnome-db] GnomeDbGrid hide column
- From: Rodrigo Moya <rodrigo gnome-db org>
- To: Philippe CHARLIER <p charlier chello be>
- Cc: GDA <gnome-db-list gnome org>
- Subject: Re: [gnome-db] GnomeDbGrid hide column
- Date: Fri, 16 Jan 2004 23:43:15 +0100
On Fri, 2004-01-16 at 20:13 +0100, Philippe CHARLIER wrote:
> Here is the patch,
>
> Please check the code, I am definitely not a specialist ;-)
>
looks ok, except for the way to retrieve the number of columns. I
replaced the gtk_tree_view_get_columns call and related code with a call
to gda_data_model_get_n_columns, as you can see in the attached patch,
which is what I've committed to CVS.
cheers
Index: libgnomedb/gnome-db-grid.c
===================================================================
RCS file: /cvs/gnome/libgnomedb/libgnomedb/gnome-db-grid.c,v
retrieving revision 1.54
diff -u -p -r1.54 gnome-db-grid.c
--- libgnomedb/gnome-db-grid.c 6 Jan 2004 11:33:18 -0000 1.54
+++ libgnomedb/gnome-db-grid.c 16 Jan 2004 22:42:59 -0000
@@ -826,7 +826,7 @@ gnome_db_grid_set_column_title(GnomeDbGr
* Returns: the title of a column.
*/
const gchar *
-gnome_db_grid_get_column_title(GnomeDbGrid *grid, gint col)
+gnome_db_grid_get_column_title (GnomeDbGrid *grid, gint col)
{
GtkTreeViewColumn *column = NULL;
gchar *title = NULL;
@@ -834,6 +834,7 @@ gnome_db_grid_get_column_title(GnomeDbGr
g_return_val_if_fail (GNOME_DB_IS_GRID (grid), NULL);
column = gtk_tree_view_get_column (GTK_TREE_VIEW (grid->priv->tree_view), col);
title = gtk_tree_view_column_get_title (column);
+
return title;
}
@@ -1206,6 +1207,53 @@ gnome_db_grid_set_row_data (GnomeDbGrid
g_hash_table_insert (grid->priv->row_data, GINT_TO_POINTER (row + 1), data);
}
+/**
+ * gnome_db_grid_set_column_visible
+ * @grid: a #GnomeDbGrid widget.
+ * @col: column number.
+ * @visible: a gboolean.
+ *
+ * Hide or Show the column "col" of the #GnomeDbGrid widget.
+ */
+void
+gnome_db_grid_set_column_visible (GnomeDbGrid *grid, gint col, gboolean visible)
+{
+ GtkTreeViewColumn *column = NULL;
+ gint number_columns;
+
+ g_return_if_fail (GNOME_DB_IS_GRID (grid));
+
+ number_columns = gda_data_model_get_n_columns (grid->priv->model);
+ if (col >= 0 && col < number_columns) {
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (grid->priv->tree_view), col);
+ gtk_tree_view_column_set_visible (column, visible);
+ }
+}
+
+/**
+ * gnome_db_grid_get_column_visible
+ * @grid: a #GnomeDbGrid widget.
+ * @col: column number.
+ *
+ * Retrieve a gboolean ( TRUE or FALSE ).
+ */
+gboolean
+gnome_db_grid_get_column_visible (GnomeDbGrid *grid, gint col)
+{
+ GtkTreeViewColumn *column = NULL;
+ gint number_columns;
+
+ g_return_val_if_fail (GNOME_DB_IS_GRID (grid), FALSE);
+
+ number_columns = gda_data_model_get_n_columns (grid->priv->model);
+ if (col >= 0 && col < number_columns) {
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (grid->priv->tree_view), col);
+ return gtk_tree_view_column_get_visible (column);
+ }
+
+ return FALSE;
+}
+
typedef struct {
gint row;
gpointer search_data;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]