[tracker/pushplugin] More accurate progress



commit 2e9a394688347aa85a30d76d0f78dbd4fa910901
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Sep 22 15:15:03 2009 +0200

    More accurate progress

 src/plugins/evolution/tracker-evolution-plugin.c |   33 ++++++++--------------
 1 files changed, 12 insertions(+), 21 deletions(-)
---
diff --git a/src/plugins/evolution/tracker-evolution-plugin.c b/src/plugins/evolution/tracker-evolution-plugin.c
index 82a72b3..fa535ef 100644
--- a/src/plugins/evolution/tracker-evolution-plugin.c
+++ b/src/plugins/evolution/tracker-evolution-plugin.c
@@ -166,7 +166,7 @@ typedef struct {
 	DBusGConnection *connection;
 	time_t last_time;
 	gboolean resuming, paused;
-	guint total_popped;
+	guint total_popped, of_total;
 } TrackerEvolutionPluginPrivate;
 
 typedef struct {
@@ -794,9 +794,7 @@ on_folder_summary_changed (CamelFolder *folder,
 	send_sparql_commit (info->self, TRUE);
 
 	g_object_set (info->self, "progress", 
-	              1.0,
-	              "status", _("Updating"), 
-	              NULL);
+	              1.0, NULL);
 
 	g_free (em_uri);
 }
@@ -853,26 +851,19 @@ many_idle_handler (gpointer user_data)
 		
 		if (priv->client) {
 			const gchar *query;
-			guint len = g_queue_get_length (many_queue);
 
 			query = tracker_sparql_builder_get_result (queued_set->sparql);
+
 			priv->total_popped++;
 
-			if (priv->total_popped > len) {
-				priv->total_popped = 0;
+			if (priv->total_popped > priv->of_total) {
+				priv->total_popped = priv->of_total;
 			}
 
-			if (len > 0) {
-				g_object_set (user_data, "progress", 
-				              (gdouble) (len - priv->total_popped) / len,
-				              "status", _("Updating"), 
-				              NULL);
-			} else {
-				g_object_set (user_data, "progress", 
-				              1.0,
-				              "status", _("Updating"), 
-				              NULL);
-			}
+			g_object_set (user_data, "progress", 
+			              (gdouble) (priv->of_total - priv->total_popped) / priv->of_total,
+			              "status", _("Updating"), 
+			              NULL);
 
 			send_sparql_update (user_data, query);
 		} else {
@@ -880,9 +871,7 @@ many_idle_handler (gpointer user_data)
 			 * this disconnected registrar from the queue */
 
 			g_object_set (user_data, "progress", 
-			              1.0,  
-			              "status", _("Finishing"), 
-			              NULL);
+			              1.0, NULL);
 
 			clean_many_queue ();
 		}
@@ -1131,11 +1120,13 @@ introduce_walk_folders_in_folder (TrackerEvolutionPlugin *self,
 
 				if (!many_queue) {
 					many_queue = g_queue_new ();
+					priv->of_total = 0;
 					start_handler = TRUE;
 				}
 
 				g_queue_push_tail (many_queue, 
 				                   queued_set);
+				priv->of_total++;
 
 				if (start_handler) {
 					start_many_handler (self);



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