aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-09-17 07:26:17 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-09-17 07:26:17 +0000
commit71f191b2a609e291a3afcf726ab8aacab572637b (patch)
treefa744ee9944df82548c6afb33451455c4ce7c61a /src
parent24c2edfeacce97b6e4c3783c53cbd2532088af95 (diff)
introduced multi-threading.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2255 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/compose.c4
-rw-r--r--src/folderview.c15
-rw-r--r--src/inc.c5
-rw-r--r--src/main.c21
-rw-r--r--src/rpop3.c4
-rw-r--r--src/send_message.c11
-rw-r--r--src/sigstatus.c4
-rw-r--r--src/trayicon.c3
8 files changed, 58 insertions, 9 deletions
diff --git a/src/compose.c b/src/compose.c
index 69ec4844..c24729d7 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -7777,10 +7777,14 @@ static gboolean autosave_timeout(gpointer data)
{
Compose *compose = (Compose *)data;
+ gdk_threads_enter();
+
debug_print("auto-saving...\n");
if (compose->modified)
compose_draft_cb(data, 1, NULL);
+ gdk_threads_leave();
+
return TRUE;
}
diff --git a/src/folderview.c b/src/folderview.c
index f938e5c1..b0976750 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -3001,6 +3001,9 @@ static gint auto_expand_timeout(gpointer data)
FolderView *folderview = data;
GtkTreeView *treeview = GTK_TREE_VIEW(folderview->treeview);
GtkTreePath *path = NULL;
+ gint ret;
+
+ gdk_threads_enter();
gtk_tree_view_get_drag_dest_row(treeview, &path, NULL);
@@ -3009,9 +3012,13 @@ static gint auto_expand_timeout(gpointer data)
gtk_tree_path_free(path);
folderview->expand_timeout = 0;
- return FALSE;
+ ret = FALSE;
} else
- return TRUE;
+ ret = TRUE;
+
+ gdk_threads_leave();
+
+ return ret;
}
static void remove_auto_expand_timeout(FolderView *folderview)
@@ -3026,9 +3033,13 @@ static gint auto_scroll_timeout(gpointer data)
{
FolderView *folderview = data;
+ gdk_threads_enter();
+
gtkut_tree_view_vertical_autoscroll
(GTK_TREE_VIEW(folderview->treeview));
+ gdk_threads_leave();
+
return TRUE;
}
diff --git a/src/inc.c b/src/inc.c
index 2e038d50..b9641b3b 100644
--- a/src/inc.c
+++ b/src/inc.c
@@ -1564,13 +1564,18 @@ static gint inc_autocheck_func(gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;
+ gdk_threads_enter();
+
if (inc_lock_count) {
debug_print("autocheck is locked.\n");
inc_autocheck_timer_set_interval(1000);
+ gdk_threads_leave();
return FALSE;
}
inc_all_account_mail(mainwin, TRUE);
+ gdk_threads_leave();
+
return FALSE;
}
diff --git a/src/main.c b/src/main.c
index d012c90b..cb14d223 100644
--- a/src/main.c
+++ b/src/main.c
@@ -208,6 +208,9 @@ int main(int argc, char *argv[])
return 0;
}
+#if USE_THREADS
+ gdk_threads_enter();
+#endif
gtk_set_locale();
gtk_init(&argc, &argv);
@@ -217,13 +220,6 @@ int main(int argc, char *argv[])
gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
gtk_widget_set_default_visual(gdk_rgb_get_visual());
-#if USE_THREADS || USE_LDAP
- if (!g_thread_supported())
- g_thread_init(NULL);
- if (!g_thread_supported())
- g_error(_("g_thread is not supported by glib.\n"));
-#endif
-
parse_gtkrc_files();
setup_rc_dir();
@@ -341,6 +337,9 @@ int main(int argc, char *argv[])
update_check(FALSE);
gtk_main();
+#if USE_THREADS
+ gdk_threads_leave();
+#endif
return 0;
}
@@ -582,6 +581,14 @@ static gint get_queued_message_num(void)
static void app_init(void)
{
+#if USE_THREADS
+ if (!g_thread_supported())
+ g_thread_init(NULL);
+ if (!g_thread_supported())
+ g_error("g_thread is not supported by glib.");
+ else
+ gdk_threads_init();
+#endif
syl_init();
prog_version = PROG_VERSION;
diff --git a/src/rpop3.c b/src/rpop3.c
index 347f1a83..aee98956 100644
--- a/src/rpop3.c
+++ b/src/rpop3.c
@@ -608,6 +608,8 @@ static void rpop3_clear_list(void)
static gboolean rpop3_ping_cb(gpointer data)
{
+ gdk_threads_enter();
+
if (rpop3_window.ping_tag > 0) {
g_source_remove(rpop3_window.ping_tag);
rpop3_window.ping_tag = 0;
@@ -615,6 +617,8 @@ static gboolean rpop3_ping_cb(gpointer data)
if (rpop3_window.session->state == POP3_IDLE)
rpop3_noop_send(rpop3_window.session);
+ gdk_threads_leave();
+
return FALSE;
}
diff --git a/src/send_message.c b/src/send_message.c
index db474602..c44232d4 100644
--- a/src/send_message.c
+++ b/src/send_message.c
@@ -795,9 +795,12 @@ static gint send_recv_message(Session *session, const gchar *msg, gpointer data)
g_return_val_if_fail(dialog != NULL, -1);
+ gdk_threads_enter();
+
switch (smtp_session->state) {
case SMTP_READY:
case SMTP_CONNECTED:
+ gdk_threads_leave();
return 0;
case SMTP_HELO:
g_snprintf(buf, sizeof(buf), _("Sending HELO..."));
@@ -832,14 +835,18 @@ static gint send_recv_message(Session *session, const gchar *msg, gpointer data)
break;
case SMTP_ERROR:
g_warning("send: error: %s\n", msg);
+ gdk_threads_leave();
return 0;
default:
+ gdk_threads_leave();
return 0;
}
progress_dialog_set_label(dialog->dialog, buf);
progress_dialog_set_row_status(dialog->dialog, 0, state_str);
+ gdk_threads_leave();
+
return 0;
}
@@ -855,6 +862,8 @@ static gint send_send_data_progressive(Session *session, guint cur_len,
SMTP_SESSION(session)->state != SMTP_EOM)
return 0;
+ gdk_threads_enter();
+
g_snprintf(buf, sizeof(buf), _("Sending message (%d / %d bytes)"),
cur_len, total_len);
progress_dialog_set_label(dialog->dialog, buf);
@@ -866,6 +875,7 @@ static gint send_send_data_progressive(Session *session, guint cur_len,
#ifdef G_OS_WIN32
GTK_EVENTS_FLUSH();
#endif
+ gdk_threads_leave();
return 0;
}
@@ -877,6 +887,7 @@ static gint send_send_data_finished(Session *session, guint len, gpointer data)
g_return_val_if_fail(dialog != NULL, -1);
send_send_data_progressive(session, len, len, dialog);
+
return 0;
}
diff --git a/src/sigstatus.c b/src/sigstatus.c
index 5d4cafa1..d4d23723 100644
--- a/src/sigstatus.c
+++ b/src/sigstatus.c
@@ -161,10 +161,14 @@ static gint timeout_cb(gpointer data)
{
GpgmegtkSigStatus hd = data;
+ gdk_threads_enter();
+
hd->running = 0;
hd->timeout_id_valid = 0;
do_destroy(hd);
+ gdk_threads_leave();
+
return FALSE;
}
diff --git a/src/trayicon.c b/src/trayicon.c
index b142916e..9416141f 100644
--- a/src/trayicon.c
+++ b/src/trayicon.c
@@ -203,8 +203,11 @@ static guint notify_tag = 0;
gboolean notify_timeout_cb(gpointer data)
{
+ gdk_threads_enter();
gtk_status_icon_set_blinking(trayicon.status_icon, FALSE);
notify_tag = 0;
+ gdk_threads_leave();
+
return FALSE;
}