[gnome-builder] pipeline: add helper to check if pipeline can export



commit 2c9532019a363f48181abf58386af55ac8462b95
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jul 22 23:16:27 2017 -0700

    pipeline: add helper to check if pipeline can export
    
    This just checks if there are export stages attached to the pipeline and
    if so returns True. This is useful to know if we can advance to the export
    phase and expect something to happen in the UI.

 libide/buildsystem/ide-build-pipeline.c |   27 +++++++++++++++++++++++++++
 libide/buildsystem/ide-build-pipeline.h |    1 +
 2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/libide/buildsystem/ide-build-pipeline.c b/libide/buildsystem/ide-build-pipeline.c
index 1d0afae..38086b0 100644
--- a/libide/buildsystem/ide-build-pipeline.c
+++ b/libide/buildsystem/ide-build-pipeline.c
@@ -2714,3 +2714,30 @@ ide_build_pipeline_rebuild_finish (IdeBuildPipeline  *self,
 
   IDE_RETURN (ret);
 }
+
+/**
+ * ide_build_pipeline_get_can_export:
+ * @self: a #IdeBuildPipeline
+ *
+ * This function is useful to discover if there are any pipeline addins
+ * which implement the export phase. UI or GAction implementations may
+ * want to use this value to set the enabled state of the action or
+ * sensitivity of a button.
+ *
+ * Returns: %TRUE if there are export pipeline stages.
+ */
+gboolean
+ide_build_pipeline_get_can_export (IdeBuildPipeline *self)
+{
+  g_return_val_if_fail (IDE_IS_BUILD_PIPELINE (self), FALSE);
+
+  for (guint i = 0; i < self->pipeline->len; i++)
+    {
+      const PipelineEntry *entry = &g_array_index (self->pipeline, PipelineEntry, i);
+
+      if ((entry->phase & IDE_BUILD_PHASE_EXPORT) != 0)
+        return TRUE;
+    }
+
+  return FALSE;
+}
diff --git a/libide/buildsystem/ide-build-pipeline.h b/libide/buildsystem/ide-build-pipeline.h
index 5b4b851..81e4a26 100644
--- a/libide/buildsystem/ide-build-pipeline.h
+++ b/libide/buildsystem/ide-build-pipeline.h
@@ -60,6 +60,7 @@ const gchar           *ide_build_pipeline_get_builddir        (IdeBuildPipeline
 const gchar           *ide_build_pipeline_get_srcdir          (IdeBuildPipeline       *self);
 gchar                 *ide_build_pipeline_get_message         (IdeBuildPipeline       *self);
 IdeBuildPhase          ide_build_pipeline_get_phase           (IdeBuildPipeline       *self);
+gboolean               ide_build_pipeline_get_can_export      (IdeBuildPipeline       *self);
 IdeSubprocessLauncher *ide_build_pipeline_create_launcher     (IdeBuildPipeline       *self,
                                                                GError                **error);
 gchar                 *ide_build_pipeline_build_srcdir_path   (IdeBuildPipeline       *self,


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