Re: [gnome-db] GnomeDbGrid hide column



Here is the patch,

Please check the code, I am definitely not a specialist ;-)

Phil

Le ven 16/01/2004 à 14:23, Philippe CHARLIER a écrit :
> Hi,
> 
> I saw in the latest CVS version that the functions:
> 
> gnome_db_grid_hide_column (...)
> gnome_db_grid_show_column (...)
> 
> are present in gnome-db-grid.h but not implemented in gnome-db-grid.c
> 
> I made the two functions:
> 
> gnome_db_grid_set_column_visible (...)
> gnome_db_grid_get_column_visible (...)
> 
> In fact only the first one is working now, but I will finish the second
> one soon.
> 
> First, I personally find that this naming of the functions is more
> coherent with the other functions (like gnome_db_grid_set_show_title).
> 
> Secondly, 

--<SNIP>--
? out.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgnomedb/ChangeLog,v
retrieving revision 1.284
diff -u -p -r1.284 ChangeLog
--- ChangeLog	13 Jan 2004 10:53:26 -0000	1.284
+++ ChangeLog	16 Jan 2004 19:08:48 -0000
@@ -1,3 +1,8 @@
+2004-01-16  Philippe Charlier <p charlier chello be>
+
+    * libgnomedb/gnome-db-grid.[ch] (gnome_db_grid_set_column_visible,
+	gnome_db_grid_get_column_visible): new API functions.
+
 2004.01-13  Rodrigo Moya <rodrigo gnome-db org>
 
 	* libgnomedb/gnome-db-data-source-selector.h: fixed argument name that
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 19:08:49 -0000
@@ -1206,6 +1206,63 @@ 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;
+	GList *list = NULL;
+
+	g_return_if_fail (GNOME_DB_IS_GRID (grid));
+
+	list = gtk_tree_view_get_columns (GTK_TREE_VIEW (grid->priv->tree_view));
+	g_return_if_fail (list != NULL);
+
+	number_columns = g_list_length (list);
+	g_list_free (list);
+	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;
+	GList *list = NULL;
+
+	g_return_val_if_fail (GNOME_DB_IS_GRID (grid), FALSE);
+
+	list = gtk_tree_view_get_columns (GTK_TREE_VIEW (grid->priv->tree_view));
+	g_return_val_if_fail (list != NULL, FALSE);
+
+	number_columns = g_list_length (list);
+	g_list_free (list);
+	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;
Index: libgnomedb/gnome-db-grid.h
===================================================================
RCS file: /cvs/gnome/libgnomedb/libgnomedb/gnome-db-grid.h,v
retrieving revision 1.19
diff -u -p -r1.19 gnome-db-grid.h
--- libgnomedb/gnome-db-grid.h	4 Jan 2004 20:49:03 -0000	1.19
+++ libgnomedb/gnome-db-grid.h	16 Jan 2004 19:08:49 -0000
@@ -88,8 +88,8 @@ gboolean         gnome_db_grid_get_colum
 	(gnome_db_grid_set_column_titles_visible (grid, TRUE))
 #define gnome_db_grid_hide_column_titles(grid) \
 	(gnome_db_grid_set_column_titles_visible (grid, FALSE))
-void             gnome_db_grid_hide_column (GnomeDbGrid *grid, gint col);
-void             gnome_db_grid_show_column (GnomeDbGrid *grid, gint col);
+void             gnome_db_grid_set_column_visible (GnomeDbGrid *grid, gint col, gboolean visible);
+gboolean         gnome_db_grid_get_column_visible (GnomeDbGrid *grid, gint col);
 
 gpointer         gnome_db_grid_get_row_data (GnomeDbGrid *grid, gint row);
 void             gnome_db_grid_set_row_data (GnomeDbGrid *grid, gint row, gpointer data);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]