[gnome-builder/wip/chergert/flatpak-breakout: 3/7] run-manager: propagate error message from async run



commit 3f982b5810f4b467b62723714f5fd0005ec4dde0
Author: Christian Hergert <chergert redhat com>
Date:   Sat Sep 10 09:33:10 2016 -0700

    run-manager: propagate error message from async run
    
    This will allow us to display the error to the user in the future.

 libide/runner/ide-run-manager.c |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/libide/runner/ide-run-manager.c b/libide/runner/ide-run-manager.c
index b02deb0..5af1579 100644
--- a/libide/runner/ide-run-manager.c
+++ b/libide/runner/ide-run-manager.c
@@ -830,6 +830,25 @@ finish:
 }
 
 static void
+ide_run_manager_run_action_cb (GObject      *object,
+                               GAsyncResult *result,
+                               gpointer      user_data)
+{
+  IdeRunManager *self = (IdeRunManager *)object;
+  IdeContext *context;
+  g_autoptr(GError) error = NULL;
+
+  g_assert (IDE_IS_RUN_MANAGER (self));
+  g_assert (G_IS_ASYNC_RESULT (result));
+
+  context = ide_object_get_context (IDE_OBJECT (self));
+
+  /* Propagate the error to the context */
+  if (!ide_run_manager_run_finish (self, result, &error))
+    ide_context_warning (context, "%s", error->message);
+}
+
+static void
 ide_run_manager_activate_action (GActionGroup *group,
                                  const gchar  *action_name,
                                  GVariant     *parameter)
@@ -852,11 +871,19 @@ ide_run_manager_activate_action (GActionGroup *group,
       if (handler && *handler)
         ide_run_manager_set_handler (self, handler);
 
-      ide_run_manager_run_async (self, NULL, NULL, NULL, NULL);
+      ide_run_manager_run_async (self,
+                                 NULL,
+                                 NULL,
+                                 ide_run_manager_run_action_cb,
+                                 NULL);
     }
   else if (g_strcmp0 (action_name, "run") == 0)
     {
-      ide_run_manager_run_async (self, NULL, NULL, NULL, NULL);
+      ide_run_manager_run_async (self,
+                                 NULL,
+                                 NULL,
+                                 ide_run_manager_run_action_cb,
+                                 NULL);
     }
   else if (g_strcmp0 (action_name, "stop") == 0)
     {


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