diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 71bb48caf5..65693b1587 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -471,6 +471,7 @@ gtk_selection_model_get_type GtkSingleSelection GTK_INVALID_LIST_POSITION gtk_single_selection_new +gtk_single_selection_get_model gtk_single_selection_get_selected gtk_single_selection_set_selected gtk_single_selection_get_selected_item diff --git a/gtk/gtksingleselection.c b/gtk/gtksingleselection.c index 5f9517fbed..f2d0d47f1c 100644 --- a/gtk/gtksingleselection.c +++ b/gtk/gtksingleselection.c @@ -329,9 +329,8 @@ gtk_single_selection_set_property (GObject *object, case PROP_MODEL: gtk_single_selection_clear_model (self); self->model = g_value_dup_object (value); - if (self->model) - g_signal_connect (self->model, "items-changed", - G_CALLBACK (gtk_single_selection_items_changed_cb), self); + g_signal_connect (self->model, "items-changed", + G_CALLBACK (gtk_single_selection_items_changed_cb), self); if (self->autoselect) gtk_single_selection_set_selected (self, 0); break; @@ -461,7 +460,7 @@ gtk_single_selection_class_init (GtkSingleSelectionClass *klass) P_("The model"), P_("The model being managed"), G_TYPE_LIST_MODEL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_properties (gobject_class, N_PROPS, properties); } @@ -491,6 +490,22 @@ gtk_single_selection_new (GListModel *model) NULL); } +/** + * gtk_single_selection_get_model: + * @self: a #GtkSingleSelection + * + * Gets the model that @self is wrapping. + * + * Returns: (transfer none): The model being wrapped + **/ +GListModel * +gtk_single_selection_get_model (GtkSingleSelection *self) +{ + g_return_val_if_fail (GTK_IS_SINGLE_SELECTION (self), NULL); + + return self->model; +} + /** * gtk_single_selection_get_selected: * @self: a #GtkSingleSelection diff --git a/gtk/gtksingleselection.h b/gtk/gtksingleselection.h index ca96a4e052..74107fcc06 100644 --- a/gtk/gtksingleselection.h +++ b/gtk/gtksingleselection.h @@ -42,8 +42,10 @@ GDK_AVAILABLE_IN_ALL G_DECLARE_FINAL_TYPE (GtkSingleSelection, gtk_single_selection, GTK, SINGLE_SELECTION, GObject) GDK_AVAILABLE_IN_ALL -GtkSingleSelection * gtk_single_selection_new (GListModel *model); +GtkSingleSelection * gtk_single_selection_new (GListModel *model); +GDK_AVAILABLE_IN_ALL +GListModel * gtk_single_selection_get_model (GtkSingleSelection *self); GDK_AVAILABLE_IN_ALL guint gtk_single_selection_get_selected (GtkSingleSelection *self); GDK_AVAILABLE_IN_ALL diff --git a/testsuite/gtk/defaultvalue.c b/testsuite/gtk/defaultvalue.c index 1ac3bdfe97..556adb9693 100644 --- a/testsuite/gtk/defaultvalue.c +++ b/testsuite/gtk/defaultvalue.c @@ -109,7 +109,8 @@ test_type (gconstpointer data) instance = G_OBJECT (g_object_ref (gdk_surface_new_temp (display, &(GdkRectangle) { 0, 0, 100, 100 }))); } - else if (g_type_is_a (type, GTK_TYPE_FILTER_LIST_MODEL)) + else if (g_type_is_a (type, GTK_TYPE_FILTER_LIST_MODEL) || + g_type_is_a (type, GTK_TYPE_SINGLE_SELECTION)) { GListStore *list_store = g_list_store_new (G_TYPE_OBJECT); instance = g_object_new (type, @@ -255,7 +256,8 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS - if (g_type_is_a (type, GTK_TYPE_FILTER_LIST_MODEL) && + if ((g_type_is_a (type, GTK_TYPE_FILTER_LIST_MODEL) || + g_type_is_a (type, GTK_TYPE_SINGLE_SELECTION)) && strcmp (pspec->name, "model") == 0) continue; diff --git a/testsuite/gtk/notify.c b/testsuite/gtk/notify.c index 99b8f82ae8..83a04b0776 100644 --- a/testsuite/gtk/notify.c +++ b/testsuite/gtk/notify.c @@ -431,7 +431,8 @@ test_type (gconstpointer data) NULL); gdk_content_formats_unref (formats); } - else if (g_type_is_a (type, GTK_TYPE_FILTER_LIST_MODEL)) + else if (g_type_is_a (type, GTK_TYPE_FILTER_LIST_MODEL) || + g_type_is_a (type, GTK_TYPE_SINGLE_SELECTION)) { GListStore *list_store = g_list_store_new (G_TYPE_OBJECT); instance = g_object_new (type, diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c index bb7e51371d..722067c118 100644 --- a/testsuite/gtk/objects-finalize.c +++ b/testsuite/gtk/objects-finalize.c @@ -64,7 +64,8 @@ test_finalize_object (gconstpointer data) NULL); gdk_content_formats_unref (formats); } - else if (g_type_is_a (test_type, GTK_TYPE_FILTER_LIST_MODEL)) + else if (g_type_is_a (test_type, GTK_TYPE_FILTER_LIST_MODEL) || + g_type_is_a (test_type, GTK_TYPE_SINGLE_SELECTION)) { GListStore *list_store = g_list_store_new (G_TYPE_OBJECT); object = g_object_new (test_type,