[gtk/wip/otte/sortlistmodel: 16/33] sor3listmodel: Add a :sorting boolean



commit 863c7e1a0af790779125650bbe408ddee8fc94de
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 11 10:43:59 2020 -0400

    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 716ec2ab15..c1e3425376 100644
--- a/gtk/gtksor3listmodel.c
+++ b/gtk/gtksor3listmodel.c
@@ -82,6 +82,7 @@ enum {
   PROP_0,
   PROP_MODEL,
   PROP_SORTER,
+  PROP_SORTING,
   NUM_PROPERTIES
 };
 
@@ -179,6 +180,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
@@ -296,6 +299,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
@@ -365,6 +370,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;
@@ -459,6 +468,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);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]