[Goodies-commits] r2559 - in thunar-svn-plugin/trunk: . thunar-svn-plugin

Peter de Ridder peter at xfce.org
Sun Mar 18 22:41:06 CET 2007


Author: peter
Date: 2007-03-18 21:41:05 +0000 (Sun, 18 Mar 2007)
New Revision: 2559

Added:
   thunar-svn-plugin/trunk/configure.ac.in
Removed:
   thunar-svn-plugin/trunk/configure.in.in
Modified:
   thunar-svn-plugin/trunk/autogen.sh
   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-backend.c
   thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-backend.h
Log:
Check for file version control too


Modified: thunar-svn-plugin/trunk/autogen.sh
===================================================================
--- thunar-svn-plugin/trunk/autogen.sh	2007-03-17 21:07:25 UTC (rev 2558)
+++ thunar-svn-plugin/trunk/autogen.sh	2007-03-18 21:41:05 UTC (rev 2559)
@@ -30,7 +30,7 @@
 revision=`LC_ALL=C svn info $0 | awk '/^Revision: / {printf "%05d\n", $2}'`
 sed -e "s/@LINGUAS@/${linguas}/g" \
     -e "s/@REVISION@/${revision}/g" \
-    < "configure.in.in" > "configure.in"
+    < "configure.ac.in" > "configure.in"
 
 exec xdt-autogen $@
 

Copied: thunar-svn-plugin/trunk/configure.ac.in (from rev 2557, thunar-svn-plugin/trunk/configure.in.in)
===================================================================
--- thunar-svn-plugin/trunk/configure.ac.in	                        (rev 0)
+++ thunar-svn-plugin/trunk/configure.ac.in	2007-03-18 21:41:05 UTC (rev 2559)
@@ -0,0 +1,176 @@
+dnl $Id: configure.in.in 2439 2007-01-20 10:41:39Z benny $
+dnl
+dnl Copyright (c) 2006-2007
+dnl         The Thunar development team. All rights reserved.
+dnl
+dnl Originally written for Thunar by Benedikt Meurer <benny at xfce.org>.
+dnl Modified by Peter de Ridder <peter at xfce.org>.
+dnl
+
+dnl ***************************
+dnl *** Version information ***
+dnl ***************************
+m4_define([tsp_version_major], [0])
+m4_define([tsp_version_minor], [0])
+m4_define([tsp_version_micro], [1])
+m4_define([tsp_version_build], [r at REVISION@])
+m4_define([tsp_version_tag], [svn])
+m4_define([tsp_version], [tsp_version_major().tsp_version_minor().tsp_version_micro()ifelse(tsp_version_tag(), [], [], [tsp_version_tag()-tsp_version_build()])])
+
+dnl *******************************************
+dnl *** Debugging support for SVN snapshots ***
+dnl *******************************************
+m4_define([tsp_debug_default], [ifelse(tsp_version_tag(), [svn], [yes], [minimum])])
+
+dnl ***************************
+dnl *** Initialize autoconf ***
+dnl ***************************
+AC_COPYRIGHT([Copyright (c) 2006-2007 Peter de Ridder <peter at xfce.org>.])
+AC_INIT([thunar-svn-plugin], [tsp_version()], [thunar-dev at xfce.org])
+AC_PREREQ([2.50])
+AC_CANONICAL_TARGET()
+AC_REVISION([$Id: configure.in.in 2439 2007-01-20 10:41:39Z benny $])
+
+dnl ***************************
+dnl *** Initialize automake ***
+dnl ***************************
+AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar])
+AM_CONFIG_HEADER([config.h])
+AM_MAINTAINER_MODE()
+
+dnl *******************************
+dnl *** Check for UNIX variants ***
+dnl *******************************
+AC_AIX()
+AC_ISC_POSIX()
+AC_MINIX()
+
+dnl ********************************
+dnl *** Check for basic programs ***
+dnl ********************************
+AC_PROG_CC()
+AC_PROG_LD()
+AC_PROG_INSTALL()
+AM_PROG_CC_C_O()
+
+dnl **************************
+dnl *** Initialize libtool ***
+dnl **************************
+AC_DISABLE_STATIC()
+AC_PROG_LIBTOOL()
+
+dnl ******************************
+dnl *** Check for i18n support ***
+dnl ******************************
+XDT_I18N([@LINGUAS@])
+
+dnl ***********************************
+dnl *** Check for required packages ***
+dnl ***********************************
+XDT_CHECK_PACKAGE([THUNARX], [thunarx-1], [0.4.0])
+XDT_CHECK_PACKAGE([THUNAR_VFS], [thunar-vfs-1], [0.4.0])
+XDT_CHECK_PACKAGE([APR], [apr-1], [1.2.7])
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
+XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.6.0])
+XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.6.0])
+AC_CHECK_LIB([svn_subr-1], [main], ,
+[
+	echo "*** The required library 'svn_subr-1' was not found on your system."
+	echo "*** Please install libsvn (atleast version 1.4)."
+	exit 1
+])
+AC_CHECK_LIB([svn_fs-1], [main], ,
+[
+	echo "*** The required library 'svn_fs-1' was not found on your system."
+	echo "*** Please install libsvn (atleast version 1.4)."
+	exit 1
+])
+AC_CHECK_LIB([svn_wc-1], [main], ,
+[
+	echo "*** The required library 'svn_wc-1' was not found on your system."
+	echo "*** Please install libsvn (atleast version 1.4)."
+	exit 1
+])
+AC_CHECK_LIB([svn_client-1], [main], ,
+[
+	echo "*** The required library 'svn_wc-1' was not found on your system."
+	echo "*** Please install libsvn (atleast version 1.4)."
+	exit 1
+])
+
+dnl ***********************************
+dnl *** Check for debugging support ***
+dnl ***********************************
+AC_ARG_ENABLE([debug],
+AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes/full@:>@], [Turn on debugging @<:@default=tsp_debug_default@:>@]),
+  [], [enable_debug=tsp_debug_default])
+AC_MSG_CHECKING([whether to enable debugging support])
+if test x"$enable_debug" = x"full" -o x"$enable_debug" = x"yes"; then
+  dnl Check whether the compiler accepts the -fno-strict-aliasing
+  dnl switch, as certain packages - like Glib - still don't work
+  dnl properly with newer compilers.
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -fno-strict-aliasing"
+  AC_MSG_CHECKING([whether $CC accepts -fno-strict-aliasing])
+  AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [
+    AC_MSG_RESULT([yes])
+    PLATFORM_CFLAGS="$PLATFORM_CFLAGS -fno-strict-aliasing"
+  ], [
+    AC_MSG_RESULT([no])
+  ])
+  CFLAGS="$save_CFLAGS"
+
+  dnl Make sure we detect possible errors
+  PLATFORM_CFLAGS="$PLATFORM_CFLAGS -Werror -Wall"
+
+  dnl Paranoia for --enable-debug=full
+  if test x"$enable_debug" = x"full"; then
+    PLATFORM_CFLAGS="$PLATFORM_CFLAGS -O0 -g3"
+    PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DG_DISABLE_DEPRECATED -DG_ENABLE_DEBUG"
+  fi
+else
+  dnl Disable object cast checks
+  PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DG_DISABLE_CAST_CHECKS"
+
+  dnl Disable all checks for --enable-debug=no
+  if test x"$enable_debug" = x"no"; then
+    PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
+  fi
+fi
+AC_MSG_RESULT([$enable_debug])
+
+dnl **************************************
+dnl *** Check for linker optimizations ***
+dnl **************************************
+AC_MSG_CHECKING([whether $LD accepts -O1])
+case `$LD -O1 -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -Wl,-O1"
+  AC_MSG_RESULT([yes])
+  ;;
+*)
+  AC_MSG_RESULT([no])
+  ;;
+esac
+
+dnl *********************************
+dnl *** Substitute platform flags ***
+dnl *********************************
+AC_MSG_CHECKING([PLATFORM_CPPFLAGS])
+AC_MSG_RESULT([$PLATFORM_CPPFLAGS])
+AC_SUBST([PLATFORM_CPPFLAGS])
+AC_MSG_CHECKING([PLATFORM_CFLAGS])
+AC_MSG_RESULT([$PLATFORM_CFLAGS])
+AC_SUBST([PLATFORM_CFLAGS])
+AC_MSG_CHECKING([PLATFORM_LDFLAGS])
+AC_MSG_RESULT([$PLATFORM_LDFLAGS])
+AC_SUBST([PLATFORM_LDFLAGS])
+
+AC_OUTPUT([
+Makefile
+icons/Makefile
+icons/16x16/Makefile
+po/Makefile.in
+thunar-svn-plugin/Makefile
+])
+

Deleted: thunar-svn-plugin/trunk/configure.in.in

Modified: thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-provider.c
===================================================================
--- thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-provider.c	2007-03-17 21:07:25 UTC (rev 2558)
+++ thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-provider.c	2007-03-18 21:41:05 UTC (rev 2559)
@@ -25,6 +25,10 @@
 #include <unistd.h>
 #endif
 
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
 #include <thunar-vfs/thunar-vfs.h>
 
 #include <thunar-svn-plugin/tsp-svn-backend.h>
@@ -217,6 +221,108 @@
 
 
 
+static GSList *
+tsp_get_parent_status (ThunarxFileInfo *file_info)
+{
+  GSList *result = NULL;
+  gchar  *filename;
+  gchar  *uri;
+
+  /* determine the parent URI for the file info */
+  uri = thunarx_file_info_get_parent_uri (file_info);
+  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))
+        {
+          /* check if the folder is a working copy */
+          result = tsp_svn_backend_get_status (filename);
+
+          /* release the filename */
+          g_free (filename);
+        }
+
+      /* release the URI */
+      g_free (uri);
+    }
+
+  return result;
+}
+
+
+
+gint
+tsp_compare_filename (const gchar *uri1, const gchar *uri2)
+{
+	/* strip the "file://" part of the uri */
+	if (strncmp (uri1, "file://", 7) == 0)
+	{
+		uri1 += 7;
+	}
+
+	/* strip the "file://" part of the uri */
+	if (strncmp (uri2, "file://", 7) == 0)
+	{
+		uri2 += 7;
+	}
+
+	gchar *path1 = g_strdup (uri1);
+	gchar *path2 = g_strdup (uri2);
+
+	/* remove trailing '/' */
+	if (path1[strlen (path1) - 1] == '/')
+	{
+		path1[strlen (path1) - 1] = '\0';
+	}
+
+	/* remove trailing '/'*/
+	if (path2[strlen (path2) - 1] == '/')
+	{
+		path2[strlen (path2) - 1] = '\0';
+	}
+	
+	gint result = strcmp (path1, path2);
+
+	g_free (path1);
+	g_free (path2);
+
+	return result;
+}
+
+
+
+static gint
+tsp_compare_path (TspSvnFileStatus *file_status, ThunarxFileInfo *file_info)
+{
+  gint   result = 1;
+  gchar *filename;
+  gchar *uri;
+
+  /* determine the parent URI for the file info */
+  uri = thunarx_file_info_get_uri (file_info);
+  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))
+        {
+          /* check if the folder is a working copy */
+          result = tsp_compare_filename (file_status->path, filename);
+
+          /* release the filename */
+          g_free (filename);
+        }
+
+      /* release the URI */
+      g_free (uri);
+    }
+
+	return result;
+}
+
+
+
 static GList*
 tsp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
                                GtkWidget           *window,
@@ -225,15 +331,19 @@
   ThunarVfsPathScheme scheme;
   ThunarVfsInfo      *info;
   gboolean            parent_wc = FALSE;
-	gboolean            one_is_wc = FALSE;
-	gboolean            one_is_not_wc = FALSE;
-	gboolean            one_is_directory = FALSE;
-	gboolean            one_is_file = FALSE;
+	gboolean            directory_is_wc = FALSE;
+	gboolean            directory_is_not_wc = FALSE;
+	gboolean            file_is_vc = FALSE;
+	gboolean            file_is_not_vc = FALSE;
   GtkAction          *action;
   GList              *actions = NULL;
   GList              *lp;
   gint                n_files = 0;
+	GSList             *file_status;
+	GSList             *iter;
 
+	file_status = tsp_get_parent_status (files->data);
+
   /* check all supplied files */
   for (lp = files; lp != NULL; lp = lp->next, ++n_files)
 	{
@@ -252,26 +362,38 @@
 
 		if (thunarx_file_info_is_directory (lp->data))
 		{
-			one_is_directory = TRUE;
 			if (tsp_is_working_copy (lp->data))
 			{
-				one_is_wc = TRUE;
+				directory_is_wc = TRUE;
 				//g_object_set_data(lp->data, TSP_SVN_WORKING_COPY, GINT_TO_POINTER(TRUE));
 			}
 			else
 			{
-				one_is_not_wc = TRUE;
+				directory_is_not_wc = TRUE;
 				//g_object_set_data(lp->data, TSP_SVN_WORKING_COPY, GINT_TO_POINTER(FALSE));
 			}
 		}
 		else
 		{
-			one_is_file = TRUE;
+			for (iter = file_status; iter; iter = iter->next)
+			{
+				if (!tsp_compare_path (iter->data, lp->data))
+				{
+					if (((TspSvnFileStatus*)iter->data)->flag.version_control)
+					{
+						file_is_vc = TRUE;
+					}
+					else
+					{
+						file_is_not_vc = TRUE;
+					}
+				}
+			}
 		}
 	}
 
 	/* is the parent folder a working copy */
-	if (!parent_wc && one_is_not_wc)
+	if (!parent_wc && (directory_is_not_wc || file_is_not_vc))
 	{
 		/* It's not a working copy
 		 * append the "Import" action */
@@ -281,10 +403,10 @@
 													 NULL);
 		actions = g_list_append (actions, action);
 	}
-	if (parent_wc || one_is_wc)
+	if (parent_wc || directory_is_wc)
 	{
 		/* append the svn submenu action */
-		action = tsp_svn_action_new ("Tsp::svn", _("SVN"), FALSE, one_is_directory, one_is_file, parent_wc, one_is_wc, one_is_not_wc);
+		action = tsp_svn_action_new ("Tsp::svn", _("SVN"), FALSE, parent_wc, directory_is_wc, directory_is_not_wc, file_is_vc, file_is_not_vc);
 		actions = g_list_append (actions, action);
 	}
 
@@ -317,7 +439,7 @@
 	if (tsp_is_working_copy (folder))
 	{
 		/* append the svn submenu action */
-		action = tsp_svn_action_new ("Tsp::svn", _("SVN"), TRUE, FALSE, FALSE, TRUE, FALSE, FALSE);
+		action = tsp_svn_action_new ("Tsp::svn", _("SVN"), TRUE, TRUE, FALSE, FALSE, FALSE, FALSE);
 		actions = g_list_append (actions, action);
 	}
 	else
@@ -329,6 +451,9 @@
 													 "label", _("SVN _Checkout"),
 													 NULL);
 		actions = g_list_append (actions, action);
+		/* append the svn submenu action
+		action = tsp_svn_action_new ("Tsp::svn", _("SVN"), TRUE, FASLE, FALSE, FALSE, FALSE, FALSE);
+		actions = g_list_append (actions, action); */
 	}
 
   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-03-17 21:07:25 UTC (rev 2558)
+++ thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-action.c	2007-03-18 21:41:05 UTC (rev 2559)
@@ -40,11 +40,11 @@
 
 	struct {
 		unsigned is_parent : 1;
-		unsigned is_directory : 1;
-		unsigned is_file : 1;
 		unsigned parent_version_control : 1;
-		unsigned version_control : 1;
-		unsigned no_version_control : 1;
+		unsigned directory_version_control : 1;
+		unsigned directory_no_version_control : 1;
+		unsigned file_version_control : 1;
+		unsigned file_no_version_control : 1;
 	} property;
 };
 
@@ -52,11 +52,11 @@
 
 enum {
 	PROPERTY_IS_PARENT = 1,
-	PROPERTY_IS_DIRECTORY,
-	PROPERTY_IS_FILE,
 	PROPERTY_PARENT_VERSION_CONTROL,
-	PROPERTY_VERSION_CONTROL,
-	PROPERTY_NO_VERSION_CONTROL
+	PROPERTY_DIRECTORY_VERSION_CONTROL,
+	PROPERTY_DIRECTORY_NO_VERSION_CONTROL,
+	PROPERTY_FILE_VERSION_CONTROL,
+	PROPERTY_FILE_NO_VERSION_CONTROL
 };
 
 
@@ -86,20 +86,20 @@
 	g_object_class_install_property (gobject_class, PROPERTY_IS_PARENT,
 		g_param_spec_boolean ("is-parent", "", "", FALSE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
 
-	g_object_class_install_property (gobject_class, PROPERTY_IS_DIRECTORY,
-		g_param_spec_boolean ("is-directory", "", "", FALSE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
-
-	g_object_class_install_property (gobject_class, PROPERTY_IS_FILE,
-		g_param_spec_boolean ("is-file", "", "", FALSE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
-
 	g_object_class_install_property (gobject_class, PROPERTY_PARENT_VERSION_CONTROL,
 		g_param_spec_boolean ("parent-version-control", "", "", FALSE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
 
-	g_object_class_install_property (gobject_class, PROPERTY_VERSION_CONTROL,
-		g_param_spec_boolean ("version-control", "", "", FALSE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+	g_object_class_install_property (gobject_class, PROPERTY_DIRECTORY_VERSION_CONTROL,
+		g_param_spec_boolean ("directory-version-control", "", "", FALSE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
 
-	g_object_class_install_property (gobject_class, PROPERTY_NO_VERSION_CONTROL,
-		g_param_spec_boolean ("no-version-control", "", "", FALSE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+	g_object_class_install_property (gobject_class, PROPERTY_DIRECTORY_NO_VERSION_CONTROL,
+		g_param_spec_boolean ("directory-no-version-control", "", "", FALSE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+
+	g_object_class_install_property (gobject_class, PROPERTY_FILE_VERSION_CONTROL,
+		g_param_spec_boolean ("file-version-control", "", "", FALSE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+
+	g_object_class_install_property (gobject_class, PROPERTY_FILE_NO_VERSION_CONTROL,
+		g_param_spec_boolean ("file-no-version-control", "", "", FALSE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
 }
 
 
@@ -108,11 +108,11 @@
 tsp_svn_action_init (TspSvnAction *self)
 {
 	self->property.is_parent = 0;
-	self->property.is_directory = 0;
-	self->property.is_file = 0;
 	self->property.parent_version_control = 0;
-	self->property.version_control = 0;
-	self->property.no_version_control = 0;
+	self->property.directory_version_control = 0;
+	self->property.directory_no_version_control = 0;
+	self->property.file_version_control = 0;
+	self->property.file_no_version_control = 0;
 }
 
 
@@ -121,11 +121,11 @@
 tsp_svn_action_new (const gchar *name,
                     const gchar *label,
 										gboolean is_parent,
-										gboolean is_directory,
-										gboolean is_file,
 										gboolean parent_version_control,
-										gboolean version_control,
-										gboolean no_version_control)
+										gboolean directory_version_control,
+										gboolean directory_no_version_control,
+										gboolean file_version_control,
+										gboolean file_no_version_control)
 {
 	g_return_val_if_fail(name, NULL);
 	g_return_val_if_fail(label, NULL);
@@ -135,11 +135,11 @@
 											 "name", name,
 											 "label", label,
 											 "is-parent", is_parent,
-											 "is-directory", is_directory,
-											 "is-file", is_file,
 											 "parent-version-control", parent_version_control,
-											 "version-control", version_control,
-											 "no-version-control", no_version_control,
+											 "directory-version-control", directory_version_control,
+											 "directory-no-version-control", directory_no_version_control,
+											 "file-version-control", file_version_control,
+											 "file-no-version-control", file_no_version_control,
 											 NULL);
 }
 
@@ -153,21 +153,21 @@
 		case PROPERTY_IS_PARENT:
 			TSP_SVN_ACTION (object)->property.is_parent = g_value_get_boolean (value)?1:0;
 		break;
-		case PROPERTY_IS_DIRECTORY:
-			TSP_SVN_ACTION (object)->property.is_directory = g_value_get_boolean (value)?1:0;
-		break;
-		case PROPERTY_IS_FILE:
-			TSP_SVN_ACTION (object)->property.is_file = g_value_get_boolean (value)?1:0;
-		break;
 		case PROPERTY_PARENT_VERSION_CONTROL:
 			TSP_SVN_ACTION (object)->property.parent_version_control = g_value_get_boolean (value)?1:0;
 		break;
-		case PROPERTY_VERSION_CONTROL:
-			TSP_SVN_ACTION (object)->property.version_control = g_value_get_boolean (value)?1:0;
+		case PROPERTY_DIRECTORY_VERSION_CONTROL:
+			TSP_SVN_ACTION (object)->property.directory_version_control = g_value_get_boolean (value)?1:0;
 		break;
-		case PROPERTY_NO_VERSION_CONTROL:
-			TSP_SVN_ACTION (object)->property.no_version_control = g_value_get_boolean (value)?1:0;
+		case PROPERTY_DIRECTORY_NO_VERSION_CONTROL:
+			TSP_SVN_ACTION (object)->property.directory_no_version_control = g_value_get_boolean (value)?1:0;
 		break;
+		case PROPERTY_FILE_VERSION_CONTROL:
+			TSP_SVN_ACTION (object)->property.file_version_control = g_value_get_boolean (value)?1:0;
+		break;
+		case PROPERTY_FILE_NO_VERSION_CONTROL:
+			TSP_SVN_ACTION (object)->property.file_no_version_control = g_value_get_boolean (value)?1:0;
+		break;
 	}
 }
 
@@ -185,14 +185,14 @@
 	menu = gtk_menu_new ();
 	gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
 	/* No version control */
-	if (tsp_action->property.parent_version_control && tsp_action->property.no_version_control && !tsp_action->property.is_parent) 
+	if (!tsp_action->property.is_parent && tsp_action->property.parent_version_control && (tsp_action->property.directory_no_version_control || tsp_action->property.file_no_version_control)) 
 	{
 		subitem = gtk_menu_item_new_with_label (_("Add"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 		gtk_widget_show(subitem);
 	}
 	/* Version control (file) */
-	if (tsp_action->property.parent_version_control && tsp_action->property.version_control && tsp_action->property.is_file) 
+	if (tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Blame"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
@@ -207,14 +207,14 @@
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 	gtk_widget_show(subitem);
 *//* Version control (parent) */
-	if (tsp_action->property.parent_version_control && tsp_action->property.is_parent) 
+	if (tsp_action->property.is_parent && tsp_action->property.parent_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Cleanup"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 		gtk_widget_show(subitem);
 	}
 	/* Version control (all) */
-	if (tsp_action->property.parent_version_control || (tsp_action->property.version_control && !tsp_action->property.is_parent) )
+	if ((tsp_action->property.is_parent && tsp_action->property.parent_version_control) || tsp_action->property.directory_version_control || tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Commit"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
@@ -225,21 +225,21 @@
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 	gtk_widget_show(subitem);
 *//* Version control (no parent) */
-	if (tsp_action->property.parent_version_control && tsp_action->property.version_control && !tsp_action->property.is_parent) 
+	if (!tsp_action->property.is_parent && tsp_action->property.parent_version_control && (tsp_action->property.directory_version_control || tsp_action->property.file_version_control))
 	{
 		subitem = gtk_menu_item_new_with_label (_("Delete"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 		gtk_widget_show(subitem);
 	}
 	/* Version control (file) */
-	if (tsp_action->property.parent_version_control && tsp_action->property.version_control && tsp_action->property.is_file) 
+	if (tsp_action->property.file_version_control) 
 	{
 		subitem = gtk_menu_item_new_with_label (_("Diff"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 		gtk_widget_show(subitem);
 	}
 	/* Version control */
-	if (tsp_action->property.parent_version_control || (tsp_action->property.version_control && !tsp_action->property.is_parent))
+	if ((tsp_action->property.is_parent && tsp_action->property.parent_version_control) || tsp_action->property.directory_version_control || tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Export"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
@@ -250,7 +250,7 @@
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 	gtk_widget_show(subitem);
 *//* Version control (all) */
-	if (tsp_action->property.parent_version_control || (tsp_action->property.version_control && tsp_action->property.is_parent))
+	if ((tsp_action->property.is_parent && tsp_action->property.parent_version_control) || tsp_action->property.directory_version_control || tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Info"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
@@ -261,14 +261,14 @@
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 	gtk_widget_show(subitem);
 *//* Version control (all) */
-	if (tsp_action->property.parent_version_control || (tsp_action->property.version_control && tsp_action->property.is_parent))
+	if ((tsp_action->property.is_parent && tsp_action->property.parent_version_control) || tsp_action->property.directory_version_control || tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Lock"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 		gtk_widget_show(subitem);
 	}
 	/* Version control (all) */
-	if (tsp_action->property.parent_version_control || (tsp_action->property.version_control && tsp_action->property.is_parent))
+	if ((tsp_action->property.is_parent && tsp_action->property.parent_version_control) || tsp_action->property.directory_version_control || tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Log"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
@@ -293,7 +293,7 @@
 	subitem = gtk_menu_item_new_with_label (_("List Properties"));
 	subitem = gtk_menu_item_new_with_label (_("Set Properties"));
 *//* Version control */
-	if (tsp_action->property.parent_version_control || (tsp_action->property.version_control && tsp_action->property.is_parent))
+	if ((tsp_action->property.is_parent && tsp_action->property.parent_version_control) || tsp_action->property.directory_version_control || tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Edit Properties"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
@@ -302,42 +302,42 @@
 /* Changed
 	subitem = gtk_menu_item_new_with_label (_("Mark Resolved"));
 *//* Version control (file) */
-	if (tsp_action->property.parent_version_control && tsp_action->property.version_control && tsp_action->property.is_file)
+	if (tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Resolve"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 		gtk_widget_show(subitem);
 	}
 	/* Version control (all) */
-	if (tsp_action->property.parent_version_control || (tsp_action->property.version_control && tsp_action->property.is_parent))
+	if ((tsp_action->property.is_parent && tsp_action->property.parent_version_control) || tsp_action->property.directory_version_control || tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Revert"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 		gtk_widget_show(subitem);
 	}
 	/* Version control (all) */
-	if (tsp_action->property.parent_version_control || (tsp_action->property.version_control && tsp_action->property.is_parent))
+	if ((tsp_action->property.is_parent && tsp_action->property.parent_version_control) || tsp_action->property.directory_version_control || tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Status"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 		gtk_widget_show(subitem);
 	}
 	/* Version control (parent) */
-	if (tsp_action->property.version_control && tsp_action->property.is_parent)
+	if (tsp_action->property.is_parent && tsp_action->property.parent_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Switch"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 		gtk_widget_show(subitem);
 	}
 	/* Version control (all) */
-	if (tsp_action->property.parent_version_control || (tsp_action->property.version_control && tsp_action->property.is_parent))
+	if ((tsp_action->property.is_parent && tsp_action->property.parent_version_control) || tsp_action->property.directory_version_control || tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Unlock"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
 		gtk_widget_show(subitem);
 	}
 	/* Version control (all) */
-	if (tsp_action->property.parent_version_control || (tsp_action->property.version_control && tsp_action->property.is_parent))
+	if ((tsp_action->property.is_parent && tsp_action->property.parent_version_control) || tsp_action->property.directory_version_control || tsp_action->property.file_version_control)
 	{
 		subitem = gtk_menu_item_new_with_label (_("Update"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);

Modified: thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-backend.c
===================================================================
--- thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-backend.c	2007-03-17 21:07:25 UTC (rev 2558)
+++ thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-backend.c	2007-03-18 21:41:05 UTC (rev 2559)
@@ -21,7 +21,7 @@
 #include <config.h>
 #endif
 
-#include <thunarx/thunarx.h>
+#include <glib.h>
 
 #include <subversion-1/svn_cmdline.h>
 #include <subversion-1/svn_client.h>
@@ -34,6 +34,7 @@
 
 
 static apr_pool_t *pool = NULL;
+static svn_client_ctx_t *ctx = NULL;
 
 
 gboolean
@@ -70,6 +71,14 @@
 	}
 #endif
 
+	err = svn_client_create_context (&ctx, pool);
+	if(err)
+		return FALSE;
+
+	err = svn_config_get_config (&(ctx->config), NULL, pool);
+	if(err)
+		return FALSE;
+
 	/* We are ready now */
 
 	return TRUE;
@@ -111,3 +120,75 @@
 	return TRUE;
 }
 
+
+
+static void
+status_callback (void *baton, const char *path, svn_wc_status2_t *status)
+{
+	GSList **list = baton;
+	TspSvnFileStatus *entry = g_new (TspSvnFileStatus, 1);
+	
+	entry->path = g_strdup (path);
+	switch (status->text_status)
+	{
+		case svn_wc_status_normal:
+		case svn_wc_status_added:
+		case svn_wc_status_missing:
+		case svn_wc_status_deleted:
+		case svn_wc_status_replaced:
+		case svn_wc_status_modified:
+		case svn_wc_status_merged:
+		case svn_wc_status_conflicted:
+		case svn_wc_status_incomplete:
+			entry->flag.version_control = 1;
+		break;
+		default:
+			entry->flag.version_control = 0;
+		break;
+	}
+
+	*list = g_slist_prepend (*list, entry);
+}
+
+
+
+GSList *
+tsp_svn_backend_get_status (const gchar *uri)
+{
+	svn_error_t *err;
+	svn_opt_revision_t revision = {svn_opt_revision_working};
+	GSList *list = NULL;
+
+	/* strip the "file://" part of the uri */
+	if (strncmp (uri, "file://", 7) == 0)
+	{
+		uri += 7;
+	}
+
+	gchar *path = g_strdup (uri);
+
+	/* remove trailing '/' cause svn_client_status2 can't handle that */
+	if (path[strlen (path) - 1] == '/')
+	{
+		path[strlen (path) - 1] = '\0';
+	}
+
+	/* check for the path is a working copy */
+	err = svn_client_status2 (NULL, path, &revision, status_callback, &list, FALSE, TRUE, FALSE, TRUE, TRUE, ctx, pool);
+
+	g_free (path);
+
+	if (err)
+	{
+		GSList *iter;
+		for (iter = list; iter; iter = iter->next)
+		{
+			g_free (iter->data);
+		}
+		g_slist_free (list);
+		return NULL;
+	}
+
+	return list;
+}
+

Modified: thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-backend.h
===================================================================
--- thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-backend.h	2007-03-17 21:07:25 UTC (rev 2558)
+++ thunar-svn-plugin/trunk/thunar-svn-plugin/tsp-svn-backend.h	2007-03-18 21:41:05 UTC (rev 2559)
@@ -24,10 +24,20 @@
 
 G_BEGIN_DECLS;
 
+typedef struct
+{
+	gchar *path;
+	struct {
+		unsigned version_control : 1;
+	} flag;
+} TspSvnFileStatus;
+
 gboolean tsp_svn_backend_init();
 
 gboolean tsp_svn_backend_is_working_copy (const gchar *uri);
 
+GSList  *tsp_svn_backend_get_status (const gchar *uri);
+
 G_END_DECLS;
 
 #endif /* !__TSP_SVN_BACKEND_H__ */




More information about the Goodies-commits mailing list