Patch: Delay refresh on any get folders operation detected.



	Hi,

	This patch is a small improvement on the behavior of the delayed
refresh mode of TnyGtkFolderListStore. The change is adding more points
where we delay the refresh.

	Also, we are removing the forcing to finish delay on connection
eventsThis is because we're usually getting the connection event too
soon (origin is going online process).

Changelog:
	* libtinymailui-gtk/tny-gtk-folder-list-store.c: delay refresh
	not only on adding accounts, but on each step of get folders
	operation. Also removing the delayed refresh on connection event
	is now disabled, as we usually get hte connection event too 
	soon.

-- 
José Dapena Paz <jdapena igalia com>
Igalia
diff --git a/ChangeLog b/ChangeLog
index 7ec8a36..2565899 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-06-19  Jose Dapena Paz  <jdapena igalia com>
+
+	* libtinymailui-gtk/tny-gtk-folder-list-store.c: delay refresh
+	not only on adding accounts, but on each step of get folders
+	operation. Also removing the delayed refresh on connection event
+	is now disabled, as we usually get hte connection event too 
+	soon.
+
 2009-06-16  Jose Dapena Paz  <jdapena igalia com>
 
 	* New libtinymail-camel/tny-camel-html-to-text-stream.[ch]:
diff --git a/libtinymailui-gtk/tny-gtk-folder-list-store.c b/libtinymailui-gtk/tny-gtk-folder-list-store.c
index 24c403d..30811bc 100644
--- a/libtinymailui-gtk/tny-gtk-folder-list-store.c
+++ b/libtinymailui-gtk/tny-gtk-folder-list-store.c
@@ -85,6 +85,22 @@ static void tny_gtk_folder_list_store_on_constatus_changed (TnyAccount *account,
 							    TnyConnectionStatus status, 
 							    TnyGtkFolderListStore *self);
 
+static gboolean delayed_refresh_timeout_handler (TnyGtkFolderListStore *self);
+
+static void
+update_delayed_refresh (TnyGtkFolderListStore *self)
+{
+	if (self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_DELAYED_REFRESH) {
+		if (self->delayed_refresh_timeout_id > 0) {
+			g_source_remove (self->delayed_refresh_timeout_id);
+		}
+		self->delayed_refresh_timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
+									       2,
+									       (GSourceFunc) delayed_refresh_timeout_handler,
+									       g_object_ref (self),
+									       g_object_unref);
+	}
+}
 
 static gboolean
 delayed_refresh_timeout_handler (TnyGtkFolderListStore *self)
@@ -333,6 +349,7 @@ recurse_folders_async_cb (TnyFolderStore *store,
 
 				add_folder_store_observer_weak (self, folder_store);
 				self->progress_count++;
+				update_delayed_refresh (self);
 				tny_folder_store_get_folders_async (folder_store,
 								    folders, NULL, 
 								    !(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH),
@@ -355,7 +372,7 @@ recurse_folders_async_cb (TnyFolderStore *store,
 			 * memory peak will happen, few data must be transmitted
 			 * in case we're online. Which is perfect! */
 
-			if (folder)
+			if (folder && !(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_DELAYED_REFRESH))
 				tny_folder_poke_status (TNY_FOLDER (folder));
 
 			if (mark_for_removal) {
@@ -373,6 +390,7 @@ recurse_folders_async_cb (TnyFolderStore *store,
 				TnyList *folders = tny_simple_list_new ();
 
 				self->progress_count++;
+				update_delayed_refresh (self);
 				tny_folder_store_get_folders_async (folder_store,
 								    folders, NULL, 
 								    !(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH),
@@ -460,9 +478,11 @@ get_folders_cb (TnyFolderStore *fstore, gboolean cancelled, TnyList *list, GErro
 	if (found) {
 		TnyList *folders = tny_simple_list_new ();
 		self->progress_count++;
+		update_delayed_refresh (self);
 		if (self->progress_count == 1) {
 			g_signal_emit (self, tny_gtk_folder_list_store_signals[ACTIVITY_CHANGED_SIGNAL], 0, TRUE);
 		}
+		update_delayed_refresh (self);
 		tny_folder_store_get_folders_async (fstore,
 						    folders, NULL, 
 						    !(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH),
@@ -494,7 +514,7 @@ tny_gtk_folder_list_store_on_constatus_changed (TnyAccount *account, TnyConnecti
 	 * we got connected, we can expect that, at least sometimes, new folders
 	 * might have arrived. We'll need to scan for those, so we'll recursively
 	 * start asking the account about its folders. */
-
+	
 	if (status == TNY_CONNECTION_STATUS_RECONNECTING || status == TNY_CONNECTION_STATUS_DISCONNECTED)
 		return;
 
@@ -504,11 +524,6 @@ tny_gtk_folder_list_store_on_constatus_changed (TnyAccount *account, TnyConnecti
 		g_signal_emit (self, tny_gtk_folder_list_store_signals[ACTIVITY_CHANGED_SIGNAL], 0, TRUE);
 	}
 
-	if (self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_DELAYED_REFRESH) {
-		self->flags &= (~TNY_GTK_FOLDER_LIST_STORE_FLAG_DELAYED_REFRESH);
-		self->flags &= (~TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH);
-	}
-
 	tny_folder_store_get_folders_async (TNY_FOLDER_STORE (account),
 					    list, self->query,
 					    !(self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_NO_REFRESH),
@@ -695,16 +710,7 @@ tny_gtk_folder_list_store_add_i (TnyGtkFolderListStore *self, TnyFolderStore *fo
 		g_signal_emit (self, tny_gtk_folder_list_store_signals[ACTIVITY_CHANGED_SIGNAL], 0, TRUE);
 	}
 
-	if (self->flags & TNY_GTK_FOLDER_LIST_STORE_FLAG_DELAYED_REFRESH) {
-		if (self->delayed_refresh_timeout_id > 0) {
-			g_source_remove (self->delayed_refresh_timeout_id);
-		}
-		self->delayed_refresh_timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
-									       1,
-									       (GSourceFunc) delayed_refresh_timeout_handler,
-									       g_object_ref (self),
-									       g_object_unref);
-	}
+	update_delayed_refresh (self);
 
 	tny_folder_store_get_folders_async (TNY_FOLDER_STORE (folder_store), 
 					    folders, self->query, 


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