[gnome-builder/wip/libide] libide: add IdeBuffer:busy gproperty
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide] libide: add IdeBuffer:busy gproperty
- Date: Wed, 18 Mar 2015 22:21:51 +0000 (UTC)
commit f23dab1d028f8a7417a854221edabd125970960d
Author: Christian Hergert <christian hergert me>
Date: Wed Mar 18 15:16:40 2015 -0700
libide: add IdeBuffer:busy gproperty
This is useful if you want to know when there is background processing
occuring on the buffer.
libide/ide-buffer.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index 5a0b722..53ca445 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -69,6 +69,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (IdeBuffer, ide_buffer, GTK_SOURCE_TYPE_BUFFER)
enum {
PROP_0,
+ PROP_BUSY,
PROP_CONTEXT,
PROP_FILE,
PROP_HIGHLIGHT_DIAGNOSTICS,
@@ -89,6 +90,16 @@ static void ide_buffer_queue_diagnose (IdeBuffer *self);
static GParamSpec *gParamSpecs [LAST_PROP];
static guint gSignals [LAST_SIGNAL];
+static gboolean
+ide_buffer_get_busy (IdeBuffer *self)
+{
+ IdeBufferPrivate *priv = ide_buffer_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_BUFFER (self), FALSE);
+
+ return priv->in_diagnose;
+}
+
static void
ide_buffer_emit_cursor_moved (IdeBuffer *self)
{
@@ -388,6 +399,7 @@ ide_buffer__diagnostician_diagnose_cb (GObject *object,
g_assert (IDE_IS_BUFFER (self));
priv->in_diagnose = FALSE;
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_BUSY]);
diagnostics = ide_diagnostician_diagnose_finish (diagnostician, result, &error);
@@ -426,6 +438,7 @@ ide_buffer__diagnose_timeout_cb (gpointer user_data)
{
priv->diagnostics_dirty = FALSE;
priv->in_diagnose = TRUE;
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_BUSY]);
ide_buffer_sync_to_unsaved_files (self);
ide_diagnostician_diagnose_async (diagnostician, priv->file, NULL,
@@ -632,6 +645,10 @@ ide_buffer_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_BUSY:
+ g_value_set_boolean (value, ide_buffer_get_busy (self));
+ break;
+
case PROP_CONTEXT:
g_value_set_object (value, ide_buffer_get_context (self));
break;
@@ -705,6 +722,15 @@ ide_buffer_class_init (IdeBufferClass *klass)
text_buffer_class->insert_text = ide_buffer_insert_text;
text_buffer_class->mark_set = ide_buffer_mark_set;
+ gParamSpecs [PROP_BUSY] =
+ g_param_spec_boolean ("busy",
+ _("Busy"),
+ _("If the buffer is performing background work."),
+ FALSE,
+ (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_BUSY,
+ gParamSpecs [PROP_BUSY]);
+
gParamSpecs [PROP_CONTEXT] =
g_param_spec_object ("context",
_("Context"),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]