[libgda] GdauiRawGrid: make sure at least one column is shown
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdauiRawGrid: make sure at least one column is shown
- Date: Mon, 15 Dec 2014 21:29:17 +0000 (UTC)
commit 506e5dfe130583cc44cfd8d0aeef3b1b274ff452
Author: Vivien Malerba <malerba gnome-db org>
Date: Mon Dec 15 22:29:05 2014 +0100
GdauiRawGrid: make sure at least one column is shown
libgda-ui/gdaui-raw-grid.c | 50 ++++++++++++++++++++++++++-----------------
1 files changed, 30 insertions(+), 20 deletions(-)
---
diff --git a/libgda-ui/gdaui-raw-grid.c b/libgda-ui/gdaui-raw-grid.c
index 786cc28..7126ce5 100644
--- a/libgda-ui/gdaui-raw-grid.c
+++ b/libgda-ui/gdaui-raw-grid.c
@@ -1913,29 +1913,39 @@ tree_view_popup_button_pressed_cb (G_GNUC_UNUSED GtkWidget *widget, GdkEventButt
/* create the menu */
menu = gtk_menu_new ();
- mitem = gtk_menu_item_new_with_label (_("Shown columns"));
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mitem);
- gtk_widget_show (mitem);
-
- submenu = gtk_menu_new ();
- gtk_widget_show (submenu);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (mitem), submenu);
+
+ /* shown columns */
+ guint nentries = 0;
for (list = grid->priv->columns_data; list; list = list->next) {
ColumnData *cdata = (ColumnData*) list->data;
- gchar *tmp;
-
- if (cdata->prog_hidden)
- continue;
- tmp = remove_double_underscores (cdata->title);
- mitem = gtk_check_menu_item_new_with_label (tmp);
- g_free (tmp);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mitem), !cdata->hidden);
- gtk_menu_shell_append (GTK_MENU_SHELL (submenu), mitem);
+ if (! cdata->prog_hidden)
+ nentries ++;
+ }
+ if (nentries > 1) {
+ mitem = gtk_menu_item_new_with_label (_("Shown columns"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), mitem);
gtk_widget_show (mitem);
- g_object_set_data (G_OBJECT (mitem), "c", cdata);
- g_signal_connect (mitem, "toggled",
- G_CALLBACK (hidden_column_mitem_toggled_cb), grid);
+ submenu = gtk_menu_new ();
+ gtk_widget_show (submenu);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (mitem), submenu);
+ for (list = grid->priv->columns_data; list; list = list->next) {
+ ColumnData *cdata = (ColumnData*) list->data;
+ if (cdata->prog_hidden)
+ continue;
+
+ gchar *tmp;
+ tmp = remove_double_underscores (cdata->title);
+ mitem = gtk_check_menu_item_new_with_label (tmp);
+ g_free (tmp);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mitem), !cdata->hidden);
+ gtk_menu_shell_append (GTK_MENU_SHELL (submenu), mitem);
+ gtk_widget_show (mitem);
+
+ g_object_set_data (G_OBJECT (mitem), "c", cdata);
+ g_signal_connect (mitem, "toggled",
+ G_CALLBACK (hidden_column_mitem_toggled_cb), grid);
+ }
}
gtk_menu_shell_append (GTK_MENU_SHELL (menu),
@@ -3314,9 +3324,9 @@ gdaui_raw_grid_selector_set_column_visible (GdauiDataSelector *iface, gint colum
g_assert (pos >= 0);
viewcol = gtk_tree_view_get_column (GTK_TREE_VIEW (grid), pos);
+ gtk_tree_view_column_set_visible (viewcol, visible);
/* Sets the column's visibility */
- gtk_tree_view_column_set_visible (viewcol, visible);
ColumnData *cdata;
cdata = g_slist_nth_data (grid->priv->columns_data, column);
g_assert (cdata);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]