columnview: Simplify column constructors

Drop gtk_column_view_column_new_with_factory and
just make gtk_column_view_column_new accept a
nullable factory. This follows what we've been
doing elsewhere.

Update all callers.
This commit is contained in:
Matthias Clasen 2020-09-25 13:53:42 -04:00
parent c9f6a9f7c5
commit 0c3f42e06e
5 changed files with 8 additions and 29 deletions

View File

@ -555,7 +555,6 @@ gtk_column_view_get_type
<TITLE>GtkColumnViewColumn</TITLE>
GtkColumnViewColumn
gtk_column_view_column_new
gtk_column_view_column_new_with_factory
gtk_column_view_column_get_column_view
gtk_column_view_column_set_factory
gtk_column_view_column_get_factory

View File

@ -357,25 +357,7 @@ gtk_column_view_column_init (GtkColumnViewColumn *self)
/**
* gtk_column_view_column_new:
* @title: (nullable): Title to use for this column
*
* Creates a new #GtkColumnViewColumn.
*
* You most likely want to call gtk_column_view_add_column() next.
*
* Returns: a new #GtkColumnViewColumn
**/
GtkColumnViewColumn *
gtk_column_view_column_new (const char *title)
{
return g_object_new (GTK_TYPE_COLUMN_VIEW_COLUMN,
"title", title,
NULL);
}
/**
* gtk_column_view_column_new_with_factory:
* @title: (nullable): Title to use for this column
* @factory: (transfer full): The factory to populate items with
* @factory: (transfer full) (nullable): The factory to populate items with
*
* Creates a new #GtkColumnViewColumn that uses the given @factory for
* mapping items to widgets.
@ -385,15 +367,15 @@ gtk_column_view_column_new (const char *title)
* The function takes ownership of the
* argument, so you can write code like
* ```
* column = gtk_column_view_column_new_with_factory (_("Name"),
* column = gtk_column_view_column_new (_("Name"),
* gtk_builder_list_item_factory_new_from_resource ("/name.ui"));
* ```
*
* Returns: a new #GtkColumnViewColumn using the given @factory
**/
GtkColumnViewColumn *
gtk_column_view_column_new_with_factory (const char *title,
GtkListItemFactory *factory)
gtk_column_view_column_new (const char *title,
GtkListItemFactory *factory)
{
GtkColumnViewColumn *result;
@ -404,7 +386,7 @@ gtk_column_view_column_new_with_factory (const char *title,
"title", title,
NULL);
g_object_unref (factory);
g_clear_object (&factory);
return result;
}

View File

@ -47,9 +47,7 @@ GDK_AVAILABLE_IN_ALL
GType gtk_column_view_column_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkColumnViewColumn * gtk_column_view_column_new (const char *title);
GDK_AVAILABLE_IN_ALL
GtkColumnViewColumn * gtk_column_view_column_new_with_factory (const char *title,
GtkColumnViewColumn * gtk_column_view_column_new (const char *title,
GtkListItemFactory *factory);
GDK_AVAILABLE_IN_ALL

View File

@ -662,7 +662,7 @@ add_extra_columns (GtkColumnView *view,
for (i = 0; i < G_N_ELEMENTS(extra_columns); i++)
{
bytes = g_bytes_new_static (extra_columns[i].factory_xml, strlen (extra_columns[i].factory_xml));
column = gtk_column_view_column_new_with_factory (extra_columns[i].title,
column = gtk_column_view_column_new (extra_columns[i].title,
gtk_builder_list_item_factory_new_from_bytes (scope, bytes));
g_bytes_unref (bytes);
sorter = GTK_SORTER (gtk_custom_sorter_new (compare_file_attribute, (gpointer) extra_columns[i].attribute, NULL));

View File

@ -388,7 +388,7 @@ main (int argc, char *argv[])
g_signal_connect (factory, "unbind", G_CALLBACK (unbind_item), NULL);
title = g_strdup_printf ("Column %u", i);
column = gtk_column_view_column_new_with_factory (title, factory);
column = gtk_column_view_column_new (title, factory);
gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
g_object_unref (column);
g_free (title);