aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-07-30 11:30:12 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-07-30 11:30:12 +0800
commitdcfc13c927ac9c8a18f259a5a055666061a63878 (patch)
tree774f4b04aa5a9fcf5174ac861109ca21aaad5ae4
parent86b1c2a109bb116487cd4d00c6da257f689adddd (diff)
downloadgsoc2013-evolution-dcfc13c927ac9c8a18f259a5a055666061a63878.tar.gz
gsoc2013-evolution-dcfc13c927ac9c8a18f259a5a055666061a63878.tar.zst
gsoc2013-evolution-dcfc13c927ac9c8a18f259a5a055666061a63878.zip
Actually add the timeout, this time in the gtk thread.
2001-07-30 Not Zed <NotZed@Ximian.com> * mail-session.c (do_register_timeout): Actually add the timeout, this time in the gtk thread. (do_remove_timeout): And same for remove. (register_timeout): (remove_timeout): Proxy the gtk calls to the main thread, and wait for them to execute synchronously. (register_timeout): Instead of return with fail for a too small timeout, just increase the timeout. svn path=/trunk/; revision=11468
-rw-r--r--mail/ChangeLog11
-rw-r--r--mail/mail-session.c42
2 files changed, 46 insertions, 7 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index b73c2488d8..8539ca7671 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,14 @@
+2001-07-30 Not Zed <NotZed@Ximian.com>
+
+ * mail-session.c (do_register_timeout): Actually add the timeout,
+ this time in the gtk thread.
+ (do_remove_timeout): And same for remove.
+ (register_timeout):
+ (remove_timeout): Proxy the gtk calls to the main thread, and
+ wait for them to execute synchronously.
+ (register_timeout): Instead of return with fail for a too small
+ timeout, just increase the timeout.
+
2001-07-27 Zbigniew Chyla <cyba@gnome.pl>
* component-factory.c (populate_folder_context_menu): Added (unused)
diff --git a/mail/mail-session.c b/mail/mail-session.c
index b864f3b32b..4a55c6cf5e 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -220,8 +220,9 @@ alert_user (CamelSession *session, CamelSessionAlertType type,
struct _timeout_data {
CamelTimeoutCallback cb;
- gpointer camel_data;
- gboolean result;
+ guint32 interval;
+ void *camel_data;
+ int result;
};
struct _timeout_msg {
@@ -263,6 +264,20 @@ camel_timeout (gpointer data)
return TRUE;
}
+static void
+do_register_timeout(CamelObject *o, void *edata, void *data)
+{
+ struct _timeout_data *td = (struct _timeout_data *)edata;
+
+ td->result = gtk_timeout_add_full(td->interval, camel_timeout, NULL, td, g_free);
+}
+
+static void
+do_remove_timeout(CamelObject *o, void *edata, void *data)
+{
+ gtk_timeout_remove(*((int *)edata));
+}
+
static guint
register_timeout (CamelSession *session, guint32 interval, CamelTimeoutCallback cb, gpointer camel_data)
{
@@ -273,20 +288,33 @@ register_timeout (CamelSession *session, guint32 interval, CamelTimeoutCallback
* leading to timeout calls piling up, and we don't have a
* good way to watch the return values. It's not cool.
*/
- g_return_val_if_fail (interval > 1000, 0);
+ if (interval < 1000) {
+ g_warning("Timeout %u too small, increased to 1000", interval);
+ interval = 1000;
+ }
+ /* This is extremely messy, we need to proxy to gtk thread for this */
td = g_malloc (sizeof (*td));
- td->result = TRUE;
+ td->interval = interval;
+ td->result = 0;
td->cb = cb;
td->camel_data = camel_data;
-
- return gtk_timeout_add_full (interval, camel_timeout, NULL, td, g_free);
+
+ mail_msg_wait(mail_proxy_event(do_register_timeout, (CamelObject *)session, td, NULL));
+
+ if (td->result == 0) {
+ g_free(td);
+ return 0;
+ }
+
+ return td->result;
}
static gboolean
remove_timeout (CamelSession *session, guint handle)
{
- gtk_timeout_remove (handle);
+ mail_msg_wait(mail_proxy_event(do_remove_timeout, (CamelObject *)session, &handle, NULL));
+
return TRUE;
}