Compare commits

..

5 Commits

Author SHA1 Message Date
Matthias Clasen
b6d908b8aa selectionfiltermodel: Make constructor allow-none
We don't pay attention to item-type anymore, so
drop the item-type property and the _for_item_type()
constructor, and allow passing NULL to the regular
constructor.

We don't make this constructor transfer-full, since
the selection filter model is not a wrapping model
like the others. It is more like fork than a wrap.
2020-07-26 17:35:49 -04:00
Matthias Clasen
c659910a83 multiselection: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Also make the constructor return GtkMultiSelection *.

Update all callers.
2020-07-26 17:25:06 -04:00
Matthias Clasen
1af097455c singleselection: 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 17:16:15 -04:00
Matthias Clasen
6873f63987 noselection: 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:55:43 -04:00
Matthias Clasen
16b043a127 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.
2020-07-26 16:38:53 -04:00
30 changed files with 79 additions and 140 deletions

View File

@@ -462,7 +462,6 @@ do_listview_clocks (GtkWidget *do_widget)
{
GtkWidget *gridview, *sw;
GtkListItemFactory *factory;
GListModel *model;
GtkNoSelection *selection;
/* This is the normal window setup code every demo does */
@@ -489,12 +488,10 @@ do_listview_clocks (GtkWidget *do_widget)
gtk_scrollable_set_hscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
gtk_scrollable_set_vscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
model = create_clocks_model ();
selection = gtk_no_selection_new (model);
selection = gtk_no_selection_new (create_clocks_model ());
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), G_LIST_MODEL (selection));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
g_object_unref (selection);
g_object_unref (model);
}
if (!gtk_widget_get_visible (window))

View File

@@ -884,7 +884,7 @@ do_listview_colors (GtkWidget *do_widget)
sort_model = gtk_sort_list_model_new (gtk_color_list_new (0), NULL);
gtk_sort_list_model_set_incremental (sort_model, TRUE);
selection = GTK_MULTI_SELECTION (gtk_multi_selection_new (G_LIST_MODEL (sort_model)));
selection = gtk_multi_selection_new (G_LIST_MODEL (sort_model));
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Colors");
@@ -970,7 +970,6 @@ do_listview_colors (GtkWidget *do_widget)
no_selection = G_LIST_MODEL (gtk_no_selection_new (selection_filter));
gtk_grid_view_set_model (GTK_GRID_VIEW (selection_view), no_selection);
g_object_unref (selection_filter);
g_object_unref (no_selection);
selection_info_toggle = gtk_toggle_button_new ();

View File

@@ -214,7 +214,6 @@ transform_settings_to_keys (GBinding *binding,
GtkSortListModel *sort_model;
GtkFilterListModel *filter_model;
GtkFilter *filter;
GtkNoSelection *selection_model;
char **keys;
guint i;
@@ -248,10 +247,7 @@ transform_settings_to_keys (GBinding *binding,
g_set_object (&current_filter, 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);
g_value_take_object (to_value, selection_model);
g_value_take_object (to_value, gtk_no_selection_new (G_LIST_MODEL (filter_model)));
return TRUE;
}
@@ -398,8 +394,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,
@@ -413,8 +409,6 @@ do_listview_settings (GtkWidget *do_widget)
columnview, NULL);
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"));

View File

@@ -281,7 +281,7 @@ GtkWidget *
create_weather_view (void)
{
GtkWidget *listview;
GListModel *model, *selection;
GListModel *selection;
GtkListItemFactory *factory;
factory = gtk_signal_list_item_factory_new ();
@@ -290,11 +290,9 @@ create_weather_view (void)
listview = gtk_list_view_new_with_factory (factory);
gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
model = create_weather_model ();
selection = G_LIST_MODEL (gtk_no_selection_new (model));
selection = G_LIST_MODEL (gtk_no_selection_new (create_weather_model ()));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
g_object_unref (selection);
g_object_unref (model);
return listview;
}

View File

@@ -226,7 +226,6 @@ do_listview_words (GtkWidget *do_widget)
g_signal_connect (filter_model, "notify::pending", G_CALLBACK (update_title_cb), progress);
update_title_cb (filter_model);
g_object_unref (filter_model);
}
if (!gtk_widget_get_visible (window))

View File

@@ -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,

View File

@@ -896,7 +896,7 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
listview = gtk_list_view_new ();
gtk_widget_set_size_request (listview, 140, -1);
model = G_LIST_MODEL (gtk_single_selection_new (G_LIST_MODEL (dialog->custom_paper_list)));
model = G_LIST_MODEL (gtk_single_selection_new (g_object_ref (G_LIST_MODEL (dialog->custom_paper_list))));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), model);
g_signal_connect (model, "notify::selected", G_CALLBACK (selected_custom_paper_changed), dialog);
g_object_unref (model);

View File

@@ -668,7 +668,6 @@ gtk_drop_down_set_model (GtkDropDown *self,
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);
update_filter (self);
@@ -677,7 +676,7 @@ gtk_drop_down_set_model (GtkDropDown *self,
gtk_list_view_set_model (GTK_LIST_VIEW (self->popup_list), selection);
g_object_unref (selection);
selection = G_LIST_MODEL (gtk_single_selection_new (model));
selection = G_LIST_MODEL (gtk_single_selection_new (g_object_ref (model)));
g_set_object (&self->selection, selection);
g_object_unref (selection);

View File

@@ -2130,7 +2130,7 @@ gtk_list_base_set_model (GtkListBase *self,
if (GTK_IS_SELECTION_MODEL (model))
selection_model = GTK_SELECTION_MODEL (g_object_ref (model));
else
selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (model)));
gtk_list_item_manager_set_model (priv->item_manager, selection_model);
gtk_list_base_set_anchor (self, 0, 0.0, GTK_PACK_START, 0.0, GTK_PACK_START);

View File

@@ -370,20 +370,27 @@ gtk_multi_selection_init (GtkMultiSelection *self)
/**
* gtk_multi_selection_new:
* @model: (transfer none): the #GListModel to manage
* @model: (allow-none) (transfer full): the #GListModel to manage, or %NULL
*
* Creates a new selection to handle @model.
*
* Returns: (transfer full) (type GtkMultiSelection): a new #GtkMultiSelection
* Returns: (transfer full): a new #GtkMultiSelection
**/
GListModel *
GtkMultiSelection *
gtk_multi_selection_new (GListModel *model)
{
GtkMultiSelection *self;
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
return g_object_new (GTK_TYPE_MULTI_SELECTION,
self = g_object_new (GTK_TYPE_MULTI_SELECTION,
"model", model,
NULL);
/* consume the reference */
g_clear_object (&model);
return self;
}
/**

View File

@@ -31,13 +31,13 @@ GDK_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (GtkMultiSelection, gtk_multi_selection, GTK, MULTI_SELECTION, GObject)
GDK_AVAILABLE_IN_ALL
GListModel * gtk_multi_selection_new (GListModel *model);
GtkMultiSelection * gtk_multi_selection_new (GListModel *model);
GDK_AVAILABLE_IN_ALL
GListModel * gtk_multi_selection_get_model (GtkMultiSelection *self);
GListModel * gtk_multi_selection_get_model (GtkMultiSelection *self);
GDK_AVAILABLE_IN_ALL
void gtk_multi_selection_set_model (GtkMultiSelection *self,
GListModel *model);
void gtk_multi_selection_set_model (GtkMultiSelection *self,
GListModel *model);
G_END_DECLS

View File

@@ -216,7 +216,7 @@ gtk_no_selection_init (GtkNoSelection *self)
/**
* gtk_no_selection_new:
* @model: (transfer none): the #GListModel to manage
* @model: (allow-none) (transfer full): the #GListModel to manage, or %NULL
*
* Creates a new selection to handle @model.
*
@@ -225,11 +225,18 @@ gtk_no_selection_init (GtkNoSelection *self)
GtkNoSelection *
gtk_no_selection_new (GListModel *model)
{
GtkNoSelection *self;
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
return g_object_new (GTK_TYPE_NO_SELECTION,
self = g_object_new (GTK_TYPE_NO_SELECTION,
"model", model,
NULL);
/* consume the reference */
g_clear_object (&model);
return self;
}
/**
@@ -253,8 +260,8 @@ gtk_no_selection_get_model (GtkNoSelection *self)
* @self: a #GtkNoSelection
* @model: (allow-none): A #GListModel to wrap
*
* Sets the model that @self should wrap. If @model is %NULL, this
* model will be empty.
* Sets the model that @self should wrap.
* If @model is %NULL, this model will be empty.
**/
void
gtk_no_selection_set_model (GtkNoSelection *self,

View File

@@ -837,7 +837,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
g_signal_connect (selection, "items-changed", G_CALLBACK (printer_added_cb), dialog);
g_signal_connect_swapped (selection, "notify::selected", G_CALLBACK (selected_printer_changed), dialog);
g_object_unref (selection);
g_object_unref (filtered);
gtk_print_load_custom_papers (dialog->custom_paper_list);

View File

@@ -37,7 +37,6 @@
enum {
PROP_0,
PROP_ITEM_TYPE,
PROP_MODEL,
NUM_PROPERTIES
};
@@ -46,7 +45,6 @@ struct _GtkSelectionFilterModel
{
GObject parent_instance;
GType item_type;
GtkSelectionModel *model;
GtkBitset *selection;
};
@@ -61,9 +59,7 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
static GType
gtk_selection_filter_model_get_item_type (GListModel *list)
{
GtkSelectionFilterModel *self = GTK_SELECTION_FILTER_MODEL (list);
return self->item_type;
return G_TYPE_OBJECT;
}
static guint
@@ -159,10 +155,6 @@ gtk_selection_filter_model_set_property (GObject *object,
switch (prop_id)
{
case PROP_ITEM_TYPE:
self->item_type = g_value_get_gtype (value);
break;
case PROP_MODEL:
gtk_selection_filter_model_set_model (self, g_value_get_object (value));
break;
@@ -183,10 +175,6 @@ gtk_selection_filter_model_get_property (GObject *object,
switch (prop_id)
{
case PROP_ITEM_TYPE:
g_value_set_gtype (value, self->item_type);
break;
case PROP_MODEL:
g_value_set_object (value, self->model);
break;
@@ -229,18 +217,6 @@ gtk_selection_filter_model_class_init (GtkSelectionFilterModelClass *class)
gobject_class->get_property = gtk_selection_filter_model_get_property;
gobject_class->dispose = gtk_selection_filter_model_dispose;
/**
* GtkSelectionFilterModel:item-type:
*
* The #GType for elements of this object
*/
properties[PROP_ITEM_TYPE] =
g_param_spec_gtype ("item-type",
P_("Item type"),
P_("The type of elements of this object"),
G_TYPE_OBJECT,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkSelectionFilterModel:model:
*
@@ -263,7 +239,7 @@ gtk_selection_filter_model_init (GtkSelectionFilterModel *self)
/**
* gtk_selection_filter_model_new:
* @model: the selection model to filter
* @model: (allow-none) (transfer none): the selection model to filter, or %NULL
*
* Creates a new #GtkSelectionFilterModel that will include the
* selected items from the underlying selection model.
@@ -273,35 +249,8 @@ gtk_selection_filter_model_init (GtkSelectionFilterModel *self)
GtkSelectionFilterModel *
gtk_selection_filter_model_new (GtkSelectionModel *model)
{
GtkSelectionFilterModel *result;
g_return_val_if_fail (GTK_IS_SELECTION_MODEL (model), NULL);
result = g_object_new (GTK_TYPE_SELECTION_FILTER_MODEL,
"item-type", g_list_model_get_item_type (G_LIST_MODEL (model)),
"model", model,
NULL);
return result;
}
/**
* gtk_selection_filter_model_new_for_type:
* @item_type: the type of the items that will be returned
*
* Creates a new empty selection filter model set up to return items
* of type @item_type. It is up to the application to set a proper
* selection model to ensure the item type is matched.
*
* Returns: a new #GtkSelectionFilterModel
**/
GtkSelectionFilterModel *
gtk_selection_filter_model_new_for_type (GType item_type)
{
g_return_val_if_fail (g_type_is_a (item_type, G_TYPE_OBJECT), NULL);
return g_object_new (GTK_TYPE_SELECTION_FILTER_MODEL,
"item-type", item_type,
"model", model,
NULL);
}
@@ -325,8 +274,6 @@ gtk_selection_filter_model_set_model (GtkSelectionFilterModel *self,
g_return_if_fail (GTK_IS_SELECTION_FILTER_MODEL (self));
g_return_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model));
g_return_if_fail (model == NULL || g_type_is_a (g_list_model_get_item_type (G_LIST_MODEL (model)),
self->item_type));
if (self->model == model)
return;

View File

@@ -453,7 +453,7 @@ gtk_single_selection_init (GtkSingleSelection *self)
/**
* gtk_single_selection_new:
* @model: (transfer none): the #GListModel to manage
* @model: (allow-none) (transfer full): the #GListModel to manage, or %NULL
*
* Creates a new selection to handle @model.
*
@@ -462,11 +462,18 @@ gtk_single_selection_init (GtkSingleSelection *self)
GtkSingleSelection *
gtk_single_selection_new (GListModel *model)
{
GtkSingleSelection *self;
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
return g_object_new (GTK_TYPE_SINGLE_SELECTION,
self = g_object_new (GTK_TYPE_SINGLE_SELECTION,
"model", model,
NULL);
/* consume the reference */
g_clear_object (&model);
return self;
}
/**

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -400,7 +400,6 @@ constructed (GObject *object)
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);
g_object_unref (model);
}

View File

@@ -85,7 +85,7 @@ gtk_inspector_list_data_set_object (GtkInspectorListData *sl,
g_object_set (page, "visible", TRUE, NULL);
sl->object = G_LIST_MODEL (object);
selection = gtk_no_selection_new (sl->object);
selection = gtk_no_selection_new (g_object_ref (sl->object));
gtk_column_view_set_model (sl->view, G_LIST_MODEL (selection));
g_object_unref (selection);
}

View File

@@ -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);
wt->priv->selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (wt->priv->tree_model)));
gtk_column_view_set_model (GTK_COLUMN_VIEW (wt->priv->list),
G_LIST_MODEL (wt->priv->selection));
}

View File

@@ -633,7 +633,6 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
gtk_widget_show (GTK_WIDGET (pl));
g_object_unref (list);
g_object_unref (sorted);
return TRUE;
}

View File

@@ -1234,12 +1234,12 @@ 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);
recorder->render_node_selection = gtk_single_selection_new (G_LIST_MODEL (recorder->render_node_model));
recorder->render_node_selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (recorder->render_node_model)));
g_signal_connect (recorder->render_node_selection, "notify::selected-item", G_CALLBACK (render_node_list_selection_changed), recorder);
factory = gtk_signal_list_item_factory_new ();

View File

@@ -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,8 +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));

View File

@@ -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);

View File

@@ -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));

View File

@@ -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);

View File

@@ -253,7 +253,7 @@ new_model (GListStore *store)
GtkSelectionModel *result;
GString *changes;
result = GTK_SELECTION_MODEL (gtk_multi_selection_new (G_LIST_MODEL (store)));
result = GTK_SELECTION_MODEL (gtk_multi_selection_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);
@@ -615,6 +615,7 @@ test_selection_filter (void)
g_object_unref (store);
g_object_unref (selection);
g_object_unref (filter);
}
static void

View File

@@ -249,7 +249,7 @@ new_model (GListStore *store, gboolean autoselect, gboolean can_unselect)
GtkSelectionModel *result;
GString *changes;
result = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (store)));
result = GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (G_LIST_MODEL (store))));
/* We want to return an empty selection unless autoselect is true,
* so undo the initial selection due to autoselect defaulting to TRUE.

View File

@@ -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);

View File

@@ -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));