Lower priority for status callbacks (patch)



Hello,

in Tinymail, status callbacks are installed when tny_folder_*_async(..)
functions are invoked. They enter an idle loop with priority
G_PRIORITY_HIGH, which is higher than that of GTK redrawings. If we are
using a GtkWidget (i.e. a progress bar) to notify the user, it could
happen that it doesn't get redrawn often enough, providing the user with
little visual feedback.

The attached patch defines a priority TNY_PRIORITY_LOWER_THAN_REDRAWS,
in tny_shared.h as follows:
 
/* GTK+ uses G_PRIORITY_HIGH_IDLE + 10 for resizing operations,
 * and G_PRIORITY_HIGH_IDLE + 20 for redrawing operations;
 * this makes sure that status cb happen after redraws, so we don't
 * get a lot of notifications with very little visual feedback */
#define TNY_PRIORITY_LOWER_THAN_GTK_REDRAWS G_PRIORITY_HIGH_IDLE + 30
        
The priority of idle calls is set to TNY_PRIORITY_LOWER_THAN_GTK_REDRAWS
(instead of G_PRIORITY_HIGH_IDLE) in: 
              * tny_camel_folder_add_msg_async_status(..)
              * tny_camel_folder_sync_async_status(..)
              * tny_camel_folder_refresh_async_status(..)
              * tny_camel_folder_get_msg_async_status(..)
              * tny_camel_folder_copy_async_status(..)
              * tny_camel_folder_transfer_msgs_async_status(..)

The patch was made against Tinymail's revision 3104.

Cheers,

Felipe Erias Morandeira
Index: tinymail/libtinymail/tny-shared.h
===================================================================
--- tinymail/libtinymail/tny-shared.h	(revision 3104)
+++ tinymail/libtinymail/tny-shared.h	(working copy)
@@ -31,6 +31,12 @@
 
 G_BEGIN_DECLS
 
+/* GTK+ uses G_PRIORITY_HIGH_IDLE + 10 for resizing operations,
+ * and G_PRIORITY_HIGH_IDLE + 20 for redrawing operations;
+ * this makes sure that status callbacks happen after redraws, so we don't
+ * get a lot of notifications but very little visual feedback */
+#define TNY_PRIORITY_LOWER_THAN_GTK_REDRAWS G_PRIORITY_HIGH_IDLE + 30
+
 typedef struct _TnyStatus TnyStatus;
 typedef struct _TnyAccountStore TnyAccountStore;
 typedef struct _TnyAccountStoreIface TnyAccountStoreIface;
Index: tinymail/libtinymail-camel/tny-camel-folder.c
===================================================================
--- tinymail/libtinymail-camel/tny-camel-folder.c	(revision 3104)
+++ tinymail/libtinymail-camel/tny-camel-folder.c	(working copy)
@@ -849,7 +849,7 @@
 		TNY_FOLDER_STATUS, TNY_FOLDER_STATUS_CODE_XFER_MSGS, what, sofar, 
 		oftotal, oinfo->stopper, oinfo->session->priv->ui_lock, oinfo->user_data);
 
-	g_idle_add_full (G_PRIORITY_HIGH,
+	g_idle_add_full (TNY_PRIORITY_LOWER_THAN_GTK_REDRAWS,
 		tny_progress_info_idle_func, info,
 		tny_progress_info_destroy);
 
@@ -1457,7 +1457,7 @@
 		TNY_FOLDER_STATUS, TNY_FOLDER_STATUS_CODE_SYNC, what, sofar, 
 		oftotal, oinfo->stopper, oinfo->session->priv->ui_lock, oinfo->user_data);
 
-	g_idle_add_full (G_PRIORITY_HIGH,
+	g_idle_add_full (TNY_PRIORITY_LOWER_THAN_GTK_REDRAWS,
 		tny_progress_info_idle_func, info,
 		tny_progress_info_destroy);
 
@@ -1662,7 +1662,7 @@
 		oftotal, oinfo->stopper, oinfo->session->priv->ui_lock, 
 		oinfo->user_data);
 
-	g_idle_add_full (G_PRIORITY_HIGH,
+	g_idle_add_full (TNY_PRIORITY_LOWER_THAN_GTK_REDRAWS,
 		tny_progress_info_idle_func, info,
 		tny_progress_info_destroy);
 
@@ -2187,7 +2187,7 @@
 		TNY_FOLDER_STATUS, TNY_FOLDER_STATUS_CODE_GET_MSG, what, sofar, 
 		oftotal, oinfo->stopper, oinfo->session->priv->ui_lock, oinfo->user_data);
 
-	g_idle_add_full (G_PRIORITY_HIGH, 
+	g_idle_add_full (TNY_PRIORITY_LOWER_THAN_GTK_REDRAWS, 
 			  tny_progress_info_idle_func, info, 
 			  tny_progress_info_destroy);
 
@@ -3229,7 +3229,7 @@
 		TNY_FOLDER_STATUS, TNY_FOLDER_STATUS_CODE_COPY_FOLDER, what, sofar, 
 		oftotal, oinfo->stopper, oinfo->session->priv->ui_lock, oinfo->user_data);
 
-	g_idle_add_full (G_PRIORITY_HIGH,
+	g_idle_add_full (TNY_PRIORITY_LOWER_THAN_GTK_REDRAWS,
 			  tny_progress_info_idle_func, info, 
 			  tny_progress_info_destroy);
 
@@ -3815,7 +3815,7 @@
 		TNY_FOLDER_STATUS, TNY_FOLDER_STATUS_CODE_XFER_MSGS, what, sofar, 
 		oftotal, oinfo->stopper, oinfo->session->priv->ui_lock, oinfo->user_data);
 
-	g_idle_add_full (G_PRIORITY_HIGH,
+	g_idle_add_full (TNY_PRIORITY_LOWER_THAN_GTK_REDRAWS,
 			  tny_progress_info_idle_func, info, 
 			  tny_progress_info_destroy);
 


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