Tolta della porcheria.

Leonardo Robol [2010-02-10 09:02]
Tolta della porcheria.
Filename
Dizzy/EventManager.cs
Dizzy/FileTreeView.cs
Dizzy/MainWindow.cs
Dizzy/Protocol.cs
diff --git a/Dizzy/EventManager.cs b/Dizzy/EventManager.cs
index 393e660..d9c0888 100644
--- a/Dizzy/EventManager.cs
+++ b/Dizzy/EventManager.cs
@@ -20,6 +20,8 @@ namespace Dizzy

 	public class EventManager
 	{
+
+		public static MessageDialog searchInProgress = null;

 		public EventManager () {}

@@ -39,5 +41,37 @@ namespace Dizzy
 				return false;
 			});
 		}
+
+		// Metodi per gestire la ricerca
+		public static void SearchStarted () {
+
+			// Questo significa che stiamo già effettuando una ricerca
+			if (searchInProgress != null)
+				return;
+
+			searchInProgress = new MessageDialog(null,
+			                                     DialogFlags.Modal,
+			                                     MessageType.Info,
+			                                     ButtonsType.None,
+			                                     true, "");
+			searchInProgress.Markup = "Ricerca in corso, attendere.";
+			GLib.Idle.Add (delegate {
+				EventManager.searchInProgress.Run ();
+				return false;
+			});
+		}
+
+		public static void SearchFinished () {
+			if (searchInProgress == null)
+				return;
+			else
+			{
+				GLib.Idle.Add(delegate {
+					searchInProgress.Destroy ();
+					searchInProgress = null;
+					return false;
+				});
+			}
+		}
 	}
 }
diff --git a/Dizzy/FileTreeView.cs b/Dizzy/FileTreeView.cs
index 409fd56..a0cf207 100644
--- a/Dizzy/FileTreeView.cs
+++ b/Dizzy/FileTreeView.cs
@@ -77,11 +77,6 @@ namespace Dizzy
 			}
 		}

-		public void SearchInProgress ()
-		{
-			this.Clear ();
-			this.AddFile (new File("Ricerca in corso...", "  "));
-		}

 		public File GetFileFromPath (TreePath path)
 		{
diff --git a/Dizzy/MainWindow.cs b/Dizzy/MainWindow.cs
index 24ea7e1..59fffae 100644
--- a/Dizzy/MainWindow.cs
+++ b/Dizzy/MainWindow.cs
@@ -53,8 +53,6 @@ public partial class MainWindow : Gtk.Window
 	}


-
-
 	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
 	{
 		if (protocol != null)
@@ -71,7 +69,7 @@ public partial class MainWindow : Gtk.Window
 	protected virtual void OnSearchRequested (object sender, System.EventArgs e)
 	{
 		this.files.Clear ();
-		this.files.SearchInProgress ();
+		EventManager.SearchStarted ();
 		this.protocol.Search (searchBox.Text, ref this.files);
 	}

@@ -80,10 +78,6 @@ public partial class MainWindow : Gtk.Window

 		File f = this.files.GetFileFromPath (args.Path);

-		// Piccolo hack per evitare che ci freghino :)
-		if(f.name == "Ricerca in corso..." && f.user == " ")
-			return;
-		//	this.tasks.AddTask (f.name, 24);
 		string download_folder = this.downloadpathchooser.Filename;

 		this.protocol.Download(f, ref tasks, download_folder);
diff --git a/Dizzy/Protocol.cs b/Dizzy/Protocol.cs
index 79a59af..e61738b 100644
--- a/Dizzy/Protocol.cs
+++ b/Dizzy/Protocol.cs
@@ -101,12 +101,14 @@ namespace Dizzy
 			}

 			this.fileTreeView.Clear ();
-			if (files.Count == 0)
-				this.fileTreeView.AddFile (new File("Nessun risultato", " "));
+
 			foreach(File f in files)
 			{
 				this.fileTreeView.AddFile (f);
 			}
+			EventManager.SearchFinished ();
+			if (files.Count == 0)
+				EventManager.ErrorMessage ("Nessun risultato trovato!");
 		}

 		public void UpdateFileList ()
ViewGit