nemo r29 - in trunk: broker gtk gtk-gui



Author: arj
Date: Mon Jan  7 10:43:21 2008
New Revision: 29
URL: http://svn.gnome.org/viewvc/nemo?rev=29&view=rev

Log:
Fix bug in closing session using Xesam



Modified:
   trunk/broker/Xesam.cs
   trunk/gtk-gui/MainWindow.cs
   trunk/gtk/MainWindow.cs

Modified: trunk/broker/Xesam.cs
==============================================================================
--- trunk/broker/Xesam.cs	(original)
+++ trunk/broker/Xesam.cs	Mon Jan  7 10:43:21 2008
@@ -49,7 +49,7 @@
 	        ObjectPath opath = new ObjectPath("/org/freedesktop/xesam/searcher/main");
 
 	        bus_search = con.GetObject<IXesamSearch>("org.freedesktop.xesam.searcher", opath);
-
+	        
 			bus_search.HitsAdded += hits_callback_handler;
 			bus_search.SearchDone += hits_done_handler;
 			
@@ -96,22 +96,26 @@
 			if (!hits_added_callbacks.ContainsKey(session_id))
 				return;
 
+			System.Console.WriteLine("handler ok {0}", session_id);
+
 			Callback callback = hits_added_callbacks[session_id];
 			
 			callback.get_results(ref callback.cur_number_of_results, amount);
 		}
 
-		private void hits_done_handler(string session_id)
+		private void hits_done_handler(string search_id)
 		{
-			System.Console.WriteLine("is done {0}", session_id);
+			System.Console.WriteLine("is done {0}", search_id);
 
 			// for text search, we only want the first results so we need this hack 
-			if (!hits_added_callbacks.ContainsKey(session_id))
+			if (!hits_added_callbacks.ContainsKey(search_id))
 				return;
 
-			VoidFunction callback = hits_done_callbacks[session_id];
+			System.Console.WriteLine("done callback {0}", search_id);
+
+			VoidFunction callback = hits_done_callbacks[search_id];
 			callback();
-			hits_done_callbacks.Remove(session_id);
+			hits_done_callbacks.Remove(search_id);
 		}
 
 		private Dictionary<string, Callback> hits_added_callbacks;
@@ -148,10 +152,27 @@
 					
 					System.Console.WriteLine("search xesam for {0} files with session id {1}, trying to get {2}", tmp_filenames.Count, this_session_id, tmp_filenames.Count);
 
-					hits_added_callbacks.Add(this_session_id, new Callback(tmp_filenames.Count, delegate(ref int count, UInt32 amount) {
-						System.Console.WriteLine("hits added  in get metadata: {0} - {1}", amount, this_session_id);
+					string xml_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+						"<request xmlns=\"http://freedesktop.org/standards/xesam/1.0/query\";>" +
+						"  <query>" +
+						"    <inSet> " +
+						"      <field name=\"xesam:url\"/> ";
+
+					foreach (string filename in tmp_filenames)
+						xml_string += "      <string>" + "file://" + filename + "</string> ";
+
+					xml_string += "    </inSet> ";
+					xml_string += "  </query> ";
+					xml_string += "</request> ";
+
+//					System.Console.WriteLine(xml_string);
 
-						object[][] results = bus_search.GetHits(this_session_id, amount);
+					string search_id = bus_search.NewSearch(this_session_id, xml_string); 
+
+					hits_added_callbacks.Add(search_id, new Callback(tmp_filenames.Count, delegate(ref int count, UInt32 amount) {
+						System.Console.WriteLine("hits added in get metadata: {0} - {1}", amount, this_session_id);
+
+						object[][] results = bus_search.GetHits(search_id, amount);
 						
 						System.Console.WriteLine("ze hits in get metadata!");
 					
@@ -168,29 +189,12 @@
 						}
 					}));
 
-					string xml_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-						"<request xmlns=\"http://freedesktop.org/standards/xesam/1.0/query\";>" +
-						"  <query>" +
-						"    <inSet> " +
-						"      <field name=\"xesam:url\"/> ";
-
-					foreach (string filename in tmp_filenames)
-						xml_string += "      <string>" + "file://" + filename + "</string> ";
-
-					xml_string += "    </inSet> ";
-					xml_string += "  </query> ";
-					xml_string += "</request> ";
-
-					System.Console.WriteLine(xml_string);
-
-					hits_done_callbacks.Add(this_session_id, delegate  { 
-						System.Console.WriteLine("closing session {0}", this_session_id);
+					hits_done_callbacks.Add(search_id, delegate  { 
+						System.Console.WriteLine("closing session {0}, search {1}", this_session_id, search_id);
 						bus_search.CloseSession(this_session_id);
-						hits_added_callbacks.Remove(this_session_id);
+						hits_added_callbacks.Remove(search_id);
 					});
 
-					bus_search.NewSearch(this_session_id, xml_string); 
-
 					bus_search.StartSearch(this_session_id);
 		        });
 

Modified: trunk/gtk-gui/MainWindow.cs
==============================================================================
--- trunk/gtk-gui/MainWindow.cs	(original)
+++ trunk/gtk-gui/MainWindow.cs	Mon Jan  7 10:43:21 2008
@@ -237,14 +237,14 @@
         this.prev_button.UseUnderline = true;
         // Container child prev_button.Gtk.Container+ContainerChild
         Gtk.Alignment w22 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
-        // Container child GtkAlignment1.Gtk.Container+ContainerChild
+        // Container child GtkAlignment.Gtk.Container+ContainerChild
         Gtk.HBox w23 = new Gtk.HBox();
         w23.Spacing = 2;
-        // Container child GtkHBox1.Gtk.Container+ContainerChild
+        // Container child GtkHBox.Gtk.Container+ContainerChild
         Gtk.Image w24 = new Gtk.Image();
         w24.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-go-back", Gtk.IconSize.Menu, 16);
         w23.Add(w24);
-        // Container child GtkHBox1.Gtk.Container+ContainerChild
+        // Container child GtkHBox.Gtk.Container+ContainerChild
         Gtk.Label w26 = new Gtk.Label();
         w26.LabelProp = "";
         w23.Add(w26);
@@ -262,14 +262,14 @@
         this.next_button.UseUnderline = true;
         // Container child next_button.Gtk.Container+ContainerChild
         Gtk.Alignment w31 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
-        // Container child GtkAlignment2.Gtk.Container+ContainerChild
+        // Container child GtkAlignment.Gtk.Container+ContainerChild
         Gtk.HBox w32 = new Gtk.HBox();
         w32.Spacing = 2;
-        // Container child GtkHBox2.Gtk.Container+ContainerChild
+        // Container child GtkHBox.Gtk.Container+ContainerChild
         Gtk.Image w33 = new Gtk.Image();
         w33.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-go-forward", Gtk.IconSize.Menu, 16);
         w32.Add(w33);
-        // Container child GtkHBox2.Gtk.Container+ContainerChild
+        // Container child GtkHBox.Gtk.Container+ContainerChild
         Gtk.Label w35 = new Gtk.Label();
         w35.LabelProp = "";
         w32.Add(w35);

Modified: trunk/gtk/MainWindow.cs
==============================================================================
--- trunk/gtk/MainWindow.cs	(original)
+++ trunk/gtk/MainWindow.cs	Mon Jan  7 10:43:21 2008
@@ -254,7 +254,7 @@
 			
 			callbacks.Add("file://" + file.path, Helpers.RunInMainThread<string[]>(delegate(string[] result) {
 				
-				System.Console.WriteLine("results: {0}", result.Length);
+//				System.Console.WriteLine("results: {0}", result.Length);
 				System.Console.WriteLine("result: {0}", result[1]);
 
 				foreach (string t in result)



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