[gnome-builder] git: do libgit2-glib checks during plugin loading



commit eddc5ccc5b9e04c225bc123f17e4dbe9397115d6
Author: Christian Hergert <christian hergert me>
Date:   Sun Dec 27 17:37:28 2015 -0800

    git: do libgit2-glib checks during plugin loading
    
    These belong in the git plugin, rather than in the application itself.

 libide/ide-application.c     |   25 -------------------------
 plugins/git/ide-git-plugin.c |   40 ++++++++++++++++++++++++++++++++++------
 2 files changed, 34 insertions(+), 31 deletions(-)
---
diff --git a/libide/ide-application.c b/libide/ide-application.c
index 0375146..74ba967 100644
--- a/libide/ide-application.c
+++ b/libide/ide-application.c
@@ -143,30 +143,6 @@ ide_application_register_search_paths (IdeApplication *self)
 }
 
 static void
-ide_application_register_ggit (IdeApplication *self)
-{
-  GgitFeatureFlags ggit_flags;
-
-  g_assert (IDE_IS_APPLICATION (self));
-
-  ggit_init ();
-
-  ggit_flags = ggit_get_features ();
-
-  if ((ggit_flags & GGIT_FEATURE_THREADS) == 0)
-    {
-      g_error (_("Builder requires libgit2-glib with threading support."));
-      exit (EXIT_FAILURE);
-    }
-
-  if ((ggit_flags & GGIT_FEATURE_SSH) == 0)
-    {
-      g_error (_("Builder requires libgit2-glib with SSH support."));
-      exit (EXIT_FAILURE);
-    }
-}
-
-static void
 ide_application_activate_primary (IdeApplication *self)
 {
   GtkWindow *window;
@@ -337,7 +313,6 @@ ide_application_startup (GApplication *application)
       ide_application_make_skeleton_dirs (self);
       ide_application_register_theme_overrides (self);
       ide_application_register_keybindings (self);
-      ide_application_register_ggit (self);
       ide_application_actions_init (self);
 
       modeline_parser_init ();
diff --git a/plugins/git/ide-git-plugin.c b/plugins/git/ide-git-plugin.c
index 97c9419..90e236e 100644
--- a/plugins/git/ide-git-plugin.c
+++ b/plugins/git/ide-git-plugin.c
@@ -22,13 +22,41 @@
 #include "ide-git-genesis-addin.h"
 #include "ide-git-vcs.h"
 
+static gboolean
+register_ggit (void)
+{
+  GgitFeatureFlags ggit_flags;
+
+  ggit_init ();
+
+  ggit_flags = ggit_get_features ();
+
+  if ((ggit_flags & GGIT_FEATURE_THREADS) == 0)
+    {
+      g_printerr ("Builder requires libgit2-glib with threading support.");
+      return FALSE;
+    }
+
+  if ((ggit_flags & GGIT_FEATURE_SSH) == 0)
+    {
+      g_printerr ("Builder requires libgit2-glib with SSH support.");
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
+
 void
 peas_register_types (PeasObjectModule *module)
 {
-  peas_object_module_register_extension_type (module,
-                                              IDE_TYPE_VCS,
-                                              IDE_TYPE_GIT_VCS);
-  peas_object_module_register_extension_type (module,
-                                              IDE_TYPE_GENESIS_ADDIN,
-                                              IDE_TYPE_GIT_GENESIS_ADDIN);
+  if (register_ggit ())
+    {
+      peas_object_module_register_extension_type (module,
+                                                  IDE_TYPE_VCS,
+                                                  IDE_TYPE_GIT_VCS);
+      peas_object_module_register_extension_type (module,
+                                                  IDE_TYPE_GENESIS_ADDIN,
+                                                  IDE_TYPE_GIT_GENESIS_ADDIN);
+    }
 }


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