diff options
author | Lars Uebernickel <lars@uebernic.de> | 2015-02-15 15:57:24 +0100 |
---|---|---|
committer | Lars Uebernickel <lars@uebernic.de> | 2015-02-16 15:36:28 +0100 |
commit | 8f5002696fc9aecfbddd087c96c5e4aa06fa04d8 (patch) | |
tree | deac185f9389f8e4ffab13c184279ced94a27449 | |
parent | 0a9c33d1b5396bc0874e08246cbcdd59309573ee (diff) | |
download | gnome-logs-8f5002696fc9aecfbddd087c96c5e4aa06fa04d8.tar.gz |
Mark application as busy while loading entries
Add a property "loading" to GlJournalModel which is TRUE while it's
fetching entries and use g_application_bind_busy_property() with it.
https://bugzilla.gnome.org/show_bug.cgi?id=744567
-rw-r--r-- | src/gl-eventviewlist.c | 1 | ||||
-rw-r--r-- | src/gl-journal-model.c | 44 | ||||
-rw-r--r-- | src/gl-journal-model.h | 2 |
3 files changed, 47 insertions, 0 deletions
diff --git a/src/gl-eventviewlist.c b/src/gl-eventviewlist.c index 40ddb4c..53b6b78 100644 --- a/src/gl-eventviewlist.c +++ b/src/gl-eventviewlist.c @@ -592,6 +592,7 @@ gl_event_view_list_init (GlEventViewList *view) categories = GL_CATEGORY_LIST (priv->categories); priv->journal_model = gl_journal_model_new (); + g_application_bind_busy_property (g_application_get_default (), priv->journal_model, "loading"); gtk_list_box_bind_model (GTK_LIST_BOX (priv->entries_box), G_LIST_MODEL (priv->journal_model), diff --git a/src/gl-journal-model.c b/src/gl-journal-model.c index dec5f05..bebaa07 100644 --- a/src/gl-journal-model.c +++ b/src/gl-journal-model.c @@ -21,6 +21,7 @@ enum { PROP_0, PROP_MATCHES, + PROP_LOADING, N_PROPERTIES }; @@ -46,6 +47,7 @@ gl_journal_model_fetch_entries (gpointer user_data) else { model->idle_source = 0; + g_object_notify_by_pspec (G_OBJECT (model), properties[PROP_LOADING]); return G_SOURCE_REMOVE; } } @@ -63,6 +65,25 @@ gl_journal_model_init (GlJournalModel *model) } static void +gl_journal_model_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GlJournalModel *model = GL_JOURNAL_MODEL (object); + + switch (property_id) + { + case PROP_LOADING: + g_value_set_boolean (value, gl_journal_model_get_loading (model)); + break; + + default: + g_assert_not_reached (); + } +} + +static void gl_journal_model_set_property (GObject *object, guint property_id, const GValue *value, @@ -88,6 +109,7 @@ gl_journal_model_stop_idle (GlJournalModel *model) { g_source_remove (model->idle_source); model->idle_source = 0; + g_object_notify_by_pspec (G_OBJECT (model), properties[PROP_LOADING]); } } @@ -142,11 +164,15 @@ gl_journal_model_class_init (GlJournalModelClass *class) GParamFlags default_flags = G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY; object_class->dispose = gl_journal_model_dispose; + object_class->get_property = gl_journal_model_get_property; object_class->set_property = gl_journal_model_set_property; properties[PROP_MATCHES] = g_param_spec_boxed ("matches", "", "", G_TYPE_STRV, G_PARAM_WRITABLE | default_flags); + properties[PROP_LOADING] = g_param_spec_boolean ("loading", "", "", TRUE, + G_PARAM_READABLE | default_flags); + g_object_class_install_properties (object_class, N_PROPERTIES, properties); } @@ -189,4 +215,22 @@ gl_journal_model_set_matches (GlJournalModel *model, gl_journal_set_matches (model->journal, matches); model->idle_source = g_idle_add_full (G_PRIORITY_LOW, gl_journal_model_fetch_entries, model, NULL); + g_object_notify_by_pspec (G_OBJECT (model), properties[PROP_LOADING]); +} + +/** + * gl_journal_model_get_loading: + * @model: a #GlJournalModel + * + * Returns %TRUE if @model is currently loading entries from the + * journal. That means that @model will grow in the near future. + * + * Returns: %TRUE if the model is loading entries from the journal + */ +gboolean +gl_journal_model_get_loading (GlJournalModel *model) +{ + g_return_val_if_fail (GL_IS_JOURNAL_MODEL (model), FALSE); + + return model->idle_source > 0; } diff --git a/src/gl-journal-model.h b/src/gl-journal-model.h index 18b9bb8..dbe8c5d 100644 --- a/src/gl-journal-model.h +++ b/src/gl-journal-model.h @@ -12,4 +12,6 @@ GlJournalModel * gl_journal_model_new (void); void gl_journal_model_set_matches (GlJournalModel *model, const gchar * const *matches); +gboolean gl_journal_model_get_loading (GlJournalModel *model); + #endif |