[f-spot] Switch Application.Invoke to ThreadAssist.



commit 4bc844f93862c975e890ec7c866b7f8927510081
Author: Ruben Vermeersch <ruben savanne be>
Date:   Wed Jul 21 17:05:48 2010 +0200

    Switch Application.Invoke to ThreadAssist.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=618986

 extensions/Exporters/CDExport/CDExport.cs          |   17 +++++++----------
 .../FacebookExport/FacebookExportDialog.cs         |   14 +++++++-------
 extensions/Exporters/FlickrExport/FlickrExport.cs  |   12 +++++-------
 extensions/Exporters/FolderExport/FolderExport.cs  |    7 +++----
 .../Tools/LiveWebGallery/LiveWebGalleryDialog.cs   |    3 ++-
 src/PixbufCache.cs                                 |    2 +-
 src/TimeAdaptor.cs                                 |    3 +--
 src/UriCollection.cs                               |    2 +-
 8 files changed, 27 insertions(+), 33 deletions(-)
---
diff --git a/extensions/Exporters/CDExport/CDExport.cs b/extensions/Exporters/CDExport/CDExport.cs
index 725196d..3c88b7d 100644
--- a/extensions/Exporters/CDExport/CDExport.cs
+++ b/extensions/Exporters/CDExport/CDExport.cs
@@ -144,10 +144,10 @@ namespace FSpotCDExport {
 			dialog = new CDExportDialog (selection, dest);
 			//LoadHistory ();
 
-                        if (dialog.Run () != (int)ResponseType.Ok) {
-                                dialog.Destroy ();
-                                return;
-                        }
+			if (dialog.Run () != (int)ResponseType.Ok) {
+				dialog.Destroy ();
+				return;
+			}
 
 			clean = dialog.Clean;
 
@@ -240,12 +240,9 @@ namespace FSpotCDExport {
 				progress_dialog.ProgressText = Catalog.GetString ("Error Transferring");
 				return;
 			}
-			Gtk.Application.Invoke (this.Destroy);
-		}
-
-		private void Destroy (object sender, System.EventArgs args)
-		{
-			progress_dialog.Destroy ();
+			ThreadAssist.ProxyToMain (() => {
+				progress_dialog.Destroy ();
+			});
 		}
 
 		private void Progress (long current_num_bytes, long total_num_bytes)
diff --git a/extensions/Exporters/FacebookExport/FacebookExportDialog.cs b/extensions/Exporters/FacebookExport/FacebookExportDialog.cs
index cf6d6e2..9cc7fa7 100644
--- a/extensions/Exporters/FacebookExport/FacebookExportDialog.cs
+++ b/extensions/Exporters/FacebookExport/FacebookExportDialog.cs
@@ -242,7 +242,7 @@ namespace FSpot.Exporter.Facebook
 						bool perm_offline = account.HasPermission("offline_access");
 						bool perm_upload = photo_perm_check.Active = account.HasPermission("photo_upload");
 
-						Gtk.Application.Invoke (delegate {
+						ThreadAssist.ProxyToMain (() => {
 							offline_perm_check.Active = perm_offline;
 							photo_perm_check.Active = perm_upload;
 							LoginProgress (0.2, Catalog.GetString ("Session established, fetching user info..."));
@@ -250,7 +250,7 @@ namespace FSpot.Exporter.Facebook
 	
 						User me = account.Facebook.GetLoggedInUser ().GetUserInfo ();
 	
-						Gtk.Application.Invoke (delegate {
+						ThreadAssist.ProxyToMain (() => {
 							LoginProgress (0.4, Catalog.GetString ("Session established, fetching friend list..."));
 						});
 
@@ -260,7 +260,7 @@ namespace FSpot.Exporter.Facebook
 						for (int i = 0; i < friend_list.Length; i++)
 							uids [i] = friend_list [i].UId;
 	
-						Gtk.Application.Invoke (delegate {
+						ThreadAssist.ProxyToMain (() => {
 							LoginProgress (0.6, Catalog.GetString ("Session established, fetching friend details..."));
 						});
 
@@ -272,11 +272,11 @@ namespace FSpot.Exporter.Facebook
 								friends.Add (user.uid, user);
 						}
 
-						Gtk.Application.Invoke (delegate {
+						ThreadAssist.ProxyToMain (() => {
 							LoginProgress (0.8, Catalog.GetString ("Session established, fetching photo albums..."));
 						});
 						Album[] albums = account.Facebook.GetAlbums ();
-						Gtk.Application.Invoke (delegate {
+						ThreadAssist.ProxyToMain (() => {
 							album_info_vbox.Sensitive = true;
 							picture_info_vbox.Sensitive = true;
 							permissions_hbox.Sensitive = true;
@@ -290,7 +290,7 @@ namespace FSpot.Exporter.Facebook
 						});
 					} catch (Exception e) {
 						Log.DebugException (e);
-						Gtk.Application.Invoke (delegate {
+						ThreadAssist.ProxyToMain (() => {
 							HigMessageDialog error = new HigMessageDialog (this, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal,
 									Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Facebook Connection Error"),
 									String.Format (Catalog.GetString ("There was an error when downloading your information from Facebook.\n\nFacebook said: {0}"), e.Message));
@@ -301,7 +301,7 @@ namespace FSpot.Exporter.Facebook
 						account.Deauthenticate ();
 						DoLogout ();
 					} finally {
-						Gtk.Application.Invoke (delegate {
+						ThreadAssist.ProxyToMain (() => {
 							log_buttons_hbox.Sensitive = true;
 							dialog_action_area.Sensitive = true;
 						});
diff --git a/extensions/Exporters/FlickrExport/FlickrExport.cs b/extensions/Exporters/FlickrExport/FlickrExport.cs
index 680128c..48e8a31 100644
--- a/extensions/Exporters/FlickrExport/FlickrExport.cs
+++ b/extensions/Exporters/FlickrExport/FlickrExport.cs
@@ -243,13 +243,11 @@ namespace FSpotFlickrExport {
 				return;
 			}
 
-			Gtk.Application.Invoke (this, args, delegate (object sender, EventArgs sargs) {
-				AuthorizationEventArgs wargs = (AuthorizationEventArgs) sargs;
-
-				do_export_flickr.Sensitive = wargs.Auth != null;
-				if (wargs.Auth != null) {
-					token = wargs.Auth.Token;
-					auth = wargs.Auth;
+			ThreadAssist.ProxyToMain (() => {
+				do_export_flickr.Sensitive = args.Auth != null;
+				if (args.Auth != null) {
+					token = args.Auth.Token;
+					auth = args.Auth;
 					CurrentState = State.Authorized;
 					Preferences.Set (current_service.PreferencePath, token);
 				} else {
diff --git a/extensions/Exporters/FolderExport/FolderExport.cs b/extensions/Exporters/FolderExport/FolderExport.cs
index 9b8fb43..dbb5252 100644
--- a/extensions/Exporters/FolderExport/FolderExport.cs
+++ b/extensions/Exporters/FolderExport/FolderExport.cs
@@ -158,7 +158,7 @@ namespace FSpotFolderExport {
 			// FIXME use mkstemp
 
 			try {
-				Gtk.Application.Invoke (delegate {Dialog.Hide ();});
+				ThreadAssist.ProxyToMain (Dialog.Hide);
 
 				GLib.File source = GLib.FileFactory.NewForPath (Path.Combine (gallery_path, gallery_name));
 				GLib.File target = GLib.FileFactory.NewForPath (Path.Combine (dest.Path, source.Basename));
@@ -249,7 +249,7 @@ namespace FSpotFolderExport {
 
 				if (open) {
 					Log.DebugFormat (String.Format ("Open URI \"{0}\"", target.Uri.ToString ()));
-					Gtk.Application.Invoke (delegate {GtkBeans.Global.ShowUri (Dialog.Screen, target.Uri.ToString () );});
+					ThreadAssist.ProxyToMain (() => { GtkBeans.Global.ShowUri (Dialog.Screen, target.Uri.ToString () ); });
 				}
 
 				// Save these settings for next time
@@ -270,7 +270,7 @@ namespace FSpotFolderExport {
 				if (!dest.IsNative)
 					System.IO.Directory.Delete (gallery_path, true);
 
-				Gtk.Application.Invoke (delegate { Dialog.Destroy(); });
+				ThreadAssist.ProxyToMain (() => { Dialog.Destroy(); });
 			}
 		}
 
@@ -443,7 +443,6 @@ namespace FSpotFolderExport {
 		public void ProcessImage (int image_num, FilterSet filter_set)
 		{
 			IBrowsableItem photo = collection [image_num];
-			string photo_path = photo.DefaultVersion.Uri.LocalPath;
 			string path;
 			ScaleRequest req;
 
diff --git a/extensions/Tools/LiveWebGallery/LiveWebGalleryDialog.cs b/extensions/Tools/LiveWebGallery/LiveWebGalleryDialog.cs
index 6244757..0982417 100644
--- a/extensions/Tools/LiveWebGallery/LiveWebGalleryDialog.cs
+++ b/extensions/Tools/LiveWebGallery/LiveWebGalleryDialog.cs
@@ -15,6 +15,7 @@ using FSpot.Extensions;
 using FSpot.Query;
 using Gtk;
 using Mono.Unix;
+using Hyena;
 
 namespace LiveWebGalleryExtension
 {
@@ -79,7 +80,7 @@ namespace LiveWebGalleryExtension
 		
 		void HandleStatsChanged (object sender, EventArgs e)
 		{
-			Gtk.Application.Invoke (delegate {
+			ThreadAssist.ProxyToMain (() => {
 				if (last_ip == null || !last_ip.Equals (stats.LastIP)) {
 					last_ip = stats.LastIP;
 					try {
diff --git a/src/PixbufCache.cs b/src/PixbufCache.cs
index 38d9e20..83a8d92 100644
--- a/src/PixbufCache.cs
+++ b/src/PixbufCache.cs
@@ -195,7 +195,7 @@ namespace FSpot {
 		
 		private void QueueLast (CacheEntry entry)
 		{
-			Gtk.Application.Invoke (delegate (object obj, System.EventArgs args) {
+			ThreadAssist.ProxyToMain (() => {
 				if (entry.Uri != null && OnPixbufLoaded != null)
 					OnPixbufLoaded (this, entry);
 			});
diff --git a/src/TimeAdaptor.cs b/src/TimeAdaptor.cs
index 2b80a83..cdef8df 100644
--- a/src/TimeAdaptor.cs
+++ b/src/TimeAdaptor.cs
@@ -177,8 +177,7 @@ namespace FSpot {
 				endyear_tmp = Math.Max (year, endyear_tmp);
 			}
 			
-			Gtk.Application.Invoke(delegate {
-				
+			ThreadAssist.ProxyToMain (() => {
 				years = years_tmp;
 				startyear = startyear_tmp;
 				endyear = endyear_tmp;
diff --git a/src/UriCollection.cs b/src/UriCollection.cs
index a6a2623..cbc81d7 100644
--- a/src/UriCollection.cs
+++ b/src/UriCollection.cs
@@ -133,7 +133,7 @@ namespace FSpot {
 					if (ImageFile.HasLoader (i))
 						items.Add (new FileBrowsableItem (i));
 				}
-				Gtk.Application.Invoke (items, System.EventArgs.Empty, delegate (object sender, EventArgs args) {
+				ThreadAssist.ProxyToMain (() => {
 					collection.Add (items.ToArray ());
 				});
 			}



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