[gnome-builder/wip/chergert/perspective] libide: move git support into embedded plugin
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/perspective] libide: move git support into embedded plugin
- Date: Sat, 28 Nov 2015 09:17:16 +0000 (UTC)
commit 09f6e967091385e7dd9e521fd84d03f28ab0c3a6
Author: Christian Hergert <chergert redhat com>
Date: Sat Nov 28 01:16:48 2015 -0800
libide: move git support into embedded plugin
libide/Makefile.am | 6 +-
libide/{directory => fallback}/ide-directory-vcs.c | 30 +++++---
libide/{directory => fallback}/ide-directory-vcs.h | 3 +-
libide/fallback/ide-fallback-plugin.c | 4 +
libide/git/git.plugin | 9 +++
.../ide-directory-vcs.h => git/ide-git-plugin.c} | 23 +++----
libide/git/ide-git-vcs.c | 19 +++--
libide/git/ide-git-vcs.h | 4 +-
libide/ide-application-plugins.c | 13 +++-
libide/ide-vcs.c | 75 ++++++++++++++-----
libide/ide-vcs.h | 11 ++--
libide/ide.c | 12 ---
libide/ide.h | 1 -
libide/resources/libide.gresource.xml | 4 +
14 files changed, 135 insertions(+), 79 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index d5b2ddb..6419cfd 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -7,8 +7,6 @@ pkglibdir = $(libdir)/gnome-builder
pkglib_LTLIBRARIES = libide-1.0.la
libide_1_0_la_public_sources = \
- directory/ide-directory-vcs.c \
- directory/ide-directory-vcs.h \
doap/ide-doap-person.c \
doap/ide-doap-person.h \
doap/ide-doap.c \
@@ -21,6 +19,8 @@ libide_1_0_la_public_sources = \
editor/ide-editor-view.h \
fallback/ide-directory-build-system.c \
fallback/ide-directory-build-system.h \
+ fallback/ide-directory-vcs.c \
+ fallback/ide-directory-vcs.h \
fallback/ide-fallback-plugin.c \
git/ide-git-remote-callbacks.c \
git/ide-git-remote-callbacks.h \
@@ -264,6 +264,7 @@ libide_1_0_la_SOURCES = \
gconstructor.h \
git/ide-git-buffer-change-monitor.c \
git/ide-git-buffer-change-monitor.h \
+ git/ide-git-plugin.c \
greeter/ide-greeter-perspective.c \
greeter/ide-greeter-perspective.h \
greeter/ide-greeter-project-row.c \
@@ -399,7 +400,6 @@ libide_1_0_la_includes = \
-I$(top_srcdir)/contrib/xml \
-I$(top_srcdir)/data/icons/hicolor \
-I$(srcdir) \
- -I$(srcdir)/directory \
-I$(srcdir)/doap \
-I$(srcdir)/editor \
-I$(srcdir)/editorconfig \
diff --git a/libide/directory/ide-directory-vcs.c b/libide/fallback/ide-directory-vcs.c
similarity index 90%
rename from libide/directory/ide-directory-vcs.c
rename to libide/fallback/ide-directory-vcs.c
index ea50434..c38a074 100644
--- a/libide/directory/ide-directory-vcs.c
+++ b/libide/fallback/ide-directory-vcs.c
@@ -24,18 +24,18 @@
struct _IdeDirectoryVcs
{
- IdeVcs parent_instance;
-
- GFile *working_directory;
+ IdeObject parent_instances;
+ GFile *working_directory;
};
#define LOAD_MAX_FILES 5000
static void async_initable_iface_init (GAsyncInitableIface *iface);
+static void vcs_iface_init (IdeVcsInterface *iface);
-G_DEFINE_TYPE_EXTENDED (IdeDirectoryVcs, ide_directory_vcs, IDE_TYPE_VCS, 0,
- G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE,
- async_initable_iface_init))
+G_DEFINE_TYPE_EXTENDED (IdeDirectoryVcs, ide_directory_vcs, IDE_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_VCS, vcs_iface_init)
+ G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, async_initable_iface_init))
static GFile *
ide_directory_vcs_get_working_directory (IdeVcs *vcs)
@@ -93,12 +93,8 @@ ide_directory_vcs_dispose (GObject *object)
static void
ide_directory_vcs_class_init (IdeDirectoryVcsClass *klass)
{
- IdeVcsClass *vcs_class = IDE_VCS_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- vcs_class->get_working_directory = ide_directory_vcs_get_working_directory;
- vcs_class->is_ignored = ide_directory_vcs_is_ignored;
-
object_class->dispose = ide_directory_vcs_dispose;
}
@@ -187,3 +183,17 @@ async_initable_iface_init (GAsyncInitableIface *iface)
iface->init_async = ide_directory_vcs_init_async;
iface->init_finish = ide_directory_vcs_init_finish;
}
+
+static gint
+ide_directory_vcs_get_priority (IdeVcs *vcs)
+{
+ return G_MAXINT;
+}
+
+static void
+vcs_iface_init (IdeVcsInterface *iface)
+{
+ iface->get_working_directory = ide_directory_vcs_get_working_directory;
+ iface->is_ignored = ide_directory_vcs_is_ignored;
+ iface->get_priority = ide_directory_vcs_get_priority;
+}
diff --git a/libide/directory/ide-directory-vcs.h b/libide/fallback/ide-directory-vcs.h
similarity index 89%
copy from libide/directory/ide-directory-vcs.h
copy to libide/fallback/ide-directory-vcs.h
index e0a6e78..d3d49c5 100644
--- a/libide/directory/ide-directory-vcs.h
+++ b/libide/fallback/ide-directory-vcs.h
@@ -25,8 +25,7 @@ G_BEGIN_DECLS
#define IDE_TYPE_DIRECTORY_VCS (ide_directory_vcs_get_type())
-G_DECLARE_FINAL_TYPE (IdeDirectoryVcs, ide_directory_vcs,
- IDE, DIRECTORY_VCS, IdeVcs)
+G_DECLARE_FINAL_TYPE (IdeDirectoryVcs, ide_directory_vcs, IDE, DIRECTORY_VCS, IdeObject)
G_END_DECLS
diff --git a/libide/fallback/ide-fallback-plugin.c b/libide/fallback/ide-fallback-plugin.c
index 44ce574..84485f6 100644
--- a/libide/fallback/ide-fallback-plugin.c
+++ b/libide/fallback/ide-fallback-plugin.c
@@ -20,6 +20,7 @@
#include "ide-build-system.h"
#include "ide-directory-build-system.h"
+#include "ide-directory-vcs.h"
void
ide_fallback_register_types (PeasObjectModule *module)
@@ -27,4 +28,7 @@ ide_fallback_register_types (PeasObjectModule *module)
peas_object_module_register_extension_type (module,
IDE_TYPE_BUILD_SYSTEM,
IDE_TYPE_DIRECTORY_BUILD_SYSTEM);
+ peas_object_module_register_extension_type (module,
+ IDE_TYPE_VCS,
+ IDE_TYPE_DIRECTORY_VCS);
}
diff --git a/libide/git/git.plugin b/libide/git/git.plugin
new file mode 100644
index 0000000..9885bbd
--- /dev/null
+++ b/libide/git/git.plugin
@@ -0,0 +1,9 @@
+[Plugin]
+Module=git-plugin
+Name=Git
+Description=Provides support for the Git version control system
+Authors=Christian Hergert <christian hergert me>
+Copyright=Copyright © 2015 Christian Hergert
+Builtin=true
+Hidden=true
+Embedded=ide_git_register_types
diff --git a/libide/directory/ide-directory-vcs.h b/libide/git/ide-git-plugin.c
similarity index 64%
rename from libide/directory/ide-directory-vcs.h
rename to libide/git/ide-git-plugin.c
index e0a6e78..45b89fc 100644
--- a/libide/directory/ide-directory-vcs.h
+++ b/libide/git/ide-git-plugin.c
@@ -1,6 +1,6 @@
-/* ide-directory-vcs.h
+/* ide-git-plugin.c
*
- * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ * Copyright (C) 2015 Christian Hergert <chergert redhat com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,18 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef IDE_DIRECTORY_VCS_H
-#define IDE_DIRECTORY_VCS_H
+#include <libpeas/peas.h>
+#include "ide-git-vcs.h"
#include "ide-vcs.h"
-G_BEGIN_DECLS
-
-#define IDE_TYPE_DIRECTORY_VCS (ide_directory_vcs_get_type())
-
-G_DECLARE_FINAL_TYPE (IdeDirectoryVcs, ide_directory_vcs,
- IDE, DIRECTORY_VCS, IdeVcs)
-
-G_END_DECLS
-
-#endif /* IDE_DIRECTORY_VCS_H */
+void
+ide_git_register_types (PeasObjectModule *module)
+{
+ peas_object_module_register_extension_type (module, IDE_TYPE_VCS, IDE_TYPE_GIT_VCS);
+}
diff --git a/libide/git/ide-git-vcs.c b/libide/git/ide-git-vcs.c
index 54f526c..afc44a8 100644
--- a/libide/git/ide-git-vcs.c
+++ b/libide/git/ide-git-vcs.c
@@ -35,7 +35,7 @@
struct _IdeGitVcs
{
- IdeVcs parent_instance;
+ IdeObject parent_instance;
GgitRepository *repository;
GgitRepository *change_monitor_repository;
@@ -50,6 +50,7 @@ struct _IdeGitVcs
};
static void g_async_initable_init_interface (GAsyncInitableIface *iface);
+static void ide_git_vcs_init_iface (IdeVcsInterface *iface);
static void ide_git_vcs_reload_async (IdeGitVcs *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -58,7 +59,8 @@ static gboolean ide_git_vcs_reload_finish (IdeGitVcs *self,
GAsyncResult *result,
GError **error);
-G_DEFINE_TYPE_EXTENDED (IdeGitVcs, ide_git_vcs, IDE_TYPE_VCS, 0,
+G_DEFINE_TYPE_EXTENDED (IdeGitVcs, ide_git_vcs, IDE_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE (IDE_TYPE_VCS, ide_git_vcs_init_iface)
G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE,
g_async_initable_init_interface))
@@ -361,18 +363,21 @@ ide_git_vcs_get_property (GObject *object,
}
static void
+ide_git_vcs_init_iface (IdeVcsInterface *iface)
+{
+ iface->get_working_directory = ide_git_vcs_get_working_directory;
+ iface->get_buffer_change_monitor = ide_git_vcs_get_buffer_change_monitor;
+ iface->is_ignored = ide_git_vcs_is_ignored;
+}
+
+static void
ide_git_vcs_class_init (IdeGitVcsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- IdeVcsClass *vcs_class = IDE_VCS_CLASS (klass);
object_class->dispose = ide_git_vcs_dispose;
object_class->get_property = ide_git_vcs_get_property;
- vcs_class->get_working_directory = ide_git_vcs_get_working_directory;
- vcs_class->get_buffer_change_monitor = ide_git_vcs_get_buffer_change_monitor;
- vcs_class->is_ignored = ide_git_vcs_is_ignored;
-
/**
* IdeGitVcs:repository:
*
diff --git a/libide/git/ide-git-vcs.h b/libide/git/ide-git-vcs.h
index 24c4683..ee66f6d 100644
--- a/libide/git/ide-git-vcs.h
+++ b/libide/git/ide-git-vcs.h
@@ -27,9 +27,9 @@ G_BEGIN_DECLS
#define IDE_TYPE_GIT_VCS (ide_git_vcs_get_type())
-G_DECLARE_FINAL_TYPE (IdeGitVcs, ide_git_vcs, IDE, GIT_VCS, IdeVcs)
+G_DECLARE_FINAL_TYPE (IdeGitVcs, ide_git_vcs, IDE, GIT_VCS, IdeObject)
-GgitRepository *ide_git_vcs_get_repository (IdeGitVcs *vcs);
+GgitRepository *ide_git_vcs_get_repository (IdeGitVcs *self);
G_END_DECLS
diff --git a/libide/ide-application-plugins.c b/libide/ide-application-plugins.c
index 2aba22f..bd223b2 100644
--- a/libide/ide-application-plugins.c
+++ b/libide/ide-application-plugins.c
@@ -56,7 +56,9 @@ void
ide_application_discover_plugins (IdeApplication *self)
{
PeasEngine *engine = peas_engine_get_default ();
+ static const gchar *embedded [] = { "editor", "fallback", "git", NULL };
const GList *list;
+ gint i;
g_return_if_fail (IDE_IS_APPLICATION (self));
@@ -93,9 +95,14 @@ ide_application_discover_plugins (IdeApplication *self)
PACKAGE_DATADIR"/gnome-builder/plugins");
}
- peas_engine_prepend_search_path (engine,
- "resource:///org/gnome/builder/plugins/editor",
- "resource:///org/gnome/builder/plugins/editor");
+ for (i = 0; embedded [i]; i++)
+ {
+ gchar *path;
+
+ path = g_strdup_printf ("resource:///org/gnome/builder/plugins/%s", embedded [i]);
+ peas_engine_prepend_search_path (engine, path, path);
+ g_free (path);
+ }
peas_engine_rescan_plugins (engine);
diff --git a/libide/ide-vcs.c b/libide/ide-vcs.c
index 0648c69..f13d34a 100644
--- a/libide/ide-vcs.c
+++ b/libide/ide-vcs.c
@@ -18,18 +18,20 @@
#include "ide-buffer.h"
#include "ide-buffer-change-monitor.h"
+#include "ide-context.h"
#include "ide-vcs.h"
-G_DEFINE_ABSTRACT_TYPE (IdeVcs, ide_vcs, IDE_TYPE_OBJECT)
+G_DEFINE_INTERFACE (IdeVcs, ide_vcs, IDE_TYPE_OBJECT)
static void
-ide_vcs_class_init (IdeVcsClass *klass)
-{
-}
-
-static void
-ide_vcs_init (IdeVcs *self)
+ide_vcs_default_init (IdeVcsInterface *iface)
{
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("context",
+ "Context",
+ "Context",
+ IDE_TYPE_CONTEXT,
+ (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)));
}
gboolean
@@ -39,12 +41,25 @@ ide_vcs_is_ignored (IdeVcs *self,
{
g_return_val_if_fail (IDE_IS_VCS (self), FALSE);
- if (IDE_VCS_GET_CLASS (self)->is_ignored)
- return IDE_VCS_GET_CLASS (self)->is_ignored (self, file, error);
+ if (IDE_VCS_GET_IFACE (self)->is_ignored)
+ return IDE_VCS_GET_IFACE (self)->is_ignored (self, file, error);
return FALSE;
}
+gint
+ide_vcs_get_priority (IdeVcs *self)
+{
+ gint ret = 0;
+
+ g_return_val_if_fail (IDE_IS_VCS (self), 0);
+
+ if (IDE_VCS_GET_IFACE (self)->get_priority)
+ ret = IDE_VCS_GET_IFACE (self)->get_priority (self);
+
+ return ret;
+}
+
/**
* ide_vcs_get_working_directory:
* @self: An #IdeVcs.
@@ -59,8 +74,8 @@ ide_vcs_get_working_directory (IdeVcs *self)
{
g_return_val_if_fail (IDE_IS_VCS (self), NULL);
- if (IDE_VCS_GET_CLASS (self)->get_working_directory)
- return IDE_VCS_GET_CLASS (self)->get_working_directory (self);
+ if (IDE_VCS_GET_IFACE (self)->get_working_directory)
+ return IDE_VCS_GET_IFACE (self)->get_working_directory (self);
return NULL;
}
@@ -82,14 +97,25 @@ ide_vcs_get_buffer_change_monitor (IdeVcs *self,
g_return_val_if_fail (IDE_IS_VCS (self), NULL);
g_return_val_if_fail (IDE_IS_BUFFER (buffer), NULL);
- if (IDE_VCS_GET_CLASS (self)->get_buffer_change_monitor)
- ret = IDE_VCS_GET_CLASS (self)->get_buffer_change_monitor (self, buffer);
+ if (IDE_VCS_GET_IFACE (self)->get_buffer_change_monitor)
+ ret = IDE_VCS_GET_IFACE (self)->get_buffer_change_monitor (self, buffer);
g_return_val_if_fail (!ret || IDE_IS_BUFFER_CHANGE_MONITOR (ret), NULL);
return ret;
}
+static gint
+sort_by_priority (gconstpointer a,
+ gconstpointer b,
+ gpointer user_data)
+{
+ IdeVcs *vcs_a = (IdeVcs *)a;
+ IdeVcs *vcs_b = (IdeVcs *)b;
+
+ return ide_vcs_get_priority (vcs_a) - ide_vcs_get_priority (vcs_b);
+}
+
void
ide_vcs_new_async (IdeContext *context,
int io_priority,
@@ -97,15 +123,24 @@ ide_vcs_new_async (IdeContext *context,
GAsyncReadyCallback callback,
gpointer user_data)
{
- ide_object_new_async (IDE_VCS_EXTENSION_POINT,
- io_priority,
- cancellable,
- callback,
- user_data,
- "context", context,
- NULL);
+ ide_object_new_for_extension_async (IDE_TYPE_VCS,
+ sort_by_priority,
+ NULL,
+ io_priority,
+ cancellable,
+ callback,
+ user_data,
+ "context", context,
+ NULL);
}
+/**
+ * ide_vcs_new_finish:
+ *
+ * Completes a call to ide_vcs_new_async().
+ *
+ * Returns: (transfer full): An #IdeVcs.
+ */
IdeVcs *
ide_vcs_new_finish (GAsyncResult *result,
GError **error)
diff --git a/libide/ide-vcs.h b/libide/ide-vcs.h
index 48f0181..edca435 100644
--- a/libide/ide-vcs.h
+++ b/libide/ide-vcs.h
@@ -25,14 +25,13 @@
G_BEGIN_DECLS
-#define IDE_TYPE_VCS (ide_vcs_get_type())
-#define IDE_VCS_EXTENSION_POINT "org.gnome.libide.extensions.vcs"
+#define IDE_TYPE_VCS (ide_vcs_get_type())
-G_DECLARE_DERIVABLE_TYPE (IdeVcs, ide_vcs, IDE, VCS, IdeObject)
+G_DECLARE_INTERFACE (IdeVcs, ide_vcs, IDE, VCS, IdeObject)
-struct _IdeVcsClass
+struct _IdeVcsInterface
{
- IdeObjectClass parent;
+ GTypeInterface parent_interface;
GFile *(*get_working_directory) (IdeVcs *self);
IdeBufferChangeMonitor *(*get_buffer_change_monitor) (IdeVcs *self,
@@ -40,6 +39,7 @@ struct _IdeVcsClass
gboolean (*is_ignored) (IdeVcs *self,
GFile *file,
GError **error);
+ gint (*get_priority) (IdeVcs *self);
};
IdeBufferChangeMonitor *ide_vcs_get_buffer_change_monitor (IdeVcs *self,
@@ -55,6 +55,7 @@ IdeVcs *ide_vcs_new_finish (GAsyncResult
gboolean ide_vcs_is_ignored (IdeVcs *self,
GFile *file,
GError **error);
+gint ide_vcs_get_priority (IdeVcs *self);
G_END_DECLS
diff --git a/libide/ide.c b/libide/ide.c
index eb84919..ba9d2b8 100644
--- a/libide/ide.c
+++ b/libide/ide.c
@@ -23,10 +23,8 @@
#include "gconstructor.h"
#include "ide.h"
-#include "ide-directory-vcs.h"
#include "ide-editorconfig-file-settings.h"
#include "ide-file-settings.h"
-#include "ide-git-vcs.h"
#include "ide-gsettings-file-settings.h"
#include "ide-modelines-file-settings.h"
@@ -74,7 +72,6 @@ ide_init_ctor (void)
{
g_io_extension_point_register (IDE_FILE_SETTINGS_EXTENSION_POINT);
g_io_extension_point_register (IDE_SCRIPT_EXTENSION_POINT);
- g_io_extension_point_register (IDE_VCS_EXTENSION_POINT);
g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT,
IDE_TYPE_MODELINES_FILE_SETTINGS,
@@ -102,13 +99,4 @@ ide_init_ctor (void)
IDE_SCRIPT_EXTENSION_POINT".py",
-100);
#endif
-
- g_io_extension_point_implement (IDE_VCS_EXTENSION_POINT,
- IDE_TYPE_GIT_VCS,
- IDE_VCS_EXTENSION_POINT".git",
- -100);
- g_io_extension_point_implement (IDE_VCS_EXTENSION_POINT,
- IDE_TYPE_DIRECTORY_VCS,
- IDE_VCS_EXTENSION_POINT".directory",
- -200);
}
diff --git a/libide/ide.h b/libide/ide.h
index f592fc6..5bbfa31 100644
--- a/libide/ide.h
+++ b/libide/ide.h
@@ -115,7 +115,6 @@ G_BEGIN_DECLS
#include "editor/ide-editor-view.h"
#include "editor/ide-editor-view-addin.h"
-#include "directory/ide-directory-vcs.h"
#include "doap/ide-doap-person.h"
#include "doap/ide-doap.h"
#include "git/ide-git-remote-callbacks.h"
diff --git a/libide/resources/libide.gresource.xml b/libide/resources/libide.gresource.xml
index 9e8814c..873fb55 100644
--- a/libide/resources/libide.gresource.xml
+++ b/libide/resources/libide.gresource.xml
@@ -72,4 +72,8 @@
<gresource prefix="/org/gnome/builder/plugins/fallback">
<file alias="fallback.plugin">../fallback/fallback.plugin</file>
</gresource>
+
+ <gresource prefix="/org/gnome/builder/plugins/git">
+ <file alias="git.plugin">../git/git.plugin</file>
+ </gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]