forked from AuroraMiddleware/gtk
treelistmodel: Make constructor transfer full
Make gtk_tree_list_model_new() take the root model as first argument, and make it transfer full, for consistency with other wrapping list constructors. Update all callers. Still missing here: Make the model property writable, and allow passing NULL in the constructor.
This commit is contained in:
parent
a46cfd3ff4
commit
dd1c0c0b22
@ -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"));
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user