forked from AuroraMiddleware/gtk
sortlistmodel: 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:
parent
706d464ae6
commit
a46cfd3ff4
@ -242,8 +242,7 @@ transform_settings_to_keys (GBinding *binding,
|
|||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
|
|
||||||
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (store),
|
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (store),
|
||||||
gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data)));
|
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data))));
|
||||||
g_object_unref (store);
|
|
||||||
|
|
||||||
filter = gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
|
filter = gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
|
||||||
g_set_object (¤t_filter, filter);
|
g_set_object (¤t_filter, filter);
|
||||||
|
@ -1500,8 +1500,8 @@ gtk_column_view_get_list_view (GtkColumnView *self)
|
|||||||
* |[
|
* |[
|
||||||
* gtk_column_view_column_set_sorter (column, sorter);
|
* gtk_column_view_column_set_sorter (column, sorter);
|
||||||
* gtk_column_view_append_column (view, column);
|
* gtk_column_view_append_column (view, column);
|
||||||
* model = gtk_sort_list_model_new (store,
|
* sorter = g_object_ref (gtk_column_view_get_sorter (view)));
|
||||||
* gtk_column_view_get_sorter (view));
|
* model = gtk_sort_list_model_new (store, sorter);
|
||||||
* selection = gtk_no_selection_new (model);
|
* selection = gtk_no_selection_new (model);
|
||||||
* gtk_column_view_set_model (view, selection);
|
* gtk_column_view_set_model (view, selection);
|
||||||
* ]|
|
* ]|
|
||||||
|
@ -813,7 +813,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
|||||||
model = load_print_backends (dialog);
|
model = load_print_backends (dialog);
|
||||||
sorter = gtk_custom_sorter_new (default_printer_list_sort_func, NULL, NULL);
|
sorter = gtk_custom_sorter_new (default_printer_list_sort_func, NULL, NULL);
|
||||||
sorted = G_LIST_MODEL (gtk_sort_list_model_new (model, sorter));
|
sorted = G_LIST_MODEL (gtk_sort_list_model_new (model, sorter));
|
||||||
g_object_unref (sorter);
|
|
||||||
|
|
||||||
filter = gtk_every_filter_new ();
|
filter = gtk_every_filter_new ();
|
||||||
|
|
||||||
@ -839,7 +838,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
|||||||
g_signal_connect_swapped (selection, "notify::selected", G_CALLBACK (selected_printer_changed), dialog);
|
g_signal_connect_swapped (selection, "notify::selected", G_CALLBACK (selected_printer_changed), dialog);
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
g_object_unref (filtered);
|
g_object_unref (filtered);
|
||||||
g_object_unref (model);
|
|
||||||
|
|
||||||
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
||||||
|
|
||||||
|
@ -828,8 +828,8 @@ gtk_sort_list_model_init (GtkSortListModel *self)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_sort_list_model_new:
|
* gtk_sort_list_model_new:
|
||||||
* @model: (allow-none): the model to sort
|
* @model: (allow-none) (transfer full): the model to sort, or %NULL
|
||||||
* @sorter: (allow-none): the #GtkSorter to sort @model with
|
* @sorter: (allow-none) (transfer full): the #GtkSorter to sort @model with, or %NULL
|
||||||
*
|
*
|
||||||
* Creates a new sort list model that uses the @sorter to sort @model.
|
* Creates a new sort list model that uses the @sorter to sort @model.
|
||||||
*
|
*
|
||||||
@ -849,6 +849,10 @@ gtk_sort_list_model_new (GListModel *model,
|
|||||||
"sorter", sorter,
|
"sorter", sorter,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* consume the references */
|
||||||
|
g_clear_object (&model);
|
||||||
|
g_clear_object (&sorter);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ struct _GtkInspectorActions
|
|||||||
|
|
||||||
GObject *object;
|
GObject *object;
|
||||||
|
|
||||||
GListModel *actions;
|
GListStore *actions;
|
||||||
GtkColumnViewColumn *name;
|
GtkColumnViewColumn *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ action_added (GObject *owner,
|
|||||||
GtkInspectorActions *sl)
|
GtkInspectorActions *sl)
|
||||||
{
|
{
|
||||||
ActionHolder *holder = action_holder_new (owner, action_name);
|
ActionHolder *holder = action_holder_new (owner, action_name);
|
||||||
g_list_store_append (G_LIST_STORE (sl->actions), holder);
|
g_list_store_append (sl->actions, holder);
|
||||||
g_object_unref (holder);
|
g_object_unref (holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ add_muxer (GtkInspectorActions *sl,
|
|||||||
static gboolean
|
static gboolean
|
||||||
reload (GtkInspectorActions *sl)
|
reload (GtkInspectorActions *sl)
|
||||||
{
|
{
|
||||||
g_list_store_remove_all (G_LIST_STORE (sl->actions));
|
g_list_store_remove_all (sl->actions);
|
||||||
|
|
||||||
if (GTK_IS_APPLICATION (sl->object))
|
if (GTK_IS_APPLICATION (sl->object))
|
||||||
{
|
{
|
||||||
@ -395,9 +395,9 @@ constructed (GObject *object)
|
|||||||
gtk_column_view_column_set_sorter (sl->name, sorter);
|
gtk_column_view_column_set_sorter (sl->name, sorter);
|
||||||
g_object_unref (sorter);
|
g_object_unref (sorter);
|
||||||
|
|
||||||
sl->actions = G_LIST_MODEL (g_list_store_new (ACTION_TYPE_HOLDER));
|
sl->actions = g_list_store_new (ACTION_TYPE_HOLDER);
|
||||||
sorted = G_LIST_MODEL (gtk_sort_list_model_new (sl->actions,
|
sorted = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (sl->actions)),
|
||||||
gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->list))));
|
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->list)))));
|
||||||
model = G_LIST_MODEL (gtk_no_selection_new (sorted));
|
model = G_LIST_MODEL (gtk_no_selection_new (sorted));
|
||||||
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->list), model);
|
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->list), model);
|
||||||
g_object_unref (sorted);
|
g_object_unref (sorted);
|
||||||
|
@ -249,7 +249,6 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
|
|||||||
|
|
||||||
sorter = gtk_custom_sorter_new (compare_controllers, NULL, NULL);
|
sorter = gtk_custom_sorter_new (compare_controllers, NULL, NULL);
|
||||||
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (flatten_model), sorter);
|
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (flatten_model), sorter);
|
||||||
g_object_unref (sorter);
|
|
||||||
|
|
||||||
gtk_list_box_bind_model (GTK_LIST_BOX (self->listbox),
|
gtk_list_box_bind_model (GTK_LIST_BOX (self->listbox),
|
||||||
G_LIST_MODEL (sort_model),
|
G_LIST_MODEL (sort_model),
|
||||||
@ -258,7 +257,6 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_object_unref (sort_model);
|
g_object_unref (sort_model);
|
||||||
g_object_unref (flatten_model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -634,7 +634,6 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
|
|||||||
|
|
||||||
g_object_unref (list);
|
g_object_unref (list);
|
||||||
g_object_unref (sorted);
|
g_object_unref (sorted);
|
||||||
g_object_unref (filtered);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -712,11 +712,10 @@ constructed (GObject *object)
|
|||||||
|
|
||||||
column_sorter = gtk_column_view_get_sorter (GTK_COLUMN_VIEW (rl->list));
|
column_sorter = gtk_column_view_get_sorter (GTK_COLUMN_VIEW (rl->list));
|
||||||
sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
|
sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
|
||||||
sort_model = G_LIST_MODEL (gtk_sort_list_model_new (G_LIST_MODEL (rl->tree_model), 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);
|
rl->selection = gtk_single_selection_new (sort_model);
|
||||||
g_object_unref (root_model);
|
g_object_unref (root_model);
|
||||||
g_object_unref (sort_model);
|
g_object_unref (sort_model);
|
||||||
g_object_unref (sorter);
|
|
||||||
|
|
||||||
gtk_column_view_set_model (GTK_COLUMN_VIEW (rl->list), G_LIST_MODEL (rl->selection));
|
gtk_column_view_set_model (GTK_COLUMN_VIEW (rl->list), G_LIST_MODEL (rl->selection));
|
||||||
|
|
||||||
|
@ -770,7 +770,6 @@ main (int argc, char *argv[])
|
|||||||
gtk_box_append (GTK_BOX (vbox), statusbar);
|
gtk_box_append (GTK_BOX (vbox), statusbar);
|
||||||
|
|
||||||
g_object_unref (filter);
|
g_object_unref (filter);
|
||||||
g_object_unref (tree);
|
|
||||||
|
|
||||||
list = gtk_list_view_new_with_factory (
|
list = gtk_list_view_new_with_factory (
|
||||||
gtk_builder_list_item_factory_new_from_bytes (scope, g_bytes_new_static (factory_ui, strlen (factory_ui))));
|
gtk_builder_list_item_factory_new_from_bytes (scope, g_bytes_new_static (factory_ui, strlen (factory_ui))));
|
||||||
|
@ -127,7 +127,6 @@ main (int argc,
|
|||||||
add (store);
|
add (store);
|
||||||
sorter = gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL));
|
sorter = gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL));
|
||||||
sort = gtk_sort_list_model_new (G_LIST_MODEL (store), sorter);
|
sort = gtk_sort_list_model_new (G_LIST_MODEL (store), sorter);
|
||||||
g_object_unref (sorter);
|
|
||||||
|
|
||||||
win = gtk_window_new ();
|
win = gtk_window_new ();
|
||||||
gtk_window_set_default_size (GTK_WINDOW (win), 400, 600);
|
gtk_window_set_default_size (GTK_WINDOW (win), 400, 600);
|
||||||
@ -182,7 +181,5 @@ main (int argc,
|
|||||||
while (g_list_model_get_n_items (toplevels))
|
while (g_list_model_get_n_items (toplevels))
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
|
|
||||||
g_object_unref (store);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,6 @@ get_file_path (GFileInfo *info)
|
|||||||
static GListModel *
|
static GListModel *
|
||||||
create_list_model_for_directory (gpointer file)
|
create_list_model_for_directory (gpointer file)
|
||||||
{
|
{
|
||||||
GtkSortListModel *sort;
|
|
||||||
GtkDirectoryList *dir;
|
GtkDirectoryList *dir;
|
||||||
GtkSorter *sorter;
|
GtkSorter *sorter;
|
||||||
|
|
||||||
@ -327,12 +326,8 @@ create_list_model_for_directory (gpointer file)
|
|||||||
|
|
||||||
dir = create_directory_list (file);
|
dir = create_directory_list (file);
|
||||||
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback) get_file_path, NULL, NULL));
|
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback) get_file_path, NULL, NULL));
|
||||||
sort = gtk_sort_list_model_new (G_LIST_MODEL (dir), sorter);
|
|
||||||
|
|
||||||
g_object_unref (sorter);
|
return G_LIST_MODEL (gtk_sort_list_model_new (G_LIST_MODEL (dir), sorter));
|
||||||
g_object_unref (dir);
|
|
||||||
|
|
||||||
return G_LIST_MODEL (sort);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _RowData RowData;
|
typedef struct _RowData RowData;
|
||||||
|
@ -247,6 +247,8 @@ new_model (guint size,
|
|||||||
{
|
{
|
||||||
GtkSortListModel *result;
|
GtkSortListModel *result;
|
||||||
|
|
||||||
|
if (sorter)
|
||||||
|
g_object_ref (sorter);
|
||||||
result = gtk_sort_list_model_new (G_LIST_MODEL (fisher_yates_shuffle (new_store (1, size, 1))), sorter);
|
result = gtk_sort_list_model_new (G_LIST_MODEL (fisher_yates_shuffle (new_store (1, size, 1))), sorter);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -630,8 +632,8 @@ test_stable (void)
|
|||||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi), b);
|
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi), b);
|
||||||
model1 = new_model (20, multi);
|
model1 = new_model (20, multi);
|
||||||
g_object_unref (multi);
|
g_object_unref (multi);
|
||||||
model2b = gtk_sort_list_model_new (gtk_sort_list_model_get_model (model1), b);
|
model2b = gtk_sort_list_model_new (g_object_ref (gtk_sort_list_model_get_model (model1)), g_object_ref (b));
|
||||||
model2 = gtk_sort_list_model_new (G_LIST_MODEL (model2b), a);
|
model2 = gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (model2b)), g_object_ref (a));
|
||||||
assert_model_equal (model1, model2);
|
assert_model_equal (model1, model2);
|
||||||
|
|
||||||
modify_sorter (a);
|
modify_sorter (a);
|
||||||
|
@ -200,9 +200,9 @@ create_sort_list_model (gconstpointer model_id,
|
|||||||
guint id = GPOINTER_TO_UINT (model_id);
|
guint id = GPOINTER_TO_UINT (model_id);
|
||||||
|
|
||||||
if (track_changes)
|
if (track_changes)
|
||||||
model = sort_list_model_new (id & 1 ? NULL : source, id & 2 ? NULL : sorter);
|
model = sort_list_model_new (((id & 1) || !source) ? NULL : g_object_ref (source), ((id & 2) || !sorter) ? NULL : g_object_ref (sorter));
|
||||||
else
|
else
|
||||||
model = gtk_sort_list_model_new (id & 1 ? NULL : source, id & 2 ? NULL : sorter);
|
model = gtk_sort_list_model_new (((id & 1) || !source) ? NULL : g_object_ref (source), ((id & 2) || !sorter) ? NULL : g_object_ref (sorter));
|
||||||
|
|
||||||
switch (id >> 2)
|
switch (id >> 2)
|
||||||
{
|
{
|
||||||
|
@ -220,8 +220,7 @@ new_model (gpointer model)
|
|||||||
GtkSorter *sorter;
|
GtkSorter *sorter;
|
||||||
|
|
||||||
sorter = gtk_custom_sorter_new (compare, NULL, NULL);
|
sorter = gtk_custom_sorter_new (compare, NULL, NULL);
|
||||||
result = gtk_sort_list_model_new (model, sorter);
|
result = gtk_sort_list_model_new (g_object_ref (model), sorter);
|
||||||
g_object_unref (sorter);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
result = gtk_sort_list_model_new (NULL, NULL);
|
result = gtk_sort_list_model_new (NULL, NULL);
|
||||||
|
@ -179,9 +179,7 @@ test_simple (void)
|
|||||||
sort = gtk_sort_list_model_new (model, sorter);
|
sort = gtk_sort_list_model_new (model, sorter);
|
||||||
assert_model (sort, "1 2 21 3 31 32 321");
|
assert_model (sort, "1 2 21 3 31 32 321");
|
||||||
|
|
||||||
g_object_unref (sorter);
|
|
||||||
g_object_unref (sort);
|
g_object_unref (sort);
|
||||||
g_object_unref (model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkSorter *
|
static GtkSorter *
|
||||||
|
Loading…
Reference in New Issue
Block a user