[anjal] BUGFIX: #581402 - Load message one by one in the thread view.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] BUGFIX: #581402 - Load message one by one in the thread view.
- Date: Fri, 19 Jun 2009 14:41:42 -0400 (EDT)
commit 79ba40e77b783c6a8717ba0db22a9bde9b3bf994
Author: Srinivasa Ragavan <sragavan novell com>
Date: Sat Jun 20 00:12:20 2009 +0530
BUGFIX: #581402 - Load message one by one in the thread view.
src/mail-conv-view.c | 63 +++++++++++++++++++++++++++++++++++++++++-----
src/mail-message-view.c | 21 ++++++++++++---
src/mail-message-view.h | 3 +-
3 files changed, 74 insertions(+), 13 deletions(-)
---
diff --git a/src/mail-conv-view.c b/src/mail-conv-view.c
index e567045..f94b262 100644
--- a/src/mail-conv-view.c
+++ b/src/mail-conv-view.c
@@ -42,6 +42,8 @@ struct _MailConvViewPrivate {
GtkWidget *viewport;
GList *child;
GList *selected_child;
+ MailMessageView **load_chain;
+ gint position;
gboolean once;
};
@@ -52,6 +54,9 @@ mail_conv_view_init (MailConvView *shell)
shell->uri = "message://";
shell->type = -1;
shell->priv->once = FALSE;
+ shell->priv->load_chain = NULL;
+ shell->priv->position = -1;
+
}
static void
@@ -330,15 +335,39 @@ mcv_message_reply (MailMessageView *mmv, MailConvView *mcv)
gtk_adjustment_set_value (adj, y+((GtkWidget *)mmv)->allocation.height);
}
+static gboolean
+render_msg (MailConvView *mcv)
+{
+ MailMessageView *child = mcv->priv->load_chain[mcv->priv->position];
+
+ mail_message_view_show_message ((MailMessageView *)child, FALSE);
+ return FALSE;
+}
+static void
+mcv_msg_load_chain (MailMessageView *mmv, MailConvView *mcv)
+{
+ g_signal_handlers_disconnect_by_func(mmv, mcv_msg_load_chain, mcv);
+
+ mcv->priv->position++;
+ if (mcv->priv->load_chain[mcv->priv->position]) {
+ MailMessageView *child = mcv->priv->load_chain[mcv->priv->position];
+ // g_signal_connect (child, "message-rendered", G_CALLBACK(mcv_msg_load_chain), mcv);
+ // mail_message_view_show_message ((MailMessageView *)child, FALSE);
+ g_signal_connect (child, "message-rendered", G_CALLBACK(mcv_msg_load_chain), mcv);
+ g_timeout_add (20, (GSourceFunc) render_msg, mcv);
+ }
+}
+
void
mail_conv_view_set_thread (MailConvView *mcv, CamelFolder *folder, GPtrArray *array)
{
GtkWidget *tmp = NULL;
- int i;
+ int i, j;
GList *focus = NULL;
extern char *scolor_bg_norm;
GtkWidget *unread = NULL;
-
+ gboolean last_mail_shown = FALSE;
+
if (mcv->child_box) {
tmp = mcv->child_box;
gtk_widget_hide (tmp);
@@ -353,8 +382,9 @@ mail_conv_view_set_thread (MailConvView *mcv, CamelFolder *folder, GPtrArray *ar
scolor_bg_norm);
gtk_container_add ((GtkContainer *)mcv->priv->viewport, mcv->child_box);
-
- for (i=0; i<array->len; i++) {
+ mcv->priv->position = 0;
+ mcv->priv->load_chain = g_malloc0(sizeof (gpointer) * (array->len+1));
+ for (i=0, j=0; i<array->len; i++) {
GtkWidget *child;
child = (GtkWidget *)mail_message_view_new ();
@@ -366,21 +396,29 @@ mail_conv_view_set_thread (MailConvView *mcv, CamelFolder *folder, GPtrArray *ar
g_signal_connect (child, "message-removed", G_CALLBACK(mcv_message_removed), mcv);
g_signal_connect (child, "message-reply", G_CALLBACK(mcv_message_reply), mcv);
focus = g_list_prepend (focus, (gpointer)mail_message_view_get_focus_widget((MailMessageView *)child));
+
+ if (mail_message_view_get_unread ((MailMessageView *)child)) {
+ mcv->priv->load_chain[j] = (MailMessageView *)child;
+ j++;
+ }
if (!unread) {
if (mail_message_view_get_unread ((MailMessageView *)child))
unread = mail_message_view_get_focus_widget((MailMessageView *)child);
- g_signal_connect (child, "message-loaded", G_CALLBACK(mcv_scroll_to_mmv), mcv);
+ g_signal_connect (child, "message-loaded", G_CALLBACK(mcv_scroll_to_mmv), mcv);
}
if (i == array->len -1) {
if (!unread) {
unread = mail_message_view_get_focus_widget((MailMessageView *)child);
g_signal_connect (child, "message-loaded", G_CALLBACK(mcv_scroll_to_mmv), mcv);
+ last_mail_shown = TRUE;
}
- mail_message_view_show_message ((MailMessageView *)child);
+ if (j>0)
+ mcv->priv->load_chain[j-1] = NULL;
+ mail_message_view_show_message ((MailMessageView *)child, TRUE);
}
}
-
+
focus = g_list_reverse (focus);
mcv->priv->child = focus;
@@ -396,6 +434,17 @@ mail_conv_view_set_thread (MailConvView *mcv, CamelFolder *folder, GPtrArray *ar
gtk_widget_grab_focus (mcv->priv->child->data);
g_signal_emit (mcv, signals[MESSAGE_SHOWN], 0);
+
+ /* Start showing the message */
+ if (!last_mail_shown && j > 1) {
+ mcv->priv->position = 0;
+ g_signal_connect (mcv->priv->load_chain[mcv->priv->position], "message-rendered", G_CALLBACK(mcv_msg_load_chain), mcv);
+ mail_message_view_show_message ((MailMessageView *)mcv->priv->load_chain[mcv->priv->position], FALSE);
+ } else {
+ g_free (mcv->priv->load_chain);
+ mcv->priv->load_chain = NULL;
+ mcv->priv->position = -1;
+ }
}
static gboolean
diff --git a/src/mail-message-view.c b/src/mail-message-view.c
index 6dd468b..82ad4f2 100644
--- a/src/mail-message-view.c
+++ b/src/mail-message-view.c
@@ -85,6 +85,7 @@ G_DEFINE_TYPE (MailMessageView, mail_message_view, GTK_TYPE_VBOX)
struct _EComposerHeaderTable *e_msg_composer_get_header_table (struct _EMsgComposer *);
enum {
+ MESSAGE_RENDERED,
MESSAGE_SELECTED,
MESSAGE_REMOVED,
MESSAGE_LOADED,
@@ -148,6 +149,14 @@ mail_message_view_class_init (MailMessageViewClass *klass)
mail_message_view_parent_class = g_type_class_peek_parent (klass);
object_class->finalize = mail_message_view_finalize;
+ signals[MESSAGE_RENDERED] =
+ g_signal_new ("message-rendered",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (MailMessageViewClass , message_rendered),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
signals[MESSAGE_SELECTED] =
g_signal_new ("message-selected",
G_OBJECT_CLASS_TYPE (object_class),
@@ -288,9 +297,10 @@ mmv_collapse (MailMessageView *mmv)
}
void
-mail_message_view_show_message (MailMessageView *mmv)
+mail_message_view_show_message (MailMessageView *mmv, gboolean show_composer)
{
- mmv->priv->show_composer = TRUE;
+ if (show_composer)
+ mmv->priv->show_composer = TRUE;
mmv_show (mmv);
}
@@ -617,7 +627,8 @@ mmv_finished_loading_webkit (WebKitWebView *webkitwebview, WebKitWebFrame *arg1
g_signal_connect (webkitwebview, "expose-event" , G_CALLBACK(mark_mail_read), mmview);
g_signal_emit (mmview, signals[MESSAGE_LOADED], 0);
gdk_window_invalidate_rect (((GtkWidget *)mmview)->window, NULL, TRUE);
- gtk_widget_queue_draw ((GtkWidget *)mmview);
+ gtk_widget_queue_draw ((GtkWidget *)mmview);
+ g_signal_emit (mmview, signals[MESSAGE_RENDERED], 0);
}
@@ -636,7 +647,7 @@ mmv_finished_mozilla (GtkWidget *w, MailMessageView *mmv)
{
g_signal_connect (w, "expose-event" , mark_mail_read, mmv);
g_signal_emit (mmv, signals[MESSAGE_LOADED], 0);
-
+ g_signal_emit (mmview, signals[MESSAGE_RENDERED], 0);
return FALSE;
}
#endif
@@ -1317,7 +1328,7 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
if (!(info->flags & CAMEL_MESSAGE_SEEN)) {
mmview->priv->show_composer = show_composer;
- mmv_show(mmview);
+ // mmv_show(mmview);
}
}
diff --git a/src/mail-message-view.h b/src/mail-message-view.h
index b705492..6707a12 100644
--- a/src/mail-message-view.h
+++ b/src/mail-message-view.h
@@ -65,6 +65,7 @@ typedef struct _MailMessageView {
typedef struct _MailMessageViewClass {
GtkVBoxClass parent_class;
+ void (*message_rendered) (MailMessageView *);
void (*message_selected) (MailMessageView *);
void (*message_removed) (MailMessageView *);
void (*message_loaded) (MailMessageView *);
@@ -80,5 +81,5 @@ GtkWidget * mail_message_view_get_focus_widget (MailMessageView *mmv);
gboolean mail_message_view_get_unread (MailMessageView *mmv);
void mail_message_view_set_web_flags (gpointer web, int flags);
GtkWidget * mail_message_view_get_body (CamelStream *stream);
-void mail_message_view_show_message (MailMessageView *mmv);
+void mail_message_view_show_message (MailMessageView *mmv, gboolean show_composer);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]