[f-spot] Fixes bug #618798, getting rid of gnomeVfs



commit e3b20d283e38a1e9b1f297b24753a8d1801bacab
Author: Paul Wellner Bou <paul purecodes org>
Date:   Mon May 17 17:03:05 2010 +0200

    Fixes bug #618798, getting rid of gnomeVfs
    
    Original patch by and all credits to Lorenzo Milesi <maxxer yetopen it>.

 extensions/Exporters/FolderExport/FolderExport.cs |  103 ++++----------------
 1 files changed, 21 insertions(+), 82 deletions(-)
---
diff --git a/extensions/Exporters/FolderExport/FolderExport.cs b/extensions/Exporters/FolderExport/FolderExport.cs
index 06dd22e..7bab676 100644
--- a/extensions/Exporters/FolderExport/FolderExport.cs
+++ b/extensions/Exporters/FolderExport/FolderExport.cs
@@ -74,7 +74,7 @@ namespace FSpotFolderExport {
 
 		private Glade.XML xml;
 		private string dialog_name = "folder_export_dialog";
-		Gnome.Vfs.Uri dest;
+		GLib.File dest;
 		Gtk.FileChooserButton uri_chooser;
 
 		int photo_index;
@@ -87,7 +87,7 @@ namespace FSpotFolderExport {
 
 		string description;
 		string gallery_name = "Gallery";
-		// FIME this needs to be a real temp directory
+		// FIXME this needs to be a real temp directory
 		string gallery_path = Path.Combine (Path.GetTempPath (), "f-spot-original-" + System.DateTime.Now.Ticks.ToString ());
 
 		ThreadProgressDialog progress_dialog;
@@ -97,27 +97,6 @@ namespace FSpotFolderExport {
 		{}
 		public void Run (IBrowsableCollection selection)
 		{
-			/*
-			Gnome.Vfs.ModuleCallbackFullAuthentication auth = new Gnome.Vfs.ModuleCallbackFullAuthentication ();
-			auth.Callback += new Gnome.Vfs.ModuleCallbackHandler (HandleAuth);
-			auth.SetDefault ();
-			auth.Push ();
-
-			Gnome.Vfs.ModuleCallbackAuthentication mauth = new Gnome.Vfs.ModuleCallbackAuthentication ();
-			mauth.Callback += new Gnome.Vfs.ModuleCallbackHandler (HandleAuth);
-			mauth.SetDefault ();
-			mauth.Push ();
-
-			Gnome.Vfs.ModuleCallbackSaveAuthentication sauth = new Gnome.Vfs.ModuleCallbackSaveAuthentication ();
-			sauth.Callback += new Gnome.Vfs.ModuleCallbackHandler (HandleAuth);
-			sauth.SetDefault ();
-			sauth.Push ();
-
-			Gnome.Vfs.ModuleCallbackStatusMessage msg = new Gnome.Vfs.ModuleCallbackStatusMessage ();
-			msg.Callback += new Gnome.Vfs.ModuleCallbackHandler (HandleMsg);
-			msg.SetDefault ();
-			msg.Push ();
-			*/
 			this.selection = selection;
 
 			IconView view = (IconView) new IconView (selection);
@@ -143,7 +122,7 @@ namespace FSpotFolderExport {
 			uri_chooser.LocalOnly = false;
 
 			if (!String.IsNullOrEmpty (Preferences.Get<string> (URI_KEY)))
-				uri_chooser.SetUri (Preferences.Get<string> (URI_KEY));
+				uri_chooser.SetCurrentFolderUri (Preferences.Get<string> (URI_KEY));
 			else
 				uri_chooser.SetFilename (uri_path);
 
@@ -183,17 +162,16 @@ namespace FSpotFolderExport {
 		{
 			// FIXME use mkstemp
 
-			Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok;
+			bool result = true;
 
 			try {
 				Dialog.Hide ();
 
-				Gnome.Vfs.Uri source = new Gnome.Vfs.Uri (Path.Combine (gallery_path, gallery_name));
-				Gnome.Vfs.Uri target = dest.Clone();
-				target = target.AppendFileName(source.ExtractShortName ());
+				GLib.File source = GLib.FileFactory.NewForPath (Path.Combine (gallery_path, gallery_name));
+				GLib.File target = GLib.FileFactory.NewForPath (Path.Combine (dest.Path, source.Basename));
 
-				if (dest.IsLocal)
-					gallery_path = Gnome.Vfs.Uri.GetLocalPathFromUri (dest.ToString ());
+				if (dest.IsNative)
+					gallery_path = dest.Path;
 
 				progress_dialog.Message = Catalog.GetString ("Building Gallery");
 				progress_dialog.Fraction = 0.0;
@@ -268,32 +246,25 @@ namespace FSpotFolderExport {
 						(gallery as OriginalGallery).CreateZip ();
 				}
 
-				// we've created the structure, now if the destination was local we are done
+				// we've created the structure, now if the destination was local (native) we are done
 				// otherwise we xfer
-				if (!dest.IsLocal) {
-					Console.WriteLine(target);
+				if (!dest.IsNative) {
 					System.Console.WriteLine ("Xfering {0} to {1}", source.ToString (), target.ToString ());
-					result = Gnome.Vfs.Xfer.XferUri (source, target,
-									 Gnome.Vfs.XferOptions.Default,
-									 Gnome.Vfs.XferErrorMode.Abort,
-									 Gnome.Vfs.XferOverwriteMode.Replace,
-									 Progress);
+					result = source.Copy (target, GLib.FileCopyFlags.Overwrite, null, Progress);
 				}
 
-				if (result == Gnome.Vfs.Result.Ok) {
-
+				if (result == true) {
 					progress_dialog.Message = Catalog.GetString ("Done Sending Photos");
 					progress_dialog.Fraction = 1.0;
 					progress_dialog.ProgressText = Catalog.GetString ("Transfer Complete");
 					progress_dialog.ButtonLabel = Gtk.Stock.Ok;
-
 				} else {
 					progress_dialog.ProgressText = result.ToString ();
 					progress_dialog.Message = Catalog.GetString ("Error While Transferring");
 				}
 
 				if (open) {
-					GtkBeans.Global.ShowUri (Dialog.Screen, target.ToString ());
+					GtkBeans.Global.ShowUri (Dialog.Screen, target.Uri.ToString () );
 				}
 
 				// Save these settings for next time
@@ -312,52 +283,20 @@ namespace FSpotFolderExport {
 			} finally {
 				// if the destination isn't local then we want to remove the temp directory we
 				// created.
-				if (!dest.IsLocal)
+				if (!dest.IsNative)
 					System.IO.Directory.Delete (gallery_path, true);
 
 				Gtk.Application.Invoke (delegate { Dialog.Destroy(); });
-
 			}
 		}
 
-		private int Progress (Gnome.Vfs.XferProgressInfo info)
+		private void Progress (long current_num_bytes, long total_num_bytes)
 		{
-			progress_dialog.ProgressText = info.Phase.ToString ();
+			progress_dialog.ProgressText = Catalog.GetString ("copying...");
 
-			if (info.BytesTotal > 0) {
-				progress_dialog.Fraction = info.BytesCopied / (double)info.BytesTotal;
+			if (total_num_bytes > 0) {
+				progress_dialog.Fraction = current_num_bytes / (double)total_num_bytes;
 			}
-
-			switch (info.Status) {
-			case Gnome.Vfs.XferProgressStatus.Vfserror:
-				progress_dialog.Message = Catalog.GetString ("Error: Error while transferring; Aborting");
-				return (int)Gnome.Vfs.XferErrorAction.Abort;
-			case Gnome.Vfs.XferProgressStatus.Overwrite:
-				progress_dialog.ProgressText = Catalog.GetString ("Error: File Already Exists; Aborting");
-				return (int)Gnome.Vfs.XferOverwriteAction.Abort;
-			default:
-				return 1;
-			}
-
-		}
-
-		private void HandleMsg (Gnome.Vfs.ModuleCallback cb)
-		{
-			Gnome.Vfs.ModuleCallbackStatusMessage msg = cb as Gnome.Vfs.ModuleCallbackStatusMessage;
-			System.Console.WriteLine ("{0}", msg.Message);
-		}
-
-		private void HandleAuth (Gnome.Vfs.ModuleCallback cb)
-		{
-			Gnome.Vfs.ModuleCallbackFullAuthentication fcb = cb as Gnome.Vfs.ModuleCallbackFullAuthentication;
-			System.Console.Write ("Enter your username ({0}): ", fcb.Username);
-			string username = System.Console.ReadLine ();
-			System.Console.Write ("Enter your password : ");
-			string passwd = System.Console.ReadLine ();
-
-			if (username.Length > 0)
-				fcb.Username = username;
-			fcb.Password = passwd;
 		}
 
 		private void HandleResponse (object sender, Gtk.ResponseArgs args)
@@ -373,7 +312,7 @@ namespace FSpotFolderExport {
 				return;
 			}
 
-			dest = new Gnome.Vfs.Uri (uri_chooser.Uri);
+			dest = GLib.FileFactory.NewForUri (uri_chooser.Uri);
 			open = open_check.Active;
 			scale = scale_check.Active;
 			rotate = rotate_check.Active;
@@ -534,7 +473,7 @@ namespace FSpotFolderExport {
 				if (request.Current.LocalPath == path)
 					request.Preserve(request.Current);
 				else
-					File.Copy (request.Current.LocalPath, path, true);
+					System.IO.File.Copy (request.Current.LocalPath, path, true);
 
 				if (photo != null && photo is Photo && App.Instance.Database != null) {
 					App.Instance.Database.Exports.Create ((photo as Photo).Id, (photo as Photo).DefaultVersionId,
@@ -1099,7 +1038,7 @@ namespace FSpotFolderExport {
 
 			writer.Write (Catalog.GetString ("Gallery generated by") + " ");
 
-			writer.AddAttribute ("href", "http://www.gnome.org/projects/f-spot";);
+			writer.AddAttribute ("href", "http://f-spot.org";);
 			writer.RenderBeginTag ("a");
 			writer.Write (String.Format ("{0} {1}", FSpot.Defines.PACKAGE, FSpot.Defines.VERSION));
 			writer.RenderEndTag ();



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