mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
columnview: Revise the constructor
Make gtk_column_view_new take a model as first argument, and make it allow-none and transfer full. Update all callers.
This commit is contained in:
parent
43000abeff
commit
fc22b75a06
@ -1179,19 +1179,30 @@ gtk_column_view_init (GtkColumnView *self)
|
||||
|
||||
/**
|
||||
* gtk_column_view_new:
|
||||
* @model: (allow-none) (transfer full): the list model to use, or %NULL
|
||||
*
|
||||
* Creates a new empty #GtkColumnView.
|
||||
* Creates a new #GtkColumnView.
|
||||
*
|
||||
* You most likely want to call gtk_column_view_set_factory() to
|
||||
* set up a way to map its items to widgets and gtk_column_view_set_model()
|
||||
* to set a model to provide items next.
|
||||
* You most likely want to call gtk_column_view_append_column() to
|
||||
* add columns next.
|
||||
*
|
||||
* Returns: a new #GtkColumnView
|
||||
**/
|
||||
GtkWidget *
|
||||
gtk_column_view_new (void)
|
||||
gtk_column_view_new (GListModel *model)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_COLUMN_VIEW, NULL);
|
||||
GtkWidget *result;
|
||||
|
||||
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_COLUMN_VIEW,
|
||||
"model", model,
|
||||
NULL);
|
||||
|
||||
/* consume the reference */
|
||||
g_clear_object (&model);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,7 +51,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_column_view_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_column_view_new (void);
|
||||
GtkWidget * gtk_column_view_new (GListModel *model);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GListModel * gtk_column_view_get_columns (GtkColumnView *self);
|
||||
|
@ -381,11 +381,7 @@ main (int argc, char *argv[])
|
||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_stack_add_titled (GTK_STACK (stack), sw, "column", "GtkColumnView");
|
||||
|
||||
cv = gtk_column_view_new ();
|
||||
|
||||
model = create_model (0, 400, 1, FALSE);
|
||||
gtk_column_view_set_model (GTK_COLUMN_VIEW (cv), model);
|
||||
g_object_unref (model);
|
||||
cv = gtk_column_view_new (create_model (0, 400, 1, FALSE));
|
||||
|
||||
for (guint i = 0; i < 20; i++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user