[gnome-builder/gnome-builder-3-24] buildmanager: add IdeBuildManager:can-build



commit a459f5b86f49501fdf6f6ae77d91a33a25935068
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 6 16:26:11 2017 -0700

    buildmanager: add IdeBuildManager:can-build
    
    This property can be used to connect sensitivity of UI based on whether
    or not the application can have a build submitted.

 libide/buildsystem/ide-build-manager.c |   41 ++++++++++++++++++++++++++++++++
 libide/buildsystem/ide-build-manager.h |    1 +
 2 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/libide/buildsystem/ide-build-manager.c b/libide/buildsystem/ide-build-manager.c
index b5692d0..7c2472e 100644
--- a/libide/buildsystem/ide-build-manager.c
+++ b/libide/buildsystem/ide-build-manager.c
@@ -46,6 +46,8 @@ struct _IdeBuildManager
   guint             diagnostic_count;
 
   guint             timer_source;
+
+  guint             can_build : 1;
 };
 
 static void initable_iface_init     (GInitableIface *);
@@ -58,6 +60,7 @@ G_DEFINE_TYPE_EXTENDED (IdeBuildManager, ide_build_manager, IDE_TYPE_OBJECT, 0,
 enum {
   PROP_0,
   PROP_BUSY,
+  PROP_CAN_BUILD,
   PROP_HAS_DIAGNOSTICS,
   PROP_LAST_BUILD_TIME,
   PROP_MESSAGE,
@@ -258,6 +261,12 @@ ide_build_manager_ensure_runtime_cb (GObject      *object,
       IDE_GOTO (failure);
     }
 
+  if (pipeline != self->pipeline)
+    {
+      IDE_TRACE_MSG ("pipeline is no longer active, ignoring");
+      IDE_GOTO (failure);
+    }
+
   /* This will cause plugins to load on the pipeline. */
   if (!g_initable_init (G_INITABLE (pipeline), NULL, &error))
     {
@@ -265,6 +274,9 @@ ide_build_manager_ensure_runtime_cb (GObject      *object,
       IDE_GOTO (failure);
     }
 
+  self->can_build = TRUE;
+
+  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CAN_BUILD]);
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PIPELINE]);
 
   IDE_EXIT;
@@ -329,6 +341,7 @@ ide_build_manager_invalidate_pipeline (IdeBuildManager *self)
    * We will delay the initialization until after the we have ensured the
    * runtime is available (possibly installing it).
    */
+  self->can_build = FALSE;
   self->pipeline = g_object_new (IDE_TYPE_BUILD_PIPELINE,
                                  "context", context,
                                  "configuration", config,
@@ -353,6 +366,7 @@ ide_build_manager_invalidate_pipeline (IdeBuildManager *self)
                                     ide_build_manager_ensure_runtime_cb,
                                     g_steal_pointer (&task));
 
+  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CAN_BUILD]);
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_HAS_DIAGNOSTICS]);
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_LAST_BUILD_TIME]);
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_MESSAGE]);
@@ -457,6 +471,10 @@ ide_build_manager_get_property (GObject    *object,
       g_value_set_boolean (value, ide_build_manager_get_busy (self));
       break;
 
+    case PROP_CAN_BUILD:
+      g_value_set_boolean (value, ide_build_manager_get_can_build (self));
+      break;
+
     case PROP_MESSAGE:
       g_value_take_string (value, ide_build_manager_get_message (self));
       break;
@@ -491,6 +509,21 @@ ide_build_manager_class_init (IdeBuildManagerClass *klass)
   object_class->get_property = ide_build_manager_get_property;
 
   /**
+   * IdeBuildManager:can-build:
+   *
+   * Gets if the build manager can queue a build request.
+   *
+   * This might be false if the required runtime is not available or other
+   * errors in setting up the build pipeline.
+   */
+  properties [PROP_CAN_BUILD] =
+    g_param_spec_boolean ("can-build",
+                          "Can Build",
+                          "If the manager can queue a build",
+                          FALSE,
+                          (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+  /**
    * IdeBuildManager:busy:
    *
    * The "busy" property indicates if there is currently a build
@@ -1356,3 +1389,11 @@ ide_build_manager_rebuild_finish (IdeBuildManager  *self,
 
   IDE_RETURN (ret);
 }
+
+gboolean
+ide_build_manager_get_can_build (IdeBuildManager *self)
+{
+  g_return_val_if_fail (IDE_IS_BUILD_MANAGER (self), FALSE);
+
+  return self->can_build;
+}
diff --git a/libide/buildsystem/ide-build-manager.h b/libide/buildsystem/ide-build-manager.h
index 5cfc2ff..79994e5 100644
--- a/libide/buildsystem/ide-build-manager.h
+++ b/libide/buildsystem/ide-build-manager.h
@@ -32,6 +32,7 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (IdeBuildManager, ide_build_manager, IDE, BUILD_MANAGER, IdeObject)
 
 gboolean          ide_build_manager_get_busy            (IdeBuildManager       *self);
+gboolean          ide_build_manager_get_can_build       (IdeBuildManager       *self);
 gchar            *ide_build_manager_get_message         (IdeBuildManager       *self);
 GDateTime        *ide_build_manager_get_last_build_time (IdeBuildManager       *self);
 GTimeSpan         ide_build_manager_get_running_time    (IdeBuildManager       *self);


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