From e9875ddeb6be2afe8cc60698e26f90fb6c89be46 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 11 Jul 2020 10:43:59 -0400 Subject: [PATCH] sor3listmodel: Add a :sorting boolean This is convenient for quitting a test run when the sorting is done. --- gtk/gtksor3listmodel.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gtk/gtksor3listmodel.c b/gtk/gtksor3listmodel.c index f73f4d76ba..137281fe0c 100644 --- a/gtk/gtksor3listmodel.c +++ b/gtk/gtksor3listmodel.c @@ -93,6 +93,7 @@ enum { PROP_0, PROP_MODEL, PROP_SORTER, + PROP_SORTING, NUM_PROPERTIES }; @@ -190,6 +191,8 @@ gtk_sor3_list_model_stop_sorting (GtkSor3ListModel *self) { g_clear_handle_id (&self->sorting_cb, g_source_remove); pivot_stack_set_size (&self->stack, 0); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTING]); } static inline int @@ -307,6 +310,8 @@ gtk_sor3_list_model_start_sorting (GtkSor3ListModel *self) self->sorting_cb = g_idle_add (gtk_sor3_list_model_sort_cb, self); g_source_set_name_by_id (self->sorting_cb, "[gtk] gtk_sor3_list_model_sort_cb"); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTING]); } static void @@ -376,6 +381,10 @@ gtk_sor3_list_model_get_property (GObject *object, g_value_set_object (value, self->sorter); break; + case PROP_SORTING: + g_value_set_boolean (value, self->sorting_cb != 0); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -470,6 +479,13 @@ gtk_sor3_list_model_class_init (GtkSor3ListModelClass *class) G_TYPE_LIST_MODEL, GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY); + properties[PROP_SORTING] = + g_param_spec_boolean ("sorting", + P_("Sorting"), + P_("Whether sorting is currently underway"), + FALSE, + GTK_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY); + g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties); }