aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-05-25 03:24:15 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-05-25 03:24:15 +0800
commitd3a3c1c3f0616f9bf1559f88b073b70d8e5d0bfc (patch)
treea58155322fdb17a1d8b07b08c08fd62d4137b46e
parentf575a7626a769b0a99e080944749958d644d4aef (diff)
downloadgsoc2013-evolution-d3a3c1c3f0616f9bf1559f88b073b70d8e5d0bfc.tar.gz
gsoc2013-evolution-d3a3c1c3f0616f9bf1559f88b073b70d8e5d0bfc.tar.zst
gsoc2013-evolution-d3a3c1c3f0616f9bf1559f88b073b70d8e5d0bfc.zip
Use named icons in the folder tree instead of pixbufs.
-rw-r--r--mail/em-folder-tree-model.c62
-rw-r--r--mail/em-folder-tree-model.h2
-rw-r--r--mail/em-folder-tree.c86
-rw-r--r--mail/em-folder-utils.c37
-rw-r--r--mail/em-folder-utils.h37
5 files changed, 107 insertions, 117 deletions
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 04e66e2c86..94b5e4f0bc 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -54,6 +54,7 @@
#include "mail-folder-cache.h"
#include "em-utils.h"
+#include "em-folder-utils.h"
#include <camel/camel-folder.h>
#include <camel/camel-vee-store.h>
@@ -66,11 +67,13 @@
static GType col_types[] = {
G_TYPE_STRING, /* display name */
G_TYPE_POINTER, /* store object */
- G_TYPE_STRING, /* path */
+ 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 */
};
@@ -439,6 +442,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite
CamelFolderInfo *fi, int fully_loaded)
{
GtkTreeRowReference *uri_row, *path_row;
+ GtkTreeStore *tree_store;
unsigned int unread;
GtkTreePath *path;
GtkTreeIter sub;
@@ -446,12 +450,15 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite
struct _CamelFolder *folder;
gboolean emitted = FALSE;
const char *name;
+ const gchar *icon_name;
guint32 flags;
/* make sure we don't already know about it? */
if (g_hash_table_lookup (si->full_hash, fi->full_name))
return;
-
+
+ tree_store = GTK_TREE_STORE (model);
+
if (!fully_loaded)
load = fi->child == NULL && !(fi->flags & (CAMEL_FOLDER_NOCHILDREN | CAMEL_FOLDER_NOINFERIORS));
@@ -516,31 +523,40 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite
}
}
- gtk_tree_store_set ((GtkTreeStore *) model, iter,
- COL_STRING_DISPLAY_NAME, name,
- COL_POINTER_CAMEL_STORE, si->store,
- COL_STRING_FULL_NAME, fi->full_name,
- COL_STRING_URI, fi->uri,
- COL_UINT_FLAGS, flags,
- COL_BOOL_IS_STORE, FALSE,
- COL_BOOL_LOAD_SUBDIRS, load,
- -1);
+ /* Choose an icon name for the folder. */
+ icon_name = em_folder_utils_get_icon_name (flags);
+
+ gtk_tree_store_set (
+ tree_store, iter,
+ COL_STRING_DISPLAY_NAME, name,
+ COL_POINTER_CAMEL_STORE, si->store,
+ COL_STRING_FULL_NAME, fi->full_name,
+ COL_STRING_ICON_NAME, icon_name,
+ COL_STRING_URI, fi->uri,
+ COL_UINT_FLAGS, flags,
+ COL_BOOL_IS_STORE, FALSE,
+ COL_BOOL_IS_FOLDER, TRUE,
+ COL_BOOL_LOAD_SUBDIRS, load,
+ -1);
if (unread != ~0)
- gtk_tree_store_set ((GtkTreeStore *) model, iter, COL_UINT_UNREAD, unread, -1);
+ gtk_tree_store_set (tree_store, iter, COL_UINT_UNREAD, unread, -1);
if (load) {
/* create a placeholder node for our subfolders... */
- gtk_tree_store_append ((GtkTreeStore *) model, &sub, iter);
- gtk_tree_store_set ((GtkTreeStore *) model, &sub,
- COL_STRING_DISPLAY_NAME, _("Loading..."),
- COL_POINTER_CAMEL_STORE, NULL,
- COL_STRING_FULL_NAME, NULL,
- COL_BOOL_LOAD_SUBDIRS, FALSE,
- COL_BOOL_IS_STORE, FALSE,
- COL_STRING_URI, NULL,
- COL_UINT_UNREAD, 0,
- -1);
+ gtk_tree_store_append (tree_store, &sub, iter);
+ gtk_tree_store_set (
+ tree_store, &sub,
+ COL_STRING_DISPLAY_NAME, _("Loading..."),
+ COL_POINTER_CAMEL_STORE, NULL,
+ COL_STRING_FULL_NAME, NULL,
+ COL_STRING_ICON_NAME, NULL,
+ COL_BOOL_LOAD_SUBDIRS, FALSE,
+ COL_BOOL_IS_STORE, FALSE,
+ COL_BOOL_IS_FOLDER, FALSE,
+ COL_STRING_URI, NULL,
+ COL_UINT_UNREAD, 0,
+ -1);
path = gtk_tree_model_get_path ((GtkTreeModel *) model, iter);
g_signal_emit (model, signals[LOADING_ROW], 0, path, iter);
@@ -552,7 +568,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite
fi = fi->child;
do {
- gtk_tree_store_append ((GtkTreeStore *) model, &sub, iter);
+ gtk_tree_store_append (tree_store, &sub, iter);
if (!emitted) {
path = gtk_tree_model_get_path ((GtkTreeModel *) model, iter);
diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h
index 3247eee308..13114c8539 100644
--- a/mail/em-folder-tree-model.h
+++ b/mail/em-folder-tree-model.h
@@ -51,11 +51,13 @@ enum {
COL_STRING_DISPLAY_NAME, /* string that appears in the tree */
COL_POINTER_CAMEL_STORE, /* CamelStore object */
COL_STRING_FULL_NAME, /* if node is a folder, the full path name of the folder, no leading / */
+ COL_STRING_ICON_NAME, /* icon name for the folder */
COL_STRING_URI, /* the uri to get the store or folder object */
COL_UINT_UNREAD, /* unread count */
COL_UINT_FLAGS, /* FolderInfo.flags */
COL_BOOL_IS_STORE, /* toplevel store node? */
+ COL_BOOL_IS_FOLDER, /* folder (not a store) */
COL_BOOL_LOAD_SUBDIRS, /* %TRUE only if the store/folder
* has subfolders which have not yet
* been added to the tree */
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 6c653116c4..14313385b4 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -262,87 +262,6 @@ subdirs_contain_unread (GtkTreeModel *model, GtkTreeIter *root)
return FALSE;
}
-
-enum {
- FOLDER_ICON_NORMAL,
- FOLDER_ICON_INBOX,
- FOLDER_ICON_OUTBOX,
- FOLDER_ICON_TRASH,
- FOLDER_ICON_JUNK,
- FOLDER_ICON_SHARED_TO_ME,
- FOLDER_ICON_SHARED_BY_ME,
- FOLDER_ICON_SENT,
- FOLDER_ICON_VIRTUAL,
- FOLDER_ICON_LAST
-};
-
-static GdkPixbuf *folder_icons[FOLDER_ICON_LAST];
-
-static void
-render_pixbuf (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
- GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
-{
- static gboolean initialised = FALSE;
- GdkPixbuf *pixbuf = NULL;
- gboolean is_store;
- guint32 flags;
- EMEventTargetCustomIcon *target;
- const char *folder_name;
-
- if (!initialised) {
- folder_icons[FOLDER_ICON_NORMAL] = e_icon_factory_get_icon ("folder", GTK_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_INBOX] = e_icon_factory_get_icon ("mail-inbox", GTK_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_OUTBOX] = e_icon_factory_get_icon ("mail-outbox", GTK_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_TRASH] = e_icon_factory_get_icon ("user-trash", GTK_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_JUNK] = e_icon_factory_get_icon ("mail-mark-junk", GTK_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_SHARED_TO_ME] = e_icon_factory_get_icon ("stock_shared-to-me", GTK_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_SHARED_BY_ME] = e_icon_factory_get_icon ("stock_shared-by-me", GTK_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_SENT] = e_icon_factory_get_icon ("mail-sent", GTK_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_VIRTUAL] = e_icon_factory_get_icon ("folder-saved-search", GTK_ICON_SIZE_MENU);
-
- initialised = TRUE;
- }
-
- gtk_tree_model_get (model, iter, COL_BOOL_IS_STORE, &is_store, COL_UINT_FLAGS, &flags, -1);
-
- if (!is_store) {
- switch((flags & CAMEL_FOLDER_TYPE_MASK)) {
- case CAMEL_FOLDER_TYPE_INBOX:
- pixbuf = folder_icons[FOLDER_ICON_INBOX];
- break;
- case CAMEL_FOLDER_TYPE_OUTBOX:
- pixbuf = folder_icons[FOLDER_ICON_OUTBOX];
- break;
- case CAMEL_FOLDER_TYPE_TRASH:
- pixbuf = folder_icons[FOLDER_ICON_TRASH];
- break;
- case CAMEL_FOLDER_TYPE_JUNK:
- pixbuf = folder_icons[FOLDER_ICON_JUNK];
- break;
- case CAMEL_FOLDER_TYPE_SENT:
- pixbuf = folder_icons[FOLDER_ICON_SENT];
- break;
- default:
- if (flags & CAMEL_FOLDER_SHARED_TO_ME)
- pixbuf = folder_icons[FOLDER_ICON_SHARED_TO_ME];
- else if (flags & CAMEL_FOLDER_SHARED_BY_ME)
- pixbuf = folder_icons[FOLDER_ICON_SHARED_BY_ME];
- else if (flags & CAMEL_FOLDER_VIRTUAL)
- pixbuf = folder_icons[FOLDER_ICON_VIRTUAL];
- else {
- pixbuf = folder_icons[FOLDER_ICON_NORMAL];
- g_object_set (renderer, "pixbuf", pixbuf, "visible", !is_store, NULL);
- gtk_tree_model_get (model, iter, COL_STRING_FULL_NAME, &folder_name, -1);
- target = em_event_target_new_custom_icon (em_event_peek(), renderer, folder_name, EM_EVENT_CUSTOM_ICON);
- e_event_emit ((EEvent *)em_event_peek (), "folder.customicon", (EEventTarget *) target);
- return;
- }
- }
- }
-
- g_object_set (renderer, "pixbuf", pixbuf, "visible", !is_store, NULL);
-}
-
static void
render_display_name (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
@@ -520,7 +439,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_set_cell_data_func (column, renderer, render_pixbuf, NULL, NULL);
+ 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);
renderer = gtk_cell_renderer_text_new ();
if (!gconf_client_get_bool (gconf, "/apps/evolution/mail/display/no_folder_dots", NULL))
diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
index 80d4fde143..05dcdc7363 100644
--- a/mail/em-folder-utils.c
+++ b/mail/em-folder-utils.c
@@ -40,8 +40,6 @@
#include <glib/gi18n.h>
#include <camel/camel-session.h>
-#include <camel/camel-store.h>
-#include <camel/camel-folder.h>
#include <camel/camel-vee-store.h>
#include <camel/camel-vtrash-folder.h>
#include <camel/camel-stream-mem.h>
@@ -707,3 +705,38 @@ em_folder_utils_create_folder (CamelFolderInfo *folderinfo, EMFolderTree *emft,
g_signal_connect (dialog, "response", G_CALLBACK (emfu_popup_new_folder_response), emft);
gtk_widget_show (dialog);
}
+
+const gchar *
+em_folder_utils_get_icon_name (guint32 flags)
+{
+ const gchar *icon_name;
+
+ switch (flags & CAMEL_FOLDER_TYPE_MASK) {
+ case CAMEL_FOLDER_TYPE_INBOX:
+ icon_name = "mail-inbox";
+ break;
+ case CAMEL_FOLDER_TYPE_OUTBOX:
+ icon_name = "mail-outbox";
+ break;
+ case CAMEL_FOLDER_TYPE_TRASH:
+ icon_name = "user-trash";
+ break;
+ case CAMEL_FOLDER_TYPE_JUNK:
+ icon_name = "mail-mark-junk";
+ break;
+ case CAMEL_FOLDER_TYPE_SENT:
+ icon_name = "mail-sent";
+ break;
+ default:
+ if (flags & CAMEL_FOLDER_SHARED_TO_ME)
+ icon_name = "stock_shared-to-me";
+ else if (flags & CAMEL_FOLDER_SHARED_BY_ME)
+ icon_name = "stock_shared-by-me";
+ else if (flags & CAMEL_FOLDER_VIRTUAL)
+ icon_name = "folder-saved-search";
+ else
+ icon_name = "folder";
+ }
+
+ return icon_name;
+}
diff --git a/mail/em-folder-utils.h b/mail/em-folder-utils.h
index 73b7bc96b2..4d03ce5762 100644
--- a/mail/em-folder-utils.h
+++ b/mail/em-folder-utils.h
@@ -21,20 +21,37 @@
*
*/
-#ifndef _EM_FOLDER_UTILS_H
-#define _EM_FOLDER_UTILS_H
+#ifndef EM_FOLDER_UTILS_H
+#define EM_FOLDER_UTILS_H
-struct _GtkWindow;
+#include <glib.h>
+#include <camel/camel-folder.h>
+#include <camel/camel-store.h>
+#include <mail/em-folder-tree.h>
-int em_folder_utils_copy_folders(CamelStore *fromstore, const char *frombase, CamelStore *tostore, const char *tobase, int delete);
+G_BEGIN_DECLS
-/* FIXME: These api's are really busted, there is no consistency and most rely on the wrong data */
+gint em_folder_utils_copy_folders (CamelStore *fromstore,
+ const gchar *frombase,
+ CamelStore *tostore,
+ const gchar *tobase,
+ int delete);
-void em_folder_utils_copy_folder (struct _CamelFolderInfo *folderinfo, int delete);
+/* FIXME These API's are really busted. There is no consistency and
+ * most rely on the wrong data. */
-void em_folder_utils_delete_folder (struct _CamelFolder *folder);
-void em_folder_utils_rename_folder (struct _CamelFolder *folder);
+void em_folder_utils_copy_folder (CamelFolderInfo *folderinfo,
+ int delete);
-void em_folder_utils_create_folder (struct _CamelFolderInfo *folderinfo, EMFolderTree * emft, struct _GtkWindow *parent);
+void em_folder_utils_delete_folder (CamelFolder *folder);
+void em_folder_utils_rename_folder (CamelFolder *folder);
-#endif
+void em_folder_utils_create_folder (CamelFolderInfo *folderinfo,
+ EMFolderTree * emft,
+ GtkWindow *parent);
+
+const gchar * em_folder_utils_get_icon_name (guint32 flags);
+
+G_END_DECLS
+
+#endif /* EM_FOLDER_UTILS_H */