[Goodies-commits] r2872 - in thunar-svn-plugin/trunk: thunar-svn-plugin tsp-svn-helper

Peter de Ridder peter at xfce.org
Thu Jun 28 00:27:21 CEST 2007


Author: peter
Date: 2007-06-27 22:27:21 +0000 (Wed, 27 Jun 2007)
New Revision: 2872

Modified:
   thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-provider.c
   thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-action.c
   thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-action.h
   thunar-svn-plugin/trunk/tsp-svn-helper/Makefile.am
   thunar-svn-plugin/trunk/tsp-svn-helper/main.c
   thunar-svn-plugin/trunk/tsp-svn-helper/tsh-common.c
   thunar-svn-plugin/trunk/tsp-svn-helper/tsh-common.h
   thunar-svn-plugin/trunk/tsp-svn-helper/tsh-update.c
Log:
updated svn update
added begin of checkout


Modified: thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-provider.c
===================================================================
--- thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-provider.c	2007-06-27 19:01:50 UTC (rev 2871)
+++ thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-provider.c	2007-06-27 22:27:21 UTC (rev 2872)
@@ -421,6 +421,7 @@
                                  ThunarxFileInfo     *folder)
 {
   GtkAction          *action;
+  GtkAction          *svnaction;
   GList              *actions = NULL;
   ThunarVfsPathScheme scheme;
   ThunarVfsInfo      *info;
@@ -435,29 +436,30 @@
 	if (G_UNLIKELY (scheme != THUNAR_VFS_PATH_SCHEME_FILE))
 		return NULL;
 
+	files = g_list_append (NULL, folder);
+
 	/* Lets see if we are dealing with a working copy */
 	if (tsp_is_working_copy (folder))
 	{
-		files = g_list_append (NULL, folder);
-
+		svnaction = tsp_svn_action_new ("Tsp::svn", _("SVN"), files, window, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE);
 		/* append the svn submenu action */
-		action = tsp_svn_action_new ("Tsp::svn", _("SVN"), files, window, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE);
-		actions = g_list_append (actions, action);
+		actions = g_list_append (actions, svnaction);
 
 		g_list_free (files);
 	}
 	else
 	{
+		svnaction = tsp_svn_action_new ("Tsp::svn", _("SVN"), files, window, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE);
 		/* It's not a working copy
 		 * append the "Checkout" action */
 		action = g_object_new (GTK_TYPE_ACTION,
 													 "name", "Tsp::checkout",
 													 "label", _("SVN _Checkout"),
 													 NULL);
+		g_signal_connect_object (action, "activate", G_CALLBACK (tsp_action_checkout), svnaction, G_CONNECT_AFTER);
 		actions = g_list_append (actions, action);
 		/* append the svn submenu action
-		action = tsp_svn_action_new ("Tsp::svn", _("SVN"), window, TRUE, FASLE, FALSE, FALSE, FALSE, FALSE);
-		actions = g_list_append (actions, action); */
+		actions = g_list_append (actions, svnaction); */
 	}
 
   return actions;

Modified: thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-action.c
===================================================================
--- thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-action.c	2007-06-27 19:01:50 UTC (rev 2871)
+++ thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-action.c	2007-06-27 22:27:21 UTC (rev 2872)
@@ -78,7 +78,7 @@
 
 
 
-static void tsp_action_update (GtkMenuItem *item, TspSvnAction *action);
+void tsp_action_update (GtkMenuItem *item, TspSvnAction *action);
 
 
 
@@ -385,7 +385,7 @@
 
 
 
-static void tsp_action_update (GtkMenuItem *item, TspSvnAction *action)
+void tsp_action_update (GtkMenuItem *item, TspSvnAction *action)
 {
 	guint size, i;
 	gchar **argv;
@@ -457,3 +457,77 @@
 	g_strfreev (argv);
 }
 
+
+
+void tsp_action_checkout (GtkMenuItem *item, TspSvnAction *action)
+{
+	guint size, i;
+	gchar **argv;
+	GList *iter;
+	gchar *uri;
+	gchar *filename;
+	gchar *file;
+	gint pid;
+	GError *error = NULL;
+	GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (action->window));
+
+	iter = action->files;
+
+	size = g_list_length (iter);
+
+	argv = g_new (gchar *, size + 3);
+
+	argv[0] = g_strdup (TSP_SVN_HELPER);
+	argv[1] = g_strdup ("--checkout");
+	argv[size + 2] = NULL;
+
+	for (i = 0; i < size; i++)
+	{
+		/* determine the URI for the file info */
+		uri = thunarx_file_info_get_uri (iter->data);
+		if (G_LIKELY (uri != NULL))
+    {
+      /* determine the local filename for the URI */
+      filename = g_filename_from_uri (uri, NULL, NULL);
+      if (G_LIKELY (filename != NULL))
+			{
+				file = filename;
+				/* strip the "file://" part of the uri */
+				if (strncmp (file, "file://", 7) == 0)
+				{
+					file += 7;
+				}
+
+				file = g_strdup (file);
+
+				/* remove trailing '/' cause svn can't handle that */
+				if (file[strlen (file) - 1] == '/')
+				{
+					file[strlen (file) - 1] = '\0';
+				}
+
+				argv[i+2] = file;
+
+				/* release the filename */
+				g_free (filename);
+			}
+
+      /* release the URI */
+      g_free (uri);
+    }
+
+		iter = g_list_next (iter);
+	}
+
+	if (!gdk_spawn_on_screen (screen, NULL, argv, NULL, 0, NULL, NULL, &pid, &error))
+	{
+		GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (action->window), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Could not spawn \'" TSP_SVN_HELPER "\'");
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s.", error->message);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+		g_error_free (error);
+	}
+
+	g_strfreev (argv);
+}
+

Modified: thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-action.h
===================================================================
--- thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-action.h	2007-06-27 19:01:50 UTC (rev 2871)
+++ thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-action.h	2007-06-27 22:27:21 UTC (rev 2872)
@@ -49,4 +49,7 @@
 
 G_END_DECLS;
 
+
+void tsp_action_checkout (GtkMenuItem *, TspSvnAction *);
+
 #endif /* !__TSP_SVN_ACTION_H__ */

Modified: thunar-svn-plugin/trunk/tsp-svn-helper/Makefile.am
===================================================================
--- thunar-svn-plugin/trunk/tsp-svn-helper/Makefile.am	2007-06-27 19:01:50 UTC (rev 2871)
+++ thunar-svn-plugin/trunk/tsp-svn-helper/Makefile.am	2007-06-27 22:27:21 UTC (rev 2872)
@@ -9,7 +9,7 @@
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"				\
 	$(PLATFORM_CPPFLAGS)
 
-libexec_PROGRAMS =								\
+libexec_PROGRAMS =							\
 	tsp-svn-helper
 
 tsp_svn_helper_SOURCES =						\
@@ -18,12 +18,18 @@
 	tsh-common.c							\
 	tsh-update.h							\
 	tsh-update.c							\
+	tsh-checkout.h							\
+	tsh-checkout.c							\
 	tsh-dialog-common.h						\
 	tsh-dialog-common.c						\
 	tsh-login-dialog.h						\
 	tsh-login-dialog.c						\
-	tsh-update-dialog.h						\
-	tsh-update-dialog.c
+	tsh-file-dialog.h						\
+	tsh-file-dialog.c						\
+	tsh-trust-dialog.h						\
+	tsh-trust-dialog.c						\
+	tsh-notify-dialog.h						\
+	tsh-notify-dialog.c
 
 tsp_svn_helper_CPPFLAGS =						\
 	-DG_LOG_DOMAIN=\"tsp-svn-helper\"

Modified: thunar-svn-plugin/trunk/tsp-svn-helper/main.c
===================================================================
--- thunar-svn-plugin/trunk/tsp-svn-helper/main.c	2007-06-27 19:01:50 UTC (rev 2871)
+++ thunar-svn-plugin/trunk/tsp-svn-helper/main.c	2007-06-27 22:27:21 UTC (rev 2872)
@@ -34,6 +34,7 @@
 
 #include "tsh-common.h"
 #include "tsh-update.h"
+#include "tsh-checkout.h"
 
 int main (int argc, char *argv[])
 {
@@ -122,6 +123,11 @@
 		thread = tsh_update(files, svn_ctx, pool);
 	}
 
+	if(checkout)
+	{
+		thread = tsh_checkout(files, svn_ctx, pool);
+	}
+
 	if(thread)
 	{
 		gtk_main ();

Modified: thunar-svn-plugin/trunk/tsp-svn-helper/tsh-common.c
===================================================================
--- thunar-svn-plugin/trunk/tsp-svn-helper/tsh-common.c	2007-06-27 19:01:50 UTC (rev 2871)
+++ thunar-svn-plugin/trunk/tsp-svn-helper/tsh-common.c	2007-06-27 22:27:21 UTC (rev 2872)
@@ -35,7 +35,11 @@
 #include <subversion-1/svn_config.h>
 #include <subversion-1/svn_fs.h>
 
+#include "tsh-dialog-common.h"
 #include "tsh-login-dialog.h"
+#include "tsh-file-dialog.h"
+#include "tsh-trust-dialog.h"
+#include "tsh-notify-dialog.h"
 
 #include "tsh-common.h"
 
@@ -244,14 +248,17 @@
                        svn_boolean_t may_save,
                        apr_pool_t *pool)
 {
-	g_debug("prompt");
-
 	if(!username)
 		username = "";
+
+	gdk_threads_enter();
+
 	GtkWidget *dialog = tsh_login_dialog_new(NULL, NULL, 0, username, TRUE, may_save);
 
 	if(gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK)
 	{
+		gdk_threads_leave();
+
 		*cred = NULL;
 
 		gtk_widget_destroy(dialog);
@@ -260,6 +267,8 @@
 		return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL);
 	}
 
+	gdk_threads_leave();
+
   svn_auth_cred_simple_t *ret = apr_pcalloc(pool, sizeof(svn_auth_cred_simple_t));
 	TshLoginDialog *login_dialog = TSH_LOGIN_DIALOG(dialog);
 	ret->username = apr_pstrdup(pool, tsh_login_dialog_get_username(login_dialog));
@@ -279,12 +288,14 @@
                                              svn_boolean_t may_save,
                                              apr_pool_t *pool)
 {
-	g_debug("prompt");
+	gdk_threads_enter();
 
 	GtkWidget *dialog = tsh_login_dialog_new(NULL, NULL, 0, "", FALSE, may_save);
 
 	if(gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK)
 	{
+		gdk_threads_leave();
+
 		*cred = NULL;
 
 		gtk_widget_destroy(dialog);
@@ -293,6 +304,8 @@
 		return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL);
 	}
 
+	gdk_threads_leave();
+
   svn_auth_cred_username_t *ret = apr_pcalloc(pool, sizeof(svn_auth_cred_username_t));
 	TshLoginDialog *login_dialog = TSH_LOGIN_DIALOG(dialog);
 	ret->username = apr_pstrdup(pool, tsh_login_dialog_get_username(login_dialog));
@@ -313,8 +326,32 @@
                                  svn_boolean_t may_save,
                                  apr_pool_t *pool)
 {
-	g_debug("prompt");
-	cancelled = TRUE;
+	gdk_threads_enter();
+
+	GtkWidget *dialog = tsh_trust_dialog_new(NULL, NULL, 0, failures, may_save);
+
+	if(gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK)
+	{
+		gdk_threads_leave();
+
+		*cred = NULL;
+
+		gtk_widget_destroy(dialog);
+
+		cancelled = TRUE;
+		return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL);
+	}
+
+	gdk_threads_leave();
+
+  svn_auth_cred_ssl_server_trust_t *ret = apr_pcalloc(pool, sizeof(svn_auth_cred_ssl_server_trust_t));
+	TshTrustDialog *trust_dialog = TSH_TRUST_DIALOG(dialog);
+	ret->may_save = tsh_trust_dialog_get_may_save(trust_dialog);
+	ret->accepted_failures = tsh_trust_dialog_get_accepted(trust_dialog);
+	*cred = ret;
+
+	gtk_widget_destroy(dialog);
+
 	return SVN_NO_ERROR;
 }
 
@@ -325,8 +362,32 @@
                                 svn_boolean_t may_save,
                                 apr_pool_t *pool)
 {
-	g_debug("prompt");
-	cancelled = TRUE;
+	gdk_threads_enter();
+
+	GtkWidget *dialog = tsh_file_dialog_new(NULL, NULL, 0, may_save);
+
+	if(gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK)
+	{
+		gdk_threads_leave();
+
+		*cred = NULL;
+
+		gtk_widget_destroy(dialog);
+
+		cancelled = TRUE;
+		return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL);
+	}
+
+	gdk_threads_leave();
+
+  svn_auth_cred_ssl_client_cert_t *ret = apr_pcalloc(pool, sizeof(svn_auth_cred_ssl_client_cert_t));
+	TshFileDialog *file_dialog = TSH_FILE_DIALOG(dialog);
+	ret->cert_file = apr_pstrdup(pool, tsh_file_dialog_get_filename(file_dialog));
+	ret->may_save = tsh_file_dialog_get_may_save(file_dialog);
+	*cred = ret;
+
+	gtk_widget_destroy(dialog);
+
 	return SVN_NO_ERROR;
 }
 
@@ -337,8 +398,32 @@
                                    svn_boolean_t may_save,
                                    apr_pool_t *pool)
 {
-	g_debug("prompt");
-	cancelled = TRUE;
+	gdk_threads_enter();
+
+	GtkWidget *dialog = tsh_login_dialog_new(NULL, NULL, 0, NULL, TRUE, may_save);
+
+	if(gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK)
+	{
+		gdk_threads_leave();
+
+		*cred = NULL;
+
+		gtk_widget_destroy(dialog);
+
+		cancelled = TRUE;
+		return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL);
+	}
+
+	gdk_threads_leave();
+
+  svn_auth_cred_ssl_client_cert_pw_t *ret = apr_pcalloc(pool, sizeof(svn_auth_cred_ssl_client_cert_pw_t));
+	TshLoginDialog *login_dialog = TSH_LOGIN_DIALOG(dialog);
+	ret->password = apr_pstrdup(pool, tsh_login_dialog_get_password(login_dialog));
+	ret->may_save = tsh_login_dialog_get_may_save(login_dialog);
+	*cred = ret;
+
+	gtk_widget_destroy(dialog);
+
 	return SVN_NO_ERROR;
 }
 
@@ -350,3 +435,42 @@
 	return SVN_NO_ERROR;
 }
 
+void
+tsh_notify_func2(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool)
+{
+	TshNotifyDialog *dialog = TSH_NOTIFY_DIALOG (baton);
+	char buffer[256];
+
+	switch(notify->action)
+	{
+		case svn_wc_notify_update_delete:
+			gdk_threads_enter();
+			tsh_notify_dialog_add(dialog, _("Deleted"), notify->path, notify->mime_type);
+			gdk_threads_leave();
+			break;
+		case svn_wc_notify_update_add:
+			gdk_threads_enter();
+			tsh_notify_dialog_add(dialog, _("Added"), notify->path, notify->mime_type);
+			gdk_threads_leave();
+			break;
+		case svn_wc_notify_update_update:
+			gdk_threads_enter();
+			tsh_notify_dialog_add(dialog, _("Updated"), notify->path, notify->mime_type);
+			gdk_threads_leave();
+			break;
+		case svn_wc_notify_update_completed:
+			g_snprintf(buffer, 256, _("At revision: %li"), notify->revision);
+			gdk_threads_enter();
+			tsh_notify_dialog_add(dialog, _("Completed"), buffer, NULL);
+			gdk_threads_leave();
+			break;
+		case svn_wc_notify_update_external:
+			gdk_threads_enter();
+			tsh_notify_dialog_add(dialog, _("External"), notify->path, notify->mime_type);
+			gdk_threads_leave();
+			break;
+		default:
+			break;
+	}
+}
+

Modified: thunar-svn-plugin/trunk/tsp-svn-helper/tsh-common.h
===================================================================
--- thunar-svn-plugin/trunk/tsp-svn-helper/tsh-common.h	2007-06-27 19:01:50 UTC (rev 2871)
+++ thunar-svn-plugin/trunk/tsp-svn-helper/tsh-common.h	2007-06-27 22:27:21 UTC (rev 2872)
@@ -23,6 +23,8 @@
 
 gboolean tsh_create_context (svn_client_ctx_t**, apr_pool_t*, svn_error_t**);
 
+void tsh_notify_func2(void *, const svn_wc_notify_t *, apr_pool_t *);
+
 G_END_DECLS
 
 #endif /*__TSH_COMMON_H__*/

Modified: thunar-svn-plugin/trunk/tsp-svn-helper/tsh-update.c
===================================================================
--- thunar-svn-plugin/trunk/tsp-svn-helper/tsh-update.c	2007-06-27 19:01:50 UTC (rev 2871)
+++ thunar-svn-plugin/trunk/tsp-svn-helper/tsh-update.c	2007-06-27 22:27:21 UTC (rev 2872)
@@ -35,46 +35,14 @@
 
 #include "tsh-common.h"
 #include "tsh-dialog-common.h"
-#include "tsh-update-dialog.h"
+#include "tsh-notify-dialog.h"
 
 #include "tsh-update.h"
 
-static void tsh_notify_func2(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool)
-{
-	TshUpdateDialog *dialog = TSH_UPDATE_DIALOG (baton);
-	char buffer[256];
-
-	gdk_threads_enter ();
-
-	switch(notify->action)
-	{
-		case svn_wc_notify_update_delete:
-			tsh_update_dialog_add(dialog, _("Deleted"), notify->path, notify->mime_type);
-			break;
-		case svn_wc_notify_update_add:
-			tsh_update_dialog_add(dialog, _("Added"), notify->path, notify->mime_type);
-			break;
-		case svn_wc_notify_update_update:
-			tsh_update_dialog_add(dialog, _("Updated"), notify->path, notify->mime_type);
-			break;
-		case svn_wc_notify_update_completed:
-			g_snprintf(buffer, 256, _("At revision: %li"), notify->revision);
-			tsh_update_dialog_add(dialog, _("Completed"), buffer, NULL);
-			break;
-		case svn_wc_notify_update_external:
-			tsh_update_dialog_add(dialog, _("External"), notify->path, notify->mime_type);
-			break;
-		default:
-			break;
-	}
-
-	gdk_threads_leave ();
-}
-
 struct thread_args {
 	svn_client_ctx_t *ctx;
 	apr_pool_t *pool;
-	TshUpdateDialog *dialog;
+	TshNotifyDialog *dialog;
 	gchar **files;
 };
 
@@ -86,7 +54,7 @@
 	apr_array_header_t *paths;
 	svn_client_ctx_t *ctx = args->ctx;
 	apr_pool_t *pool = args->pool;
-	TshUpdateDialog *dialog = args->dialog;
+	TshNotifyDialog *dialog = args->dialog;
 	gchar **files = args->files;
 	gint size, i;
 
@@ -110,19 +78,21 @@
 		APR_ARRAY_PUSH (paths, const char *) = ""; // current directory
 	}
 
-	//APR_ARRAY_PUSH (paths, const char *) = "/home/cavalier/xfce/svn/squeeze";
-
   revision.kind = svn_opt_revision_head;
-	if ((err = svn_client_update2(NULL, paths, &revision, TRUE, TRUE, ctx, pool)))
+	if ((err = svn_client_update2(NULL, paths, &revision, TRUE, FALSE, ctx, pool)))
 	{
-		tsh_update_dialog_done (dialog);
+		gdk_threads_enter();
+		tsh_notify_dialog_done (dialog);
+		gdk_threads_leave();
 
 		svn_handle_error2(err, stderr, FALSE, G_LOG_DOMAIN ": ");
 		svn_error_clear(err);
 		return GINT_TO_POINTER (FALSE);
 	}
 
-	tsh_update_dialog_done (dialog);
+	gdk_threads_enter();
+	tsh_notify_dialog_done (dialog);
+	gdk_threads_leave();
 	
 	return GINT_TO_POINTER (TRUE);
 }
@@ -132,7 +102,7 @@
 	GtkWidget *dialog;
 	struct thread_args *args;
 
-	dialog = tsh_update_dialog_new (NULL, NULL, 0);
+	dialog = tsh_notify_dialog_new (NULL, NULL, 0);
 	tsh_dialog_start (GTK_DIALOG (dialog), TRUE);
 
 	ctx->notify_func2 = tsh_notify_func2;
@@ -141,7 +111,7 @@
 	args = g_malloc (sizeof (struct thread_args));
 	args->ctx = ctx;
 	args->pool = pool;
-	args->dialog = TSH_UPDATE_DIALOG (dialog);
+	args->dialog = TSH_NOTIFY_DIALOG (dialog);
 	args->files = files;
 
 	return g_thread_create (update_thread, args, TRUE, NULL);




More information about the Goodies-commits mailing list