forked from AuroraMiddleware/gtk
list widgets: Use selection models in the api
Change the apis in GtkListView, GtkColumnView and GtkGridView to be explicitly about GtkSelectionModel, to make it obvious that the widgets handle selection. Update all users.
This commit is contained in:
parent
d2d8b748e9
commit
8d79a32c50
@ -164,7 +164,7 @@ populate_grid (void)
|
|||||||
list = create_color_grid ();
|
list = create_color_grid ();
|
||||||
|
|
||||||
selection = gtk_no_selection_new (gtk_color_list_new (2097152));
|
selection = gtk_no_selection_new (gtk_color_list_new (2097152));
|
||||||
gtk_grid_view_set_model (GTK_GRID_VIEW (list), G_LIST_MODEL (selection));
|
gtk_grid_view_set_model (GTK_GRID_VIEW (list), GTK_SELECTION_MODEL (selection));
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
|
|
||||||
hincrement = 0;
|
hincrement = 0;
|
||||||
|
@ -104,7 +104,7 @@ activate_cb (GtkListView *list,
|
|||||||
GdkAppLaunchContext *context;
|
GdkAppLaunchContext *context;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
app_info = g_list_model_get_item (gtk_list_view_get_model (list), position);
|
app_info = g_list_model_get_item (G_LIST_MODEL (gtk_list_view_get_model (list)), position);
|
||||||
|
|
||||||
/* Prepare the context for launching the application and launch it. This
|
/* Prepare the context for launching the application and launch it. This
|
||||||
* code is explained in detail in the documentation for #GdkAppLaunchContext
|
* code is explained in detail in the documentation for #GdkAppLaunchContext
|
||||||
@ -176,7 +176,7 @@ do_listview_applauncher (GtkWidget *do_widget)
|
|||||||
|
|
||||||
/* Create the list widget here.
|
/* Create the list widget here.
|
||||||
*/
|
*/
|
||||||
list = gtk_list_view_new_with_factory (model, factory);
|
list = gtk_list_view_new_with_factory (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory);
|
||||||
|
|
||||||
/* We connect the activate signal here. It's the function we defined
|
/* We connect the activate signal here. It's the function we defined
|
||||||
* above for launching the selected application.
|
* above for launching the selected application.
|
||||||
|
@ -462,7 +462,7 @@ do_listview_clocks (GtkWidget *do_widget)
|
|||||||
{
|
{
|
||||||
GtkWidget *gridview, *sw;
|
GtkWidget *gridview, *sw;
|
||||||
GtkListItemFactory *factory;
|
GtkListItemFactory *factory;
|
||||||
GListModel *model;
|
GtkSelectionModel *model;
|
||||||
|
|
||||||
/* This is the normal window setup code every demo does */
|
/* This is the normal window setup code every demo does */
|
||||||
window = gtk_window_new ();
|
window = gtk_window_new ();
|
||||||
@ -484,7 +484,7 @@ do_listview_clocks (GtkWidget *do_widget)
|
|||||||
factory = gtk_signal_list_item_factory_new ();
|
factory = gtk_signal_list_item_factory_new ();
|
||||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
|
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
|
||||||
|
|
||||||
model = G_LIST_MODEL (gtk_no_selection_new (create_clocks_model ()));
|
model = GTK_SELECTION_MODEL (gtk_no_selection_new (create_clocks_model ()));
|
||||||
gridview = gtk_grid_view_new_with_factory (model, factory);
|
gridview = gtk_grid_view_new_with_factory (model, factory);
|
||||||
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);
|
||||||
|
@ -866,7 +866,7 @@ do_listview_colors (GtkWidget *do_widget)
|
|||||||
guint len;
|
guint len;
|
||||||
GtkWidget *selection_view;
|
GtkWidget *selection_view;
|
||||||
GListModel *selection_filter;
|
GListModel *selection_filter;
|
||||||
GListModel *no_selection;
|
GtkSelectionModel *no_selection;
|
||||||
GtkWidget *grid;
|
GtkWidget *grid;
|
||||||
GtkWidget *selection_size_label;
|
GtkWidget *selection_size_label;
|
||||||
GtkWidget *selection_average_picture;
|
GtkWidget *selection_average_picture;
|
||||||
@ -959,7 +959,7 @@ do_listview_colors (GtkWidget *do_widget)
|
|||||||
gtk_box_append (GTK_BOX (box), sw);
|
gtk_box_append (GTK_BOX (box), sw);
|
||||||
|
|
||||||
gridview = create_color_grid ();
|
gridview = create_color_grid ();
|
||||||
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);
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
|
||||||
gtk_widget_set_hexpand (sw, TRUE);
|
gtk_widget_set_hexpand (sw, TRUE);
|
||||||
gtk_widget_set_vexpand (sw, TRUE);
|
gtk_widget_set_vexpand (sw, TRUE);
|
||||||
@ -968,7 +968,7 @@ 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_count), selection_size_label);
|
||||||
g_signal_connect (selection_filter, "items-changed", G_CALLBACK (update_selection_average), selection_average_picture);
|
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));
|
no_selection = GTK_SELECTION_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 (no_selection);
|
g_object_unref (no_selection);
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ filebrowser_view_activated_cb (GtkGridView *view,
|
|||||||
{
|
{
|
||||||
GFileInfo *info;
|
GFileInfo *info;
|
||||||
|
|
||||||
info = g_list_model_get_item (gtk_grid_view_get_model (view), pos);
|
info = g_list_model_get_item (G_LIST_MODEL (gtk_grid_view_get_model (view)), pos);
|
||||||
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
|
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
|
||||||
gtk_directory_list_set_file (list, G_FILE (g_file_info_get_attribute_object (info, "standard::file")));
|
gtk_directory_list_set_file (list, G_FILE (g_file_info_get_attribute_object (info, "standard::file")));
|
||||||
|
|
||||||
|
@ -165,8 +165,12 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkDirectoryList" id="dirlist">
|
<object class="GtkSingleSelection" id="selection_model">
|
||||||
<property name="attributes">standard::name,standard::display-name,standard::icon,standard::size,standard::content-type</property>
|
<property name="model">
|
||||||
|
<object class="GtkDirectoryList" id="dirlist">
|
||||||
|
<property name="attributes">standard::name,standard::display-name,standard::icon,standard::size,standard::content-type</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkWindow" id="window">
|
<object class="GtkWindow" id="window">
|
||||||
<property name="title" translatable="yes">File browser</property>
|
<property name="title" translatable="yes">File browser</property>
|
||||||
@ -227,7 +231,7 @@
|
|||||||
<property name="can-focus">1</property>
|
<property name="can-focus">1</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGridView" id="view">
|
<object class="GtkGridView" id="view">
|
||||||
<property name="model">dirlist</property>
|
<property name="model">selection_model</property>
|
||||||
<property name="max-columns">15</property>
|
<property name="max-columns">15</property>
|
||||||
<binding name="factory">
|
<binding name="factory">
|
||||||
<lookup name="factory" type="FileBrowserView">
|
<lookup name="factory" type="FileBrowserView">
|
||||||
|
@ -413,7 +413,7 @@ do_listview_settings (GtkWidget *do_widget)
|
|||||||
transform_settings_to_keys,
|
transform_settings_to_keys,
|
||||||
NULL,
|
NULL,
|
||||||
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), GTK_SELECTION_MODEL (selection));
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
|
|
||||||
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"));
|
||||||
|
@ -281,13 +281,13 @@ GtkWidget *
|
|||||||
create_weather_view (void)
|
create_weather_view (void)
|
||||||
{
|
{
|
||||||
GtkWidget *listview;
|
GtkWidget *listview;
|
||||||
GListModel *model;
|
GtkSelectionModel *model;
|
||||||
GtkListItemFactory *factory;
|
GtkListItemFactory *factory;
|
||||||
|
|
||||||
factory = gtk_signal_list_item_factory_new ();
|
factory = gtk_signal_list_item_factory_new ();
|
||||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_widget), NULL);
|
g_signal_connect (factory, "setup", G_CALLBACK (setup_widget), NULL);
|
||||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_widget), NULL);
|
g_signal_connect (factory, "bind", G_CALLBACK (bind_widget), NULL);
|
||||||
model = G_LIST_MODEL (gtk_no_selection_new (create_weather_model ()));
|
model = GTK_SELECTION_MODEL (gtk_no_selection_new (create_weather_model ()));
|
||||||
listview = gtk_list_view_new_with_factory (model, factory);
|
listview = gtk_list_view_new_with_factory (model, 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);
|
||||||
|
@ -218,7 +218,7 @@ do_listview_words (GtkWidget *do_widget)
|
|||||||
gtk_overlay_set_child (GTK_OVERLAY (overlay), sw);
|
gtk_overlay_set_child (GTK_OVERLAY (overlay), sw);
|
||||||
|
|
||||||
listview = gtk_list_view_new_with_factory (
|
listview = gtk_list_view_new_with_factory (
|
||||||
G_LIST_MODEL (gtk_no_selection_new (G_LIST_MODEL (filter_model))),
|
GTK_SELECTION_MODEL (gtk_no_selection_new (G_LIST_MODEL (filter_model))),
|
||||||
gtk_builder_list_item_factory_new_from_bytes (NULL,
|
gtk_builder_list_item_factory_new_from_bytes (NULL,
|
||||||
g_bytes_new_static (factory_text, strlen (factory_text))));
|
g_bytes_new_static (factory_text, strlen (factory_text))));
|
||||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
|
||||||
|
@ -640,7 +640,8 @@ activate_cb (GtkWidget *widget,
|
|||||||
guint position,
|
guint position,
|
||||||
gpointer window)
|
gpointer window)
|
||||||
{
|
{
|
||||||
GtkTreeListRow *row = g_list_model_get_item (gtk_list_view_get_model (GTK_LIST_VIEW (widget)), position);
|
GListModel *model = G_LIST_MODEL (gtk_list_view_get_model (GTK_LIST_VIEW (widget)));
|
||||||
|
GtkTreeListRow *row = g_list_model_get_item (model, position);
|
||||||
GtkDemo *demo = gtk_tree_list_row_get_item (row);
|
GtkDemo *demo = gtk_tree_list_row_get_item (row);
|
||||||
|
|
||||||
gtk_demo_run (demo, window);
|
gtk_demo_run (demo, window);
|
||||||
@ -872,9 +873,10 @@ activate (GApplication *app)
|
|||||||
|
|
||||||
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
|
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
|
||||||
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
|
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), GTK_SELECTION_MODEL (selection));
|
||||||
|
|
||||||
selection_cb (selection, NULL, NULL);
|
selection_cb (selection, NULL, NULL);
|
||||||
|
g_object_unref (selection);
|
||||||
|
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ item_activated (GtkGridView *view,
|
|||||||
guint position,
|
guint position,
|
||||||
IconBrowserWindow *win)
|
IconBrowserWindow *win)
|
||||||
{
|
{
|
||||||
GListModel *model = gtk_grid_view_get_model (view);
|
GListModel *model = G_LIST_MODEL (gtk_grid_view_get_model (view));
|
||||||
IbIcon *icon = g_list_model_get_item (model, position);
|
IbIcon *icon = g_list_model_get_item (model, position);
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *description;
|
const char *description;
|
||||||
|
@ -632,7 +632,7 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
|
|||||||
g_param_spec_object ("model",
|
g_param_spec_object ("model",
|
||||||
P_("Model"),
|
P_("Model"),
|
||||||
P_("Model for the items displayed"),
|
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);
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1193,11 +1193,11 @@ gtk_column_view_init (GtkColumnView *self)
|
|||||||
* Returns: a new #GtkColumnView
|
* Returns: a new #GtkColumnView
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gtk_column_view_new (GListModel *model)
|
gtk_column_view_new (GtkSelectionModel *model)
|
||||||
{
|
{
|
||||||
GtkWidget *result;
|
GtkWidget *result;
|
||||||
|
|
||||||
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
|
g_return_val_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model), NULL);
|
||||||
|
|
||||||
result = g_object_new (GTK_TYPE_COLUMN_VIEW,
|
result = g_object_new (GTK_TYPE_COLUMN_VIEW,
|
||||||
"model", model,
|
"model", model,
|
||||||
@ -1217,7 +1217,7 @@ gtk_column_view_new (GListModel *model)
|
|||||||
*
|
*
|
||||||
* Returns: (nullable) (transfer none): The model in use
|
* Returns: (nullable) (transfer none): The model in use
|
||||||
**/
|
**/
|
||||||
GListModel *
|
GtkSelectionModel *
|
||||||
gtk_column_view_get_model (GtkColumnView *self)
|
gtk_column_view_get_model (GtkColumnView *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GTK_IS_COLUMN_VIEW (self), NULL);
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW (self), NULL);
|
||||||
@ -1230,17 +1230,14 @@ gtk_column_view_get_model (GtkColumnView *self)
|
|||||||
* @self: a #GtkColumnView
|
* @self: a #GtkColumnView
|
||||||
* @model: (allow-none) (transfer none): the model to use or %NULL for none
|
* @model: (allow-none) (transfer none): the model to use or %NULL for none
|
||||||
*
|
*
|
||||||
* Sets the #GListModel to use.
|
* Sets the #GtkSelectionModel to use.
|
||||||
*
|
|
||||||
* If the @model is a #GtkSelectionModel, it is used for managing the selection.
|
|
||||||
* Otherwise, @self creates a #GtkSingleSelection for the selection.
|
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gtk_column_view_set_model (GtkColumnView *self,
|
gtk_column_view_set_model (GtkColumnView *self,
|
||||||
GListModel *model)
|
GtkSelectionModel *model)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
|
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)
|
if (gtk_list_view_get_model (self->listview) == model)
|
||||||
return;
|
return;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <gtk/gtktypes.h>
|
#include <gtk/gtktypes.h>
|
||||||
#include <gtk/gtksortlistmodel.h>
|
#include <gtk/gtksortlistmodel.h>
|
||||||
|
#include <gtk/gtkselectionmodel.h>
|
||||||
#include <gtk/gtksorter.h>
|
#include <gtk/gtksorter.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
@ -51,7 +52,7 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
GType gtk_column_view_get_type (void) G_GNUC_CONST;
|
GType gtk_column_view_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkWidget * gtk_column_view_new (GListModel *model);
|
GtkWidget * gtk_column_view_new (GtkSelectionModel *model);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GListModel * gtk_column_view_get_columns (GtkColumnView *self);
|
GListModel * gtk_column_view_get_columns (GtkColumnView *self);
|
||||||
@ -67,10 +68,11 @@ void gtk_column_view_insert_column (GtkColumnView
|
|||||||
GtkColumnViewColumn *column);
|
GtkColumnViewColumn *column);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GListModel * gtk_column_view_get_model (GtkColumnView *self);
|
GtkSelectionModel *
|
||||||
|
gtk_column_view_get_model (GtkColumnView *self);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_column_view_set_model (GtkColumnView *self,
|
void gtk_column_view_set_model (GtkColumnView *self,
|
||||||
GListModel *model);
|
GtkSelectionModel *model);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
gboolean gtk_column_view_get_show_row_separators (GtkColumnView *self);
|
gboolean gtk_column_view_get_show_row_separators (GtkColumnView *self);
|
||||||
|
@ -513,7 +513,7 @@ update_custom_widgets_from_list (GtkCustomPaperUnixDialog *dialog)
|
|||||||
GListModel *model;
|
GListModel *model;
|
||||||
GtkPageSetup *page_setup;
|
GtkPageSetup *page_setup;
|
||||||
|
|
||||||
model = gtk_list_view_get_model (GTK_LIST_VIEW (dialog->listview));
|
model = G_LIST_MODEL (gtk_list_view_get_model (GTK_LIST_VIEW (dialog->listview)));
|
||||||
page_setup = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (model));
|
page_setup = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (model));
|
||||||
|
|
||||||
dialog->non_user_change = TRUE;
|
dialog->non_user_change = TRUE;
|
||||||
@ -563,7 +563,7 @@ unit_widget_changed (GtkCustomPaperUnixDialog *dialog)
|
|||||||
if (dialog->non_user_change)
|
if (dialog->non_user_change)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
model = gtk_list_view_get_model (GTK_LIST_VIEW (dialog->listview));
|
model = G_LIST_MODEL (gtk_list_view_get_model (GTK_LIST_VIEW (dialog->listview)));
|
||||||
page_setup = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (model));
|
page_setup = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (model));
|
||||||
|
|
||||||
if (page_setup != NULL)
|
if (page_setup != NULL)
|
||||||
@ -648,7 +648,7 @@ remove_custom_paper (GtkCustomPaperUnixDialog *dialog)
|
|||||||
GListModel *model;
|
GListModel *model;
|
||||||
guint selected;
|
guint selected;
|
||||||
|
|
||||||
model = gtk_list_view_get_model (GTK_LIST_VIEW (dialog->listview));
|
model = G_LIST_MODEL (gtk_list_view_get_model (GTK_LIST_VIEW (dialog->listview)));
|
||||||
selected = gtk_single_selection_get_selected (GTK_SINGLE_SELECTION (model));
|
selected = gtk_single_selection_get_selected (GTK_SINGLE_SELECTION (model));
|
||||||
if (selected != GTK_INVALID_LIST_POSITION)
|
if (selected != GTK_INVALID_LIST_POSITION)
|
||||||
g_list_store_remove (dialog->custom_paper_list, selected);
|
g_list_store_remove (dialog->custom_paper_list, selected);
|
||||||
@ -867,7 +867,7 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
|
|||||||
GtkWidget *grid, *label, *widget, *frame, *combo;
|
GtkWidget *grid, *label, *widget, *frame, *combo;
|
||||||
GtkWidget *hbox, *vbox, *listview, *scrolled, *toolbar, *button;
|
GtkWidget *hbox, *vbox, *listview, *scrolled, *toolbar, *button;
|
||||||
GtkUnit user_units;
|
GtkUnit user_units;
|
||||||
GListModel *model;
|
GtkSelectionModel *model;
|
||||||
GtkListItemFactory *factory;
|
GtkListItemFactory *factory;
|
||||||
|
|
||||||
content_area = gtk_dialog_get_content_area (cpu_dialog);
|
content_area = gtk_dialog_get_content_area (cpu_dialog);
|
||||||
@ -893,7 +893,7 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
|
|||||||
gtk_box_append (GTK_BOX (vbox), scrolled);
|
gtk_box_append (GTK_BOX (vbox), scrolled);
|
||||||
gtk_widget_show (scrolled);
|
gtk_widget_show (scrolled);
|
||||||
|
|
||||||
model = G_LIST_MODEL (gtk_single_selection_new (g_object_ref (G_LIST_MODEL (dialog->custom_paper_list))));
|
model = GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (G_LIST_MODEL (dialog->custom_paper_list))));
|
||||||
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);
|
||||||
|
|
||||||
factory = gtk_signal_list_item_factory_new ();
|
factory = gtk_signal_list_item_factory_new ();
|
||||||
|
@ -81,9 +81,9 @@ struct _GtkDropDown
|
|||||||
GtkListItemFactory *factory;
|
GtkListItemFactory *factory;
|
||||||
GtkListItemFactory *list_factory;
|
GtkListItemFactory *list_factory;
|
||||||
GListModel *model;
|
GListModel *model;
|
||||||
GListModel *selection;
|
GtkSelectionModel *selection;
|
||||||
GListModel *filter_model;
|
GListModel *filter_model;
|
||||||
GListModel *popup_selection;
|
GtkSelectionModel *popup_selection;
|
||||||
|
|
||||||
GtkWidget *popup;
|
GtkWidget *popup;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
@ -690,19 +690,19 @@ gtk_drop_down_set_model (GtkDropDown *self,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
GListModel *filter_model;
|
GListModel *filter_model;
|
||||||
GListModel *selection;
|
GtkSelectionModel *selection;
|
||||||
|
|
||||||
filter_model = G_LIST_MODEL (gtk_filter_list_model_new (g_object_ref (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);
|
||||||
|
|
||||||
update_filter (self);
|
update_filter (self);
|
||||||
|
|
||||||
selection = G_LIST_MODEL (gtk_single_selection_new (filter_model));
|
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (filter_model));
|
||||||
g_set_object (&self->popup_selection, selection);
|
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), selection);
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
|
|
||||||
selection = G_LIST_MODEL (gtk_single_selection_new (g_object_ref (model)));
|
selection = GTK_SELECTION_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);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
* SECTION:gtkgridview
|
* SECTION:gtkgridview
|
||||||
* @title: GtkGridView
|
* @title: GtkGridView
|
||||||
* @short_description: A widget for displaying grids
|
* @short_description: A widget for displaying grids
|
||||||
* @see_also: #GListModel, #GtkListView, #GtkColumnView
|
* @see_also: #GtkSelectionModel, #GtkListView, #GtkColumnView
|
||||||
*
|
*
|
||||||
* GtkGridView is a widget to present a view into a large dynamic grid of items.
|
* GtkGridView is a widget to present a view into a large dynamic grid of items.
|
||||||
*
|
*
|
||||||
@ -1092,7 +1092,7 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
|
|||||||
g_param_spec_object ("model",
|
g_param_spec_object ("model",
|
||||||
P_("Model"),
|
P_("Model"),
|
||||||
P_("Model for the items displayed"),
|
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);
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1188,11 +1188,11 @@ gtk_grid_view_init (GtkGridView *self)
|
|||||||
* Returns: a new #GtkGridView
|
* Returns: a new #GtkGridView
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gtk_grid_view_new (GListModel *model)
|
gtk_grid_view_new (GtkSelectionModel *model)
|
||||||
{
|
{
|
||||||
GtkWidget *result;
|
GtkWidget *result;
|
||||||
|
|
||||||
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
|
g_return_val_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model), NULL);
|
||||||
|
|
||||||
result = g_object_new (GTK_TYPE_GRID_VIEW,
|
result = g_object_new (GTK_TYPE_GRID_VIEW,
|
||||||
"model", model,
|
"model", model,
|
||||||
@ -1222,11 +1222,12 @@ gtk_grid_view_new (GListModel *model)
|
|||||||
* Returns: a new #GtkGridView using the given @factory
|
* Returns: a new #GtkGridView using the given @factory
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gtk_grid_view_new_with_factory (GListModel *model,
|
gtk_grid_view_new_with_factory (GtkSelectionModel *model,
|
||||||
GtkListItemFactory *factory)
|
GtkListItemFactory *factory)
|
||||||
{
|
{
|
||||||
GtkWidget *result;
|
GtkWidget *result;
|
||||||
|
|
||||||
|
g_return_val_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model), NULL);
|
||||||
g_return_val_if_fail (GTK_IS_LIST_ITEM_FACTORY (factory), NULL);
|
g_return_val_if_fail (GTK_IS_LIST_ITEM_FACTORY (factory), NULL);
|
||||||
|
|
||||||
result = g_object_new (GTK_TYPE_GRID_VIEW,
|
result = g_object_new (GTK_TYPE_GRID_VIEW,
|
||||||
@ -1249,7 +1250,7 @@ gtk_grid_view_new_with_factory (GListModel *model,
|
|||||||
*
|
*
|
||||||
* Returns: (nullable) (transfer none): The model in use
|
* Returns: (nullable) (transfer none): The model in use
|
||||||
**/
|
**/
|
||||||
GListModel *
|
GtkSelectionModel *
|
||||||
gtk_grid_view_get_model (GtkGridView *self)
|
gtk_grid_view_get_model (GtkGridView *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GTK_IS_GRID_VIEW (self), NULL);
|
g_return_val_if_fail (GTK_IS_GRID_VIEW (self), NULL);
|
||||||
@ -1262,14 +1263,14 @@ gtk_grid_view_get_model (GtkGridView *self)
|
|||||||
* @self: a #GtkGridView
|
* @self: a #GtkGridView
|
||||||
* @model: (allow-none) (transfer none): the model to use or %NULL for none
|
* @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
|
void
|
||||||
gtk_grid_view_set_model (GtkGridView *self,
|
gtk_grid_view_set_model (GtkGridView *self,
|
||||||
GListModel *model)
|
GtkSelectionModel *model)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GTK_IS_GRID_VIEW (self));
|
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))
|
if (!gtk_list_base_set_model (GTK_LIST_BASE (self), model))
|
||||||
return;
|
return;
|
||||||
|
@ -48,16 +48,17 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
GType gtk_grid_view_get_type (void) G_GNUC_CONST;
|
GType gtk_grid_view_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkWidget * gtk_grid_view_new (GListModel *model);
|
GtkWidget * gtk_grid_view_new (GtkSelectionModel *model);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkWidget * gtk_grid_view_new_with_factory (GListModel *model,
|
GtkWidget * gtk_grid_view_new_with_factory (GtkSelectionModel *model,
|
||||||
GtkListItemFactory *factory);
|
GtkListItemFactory *factory);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GListModel * gtk_grid_view_get_model (GtkGridView *self);
|
GtkSelectionModel *
|
||||||
|
gtk_grid_view_get_model (GtkGridView *self);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_grid_view_set_model (GtkGridView *self,
|
void gtk_grid_view_set_model (GtkGridView *self,
|
||||||
GListModel *model);
|
GtkSelectionModel *model);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_grid_view_set_factory (GtkGridView *self,
|
void gtk_grid_view_set_factory (GtkGridView *self,
|
||||||
GtkListItemFactory *factory);
|
GtkListItemFactory *factory);
|
||||||
|
@ -56,7 +56,7 @@ typedef struct _GtkListBasePrivate GtkListBasePrivate;
|
|||||||
struct _GtkListBasePrivate
|
struct _GtkListBasePrivate
|
||||||
{
|
{
|
||||||
GtkListItemManager *item_manager;
|
GtkListItemManager *item_manager;
|
||||||
GListModel *model;
|
GtkSelectionModel *model;
|
||||||
GtkOrientation orientation;
|
GtkOrientation orientation;
|
||||||
GtkAdjustment *adjustment[2];
|
GtkAdjustment *adjustment[2];
|
||||||
GtkScrollablePolicy scroll_policy[2];
|
GtkScrollablePolicy scroll_policy[2];
|
||||||
@ -469,7 +469,7 @@ gtk_list_base_get_n_items (GtkListBase *self)
|
|||||||
if (priv->model == NULL)
|
if (priv->model == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return g_list_model_get_n_items (priv->model);
|
return g_list_model_get_n_items (G_LIST_MODEL (priv->model));
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
@ -2102,7 +2102,7 @@ gtk_list_base_grab_focus_on_item (GtkListBase *self,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GListModel *
|
GtkSelectionModel *
|
||||||
gtk_list_base_get_model (GtkListBase *self)
|
gtk_list_base_get_model (GtkListBase *self)
|
||||||
{
|
{
|
||||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||||
@ -2111,8 +2111,8 @@ gtk_list_base_get_model (GtkListBase *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gtk_list_base_set_model (GtkListBase *self,
|
gtk_list_base_set_model (GtkListBase *self,
|
||||||
GListModel *model)
|
GtkSelectionModel *model)
|
||||||
{
|
{
|
||||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||||
|
|
||||||
@ -2123,19 +2123,9 @@ gtk_list_base_set_model (GtkListBase *self,
|
|||||||
|
|
||||||
if (model)
|
if (model)
|
||||||
{
|
{
|
||||||
GtkSelectionModel *selection_model;
|
|
||||||
|
|
||||||
priv->model = g_object_ref (model);
|
priv->model = g_object_ref (model);
|
||||||
|
gtk_list_item_manager_set_model (priv->item_manager, 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 (g_object_ref (model)));
|
|
||||||
|
|
||||||
gtk_list_item_manager_set_model (priv->item_manager, selection_model);
|
|
||||||
gtk_list_base_set_anchor (self, 0, 0.0, GTK_PACK_START, 0.0, GTK_PACK_START);
|
gtk_list_base_set_anchor (self, 0, 0.0, GTK_PACK_START, 0.0, GTK_PACK_START);
|
||||||
|
|
||||||
g_object_unref (selection_model);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gtk/gtkwidget.h>
|
#include <gtk/gtkwidget.h>
|
||||||
|
#include <gtk/gtkselectionmodel.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ GtkListItemManager * gtk_list_base_get_manager (GtkListBase
|
|||||||
GtkScrollablePolicy gtk_list_base_get_scroll_policy (GtkListBase *self,
|
GtkScrollablePolicy gtk_list_base_get_scroll_policy (GtkListBase *self,
|
||||||
GtkOrientation orientation);
|
GtkOrientation orientation);
|
||||||
guint gtk_list_base_get_n_items (GtkListBase *self);
|
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,
|
gboolean gtk_list_base_set_model (GtkListBase *self,
|
||||||
GListModel *model);
|
GtkSelectionModel *model);
|
||||||
void gtk_list_base_update_adjustments (GtkListBase *self,
|
void gtk_list_base_update_adjustments (GtkListBase *self,
|
||||||
int total_across,
|
int total_across,
|
||||||
int total_along,
|
int total_along,
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
* SECTION:gtklistview
|
* SECTION:gtklistview
|
||||||
* @title: GtkListView
|
* @title: GtkListView
|
||||||
* @short_description: A widget for displaying lists
|
* @short_description: A widget for displaying lists
|
||||||
* @see_also: #GListModel, #GtkColumnView, #GtkGridView
|
* @see_also: #GtkSelectionModel, #GtkColumnView, #GtkGridView
|
||||||
*
|
*
|
||||||
* GtkListView is a widget to present a view into a large dynamic list of items.
|
* GtkListView is a widget to present a view into a large dynamic list of items.
|
||||||
*
|
*
|
||||||
@ -839,7 +839,7 @@ gtk_list_view_class_init (GtkListViewClass *klass)
|
|||||||
g_param_spec_object ("model",
|
g_param_spec_object ("model",
|
||||||
P_("Model"),
|
P_("Model"),
|
||||||
P_("Model for the items displayed"),
|
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);
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -943,11 +943,11 @@ gtk_list_view_init (GtkListView *self)
|
|||||||
* Returns: a new #GtkListView
|
* Returns: a new #GtkListView
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gtk_list_view_new (GListModel *model)
|
gtk_list_view_new (GtkSelectionModel *model)
|
||||||
{
|
{
|
||||||
GtkWidget *result;
|
GtkWidget *result;
|
||||||
|
|
||||||
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
|
g_return_val_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model), NULL);
|
||||||
|
|
||||||
result = g_object_new (GTK_TYPE_LIST_VIEW,
|
result = g_object_new (GTK_TYPE_LIST_VIEW,
|
||||||
"model", model,
|
"model", model,
|
||||||
@ -977,12 +977,12 @@ gtk_list_view_new (GListModel *model)
|
|||||||
* Returns: a new #GtkListView using the given @factory
|
* Returns: a new #GtkListView using the given @factory
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gtk_list_view_new_with_factory (GListModel *model,
|
gtk_list_view_new_with_factory (GtkSelectionModel *model,
|
||||||
GtkListItemFactory *factory)
|
GtkListItemFactory *factory)
|
||||||
{
|
{
|
||||||
GtkWidget *result;
|
GtkWidget *result;
|
||||||
|
|
||||||
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
|
g_return_val_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model), NULL);
|
||||||
g_return_val_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory), NULL);
|
g_return_val_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory), NULL);
|
||||||
|
|
||||||
result = g_object_new (GTK_TYPE_LIST_VIEW,
|
result = g_object_new (GTK_TYPE_LIST_VIEW,
|
||||||
@ -1005,7 +1005,7 @@ gtk_list_view_new_with_factory (GListModel *model,
|
|||||||
*
|
*
|
||||||
* Returns: (nullable) (transfer none): The model in use
|
* Returns: (nullable) (transfer none): The model in use
|
||||||
**/
|
**/
|
||||||
GListModel *
|
GtkSelectionModel *
|
||||||
gtk_list_view_get_model (GtkListView *self)
|
gtk_list_view_get_model (GtkListView *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GTK_IS_LIST_VIEW (self), NULL);
|
g_return_val_if_fail (GTK_IS_LIST_VIEW (self), NULL);
|
||||||
@ -1018,17 +1018,14 @@ gtk_list_view_get_model (GtkListView *self)
|
|||||||
* @self: a #GtkListView
|
* @self: a #GtkListView
|
||||||
* @model: (allow-none) (transfer none): the model to use or %NULL for none
|
* @model: (allow-none) (transfer none): the model to use or %NULL for none
|
||||||
*
|
*
|
||||||
* Sets the #GListModel to use.
|
* Sets the #GtkSelectionModel to use.
|
||||||
*
|
|
||||||
* If the @model is a #GtkSelectionModel, it is used for managing the selection.
|
|
||||||
* Otherwise, @self creates a #GtkSingleSelection for the selection.
|
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gtk_list_view_set_model (GtkListView *self,
|
gtk_list_view_set_model (GtkListView *self,
|
||||||
GListModel *model)
|
GtkSelectionModel *model)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GTK_IS_LIST_VIEW (self));
|
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))
|
if (!gtk_list_base_set_model (GTK_LIST_BASE (self), model))
|
||||||
return;
|
return;
|
||||||
|
@ -47,16 +47,17 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
GType gtk_list_view_get_type (void) G_GNUC_CONST;
|
GType gtk_list_view_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkWidget * gtk_list_view_new (GListModel *model);
|
GtkWidget * gtk_list_view_new (GtkSelectionModel *model);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkWidget * gtk_list_view_new_with_factory (GListModel *model,
|
GtkWidget * gtk_list_view_new_with_factory (GtkSelectionModel *model,
|
||||||
GtkListItemFactory *factory);
|
GtkListItemFactory *factory);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GListModel * gtk_list_view_get_model (GtkListView *self);
|
GtkSelectionModel *
|
||||||
|
gtk_list_view_get_model (GtkListView *self);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_list_view_set_model (GtkListView *self,
|
void gtk_list_view_set_model (GtkListView *self,
|
||||||
GListModel *model);
|
GtkSelectionModel *model);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_list_view_set_factory (GtkListView *self,
|
void gtk_list_view_set_factory (GtkListView *self,
|
||||||
GtkListItemFactory *factory);
|
GtkListItemFactory *factory);
|
||||||
|
@ -832,7 +832,7 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
|||||||
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);
|
||||||
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (selection), GTK_INVALID_LIST_POSITION);
|
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);
|
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 (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);
|
||||||
@ -984,7 +984,7 @@ printer_status_cb (GtkPrintBackend *backend,
|
|||||||
*/
|
*/
|
||||||
selected_printer_changed (dialog);
|
selected_printer_changed (dialog);
|
||||||
|
|
||||||
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)));
|
||||||
|
|
||||||
if (gtk_print_backend_printer_list_is_done (backend) &&
|
if (gtk_print_backend_printer_list_is_done (backend) &&
|
||||||
gtk_printer_is_default (printer) &&
|
gtk_printer_is_default (printer) &&
|
||||||
@ -1807,7 +1807,7 @@ printer_details_acquired (GtkPrinter *printer,
|
|||||||
static void
|
static void
|
||||||
selected_printer_changed (GtkPrintUnixDialog *dialog)
|
selected_printer_changed (GtkPrintUnixDialog *dialog)
|
||||||
{
|
{
|
||||||
GListModel *model = gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list));
|
GListModel *model = G_LIST_MODEL (gtk_column_view_get_model (GTK_COLUMN_VIEW (dialog->printer_list)));
|
||||||
GtkPrinter *printer;
|
GtkPrinter *printer;
|
||||||
|
|
||||||
/* Whenever the user selects a printer we stop looking for
|
/* Whenever the user selects a printer we stop looking for
|
||||||
@ -3152,7 +3152,7 @@ set_active_printer (GtkPrintUnixDialog *dialog,
|
|||||||
GtkPrinter *printer;
|
GtkPrinter *printer;
|
||||||
guint i;
|
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++)
|
for (i = 0; i < g_list_model_get_n_items (model); i++)
|
||||||
{
|
{
|
||||||
|
@ -315,7 +315,7 @@ update_attributes (GtkInspectorA11y *sl)
|
|||||||
|
|
||||||
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (store), filter);
|
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (store), filter);
|
||||||
selection = gtk_no_selection_new (G_LIST_MODEL (filter_model));
|
selection = gtk_no_selection_new (G_LIST_MODEL (filter_model));
|
||||||
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->attributes), G_LIST_MODEL (selection));
|
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->attributes), GTK_SELECTION_MODEL (selection));
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
|
|
||||||
if (g_list_model_get_n_items (G_LIST_MODEL (filter_model)) > 0)
|
if (g_list_model_get_n_items (G_LIST_MODEL (filter_model)) > 0)
|
||||||
|
@ -401,7 +401,7 @@ constructed (GObject *object)
|
|||||||
sorted = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (sl->actions)),
|
sorted = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (sl->actions)),
|
||||||
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->list)))));
|
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), GTK_SELECTION_MODEL (model));
|
||||||
g_object_unref (model);
|
g_object_unref (model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ gtk_inspector_list_data_set_object (GtkInspectorListData *sl,
|
|||||||
|
|
||||||
sl->object = G_LIST_MODEL (object);
|
sl->object = G_LIST_MODEL (object);
|
||||||
selection = gtk_no_selection_new (g_object_ref (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, GTK_SELECTION_MODEL (selection));
|
||||||
g_object_unref (selection);
|
g_object_unref (selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1306,5 +1306,5 @@ gtk_inspector_object_tree_set_display (GtkInspectorObjectTree *wt,
|
|||||||
NULL);
|
NULL);
|
||||||
wt->priv->selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (wt->priv->tree_model)));
|
wt->priv->selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (wt->priv->tree_model)));
|
||||||
gtk_column_view_set_model (GTK_COLUMN_VIEW (wt->priv->list),
|
gtk_column_view_set_model (GTK_COLUMN_VIEW (wt->priv->list),
|
||||||
G_LIST_MODEL (wt->priv->selection));
|
GTK_SELECTION_MODEL (wt->priv->selection));
|
||||||
}
|
}
|
||||||
|
@ -626,7 +626,7 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
|
|||||||
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)));
|
||||||
|
|
||||||
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 (list));
|
||||||
gtk_sort_list_model_set_sorter (sorted, gtk_column_view_get_sorter (GTK_COLUMN_VIEW (pl->priv->list)));
|
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_column_view_sort_by_column (GTK_COLUMN_VIEW (pl->priv->list), pl->priv->name, GTK_SORT_ASCENDING);
|
||||||
|
|
||||||
|
@ -1269,7 +1269,7 @@ gtk_inspector_recorder_init (GtkInspectorRecorder *recorder)
|
|||||||
gtk_list_view_set_factory (GTK_LIST_VIEW (recorder->render_node_list), factory);
|
gtk_list_view_set_factory (GTK_LIST_VIEW (recorder->render_node_list), factory);
|
||||||
g_object_unref (factory);
|
g_object_unref (factory);
|
||||||
gtk_list_view_set_model (GTK_LIST_VIEW (recorder->render_node_list),
|
gtk_list_view_set_model (GTK_LIST_VIEW (recorder->render_node_list),
|
||||||
G_LIST_MODEL (recorder->render_node_selection));
|
GTK_SELECTION_MODEL (recorder->render_node_selection));
|
||||||
|
|
||||||
recorder->render_node_properties = GTK_TREE_MODEL (gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_TEXTURE));
|
recorder->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 (recorder->node_property_tree), recorder->render_node_properties);
|
gtk_tree_view_set_model (GTK_TREE_VIEW (recorder->node_property_tree), recorder->render_node_properties);
|
||||||
|
@ -713,7 +713,7 @@ constructed (GObject *object)
|
|||||||
sort_model = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (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);
|
||||||
|
|
||||||
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);
|
g_signal_connect (rl->selection, "selection-changed", G_CALLBACK (on_selection_changed), rl);
|
||||||
}
|
}
|
||||||
|
@ -694,6 +694,7 @@ main (int argc, char *argv[])
|
|||||||
GtkBuilderScope *scope;
|
GtkBuilderScope *scope;
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
GtkSelectionModel *selection;
|
||||||
|
|
||||||
gtk_init ();
|
gtk_init ();
|
||||||
|
|
||||||
@ -759,7 +760,9 @@ main (int argc, char *argv[])
|
|||||||
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);
|
||||||
|
|
||||||
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 ();
|
statusbar = gtk_statusbar_new ();
|
||||||
gtk_widget_add_tick_callback (statusbar, (GtkTickCallback) update_statusbar, NULL, NULL);
|
gtk_widget_add_tick_callback (statusbar, (GtkTickCallback) update_statusbar, NULL, NULL);
|
||||||
@ -771,7 +774,7 @@ main (int argc, char *argv[])
|
|||||||
g_object_unref (filter);
|
g_object_unref (filter);
|
||||||
|
|
||||||
list = gtk_list_view_new_with_factory (
|
list = gtk_list_view_new_with_factory (
|
||||||
g_object_ref (gtk_column_view_get_columns (GTK_COLUMN_VIEW (view))),
|
GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (gtk_column_view_get_columns (GTK_COLUMN_VIEW (view))))),
|
||||||
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))));
|
||||||
gtk_box_append (GTK_BOX (hbox), list);
|
gtk_box_append (GTK_BOX (hbox), list);
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ main (int argc, char *argv[])
|
|||||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_item), NULL);
|
g_signal_connect (factory, "bind", G_CALLBACK (bind_item), NULL);
|
||||||
g_signal_connect (factory, "unbind", G_CALLBACK (unbind_item), NULL);
|
g_signal_connect (factory, "unbind", G_CALLBACK (unbind_item), NULL);
|
||||||
|
|
||||||
grid = gtk_grid_view_new_with_factory (model, factory);
|
grid = gtk_grid_view_new_with_factory (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory);
|
||||||
gtk_grid_view_set_min_columns (GTK_GRID_VIEW (grid), 20);
|
gtk_grid_view_set_min_columns (GTK_GRID_VIEW (grid), 20);
|
||||||
gtk_grid_view_set_max_columns (GTK_GRID_VIEW (grid), 20);
|
gtk_grid_view_set_max_columns (GTK_GRID_VIEW (grid), 20);
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ main (int argc, char *argv[])
|
|||||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||||
gtk_stack_add_titled (GTK_STACK (stack), sw, "list", "GtkListView");
|
gtk_stack_add_titled (GTK_STACK (stack), sw, "list", "GtkListView");
|
||||||
|
|
||||||
list = gtk_list_view_new (create_model (0, 400, 1, FALSE));
|
list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (create_model (0, 400, 1, FALSE))));
|
||||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
|
||||||
|
|
||||||
factory = gtk_signal_list_item_factory_new ();
|
factory = gtk_signal_list_item_factory_new ();
|
||||||
@ -375,7 +375,7 @@ main (int argc, char *argv[])
|
|||||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||||
gtk_stack_add_titled (GTK_STACK (stack), sw, "column", "GtkColumnView");
|
gtk_stack_add_titled (GTK_STACK (stack), sw, "column", "GtkColumnView");
|
||||||
|
|
||||||
cv = gtk_column_view_new (create_model (0, 400, 1, FALSE));
|
cv = gtk_column_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (create_model (0, 400, 1, FALSE))));
|
||||||
|
|
||||||
for (guint i = 0; i < 20; i++)
|
for (guint i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
@ -401,7 +401,7 @@ main (int argc, char *argv[])
|
|||||||
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||||
gtk_stack_add_titled (GTK_STACK (stack), sw, "tree", "Tree");
|
gtk_stack_add_titled (GTK_STACK (stack), sw, "tree", "Tree");
|
||||||
|
|
||||||
list = gtk_list_view_new (create_tree_model (20, 20));
|
list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (create_tree_model (20, 20))));
|
||||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
|
||||||
|
|
||||||
factory = gtk_signal_list_item_factory_new ();
|
factory = gtk_signal_list_item_factory_new ();
|
||||||
|
@ -119,6 +119,7 @@ main (int argc,
|
|||||||
GtkSorter *sorter;
|
GtkSorter *sorter;
|
||||||
guint i;
|
guint i;
|
||||||
GtkListItemFactory *factory;
|
GtkListItemFactory *factory;
|
||||||
|
GtkSelectionModel *selection;
|
||||||
|
|
||||||
gtk_init ();
|
gtk_init ();
|
||||||
|
|
||||||
@ -166,7 +167,9 @@ main (int argc,
|
|||||||
listbox = gtk_list_box_new ();
|
listbox = gtk_list_box_new ();
|
||||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listbox);
|
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),
|
gtk_list_box_bind_model (GTK_LIST_BOX (listbox),
|
||||||
G_LIST_MODEL (sort),
|
G_LIST_MODEL (sort),
|
||||||
create_widget_for_listbox,
|
create_widget_for_listbox,
|
||||||
|
@ -636,7 +636,7 @@ main (int argc, char *argv[])
|
|||||||
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);
|
||||||
|
|
||||||
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 ();
|
statusbar = gtk_statusbar_new ();
|
||||||
gtk_widget_add_tick_callback (statusbar, (GtkTickCallback) update_statusbar, NULL, NULL);
|
gtk_widget_add_tick_callback (statusbar, (GtkTickCallback) update_statusbar, NULL, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user