[gnome-builder] vcs: add IdeVcsInitializer



commit f31dee800b6e09e84d29304447cd5fc1d21ecd73
Author: Christian Hergert <chergert redhat com>
Date:   Tue May 10 18:51:48 2016 +0300

    vcs: add IdeVcsInitializer
    
    This interface can be used to initialize a new version control repository.

 libide/Makefile.am           |    2 +
 libide/ide-vcs-initializer.c |   62 ++++++++++++++++++++++++++++++++++++++++++
 libide/ide-vcs-initializer.h |   57 ++++++++++++++++++++++++++++++++++++++
 libide/ide.h                 |    1 +
 4 files changed, 122 insertions(+), 0 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index 49c690d..6ada4d8 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -134,6 +134,7 @@ libide_1_0_la_public_headers = \
        ide-unsaved-files.h \
        ide-uri.h \
        ide-vcs-uri.h \
+       ide-vcs-initializer.h \
        ide-vcs.h \
        ide-workbench-addin.h \
        ide-workbench-header-bar.h \
@@ -284,6 +285,7 @@ libide_1_0_la_public_sources = \
        ide-unsaved-file.c \
        ide-unsaved-files.c \
        ide-uri.c \
+       ide-vcs-initializer.c \
        ide-vcs-uri.c \
        ide-vcs.c \
        ide-workbench-addin.c \
diff --git a/libide/ide-vcs-initializer.c b/libide/ide-vcs-initializer.c
new file mode 100644
index 0000000..4a3d8f9
--- /dev/null
+++ b/libide/ide-vcs-initializer.c
@@ -0,0 +1,62 @@
+/* ide-vcs-initializer.c
+ *
+ * Copyright (C) 2016 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ide-vcs-initializer.h"
+
+G_DEFINE_INTERFACE (IdeVcsInitializer, ide_vcs_initializer, G_TYPE_OBJECT)
+
+static void
+ide_vcs_initializer_default_init (IdeVcsInitializerInterface *iface)
+{
+}
+
+void
+ide_vcs_initializer_initialize_async  (IdeVcsInitializer   *self,
+                                       GFile               *file,
+                                       GCancellable        *cancellable,
+                                       GAsyncReadyCallback  callback,
+                                       gpointer             user_data)
+{
+  g_return_if_fail (IDE_IS_VCS_INITIALIZER (self));
+  g_return_if_fail (G_IS_FILE (file));
+  g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+  IDE_VCS_INITIALIZER_GET_IFACE (self)->initialize_async (self, file, cancellable, callback, user_data);
+}
+
+gboolean
+ide_vcs_initializer_initialize_finish (IdeVcsInitializer  *self,
+                                       GAsyncResult       *result,
+                                       GError            **error)
+{
+  g_return_val_if_fail (IDE_IS_VCS_INITIALIZER (self), FALSE);
+  g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
+
+  return IDE_VCS_INITIALIZER_GET_IFACE (self)->initialize_finish (self, result, error);
+}
+
+gchar *
+ide_vcs_initializer_get_title (IdeVcsInitializer *self)
+{
+  g_return_val_if_fail (IDE_IS_VCS_INITIALIZER (self), NULL);
+
+  if (IDE_VCS_INITIALIZER_GET_IFACE (self)->get_title)
+    return IDE_VCS_INITIALIZER_GET_IFACE (self)->get_title (self);
+
+  return g_strdup (G_OBJECT_TYPE_NAME (self));
+}
diff --git a/libide/ide-vcs-initializer.h b/libide/ide-vcs-initializer.h
new file mode 100644
index 0000000..f71f741
--- /dev/null
+++ b/libide/ide-vcs-initializer.h
@@ -0,0 +1,57 @@
+/* ide-vcs-initializer.h
+ *
+ * Copyright (C) 2016 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_VCS_INITIALIZER_H
+#define IDE_VCS_INITIALIZER_H
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_VCS_INITIALIZER (ide_vcs_initializer_get_type ())
+
+G_DECLARE_INTERFACE (IdeVcsInitializer, ide_vcs_initializer, IDE, VCS_INITIALIZER, GObject)
+
+struct _IdeVcsInitializerInterface
+{
+  GTypeInterface parent;
+
+  gchar   *(*get_title)         (IdeVcsInitializer    *self);
+  void     (*initialize_async)  (IdeVcsInitializer    *self,
+                                 GFile                *file,
+                                 GCancellable         *cancellable,
+                                 GAsyncReadyCallback   callback,
+                                 gpointer              user_data);
+  gboolean (*initialize_finish) (IdeVcsInitializer    *self,
+                                 GAsyncResult         *result,
+                                 GError              **error);
+};
+
+gchar   *ide_vcs_initializer_get_title         (IdeVcsInitializer    *self);
+void     ide_vcs_initializer_initialize_async  (IdeVcsInitializer    *self,
+                                                GFile                *file,
+                                                GCancellable         *cancellable,
+                                                GAsyncReadyCallback   callback,
+                                                gpointer              user_data);
+gboolean ide_vcs_initializer_initialize_finish (IdeVcsInitializer    *self,
+                                                GAsyncResult         *result,
+                                                GError              **error);
+
+G_END_DECLS
+
+#endif /* IDE_VCS_INITIALIZER_H */
diff --git a/libide/ide.h b/libide/ide.h
index 72f9a40..caafa11 100644
--- a/libide/ide.h
+++ b/libide/ide.h
@@ -124,6 +124,7 @@ G_BEGIN_DECLS
 #include "ide-unsaved-files.h"
 #include "ide-uri.h"
 #include "ide-vcs.h"
+#include "ide-vcs-initializer.h"
 #include "ide-vcs-uri.h"
 #include "ide-workbench.h"
 #include "ide-workbench-addin.h"


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