[gnome-builder] runtime: Add a postinstall_async vfunc to IdeRuntime



commit 703f8ff89135c91952947d652a46340469cd5f67
Author: Matthew Leeds <mleeds redhat com>
Date:   Thu Sep 1 22:49:20 2016 -0500

    runtime: Add a postinstall_async vfunc to IdeRuntime
    
    Runtimes may need to do something when an install finishes (for example
    the flatpak runtime will run "flatpak install..."), so this
    commit adds a virtual function for that.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772898

 libide/runtimes/ide-runtime.c |   50 +++++++++++++++++++++++++++++++++++++++++
 libide/runtimes/ide-runtime.h |   16 +++++++++++-
 2 files changed, 64 insertions(+), 2 deletions(-)
---
diff --git a/libide/runtimes/ide-runtime.c b/libide/runtimes/ide-runtime.c
index bf64e6c..f8f6afa 100644
--- a/libide/runtimes/ide-runtime.c
+++ b/libide/runtimes/ide-runtime.c
@@ -95,6 +95,32 @@ ide_runtime_real_postbuild_finish (IdeRuntime    *self,
   return g_task_propagate_boolean (G_TASK (result), error);
 }
 
+static void
+ide_runtime_real_postinstall_async (IdeRuntime          *self,
+                                    GCancellable        *cancellable,
+                                    GAsyncReadyCallback  callback,
+                                    gpointer             user_data)
+{
+  g_autoptr(GTask) task = NULL;
+
+  g_assert (IDE_IS_RUNTIME (self));
+  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  task = g_task_new (self, cancellable, callback, user_data);
+  g_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+ide_runtime_real_postinstall_finish (IdeRuntime    *self,
+                                     GAsyncResult  *result,
+                                     GError       **error)
+{
+  g_assert (IDE_IS_RUNTIME (self));
+  g_assert (G_IS_TASK (result));
+
+  return g_task_propagate_boolean (G_TASK (result), error);
+}
+
 static IdeSubprocessLauncher *
 ide_runtime_real_create_launcher (IdeRuntime  *self,
                                   GError     **error)
@@ -312,6 +338,8 @@ ide_runtime_class_init (IdeRuntimeClass *klass)
   klass->prebuild_finish = ide_runtime_real_prebuild_finish;
   klass->postbuild_async = ide_runtime_real_postbuild_async;
   klass->postbuild_finish = ide_runtime_real_postbuild_finish;
+  klass->postinstall_async = ide_runtime_real_postinstall_async;
+  klass->postinstall_finish = ide_runtime_real_postinstall_finish;
   klass->create_launcher = ide_runtime_real_create_launcher;
   klass->create_runner = ide_runtime_real_create_runner;
   klass->contains_program_in_path = ide_runtime_real_contains_program_in_path;
@@ -453,6 +481,28 @@ ide_runtime_postbuild_finish (IdeRuntime    *self,
   return IDE_RUNTIME_GET_CLASS (self)->postbuild_finish (self, result, error);
 }
 
+void
+ide_runtime_postinstall_async (IdeRuntime          *self,
+                               GCancellable        *cancellable,
+                               GAsyncReadyCallback  callback,
+                               gpointer             user_data)
+{
+  g_return_if_fail (IDE_IS_RUNTIME (self));
+  g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  IDE_RUNTIME_GET_CLASS (self)->postinstall_async (self, cancellable, callback, user_data);
+}
+
+gboolean
+ide_runtime_postinstall_finish (IdeRuntime    *self,
+                                GAsyncResult  *result,
+                                GError       **error)
+{
+  g_return_val_if_fail (IDE_IS_RUNTIME (self), FALSE);
+
+  return IDE_RUNTIME_GET_CLASS (self)->postinstall_finish (self, result, error);
+}
+
 /**
  * ide_runtime_create_launcher:
  *
diff --git a/libide/runtimes/ide-runtime.h b/libide/runtimes/ide-runtime.h
index 28f3931..d802619 100644
--- a/libide/runtimes/ide-runtime.h
+++ b/libide/runtimes/ide-runtime.h
@@ -66,9 +66,14 @@ struct _IdeRuntimeClass
                                                       IdeConfiguration     *configuration);
   IdeRunner             *(*create_runner)            (IdeRuntime           *self,
                                                       IdeBuildTarget       *build_target);
+  void                   (*postinstall_async)        (IdeRuntime           *self,
+                                                      GCancellable         *cancellable,
+                                                      GAsyncReadyCallback   callback,
+                                                      gpointer              user_data);
+  gboolean               (*postinstall_finish)       (IdeRuntime           *self,
+                                                      GAsyncResult         *result,
+                                                      GError              **error);
 
-  gpointer _reserved1;
-  gpointer _reserved2;
   gpointer _reserved3;
   gpointer _reserved4;
   gpointer _reserved5;
@@ -100,6 +105,13 @@ void                   ide_runtime_postbuild_async          (IdeRuntime
 gboolean               ide_runtime_postbuild_finish         (IdeRuntime           *self,
                                                              GAsyncResult         *result,
                                                              GError              **error);
+void                   ide_runtime_postinstall_async        (IdeRuntime           *self,
+                                                             GCancellable         *cancellable,
+                                                             GAsyncReadyCallback   callback,
+                                                             gpointer              user_data);
+gboolean               ide_runtime_postinstall_finish       (IdeRuntime           *self,
+                                                             GAsyncResult         *result,
+                                                             GError              **error);
 gboolean               ide_runtime_contains_program_in_path (IdeRuntime           *self,
                                                              const gchar          *program,
                                                              GCancellable         *cancellable);


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