anjuta r4555 - in trunk: . plugins/subversion



Author: jrliggett
Date: Fri Jan  9 07:37:29 2009
New Revision: 4555
URL: http://svn.gnome.org/viewvc/anjuta?rev=4555&view=rev

Log:
* plugins/subversion/Makefile.am:
* plugins/subversion/plugin.c:
* plugins/subversion/subversion-vcs-interface.c
(subversion_ivcs_iface_init), (subversion_ivcs_add),
(subversion_ivcs_checkout), (on_diff_command_data_arrived),
(subversion_ivcs_diff), (on_status_command_data_arrived),
(subversion_ivcs_query_status), (subversion_ivcs_remove):
* plugins/subversion/subversion-vcs-interface.h:
An initial implementation of IAnjutaVcs interface for the Subversion plugin.
	
Important Notes:
	- The functionality of the interface is untested. The plugin compiles
	   and loads fine, but I haven't verified that the actual interface 
	   methods work
	- The checkout method is a stub right now; we don't even have support
	  for that in the plugin right now. That will be changing soon.
	- The cancellable parameter is ignored. Implementing suport for that
	   is also on my todo list.

Added:
   trunk/plugins/subversion/subversion-vcs-interface.c   (contents, props changed)
   trunk/plugins/subversion/subversion-vcs-interface.h   (contents, props changed)
Modified:
   trunk/ChangeLog
   trunk/plugins/subversion/Makefile.am
   trunk/plugins/subversion/plugin.c

Modified: trunk/plugins/subversion/Makefile.am
==============================================================================
--- trunk/plugins/subversion/Makefile.am	(original)
+++ trunk/plugins/subversion/Makefile.am	Fri Jan  9 07:37:29 2009
@@ -95,7 +95,9 @@
 	subversion-resolve-dialog.c \
 	subversion-resolve-dialog.h \
 	svn-resolve-command.h \
-	svn-resolve-command.c
+	svn-resolve-command.c \
+	subversion-vcs-interface.c \
+	subversion-vcs-interface.h
 
 endif
 

Modified: trunk/plugins/subversion/plugin.c
==============================================================================
--- trunk/plugins/subversion/plugin.c	(original)
+++ trunk/plugins/subversion/plugin.c	Fri Jan  9 07:37:29 2009
@@ -28,6 +28,7 @@
 #include <libanjuta/interfaces/ianjuta-vcs.h>
 
 #include "plugin.h"
+#include "subversion-vcs-interface.h"
 #include "subversion-add-dialog.h"
 #include "subversion-remove-dialog.h"
 #include "subversion-commit-dialog.h"
@@ -572,6 +573,7 @@
 }
 
 ANJUTA_PLUGIN_BEGIN (Subversion, subversion);
+ANJUTA_PLUGIN_ADD_INTERFACE (subversion_ivcs, IANJUTA_TYPE_VCS);
 ANJUTA_PLUGIN_END;
 
 ANJUTA_SIMPLE_PLUGIN (Subversion, subversion);

Added: trunk/plugins/subversion/subversion-vcs-interface.c
==============================================================================
--- (empty file)
+++ trunk/plugins/subversion/subversion-vcs-interface.c	Fri Jan  9 07:37:29 2009
@@ -0,0 +1,215 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * anjuta is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 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 anjuta.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#include "subversion-vcs-interface.h"
+
+void
+subversion_ivcs_iface_init (IAnjutaVcsIface *iface)
+{
+	iface->add = subversion_ivcs_add;
+	iface->checkout = subversion_ivcs_checkout;
+	iface->diff = subversion_ivcs_diff;
+	iface->query_status = subversion_ivcs_query_status;
+	iface->remove = subversion_ivcs_remove;
+}
+
+void
+subversion_ivcs_add (IAnjutaVcs *obj, GList *files, AnjutaAsyncNotify *notify,
+					 GError **err)
+{
+	GList *path_list;
+	SvnAddCommand *add_command;
+	
+	path_list = anjuta_util_convert_gfile_list_to_path_list (files);
+	add_command = svn_add_command_new_list (path_list, FALSE, TRUE);
+	
+	anjuta_util_glist_strings_free (path_list);
+	
+	g_signal_connect (G_OBJECT (add_command), "finished", 
+					  G_CALLBACK (g_object_unref), 
+					  NULL);
+	
+	if (notify)
+	{
+		g_signal_connect_swapped (G_OBJECT (add_command), "finished",
+								  G_CALLBACK (anjuta_async_notify_notify_finished),
+								  notify);
+	}
+	
+	anjuta_command_start (ANJUTA_COMMAND (add_command));
+	
+}
+
+void
+subversion_ivcs_checkout (IAnjutaVcs *obj, 
+						  const gchar *repository_location, GFile *dest,
+						  GCancellable *cancel,
+						  AnjutaAsyncNotify *notify, GError **err)
+{
+	/* Stub */
+}
+
+static void
+on_diff_command_data_arrived (AnjutaCommand *command, 
+							  IAnjutaVcsDiffCallback callback)
+{
+	GQueue *output;
+	gchar *line;
+	
+	output = svn_diff_command_get_output (SVN_DIFF_COMMAND (command));
+	
+	while (g_queue_peek_head (output))
+	{
+		line = g_queue_pop_head (output);
+		callback (g_object_get_data (G_OBJECT (command), "file"), line,
+				  g_object_get_data (G_OBJECT (command), "user-data"));
+		g_free (line);
+	}
+}
+
+void 
+subversion_ivcs_diff (IAnjutaVcs *obj, GFile* file,  
+					  IAnjutaVcsDiffCallback callback, gpointer user_data,  
+					  GCancellable* cancel, AnjutaAsyncNotify *notify,
+					  GError **err)
+{
+	gchar *path;
+	SvnDiffCommand *diff_command;
+	
+	path = g_file_get_path (file);
+	diff_command = svn_diff_command_new (path, SVN_DIFF_REVISION_NONE,
+										 SVN_DIFF_REVISION_NONE,
+										 TRUE);
+	
+	g_free (path);
+	
+	g_object_set_data_full (G_OBJECT (diff_command), "file", 
+							g_object_ref (file),
+							(GDestroyNotify) g_object_unref);
+	g_object_set_data (G_OBJECT (diff_command), "user-data", user_data);
+	
+	g_signal_connect (G_OBJECT (diff_command), "finished", 
+					  G_CALLBACK (g_object_unref),
+					  NULL);
+	
+	g_signal_connect (G_OBJECT (diff_command), "data-arrived",
+					  G_CALLBACK (on_diff_command_data_arrived),
+					  callback);
+	
+	if (notify)
+	{
+		g_signal_connect_swapped (G_OBJECT (diff_command), "finished",
+								  G_CALLBACK (anjuta_async_notify_notify_finished),
+								  notify);
+	}
+	
+	anjuta_command_start (ANJUTA_COMMAND (diff_command));
+}
+
+static void
+on_status_command_data_arrived (AnjutaCommand *command, 
+								IAnjutaVcsStatusCallback callback)
+{
+	GQueue *status_queue;
+	SvnStatus *status;
+	gchar *path;
+	
+	status_queue = svn_status_command_get_status_queue (SVN_STATUS_COMMAND (command));
+	
+	while (g_queue_peek_head (status_queue))
+	{
+		status = g_queue_pop_head (status_queue);
+		path = svn_status_get_path (status);
+		
+		callback (g_object_get_data (G_OBJECT (command), "file"), 
+				  svn_status_get_vcs_status (status),
+				  g_object_get_data (G_OBJECT (command), "user-data"));
+		
+		svn_status_destroy (status);
+		g_free (path);
+	}
+}
+
+void 
+subversion_ivcs_query_status (IAnjutaVcs *obj, GFile *file, 
+							  IAnjutaVcsStatusCallback callback,
+							  gpointer user_data, GCancellable *cancel,
+							  AnjutaAsyncNotify *notify, GError **err)
+{
+	gchar *path;
+	SvnStatusCommand *status_command;
+	
+	path = g_file_get_path (file);
+	status_command = svn_status_command_new (path, TRUE, FALSE);
+	
+	g_free (path);
+	
+	g_object_set_data_full (G_OBJECT (status_command), "file", 
+							g_object_ref (file),
+							(GDestroyNotify) g_object_unref);
+	g_object_set_data (G_OBJECT (status_command), "user-data", user_data);
+	
+	g_signal_connect (G_OBJECT (status_command), "data-arrived",
+					  G_CALLBACK (on_status_command_data_arrived),
+					  callback);
+	
+	g_signal_connect (G_OBJECT (status_command), "finished",
+					  G_CALLBACK (g_object_unref),
+					  NULL);
+	
+	if (notify)
+	{
+		g_signal_connect_swapped (G_OBJECT (status_command), "finished",
+								  G_CALLBACK (anjuta_async_notify_notify_finished),
+								  notify);
+	}
+	
+	anjuta_command_start (ANJUTA_COMMAND (status_command));
+}
+
+void 
+subversion_ivcs_remove (IAnjutaVcs *obj, GList *files, 
+						AnjutaAsyncNotify *notify, GError **err)
+{
+	GList *path_list;
+	SvnRemoveCommand *remove_command;
+	
+	path_list = anjuta_util_convert_gfile_list_to_path_list (files);
+	remove_command = svn_remove_command_new_list (path_list, NULL, FALSE);
+	
+	anjuta_util_glist_strings_free (path_list);
+	
+	g_signal_connect (G_OBJECT (remove_command), "finished", 
+					  G_CALLBACK (g_object_unref), 
+					  NULL);
+	
+	if (notify)
+	{
+		g_signal_connect_swapped (G_OBJECT (remove_command), "finished",
+								  G_CALLBACK (anjuta_async_notify_notify_finished),
+								  notify);
+	}
+	
+	anjuta_command_start (ANJUTA_COMMAND (remove_command));
+}
\ No newline at end of file

Added: trunk/plugins/subversion/subversion-vcs-interface.h
==============================================================================
--- (empty file)
+++ trunk/plugins/subversion/subversion-vcs-interface.h	Fri Jan  9 07:37:29 2009
@@ -0,0 +1,56 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * anjuta is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 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 anjuta.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#ifndef _SUBVERSION_VCS_INTERFACE_H_
+#define _SUBVERSION_VCS_INTERFACE_H_
+
+#include <libanjuta/anjuta-utils.h>
+#include <libanjuta/interfaces/ianjuta-vcs.h>
+
+#include "svn-add-command.h"
+#include "svn-diff-command.h"
+#include "svn-status-command.h"
+#include "svn-remove-command.h"
+
+void subversion_ivcs_iface_init (IAnjutaVcsIface *iface);
+void subversion_ivcs_add (IAnjutaVcs *obj, GList *files, 
+						  AnjutaAsyncNotify *notify, GError **err);
+void subversion_ivcs_checkout (IAnjutaVcs *obj, 
+							   const gchar *repository_location, GFile *dest,
+							   GCancellable *cancel,
+							   AnjutaAsyncNotify *notify, GError **err);
+void subversion_ivcs_diff (IAnjutaVcs *obj, GFile* file,  
+						   IAnjutaVcsDiffCallback callback, gpointer user_data,  
+						   GCancellable* cancel, AnjutaAsyncNotify *notify,
+						   GError **err);
+void subversion_ivcs_query_status (IAnjutaVcs *obj, GFile *file, 
+								   IAnjutaVcsStatusCallback callback,
+								   gpointer user_data, GCancellable *cancel,
+								   AnjutaAsyncNotify *notify, GError **err);
+void subversion_ivcs_remove (IAnjutaVcs *obj, GList *files, 
+							 AnjutaAsyncNotify *notify, GError **err);
+
+
+#endif 
+ 
\ No newline at end of file



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