[anjuta/libgit2-glib: 18/18] git: Implement GitCommand base class



commit e02521dc3371f3ded3e0f6e566ee92f739b1e89e
Author: James Liggett <jrliggett cox net>
Date:   Thu Jul 11 22:56:49 2013 -0700

    git: Implement GitCommand base class
    
    The new GitCommand is used for commands that use libgit2 in a thread, while
    GitProcessCommand is for the older process-based commands.

 configure.ac              |   39 ++++++++++++++++
 plugins/git/Makefile.am   |   14 +++++-
 plugins/git/git-command.c |  106 +++++++++++++++++++++++++++++++++++++++++++++
 plugins/git/git-command.h |   58 ++++++++++++++++++++++++
 4 files changed, 214 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ba17c93..2f997f0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,6 +63,9 @@ SVN_MINOR=5
 SVN_PATCH=0
 SUBVERSION_REQUIRED=$SVN_MAJOR.$SVN_MINOR.$SVN_PATCH
 
+dnl Git plugin 
+GIT2_GLIB_REQUIRED=0.0.6
+
 AM_INIT_AUTOMAKE([1.10 dist-xz no-dist-gzip])
 AM_MAINTAINER_MODE([enable])
 
@@ -738,6 +741,35 @@ AC_SUBST(SVN_LIB)
 AC_SUBST(SVN_CFLAGS)
 
 dnl ------------------------------------------
+dnl libgit2-glib checks for the git plugin
+dnl ------------------------------------------
+user_disabled_git=0
+have_git2_glib=no
+
+AC_ARG_ENABLE(plugin-git,
+       AS_HELP_STRING([--disable-plugin-git], [Disable the git plugin]),
+       [ if test "$enableval" = "no"; then 
+               user_disabled_git=1
+         fi ],
+         [ user_disabled_git=0 ])
+
+AC_MSG_CHECKING(if git plugin is disabled)
+
+if test "$user_disabled_git" = 1; then
+       AC_MSG_RESULT(yes)
+else
+       AC_MSG_RESULT(no)
+
+       PKG_CHECK_MODULES(GIT2_GLIB, libgit2-glib-1.0 >= GIT2_GLIB_REQUIRED,
+                                         have_git2_glib=yes, have_git2_glib=no)
+fi
+
+AM_CONDITIONAL(BUILD_GIT, [test "$have_git2_glib" = "yes"])
+AC_SUBST(GIT2_GLIB_CFLAGS)
+AC_SUBST(GIT2_GLIB_LIBS)
+       
+
+dnl ------------------------------------------
 dnl Symbol-db shared memory checks
 dnl ------------------------------------------
 
@@ -917,6 +949,13 @@ echo " "
 echo "-------------------------------------------------------------------"
 echo "Conditionally built plugins:"
 echo "-------------------------------------------------------------------"
+if [ test x$have_git2_glib = xyes ]; then
+        echo "Building git plugin ....................................YES"
+else
+        echo "Building git plugin ....................................NO"
+        echo "        Requires libgit2-glib (>= $GIT2_GLIB_REQUIRED)"
+fi
+
 if [ test -n "$SVN_INCLUDE" ]; then
         echo "Building subversion plugin: ............................YES"
 else
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index d4fc517..f59d488 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -1,3 +1,5 @@
+if BUILD_GIT
+
 SUBDIRS = images
 
 # Plugin glade file
@@ -27,7 +29,8 @@ dist_git_plugin_DATA = $(plugin_in_files:.plugin.in=.plugin)
 AM_CPPFLAGS = \
        $(WARN_CFLAGS) \
        $(DEPRECATED_FLAGS) \
-       $(LIBANJUTA_CFLAGS)
+       $(LIBANJUTA_CFLAGS) \
+       $(GIT2_GLIB_CFLAGS)
 
 # Where to install the plugin
 plugindir = $(anjuta_plugin_dir)
@@ -228,20 +231,25 @@ libanjuta_git_la_SOURCES = \
        git-patch-series-pane.c \
        git-patch-series-pane.h \
        git-apply-mailbox-pane.c \
-       git-apply-mailbox-pane.h
+       git-apply-mailbox-pane.h \
+       git-command.c \
+       git-command.h
        
 
 libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 
 # Plugin dependencies
 libanjuta_git_la_LIBADD = \
-       $(LIBANJUTA_LIBS)
+       $(LIBANJUTA_LIBS) \
+       $(GIT2_GLIB_LIBS)
 
 gsettings_in_file = org.gnome.anjuta.plugins.git.gschema.xml.in
 gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
 @INTLTOOL_XML_NOMERGE_RULE@
 @GSETTINGS_RULES@
 
+endif
+
 EXTRA_DIST = \
        $(plugin_in_files) \
        $(gsettings_in_file)
diff --git a/plugins/git/git-command.c b/plugins/git/git-command.c
new file mode 100644
index 0000000..213295e
--- /dev/null
+++ b/plugins/git/git-command.c
@@ -0,0 +1,106 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-  */
+/*
+ * git-command.c
+ * Copyright (C) 2013 James Liggett <jrliggett cox net>
+ *
+ * anjuta 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.
+ * 
+ * anjuta 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 "git-command.h"
+
+struct _GitCommandPrivate
+{
+};
+
+
+enum
+{
+       PROP_0,
+
+       PROP_REPOSITORY
+};
+
+
+
+G_DEFINE_TYPE (GitCommand, git_command, ANJUTA_TYPE_ASYNC_TASK);
+
+static void
+git_command_init (GitCommand *git_command)
+{
+       git_command->priv = G_TYPE_INSTANCE_GET_PRIVATE (git_command, GIT_TYPE_COMMAND, GitCommandPrivate);
+
+       /* TODO: Add initialization code here */
+}
+
+static void
+git_command_finalize (GObject *object)
+{
+       /* TODO: Add deinitalization code here */
+
+       G_OBJECT_CLASS (git_command_parent_class)->finalize (object);
+}
+
+static void
+git_command_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+       g_return_if_fail (GIT_IS_COMMAND (object));
+
+       switch (prop_id)
+       {
+       case PROP_REPOSITORY:
+               /* TODO: Add setter for "repository" property here */
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+               break;
+       }
+}
+
+static void
+git_command_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+       g_return_if_fail (GIT_IS_COMMAND (object));
+
+       switch (prop_id)
+       {
+       case PROP_REPOSITORY:
+               /* TODO: Add getter for "repository" property here */
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+               break;
+       }
+}
+
+static void
+git_command_class_init (GitCommandClass *klass)
+{
+       GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (klass, sizeof (GitCommandPrivate));
+
+       object_class->finalize = git_command_finalize;
+       object_class->set_property = git_command_set_property;
+       object_class->get_property = git_command_get_property;
+
+       g_object_class_install_property (object_class,
+                                        PROP_REPOSITORY,
+                                        g_param_spec_object ("repository",
+                                                             "repository",
+                                                             "Git repository that this command operates on",
+                                                             GGIT_TYPE_REPOSITORY,
+                                                             G_PARAM_CONSTRUCT_ONLY));
+}
+
+
diff --git a/plugins/git/git-command.h b/plugins/git/git-command.h
new file mode 100644
index 0000000..5cf60cb
--- /dev/null
+++ b/plugins/git/git-command.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-  */
+/*
+ * git-command.h
+ * Copyright (C) 2013 James Liggett <jrliggett cox net>
+ *
+ * anjuta 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.
+ * 
+ * anjuta 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 _GIT_COMMAND_H_
+#define _GIT_COMMAND_H_
+
+#include <glib-object.h>
+#include <libanjuta/anjuta-async-task.h>
+#include <libgit2-glib/ggit-repository.h>
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_COMMAND             (git_command_get_type ())
+#define GIT_COMMAND(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_COMMAND, GitCommand))
+#define GIT_COMMAND_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_COMMAND, GitCommandClass))
+#define GIT_IS_COMMAND(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_COMMAND))
+#define GIT_IS_COMMAND_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_COMMAND))
+#define GIT_COMMAND_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_COMMAND, GitCommandClass))
+
+typedef struct _GitCommandClass GitCommandClass;
+typedef struct _GitCommand GitCommand;
+typedef struct _GitCommandPrivate GitCommandPrivate;
+
+
+struct _GitCommandClass
+{
+       AnjutaAsyncTaskClass parent_class;
+};
+
+struct _GitCommand
+{
+       AnjutaAsyncTask parent_instance;
+
+       GitCommandPrivate *priv;
+};
+
+GType git_command_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* _GIT_COMMAND_H_ */
+


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