[gnome-builder/gnome-builder-3-24] buildmanager: disable actions when can-build is FALSE



commit 8c84a951cb258ea4c826c0948b70b47a8778d06f
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 6 16:31:38 2017 -0700

    buildmanager: disable actions when can-build is FALSE
    
    If we cannot build the project, we should propagate that setting to the
    various IdeBuildManager GActions exported to the UI.

 libide/buildsystem/ide-build-manager.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/libide/buildsystem/ide-build-manager.c b/libide/buildsystem/ide-build-manager.c
index 7c2472e..b6034d0 100644
--- a/libide/buildsystem/ide-build-manager.c
+++ b/libide/buildsystem/ide-build-manager.c
@@ -80,15 +80,16 @@ static GParamSpec *properties [N_PROPS];
 static guint signals [N_SIGNALS];
 
 static void
-ide_build_manager_propagate_busy (IdeBuildManager *self)
+ide_build_manager_propagate_action_enabled (IdeBuildManager *self)
 {
   gboolean busy = ide_build_manager_get_busy (self);
+  gboolean can_build = ide_build_manager_get_can_build (self);
 
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_BUSY]);
   g_action_group_action_enabled_changed (G_ACTION_GROUP (self), "cancel", busy);
-  g_action_group_action_enabled_changed (G_ACTION_GROUP (self), "build", !busy);
-  g_action_group_action_enabled_changed (G_ACTION_GROUP (self), "rebuild", !busy);
-  g_action_group_action_enabled_changed (G_ACTION_GROUP (self), "clean", !busy);
+  g_action_group_action_enabled_changed (G_ACTION_GROUP (self), "build", !busy && can_build);
+  g_action_group_action_enabled_changed (G_ACTION_GROUP (self), "rebuild", !busy && can_build);
+  g_action_group_action_enabled_changed (G_ACTION_GROUP (self), "clean", !busy && can_build);
 }
 
 static gboolean
@@ -174,7 +175,7 @@ ide_build_manager_notify_busy (IdeBuildManager  *self,
   g_assert (G_IS_PARAM_SPEC (pspec));
   g_assert (IDE_IS_BUILD_PIPELINE (pipeline));
 
-  ide_build_manager_propagate_busy (self);
+  ide_build_manager_propagate_action_enabled (self);
 
   IDE_EXIT;
 }
@@ -288,6 +289,8 @@ failure:
       egg_signal_group_set_target (self->pipeline_signals, NULL);
     }
 
+  ide_build_manager_propagate_action_enabled (self);
+
   IDE_EXIT;
 }
 
@@ -372,7 +375,7 @@ ide_build_manager_invalidate_pipeline (IdeBuildManager *self)
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_MESSAGE]);
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_RUNNING_TIME]);
 
-  ide_build_manager_propagate_busy (self);
+  ide_build_manager_propagate_action_enabled (self);
 
   IDE_EXIT;
 }
@@ -974,7 +977,7 @@ ide_build_manager_execute_cb (GObject      *object,
   g_task_return_boolean (task, TRUE);
 
 failure:
-  ide_build_manager_propagate_busy (self);
+  ide_build_manager_propagate_action_enabled (self);
 
   IDE_EXIT;
 }
@@ -1016,7 +1019,7 @@ ide_build_manager_save_all_cb (GObject      *object,
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_LAST_BUILD_TIME]);
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_RUNNING_TIME]);
 
-  ide_build_manager_propagate_busy (self);
+  ide_build_manager_propagate_action_enabled (self);
 
   IDE_EXIT;
 }
@@ -1114,7 +1117,7 @@ ide_build_manager_execute_async (IdeBuildManager     *self,
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_LAST_BUILD_TIME]);
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_RUNNING_TIME]);
 
-  ide_build_manager_propagate_busy (self);
+  ide_build_manager_propagate_action_enabled (self);
 
   IDE_EXIT;
 }
@@ -1174,7 +1177,7 @@ ide_build_manager_clean_cb (GObject      *object,
   g_task_return_boolean (task, TRUE);
 
 failure:
-  ide_build_manager_propagate_busy (self);
+  ide_build_manager_propagate_action_enabled (self);
 }
 
 void
@@ -1219,7 +1222,7 @@ ide_build_manager_clean_async (IdeBuildManager     *self,
 
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_HAS_DIAGNOSTICS]);
 
-  ide_build_manager_propagate_busy (self);
+  ide_build_manager_propagate_action_enabled (self);
 
   IDE_EXIT;
 }


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