[gnome-builder] vcs: avoid out parameters for notifications



commit 9002f7a4dc9c5c73144f18b4d72e4aadccb00aa7
Author: Christian Hergert <chergert redhat com>
Date:   Tue Mar 12 14:47:48 2019 -0700

    vcs: avoid out parameters for notifications

 src/libide/greeter/ide-clone-surface.c | 11 +++++------
 src/libide/vcs/ide-vcs-cloner.c        | 10 ++++------
 src/libide/vcs/ide-vcs-cloner.h        |  4 ++--
 src/plugins/git/gbp-git-vcs-cloner.c   | 15 ++++++++++-----
 4 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/src/libide/greeter/ide-clone-surface.c b/src/libide/greeter/ide-clone-surface.c
index f98b3c69f..9e7bccaa8 100644
--- a/src/libide/greeter/ide-clone-surface.c
+++ b/src/libide/greeter/ide-clone-surface.c
@@ -568,12 +568,14 @@ ide_clone_surface_clone (IdeCloneSurface *self)
                            cancellable,
                            G_CONNECT_SWAPPED);
 
+  notif = ide_notification_new ();
+
   ide_vcs_cloner_clone_async (addin,
                               uri,
                               path,
                               &dict,
+                              notif,
                               cancellable,
-                              &notif,
                               ide_clone_surface_clone_cb,
                               g_object_ref (self));
 
@@ -585,11 +587,8 @@ ide_clone_surface_clone (IdeCloneSurface *self)
   gtk_widget_set_sensitive (GTK_WIDGET (self->branch_entry), FALSE);
   gtk_stack_set_visible_child (self->button_stack, GTK_WIDGET (self->cancel_button));
 
-  if (notif != NULL)
-    {
-      g_object_bind_property (notif, "progress", self->uri_entry, "progress-fraction", 
G_BINDING_SYNC_CREATE);
-      g_object_bind_property (notif, "body", self->status_message, "label", G_BINDING_SYNC_CREATE);
-    }
+  g_object_bind_property (notif, "progress", self->uri_entry, "progress-fraction", G_BINDING_SYNC_CREATE);
+  g_object_bind_property (notif, "body", self->status_message, "label", G_BINDING_SYNC_CREATE);
 
   g_variant_dict_clear (&dict);
 }
diff --git a/src/libide/vcs/ide-vcs-cloner.c b/src/libide/vcs/ide-vcs-cloner.c
index b1c798e89..cdd16519e 100644
--- a/src/libide/vcs/ide-vcs-cloner.c
+++ b/src/libide/vcs/ide-vcs-cloner.c
@@ -69,7 +69,7 @@ ide_vcs_cloner_validate_uri (IdeVcsCloner  *self,
  * @destination: a string containing the destination path
  * @options: a #GVariantDict containing any user supplied options
  * @cancellable: (nullable): a #GCancellable
- * @progress: (out) (optional): a location for an #IdeNotification, or %NULL
+ * @progress: (nullable): a location for an #IdeNotification, or %NULL
  * @callback: a #GAsyncReadyCallback to execute upon completion
  * @user_data: closure data for @callback
  *
@@ -80,25 +80,23 @@ ide_vcs_cloner_clone_async (IdeVcsCloner         *self,
                             const gchar          *uri,
                             const gchar          *destination,
                             GVariantDict         *options,
+                            IdeNotification      *progress,
                             GCancellable         *cancellable,
-                            IdeNotification     **progress,
                             GAsyncReadyCallback   callback,
                             gpointer              user_data)
 {
   g_return_if_fail (IDE_IS_VCS_CLONER (self));
   g_return_if_fail (uri != NULL);
   g_return_if_fail (destination != NULL);
+  g_return_if_fail (!progress || IDE_IS_NOTIFICATION (progress));
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
 
-  if (progress != NULL)
-    *progress = NULL;
-
   IDE_VCS_CLONER_GET_IFACE (self)->clone_async (self,
                                                 uri,
                                                 destination,
                                                 options,
-                                                cancellable,
                                                 progress,
+                                                cancellable,
                                                 callback,
                                                 user_data);
 }
diff --git a/src/libide/vcs/ide-vcs-cloner.h b/src/libide/vcs/ide-vcs-cloner.h
index 2f400fdd9..3a9dc5499 100644
--- a/src/libide/vcs/ide-vcs-cloner.h
+++ b/src/libide/vcs/ide-vcs-cloner.h
@@ -41,8 +41,8 @@ struct _IdeVcsClonerInterface
                              const gchar          *uri,
                              const gchar          *destination,
                              GVariantDict         *options,
+                             IdeNotification      *progress,
                              GCancellable         *cancellable,
-                             IdeNotification     **progress,
                              GAsyncReadyCallback   callback,
                              gpointer              user_data);
   gboolean  (*clone_finish) (IdeVcsCloner         *self,
@@ -57,8 +57,8 @@ void      ide_vcs_cloner_clone_async  (IdeVcsCloner         *self,
                                        const gchar          *uri,
                                        const gchar          *destination,
                                        GVariantDict         *options,
+                                       IdeNotification      *progress,
                                        GCancellable         *cancellable,
-                                       IdeNotification     **progress,
                                        GAsyncReadyCallback   callback,
                                        gpointer              user_data);
 IDE_AVAILABLE_IN_3_32
diff --git a/src/plugins/git/gbp-git-vcs-cloner.c b/src/plugins/git/gbp-git-vcs-cloner.c
index 6c381c7b8..0a03b7b4c 100644
--- a/src/plugins/git/gbp-git-vcs-cloner.c
+++ b/src/plugins/git/gbp-git-vcs-cloner.c
@@ -227,8 +227,8 @@ gbp_git_vcs_cloner_clone_async (IdeVcsCloner        *cloner,
                                 const gchar         *uri,
                                 const gchar         *destination,
                                 GVariantDict        *options,
+                                IdeNotification     *notif,
                                 GCancellable        *cancellable,
-                                IdeNotification    **notif,
                                 GAsyncReadyCallback  callback,
                                 gpointer             user_data)
 {
@@ -244,14 +244,17 @@ gbp_git_vcs_cloner_clone_async (IdeVcsCloner        *cloner,
   g_assert (GBP_IS_GIT_VCS_CLONER (cloner));
   g_assert (uri != NULL);
   g_assert (destination != NULL);
+  g_assert (!notif || IDE_IS_NOTIFICATION (notif));
   g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
 
   task = ide_task_new (self, cancellable, callback, user_data);
   ide_task_set_source_tag (task, gbp_git_vcs_cloner_clone_async);
 
-  notif_local = ide_notification_new ();
-  if (notif != NULL)
-    *notif = g_object_ref (notif_local);
+  if (notif == NULL)
+    {
+      notif_local = ide_notification_new ();
+      notif = notif_local;
+    }
 
   if (!g_variant_dict_lookup (options, "branch", "&s", &branch))
     branch = "master";
@@ -286,7 +289,9 @@ gbp_git_vcs_cloner_clone_async (IdeVcsCloner        *cloner,
         ide_vcs_uri_set_user (vcs_uri, g_get_user_name ());
     }
 
-  req = clone_request_new (vcs_uri, branch, location, notif_local);
+  g_assert (IDE_IS_NOTIFICATION (notif));
+
+  req = clone_request_new (vcs_uri, branch, location, notif);
 
   g_variant_dict_lookup (options, "author-name", "s", &req->author_name);
   g_variant_dict_lookup (options, "author-email", "s", &req->author_email);


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