[f-spot] Prepare import when selecting previous option menu items



commit 4a4788ce4e702415f4f76aa4a10b049cf81b84cb
Author: Paul Wellner Bou <paul purecodes org>
Date:   Thu May 20 18:10:54 2010 +0200

    Prepare import when selecting previous option menu items
    
    https://bugzilla.gnome.org/show_bug.cgi?id=619171
    
    Use correct casts

 src/ImportCommand.cs |   80 ++++++++++++++++++++++++++++---------------------
 1 files changed, 46 insertions(+), 34 deletions(-)
---
diff --git a/src/ImportCommand.cs b/src/ImportCommand.cs
index 49b00ce..30fd7c3 100644
--- a/src/ImportCommand.cs
+++ b/src/ImportCommand.cs
@@ -227,6 +227,17 @@ public class ImportCommand : GladeDialog
 		private void HandleActivated (object sender, EventArgs args)
 		{
 			command.Source = (SourceItem) sender;
+			command.ChangeSelection ();
+		}
+
+		public void HandleSourceSelectionChanged (object sender, EventArgs args)
+		{
+			SourceMenu sm = (sender as OptionMenu).Menu as SourceMenu;
+			SourceItem source = sm.Active as SourceItem;
+			if(source != command.Source) {
+				command.Source = source;
+				command.ChangeSelection ();
+			}
 		}
 
 		public int SourceCount {
@@ -298,42 +309,43 @@ public class ImportCommand : GladeDialog
 
 	public Uri ImportUri { get; private set; }
 	
-	private SourceItem Source {
-		set {
-			if (store == null || collection == null)
-				return;
-			
-			SourceItem item = value;
+	private SourceItem Source;
+
+	public void ChangeSelection ()
+	{
+		if (store == null || collection == null)
+			return;
+
+		SourceItem item = Source;
+
+		this.Cancel ();
+		this.copy = copy_check.Active;
+
+		if (!item.Sensitive)
+			return;
+
+		if (item.Source is BrowseSource) {
+			Uri uri = ChooseUri ();
 			
-			this.Cancel ();
-			this.copy = copy_check.Active;
-
-			if (!item.Sensitive)
-				return;
-
-			if (item.Source is BrowseSource) {
-				Uri uri = ChooseUri ();
-				
-				if (uri != null) {
-					SourceItem uri_item = new SourceItem (new VfsSource (uri));
-					menu.Prepend (uri_item);
-					uri_item.ShowAll ();
-					source_option_menu.SetHistory (0);
-					ImportUri = uri;
-				}
-			} else if (item.Source is VfsSource) {
-				VfsSource vfs = item.Source as VfsSource;
-				ImportUri = vfs.uri;
-			} else if (item.Source is CameraSource) {
-				CameraSource csource = item.Source as CameraSource;
-				string port = "gphoto2:" + csource.Port;
-				this.Cancel ();
-				this.Dialog.Destroy ();
-				App.Instance.Organizer.ImportCamera (port);
+			if (uri != null) {
+				SourceItem uri_item = new SourceItem (new VfsSource (uri));
+				menu.Prepend (uri_item);
+				uri_item.ShowAll ();
+				source_option_menu.SetHistory (0);
+				ImportUri = uri;
 			}
-
-			idle_start.Start ();
+		} else if (item.Source is VfsSource) {
+			VfsSource vfs = item.Source as VfsSource;
+			ImportUri = vfs.uri;
+		} else if (item.Source is CameraSource) {
+			CameraSource csource = item.Source as CameraSource;
+			string port = "gphoto2:" + csource.Port;
+			this.Cancel ();
+			this.Dialog.Destroy ();
+			App.Instance.Organizer.ImportCamera (port);
 		}
+
+		idle_start.Start ();
 	}
 
 	public ImportCommand (Gtk.Window mw)
@@ -592,7 +604,7 @@ public class ImportCommand : GladeDialog
 		this.Dialog.Show ();
         progress_bar.Hide ();
 
-		//source_option_menu.Changed += HandleSourceChanged;
+		source_option_menu.Changed += menu.HandleSourceSelectionChanged;
 		if (uri != null) {
 			ImportUri = uri;
 			int i = menu.FindItemPosition (uri);



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