diff options
author | Benjamin Otte <otte@redhat.com> | 2019-10-07 06:36:25 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2019-10-15 07:17:07 +0200 |
commit | 9f5ee77a44ad08f96d0ffb82ab94bce14e531fad (patch) | |
tree | 126208c0af5dc05520f692c056b7bcfbf5aa7f31 /gtk/gtksingleselection.c | |
parent | 6d20fe0bf9f00e01a5545a26fde3637edd262edc (diff) | |
download | gtk+-9f5ee77a44ad08f96d0ffb82ab94bce14e531fad.tar.gz |
singleselection: Fix model property
1. Make the model property construct-only. Allowing to change the
model has invalid side effects.
2. Add a getter for the model property.
Diffstat (limited to 'gtk/gtksingleselection.c')
-rw-r--r-- | gtk/gtksingleselection.c | 23 |
1 files changed, 19 insertions, 4 deletions
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); } @@ -492,6 +491,22 @@ gtk_single_selection_new (GListModel *model) } /** + * 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 * |