Re: Patch: more responsive header list model



El mié, 10-02-2010 a las 17:18 +0100, Sergio Villar Senin escribió:
> Having a boolean argument seems a bit weird to me Dape, because it gives
> the impression that you can disable the update in batches when it's
> actually false. Why not just passing the amount of headers?

	So, new patch. Now it gets a gint with the number of headers to fetch
in each notify_views_add.

Changelog would be:
	* libtinymailui-gtk/tny-gtk-header-list-model.c:
	new method tny_gtk_header_list_model_set_update_in_batches
	to change the way headers are exposed to tree model. It
	sets the number of headers that will be added to tree model
	per batch. By default it's 3000 (old behavior). You can set
	a lower value to make ui more responsive.



-- 
José Dapena Paz <jdapena igalia com>
Igalia
diff --git a/ChangeLog b/ChangeLog
index 756b50a..2b78740 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-02-10  Jose Dapena Paz  <jdapena igalia com>
+
+	* libtinymailui-gtk/tny-gtk-header-list-model.c:
+	new method tny_gtk_header_list_model_set_update_in_batches
+	to change the way headers are exposed to tree model. It
+	sets the number of headers that will be added to tree model
+	per batch. By default it's 3000 (old behavior). You can set
+	a lower value to make ui more responsive.
+
 2010-01-27  Sergio Villar Senin  <svillar igalia com>
 
 	* configure.ac: changed library version.
diff --git a/libtinymailui-gtk/tny-gtk-header-list-iterator-priv.h b/libtinymailui-gtk/tny-gtk-header-list-iterator-priv.h
index 27d2bda..d07f3f6 100644
--- a/libtinymailui-gtk/tny-gtk-header-list-iterator-priv.h
+++ b/libtinymailui-gtk/tny-gtk-header-list-iterator-priv.h
@@ -84,6 +84,7 @@ struct _TnyGtkHeaderListModelPriv
 	gint show_latest;
 	GPtrArray *not_latest_items;
 	time_t oldest_received;
+	gint headers_per_batch;
 };
 
 G_END_DECLS
diff --git a/libtinymailui-gtk/tny-gtk-header-list-model.c b/libtinymailui-gtk/tny-gtk-header-list-model.c
index 8109959..dc55277 100644
--- a/libtinymailui-gtk/tny-gtk-header-list-model.c
+++ b/libtinymailui-gtk/tny-gtk-header-list-model.c
@@ -680,9 +680,9 @@ notify_views_add (gpointer data)
 
 	already_registered = priv->registered;
 	if ( already_registered == 0)
-		mails_load_count = 100;
+		mails_load_count = (priv->headers_per_batch < 100)?priv->headers_per_batch:100;
 	else
-		mails_load_count = 3000;
+		mails_load_count = priv->headers_per_batch;
 
 	if (priv->items->len - already_registered > mails_load_count) {
 		going_tb_registered = already_registered + mails_load_count;
@@ -1230,6 +1230,7 @@ tny_gtk_header_list_model_init (TnyGtkHeaderListModel *self)
 	priv->ra_lock = g_mutex_new ();
 	priv->to_lock = g_mutex_new ();
 	priv->registered = 0;
+	priv->headers_per_batch = 3000;
 
 	return;
 }
@@ -1537,3 +1538,12 @@ update_oldest_received (TnyGtkHeaderListModel *self, TnyHeader *header)
 		priv->oldest_received = date_received;
 	}
 }
+
+void
+tny_gtk_header_list_model_set_update_in_batches (TnyGtkHeaderListModel *self,
+						 gint headers_per_batch)
+{
+	TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self);
+
+	priv->headers_per_batch = headers_per_batch;
+}
diff --git a/libtinymailui-gtk/tny-gtk-header-list-model.h b/libtinymailui-gtk/tny-gtk-header-list-model.h
index e7585a5..eed486f 100644
--- a/libtinymailui-gtk/tny-gtk-header-list-model.h
+++ b/libtinymailui-gtk/tny-gtk-header-list-model.h
@@ -79,6 +79,7 @@ void tny_gtk_header_list_model_set_no_duplicates (TnyGtkHeaderListModel *self, g
 gboolean tny_gtk_header_list_model_get_no_duplicates (TnyGtkHeaderListModel *self);
 void tny_gtk_header_list_model_set_show_latest (TnyGtkHeaderListModel *self, gint show_latest_n);
 gint tny_gtk_header_list_model_get_show_latest (TnyGtkHeaderListModel *self);
+void tny_gtk_header_list_model_set_update_in_batches (TnyGtkHeaderListModel *self, gint headers_per_batch);
 
 G_END_DECLS
 


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