[f-spot] use a EventHandler<> for ApplicationActivated



commit 75a7f6696cbf51bab31cbd8f4347e02f738f9b47
Author: Stephane Delcroix <stephane delcroix org>
Date:   Thu Jun 25 13:01:41 2009 +0200

    use a EventHandler<> for ApplicationActivated
    
    the ApplicationActivated event now uses a EventHandler<ApplicationActivatedEventArgs> delegate type, as it's recommended. This also avoid creating a delegate on the fly for wrapping HandleOpenWith

 src/Extensions/PopupCommands.cs              |    4 +-
 src/MainWindow.cs                            |    9 ++++---
 src/Makefile.am                              |    1 +
 src/Widgets/ApplicationActivatedEventArgs.cs |   30 ++++++++++++++++++++++++++
 src/Widgets/OpenWithMenu.cs                  |   12 ++++++----
 5 files changed, 45 insertions(+), 11 deletions(-)
---
diff --git a/src/Extensions/PopupCommands.cs b/src/Extensions/PopupCommands.cs
index f731182..a0ae7b5 100644
--- a/src/Extensions/PopupCommands.cs
+++ b/src/Extensions/PopupCommands.cs
@@ -9,8 +9,8 @@
  */
 
 using System;
-
 using GLib;
+using FSpot.Widgets;
 
 namespace FSpot.Extensions 
 {
@@ -61,7 +61,7 @@ namespace FSpot.Extensions
 		public Gtk.Menu GetMenu ()
 		{
 			owm = new Widgets.OpenWithMenu (MainWindow.Toplevel.SelectedMimeTypes, "f-spot");
-			owm.ApplicationActivated += delegate (AppInfo app) { MainWindow.Toplevel.HandleOpenWith (this, app); };
+			owm.ApplicationActivated += MainWindow.Toplevel.HandleOpenWith;
 			return (Gtk.Menu) owm;
 		}
 
diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index e046c2d..d58f2ac 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -2874,8 +2874,9 @@ public class MainWindow {
 		}
 	}
 
-	public void HandleOpenWith (object sender, GLib.AppInfo application)
+	public void HandleOpenWith (object sender, ApplicationActivatedEventArgs e)
 	{
+		GLib.AppInfo application = e.AppInfo;
 		Photo[] selected = SelectedPhotos ();
 
 		if (selected == null || selected.Length < 1)
@@ -2908,7 +2909,7 @@ public class MainWindow {
 			CheckButton cb = new CheckButton (Catalog.GetString ("XCF version"));
 			cb.Active = Preferences.Get<bool> (Preferences.EDIT_CREATE_XCF_VERSION);
 			hmd.VBox.Add (cb);
-			cb.Toggled += delegate (object s, EventArgs e) {
+			cb.Toggled += delegate (object s, EventArgs ea) {
 				Preferences.Set (Preferences.EDIT_CREATE_XCF_VERSION, (s as CheckButton).Active);
 			};
 			cb.Show ();
@@ -2941,8 +2942,8 @@ public class MainWindow {
 					uint version = photo.CreateNamedVersion (application.Name, create_xcf ? ".xcf" : null, photo.DefaultVersionId, true);
 					photo.DefaultVersionId = version;
 				}
-			} catch (Exception e) {
-				errors.Add (new EditException (photo, e));
+			} catch (Exception ex) {
+				errors.Add (new EditException (photo, ex));
 			}
 
 			uri_list.Append (photo.DefaultVersionUri.ToString ());
diff --git a/src/Makefile.am b/src/Makefile.am
index 6bb8a11..24d5c3e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -78,6 +78,7 @@ WIDGETS_CSDISTFILES =				\
 	$(srcdir)/Bling/EasingMode.cs		\
 	$(srcdir)/Bling/EasedAnimation.cs	\
 	$(srcdir)/Bling/QuinticEase.cs		\
+	$(srcdir)/Widgets/ApplicationActivatedEventArgs.cs	\
 	$(srcdir)/Widgets/BuilderWindow.cs	\
 	$(srcdir)/Widgets/CheckPattern.cs	\
 	$(srcdir)/Widgets/ComplexMenuItem.cs	\
diff --git a/src/Widgets/ApplicationActivatedEventArgs.cs b/src/Widgets/ApplicationActivatedEventArgs.cs
new file mode 100644
index 0000000..72a5379
--- /dev/null
+++ b/src/Widgets/ApplicationActivatedEventArgs.cs
@@ -0,0 +1,30 @@
+//
+// FSpot.Widgets.ApplicationActivatedEventArgs.cs
+//
+// Author(s):
+//	Stephane Delcroix <stephane delcroix org>
+//
+// Copyright (c) 2009 Novell, Inc.
+//
+// This is free software. See COPYING for details.
+//
+
+using System;
+using GLib;
+
+namespace FSpot.Widgets
+{
+	public class ApplicationActivatedEventArgs : EventArgs
+	{
+		AppInfo app;
+		public AppInfo AppInfo {
+			get { return app; }
+		}
+
+		public ApplicationActivatedEventArgs (AppInfo app) : base ()
+		{
+			this.app = app;
+		}
+	}
+}
+
diff --git a/src/Widgets/OpenWithMenu.cs b/src/Widgets/OpenWithMenu.cs
index 77576fc..67d9b07 100644
--- a/src/Widgets/OpenWithMenu.cs
+++ b/src/Widgets/OpenWithMenu.cs
@@ -7,6 +7,9 @@
  * 	Gabriel Burt  <gabriel burt gmail com>
  * 	Larry Ewing  <lewing novell com>
  *
+ * Copyright (c) 2007 Stephane Delcroix
+ * Copyright (c) 2007-2009 Novell, Inc.
+ *
  * This is free software. See COPYING for details.
  */
 
@@ -21,8 +24,7 @@ using Mono.Unix;
 
 namespace FSpot.Widgets {
 	public class OpenWithMenu: Gtk.Menu {
-		public delegate void OpenWithHandler (AppInfo app_info);
-		public event OpenWithHandler ApplicationActivated;
+		public event EventHandler<ApplicationActivatedEventArgs> ApplicationActivated;
 
 		public delegate string [] TypeFetcher ();
 		TypeFetcher type_fetcher;
@@ -97,11 +99,11 @@ namespace FSpot.Widgets {
 			AppMenuItem app = (sender as AppMenuItem);
 
 			if (ApplicationActivated != null)
-				ApplicationActivated (app.App);
+				ApplicationActivated (this, new ApplicationActivatedEventArgs (app.App));
 		}
 
-		private class AppMenuItem : ImageMenuItem {
-
+		private class AppMenuItem : ImageMenuItem
+		{
 			AppInfo app;
 			public AppInfo App {
 				get { return app; }



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