[gnome-builder] genesis: add apply_uri vfunc
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] genesis: add apply_uri vfunc
- Date: Fri, 10 Nov 2017 08:30:18 +0000 (UTC)
commit 161803d85e0e1aa55b9118fb2d42d214a34b862c
Author: Christian Hergert <chergert redhat com>
Date: Fri Nov 10 00:13:17 2017 -0800
genesis: add apply_uri vfunc
This allows us to request that a genesis addin focus the URI
in it's clone widget. This really only activates the git plugin
currently, but theoretically, others could do it.
src/libide/genesis/ide-genesis-addin.c | 24 ++++++++++++++++++++++++
src/libide/genesis/ide-genesis-addin.h | 7 +++++++
src/plugins/git/ide-git-clone-widget.c | 13 +++++++++++++
src/plugins/git/ide-git-clone-widget.h | 4 ++++
src/plugins/git/ide-git-genesis-addin.c | 15 +++++++++++++++
5 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/src/libide/genesis/ide-genesis-addin.c b/src/libide/genesis/ide-genesis-addin.c
index c7370e9..024d67d 100644
--- a/src/libide/genesis/ide-genesis-addin.c
+++ b/src/libide/genesis/ide-genesis-addin.c
@@ -114,3 +114,27 @@ ide_genesis_addin_get_next_label (IdeGenesisAddin *self)
return NULL;
}
+
+/**
+ * ide_genesis_addin_apply_uri:
+ * @self: an #IdeGenesisAddin
+ * @uri: an #IdeVcsUri
+ *
+ * If the #IdeGenesisAddin knows how to handle @uri, it should update it's
+ * UI to reflect the uri and return %TRUE. If so, ide_genesis_addin_run_async()
+ * will be called afterwards to begin a clone.
+ *
+ * Returns: %TRUE if @uri was handled; otherwise %FALSE.
+ */
+gboolean
+ide_genesis_addin_apply_uri (IdeGenesisAddin *self,
+ IdeVcsUri *uri)
+{
+ g_return_val_if_fail (IDE_IS_GENESIS_ADDIN (self), FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
+
+ if (IDE_GENESIS_ADDIN_GET_IFACE (self)->apply_uri)
+ return IDE_GENESIS_ADDIN_GET_IFACE (self)->apply_uri (self, uri);
+
+ return FALSE;
+}
diff --git a/src/libide/genesis/ide-genesis-addin.h b/src/libide/genesis/ide-genesis-addin.h
index 5c84f06..cc0a0d1 100644
--- a/src/libide/genesis/ide-genesis-addin.h
+++ b/src/libide/genesis/ide-genesis-addin.h
@@ -22,6 +22,8 @@
#include "ide-version-macros.h"
+#include "vcs/ide-vcs-uri.h"
+
G_BEGIN_DECLS
#define IDE_TYPE_GENESIS_ADDIN (ide_genesis_addin_get_type())
@@ -45,8 +47,13 @@ struct _IdeGenesisAddinInterface
gchar *(*get_label) (IdeGenesisAddin *self);
gchar *(*get_next_label) (IdeGenesisAddin *self);
gint (*get_priority) (IdeGenesisAddin *self);
+ gboolean (*apply_uri) (IdeGenesisAddin *self,
+ IdeVcsUri *uri);
};
+IDE_AVAILABLE_IN_3_28
+gboolean ide_genesis_addin_apply_uri (IdeGenesisAddin *self,
+ IdeVcsUri *uri);
IDE_AVAILABLE_IN_ALL
gchar *ide_genesis_addin_get_label (IdeGenesisAddin *self);
IDE_AVAILABLE_IN_ALL
diff --git a/src/plugins/git/ide-git-clone-widget.c b/src/plugins/git/ide-git-clone-widget.c
index 68a191e..d1ed9db 100644
--- a/src/plugins/git/ide-git-clone-widget.c
+++ b/src/plugins/git/ide-git-clone-widget.c
@@ -489,3 +489,16 @@ ide_git_clone_widget_clone_finish (IdeGitCloneWidget *self,
return ret;
}
+
+void
+ide_git_clone_widget_set_uri (IdeGitCloneWidget *self,
+ IdeVcsUri *uri)
+{
+ g_autofree gchar *str = NULL;
+
+ g_return_if_fail (IDE_IS_GIT_CLONE_WIDGET (self));
+ g_return_if_fail (uri != NULL);
+
+ str = ide_vcs_uri_to_string (uri);
+ gtk_entry_set_text (self->clone_uri_entry, str);
+}
diff --git a/src/plugins/git/ide-git-clone-widget.h b/src/plugins/git/ide-git-clone-widget.h
index 0cbd94e..712fba8 100644
--- a/src/plugins/git/ide-git-clone-widget.h
+++ b/src/plugins/git/ide-git-clone-widget.h
@@ -20,12 +20,16 @@
#include <gtk/gtk.h>
+#include "vcs/ide-vcs-uri.h"
+
G_BEGIN_DECLS
#define IDE_TYPE_GIT_CLONE_WIDGET (ide_git_clone_widget_get_type())
G_DECLARE_FINAL_TYPE (IdeGitCloneWidget, ide_git_clone_widget, IDE, GIT_CLONE_WIDGET, GtkBin)
+void ide_git_clone_widget_set_uri (IdeGitCloneWidget *self,
+ IdeVcsUri *uri);
void ide_git_clone_widget_clone_async (IdeGitCloneWidget *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
diff --git a/src/plugins/git/ide-git-genesis-addin.c b/src/plugins/git/ide-git-genesis-addin.c
index 216c6bb..5a356d5 100644
--- a/src/plugins/git/ide-git-genesis-addin.c
+++ b/src/plugins/git/ide-git-genesis-addin.c
@@ -190,6 +190,20 @@ ide_git_genesis_addin_get_next_label (IdeGenesisAddin *addin)
return g_strdup (_("Clone"));
}
+static gboolean
+ide_git_genesis_addin_apply_uri (IdeGenesisAddin *addin,
+ IdeVcsUri *uri)
+{
+ IdeGitGenesisAddin *self = (IdeGitGenesisAddin *)addin;
+
+ g_assert (IDE_IS_GIT_GENESIS_ADDIN (self));
+ g_assert (uri != NULL);
+
+ ide_git_clone_widget_set_uri (self->clone_widget, uri);
+
+ return TRUE;
+}
+
static void
genesis_addin_iface_init (IdeGenesisAddinInterface *iface)
{
@@ -201,4 +215,5 @@ genesis_addin_iface_init (IdeGenesisAddinInterface *iface)
iface->get_priority = ide_git_genesis_addin_get_priority;
iface->get_label = ide_git_genesis_addin_get_label;
iface->get_next_label = ide_git_genesis_addin_get_next_label;
+ iface->apply_uri = ide_git_genesis_addin_apply_uri;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]