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> <TITLE>GtkColumnViewColumn</TITLE>
GtkColumnViewColumn GtkColumnViewColumn
gtk_column_view_column_new gtk_column_view_column_new
gtk_column_view_column_new_with_factory
gtk_column_view_column_get_column_view gtk_column_view_column_get_column_view
gtk_column_view_column_set_factory gtk_column_view_column_set_factory
gtk_column_view_column_get_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: * gtk_column_view_column_new:
* @title: (nullable): Title to use for this column * @title: (nullable): Title to use for this column
* * @factory: (transfer full) (nullable): The factory to populate items with
* 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
* *
* Creates a new #GtkColumnViewColumn that uses the given @factory for * Creates a new #GtkColumnViewColumn that uses the given @factory for
* mapping items to widgets. * mapping items to widgets.
@ -385,15 +367,15 @@ gtk_column_view_column_new (const char *title)
* The function takes ownership of the * The function takes ownership of the
* argument, so you can write code like * 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")); * gtk_builder_list_item_factory_new_from_resource ("/name.ui"));
* ``` * ```
* *
* Returns: a new #GtkColumnViewColumn using the given @factory * Returns: a new #GtkColumnViewColumn using the given @factory
**/ **/
GtkColumnViewColumn * GtkColumnViewColumn *
gtk_column_view_column_new_with_factory (const char *title, gtk_column_view_column_new (const char *title,
GtkListItemFactory *factory) GtkListItemFactory *factory)
{ {
GtkColumnViewColumn *result; GtkColumnViewColumn *result;
@ -404,7 +386,7 @@ gtk_column_view_column_new_with_factory (const char *title,
"title", title, "title", title,
NULL); NULL);
g_object_unref (factory); g_clear_object (&factory);
return result; return result;
} }

View File

@ -47,9 +47,7 @@ GDK_AVAILABLE_IN_ALL
GType gtk_column_view_column_get_type (void) G_GNUC_CONST; GType gtk_column_view_column_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GtkColumnViewColumn * gtk_column_view_column_new (const char *title); GtkColumnViewColumn * gtk_column_view_column_new (const char *title,
GDK_AVAILABLE_IN_ALL
GtkColumnViewColumn * gtk_column_view_column_new_with_factory (const char *title,
GtkListItemFactory *factory); GtkListItemFactory *factory);
GDK_AVAILABLE_IN_ALL 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++) 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)); 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)); gtk_builder_list_item_factory_new_from_bytes (scope, bytes));
g_bytes_unref (bytes); g_bytes_unref (bytes);
sorter = GTK_SORTER (gtk_custom_sorter_new (compare_file_attribute, (gpointer) extra_columns[i].attribute, NULL)); 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); g_signal_connect (factory, "unbind", G_CALLBACK (unbind_item), NULL);
title = g_strdup_printf ("Column %u", i); 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); gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
g_object_unref (column); g_object_unref (column);
g_free (title); g_free (title);