mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
columnviewcolumn: Add a visible property
This lets us hide columns, which is an expected feature of columned lists.
This commit is contained in:
parent
93353888ca
commit
4877bb5b5c
@ -530,6 +530,8 @@ gtk_column_view_column_set_title
|
|||||||
gtk_column_view_column_get_title
|
gtk_column_view_column_get_title
|
||||||
gtk_column_view_column_set_sorter
|
gtk_column_view_column_set_sorter
|
||||||
gtk_column_view_column_get_sorter
|
gtk_column_view_column_get_sorter
|
||||||
|
gtk_column_view_column_set_visible
|
||||||
|
gtk_column_view_column_get_visible
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GTK_COLUMN_VIEW_COLUMN
|
GTK_COLUMN_VIEW_COLUMN
|
||||||
GTK_COLUMN_VIEW_COLUMN_CLASS
|
GTK_COLUMN_VIEW_COLUMN_CLASS
|
||||||
|
@ -156,6 +156,7 @@ gtk_column_view_cell_new (GtkColumnViewColumn *column)
|
|||||||
|
|
||||||
cell = g_object_new (GTK_TYPE_COLUMN_VIEW_CELL,
|
cell = g_object_new (GTK_TYPE_COLUMN_VIEW_CELL,
|
||||||
"factory", gtk_column_view_column_get_factory (column),
|
"factory", gtk_column_view_column_get_factory (column),
|
||||||
|
"visible", gtk_column_view_column_get_visible (column),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
cell->column = g_object_ref (column);
|
cell->column = g_object_ref (column);
|
||||||
|
@ -61,6 +61,8 @@ struct _GtkColumnViewColumn
|
|||||||
int allocation_offset;
|
int allocation_offset;
|
||||||
int allocation_size;
|
int allocation_size;
|
||||||
|
|
||||||
|
gboolean visible;
|
||||||
|
|
||||||
/* This list isn't sorted - this is just caching for performance */
|
/* This list isn't sorted - this is just caching for performance */
|
||||||
GtkColumnViewCell *first_cell; /* no reference, just caching */
|
GtkColumnViewCell *first_cell; /* no reference, just caching */
|
||||||
};
|
};
|
||||||
@ -77,6 +79,7 @@ enum
|
|||||||
PROP_FACTORY,
|
PROP_FACTORY,
|
||||||
PROP_TITLE,
|
PROP_TITLE,
|
||||||
PROP_SORTER,
|
PROP_SORTER,
|
||||||
|
PROP_VISIBLE,
|
||||||
|
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
@ -126,6 +129,10 @@ gtk_column_view_column_get_property (GObject *object,
|
|||||||
g_value_set_object (value, self->sorter);
|
g_value_set_object (value, self->sorter);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_VISIBLE:
|
||||||
|
g_value_set_boolean (value, self->visible);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -154,6 +161,10 @@ gtk_column_view_column_set_property (GObject *object,
|
|||||||
gtk_column_view_column_set_sorter (self, g_value_get_object (value));
|
gtk_column_view_column_set_sorter (self, g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_VISIBLE:
|
||||||
|
gtk_column_view_column_set_visible (self, g_value_get_boolean (value));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -217,6 +228,18 @@ gtk_column_view_column_class_init (GtkColumnViewColumnClass *klass)
|
|||||||
GTK_TYPE_SORTER,
|
GTK_TYPE_SORTER,
|
||||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GtkColumnViewColumn:visible:
|
||||||
|
*
|
||||||
|
* Whether this column is visible
|
||||||
|
*/
|
||||||
|
properties[PROP_VISIBLE] =
|
||||||
|
g_param_spec_boolean ("visible",
|
||||||
|
P_("Visible"),
|
||||||
|
P_("Whether this column is visible"),
|
||||||
|
TRUE,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,6 +248,7 @@ gtk_column_view_column_init (GtkColumnViewColumn *self)
|
|||||||
{
|
{
|
||||||
self->minimum_size_request = -1;
|
self->minimum_size_request = -1;
|
||||||
self->natural_size_request = -1;
|
self->natural_size_request = -1;
|
||||||
|
self->visible = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -647,3 +671,53 @@ gtk_column_view_column_notify_sort (GtkColumnViewColumn *self)
|
|||||||
if (self->header)
|
if (self->header)
|
||||||
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
|
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_column_view_column_set_visible:
|
||||||
|
* @self: a #GtkColumnViewColumn
|
||||||
|
* @visible: whether this column should be visible
|
||||||
|
*
|
||||||
|
* Sets whether this column should be visible in views.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_column_view_column_set_visible (GtkColumnViewColumn *self,
|
||||||
|
gboolean visible)
|
||||||
|
{
|
||||||
|
GtkColumnViewCell *cell;
|
||||||
|
|
||||||
|
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
||||||
|
|
||||||
|
if (self->visible == visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
self->visible = visible;
|
||||||
|
|
||||||
|
self->minimum_size_request = -1;
|
||||||
|
self->natural_size_request = -1;
|
||||||
|
|
||||||
|
if (self->header)
|
||||||
|
gtk_widget_set_visible (GTK_WIDGET (self->header), visible);
|
||||||
|
|
||||||
|
for (cell = self->first_cell; cell; cell = gtk_column_view_cell_get_next (cell))
|
||||||
|
{
|
||||||
|
gtk_widget_set_visible (GTK_WIDGET (cell), visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VISIBLE]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_column_view_get_visible:
|
||||||
|
* @self: a #GtkColumnViewColumn
|
||||||
|
*
|
||||||
|
* Returns whether this column is visible.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if this column is visible
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gtk_column_view_column_get_visible (GtkColumnViewColumn *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), TRUE);
|
||||||
|
|
||||||
|
return self->visible;
|
||||||
|
}
|
||||||
|
@ -72,6 +72,12 @@ void gtk_column_view_column_set_sorter (GtkColu
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkSorter * gtk_column_view_column_get_sorter (GtkColumnViewColumn *self);
|
GtkSorter * gtk_column_view_column_get_sorter (GtkColumnViewColumn *self);
|
||||||
|
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
void gtk_column_view_column_set_visible (GtkColumnViewColumn *self,
|
||||||
|
gboolean visible);
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
gboolean gtk_column_view_column_get_visible (GtkColumnViewColumn *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_COLUMN_VIEW_COLUMN_H__ */
|
#endif /* __GTK_COLUMN_VIEW_COLUMN_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user