diff options
author | Milan Crha <mcrha@redhat.com> | 2009-05-30 13:07:39 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-06-01 20:54:19 +0800 |
commit | de681d39eb1980215c71de9b338e24d0031c0d27 (patch) | |
tree | 6f95b23f81bd1a18ebdb72e8a4c7acc00181b8cb /mail | |
parent | 9e5775a7f6b7ba129e4538dbc0e6dfdaf7402f22 (diff) | |
download | gsoc2013-evolution-de681d39eb1980215c71de9b338e24d0031c0d27.tar gsoc2013-evolution-de681d39eb1980215c71de9b338e24d0031c0d27.tar.gz gsoc2013-evolution-de681d39eb1980215c71de9b338e24d0031c0d27.tar.bz2 gsoc2013-evolution-de681d39eb1980215c71de9b338e24d0031c0d27.tar.lz gsoc2013-evolution-de681d39eb1980215c71de9b338e24d0031c0d27.tar.xz gsoc2013-evolution-de681d39eb1980215c71de9b338e24d0031c0d27.tar.zst gsoc2013-evolution-de681d39eb1980215c71de9b338e24d0031c0d27.zip |
Bug 323037 – Folder emblem to show new mail arrival
Diffstat (limited to 'mail')
-rw-r--r-- | mail/em-folder-tree-model.c | 51 | ||||
-rw-r--r-- | mail/em-folder-tree-model.h | 1 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 64 |
3 files changed, 97 insertions, 19 deletions
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index a12b453e53..f04cf03720 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -65,19 +65,6 @@ #define u(x) /* unread count debug */ #define d(x) -static GType col_types[] = { - G_TYPE_STRING, /* display name */ - G_TYPE_POINTER, /* store object */ - G_TYPE_STRING, /* full name */ - G_TYPE_STRING, /* icon name */ - G_TYPE_STRING, /* uri */ - G_TYPE_UINT, /* unread count */ - G_TYPE_UINT, /* flags */ - G_TYPE_BOOLEAN, /* is a store node */ - G_TYPE_BOOLEAN, /* is a folder node */ - G_TYPE_BOOLEAN, /* has not-yet-loaded subfolders */ -}; - /* GObject virtual method overrides */ static void em_folder_tree_model_class_init (EMFolderTreeModelClass *klass); static void em_folder_tree_model_init (EMFolderTreeModel *model); @@ -374,6 +361,20 @@ em_folder_tree_model_new (const gchar *evolution_dir) EMFolderTreeModel *model; gchar *filename; + GType col_types[] = { + G_TYPE_STRING, /* display name */ + G_TYPE_POINTER, /* store object */ + G_TYPE_STRING, /* full name */ + G_TYPE_STRING, /* icon name */ + G_TYPE_STRING, /* uri */ + G_TYPE_UINT, /* unread count */ + G_TYPE_UINT, /* flags */ + G_TYPE_BOOLEAN, /* is a store node */ + G_TYPE_BOOLEAN, /* is a folder node */ + G_TYPE_BOOLEAN, /* has not-yet-loaded subfolders */ + G_TYPE_UINT /* last known unread count */ + }; + model = g_object_new (EM_TYPE_FOLDER_TREE_MODEL, NULL); gtk_tree_store_set_column_types ((GtkTreeStore *) model, NUM_COLUMNS, col_types); gtk_tree_sortable_set_sort_column_id ((GtkTreeSortable *) model, @@ -540,13 +541,16 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite COL_BOOL_IS_STORE, FALSE, COL_BOOL_IS_FOLDER, TRUE, COL_BOOL_LOAD_SUBDIRS, load, + COL_UINT_UNREAD_LAST_SEL, 0, -1); target = em_event_target_new_custom_icon (em_event_peek(), tree_store, iter, fi->full_name, EM_EVENT_CUSTOM_ICON); e_event_emit ((EEvent *)em_event_peek (), "folder.customicon", (EEventTarget *) target); if (unread != ~0) - gtk_tree_store_set (tree_store, iter, COL_UINT_UNREAD, unread, -1); + gtk_tree_store_set ( + tree_store, iter, COL_UINT_UNREAD, unread, + COL_UINT_UNREAD_LAST_SEL, unread, -1); if (load) { /* create a placeholder node for our subfolders... */ @@ -562,6 +566,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite COL_BOOL_IS_FOLDER, FALSE, COL_STRING_URI, NULL, COL_UINT_UNREAD, 0, + COL_UINT_UNREAD_LAST_SEL, 0, -1); path = gtk_tree_model_get_path ((GtkTreeModel *) model, iter); @@ -869,6 +874,7 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, CamelStore *store, con COL_BOOL_IS_STORE, FALSE, COL_STRING_URI, NULL, COL_UINT_UNREAD, 0, + COL_UINT_UNREAD_LAST_SEL, 0, -1); g_free (uri); @@ -1323,6 +1329,8 @@ em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *sto GtkTreeRowReference *row; GtkTreePath *tree_path; GtkTreeIter iter; + guint old_unread = 0; + gchar *uri, *sel_uri; g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model)); g_return_if_fail (CAMEL_IS_STORE (store)); @@ -1351,7 +1359,20 @@ em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *sto gtk_tree_path_free (tree_path); - gtk_tree_store_set ((GtkTreeStore *) model, &iter, COL_UINT_UNREAD, unread, -1); + sel_uri = em_folder_tree_model_get_selected (model); + gtk_tree_model_get ( + GTK_TREE_MODEL (model), &iter, + COL_UINT_UNREAD_LAST_SEL, &old_unread, + COL_STRING_URI, &uri, -1); + if (!(g_strcmp0 (sel_uri, uri) != 0 && unread > old_unread)) + old_unread = unread; + gtk_tree_store_set ( + GTK_TREE_STORE (model), &iter, + COL_UINT_UNREAD, unread, + COL_UINT_UNREAD_LAST_SEL, old_unread, -1); + + g_free (uri); + g_free (sel_uri); /* May be this is from where we should propagate unread count to parents etc. */ emft_model_unread_count_changed (GTK_TREE_MODEL (model), &iter); diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h index 3748da79a0..563ede2787 100644 --- a/mail/em-folder-tree-model.h +++ b/mail/em-folder-tree-model.h @@ -61,6 +61,7 @@ enum { COL_BOOL_LOAD_SUBDIRS, /* %TRUE only if the store/folder * has subfolders which have not yet * been added to the tree */ + COL_UINT_UNREAD_LAST_SEL, /* last known unread count */ NUM_COLUMNS }; diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index a7b56e7fcb..25c7809c54 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -309,6 +309,49 @@ render_display_name (GtkTreeViewColumn *column, GtkCellRenderer *renderer, g_free (display); } +static void +render_icon (GtkTreeViewColumn *column, + GtkCellRenderer *renderer, + GtkTreeModel *model, + GtkTreeIter *iter) +{ + GIcon *icon; + guint unread; + guint old_unread; + gchar *icon_name; + + gtk_tree_model_get ( + model, iter, + COL_STRING_ICON_NAME, &icon_name, + COL_UINT_UNREAD_LAST_SEL, &old_unread, + COL_UINT_UNREAD, &unread, -1); + + if (icon_name == NULL) + return; + + icon = g_themed_icon_new (icon_name); + + /* Show an emblem if there's new mail. */ + if (unread > old_unread) { + GIcon *temp_icon; + GEmblem *emblem; + + temp_icon = g_themed_icon_new ("emblem-new"); + emblem = g_emblem_new (temp_icon); + g_object_unref (temp_icon); + + temp_icon = g_emblemed_icon_new (icon, emblem); + g_object_unref (emblem); + g_object_unref (icon); + + icon = temp_icon; + } + + g_object_set (renderer, "gicon", icon, NULL); + + g_object_unref (icon); +} + static gboolean emft_select_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean selected, gpointer data) { @@ -441,9 +484,10 @@ folder_tree_new (EMFolderTree *emft, EMFolderTreeModel *model) renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_add_attribute ( - column, renderer, "icon-name", COL_STRING_ICON_NAME); - gtk_tree_view_column_add_attribute ( column, renderer, "visible", COL_BOOL_IS_FOLDER); + gtk_tree_view_column_set_cell_data_func ( + column, renderer, (GtkTreeCellDataFunc) + render_icon, NULL, NULL); renderer = gtk_cell_renderer_text_new (); if (!gconf_client_get_bool (gconf, "/apps/evolution/mail/display/no_folder_dots", NULL)) @@ -2256,6 +2300,8 @@ emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft) GtkTreeModel *model; GtkTreeIter iter; guint32 flags; + guint unread = 0; + guint old_unread = 0; if (!emft_selection_get_selected (selection, &model, &iter)) { em_folder_tree_model_set_selected (emft->priv->model, NULL); @@ -2264,8 +2310,18 @@ emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft) return; } - gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &full_name, - COL_STRING_URI, &uri, COL_UINT_FLAGS, &flags, -1); + gtk_tree_model_get ( + model, &iter, + COL_STRING_FULL_NAME, &full_name, + COL_STRING_URI, &uri, COL_UINT_FLAGS, &flags, + COL_UINT_UNREAD, &unread, COL_UINT_UNREAD_LAST_SEL, + &old_unread, -1); + + /* Sync unread counts to distinguish new incoming mail. */ + if (unread != old_unread) + gtk_tree_store_set ( + GTK_TREE_STORE (model), &iter, + COL_UINT_UNREAD_LAST_SEL, unread, -1); g_signal_emit (emft, signals[FOLDER_SELECTED], 0, full_name, uri, flags); g_free(uri); |