noselection: Make constructor transfer full

This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
This commit is contained in:
Matthias Clasen 2020-07-26 16:55:43 -04:00
parent dd1c0c0b22
commit 68d6671413
9 changed files with 16 additions and 22 deletions

View File

@ -462,7 +462,6 @@ do_listview_clocks (GtkWidget *do_widget)
{
GtkWidget *gridview, *sw;
GtkListItemFactory *factory;
GListModel *model;
GtkNoSelection *selection;
/* This is the normal window setup code every demo does */
@ -489,12 +488,10 @@ do_listview_clocks (GtkWidget *do_widget)
gtk_scrollable_set_hscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
gtk_scrollable_set_vscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
model = create_clocks_model ();
selection = gtk_no_selection_new (model);
selection = gtk_no_selection_new (create_clocks_model ());
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), G_LIST_MODEL (selection));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
g_object_unref (selection);
g_object_unref (model);
}
if (!gtk_widget_get_visible (window))

View File

@ -970,7 +970,6 @@ do_listview_colors (GtkWidget *do_widget)
no_selection = G_LIST_MODEL (gtk_no_selection_new (selection_filter));
gtk_grid_view_set_model (GTK_GRID_VIEW (selection_view), no_selection);
g_object_unref (selection_filter);
g_object_unref (no_selection);
selection_info_toggle = gtk_toggle_button_new ();

View File

@ -214,7 +214,6 @@ transform_settings_to_keys (GBinding *binding,
GtkSortListModel *sort_model;
GtkFilterListModel *filter_model;
GtkFilter *filter;
GtkNoSelection *selection_model;
char **keys;
guint i;
@ -248,10 +247,7 @@ transform_settings_to_keys (GBinding *binding,
g_set_object (&current_filter, filter);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
selection_model = gtk_no_selection_new (G_LIST_MODEL (filter_model));
g_object_unref (filter_model);
g_value_take_object (to_value, selection_model);
g_value_take_object (to_value, gtk_no_selection_new (G_LIST_MODEL (filter_model)));
return TRUE;
}

View File

@ -281,7 +281,7 @@ GtkWidget *
create_weather_view (void)
{
GtkWidget *listview;
GListModel *model, *selection;
GListModel *selection;
GtkListItemFactory *factory;
factory = gtk_signal_list_item_factory_new ();
@ -290,11 +290,9 @@ create_weather_view (void)
listview = gtk_list_view_new_with_factory (factory);
gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
model = create_weather_model ();
selection = G_LIST_MODEL (gtk_no_selection_new (model));
selection = G_LIST_MODEL (gtk_no_selection_new (create_weather_model ()));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
g_object_unref (selection);
g_object_unref (model);
return listview;
}

View File

@ -226,7 +226,6 @@ do_listview_words (GtkWidget *do_widget)
g_signal_connect (filter_model, "notify::pending", G_CALLBACK (update_title_cb), progress);
update_title_cb (filter_model);
g_object_unref (filter_model);
}
if (!gtk_widget_get_visible (window))

View File

@ -216,7 +216,7 @@ gtk_no_selection_init (GtkNoSelection *self)
/**
* gtk_no_selection_new:
* @model: (transfer none): the #GListModel to manage
* @model: (allow-none) (transfer full): the #GListModel to manage, or %NULL
*
* Creates a new selection to handle @model.
*
@ -225,11 +225,18 @@ gtk_no_selection_init (GtkNoSelection *self)
GtkNoSelection *
gtk_no_selection_new (GListModel *model)
{
GtkNoSelection *self;
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
return g_object_new (GTK_TYPE_NO_SELECTION,
self = g_object_new (GTK_TYPE_NO_SELECTION,
"model", model,
NULL);
/* consume the reference */
g_clear_object (&model);
return self;
}
/**
@ -253,8 +260,8 @@ gtk_no_selection_get_model (GtkNoSelection *self)
* @self: a #GtkNoSelection
* @model: (allow-none): A #GListModel to wrap
*
* Sets the model that @self should wrap. If @model is %NULL, this
* model will be empty.
* Sets the model that @self should wrap.
* If @model is %NULL, this model will be empty.
**/
void
gtk_no_selection_set_model (GtkNoSelection *self,

View File

@ -400,7 +400,6 @@ constructed (GObject *object)
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->list)))));
model = G_LIST_MODEL (gtk_no_selection_new (sorted));
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->list), model);
g_object_unref (sorted);
g_object_unref (model);
}

View File

@ -85,7 +85,7 @@ gtk_inspector_list_data_set_object (GtkInspectorListData *sl,
g_object_set (page, "visible", TRUE, NULL);
sl->object = G_LIST_MODEL (object);
selection = gtk_no_selection_new (sl->object);
selection = gtk_no_selection_new (g_object_ref (sl->object));
gtk_column_view_set_model (sl->view, G_LIST_MODEL (selection));
g_object_unref (selection);
}

View File

@ -633,7 +633,6 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
gtk_widget_show (GTK_WIDGET (pl));
g_object_unref (list);
g_object_unref (sorted);
return TRUE;
}