[gnome-builder/wip/gtk4-port: 1240/1774] libide/vcs: add API to list branches from a cloner
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1240/1774] libide/vcs: add API to list branches from a cloner
- Date: Mon, 11 Jul 2022 22:31:39 +0000 (UTC)
commit 81adeaeebd21678af7472b082db58c7918d9174e
Author: Christian Hergert <chergert redhat com>
Date: Tue May 31 16:01:03 2022 -0700
libide/vcs: add API to list branches from a cloner
This is helpful for cases where we want to list available branches for the
user to select the target branch.
src/libide/vcs/ide-vcs-cloner.c | 41 ++++++++++++++++++
src/libide/vcs/ide-vcs-cloner.h | 92 +++++++++++++++++++++++++----------------
2 files changed, 97 insertions(+), 36 deletions(-)
---
diff --git a/src/libide/vcs/ide-vcs-cloner.c b/src/libide/vcs/ide-vcs-cloner.c
index 3acb4a45f..10e9fe776 100644
--- a/src/libide/vcs/ide-vcs-cloner.c
+++ b/src/libide/vcs/ide-vcs-cloner.c
@@ -304,3 +304,44 @@ ide_vcs_cloner_clone_simple (IdeContext *context,
return TRUE;
}
+void
+ide_vcs_cloner_list_branches_async (IdeVcsCloner *self,
+ IdeVcsUri *uri,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ IDE_ENTRY;
+
+ g_return_if_fail (IDE_IS_VCS_CLONER (self));
+ g_return_if_fail (uri != NULL);
+ g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ IDE_VCS_CLONER_GET_IFACE (self)->list_branches_async (self, uri, cancellable, callback, user_data);
+
+ IDE_EXIT;
+}
+
+/**
+ * ide_vcs_cloner_list_branches_finish:
+ *
+ * Returns: (transfer full): a #GListModel of #IdeVcsBranch
+ */
+GListModel *
+ide_vcs_cloner_list_branches_finish (IdeVcsCloner *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ GListModel *ret;
+
+ IDE_ENTRY;
+
+ g_return_val_if_fail (IDE_IS_VCS_CLONER (self), NULL);
+ g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
+
+ ret = IDE_VCS_CLONER_GET_IFACE (self)->list_branches_finish (self, result, error);
+
+ g_return_val_if_fail (!ret || G_IS_LIST_MODEL (ret), NULL);
+
+ IDE_RETURN (ret);
+}
diff --git a/src/libide/vcs/ide-vcs-cloner.h b/src/libide/vcs/ide-vcs-cloner.h
index c535842d4..c70a790a3 100644
--- a/src/libide/vcs/ide-vcs-cloner.h
+++ b/src/libide/vcs/ide-vcs-cloner.h
@@ -22,6 +22,8 @@
#include <libide-core.h>
+#include "ide-vcs-uri.h"
+
G_BEGIN_DECLS
#define IDE_TYPE_VCS_CLONER (ide_vcs_cloner_get_type())
@@ -33,50 +35,68 @@ struct _IdeVcsClonerInterface
{
GTypeInterface parent_iface;
- gchar *(*get_title) (IdeVcsCloner *self);
- gboolean (*validate_uri) (IdeVcsCloner *self,
- const gchar *uri,
- gchar **errmsg);
- void (*clone_async) (IdeVcsCloner *self,
- const gchar *uri,
- const gchar *destination,
- GVariant *options,
- IdeNotification *progress,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*clone_finish) (IdeVcsCloner *self,
- GAsyncResult *result,
- GError **error);
-};
-
-IDE_AVAILABLE_IN_ALL
-gchar *ide_vcs_cloner_get_title (IdeVcsCloner *self);
-IDE_AVAILABLE_IN_ALL
-void ide_vcs_cloner_clone_async (IdeVcsCloner *self,
- const gchar *uri,
- const gchar *destination,
+ char *(*get_title) (IdeVcsCloner *self);
+ gboolean (*validate_uri) (IdeVcsCloner *self,
+ const char *uri,
+ char **errmsg);
+ void (*clone_async) (IdeVcsCloner *self,
+ const char *uri,
+ const char *destination,
GVariant *options,
IdeNotification *progress,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
-IDE_AVAILABLE_IN_ALL
-gboolean ide_vcs_cloner_clone_finish (IdeVcsCloner *self,
+ gboolean (*clone_finish) (IdeVcsCloner *self,
GAsyncResult *result,
GError **error);
-IDE_AVAILABLE_IN_ALL
-gboolean ide_vcs_cloner_validate_uri (IdeVcsCloner *self,
- const gchar *uri,
- gchar **errmsg);
-IDE_AVAILABLE_IN_ALL
-gboolean ide_vcs_cloner_clone_simple (IdeContext *context,
- const gchar *module_name,
- const gchar *url,
- const gchar *branch,
- const gchar *destination,
- IdeNotification *notif,
+ void (*list_branches_async) (IdeVcsCloner *self,
+ IdeVcsUri *uri,
GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ GListModel *(*list_branches_finish) (IdeVcsCloner *self,
+ GAsyncResult *result,
GError **error);
+};
+
+IDE_AVAILABLE_IN_ALL
+char *ide_vcs_cloner_get_title (IdeVcsCloner *self);
+IDE_AVAILABLE_IN_ALL
+void ide_vcs_cloner_clone_async (IdeVcsCloner *self,
+ const char *uri,
+ const char *destination,
+ GVariant *options,
+ IdeNotification *progress,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_vcs_cloner_clone_finish (IdeVcsCloner *self,
+ GAsyncResult *result,
+ GError **error);
+IDE_AVAILABLE_IN_ALL
+void ide_vcs_cloner_list_branches_async (IdeVcsCloner *self,
+ IdeVcsUri *uri,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+IDE_AVAILABLE_IN_ALL
+GListModel *ide_vcs_cloner_list_branches_finish (IdeVcsCloner *self,
+ GAsyncResult *result,
+ GError **error);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_vcs_cloner_validate_uri (IdeVcsCloner *self,
+ const char *uri,
+ char **errmsg);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_vcs_cloner_clone_simple (IdeContext *context,
+ const char *module_name,
+ const char *url,
+ const char *branch,
+ const char *destination,
+ IdeNotification *notif,
+ GCancellable *cancellable,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]