[anjal] unread message list based on thread.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] unread message list based on thread.
- Date: Wed, 18 Mar 2009 07:40:20 -0400 (EDT)
commit 3e0c941d115b62e74f4da0732cf0f0aacbf0c1e0
Author: Srinivasa Ragavan <sragavan novell com>
Date: Wed Mar 18 17:13:21 2009 +0530
unread message list based on thread.
---
src/mail-folder-view.c | 100 ++++++++++++++++++++++++++++++++++-------------
src/mail-folder-view.h | 2 +-
src/mail-message-view.c | 6 ++-
3 files changed, 79 insertions(+), 29 deletions(-)
diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index 182eb84..e795395 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -42,6 +42,7 @@ struct _MailFolderViewPrivate {
GtkWidget *tab_str;
CamelFolder *folder;
+ char *uri;
char *uid;
int sort_selected;
@@ -195,7 +196,8 @@ mail_folder_view_init (MailFolderView *shell)
gtk_widget_show_all (shell->tab_label);
g_object_unref (pbuf);
shell->priv->uid = NULL;
-
+ shell->priv->folder = NULL;
+ shell->priv->uri = NULL;
shell->priv->sort_selected = 1;
shell->priv->sort_ascending = FALSE;
}
@@ -203,6 +205,12 @@ mail_folder_view_init (MailFolderView *shell)
static void
mail_folder_view_finalize (GObject *object)
{
+ MailFolderView *mfv = (MailFolderView *)object;
+
+ g_object_unref (mfv->model);
+ camel_object_unref (mfv->priv->folder);
+ g_free (mfv->priv->uri);
+ g_free (mfv->priv);
G_OBJECT_CLASS (mail_folder_view_parent_class)->finalize (object);
}
@@ -251,6 +259,7 @@ db_read_done (struct _db_read_msg *m)
static void
db_read_free (struct _db_read_msg *m)
{
+ g_free(m->uri);
}
static MailMsgInfo db_read_info = {
@@ -268,7 +277,7 @@ mfv_db_load (MailFolderView *mfv, const char *uri, CamelFolder *folder)
m = mail_msg_new (&db_read_info);
m->mfv = mfv;
- m->uri = uri;
+ m->uri = g_strdup(uri);
m->folder = folder;
m->done = mail_folder_view_set_folder;
mail_msg_unordered_push (m);
@@ -284,6 +293,9 @@ mfv_got_folder(char *uri, CamelFolder *folder, void *data)
if (mfv->priv->folder) {
gtk_tree_view_set_model (GTK_TREE_VIEW (mfv->tree), NULL);
camel_object_unref (mfv->priv->folder);
+ mfv->priv->folder= NULL;
+ g_free(mfv->priv->uri);
+ mfv->priv->uri = NULL;
g_object_unref (mfv->model);
if (mfv->priv->light)
mfv->model = mail_sqlite_store_new ();
@@ -297,7 +309,7 @@ mfv_got_folder(char *uri, CamelFolder *folder, void *data)
m = mail_msg_new (&db_read_info);
m->mfv = mfv;
- m->uri = uri;
+ m->uri = g_strdup(uri);
m->folder = folder;
m->done = mail_folder_view_set_folder;
mail_msg_unordered_push (m);
@@ -307,6 +319,10 @@ void
mail_folder_view_set_folder_uri (MailFolderView *mfv, const char *uri)
{
char *str=NULL;
+
+ if (uri && mfv->priv->uri && !strcmp(uri, mfv->priv->uri))
+ return;
+
gtk_widget_show (mfv->priv->info_spinner);
gtk_widget_hide (mfv->mail);
gtk_widget_show (mfv->priv->info_bar);
@@ -323,7 +339,7 @@ mail_folder_view_set_folder_uri (MailFolderView *mfv, const char *uri)
void
mail_folder_view_set_folder (MailFolderView *mfv, CamelFolder *folder, const char *uri)
{
- /*
+
if (mfv->priv->folder) {
gtk_tree_view_set_model (GTK_TREE_VIEW (mfv->tree), NULL);
camel_object_unref (mfv->priv->folder);
@@ -335,17 +351,12 @@ mail_folder_view_set_folder (MailFolderView *mfv, CamelFolder *folder, const cha
((EMTreeStore *)mfv->model)->func = sorting[mfv->priv->sort_selected-1].func;;
((EMTreeStore *)mfv->model)->sort_ascending = mfv->priv->sort_ascending;
}
- }*/
+ }
if (folder) {
/* Load cursor based or folder based */
-/*
- if (mfv->priv->light)
- mail_sqlite_store_set_folder (mfv->model, folder, NULL);
- else
- em_tree_store_add_folder (mfv->model, folder, mfv->priv->expr, TRUE);
- */
+
gtk_tree_view_set_model (GTK_TREE_VIEW (mfv->tree), mfv->model);
-
+ mfv->priv->uri = g_strdup(uri);
mfv->priv->folder = folder;
gtk_widget_hide (mfv->mail);
gtk_widget_hide (mfv->priv->info_spinner);
@@ -355,7 +366,6 @@ mail_folder_view_set_folder (MailFolderView *mfv, CamelFolder *folder, const cha
gtk_label_set_text (mfv->priv->tab_str, folder->full_name);
-
/* FIXME: Set a signal emit and listen for it at note book and set the title appropriately */
}
}
@@ -478,6 +488,7 @@ draw_text (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *
GValue value = { 0, }, value1 = {0,};
int i=0;
gboolean bold, ellipsize, strike, markup;
+ gboolean unread;
guint32 flags;
/*
@@ -506,20 +517,30 @@ draw_text (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *
strike = GPOINTER_TO_INT(g_object_get_data(child, "p-strike")) ? TRUE : FALSE;
markup = GPOINTER_TO_INT(g_object_get_data(child, "p-markup")) ? TRUE : FALSE;
if (i !=-1) {
- GValue v = {0,};
+ GValue v = {0,}, v1 = {0};
g_value_init (&v, G_TYPE_UINT);
g_value_unset (&v);
+ g_value_init (&v1, G_TYPE_BOOLEAN);
+ g_value_unset (&v1);
gtk_tree_model_get_value (tree_model, iter, i, &value);
g_object_set_property ((GObject *)child, (gchar *) markup ? "markup" : "text", &value);
if (mfv->priv->light) {
gtk_tree_model_get_value (tree_model, iter, COL_FLAGS, &v);
- } else
+ } else {
gtk_tree_model_get_value (tree_model, iter, EMTS_COL_FLAGS, &v);
+ gtk_tree_model_get_value (tree_model, iter, EMTS_COL_UNREAD, &v1);
+ }
+ if(!mfv->priv->light)
+ unread = g_value_get_boolean (&v1);
flags = g_value_get_uint (&v);
g_object_set ((GObject *)child,"strikethrough", (strike && (flags &CAMEL_MESSAGE_DELETED)),
"ellipsize", ellipsize ? PANGO_ELLIPSIZE_END : PANGO_ELLIPSIZE_NONE, NULL);
- if (bold)
- g_object_set ((GObject *)child, "weight", ((!(flags &CAMEL_MESSAGE_SEEN))) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, NULL);
+ if (bold) {
+ if ( mfv->priv->light)
+ g_object_set ((GObject *)child, "weight", ((!(flags &CAMEL_MESSAGE_SEEN))) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, NULL);
+ else
+ g_object_set ((GObject *)child, "weight", (unread ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL), NULL);
+ }
g_value_unset (&value);
i=-1;
}
@@ -529,9 +550,11 @@ draw_text (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *
while (t) {
GtkCellRenderer *c = (GtkCellRenderer *)t->data;
if (GTK_IS_CELL_RENDERER_TEXT (c)) {
- GValue v = {0,};
+ GValue v = {0,}, v1 = {0};
g_value_init (&v, G_TYPE_UINT);
g_value_unset (&v);
+ g_value_init (&v1, G_TYPE_BOOLEAN);
+ g_value_unset (&v1);
i = GPOINTER_TO_INT(g_object_get_data(c, "data"));
ellipsize = GPOINTER_TO_INT(g_object_get_data(c, "p-ellipsize")) ? TRUE : FALSE;
bold = GPOINTER_TO_INT(g_object_get_data(c, "p-bold")) ? TRUE : FALSE;
@@ -547,14 +570,22 @@ draw_text (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *
}
if (mfv->priv->light) {
gtk_tree_model_get_value (tree_model, iter, COL_FLAGS, &v);
- } else
+ } else {
gtk_tree_model_get_value (tree_model, iter, EMTS_COL_FLAGS, &v);
+ gtk_tree_model_get_value (tree_model, iter, EMTS_COL_UNREAD, &v1);
+ }
- flags = g_value_get_uint (&v);
+ flags = g_value_get_uint (&v);
+ if(!mfv->priv->light)
+ unread = g_value_get_boolean (&v1);
g_object_set ((GObject *)c,"strikethrough", (strike && (flags &CAMEL_MESSAGE_DELETED)),
"ellipsize", ellipsize ? PANGO_ELLIPSIZE_END : PANGO_ELLIPSIZE_NONE, NULL);
- if (bold)
- g_object_set ((GObject *)c, "weight", ((!(flags &CAMEL_MESSAGE_SEEN))) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, NULL);
+ if (bold) {
+ if ( mfv->priv->light)
+ g_object_set ((GObject *)c, "weight", ((!(flags &CAMEL_MESSAGE_SEEN))) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, NULL);
+ else
+ g_object_set ((GObject *)c, "weight", (unread ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL), NULL);
+ }
g_value_unset (&value);
}
@@ -566,6 +597,10 @@ draw_text (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *
GtkCellRenderer *c = (GtkCellRenderer *)t->data;
guint32 flags;
if (GTK_IS_CELL_RENDERER_TEXT (c)) {
+ GValue v1 = {0};
+ g_value_init (&v1, G_TYPE_BOOLEAN);
+ g_value_unset (&v1);
+
i = GPOINTER_TO_INT(g_object_get_data(c, "data"));
ellipsize = GPOINTER_TO_INT(g_object_get_data(c, "p-ellipsize")) ? TRUE : FALSE;
bold = GPOINTER_TO_INT(g_object_get_data(c, "p-bold")) ? TRUE : FALSE;
@@ -589,13 +624,21 @@ draw_text (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *
}
if (mfv->priv->light)
gtk_tree_model_get_value (tree_model, iter, COL_FLAGS, &value1);
- else
- gtk_tree_model_get_value (tree_model, iter, EMTS_COL_FLAGS, &value1);
+ else {
+ gtk_tree_model_get_value (tree_model, iter, EMTS_COL_FLAGS, &value1);
+ gtk_tree_model_get_value (tree_model, iter, EMTS_COL_UNREAD, &v1);
+ }
flags = g_value_get_uint (&value1);
+ if(!mfv->priv->light)
+ unread = g_value_get_boolean (&v1);
+ if (bold) {
+ if ( mfv->priv->light)
+ g_object_set ((GObject *)c, "weight", ((!(flags &CAMEL_MESSAGE_SEEN))) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, NULL);
+ else
+ g_object_set ((GObject *)c, "weight", (unread ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL), NULL);
+ }
g_object_set ((GObject *)c,"strikethrough", (strike && (flags &CAMEL_MESSAGE_DELETED)),
"ellipsize", ellipsize ? PANGO_ELLIPSIZE_END : PANGO_ELLIPSIZE_NONE, NULL);
- if (bold)
- g_object_set ((GObject *)c, "weight", ((!(flags &CAMEL_MESSAGE_SEEN))) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, NULL);
g_value_unset (&value1);
}
@@ -945,13 +988,16 @@ mail_folder_view_show_sort_popup (MailFolderView *mfv, GtkWidget *button)
}
void
-mail_folder_view_activate (MailFolderView *mfv, GtkWidget *folder_tree, GtkWidget *check_mail, GtkWidget *sort_by, gboolean act)
+mail_folder_view_activate (MailFolderView *mfv, GtkWidget *tree, GtkWidget *folder_tree, GtkWidget *check_mail, GtkWidget *sort_by, gboolean act)
{
if (!folder_tree || !check_mail || !sort_by)
return;
gtk_widget_set_sensitive (folder_tree, act);
gtk_widget_set_sensitive (check_mail, act);
gtk_widget_set_sensitive (sort_by, act);
+ if (mfv->priv->folder) {
+ em_folder_tree_set_selected (tree, mfv->priv->uri, FALSE);
+ }
}
void
diff --git a/src/mail-folder-view.h b/src/mail-folder-view.h
index b04276a..6ab6a97 100644
--- a/src/mail-folder-view.h
+++ b/src/mail-folder-view.h
@@ -68,7 +68,7 @@ void mail_folder_view_set_folder_uri (MailFolderView *mfv, const char *uri);
void mail_folder_view_set_message (MailFolderView *mfv, const char *uid, gboolean nomarkseen);
void mail_folder_view_show_sort_popup (MailFolderView *, GtkWidget *);
void mail_folder_view_show_list (MailFolderView *mfv);
-void mail_folder_view_activate (MailFolderView *mfv, GtkWidget *folder_tree, GtkWidget *check_mail, GtkWidget *sort_by, gboolean act);
+void mail_folder_view_activate (MailFolderView *mfv, GtkWidget *tree, GtkWidget *folder_tree, GtkWidget *check_mail, GtkWidget *sort_by, gboolean act);
void mail_folder_view_check_mail (MailFolderView *mfv);
#endif
diff --git a/src/mail-message-view.c b/src/mail-message-view.c
index 0a52a2a..3a30542 100644
--- a/src/mail-message-view.c
+++ b/src/mail-message-view.c
@@ -384,7 +384,7 @@ void
mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, const char *uid)
{
GtkWidget *tmp;
- CamelMessageInfo *info;
+ CamelMessageInfoBase *info;
GtkWidget *box, *header_row, *details_row;
GtkWidget *reply, *reply_all, *forward, *discard;
char *str ,**strv;
@@ -590,6 +590,10 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
gtk_container_add (mmview->frame, mmview->comp_view);
gtk_box_pack_start (mmview, mmview->frame, FALSE, FALSE, 18);
gtk_widget_hide (mmview->comp_view);
+
+ if (!(info->flags & CAMEL_MESSAGE_SEEN))
+ mmv_show(mmview);
+ camel_message_info_free(info);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]