diff --git a/demos/gtk-demo/listview_settings.c b/demos/gtk-demo/listview_settings.c index 981a068010..49dca2376a 100644 --- a/demos/gtk-demo/listview_settings.c +++ b/demos/gtk-demo/listview_settings.c @@ -398,8 +398,8 @@ do_listview_settings (GtkWidget *do_widget) g_object_unref (actions); model = create_settings_model (NULL, NULL); - treemodel = gtk_tree_list_model_new (FALSE, - model, + treemodel = gtk_tree_list_model_new (model, + FALSE, TRUE, create_settings_model, NULL, @@ -414,7 +414,6 @@ do_listview_settings (GtkWidget *do_widget) gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection)); g_object_unref (selection); g_object_unref (treemodel); - g_object_unref (model); name_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "name_column")); sorter = gtk_string_sorter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name")); diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c index bc89b017d0..21fc5f187c 100644 --- a/demos/gtk-demo/main.c +++ b/demos/gtk-demo/main.c @@ -1136,8 +1136,8 @@ activate (GApplication *app) g_signal_connect (search_bar, "notify::search-mode-enabled", G_CALLBACK (clear_search), NULL); listmodel = create_demo_model (); - treemodel = gtk_tree_list_model_new (FALSE, - G_LIST_MODEL (listmodel), + treemodel = gtk_tree_list_model_new (G_LIST_MODEL (listmodel), + FALSE, TRUE, get_child_model, NULL, diff --git a/gtk/gtktreelistmodel.c b/gtk/gtktreelistmodel.c index 4311acb9d3..82b6bf5056 100644 --- a/gtk/gtktreelistmodel.c +++ b/gtk/gtktreelistmodel.c @@ -734,8 +734,8 @@ gtk_tree_list_model_init (GtkTreeListModel *self) /** * gtk_tree_list_model_new: + * @root: (transfer full): The #GListModel to use as root * @passthrough: %TRUE to pass through items from the models - * @root: The #GListModel to use as root * @autoexpand: %TRUE to set the autoexpand property and expand the @root model * @create_func: Function to call to create the #GListModel for the children * of an item @@ -743,12 +743,12 @@ gtk_tree_list_model_init (GtkTreeListModel *self) * @user_destroy: Function to call to free @user_data * * Creates a new empty #GtkTreeListModel displaying @root with all rows collapsed. - * - * Returns: a newly created #GtkTreeListModel. + * + * Returns: a newly created #GtkTreeListModel. **/ GtkTreeListModel * -gtk_tree_list_model_new (gboolean passthrough, - GListModel *root, +gtk_tree_list_model_new (GListModel *root, + gboolean passthrough, gboolean autoexpand, GtkTreeListModelCreateModelFunc create_func, gpointer user_data, @@ -768,7 +768,7 @@ gtk_tree_list_model_new (gboolean passthrough, self->user_data = user_data; self->user_destroy = user_destroy; - gtk_tree_list_model_init_node (self, &self->root_node, g_object_ref (root)); + gtk_tree_list_model_init_node (self, &self->root_node, root); return self; } diff --git a/gtk/gtktreelistmodel.h b/gtk/gtktreelistmodel.h index 1b358f8d6b..e5f76ac5aa 100644 --- a/gtk/gtktreelistmodel.h +++ b/gtk/gtktreelistmodel.h @@ -58,8 +58,8 @@ G_DECLARE_FINAL_TYPE (GtkTreeListRow, gtk_tree_list_row, GTK, TREE_LIST_ROW, GOb typedef GListModel * (* GtkTreeListModelCreateModelFunc) (gpointer item, gpointer user_data); GDK_AVAILABLE_IN_ALL -GtkTreeListModel * gtk_tree_list_model_new (gboolean passthrough, - GListModel *root, +GtkTreeListModel * gtk_tree_list_model_new (GListModel *root, + gboolean passthrough, gboolean autoexpand, GtkTreeListModelCreateModelFunc create_func, gpointer user_data, diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c index 3d86e11693..5b65f03b91 100644 --- a/gtk/inspector/object-tree.c +++ b/gtk/inspector/object-tree.c @@ -1298,18 +1298,13 @@ void gtk_inspector_object_tree_set_display (GtkInspectorObjectTree *wt, GdkDisplay *display) { - GListModel *root_model; - - root_model = create_root_model (display); - wt->priv->tree_model = gtk_tree_list_model_new (FALSE, - root_model, + wt->priv->tree_model = gtk_tree_list_model_new (create_root_model (display), + FALSE, FALSE, create_model_for_object, NULL, NULL); wt->priv->selection = gtk_single_selection_new (G_LIST_MODEL (wt->priv->tree_model)); - g_object_unref (root_model); - gtk_column_view_set_model (GTK_COLUMN_VIEW (wt->priv->list), G_LIST_MODEL (wt->priv->selection)); } diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c index c07d63b01b..c76fb2971c 100644 --- a/gtk/inspector/recorder.c +++ b/gtk/inspector/recorder.c @@ -1234,8 +1234,8 @@ gtk_inspector_recorder_init (GtkInspectorRecorder *recorder) NULL); recorder->render_node_root_model = g_list_store_new (GDK_TYPE_PAINTABLE); - recorder->render_node_model = gtk_tree_list_model_new (FALSE, - G_LIST_MODEL (recorder->render_node_root_model), + recorder->render_node_model = gtk_tree_list_model_new (g_object_ref (G_LIST_MODEL (recorder->render_node_root_model)), + FALSE, TRUE, create_list_model_for_render_node_paintable, NULL, NULL); diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c index 1cb3770bd4..2abce1df7f 100644 --- a/gtk/inspector/resource-list.c +++ b/gtk/inspector/resource-list.c @@ -692,7 +692,6 @@ static void constructed (GObject *object) { GtkInspectorResourceList *rl = GTK_INSPECTOR_RESOURCE_LIST (object); - GListModel *root_model; GListModel *sort_model; GtkSorter *column_sorter; GtkSorter *sorter; @@ -702,9 +701,8 @@ constructed (GObject *object) g_signal_connect (rl->close_details_button, "clicked", G_CALLBACK (close_details), rl); - root_model = load_resources (); - rl->tree_model = gtk_tree_list_model_new (FALSE, - root_model, + rl->tree_model = gtk_tree_list_model_new (load_resources (), + FALSE, FALSE, create_model_for_object, NULL, @@ -714,7 +712,6 @@ constructed (GObject *object) sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter)); sort_model = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (rl->tree_model)), sorter)); rl->selection = gtk_single_selection_new (sort_model); - g_object_unref (root_model); g_object_unref (sort_model); gtk_column_view_set_model (GTK_COLUMN_VIEW (rl->list), G_LIST_MODEL (rl->selection)); diff --git a/tests/testcolumnview.c b/tests/testcolumnview.c index a77c93ca0b..e60eab6746 100644 --- a/tests/testcolumnview.c +++ b/tests/testcolumnview.c @@ -746,12 +746,11 @@ main (int argc, char *argv[]) dirmodel = create_list_model_for_directory (root); g_object_unref (root); } - tree = gtk_tree_list_model_new (FALSE, - dirmodel, + tree = gtk_tree_list_model_new (dirmodel, + FALSE, TRUE, create_list_model_for_file_info, NULL, NULL); - g_object_unref (dirmodel); sorter = gtk_tree_list_row_sorter_new (g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (view)))); sort = gtk_sort_list_model_new (G_LIST_MODEL (tree), sorter); diff --git a/tests/testlistdnd.c b/tests/testlistdnd.c index 2d8f7f4b7e..533f0a8d38 100644 --- a/tests/testlistdnd.c +++ b/tests/testlistdnd.c @@ -191,8 +191,8 @@ create_child_model (gpointer item, static GListModel * create_tree_model (guint n, guint m) { - return G_LIST_MODEL (gtk_tree_list_model_new (FALSE, - create_model (0, n, m, TRUE), + return G_LIST_MODEL (gtk_tree_list_model_new (create_model (0, n, m, TRUE), + FALSE, FALSE, create_child_model, GUINT_TO_POINTER (m), NULL)); diff --git a/tests/testlistview.c b/tests/testlistview.c index 6eea54d593..c0552d14af 100644 --- a/tests/testlistview.c +++ b/tests/testlistview.c @@ -589,7 +589,6 @@ int main (int argc, char *argv[]) { GtkWidget *win, *vbox, *sw, *listview, *search_entry, *statusbar; - GListModel *dirmodel; GtkTreeListModel *tree; GtkFilterListModel *filter; GtkFilter *custom_filter; @@ -623,13 +622,11 @@ main (int argc, char *argv[]) root = g_file_new_for_commandline_arg (argv[1]); else root = g_file_new_for_path (g_get_current_dir ()); - dirmodel = create_list_model_for_directory (root); - tree = gtk_tree_list_model_new (FALSE, - dirmodel, + tree = gtk_tree_list_model_new (create_list_model_for_directory (root), + FALSE, TRUE, create_list_model_for_file_info, NULL, NULL); - g_object_unref (dirmodel); g_object_unref (root); custom_filter = gtk_custom_filter_new (match_file, search_entry, NULL); diff --git a/testsuite/gtk/treelistmodel.c b/testsuite/gtk/treelistmodel.c index 75dbcd41fa..14bc09dc62 100644 --- a/testsuite/gtk/treelistmodel.c +++ b/testsuite/gtk/treelistmodel.c @@ -170,7 +170,7 @@ new_model (guint size, GtkTreeListModel *tree; GString *changes; - tree = gtk_tree_list_model_new (TRUE, G_LIST_MODEL (new_store (size, size, size)), expanded, create_sub_model_cb, NULL, NULL); + tree = gtk_tree_list_model_new (G_LIST_MODEL (new_store (size, size, size)), TRUE, expanded, create_sub_model_cb, NULL, NULL); changes = g_string_new (""); g_object_set_qdata_full (G_OBJECT(tree), changes_quark, changes, free_changes); g_signal_connect (tree, "items-changed", G_CALLBACK (items_changed), changes); diff --git a/testsuite/gtk/treesorter.c b/testsuite/gtk/treesorter.c index 73bdb4c9ae..25d43a3d40 100644 --- a/testsuite/gtk/treesorter.c +++ b/testsuite/gtk/treesorter.c @@ -158,8 +158,8 @@ new_child_model (gpointer item, static GListModel * new_model (guint size) { - return G_LIST_MODEL (gtk_tree_list_model_new (FALSE, - G_LIST_MODEL (new_store (1, size, 1)), + return G_LIST_MODEL (gtk_tree_list_model_new (G_LIST_MODEL (new_store (1, size, 1)), + FALSE, TRUE, new_child_model, NULL, NULL));