Compare commits

...

6 Commits

Author SHA1 Message Date
Matthias Clasen
0b7f7028d9 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.
2020-07-26 16:25:12 -04:00
Matthias Clasen
5dba053ad1 filterlistmodel: 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.
2020-07-26 15:55:44 -04:00
Matthias Clasen
cd8a810d69 slicelistmodel: 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.
2020-07-26 15:38:15 -04:00
Matthias Clasen
8f63a5ab63 listlistmodel: Drop item_type
We are using G_TYPE_OBJECT throughout, so there
is no need for GtkListListModel to do anything else.

Update all callers.
2020-07-26 14:37:55 -04:00
Matthias Clasen
eb3381723f maplistmodel: 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.
2020-07-26 14:23:16 -04:00
Matthias Clasen
7e87ad1887 flattenlistmodel: Make the 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.
2020-07-26 14:21:28 -04:00
39 changed files with 104 additions and 180 deletions

View File

@@ -174,28 +174,25 @@ constraint_view_init (ConstraintView *self)
manager = gtk_constraint_layout_new ();
gtk_widget_set_layout_manager (GTK_WIDGET (self), manager);
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
guides = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (manager));
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, filter);
g_object_unref (filter);
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
children = (GListModel *)gtk_filter_list_model_new (all_children, filter);
g_object_unref (filter);
list = g_list_store_new (G_TYPE_LIST_MODEL);
g_list_store_append (list, children);
g_list_store_append (list, guides);
g_list_store_append (list, constraints);
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
g_object_unref (children);
g_object_unref (guides);
g_object_unref (constraints);
g_object_unref (all_children);
g_object_unref (all_constraints);
g_object_unref (list);
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
controller = (GtkEventController *)gtk_gesture_drag_new ();
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);

View File

@@ -242,16 +242,11 @@ transform_settings_to_keys (GBinding *binding,
g_object_unref (settings);
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (store),
gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data)));
g_object_unref (store);
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data))));
filter = gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
g_object_unref (sort_model);
g_set_object (&current_filter, filter);
g_object_unref (filter);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
selection_model = gtk_no_selection_new (G_LIST_MODEL (filter_model));
g_object_unref (filter_model);

View File

@@ -1145,6 +1145,7 @@ activate (GApplication *app)
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL);
filter = gtk_custom_filter_new ((GtkCustomFilterFunc)demo_filter_by_name, filter_model, NULL);
gtk_filter_list_model_set_filter (filter_model, filter);
g_object_unref (filter);
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);

View File

@@ -1500,8 +1500,8 @@ gtk_column_view_get_list_view (GtkColumnView *self)
* |[
* gtk_column_view_column_set_sorter (column, sorter);
* gtk_column_view_append_column (view, column);
* model = gtk_sort_list_model_new (store,
* gtk_column_view_get_sorter (view));
* sorter = g_object_ref (gtk_column_view_get_sorter (view)));
* model = gtk_sort_list_model_new (store, sorter);
* selection = gtk_no_selection_new (model);
* gtk_column_view_set_model (view, selection);
* ]|

View File

@@ -322,12 +322,9 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
g_object_unref (printer_list);
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (printer_list_list)));
g_object_unref (printer_list_list);
filter = gtk_custom_filter_new (match_func, NULL, NULL);
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
g_object_unref (full_list);
g_object_unref (filter);
dialog->custom_paper_list = g_list_store_new (GTK_TYPE_PAGE_SETUP);
gtk_print_load_custom_papers (dialog->custom_paper_list);

View File

@@ -666,7 +666,7 @@ gtk_drop_down_set_model (GtkDropDown *self,
GListModel *filter_model;
GListModel *selection;
filter_model = G_LIST_MODEL (gtk_filter_list_model_new (model, NULL));
filter_model = G_LIST_MODEL (gtk_filter_list_model_new (g_object_ref (model), NULL));
g_set_object (&self->filter_model, filter_model);
g_object_unref (filter_model);

View File

@@ -614,8 +614,8 @@ gtk_filter_list_model_init (GtkFilterListModel *self)
/**
* gtk_filter_list_model_new:
* @model: (allow-none): the model to sort
* @filter: (allow-none): filter or %NULL to not filter items
* @model: (allow-none) (transfer full): the model to sort, or %NULL
* @filter: (allow-none) (transfer full): filter or %NULL to not filter items
*
* Creates a new #GtkFilterListModel that will filter @model using the given
* @filter.
@@ -636,6 +636,10 @@ gtk_filter_list_model_new (GListModel *model,
"filter", filter,
NULL);
/* consume the references */
g_clear_object (&model);
g_clear_object (&filter);
return result;
}

View File

@@ -425,7 +425,7 @@ gtk_flatten_list_model_init (GtkFlattenListModel *self)
/**
* gtk_flatten_list_model_new:
* @model: (nullable) (transfer none): the model to be flattened
* @model: (nullable) (transfer full): the model to be flattened
*
* Creates a new #GtkFlattenListModel that flattens @list.
*
@@ -442,6 +442,9 @@ gtk_flatten_list_model_new (GListModel *model)
"model", model,
NULL);
/* we consume the reference */
g_clear_object (&model);
return result;
}

View File

@@ -784,7 +784,7 @@ update_fontlist (GtkFontChooserWidget *self)
if ((self->level & GTK_FONT_CHOOSER_LEVEL_STYLE) == 0)
model = g_object_ref (G_LIST_MODEL (fontmap));
else
model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (fontmap)));
model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (g_object_ref (fontmap))));
gtk_filter_list_model_set_model (self->filter_model, model);
g_object_unref (model);
}

View File

@@ -36,7 +36,6 @@ struct _GtkListListModel
{
GObject parent_instance;
GType item_type;
guint n_items;
gpointer (* get_first) (gpointer);
gpointer (* get_next) (gpointer, gpointer);
@@ -55,9 +54,7 @@ struct _GtkListListModelClass
static GType
gtk_list_list_model_get_item_type (GListModel *list)
{
GtkListListModel *self = GTK_LIST_LIST_MODEL (list);
return self->item_type;
return G_TYPE_OBJECT;
}
static guint
@@ -143,8 +140,7 @@ gtk_list_list_model_init (GtkListListModel *self)
}
GtkListListModel *
gtk_list_list_model_new (GType item_type,
gpointer (* get_first) (gpointer),
gtk_list_list_model_new (gpointer (* get_first) (gpointer),
gpointer (* get_next) (gpointer, gpointer),
gpointer (* get_previous) (gpointer, gpointer),
gpointer (* get_last) (gpointer),
@@ -161,8 +157,7 @@ gtk_list_list_model_new (GType item_type,
item = get_next (item, data))
n_items++;
return gtk_list_list_model_new_with_size (item_type,
n_items,
return gtk_list_list_model_new_with_size (n_items,
get_first,
get_next,
get_previous,
@@ -173,8 +168,7 @@ gtk_list_list_model_new (GType item_type,
}
GtkListListModel *
gtk_list_list_model_new_with_size (GType item_type,
guint n_items,
gtk_list_list_model_new_with_size (guint n_items,
gpointer (* get_first) (gpointer),
gpointer (* get_next) (gpointer, gpointer),
gpointer (* get_previous) (gpointer, gpointer),
@@ -185,7 +179,6 @@ gtk_list_list_model_new_with_size (GType item_type,
{
GtkListListModel *result;
g_return_val_if_fail (g_type_is_a (item_type, G_TYPE_OBJECT), NULL);
g_return_val_if_fail (get_first != NULL, NULL);
g_return_val_if_fail (get_next != NULL, NULL);
g_return_val_if_fail (get_previous != NULL, NULL);
@@ -193,7 +186,6 @@ gtk_list_list_model_new_with_size (GType item_type,
result = g_object_new (GTK_TYPE_LIST_LIST_MODEL, NULL);
result->item_type = item_type;
result->n_items = n_items;
result->get_first = get_first;
result->get_next = get_next;

View File

@@ -37,8 +37,7 @@ typedef struct _GtkListListModelClass GtkListListModelClass;
GType gtk_list_list_model_get_type (void) G_GNUC_CONST;
GtkListListModel * gtk_list_list_model_new (GType item_type,
gpointer (* get_first) (gpointer),
GtkListListModel * gtk_list_list_model_new (gpointer (* get_first) (gpointer),
gpointer (* get_next) (gpointer, gpointer),
gpointer (* get_previous) (gpointer, gpointer),
gpointer (* get_last) (gpointer),
@@ -46,8 +45,7 @@ GtkListListModel * gtk_list_list_model_new (GType
gpointer data,
GDestroyNotify notify);
GtkListListModel * gtk_list_list_model_new_with_size (GType item_type,
guint n_items,
GtkListListModel * gtk_list_list_model_new_with_size (guint n_items,
gpointer (* get_first) (gpointer),
gpointer (* get_next) (gpointer, gpointer),
gpointer (* get_previous) (gpointer, gpointer),

View File

@@ -412,7 +412,7 @@ gtk_map_list_model_augment (GtkRbTree *map,
/**
* gtk_map_list_model_new:
* @model: (allow-none): The model to map or %NULL for none
* @model: (transfer full) (allow-none): The model to map or %NULL for none
* @map_func: (allow-none): map function or %NULL to not map items
* @user_data: (closure): user data passed to @map_func
* @user_destroy: destroy notifier for @user_data
@@ -435,6 +435,9 @@ gtk_map_list_model_new (GListModel *model,
"model", model,
NULL);
/* consume the reference */
g_clear_object (&model);
if (map_func)
gtk_map_list_model_set_map_func (result, map_func, user_data, user_destroy);

View File

@@ -308,7 +308,6 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
g_list_store_append (store, dialog->manage_papers_list);
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
gtk_drop_down_set_model (GTK_DROP_DOWN (dialog->paper_size_combo), paper_size_list);
g_object_unref (store);
g_object_unref (paper_size_list);
/* Do this in code, we want the translatable strings without the markup */
@@ -325,8 +324,6 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
filter = gtk_custom_filter_new (match_func, NULL, NULL);
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
g_object_unref (full_list);
g_object_unref (filter);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_printer_item), dialog);

View File

@@ -807,14 +807,12 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
g_list_store_append (store, dialog->manage_papers_list);
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
gtk_drop_down_set_model (GTK_DROP_DOWN (dialog->paper_size_combo), paper_size_list);
g_object_unref (store);
g_object_unref (paper_size_list);
/* Load backends */
model = load_print_backends (dialog);
sorter = gtk_custom_sorter_new (default_printer_list_sort_func, NULL, NULL);
sorted = G_LIST_MODEL (gtk_sort_list_model_new (model, sorter));
g_object_unref (sorter);
filter = gtk_every_filter_new ();
@@ -831,7 +829,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), filter1);
filtered = G_LIST_MODEL (gtk_filter_list_model_new (sorted, filter));
g_object_unref (filter);
selection = G_LIST_MODEL (gtk_single_selection_new (filtered));
gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (selection), FALSE);
@@ -841,7 +838,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
g_signal_connect_swapped (selection, "notify::selected", G_CALLBACK (selected_printer_changed), dialog);
g_object_unref (selection);
g_object_unref (filtered);
g_object_unref (model);
gtk_print_load_custom_papers (dialog->custom_paper_list);
@@ -1037,7 +1033,6 @@ load_print_backends (GtkPrintUnixDialog *dialog)
{
GList *node;
GListStore *lists;
GListModel *model;
lists = g_list_store_new (G_TYPE_LIST_MODEL);
@@ -1053,11 +1048,7 @@ load_print_backends (GtkPrintUnixDialog *dialog)
g_list_store_append (lists, gtk_print_backend_get_printers (backend));
}
model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (lists)));
g_object_unref (lists);
return model;
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (lists)));
}
static void

View File

@@ -44,21 +44,16 @@ G_DEFINE_INTERFACE (GtkShortcutManager, gtk_shortcut_manager, G_TYPE_OBJECT)
void
gtk_shortcut_manager_create_controllers (GtkWidget *widget)
{
GListStore *store;
GtkFlattenListModel *model;
GtkEventController *controller;
store = g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER);
model = gtk_flatten_list_model_new (G_LIST_MODEL (store));
g_object_unref (store);
model = gtk_flatten_list_model_new (G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER)));
g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-bubble", model, g_object_unref);
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-bubble");
gtk_widget_add_controller (widget, controller);
store = g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER);
model = gtk_flatten_list_model_new (G_LIST_MODEL (store));
g_object_unref (store);
model = gtk_flatten_list_model_new (G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER)));
g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-capture", model, g_object_unref);
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-capture");

View File

@@ -30,11 +30,12 @@
* @short_description: A list model that presents a slice out of a larger list
* @see_also: #GListModel
*
* #GtkSliceListModel is a list model that takes a list model and presents a slice of
* that model.
* #GtkSliceListModel is a list model that takes a list model and presents a
* slice of that model.
*
* This is useful when implementing paging by setting the size to the number of elements
* per page and updating the offset whenever a different page is opened.
* This is useful when implementing paging by setting the size to the number
* of elements per page and updating the offset whenever a different page is
* opened.
*/
#define DEFAULT_SIZE 10
@@ -300,7 +301,7 @@ gtk_slice_list_model_init (GtkSliceListModel *self)
/**
* gtk_slice_list_model_new:
* @model: (transfer none) (allow-none): The model to use
* @model: (transfer full) (allow-none): The model to use, or %NULL
* @offset: the offset of the slice
* @size: maximum size of the slice
*
@@ -314,13 +315,20 @@ gtk_slice_list_model_new (GListModel *model,
guint offset,
guint size)
{
GtkSliceListModel *self;
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
return g_object_new (GTK_TYPE_SLICE_LIST_MODEL,
self = g_object_new (GTK_TYPE_SLICE_LIST_MODEL,
"model", model,
"offset", offset,
"size", size,
NULL);
/* consume the reference */
g_clear_object (&model);
return self;
}
/**

View File

@@ -828,8 +828,8 @@ gtk_sort_list_model_init (GtkSortListModel *self)
/**
* gtk_sort_list_model_new:
* @model: (allow-none): the model to sort
* @sorter: (allow-none): the #GtkSorter to sort @model with
* @model: (allow-none) (transfer full): the model to sort, or %NULL
* @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.
*
@@ -849,6 +849,10 @@ gtk_sort_list_model_new (GListModel *model,
"sorter", sorter,
NULL);
/* consume the references */
g_clear_object (&model);
g_clear_object (&sorter);
return result;
}

View File

@@ -11535,8 +11535,7 @@ gtk_widget_observe_children (GtkWidget *widget)
if (priv->children_observer)
return g_object_ref (G_LIST_MODEL (priv->children_observer));
priv->children_observer = gtk_list_list_model_new (GTK_TYPE_WIDGET,
(gpointer) gtk_widget_get_first_child,
priv->children_observer = gtk_list_list_model_new ((gpointer) gtk_widget_get_first_child,
(gpointer) gtk_widget_get_next_sibling,
(gpointer) gtk_widget_get_prev_sibling,
(gpointer) gtk_widget_get_last_child,
@@ -11622,14 +11621,13 @@ gtk_widget_observe_controllers (GtkWidget *widget)
if (priv->controller_observer)
return g_object_ref (G_LIST_MODEL (priv->controller_observer));
priv->controller_observer = gtk_list_list_model_new (GTK_TYPE_EVENT_CONTROLLER,
gtk_widget_controller_list_get_first,
gtk_widget_controller_list_get_next,
gtk_widget_controller_list_get_prev,
NULL,
(gpointer) g_object_ref,
widget,
gtk_widget_controller_observer_destroyed);
priv->controller_observer = gtk_list_list_model_new (gtk_widget_controller_list_get_first,
gtk_widget_controller_list_get_next,
gtk_widget_controller_list_get_prev,
NULL,
(gpointer) g_object_ref,
widget,
gtk_widget_controller_observer_destroyed);
return G_LIST_MODEL (priv->controller_observer);
}

View File

@@ -46,7 +46,7 @@ struct _GtkInspectorActions
GObject *object;
GListModel *actions;
GListStore *actions;
GtkColumnViewColumn *name;
};
@@ -79,7 +79,7 @@ action_added (GObject *owner,
GtkInspectorActions *sl)
{
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);
}
@@ -283,7 +283,7 @@ add_muxer (GtkInspectorActions *sl,
static gboolean
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))
{
@@ -395,9 +395,9 @@ constructed (GObject *object)
gtk_column_view_column_set_sorter (sl->name, sorter);
g_object_unref (sorter);
sl->actions = G_LIST_MODEL (g_list_store_new (ACTION_TYPE_HOLDER));
sorted = G_LIST_MODEL (gtk_sort_list_model_new (sl->actions,
gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->list))));
sl->actions = g_list_store_new (ACTION_TYPE_HOLDER);
sorted = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (sl->actions)),
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->list)))));
model = G_LIST_MODEL (gtk_no_selection_new (sorted));
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->list), model);
g_object_unref (sorted);

View File

@@ -244,13 +244,11 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
gtk_property_lookup_list_model_set_object (self->model, object);
map_model = gtk_map_list_model_new (G_LIST_MODEL (self->model), map_to_controllers, NULL, NULL);
g_object_unref (self->model);
flatten_model = gtk_flatten_list_model_new (G_LIST_MODEL (map_model));
sorter = gtk_custom_sorter_new (compare_controllers, NULL, NULL);
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),
G_LIST_MODEL (sort_model),
@@ -259,8 +257,6 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
NULL);
g_object_unref (sort_model);
g_object_unref (flatten_model);
g_object_unref (map_model);
}
static void

View File

@@ -116,7 +116,6 @@ static GListModel *
object_tree_widget_get_children (GObject *object)
{
GtkWidget *widget = GTK_WIDGET (object);
GtkFlattenListModel *flatten;
GListStore *list;
GListModel *sublist;
@@ -130,10 +129,7 @@ object_tree_widget_get_children (GObject *object)
g_list_store_append (list, sublist);
g_object_unref (sublist);
flatten = gtk_flatten_list_model_new (G_LIST_MODEL (list));
g_object_unref (list);
return G_LIST_MODEL (flatten);
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
}
static GListModel *
@@ -211,7 +207,6 @@ list_model_for_properties (GObject *object,
const char **props)
{
GListStore *concat;
GListModel *result;
guint i;
if (props[1] == NULL)
@@ -225,9 +220,7 @@ list_model_for_properties (GObject *object,
g_object_unref (tmp);
}
result = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (concat)));
g_object_unref (concat);
return result;
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (concat)));
}
static GListModel *
@@ -310,7 +303,6 @@ object_tree_tree_view_get_children (GObject *object)
GtkTreeView *treeview = GTK_TREE_VIEW (object);
GListStore *columns, *selection, *result_list;
GListModel *props;
GtkFlattenListModel *result;
guint i;
props = list_model_for_properties (object, (const char *[2]) { "model", NULL });
@@ -330,10 +322,8 @@ object_tree_tree_view_get_children (GObject *object)
g_object_unref (selection);
g_list_store_append (result_list, columns);
g_object_unref (columns);
result = gtk_flatten_list_model_new (G_LIST_MODEL (result_list));
g_object_unref (result_list);
return G_LIST_MODEL (result);
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
}
static GListModel *
@@ -341,7 +331,6 @@ object_tree_column_view_get_children (GObject *object)
{
GtkColumnView *view = GTK_COLUMN_VIEW (object);
GListStore *result_list;
GtkFlattenListModel *result;
GListModel *columns, *sublist;
result_list = g_list_store_new (G_TYPE_LIST_MODEL);
@@ -353,10 +342,7 @@ object_tree_column_view_get_children (GObject *object)
g_list_store_append (result_list, sublist);
g_object_unref (sublist);
result = gtk_flatten_list_model_new (G_LIST_MODEL (result_list));
g_object_unref (result_list);
return G_LIST_MODEL (result);
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
}
static GListModel *
@@ -602,12 +588,11 @@ static GListModel *
object_get_children (GObject *object)
{
GType object_type;
GListModel *result, *children;
GListModel *children;
GListStore *result_list;
guint i;
object_type = G_OBJECT_TYPE (object);
result = NULL;
result_list = NULL;
for (i = 0; i < G_N_ELEMENTS (object_tree_class_funcs); i++)
@@ -619,32 +604,17 @@ object_get_children (GObject *object)
if (children == NULL)
continue;
if (result_list)
{
g_list_store_append (result_list, children);
g_object_unref (children);
}
else if (result == NULL)
{
result = children;
}
else
{
result_list = g_list_store_new (G_TYPE_LIST_MODEL);
g_list_store_append (result_list, result);
g_object_unref (result);
g_list_store_append (result_list, children);
g_object_unref (children);
}
if (!result_list)
result_list = g_list_store_new (G_TYPE_LIST_MODEL);
g_list_store_append (result_list, children);
g_object_unref (children);
}
if (result_list)
{
result = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
g_object_unref (result_list);
}
return result;
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
else
return NULL;
}
static const char *
@@ -1167,7 +1137,6 @@ create_root_model (GdkDisplay *display)
{
GtkFilter *custom_filter;
GtkFilterListModel *filter;
GtkFlattenListModel *flatten;
GListStore *list, *special;
gpointer item;
@@ -1182,16 +1151,13 @@ create_root_model (GdkDisplay *display)
g_object_unref (special);
filter = gtk_filter_list_model_new (NULL, NULL);
custom_filter = gtk_custom_filter_new (toplevel_filter_func,
display, NULL);
custom_filter = gtk_custom_filter_new (toplevel_filter_func, display, NULL);
gtk_filter_list_model_set_filter (filter, custom_filter);
gtk_filter_list_model_set_model (filter, gtk_window_get_toplevels ());
g_list_store_append (list, filter);
g_object_unref (filter);
flatten = gtk_flatten_list_model_new (G_LIST_MODEL (list));
g_object_unref (list);
return G_LIST_MODEL (flatten);
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
}
static void

View File

@@ -622,7 +622,7 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
if (GTK_IS_WIDGET (object))
g_signal_connect_object (object, "destroy", G_CALLBACK (cleanup_object), pl, G_CONNECT_SWAPPED);
filtered = G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (store), pl->priv->filter));
filtered = G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (store), g_object_ref (pl->priv->filter)));
sorted = gtk_sort_list_model_new (filtered, NULL);
list = G_LIST_MODEL (gtk_no_selection_new (G_LIST_MODEL (sorted)));
@@ -634,8 +634,6 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
g_object_unref (list);
g_object_unref (sorted);
g_object_unref (filtered);
g_object_unref (store);
return TRUE;
}

View File

@@ -712,11 +712,10 @@ constructed (GObject *object)
column_sorter = gtk_column_view_get_sorter (GTK_COLUMN_VIEW (rl->list));
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);
g_object_unref (root_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));

View File

@@ -759,7 +759,6 @@ main (int argc, char *argv[])
custom_filter = gtk_custom_filter_new (match_file, g_object_ref (search_entry), g_object_unref);
filter = gtk_filter_list_model_new (G_LIST_MODEL (sort), custom_filter);
g_signal_connect (search_entry, "search-changed", G_CALLBACK (search_changed_cb), custom_filter);
g_object_unref (custom_filter);
gtk_column_view_set_model (GTK_COLUMN_VIEW (view), G_LIST_MODEL (filter));
@@ -771,8 +770,6 @@ main (int argc, char *argv[])
gtk_box_append (GTK_BOX (vbox), statusbar);
g_object_unref (filter);
g_object_unref (sort);
g_object_unref (tree);
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))));

View File

@@ -127,7 +127,6 @@ main (int argc,
add (store);
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);
g_object_unref (sorter);
win = gtk_window_new ();
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))
g_main_context_iteration (NULL, TRUE);
g_object_unref (store);
return 0;
}

View File

@@ -318,7 +318,6 @@ get_file_path (GFileInfo *info)
static GListModel *
create_list_model_for_directory (gpointer file)
{
GtkSortListModel *sort;
GtkDirectoryList *dir;
GtkSorter *sorter;
@@ -327,12 +326,8 @@ create_list_model_for_directory (gpointer 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));
sort = gtk_sort_list_model_new (G_LIST_MODEL (dir), sorter);
g_object_unref (sorter);
g_object_unref (dir);
return G_LIST_MODEL (sort);
return G_LIST_MODEL (gtk_sort_list_model_new (G_LIST_MODEL (dir), sorter));
}
typedef struct _RowData RowData;
@@ -640,7 +635,6 @@ main (int argc, char *argv[])
custom_filter = gtk_custom_filter_new (match_file, search_entry, NULL);
filter = gtk_filter_list_model_new (G_LIST_MODEL (tree), custom_filter);
g_signal_connect (search_entry, "search-changed", G_CALLBACK (search_changed_cb), custom_filter);
g_object_unref (custom_filter);
selectionmodel = file_info_selection_new (G_LIST_MODEL (filter));
g_object_unref (filter);
@@ -654,7 +648,6 @@ main (int argc, char *argv[])
update_statusbar (GTK_STATUSBAR (statusbar));
gtk_box_append (GTK_BOX (vbox), statusbar);
g_object_unref (tree);
g_object_unref (selectionmodel);
gtk_widget_show (win);

View File

@@ -262,8 +262,6 @@ test_nested (void)
g_assert_cmpint (counter, ==, 0);
g_object_unref (filtered);
g_object_unref (list);
g_object_unref (filter);
gtk_expression_unref (expr);
}

View File

@@ -189,7 +189,7 @@ new_model (guint size,
{
GtkFilterListModel *result;
result = gtk_filter_list_model_new (G_LIST_MODEL (new_store (1, size, 1)), filter);
result = gtk_filter_list_model_new (g_object_ref (G_LIST_MODEL (new_store (1, size, 1))), g_object_ref (filter));
return result;
}

View File

@@ -135,6 +135,10 @@ filter_list_model_new (GListModel *source,
GListStore *check;
guint i;
if (source)
g_object_ref (source);
if (filter)
g_object_ref (filter);
model = gtk_filter_list_model_new (source, filter);
check = g_list_store_new (G_TYPE_OBJECT);
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model)); i++)
@@ -443,8 +447,6 @@ test_model_changes (gconstpointer model_id)
g_object_unref (model2);
g_object_unref (flatten2);
g_object_unref (flatten1);
g_object_unref (store2);
g_object_unref (store1);
g_object_unref (multi);
}

View File

@@ -167,8 +167,7 @@ new_model (guint size,
filter = gtk_custom_filter_new (filter_func, data, NULL);
else
filter = NULL;
result = gtk_filter_list_model_new (G_LIST_MODEL (new_store (1, size, 1)), filter);
g_clear_object (&filter);
result = gtk_filter_list_model_new (g_object_ref (G_LIST_MODEL (new_store (1, size, 1))), filter);
changes = g_string_new ("");
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);

View File

@@ -210,7 +210,7 @@ new_model (GListStore *store)
GtkFlattenListModel *result;
GString *changes;
result = gtk_flatten_list_model_new (G_LIST_MODEL (store));
result = gtk_flatten_list_model_new (g_object_ref (G_LIST_MODEL (store)));
changes = g_string_new ("");
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);

View File

@@ -196,7 +196,7 @@ new_model (GListStore *store)
GtkMapListModel *result;
GString *changes;
result = gtk_map_list_model_new (G_LIST_MODEL (store), map_multiply, GUINT_TO_POINTER (2), NULL);
result = gtk_map_list_model_new (g_object_ref (G_LIST_MODEL (store)), map_multiply, GUINT_TO_POINTER (2), NULL);
changes = g_string_new ("");
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);

View File

@@ -627,7 +627,7 @@ test_set_model (void)
store = new_store (1, 5, 1);
m1 = G_LIST_MODEL (store);
m2 = G_LIST_MODEL (gtk_slice_list_model_new (m1, 0, 3));
m2 = G_LIST_MODEL (gtk_slice_list_model_new (g_object_ref (m1), 0, 3));
selection = new_model (store);
assert_selection (selection, "");
assert_selection_changes (selection, "");

View File

@@ -653,7 +653,7 @@ test_set_model (void)
store = new_store (1, 5, 1);
m1 = G_LIST_MODEL (store);
m2 = G_LIST_MODEL (gtk_slice_list_model_new (m1, 0, 3));
m2 = G_LIST_MODEL (gtk_slice_list_model_new (g_object_ref (m1), 0, 3));
selection = new_model (store, TRUE, TRUE);
assert_selection (selection, "1");
assert_selection_changes (selection, "");

View File

@@ -191,7 +191,7 @@ new_model (GListStore *store, guint offset, guint size)
GtkSliceListModel *result;
GString *changes;
result = gtk_slice_list_model_new (G_LIST_MODEL (store), offset, size);
result = gtk_slice_list_model_new (g_object_ref (G_LIST_MODEL (store)), offset, size);
changes = g_string_new ("");
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);

View File

@@ -247,7 +247,7 @@ new_model (guint size,
{
GtkSortListModel *result;
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))), g_object_ref (sorter));
return result;
}
@@ -630,8 +630,8 @@ test_stable (void)
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi), b);
model1 = new_model (20, multi);
g_object_unref (multi);
model2b = gtk_sort_list_model_new (gtk_sort_list_model_get_model (model1), b);
model2 = gtk_sort_list_model_new (G_LIST_MODEL (model2b), a);
model2b = gtk_sort_list_model_new (g_object_ref (gtk_sort_list_model_get_model (model1)), b);
model2 = gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (model2b)), a);
assert_model_equal (model1, model2);
modify_sorter (a);

View File

@@ -200,9 +200,9 @@ create_sort_list_model (gconstpointer model_id,
guint id = GPOINTER_TO_UINT (model_id);
if (track_changes)
model = sort_list_model_new (id & 1 ? NULL : source, id & 2 ? NULL : sorter);
model = sort_list_model_new (id & 1 ? NULL : g_object_ref (source), id & 2 ? NULL : g_object_ref (sorter));
else
model = gtk_sort_list_model_new (id & 1 ? NULL : source, id & 2 ? NULL : sorter);
model = gtk_sort_list_model_new (id & 1 ? NULL : g_object_ref (source), id & 2 ? NULL : g_object_ref (sorter));
switch (id >> 2)
{
@@ -433,7 +433,6 @@ test_stability (gconstpointer model_id)
g_object_unref (sort2);
g_object_unref (sort1);
g_object_unref (flatten);
g_object_unref (store);
}
static void

View File

@@ -220,8 +220,7 @@ new_model (gpointer model)
GtkSorter *sorter;
sorter = gtk_custom_sorter_new (compare, NULL, NULL);
result = gtk_sort_list_model_new (model, sorter);
g_object_unref (sorter);
result = gtk_sort_list_model_new (g_object_ref (model), sorter);
}
else
result = gtk_sort_list_model_new (NULL, NULL);

View File

@@ -179,9 +179,7 @@ test_simple (void)
sort = gtk_sort_list_model_new (model, sorter);
assert_model (sort, "1 2 21 3 31 32 321");
g_object_unref (sorter);
g_object_unref (sort);
g_object_unref (model);
}
static GtkSorter *