G_CALLBACK (gdaex_grid_on_menu_item_toggled), (gpointer)grid);
gtk_menu_shell_append (GTK_MENU_SHELL (submitem), mitem);
- gtk_widget_show (mitem);
+ if (gdaex_grid_column_get_viewable (gcolumn))
+ {
+ gtk_widget_show (mitem);
+ }
+ else
+ {
+ gtk_widget_set_visible (GTK_WIDGET (mitem), FALSE);
+ }
g_object_set_data (G_OBJECT (gcolumn), "menuitem", mitem);
g_object_set_data (G_OBJECT (gcolumn), "menuitem_handler_id", GINT_TO_POINTER (hid));
gchar *field_name;
GType type;
gboolean visible;
+ gboolean viewable;
gboolean resizable;
gboolean sortable;
gboolean reorderable;
priv->field_name = NULL;
priv->type = G_TYPE_NONE;
priv->visible = FALSE;
+ priv->viewable = TRUE;
priv->resizable = FALSE;
priv->sortable = FALSE;
priv->reorderable = FALSE;
GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+ if (!priv->viewable)
+ {
+ return;
+ }
+
priv->visible = visible;
if (priv->vcolumn != NULL)
return priv->visible;
}
+/**
+ * gdaex_grid_column_set_viewable:
+ * @column:
+ * @viewable:
+ *
+ */
+void
+gdaex_grid_column_set_viewable (GdaExGridColumn *column, gboolean viewable)
+{
+ g_return_if_fail (GDAEX_IS_GRID_COLUMN (column));
+
+ GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+ if (!viewable)
+ {
+ gdaex_grid_column_set_visible (column, FALSE);
+ }
+
+ priv->viewable = viewable;
+
+ gtk_widget_set_visible (GTK_WIDGET (g_object_get_data (G_OBJECT (column), "menuitem")),
+ priv->viewable);
+}
+
+/**
+ * gdaex_grid_column_get_viewable:
+ * column:
+ *
+ * Returns: if column is viewable.
+ */
+gboolean
+gdaex_grid_column_get_viewable (GdaExGridColumn *column)
+{
+ g_return_val_if_fail (GDAEX_IS_GRID_COLUMN (column), FALSE);
+
+ GdaExGridColumnPrivate *priv = GDAEX_GRID_COLUMN_GET_PRIVATE (column);
+
+ return priv->viewable;
+}
+
/**
* gdaex_grid_column_set_resizable:
* @column:
/*
* gridcolumn.h
*
- * Copyright (C) 2010-2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2019 Andrea Zagli <azagli@libero.it>
*
* This file is part of libgdaexgrid.
*
void gdaex_grid_column_set_visible (GdaExGridColumn *column, gboolean visible);
gboolean gdaex_grid_column_get_visible (GdaExGridColumn *column);
+void gdaex_grid_column_set_viewable (GdaExGridColumn *column, gboolean viewable);
+gboolean gdaex_grid_column_get_viewable (GdaExGridColumn *column);
+
void gdaex_grid_column_set_resizable (GdaExGridColumn *column, gboolean resizable);
gboolean gdaex_grid_column_get_resizable (GdaExGridColumn *column);
#include "gridcolumn.h"
GdaExGridColumn *gcol_birthday;
+GdaExGridColumn *gcol_viewable;
static void
missing_func (GtkTreeStore *tstore, GtkTreeIter *iter, gpointer user_data)
gdaex_grid_column_set_visible (gcol_birthday, !gdaex_grid_column_get_visible (gcol_birthday));
}
+static void
+on_btn_viewable_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ gdaex_grid_column_set_viewable (gcol_viewable, !gdaex_grid_column_get_viewable (gcol_viewable));
+}
+
int
main (int argc, char **argv)
{
gcol = gdaex_grid_column_new ("Married", "married", G_TYPE_BOOLEAN, TRUE, TRUE, TRUE, TRUE, -1);
gdaex_grid_add_column (grid, gcol);
+ gcol_viewable = gdaex_grid_column_new ("Viewable", "viewable", G_TYPE_BOOLEAN, TRUE, TRUE, TRUE, TRUE, -1);
+ gdaex_grid_add_column (grid, gcol_viewable);
+
wgrid = gdaex_grid_get_widget (grid);
gtk_container_add (GTK_CONTAINER (scrolledw), wgrid);
g_signal_connect (G_OBJECT (btn), "clicked",
G_CALLBACK (on_btn_birthday_clicked), NULL);
+ btn = gtk_button_new_with_label ("Set/Unset Viewable");
+ gtk_box_pack_start (GTK_BOX (hbtnbox), btn, TRUE, TRUE, 0);
+
+ g_signal_connect (G_OBJECT (btn), "clicked",
+ G_CALLBACK (on_btn_viewable_clicked), NULL);
+
gtk_widget_show_all (w);
gtk_main ();