sor3listmodel: Add a :sorting boolean
This is convenient for quitting a test run when the sorting is done.
This commit is contained in:
committed by
Benjamin Otte
parent
99a6c230f3
commit
863c7e1a0a
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user