Compare commits

...

1 Commits

Author SHA1 Message Date
Matthias Clasen
a9c7f94e04 Change list widget to use a GtkSelectionModel
Change the type of the model property in GtkListView,
GtkColumnView and GtkGridView to be GtkSelectionModel.

The convenience of automatic interposition of a selection
model is minor, compared to the confusion.

Update all callers.
2020-07-17 07:35:09 -04:00
28 changed files with 124 additions and 111 deletions

View File

@@ -144,6 +144,7 @@ do_listview_applauncher (GtkWidget *do_widget)
{
GtkWidget *list, *sw;
GListModel *model;
GtkSelectionModel *selection;
GtkListItemFactory *factory;
/* Create a window and set a few defaults */
@@ -181,8 +182,10 @@ do_listview_applauncher (GtkWidget *do_widget)
* to create as many listitems as it needs to show itself to the user.
*/
model = create_application_list ();
gtk_list_view_set_model (GTK_LIST_VIEW (list), model);
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
gtk_list_view_set_model (GTK_LIST_VIEW (list), selection);
g_object_unref (model);
g_object_unref (selection);
/* List widgets should always be contained in a #GtkScrolledWindow,
* because otherwise they might get too large or they might not

View File

@@ -491,7 +491,7 @@ do_listview_clocks (GtkWidget *do_widget)
model = 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), GTK_SELECTION_MODEL (selection));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
g_object_unref (selection);
g_object_unref (model);

View File

@@ -662,7 +662,8 @@ create_color_grid (void)
{
GtkWidget *gridview;
GtkListItemFactory *factory;
GListModel *model, *selection;
GListModel *model;
GtkSelectionModel *selection;
gridview = gtk_grid_view_new ();
gtk_scrollable_set_hscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
@@ -678,7 +679,7 @@ create_color_grid (void)
model = G_LIST_MODEL (gtk_sort_list_model_new (gtk_color_list_new (0), NULL));
selection = G_LIST_MODEL (gtk_multi_selection_new (model));
selection = GTK_SELECTION_MODEL (gtk_multi_selection_new (model));
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), selection);
g_object_unref (selection);
g_object_unref (model);
@@ -857,7 +858,7 @@ do_listview_colors (GtkWidget *do_widget)
guint len;
GtkWidget *selection_view;
GListModel *selection_filter;
GListModel *no_selection;
GtkSelectionModel *selection;
GtkWidget *grid;
GtkWidget *selection_size_label;
GtkWidget *selection_average_picture;
@@ -945,10 +946,10 @@ do_listview_colors (GtkWidget *do_widget)
g_signal_connect (selection_filter, "items-changed", G_CALLBACK (update_selection_count), selection_size_label);
g_signal_connect (selection_filter, "items-changed", G_CALLBACK (update_selection_average), selection_average_picture);
no_selection = G_LIST_MODEL (gtk_no_selection_new (selection_filter));
gtk_grid_view_set_model (GTK_GRID_VIEW (selection_view), no_selection);
selection = GTK_SELECTION_MODEL (gtk_no_selection_new (selection_filter));
gtk_grid_view_set_model (GTK_GRID_VIEW (selection_view), selection);
g_object_unref (selection_filter);
g_object_unref (no_selection);
g_object_unref (selection);
model = gtk_multi_selection_get_model (GTK_MULTI_SELECTION (model));
g_object_ref (model);

View File

@@ -345,7 +345,7 @@ do_listview_settings (GtkWidget *do_widget)
GtkWidget *listview, *columnview;
GListModel *model;
GtkTreeListModel *treemodel;
GtkSingleSelection *selection;
GtkSelectionModel *selection;
GtkBuilderScope *scope;
GtkBuilder *builder;
GtkColumnViewColumn *name_column;
@@ -409,14 +409,14 @@ do_listview_settings (GtkWidget *do_widget)
create_settings_model,
NULL,
NULL);
selection = gtk_single_selection_new (G_LIST_MODEL (treemodel));
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (treemodel)));
g_object_bind_property_full (selection, "selected-item",
columnview, "model",
G_BINDING_SYNC_CREATE,
transform_settings_to_keys,
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), selection);
g_object_unref (selection);
g_object_unref (treemodel);
g_object_unref (model);

View File

@@ -281,7 +281,8 @@ GtkWidget *
create_weather_view (void)
{
GtkWidget *listview;
GListModel *model, *selection;
GListModel *model;
GtkSelectionModel *selection;
GtkListItemFactory *factory;
factory = gtk_signal_list_item_factory_new ();
@@ -291,7 +292,7 @@ create_weather_view (void)
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 = GTK_SELECTION_MODEL (gtk_no_selection_new (model));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
g_object_unref (selection);
g_object_unref (model);

View File

@@ -157,7 +157,7 @@ do_listview_words (GtkWidget *do_widget)
{
GtkWidget *header, *listview, *sw, *vbox, *search_entry, *open_button, *overlay;
GtkFilterListModel *filter_model;
GtkNoSelection *selection;
GtkSelectionModel *selection;
GtkStringList *stringlist;
GtkFilter *filter;
GFile *file;
@@ -218,8 +218,8 @@ do_listview_words (GtkWidget *do_widget)
gtk_builder_list_item_factory_new_from_bytes (NULL,
g_bytes_new_static (factory_text, strlen (factory_text))));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
selection = gtk_no_selection_new (G_LIST_MODEL (filter_model));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
selection = GTK_SELECTION_MODEL (gtk_no_selection_new (G_LIST_MODEL (filter_model)));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
g_object_unref (selection);
g_signal_connect (filter_model, "items-changed", G_CALLBACK (update_title_cb), progress);

View File

@@ -16,7 +16,7 @@ static GtkWidget *source_view;
static gchar *current_file = NULL;
static GtkWidget *notebook;
static GtkSingleSelection *selection;
static GtkSelectionModel *selection;
static GtkWidget *toplevel;
static char **search_needle;
@@ -220,7 +220,7 @@ activate_run (GSimpleAction *action,
GVariant *parameter,
gpointer window)
{
GtkTreeListRow *row = gtk_single_selection_get_selected_item (selection);
GtkTreeListRow *row = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (selection));
GtkDemo *demo = gtk_tree_list_row_get_item (row);
gtk_demo_run (demo, window);
@@ -932,7 +932,7 @@ activate_cb (GtkWidget *widget,
guint position,
gpointer window)
{
GtkTreeListRow *row = g_list_model_get_item (gtk_list_view_get_model (GTK_LIST_VIEW (widget)), position);
GtkTreeListRow *row = g_list_model_get_item (G_LIST_MODEL (gtk_list_view_get_model (GTK_LIST_VIEW (widget))), position);
GtkDemo *demo = gtk_tree_list_row_get_item (row);
gtk_demo_run (demo, window);
@@ -1152,11 +1152,11 @@ activate (GApplication *app)
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);
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (filter_model)));
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
selection_cb (selection, NULL, NULL);
selection_cb (GTK_SINGLE_SELECTION (selection), NULL, NULL);
g_object_unref (builder);
}

View File

@@ -628,7 +628,7 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
g_param_spec_object ("model",
P_("Model"),
P_("Model for the items displayed"),
G_TYPE_LIST_MODEL,
GTK_TYPE_SELECTION_MODEL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
@@ -1202,7 +1202,7 @@ gtk_column_view_new (void)
*
* Returns: (nullable) (transfer none): The model in use
**/
GListModel *
GtkSelectionModel *
gtk_column_view_get_model (GtkColumnView *self)
{
g_return_val_if_fail (GTK_IS_COLUMN_VIEW (self), NULL);
@@ -1215,17 +1215,14 @@ gtk_column_view_get_model (GtkColumnView *self)
* @self: a #GtkColumnView
* @model: (allow-none) (transfer none): the model to use or %NULL for none
*
* Sets the #GListModel to use.
*
* If the @model is a #GtkSelectionModel, it is used for managing the selection.
* Otherwise, @self creates a #GtkSingleSelection for the selection.
* Sets the #GtkSelectionModel to use.
**/
void
gtk_column_view_set_model (GtkColumnView *self,
GListModel *model)
gtk_column_view_set_model (GtkColumnView *self,
GtkSelectionModel *model)
{
g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model));
g_return_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model));
if (gtk_list_view_get_model (self->listview) == model)
return;

View File

@@ -26,6 +26,7 @@
#include <gtk/gtktypes.h>
#include <gtk/gtksortlistmodel.h>
#include <gtk/gtkselectionmodel.h>
#include <gtk/gtksorter.h>
G_BEGIN_DECLS
@@ -67,10 +68,10 @@ void gtk_column_view_insert_column (GtkColumnView
GtkColumnViewColumn *column);
GDK_AVAILABLE_IN_ALL
GListModel * gtk_column_view_get_model (GtkColumnView *self);
GtkSelectionModel * gtk_column_view_get_model (GtkColumnView *self);
GDK_AVAILABLE_IN_ALL
void gtk_column_view_set_model (GtkColumnView *self,
GListModel *model);
GtkSelectionModel *model);
GDK_AVAILABLE_IN_ALL
gboolean gtk_column_view_get_show_row_separators (GtkColumnView *self);

View File

@@ -513,7 +513,7 @@ update_combo_sensitivity_from_printers (GtkCustomPaperUnixDialog *dialog)
static void
update_custom_widgets_from_list (GtkCustomPaperUnixDialog *dialog)
{
GListModel *model;
GtkSelectionModel *model;
GtkPageSetup *page_setup;
model = gtk_list_view_get_model (GTK_LIST_VIEW (dialog->listview));
@@ -559,7 +559,7 @@ static void
unit_widget_changed (GtkCustomPaperUnixDialog *dialog)
{
double w, h, top, bottom, left, right;
GListModel *model;
GtkSelectionModel *model;
GtkPageSetup *page_setup;
GtkPaperSize *paper_size;
@@ -648,7 +648,7 @@ add_custom_paper (GtkCustomPaperUnixDialog *dialog)
static void
remove_custom_paper (GtkCustomPaperUnixDialog *dialog)
{
GListModel *model;
GtkSelectionModel *model;
guint selected;
model = gtk_list_view_get_model (GTK_LIST_VIEW (dialog->listview));
@@ -870,7 +870,7 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
GtkWidget *grid, *label, *widget, *frame, *combo;
GtkWidget *hbox, *vbox, *listview, *scrolled, *toolbar, *button;
GtkUnit user_units;
GListModel *model;
GtkSingleSelection *selection;
GtkListItemFactory *factory;
content_area = gtk_dialog_get_content_area (cpu_dialog);
@@ -899,10 +899,10 @@ 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)));
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);
selection = gtk_single_selection_new (G_LIST_MODEL (dialog->custom_paper_list));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), GTK_SELECTION_MODEL (selection));
g_signal_connect (selection, "notify::selected", G_CALLBACK (selected_custom_paper_changed), dialog);
g_object_unref (selection);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_item), NULL);

View File

@@ -673,7 +673,7 @@ gtk_drop_down_set_model (GtkDropDown *self,
selection = G_LIST_MODEL (gtk_single_selection_new (filter_model));
g_set_object (&self->popup_selection, selection);
gtk_list_view_set_model (GTK_LIST_VIEW (self->popup_list), selection);
gtk_list_view_set_model (GTK_LIST_VIEW (self->popup_list), GTK_SELECTION_MODEL (selection));
g_object_unref (selection);
selection = G_LIST_MODEL (gtk_single_selection_new (model));

View File

@@ -1092,7 +1092,7 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
g_param_spec_object ("model",
P_("Model"),
P_("Model for the items displayed"),
G_TYPE_LIST_MODEL,
GTK_TYPE_SELECTION_MODEL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
@@ -1235,7 +1235,7 @@ gtk_grid_view_new_with_factory (GtkListItemFactory *factory)
*
* Returns: (nullable) (transfer none): The model in use
**/
GListModel *
GtkSelectionModel *
gtk_grid_view_get_model (GtkGridView *self)
{
g_return_val_if_fail (GTK_IS_GRID_VIEW (self), NULL);
@@ -1248,14 +1248,14 @@ gtk_grid_view_get_model (GtkGridView *self)
* @self: a #GtkGridView
* @model: (allow-none) (transfer none): the model to use or %NULL for none
*
* Sets the #GListModel to use for
* Sets the #GtkSelectionModel to use for
**/
void
gtk_grid_view_set_model (GtkGridView *self,
GListModel *model)
gtk_grid_view_set_model (GtkGridView *self,
GtkSelectionModel *model)
{
g_return_if_fail (GTK_IS_GRID_VIEW (self));
g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model));
g_return_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model));
if (!gtk_list_base_set_model (GTK_LIST_BASE (self), model))
return;

View File

@@ -25,6 +25,7 @@
#endif
#include <gtk/gtklistbase.h>
#include <gtk/gtkselectionmodel.h>
G_BEGIN_DECLS
@@ -53,10 +54,10 @@ GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_grid_view_new_with_factory (GtkListItemFactory *factory);
GDK_AVAILABLE_IN_ALL
GListModel * gtk_grid_view_get_model (GtkGridView *self);
GtkSelectionModel * gtk_grid_view_get_model (GtkGridView *self);
GDK_AVAILABLE_IN_ALL
void gtk_grid_view_set_model (GtkGridView *self,
GListModel *model);
GtkSelectionModel *model);
GDK_AVAILABLE_IN_ALL
void gtk_grid_view_set_factory (GtkGridView *self,
GtkListItemFactory *factory);

View File

@@ -2102,40 +2102,30 @@ gtk_list_base_grab_focus_on_item (GtkListBase *self,
return TRUE;
}
GListModel *
GtkSelectionModel *
gtk_list_base_get_model (GtkListBase *self)
{
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
return priv->model;
return GTK_SELECTION_MODEL (priv->model);
}
gboolean
gtk_list_base_set_model (GtkListBase *self,
GListModel *model)
gtk_list_base_set_model (GtkListBase *self,
GtkSelectionModel *model)
{
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
if (priv->model == model)
if (priv->model == G_LIST_MODEL (model))
return FALSE;
g_clear_object (&priv->model);
if (model)
{
GtkSelectionModel *selection_model;
priv->model = g_object_ref (model);
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));
gtk_list_item_manager_set_model (priv->item_manager, selection_model);
priv->model = g_object_ref (G_LIST_MODEL (model));
gtk_list_item_manager_set_model (priv->item_manager, model);
gtk_list_base_set_anchor (self, 0, 0.0, GTK_PACK_START, 0.0, GTK_PACK_START);
g_object_unref (selection_model);
}
else
{

View File

@@ -23,6 +23,7 @@
#include "gtklistbase.h"
#include "gtklistitemmanagerprivate.h"
#include "gtkselectionmodel.h"
#include "gtkprivate.h"
struct _GtkListBase
@@ -71,9 +72,9 @@ GtkListItemManager * gtk_list_base_get_manager (GtkListBase
GtkScrollablePolicy gtk_list_base_get_scroll_policy (GtkListBase *self,
GtkOrientation orientation);
guint gtk_list_base_get_n_items (GtkListBase *self);
GListModel * gtk_list_base_get_model (GtkListBase *self);
GtkSelectionModel * gtk_list_base_get_model (GtkListBase *self);
gboolean gtk_list_base_set_model (GtkListBase *self,
GListModel *model);
GtkSelectionModel *model);
void gtk_list_base_update_adjustments (GtkListBase *self,
int total_across,
int total_along,

View File

@@ -831,13 +831,14 @@ gtk_list_view_class_init (GtkListViewClass *klass)
/**
* GtkListView:model:
*
* Model for the items displayed
* Model for the items displayed.
* This must be a #GtkSelectionModel
*/
properties[PROP_MODEL] =
g_param_spec_object ("model",
P_("Model"),
P_("Model for the items displayed"),
G_TYPE_LIST_MODEL,
GTK_TYPE_SELECTION_MODEL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
@@ -989,7 +990,7 @@ gtk_list_view_new_with_factory (GtkListItemFactory *factory)
*
* Returns: (nullable) (transfer none): The model in use
**/
GListModel *
GtkSelectionModel *
gtk_list_view_get_model (GtkListView *self)
{
g_return_val_if_fail (GTK_IS_LIST_VIEW (self), NULL);
@@ -1002,17 +1003,14 @@ gtk_list_view_get_model (GtkListView *self)
* @self: a #GtkListView
* @model: (allow-none) (transfer none): the model to use or %NULL for none
*
* Sets the #GListModel to use.
*
* If the @model is a #GtkSelectionModel, it is used for managing the selection.
* Otherwise, @self creates a #GtkSingleSelection for the selection.
**/
* Sets the #GtkSelectionModel to use.
*/
void
gtk_list_view_set_model (GtkListView *self,
GListModel *model)
gtk_list_view_set_model (GtkListView *self,
GtkSelectionModel *model)
{
g_return_if_fail (GTK_IS_LIST_VIEW (self));
g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model));
g_return_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model));
if (!gtk_list_base_set_model (GTK_LIST_BASE (self), model))
return;

View File

@@ -25,6 +25,7 @@
#endif
#include <gtk/gtklistbase.h>
#include <gtk/gtkselectionmodel.h>
G_BEGIN_DECLS
@@ -52,10 +53,10 @@ GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_list_view_new_with_factory (GtkListItemFactory *factory);
GDK_AVAILABLE_IN_ALL
GListModel * gtk_list_view_get_model (GtkListView *self);
GtkSelectionModel * gtk_list_view_get_model (GtkListView *self);
GDK_AVAILABLE_IN_ALL
void gtk_list_view_set_model (GtkListView *self,
GListModel *model);
GtkSelectionModel *model);
GDK_AVAILABLE_IN_ALL
void gtk_list_view_set_factory (GtkListView *self,
GtkListItemFactory *factory);

View File

@@ -740,7 +740,7 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
GListModel *model;
GListModel *sorted;
GListModel *filtered;
GListModel *selection;
GtkSingleSelection *selection;
GtkSorter *sorter;
GtkFilter *filter;
GtkFilter *filter1;
@@ -833,10 +833,10 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
filtered = G_LIST_MODEL (gtk_filter_list_model_new (sorted, filter));
g_object_unref (filter);
selection = G_LIST_MODEL (gtk_single_selection_new (filtered));
gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (selection), FALSE);
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (selection), GTK_INVALID_LIST_POSITION);
gtk_column_view_set_model (GTK_COLUMN_VIEW (dialog->printer_list), selection);
selection = gtk_single_selection_new (filtered);
gtk_single_selection_set_autoselect (selection, FALSE);
gtk_single_selection_set_selected (selection, GTK_INVALID_LIST_POSITION);
gtk_column_view_set_model (GTK_COLUMN_VIEW (dialog->printer_list), GTK_SELECTION_MODEL (selection));
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);
@@ -983,18 +983,18 @@ printer_status_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
GtkPrintUnixDialog *dialog)
{
GListModel *model;
GtkSingleSelection *selection;
/* When the pause state change then we need to update sensitive property
* of GTK_RESPONSE_OK button inside of selected_printer_changed function.
*/
selected_printer_changed (dialog);
model = gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list));
selection = GTK_SINGLE_SELECTION (gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list)));
if (gtk_print_backend_printer_list_is_done (backend) &&
gtk_printer_is_default (printer) &&
gtk_single_selection_get_selected (GTK_SINGLE_SELECTION (model)) == GTK_INVALID_LIST_POSITION)
gtk_single_selection_get_selected (selection) == GTK_INVALID_LIST_POSITION)
set_active_printer (dialog, gtk_printer_get_name (printer));
}
@@ -1822,9 +1822,11 @@ printer_details_acquired (GtkPrinter *printer,
static void
selected_printer_changed (GtkPrintUnixDialog *dialog)
{
GListModel *model = gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list));
GtkSingleSelection *selection;
GtkPrinter *printer;
selection = GTK_SINGLE_SELECTION (gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list)));
/* Whenever the user selects a printer we stop looking for
* the printer specified in the initial settings
*/
@@ -1837,7 +1839,7 @@ selected_printer_changed (GtkPrintUnixDialog *dialog)
disconnect_printer_details_request (dialog, FALSE);
printer = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (model));
printer = gtk_single_selection_get_selected_item (selection);
/* sets GTK_RESPONSE_OK button sensitivity depending on whether the printer
* accepts/rejects jobs
@@ -3170,7 +3172,7 @@ set_active_printer (GtkPrintUnixDialog *dialog,
GtkPrinter *printer;
guint i;
model = gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list));
model = G_LIST_MODEL (gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list)));
for (i = 0; i < g_list_model_get_n_items (model); i++)
{

View File

@@ -422,7 +422,7 @@ constructed (GObject *object)
GtkInspectorActions *sl = GTK_INSPECTOR_ACTIONS (object);
GtkSorter *sorter;
GListModel *sorted;
GListModel *model;
GtkSelectionModel *model;
g_signal_connect_swapped (sl->priv->button, "clicked",
G_CALLBACK (refresh_all), sl);
@@ -438,7 +438,7 @@ constructed (GObject *object)
sl->priv->actions = G_LIST_MODEL (g_list_store_new (ACTION_TYPE_HOLDER));
sorted = G_LIST_MODEL (gtk_sort_list_model_new (sl->priv->actions,
gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->priv->list))));
model = G_LIST_MODEL (gtk_no_selection_new (sorted));
model = GTK_SELECTION_MODEL (gtk_no_selection_new (sorted));
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->priv->list), model);
g_object_unref (sorted);
g_object_unref (model);

View File

@@ -86,7 +86,7 @@ gtk_inspector_list_data_set_object (GtkInspectorListData *sl,
sl->object = G_LIST_MODEL (object);
selection = gtk_no_selection_new (sl->object);
gtk_column_view_set_model (sl->view, G_LIST_MODEL (selection));
gtk_column_view_set_model (sl->view, GTK_SELECTION_MODEL (selection));
g_object_unref (selection);
}

View File

@@ -1345,5 +1345,5 @@ gtk_inspector_object_tree_set_display (GtkInspectorObjectTree *wt,
g_object_unref (root_model);
gtk_column_view_set_model (GTK_COLUMN_VIEW (wt->priv->list),
G_LIST_MODEL (wt->priv->selection));
GTK_SELECTION_MODEL (wt->priv->selection));
}

View File

@@ -583,7 +583,7 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
guint num_properties;
guint i;
GListStore *store;
GListModel *list;
GtkNoSelection *selection;
GListModel *filtered;
GtkSortListModel *sorted;
@@ -624,15 +624,15 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
filtered = G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (store), pl->priv->filter));
sorted = gtk_sort_list_model_new (filtered, NULL);
list = G_LIST_MODEL (gtk_no_selection_new (G_LIST_MODEL (sorted)));
selection = gtk_no_selection_new (G_LIST_MODEL (sorted));
gtk_column_view_set_model (GTK_COLUMN_VIEW (pl->priv->list), list);
gtk_column_view_set_model (GTK_COLUMN_VIEW (pl->priv->list), GTK_SELECTION_MODEL (selection));
gtk_sort_list_model_set_sorter (sorted, gtk_column_view_get_sorter (GTK_COLUMN_VIEW (pl->priv->list)));
gtk_column_view_sort_by_column (GTK_COLUMN_VIEW (pl->priv->list), pl->priv->name, GTK_SORT_ASCENDING);
gtk_widget_show (GTK_WIDGET (pl));
g_object_unref (list);
g_object_unref (selection);
g_object_unref (sorted);
g_object_unref (filtered);
g_object_unref (store);

View File

@@ -1247,7 +1247,7 @@ gtk_inspector_recorder_init (GtkInspectorRecorder *recorder)
gtk_list_view_set_factory (GTK_LIST_VIEW (priv->render_node_list), factory);
g_object_unref (factory);
gtk_list_view_set_model (GTK_LIST_VIEW (priv->render_node_list),
G_LIST_MODEL (priv->render_node_selection));
GTK_SELECTION_MODEL (priv->render_node_selection));
priv->render_node_properties = GTK_TREE_MODEL (gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_TEXTURE));
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->node_property_tree), priv->render_node_properties);

View File

@@ -718,7 +718,7 @@ constructed (GObject *object)
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), GTK_SELECTION_MODEL (rl->selection));
g_signal_connect (rl->selection, "selection-changed", G_CALLBACK (on_selection_changed), rl);
}

View File

@@ -687,6 +687,7 @@ main (int argc, char *argv[])
GListModel *dirmodel;
GtkTreeListModel *tree;
GtkFilterListModel *filter;
GtkSelectionModel *selection;
GtkFilter *custom_filter;
GtkSortListModel *sort;
GtkSorter *sorter;
@@ -761,7 +762,9 @@ main (int argc, char *argv[])
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));
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (filter)));
gtk_column_view_set_model (GTK_COLUMN_VIEW (view), selection);
g_object_unref (selection);
statusbar = gtk_statusbar_new ();
gtk_widget_add_tick_callback (statusbar, (GtkTickCallback) update_statusbar, NULL, NULL);
@@ -776,7 +779,9 @@ main (int argc, char *argv[])
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_list_view_set_model (GTK_LIST_VIEW (list), gtk_column_view_get_columns (GTK_COLUMN_VIEW (view)));
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (gtk_column_view_get_columns (GTK_COLUMN_VIEW (view))));
gtk_list_view_set_model (GTK_LIST_VIEW (list), selection);
g_object_unref (selection);
gtk_box_append (GTK_BOX (hbox), list);
g_object_unref (scope);

View File

@@ -309,6 +309,7 @@ main (int argc, char *argv[])
GtkWidget *list;
GtkWidget *cv;
GListModel *model;
GtkSelectionModel *selection;
GtkListItemFactory *factory;
gtk_init ();
@@ -349,7 +350,9 @@ main (int argc, char *argv[])
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), grid);
model = create_model (0, 400, 1, FALSE);
gtk_grid_view_set_model (GTK_GRID_VIEW (grid), model);
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
gtk_grid_view_set_model (GTK_GRID_VIEW (grid), selection);
g_object_unref (selection);
g_object_unref (model);
factory = gtk_signal_list_item_factory_new ();
@@ -369,7 +372,9 @@ main (int argc, char *argv[])
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
model = create_model (0, 400, 1, FALSE);
gtk_list_view_set_model (GTK_LIST_VIEW (list), model);
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
gtk_list_view_set_model (GTK_LIST_VIEW (list), selection);
g_object_unref (selection);
g_object_unref (model);
factory = gtk_signal_list_item_factory_new ();
@@ -388,7 +393,9 @@ main (int argc, char *argv[])
cv = gtk_column_view_new ();
model = create_model (0, 400, 1, FALSE);
gtk_column_view_set_model (GTK_COLUMN_VIEW (cv), model);
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
gtk_column_view_set_model (GTK_COLUMN_VIEW (cv), selection);
g_object_unref (selection);
g_object_unref (model);
for (guint i = 0; i < 20; i++)
@@ -419,7 +426,9 @@ main (int argc, char *argv[])
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
model = create_tree_model (20, 20);
gtk_list_view_set_model (GTK_LIST_VIEW (list), model);
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
gtk_list_view_set_model (GTK_LIST_VIEW (list), selection);
g_object_unref (selection);
g_object_unref (model);
factory = gtk_signal_list_item_factory_new ();

View File

@@ -116,6 +116,7 @@ main (int argc,
GListStore *store;
GListModel *toplevels;
GtkSortListModel *sort;
GtkSelectionModel *selection;
GtkSorter *sorter;
guint i;
GtkListItemFactory *factory;
@@ -167,7 +168,9 @@ main (int argc,
listbox = gtk_list_box_new ();
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listbox);
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (sort));
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (sort)));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
g_object_unref (selection);
gtk_list_box_bind_model (GTK_LIST_BOX (listbox),
G_LIST_MODEL (sort),
create_widget_for_listbox,

View File

@@ -645,7 +645,7 @@ main (int argc, char *argv[])
selectionmodel = file_info_selection_new (G_LIST_MODEL (filter));
g_object_unref (filter);
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selectionmodel));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), GTK_SELECTION_MODEL (selectionmodel));
statusbar = gtk_statusbar_new ();
gtk_widget_add_tick_callback (statusbar, (GtkTickCallback) update_statusbar, NULL, NULL);