Compare commits
11 Commits
pango2-win
...
selection-
Author | SHA1 | Date | |
---|---|---|---|
|
b6d908b8aa | ||
|
c659910a83 | ||
|
1af097455c | ||
|
6873f63987 | ||
|
16b043a127 | ||
|
0b7f7028d9 | ||
|
5dba053ad1 | ||
|
cd8a810d69 | ||
|
8f63a5ab63 | ||
|
eb3381723f | ||
|
7e87ad1887 |
@@ -174,28 +174,25 @@ constraint_view_init (ConstraintView *self)
|
|||||||
manager = gtk_constraint_layout_new ();
|
manager = gtk_constraint_layout_new ();
|
||||||
gtk_widget_set_layout_manager (GTK_WIDGET (self), manager);
|
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));
|
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);
|
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
|
||||||
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, filter);
|
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);
|
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
|
||||||
children = (GListModel *)gtk_filter_list_model_new (all_children, filter);
|
children = (GListModel *)gtk_filter_list_model_new (all_children, filter);
|
||||||
g_object_unref (filter);
|
|
||||||
|
|
||||||
list = g_list_store_new (G_TYPE_LIST_MODEL);
|
list = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||||
g_list_store_append (list, children);
|
g_list_store_append (list, children);
|
||||||
g_list_store_append (list, guides);
|
g_list_store_append (list, guides);
|
||||||
g_list_store_append (list, constraints);
|
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 (children);
|
||||||
g_object_unref (guides);
|
g_object_unref (guides);
|
||||||
g_object_unref (constraints);
|
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 ();
|
controller = (GtkEventController *)gtk_gesture_drag_new ();
|
||||||
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);
|
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);
|
||||||
|
@@ -462,7 +462,6 @@ do_listview_clocks (GtkWidget *do_widget)
|
|||||||
{
|
{
|
||||||
GtkWidget *gridview, *sw;
|
GtkWidget *gridview, *sw;
|
||||||
GtkListItemFactory *factory;
|
GtkListItemFactory *factory;
|
||||||
GListModel *model;
|
|
||||||
GtkNoSelection *selection;
|
GtkNoSelection *selection;
|
||||||
|
|
||||||
/* This is the normal window setup code every demo does */
|
/* 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_hscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
|
||||||
gtk_scrollable_set_vscroll_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 (create_clocks_model ());
|
||||||
selection = gtk_no_selection_new (model);
|
|
||||||
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), G_LIST_MODEL (selection));
|
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), G_LIST_MODEL (selection));
|
||||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
g_object_unref (model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
|
@@ -884,7 +884,7 @@ do_listview_colors (GtkWidget *do_widget)
|
|||||||
|
|
||||||
sort_model = gtk_sort_list_model_new (gtk_color_list_new (0), NULL);
|
sort_model = gtk_sort_list_model_new (gtk_color_list_new (0), NULL);
|
||||||
gtk_sort_list_model_set_incremental (sort_model, TRUE);
|
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 ();
|
window = gtk_window_new ();
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "Colors");
|
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));
|
no_selection = G_LIST_MODEL (gtk_no_selection_new (selection_filter));
|
||||||
gtk_grid_view_set_model (GTK_GRID_VIEW (selection_view), no_selection);
|
gtk_grid_view_set_model (GTK_GRID_VIEW (selection_view), no_selection);
|
||||||
g_object_unref (selection_filter);
|
|
||||||
g_object_unref (no_selection);
|
g_object_unref (no_selection);
|
||||||
|
|
||||||
selection_info_toggle = gtk_toggle_button_new ();
|
selection_info_toggle = gtk_toggle_button_new ();
|
||||||
|
@@ -214,7 +214,6 @@ transform_settings_to_keys (GBinding *binding,
|
|||||||
GtkSortListModel *sort_model;
|
GtkSortListModel *sort_model;
|
||||||
GtkFilterListModel *filter_model;
|
GtkFilterListModel *filter_model;
|
||||||
GtkFilter *filter;
|
GtkFilter *filter;
|
||||||
GtkNoSelection *selection_model;
|
|
||||||
char **keys;
|
char **keys;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
@@ -242,21 +241,13 @@ 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"));
|
||||||
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
|
|
||||||
g_object_unref (sort_model);
|
|
||||||
|
|
||||||
g_set_object (¤t_filter, filter);
|
g_set_object (¤t_filter, filter);
|
||||||
|
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
|
||||||
|
|
||||||
g_object_unref (filter);
|
g_value_take_object (to_value, gtk_no_selection_new (G_LIST_MODEL (filter_model)));
|
||||||
|
|
||||||
selection_model = gtk_no_selection_new (G_LIST_MODEL (filter_model));
|
|
||||||
g_object_unref (filter_model);
|
|
||||||
|
|
||||||
g_value_take_object (to_value, selection_model);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -403,8 +394,8 @@ do_listview_settings (GtkWidget *do_widget)
|
|||||||
g_object_unref (actions);
|
g_object_unref (actions);
|
||||||
|
|
||||||
model = create_settings_model (NULL, NULL);
|
model = create_settings_model (NULL, NULL);
|
||||||
treemodel = gtk_tree_list_model_new (FALSE,
|
treemodel = gtk_tree_list_model_new (model,
|
||||||
model,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
create_settings_model,
|
create_settings_model,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -418,8 +409,6 @@ do_listview_settings (GtkWidget *do_widget)
|
|||||||
columnview, NULL);
|
columnview, NULL);
|
||||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
|
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
|
||||||
g_object_unref (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"));
|
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"));
|
sorter = gtk_string_sorter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
|
||||||
|
@@ -281,7 +281,7 @@ GtkWidget *
|
|||||||
create_weather_view (void)
|
create_weather_view (void)
|
||||||
{
|
{
|
||||||
GtkWidget *listview;
|
GtkWidget *listview;
|
||||||
GListModel *model, *selection;
|
GListModel *selection;
|
||||||
GtkListItemFactory *factory;
|
GtkListItemFactory *factory;
|
||||||
|
|
||||||
factory = gtk_signal_list_item_factory_new ();
|
factory = gtk_signal_list_item_factory_new ();
|
||||||
@@ -290,11 +290,9 @@ create_weather_view (void)
|
|||||||
listview = gtk_list_view_new_with_factory (factory);
|
listview = gtk_list_view_new_with_factory (factory);
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
|
||||||
gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
|
gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
|
||||||
model = create_weather_model ();
|
selection = G_LIST_MODEL (gtk_no_selection_new (create_weather_model ()));
|
||||||
selection = G_LIST_MODEL (gtk_no_selection_new (model));
|
|
||||||
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
|
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
g_object_unref (model);
|
|
||||||
|
|
||||||
return listview;
|
return listview;
|
||||||
}
|
}
|
||||||
|
@@ -226,7 +226,6 @@ do_listview_words (GtkWidget *do_widget)
|
|||||||
g_signal_connect (filter_model, "notify::pending", G_CALLBACK (update_title_cb), progress);
|
g_signal_connect (filter_model, "notify::pending", G_CALLBACK (update_title_cb), progress);
|
||||||
update_title_cb (filter_model);
|
update_title_cb (filter_model);
|
||||||
|
|
||||||
g_object_unref (filter_model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
|
@@ -1136,8 +1136,8 @@ activate (GApplication *app)
|
|||||||
g_signal_connect (search_bar, "notify::search-mode-enabled", G_CALLBACK (clear_search), NULL);
|
g_signal_connect (search_bar, "notify::search-mode-enabled", G_CALLBACK (clear_search), NULL);
|
||||||
|
|
||||||
listmodel = create_demo_model ();
|
listmodel = create_demo_model ();
|
||||||
treemodel = gtk_tree_list_model_new (FALSE,
|
treemodel = gtk_tree_list_model_new (G_LIST_MODEL (listmodel),
|
||||||
G_LIST_MODEL (listmodel),
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
get_child_model,
|
get_child_model,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -1145,6 +1145,7 @@ activate (GApplication *app)
|
|||||||
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL);
|
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);
|
filter = gtk_custom_filter_new ((GtkCustomFilterFunc)demo_filter_by_name, filter_model, NULL);
|
||||||
gtk_filter_list_model_set_filter (filter_model, filter);
|
gtk_filter_list_model_set_filter (filter_model, filter);
|
||||||
|
g_object_unref (filter);
|
||||||
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
|
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);
|
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), 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);
|
||||||
* ]|
|
* ]|
|
||||||
|
@@ -322,12 +322,9 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
|
|||||||
g_object_unref (printer_list);
|
g_object_unref (printer_list);
|
||||||
|
|
||||||
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (printer_list_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);
|
filter = gtk_custom_filter_new (match_func, NULL, NULL);
|
||||||
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
|
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);
|
dialog->custom_paper_list = g_list_store_new (GTK_TYPE_PAGE_SETUP);
|
||||||
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
||||||
@@ -899,7 +896,7 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
|
|||||||
listview = gtk_list_view_new ();
|
listview = gtk_list_view_new ();
|
||||||
gtk_widget_set_size_request (listview, 140, -1);
|
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);
|
gtk_list_view_set_model (GTK_LIST_VIEW (listview), model);
|
||||||
g_signal_connect (model, "notify::selected", G_CALLBACK (selected_custom_paper_changed), dialog);
|
g_signal_connect (model, "notify::selected", G_CALLBACK (selected_custom_paper_changed), dialog);
|
||||||
g_object_unref (model);
|
g_object_unref (model);
|
||||||
|
@@ -666,9 +666,8 @@ gtk_drop_down_set_model (GtkDropDown *self,
|
|||||||
GListModel *filter_model;
|
GListModel *filter_model;
|
||||||
GListModel *selection;
|
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_set_object (&self->filter_model, filter_model);
|
||||||
g_object_unref (filter_model);
|
|
||||||
|
|
||||||
update_filter (self);
|
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);
|
gtk_list_view_set_model (GTK_LIST_VIEW (self->popup_list), selection);
|
||||||
g_object_unref (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_set_object (&self->selection, selection);
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
|
|
||||||
|
@@ -614,8 +614,8 @@ gtk_filter_list_model_init (GtkFilterListModel *self)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_filter_list_model_new:
|
* gtk_filter_list_model_new:
|
||||||
* @model: (allow-none): the model to sort
|
* @model: (allow-none) (transfer full): the model to sort, or %NULL
|
||||||
* @filter: (allow-none): filter or %NULL to not filter items
|
* @filter: (allow-none) (transfer full): filter or %NULL to not filter items
|
||||||
*
|
*
|
||||||
* Creates a new #GtkFilterListModel that will filter @model using the given
|
* Creates a new #GtkFilterListModel that will filter @model using the given
|
||||||
* @filter.
|
* @filter.
|
||||||
@@ -636,6 +636,10 @@ gtk_filter_list_model_new (GListModel *model,
|
|||||||
"filter", filter,
|
"filter", filter,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* consume the references */
|
||||||
|
g_clear_object (&model);
|
||||||
|
g_clear_object (&filter);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -425,7 +425,7 @@ gtk_flatten_list_model_init (GtkFlattenListModel *self)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_flatten_list_model_new:
|
* 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.
|
* Creates a new #GtkFlattenListModel that flattens @list.
|
||||||
*
|
*
|
||||||
@@ -442,6 +442,9 @@ gtk_flatten_list_model_new (GListModel *model)
|
|||||||
"model", model,
|
"model", model,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* we consume the reference */
|
||||||
|
g_clear_object (&model);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -784,7 +784,7 @@ update_fontlist (GtkFontChooserWidget *self)
|
|||||||
if ((self->level & GTK_FONT_CHOOSER_LEVEL_STYLE) == 0)
|
if ((self->level & GTK_FONT_CHOOSER_LEVEL_STYLE) == 0)
|
||||||
model = g_object_ref (G_LIST_MODEL (fontmap));
|
model = g_object_ref (G_LIST_MODEL (fontmap));
|
||||||
else
|
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);
|
gtk_filter_list_model_set_model (self->filter_model, model);
|
||||||
g_object_unref (model);
|
g_object_unref (model);
|
||||||
}
|
}
|
||||||
|
@@ -2130,7 +2130,7 @@ gtk_list_base_set_model (GtkListBase *self,
|
|||||||
if (GTK_IS_SELECTION_MODEL (model))
|
if (GTK_IS_SELECTION_MODEL (model))
|
||||||
selection_model = GTK_SELECTION_MODEL (g_object_ref (model));
|
selection_model = GTK_SELECTION_MODEL (g_object_ref (model));
|
||||||
else
|
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_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);
|
gtk_list_base_set_anchor (self, 0, 0.0, GTK_PACK_START, 0.0, GTK_PACK_START);
|
||||||
|
@@ -36,7 +36,6 @@ struct _GtkListListModel
|
|||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
GType item_type;
|
|
||||||
guint n_items;
|
guint n_items;
|
||||||
gpointer (* get_first) (gpointer);
|
gpointer (* get_first) (gpointer);
|
||||||
gpointer (* get_next) (gpointer, gpointer);
|
gpointer (* get_next) (gpointer, gpointer);
|
||||||
@@ -55,9 +54,7 @@ struct _GtkListListModelClass
|
|||||||
static GType
|
static GType
|
||||||
gtk_list_list_model_get_item_type (GListModel *list)
|
gtk_list_list_model_get_item_type (GListModel *list)
|
||||||
{
|
{
|
||||||
GtkListListModel *self = GTK_LIST_LIST_MODEL (list);
|
return G_TYPE_OBJECT;
|
||||||
|
|
||||||
return self->item_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
@@ -143,8 +140,7 @@ gtk_list_list_model_init (GtkListListModel *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GtkListListModel *
|
GtkListListModel *
|
||||||
gtk_list_list_model_new (GType item_type,
|
gtk_list_list_model_new (gpointer (* get_first) (gpointer),
|
||||||
gpointer (* get_first) (gpointer),
|
|
||||||
gpointer (* get_next) (gpointer, gpointer),
|
gpointer (* get_next) (gpointer, gpointer),
|
||||||
gpointer (* get_previous) (gpointer, gpointer),
|
gpointer (* get_previous) (gpointer, gpointer),
|
||||||
gpointer (* get_last) (gpointer),
|
gpointer (* get_last) (gpointer),
|
||||||
@@ -161,8 +157,7 @@ gtk_list_list_model_new (GType item_type,
|
|||||||
item = get_next (item, data))
|
item = get_next (item, data))
|
||||||
n_items++;
|
n_items++;
|
||||||
|
|
||||||
return gtk_list_list_model_new_with_size (item_type,
|
return gtk_list_list_model_new_with_size (n_items,
|
||||||
n_items,
|
|
||||||
get_first,
|
get_first,
|
||||||
get_next,
|
get_next,
|
||||||
get_previous,
|
get_previous,
|
||||||
@@ -173,8 +168,7 @@ gtk_list_list_model_new (GType item_type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GtkListListModel *
|
GtkListListModel *
|
||||||
gtk_list_list_model_new_with_size (GType item_type,
|
gtk_list_list_model_new_with_size (guint n_items,
|
||||||
guint n_items,
|
|
||||||
gpointer (* get_first) (gpointer),
|
gpointer (* get_first) (gpointer),
|
||||||
gpointer (* get_next) (gpointer, gpointer),
|
gpointer (* get_next) (gpointer, gpointer),
|
||||||
gpointer (* get_previous) (gpointer, gpointer),
|
gpointer (* get_previous) (gpointer, gpointer),
|
||||||
@@ -185,7 +179,6 @@ gtk_list_list_model_new_with_size (GType item_type,
|
|||||||
{
|
{
|
||||||
GtkListListModel *result;
|
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_first != NULL, NULL);
|
||||||
g_return_val_if_fail (get_next != NULL, NULL);
|
g_return_val_if_fail (get_next != NULL, NULL);
|
||||||
g_return_val_if_fail (get_previous != 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 = g_object_new (GTK_TYPE_LIST_LIST_MODEL, NULL);
|
||||||
|
|
||||||
result->item_type = item_type;
|
|
||||||
result->n_items = n_items;
|
result->n_items = n_items;
|
||||||
result->get_first = get_first;
|
result->get_first = get_first;
|
||||||
result->get_next = get_next;
|
result->get_next = get_next;
|
||||||
|
@@ -37,8 +37,7 @@ typedef struct _GtkListListModelClass GtkListListModelClass;
|
|||||||
|
|
||||||
GType gtk_list_list_model_get_type (void) G_GNUC_CONST;
|
GType gtk_list_list_model_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkListListModel * gtk_list_list_model_new (GType item_type,
|
GtkListListModel * gtk_list_list_model_new (gpointer (* get_first) (gpointer),
|
||||||
gpointer (* get_first) (gpointer),
|
|
||||||
gpointer (* get_next) (gpointer, gpointer),
|
gpointer (* get_next) (gpointer, gpointer),
|
||||||
gpointer (* get_previous) (gpointer, gpointer),
|
gpointer (* get_previous) (gpointer, gpointer),
|
||||||
gpointer (* get_last) (gpointer),
|
gpointer (* get_last) (gpointer),
|
||||||
@@ -46,8 +45,7 @@ GtkListListModel * gtk_list_list_model_new (GType
|
|||||||
gpointer data,
|
gpointer data,
|
||||||
GDestroyNotify notify);
|
GDestroyNotify notify);
|
||||||
|
|
||||||
GtkListListModel * gtk_list_list_model_new_with_size (GType item_type,
|
GtkListListModel * gtk_list_list_model_new_with_size (guint n_items,
|
||||||
guint n_items,
|
|
||||||
gpointer (* get_first) (gpointer),
|
gpointer (* get_first) (gpointer),
|
||||||
gpointer (* get_next) (gpointer, gpointer),
|
gpointer (* get_next) (gpointer, gpointer),
|
||||||
gpointer (* get_previous) (gpointer, gpointer),
|
gpointer (* get_previous) (gpointer, gpointer),
|
||||||
|
@@ -412,7 +412,7 @@ gtk_map_list_model_augment (GtkRbTree *map,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_map_list_model_new:
|
* 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
|
* @map_func: (allow-none): map function or %NULL to not map items
|
||||||
* @user_data: (closure): user data passed to @map_func
|
* @user_data: (closure): user data passed to @map_func
|
||||||
* @user_destroy: destroy notifier for @user_data
|
* @user_destroy: destroy notifier for @user_data
|
||||||
@@ -435,6 +435,9 @@ gtk_map_list_model_new (GListModel *model,
|
|||||||
"model", model,
|
"model", model,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* consume the reference */
|
||||||
|
g_clear_object (&model);
|
||||||
|
|
||||||
if (map_func)
|
if (map_func)
|
||||||
gtk_map_list_model_set_map_func (result, map_func, user_data, user_destroy);
|
gtk_map_list_model_set_map_func (result, map_func, user_data, user_destroy);
|
||||||
|
|
||||||
|
@@ -370,20 +370,27 @@ gtk_multi_selection_init (GtkMultiSelection *self)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_multi_selection_new:
|
* 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.
|
* 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)
|
gtk_multi_selection_new (GListModel *model)
|
||||||
{
|
{
|
||||||
|
GtkMultiSelection *self;
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
|
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,
|
"model", model,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* consume the reference */
|
||||||
|
g_clear_object (&model);
|
||||||
|
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -31,13 +31,13 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
G_DECLARE_FINAL_TYPE (GtkMultiSelection, gtk_multi_selection, GTK, MULTI_SELECTION, GObject)
|
G_DECLARE_FINAL_TYPE (GtkMultiSelection, gtk_multi_selection, GTK, MULTI_SELECTION, GObject)
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GListModel * gtk_multi_selection_new (GListModel *model);
|
GtkMultiSelection * gtk_multi_selection_new (GListModel *model);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GListModel * gtk_multi_selection_get_model (GtkMultiSelection *self);
|
GListModel * gtk_multi_selection_get_model (GtkMultiSelection *self);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_multi_selection_set_model (GtkMultiSelection *self,
|
void gtk_multi_selection_set_model (GtkMultiSelection *self,
|
||||||
GListModel *model);
|
GListModel *model);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@@ -216,7 +216,7 @@ gtk_no_selection_init (GtkNoSelection *self)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_no_selection_new:
|
* 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.
|
* Creates a new selection to handle @model.
|
||||||
*
|
*
|
||||||
@@ -225,11 +225,18 @@ gtk_no_selection_init (GtkNoSelection *self)
|
|||||||
GtkNoSelection *
|
GtkNoSelection *
|
||||||
gtk_no_selection_new (GListModel *model)
|
gtk_no_selection_new (GListModel *model)
|
||||||
{
|
{
|
||||||
|
GtkNoSelection *self;
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
|
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,
|
"model", model,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* consume the reference */
|
||||||
|
g_clear_object (&model);
|
||||||
|
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,8 +260,8 @@ gtk_no_selection_get_model (GtkNoSelection *self)
|
|||||||
* @self: a #GtkNoSelection
|
* @self: a #GtkNoSelection
|
||||||
* @model: (allow-none): A #GListModel to wrap
|
* @model: (allow-none): A #GListModel to wrap
|
||||||
*
|
*
|
||||||
* Sets the model that @self should wrap. If @model is %NULL, this
|
* Sets the model that @self should wrap.
|
||||||
* model will be empty.
|
* If @model is %NULL, this model will be empty.
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gtk_no_selection_set_model (GtkNoSelection *self,
|
gtk_no_selection_set_model (GtkNoSelection *self,
|
||||||
|
@@ -308,7 +308,6 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
|
|||||||
g_list_store_append (store, dialog->manage_papers_list);
|
g_list_store_append (store, dialog->manage_papers_list);
|
||||||
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
|
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);
|
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);
|
g_object_unref (paper_size_list);
|
||||||
|
|
||||||
/* Do this in code, we want the translatable strings without the markup */
|
/* 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);
|
filter = gtk_custom_filter_new (match_func, NULL, NULL);
|
||||||
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
|
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 ();
|
factory = gtk_signal_list_item_factory_new ();
|
||||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_printer_item), dialog);
|
g_signal_connect (factory, "setup", G_CALLBACK (setup_printer_item), dialog);
|
||||||
|
@@ -807,14 +807,12 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
|||||||
g_list_store_append (store, dialog->manage_papers_list);
|
g_list_store_append (store, dialog->manage_papers_list);
|
||||||
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
|
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);
|
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);
|
g_object_unref (paper_size_list);
|
||||||
|
|
||||||
/* Load backends */
|
/* Load backends */
|
||||||
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 ();
|
||||||
|
|
||||||
@@ -831,7 +829,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
|||||||
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), filter1);
|
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), filter1);
|
||||||
|
|
||||||
filtered = G_LIST_MODEL (gtk_filter_list_model_new (sorted, filter));
|
filtered = G_LIST_MODEL (gtk_filter_list_model_new (sorted, filter));
|
||||||
g_object_unref (filter);
|
|
||||||
|
|
||||||
selection = G_LIST_MODEL (gtk_single_selection_new (filtered));
|
selection = G_LIST_MODEL (gtk_single_selection_new (filtered));
|
||||||
gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (selection), FALSE);
|
gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (selection), FALSE);
|
||||||
@@ -840,8 +837,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
|||||||
g_signal_connect (selection, "items-changed", G_CALLBACK (printer_added_cb), 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_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 (model);
|
|
||||||
|
|
||||||
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
||||||
|
|
||||||
@@ -1037,7 +1032,6 @@ load_print_backends (GtkPrintUnixDialog *dialog)
|
|||||||
{
|
{
|
||||||
GList *node;
|
GList *node;
|
||||||
GListStore *lists;
|
GListStore *lists;
|
||||||
GListModel *model;
|
|
||||||
|
|
||||||
lists = g_list_store_new (G_TYPE_LIST_MODEL);
|
lists = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||||
|
|
||||||
@@ -1053,11 +1047,7 @@ load_print_backends (GtkPrintUnixDialog *dialog)
|
|||||||
g_list_store_append (lists, gtk_print_backend_get_printers (backend));
|
g_list_store_append (lists, gtk_print_backend_get_printers (backend));
|
||||||
}
|
}
|
||||||
|
|
||||||
model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (lists)));
|
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (lists)));
|
||||||
|
|
||||||
g_object_unref (lists);
|
|
||||||
|
|
||||||
return model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_ITEM_TYPE,
|
|
||||||
PROP_MODEL,
|
PROP_MODEL,
|
||||||
NUM_PROPERTIES
|
NUM_PROPERTIES
|
||||||
};
|
};
|
||||||
@@ -46,7 +45,6 @@ struct _GtkSelectionFilterModel
|
|||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
GType item_type;
|
|
||||||
GtkSelectionModel *model;
|
GtkSelectionModel *model;
|
||||||
GtkBitset *selection;
|
GtkBitset *selection;
|
||||||
};
|
};
|
||||||
@@ -61,9 +59,7 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
|
|||||||
static GType
|
static GType
|
||||||
gtk_selection_filter_model_get_item_type (GListModel *list)
|
gtk_selection_filter_model_get_item_type (GListModel *list)
|
||||||
{
|
{
|
||||||
GtkSelectionFilterModel *self = GTK_SELECTION_FILTER_MODEL (list);
|
return G_TYPE_OBJECT;
|
||||||
|
|
||||||
return self->item_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
@@ -159,10 +155,6 @@ gtk_selection_filter_model_set_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_ITEM_TYPE:
|
|
||||||
self->item_type = g_value_get_gtype (value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_MODEL:
|
case PROP_MODEL:
|
||||||
gtk_selection_filter_model_set_model (self, g_value_get_object (value));
|
gtk_selection_filter_model_set_model (self, g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
@@ -183,10 +175,6 @@ gtk_selection_filter_model_get_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_ITEM_TYPE:
|
|
||||||
g_value_set_gtype (value, self->item_type);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_MODEL:
|
case PROP_MODEL:
|
||||||
g_value_set_object (value, self->model);
|
g_value_set_object (value, self->model);
|
||||||
break;
|
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->get_property = gtk_selection_filter_model_get_property;
|
||||||
gobject_class->dispose = gtk_selection_filter_model_dispose;
|
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:
|
* GtkSelectionFilterModel:model:
|
||||||
*
|
*
|
||||||
@@ -263,7 +239,7 @@ gtk_selection_filter_model_init (GtkSelectionFilterModel *self)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_selection_filter_model_new:
|
* 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
|
* Creates a new #GtkSelectionFilterModel that will include the
|
||||||
* selected items from the underlying selection model.
|
* selected items from the underlying selection model.
|
||||||
@@ -273,35 +249,8 @@ gtk_selection_filter_model_init (GtkSelectionFilterModel *self)
|
|||||||
GtkSelectionFilterModel *
|
GtkSelectionFilterModel *
|
||||||
gtk_selection_filter_model_new (GtkSelectionModel *model)
|
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,
|
return g_object_new (GTK_TYPE_SELECTION_FILTER_MODEL,
|
||||||
"item-type", item_type,
|
"model", model,
|
||||||
NULL);
|
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 (GTK_IS_SELECTION_FILTER_MODEL (self));
|
||||||
g_return_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model));
|
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)
|
if (self->model == model)
|
||||||
return;
|
return;
|
||||||
|
@@ -44,21 +44,16 @@ G_DEFINE_INTERFACE (GtkShortcutManager, gtk_shortcut_manager, G_TYPE_OBJECT)
|
|||||||
void
|
void
|
||||||
gtk_shortcut_manager_create_controllers (GtkWidget *widget)
|
gtk_shortcut_manager_create_controllers (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
GListStore *store;
|
|
||||||
GtkFlattenListModel *model;
|
GtkFlattenListModel *model;
|
||||||
GtkEventController *controller;
|
GtkEventController *controller;
|
||||||
|
|
||||||
store = g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER);
|
model = gtk_flatten_list_model_new (G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER)));
|
||||||
model = gtk_flatten_list_model_new (G_LIST_MODEL (store));
|
|
||||||
g_object_unref (store);
|
|
||||||
g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-bubble", model, g_object_unref);
|
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));
|
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
|
||||||
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-bubble");
|
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-bubble");
|
||||||
gtk_widget_add_controller (widget, controller);
|
gtk_widget_add_controller (widget, controller);
|
||||||
|
|
||||||
store = g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER);
|
model = gtk_flatten_list_model_new (G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER)));
|
||||||
model = gtk_flatten_list_model_new (G_LIST_MODEL (store));
|
|
||||||
g_object_unref (store);
|
|
||||||
g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-capture", model, g_object_unref);
|
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));
|
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
|
||||||
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-capture");
|
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-capture");
|
||||||
|
@@ -453,7 +453,7 @@ gtk_single_selection_init (GtkSingleSelection *self)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_single_selection_new:
|
* 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.
|
* Creates a new selection to handle @model.
|
||||||
*
|
*
|
||||||
@@ -462,11 +462,18 @@ gtk_single_selection_init (GtkSingleSelection *self)
|
|||||||
GtkSingleSelection *
|
GtkSingleSelection *
|
||||||
gtk_single_selection_new (GListModel *model)
|
gtk_single_selection_new (GListModel *model)
|
||||||
{
|
{
|
||||||
|
GtkSingleSelection *self;
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
|
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,
|
"model", model,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* consume the reference */
|
||||||
|
g_clear_object (&model);
|
||||||
|
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -30,11 +30,12 @@
|
|||||||
* @short_description: A list model that presents a slice out of a larger list
|
* @short_description: A list model that presents a slice out of a larger list
|
||||||
* @see_also: #GListModel
|
* @see_also: #GListModel
|
||||||
*
|
*
|
||||||
* #GtkSliceListModel is a list model that takes a list model and presents a slice of
|
* #GtkSliceListModel is a list model that takes a list model and presents a
|
||||||
* that model.
|
* slice of that model.
|
||||||
*
|
*
|
||||||
* This is useful when implementing paging by setting the size to the number of elements
|
* This is useful when implementing paging by setting the size to the number
|
||||||
* per page and updating the offset whenever a different page is opened.
|
* of elements per page and updating the offset whenever a different page is
|
||||||
|
* opened.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEFAULT_SIZE 10
|
#define DEFAULT_SIZE 10
|
||||||
@@ -300,7 +301,7 @@ gtk_slice_list_model_init (GtkSliceListModel *self)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_slice_list_model_new:
|
* 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
|
* @offset: the offset of the slice
|
||||||
* @size: maximum size of the slice
|
* @size: maximum size of the slice
|
||||||
*
|
*
|
||||||
@@ -314,13 +315,20 @@ gtk_slice_list_model_new (GListModel *model,
|
|||||||
guint offset,
|
guint offset,
|
||||||
guint size)
|
guint size)
|
||||||
{
|
{
|
||||||
|
GtkSliceListModel *self;
|
||||||
|
|
||||||
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
|
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,
|
"model", model,
|
||||||
"offset", offset,
|
"offset", offset,
|
||||||
"size", size,
|
"size", size,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* consume the reference */
|
||||||
|
g_clear_object (&model);
|
||||||
|
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -734,8 +734,8 @@ gtk_tree_list_model_init (GtkTreeListModel *self)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_tree_list_model_new:
|
* gtk_tree_list_model_new:
|
||||||
|
* @root: (transfer full): The #GListModel to use as root
|
||||||
* @passthrough: %TRUE to pass through items from the models
|
* @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
|
* @autoexpand: %TRUE to set the autoexpand property and expand the @root model
|
||||||
* @create_func: Function to call to create the #GListModel for the children
|
* @create_func: Function to call to create the #GListModel for the children
|
||||||
* of an item
|
* of an item
|
||||||
@@ -743,12 +743,12 @@ gtk_tree_list_model_init (GtkTreeListModel *self)
|
|||||||
* @user_destroy: Function to call to free @user_data
|
* @user_destroy: Function to call to free @user_data
|
||||||
*
|
*
|
||||||
* Creates a new empty #GtkTreeListModel displaying @root with all rows collapsed.
|
* Creates a new empty #GtkTreeListModel displaying @root with all rows collapsed.
|
||||||
*
|
*
|
||||||
* Returns: a newly created #GtkTreeListModel.
|
* Returns: a newly created #GtkTreeListModel.
|
||||||
**/
|
**/
|
||||||
GtkTreeListModel *
|
GtkTreeListModel *
|
||||||
gtk_tree_list_model_new (gboolean passthrough,
|
gtk_tree_list_model_new (GListModel *root,
|
||||||
GListModel *root,
|
gboolean passthrough,
|
||||||
gboolean autoexpand,
|
gboolean autoexpand,
|
||||||
GtkTreeListModelCreateModelFunc create_func,
|
GtkTreeListModelCreateModelFunc create_func,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
@@ -768,7 +768,7 @@ gtk_tree_list_model_new (gboolean passthrough,
|
|||||||
self->user_data = user_data;
|
self->user_data = user_data;
|
||||||
self->user_destroy = user_destroy;
|
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;
|
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);
|
typedef GListModel * (* GtkTreeListModelCreateModelFunc) (gpointer item, gpointer user_data);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkTreeListModel * gtk_tree_list_model_new (gboolean passthrough,
|
GtkTreeListModel * gtk_tree_list_model_new (GListModel *root,
|
||||||
GListModel *root,
|
gboolean passthrough,
|
||||||
gboolean autoexpand,
|
gboolean autoexpand,
|
||||||
GtkTreeListModelCreateModelFunc create_func,
|
GtkTreeListModelCreateModelFunc create_func,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
|
@@ -11535,8 +11535,7 @@ gtk_widget_observe_children (GtkWidget *widget)
|
|||||||
if (priv->children_observer)
|
if (priv->children_observer)
|
||||||
return g_object_ref (G_LIST_MODEL (priv->children_observer));
|
return g_object_ref (G_LIST_MODEL (priv->children_observer));
|
||||||
|
|
||||||
priv->children_observer = gtk_list_list_model_new (GTK_TYPE_WIDGET,
|
priv->children_observer = gtk_list_list_model_new ((gpointer) gtk_widget_get_first_child,
|
||||||
(gpointer) gtk_widget_get_first_child,
|
|
||||||
(gpointer) gtk_widget_get_next_sibling,
|
(gpointer) gtk_widget_get_next_sibling,
|
||||||
(gpointer) gtk_widget_get_prev_sibling,
|
(gpointer) gtk_widget_get_prev_sibling,
|
||||||
(gpointer) gtk_widget_get_last_child,
|
(gpointer) gtk_widget_get_last_child,
|
||||||
@@ -11622,14 +11621,13 @@ gtk_widget_observe_controllers (GtkWidget *widget)
|
|||||||
if (priv->controller_observer)
|
if (priv->controller_observer)
|
||||||
return g_object_ref (G_LIST_MODEL (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,
|
priv->controller_observer = gtk_list_list_model_new (gtk_widget_controller_list_get_first,
|
||||||
gtk_widget_controller_list_get_first,
|
gtk_widget_controller_list_get_next,
|
||||||
gtk_widget_controller_list_get_next,
|
gtk_widget_controller_list_get_prev,
|
||||||
gtk_widget_controller_list_get_prev,
|
NULL,
|
||||||
NULL,
|
(gpointer) g_object_ref,
|
||||||
(gpointer) g_object_ref,
|
widget,
|
||||||
widget,
|
gtk_widget_controller_observer_destroyed);
|
||||||
gtk_widget_controller_observer_destroyed);
|
|
||||||
|
|
||||||
return G_LIST_MODEL (priv->controller_observer);
|
return G_LIST_MODEL (priv->controller_observer);
|
||||||
}
|
}
|
||||||
|
@@ -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,12 +395,11 @@ 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 (model);
|
g_object_unref (model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -244,13 +244,11 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
|
|||||||
gtk_property_lookup_list_model_set_object (self->model, object);
|
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);
|
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));
|
flatten_model = gtk_flatten_list_model_new (G_LIST_MODEL (map_model));
|
||||||
|
|
||||||
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),
|
||||||
@@ -259,8 +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);
|
|
||||||
g_object_unref (map_model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -85,7 +85,7 @@ gtk_inspector_list_data_set_object (GtkInspectorListData *sl,
|
|||||||
g_object_set (page, "visible", TRUE, NULL);
|
g_object_set (page, "visible", TRUE, NULL);
|
||||||
|
|
||||||
sl->object = G_LIST_MODEL (object);
|
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));
|
gtk_column_view_set_model (sl->view, G_LIST_MODEL (selection));
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
}
|
}
|
||||||
|
@@ -116,7 +116,6 @@ static GListModel *
|
|||||||
object_tree_widget_get_children (GObject *object)
|
object_tree_widget_get_children (GObject *object)
|
||||||
{
|
{
|
||||||
GtkWidget *widget = GTK_WIDGET (object);
|
GtkWidget *widget = GTK_WIDGET (object);
|
||||||
GtkFlattenListModel *flatten;
|
|
||||||
GListStore *list;
|
GListStore *list;
|
||||||
GListModel *sublist;
|
GListModel *sublist;
|
||||||
|
|
||||||
@@ -130,10 +129,7 @@ object_tree_widget_get_children (GObject *object)
|
|||||||
g_list_store_append (list, sublist);
|
g_list_store_append (list, sublist);
|
||||||
g_object_unref (sublist);
|
g_object_unref (sublist);
|
||||||
|
|
||||||
flatten = gtk_flatten_list_model_new (G_LIST_MODEL (list));
|
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
|
||||||
g_object_unref (list);
|
|
||||||
|
|
||||||
return G_LIST_MODEL (flatten);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GListModel *
|
static GListModel *
|
||||||
@@ -211,7 +207,6 @@ list_model_for_properties (GObject *object,
|
|||||||
const char **props)
|
const char **props)
|
||||||
{
|
{
|
||||||
GListStore *concat;
|
GListStore *concat;
|
||||||
GListModel *result;
|
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
if (props[1] == NULL)
|
if (props[1] == NULL)
|
||||||
@@ -225,9 +220,7 @@ list_model_for_properties (GObject *object,
|
|||||||
g_object_unref (tmp);
|
g_object_unref (tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (concat)));
|
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (concat)));
|
||||||
g_object_unref (concat);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GListModel *
|
static GListModel *
|
||||||
@@ -310,7 +303,6 @@ object_tree_tree_view_get_children (GObject *object)
|
|||||||
GtkTreeView *treeview = GTK_TREE_VIEW (object);
|
GtkTreeView *treeview = GTK_TREE_VIEW (object);
|
||||||
GListStore *columns, *selection, *result_list;
|
GListStore *columns, *selection, *result_list;
|
||||||
GListModel *props;
|
GListModel *props;
|
||||||
GtkFlattenListModel *result;
|
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
props = list_model_for_properties (object, (const char *[2]) { "model", NULL });
|
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_object_unref (selection);
|
||||||
g_list_store_append (result_list, columns);
|
g_list_store_append (result_list, columns);
|
||||||
g_object_unref (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 *
|
static GListModel *
|
||||||
@@ -341,7 +331,6 @@ object_tree_column_view_get_children (GObject *object)
|
|||||||
{
|
{
|
||||||
GtkColumnView *view = GTK_COLUMN_VIEW (object);
|
GtkColumnView *view = GTK_COLUMN_VIEW (object);
|
||||||
GListStore *result_list;
|
GListStore *result_list;
|
||||||
GtkFlattenListModel *result;
|
|
||||||
GListModel *columns, *sublist;
|
GListModel *columns, *sublist;
|
||||||
|
|
||||||
result_list = g_list_store_new (G_TYPE_LIST_MODEL);
|
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_list_store_append (result_list, sublist);
|
||||||
g_object_unref (sublist);
|
g_object_unref (sublist);
|
||||||
|
|
||||||
result = gtk_flatten_list_model_new (G_LIST_MODEL (result_list));
|
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
|
||||||
g_object_unref (result_list);
|
|
||||||
|
|
||||||
return G_LIST_MODEL (result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GListModel *
|
static GListModel *
|
||||||
@@ -602,12 +588,11 @@ static GListModel *
|
|||||||
object_get_children (GObject *object)
|
object_get_children (GObject *object)
|
||||||
{
|
{
|
||||||
GType object_type;
|
GType object_type;
|
||||||
GListModel *result, *children;
|
GListModel *children;
|
||||||
GListStore *result_list;
|
GListStore *result_list;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
object_type = G_OBJECT_TYPE (object);
|
object_type = G_OBJECT_TYPE (object);
|
||||||
result = NULL;
|
|
||||||
result_list = NULL;
|
result_list = NULL;
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (object_tree_class_funcs); i++)
|
for (i = 0; i < G_N_ELEMENTS (object_tree_class_funcs); i++)
|
||||||
@@ -619,32 +604,17 @@ object_get_children (GObject *object)
|
|||||||
if (children == NULL)
|
if (children == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (result_list)
|
if (!result_list)
|
||||||
{
|
result_list = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||||
g_list_store_append (result_list, children);
|
|
||||||
g_object_unref (children);
|
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)
|
if (result_list)
|
||||||
{
|
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
|
||||||
result = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
|
else
|
||||||
g_object_unref (result_list);
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -1167,7 +1137,6 @@ create_root_model (GdkDisplay *display)
|
|||||||
{
|
{
|
||||||
GtkFilter *custom_filter;
|
GtkFilter *custom_filter;
|
||||||
GtkFilterListModel *filter;
|
GtkFilterListModel *filter;
|
||||||
GtkFlattenListModel *flatten;
|
|
||||||
GListStore *list, *special;
|
GListStore *list, *special;
|
||||||
gpointer item;
|
gpointer item;
|
||||||
|
|
||||||
@@ -1182,16 +1151,13 @@ create_root_model (GdkDisplay *display)
|
|||||||
g_object_unref (special);
|
g_object_unref (special);
|
||||||
|
|
||||||
filter = gtk_filter_list_model_new (NULL, NULL);
|
filter = gtk_filter_list_model_new (NULL, NULL);
|
||||||
custom_filter = gtk_custom_filter_new (toplevel_filter_func,
|
custom_filter = gtk_custom_filter_new (toplevel_filter_func, display, NULL);
|
||||||
display, NULL);
|
|
||||||
gtk_filter_list_model_set_filter (filter, custom_filter);
|
gtk_filter_list_model_set_filter (filter, custom_filter);
|
||||||
gtk_filter_list_model_set_model (filter, gtk_window_get_toplevels ());
|
gtk_filter_list_model_set_model (filter, gtk_window_get_toplevels ());
|
||||||
g_list_store_append (list, filter);
|
g_list_store_append (list, filter);
|
||||||
g_object_unref (filter);
|
g_object_unref (filter);
|
||||||
|
|
||||||
flatten = gtk_flatten_list_model_new (G_LIST_MODEL (list));
|
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
|
||||||
g_object_unref (list);
|
|
||||||
return G_LIST_MODEL (flatten);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1332,18 +1298,13 @@ void
|
|||||||
gtk_inspector_object_tree_set_display (GtkInspectorObjectTree *wt,
|
gtk_inspector_object_tree_set_display (GtkInspectorObjectTree *wt,
|
||||||
GdkDisplay *display)
|
GdkDisplay *display)
|
||||||
{
|
{
|
||||||
GListModel *root_model;
|
wt->priv->tree_model = gtk_tree_list_model_new (create_root_model (display),
|
||||||
|
FALSE,
|
||||||
root_model = create_root_model (display);
|
|
||||||
wt->priv->tree_model = gtk_tree_list_model_new (FALSE,
|
|
||||||
root_model,
|
|
||||||
FALSE,
|
FALSE,
|
||||||
create_model_for_object,
|
create_model_for_object,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
wt->priv->selection = gtk_single_selection_new (G_LIST_MODEL (wt->priv->tree_model));
|
wt->priv->selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (wt->priv->tree_model)));
|
||||||
g_object_unref (root_model);
|
|
||||||
|
|
||||||
gtk_column_view_set_model (GTK_COLUMN_VIEW (wt->priv->list),
|
gtk_column_view_set_model (GTK_COLUMN_VIEW (wt->priv->list),
|
||||||
G_LIST_MODEL (wt->priv->selection));
|
G_LIST_MODEL (wt->priv->selection));
|
||||||
}
|
}
|
||||||
|
@@ -622,7 +622,7 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
|
|||||||
if (GTK_IS_WIDGET (object))
|
if (GTK_IS_WIDGET (object))
|
||||||
g_signal_connect_object (object, "destroy", G_CALLBACK (cleanup_object), pl, G_CONNECT_SWAPPED);
|
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);
|
sorted = gtk_sort_list_model_new (filtered, NULL);
|
||||||
list = G_LIST_MODEL (gtk_no_selection_new (G_LIST_MODEL (sorted)));
|
list = G_LIST_MODEL (gtk_no_selection_new (G_LIST_MODEL (sorted)));
|
||||||
|
|
||||||
@@ -633,9 +633,6 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
|
|||||||
gtk_widget_show (GTK_WIDGET (pl));
|
gtk_widget_show (GTK_WIDGET (pl));
|
||||||
|
|
||||||
g_object_unref (list);
|
g_object_unref (list);
|
||||||
g_object_unref (sorted);
|
|
||||||
g_object_unref (filtered);
|
|
||||||
g_object_unref (store);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -1234,12 +1234,12 @@ gtk_inspector_recorder_init (GtkInspectorRecorder *recorder)
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
recorder->render_node_root_model = g_list_store_new (GDK_TYPE_PAINTABLE);
|
recorder->render_node_root_model = g_list_store_new (GDK_TYPE_PAINTABLE);
|
||||||
recorder->render_node_model = gtk_tree_list_model_new (FALSE,
|
recorder->render_node_model = gtk_tree_list_model_new (g_object_ref (G_LIST_MODEL (recorder->render_node_root_model)),
|
||||||
G_LIST_MODEL (recorder->render_node_root_model),
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
create_list_model_for_render_node_paintable,
|
create_list_model_for_render_node_paintable,
|
||||||
NULL, NULL);
|
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);
|
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 ();
|
factory = gtk_signal_list_item_factory_new ();
|
||||||
|
@@ -692,7 +692,6 @@ static void
|
|||||||
constructed (GObject *object)
|
constructed (GObject *object)
|
||||||
{
|
{
|
||||||
GtkInspectorResourceList *rl = GTK_INSPECTOR_RESOURCE_LIST (object);
|
GtkInspectorResourceList *rl = GTK_INSPECTOR_RESOURCE_LIST (object);
|
||||||
GListModel *root_model;
|
|
||||||
GListModel *sort_model;
|
GListModel *sort_model;
|
||||||
GtkSorter *column_sorter;
|
GtkSorter *column_sorter;
|
||||||
GtkSorter *sorter;
|
GtkSorter *sorter;
|
||||||
@@ -702,9 +701,8 @@ constructed (GObject *object)
|
|||||||
g_signal_connect (rl->close_details_button, "clicked",
|
g_signal_connect (rl->close_details_button, "clicked",
|
||||||
G_CALLBACK (close_details), rl);
|
G_CALLBACK (close_details), rl);
|
||||||
|
|
||||||
root_model = load_resources ();
|
rl->tree_model = gtk_tree_list_model_new (load_resources (),
|
||||||
rl->tree_model = gtk_tree_list_model_new (FALSE,
|
FALSE,
|
||||||
root_model,
|
|
||||||
FALSE,
|
FALSE,
|
||||||
create_model_for_object,
|
create_model_for_object,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -712,11 +710,8 @@ 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 (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));
|
||||||
|
|
||||||
|
@@ -746,12 +746,11 @@ main (int argc, char *argv[])
|
|||||||
dirmodel = create_list_model_for_directory (root);
|
dirmodel = create_list_model_for_directory (root);
|
||||||
g_object_unref (root);
|
g_object_unref (root);
|
||||||
}
|
}
|
||||||
tree = gtk_tree_list_model_new (FALSE,
|
tree = gtk_tree_list_model_new (dirmodel,
|
||||||
dirmodel,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
create_list_model_for_file_info,
|
create_list_model_for_file_info,
|
||||||
NULL, NULL);
|
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))));
|
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);
|
sort = gtk_sort_list_model_new (G_LIST_MODEL (tree), sorter);
|
||||||
@@ -759,7 +758,6 @@ main (int argc, char *argv[])
|
|||||||
custom_filter = gtk_custom_filter_new (match_file, g_object_ref (search_entry), g_object_unref);
|
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);
|
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_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));
|
gtk_column_view_set_model (GTK_COLUMN_VIEW (view), G_LIST_MODEL (filter));
|
||||||
|
|
||||||
@@ -771,8 +769,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 (sort);
|
|
||||||
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))));
|
||||||
|
@@ -191,8 +191,8 @@ create_child_model (gpointer item,
|
|||||||
static GListModel *
|
static GListModel *
|
||||||
create_tree_model (guint n, guint m)
|
create_tree_model (guint n, guint m)
|
||||||
{
|
{
|
||||||
return G_LIST_MODEL (gtk_tree_list_model_new (FALSE,
|
return G_LIST_MODEL (gtk_tree_list_model_new (create_model (0, n, m, TRUE),
|
||||||
create_model (0, n, m, TRUE),
|
FALSE,
|
||||||
FALSE,
|
FALSE,
|
||||||
create_child_model,
|
create_child_model,
|
||||||
GUINT_TO_POINTER (m), NULL));
|
GUINT_TO_POINTER (m), NULL));
|
||||||
|
@@ -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;
|
||||||
@@ -594,7 +589,6 @@ int
|
|||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GtkWidget *win, *vbox, *sw, *listview, *search_entry, *statusbar;
|
GtkWidget *win, *vbox, *sw, *listview, *search_entry, *statusbar;
|
||||||
GListModel *dirmodel;
|
|
||||||
GtkTreeListModel *tree;
|
GtkTreeListModel *tree;
|
||||||
GtkFilterListModel *filter;
|
GtkFilterListModel *filter;
|
||||||
GtkFilter *custom_filter;
|
GtkFilter *custom_filter;
|
||||||
@@ -628,19 +622,16 @@ main (int argc, char *argv[])
|
|||||||
root = g_file_new_for_commandline_arg (argv[1]);
|
root = g_file_new_for_commandline_arg (argv[1]);
|
||||||
else
|
else
|
||||||
root = g_file_new_for_path (g_get_current_dir ());
|
root = g_file_new_for_path (g_get_current_dir ());
|
||||||
dirmodel = create_list_model_for_directory (root);
|
tree = gtk_tree_list_model_new (create_list_model_for_directory (root),
|
||||||
tree = gtk_tree_list_model_new (FALSE,
|
FALSE,
|
||||||
dirmodel,
|
|
||||||
TRUE,
|
TRUE,
|
||||||
create_list_model_for_file_info,
|
create_list_model_for_file_info,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
g_object_unref (dirmodel);
|
|
||||||
g_object_unref (root);
|
g_object_unref (root);
|
||||||
|
|
||||||
custom_filter = gtk_custom_filter_new (match_file, search_entry, NULL);
|
custom_filter = gtk_custom_filter_new (match_file, search_entry, NULL);
|
||||||
filter = gtk_filter_list_model_new (G_LIST_MODEL (tree), custom_filter);
|
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_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));
|
selectionmodel = file_info_selection_new (G_LIST_MODEL (filter));
|
||||||
g_object_unref (filter);
|
g_object_unref (filter);
|
||||||
@@ -654,7 +645,6 @@ main (int argc, char *argv[])
|
|||||||
update_statusbar (GTK_STATUSBAR (statusbar));
|
update_statusbar (GTK_STATUSBAR (statusbar));
|
||||||
gtk_box_append (GTK_BOX (vbox), statusbar);
|
gtk_box_append (GTK_BOX (vbox), statusbar);
|
||||||
|
|
||||||
g_object_unref (tree);
|
|
||||||
g_object_unref (selectionmodel);
|
g_object_unref (selectionmodel);
|
||||||
|
|
||||||
gtk_widget_show (win);
|
gtk_widget_show (win);
|
||||||
|
@@ -262,8 +262,6 @@ test_nested (void)
|
|||||||
g_assert_cmpint (counter, ==, 0);
|
g_assert_cmpint (counter, ==, 0);
|
||||||
|
|
||||||
g_object_unref (filtered);
|
g_object_unref (filtered);
|
||||||
g_object_unref (list);
|
|
||||||
g_object_unref (filter);
|
|
||||||
gtk_expression_unref (expr);
|
gtk_expression_unref (expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -189,7 +189,7 @@ new_model (guint size,
|
|||||||
{
|
{
|
||||||
GtkFilterListModel *result;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -135,6 +135,10 @@ filter_list_model_new (GListModel *source,
|
|||||||
GListStore *check;
|
GListStore *check;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
if (source)
|
||||||
|
g_object_ref (source);
|
||||||
|
if (filter)
|
||||||
|
g_object_ref (filter);
|
||||||
model = gtk_filter_list_model_new (source, filter);
|
model = gtk_filter_list_model_new (source, filter);
|
||||||
check = g_list_store_new (G_TYPE_OBJECT);
|
check = g_list_store_new (G_TYPE_OBJECT);
|
||||||
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model)); i++)
|
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 (model2);
|
||||||
g_object_unref (flatten2);
|
g_object_unref (flatten2);
|
||||||
g_object_unref (flatten1);
|
g_object_unref (flatten1);
|
||||||
g_object_unref (store2);
|
|
||||||
g_object_unref (store1);
|
|
||||||
g_object_unref (multi);
|
g_object_unref (multi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -167,8 +167,7 @@ new_model (guint size,
|
|||||||
filter = gtk_custom_filter_new (filter_func, data, NULL);
|
filter = gtk_custom_filter_new (filter_func, data, NULL);
|
||||||
else
|
else
|
||||||
filter = NULL;
|
filter = NULL;
|
||||||
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))), filter);
|
||||||
g_clear_object (&filter);
|
|
||||||
changes = g_string_new ("");
|
changes = g_string_new ("");
|
||||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||||
|
@@ -210,7 +210,7 @@ new_model (GListStore *store)
|
|||||||
GtkFlattenListModel *result;
|
GtkFlattenListModel *result;
|
||||||
GString *changes;
|
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 ("");
|
changes = g_string_new ("");
|
||||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||||
|
@@ -196,7 +196,7 @@ new_model (GListStore *store)
|
|||||||
GtkMapListModel *result;
|
GtkMapListModel *result;
|
||||||
GString *changes;
|
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 ("");
|
changes = g_string_new ("");
|
||||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||||
|
@@ -253,7 +253,7 @@ new_model (GListStore *store)
|
|||||||
GtkSelectionModel *result;
|
GtkSelectionModel *result;
|
||||||
GString *changes;
|
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 ("");
|
changes = g_string_new ("");
|
||||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
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 (store);
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
|
g_object_unref (filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -627,7 +628,7 @@ test_set_model (void)
|
|||||||
|
|
||||||
store = new_store (1, 5, 1);
|
store = new_store (1, 5, 1);
|
||||||
m1 = G_LIST_MODEL (store);
|
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);
|
selection = new_model (store);
|
||||||
assert_selection (selection, "");
|
assert_selection (selection, "");
|
||||||
assert_selection_changes (selection, "");
|
assert_selection_changes (selection, "");
|
||||||
|
@@ -249,7 +249,7 @@ new_model (GListStore *store, gboolean autoselect, gboolean can_unselect)
|
|||||||
GtkSelectionModel *result;
|
GtkSelectionModel *result;
|
||||||
GString *changes;
|
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,
|
/* We want to return an empty selection unless autoselect is true,
|
||||||
* so undo the initial selection due to autoselect defaulting to TRUE.
|
* so undo the initial selection due to autoselect defaulting to TRUE.
|
||||||
@@ -653,7 +653,7 @@ test_set_model (void)
|
|||||||
|
|
||||||
store = new_store (1, 5, 1);
|
store = new_store (1, 5, 1);
|
||||||
m1 = G_LIST_MODEL (store);
|
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);
|
selection = new_model (store, TRUE, TRUE);
|
||||||
assert_selection (selection, "1");
|
assert_selection (selection, "1");
|
||||||
assert_selection_changes (selection, "");
|
assert_selection_changes (selection, "");
|
||||||
|
@@ -191,7 +191,7 @@ new_model (GListStore *store, guint offset, guint size)
|
|||||||
GtkSliceListModel *result;
|
GtkSliceListModel *result;
|
||||||
GString *changes;
|
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 ("");
|
changes = g_string_new ("");
|
||||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||||
|
@@ -247,7 +247,7 @@ new_model (guint size,
|
|||||||
{
|
{
|
||||||
GtkSortListModel *result;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -630,8 +630,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)), 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)), 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 ? NULL : g_object_ref (source), id & 2 ? 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 ? NULL : g_object_ref (source), id & 2 ? NULL : g_object_ref (sorter));
|
||||||
|
|
||||||
switch (id >> 2)
|
switch (id >> 2)
|
||||||
{
|
{
|
||||||
@@ -433,7 +433,6 @@ test_stability (gconstpointer model_id)
|
|||||||
g_object_unref (sort2);
|
g_object_unref (sort2);
|
||||||
g_object_unref (sort1);
|
g_object_unref (sort1);
|
||||||
g_object_unref (flatten);
|
g_object_unref (flatten);
|
||||||
g_object_unref (store);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -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);
|
||||||
|
@@ -170,7 +170,7 @@ new_model (guint size,
|
|||||||
GtkTreeListModel *tree;
|
GtkTreeListModel *tree;
|
||||||
GString *changes;
|
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 ("");
|
changes = g_string_new ("");
|
||||||
g_object_set_qdata_full (G_OBJECT(tree), changes_quark, changes, free_changes);
|
g_object_set_qdata_full (G_OBJECT(tree), changes_quark, changes, free_changes);
|
||||||
g_signal_connect (tree, "items-changed", G_CALLBACK (items_changed), changes);
|
g_signal_connect (tree, "items-changed", G_CALLBACK (items_changed), changes);
|
||||||
|
@@ -158,8 +158,8 @@ new_child_model (gpointer item,
|
|||||||
static GListModel *
|
static GListModel *
|
||||||
new_model (guint size)
|
new_model (guint size)
|
||||||
{
|
{
|
||||||
return G_LIST_MODEL (gtk_tree_list_model_new (FALSE,
|
return G_LIST_MODEL (gtk_tree_list_model_new (G_LIST_MODEL (new_store (1, size, 1)),
|
||||||
G_LIST_MODEL (new_store (1, size, 1)),
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
new_child_model,
|
new_child_model,
|
||||||
NULL, NULL));
|
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 *
|
||||||
|
Reference in New Issue
Block a user