aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-01-25 11:28:18 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-01-25 11:28:18 +0800
commit32ffc3ca1ca80b2d843fbe28da7deab35fabcbf1 (patch)
tree36f52060c250aacf445013b1bf15541892098f3f /mail
parentcbb3a71adc5551f4c600cfc6f53fc112f3022a78 (diff)
downloadgsoc2013-evolution-32ffc3ca1ca80b2d843fbe28da7deab35fabcbf1.tar.gz
gsoc2013-evolution-32ffc3ca1ca80b2d843fbe28da7deab35fabcbf1.tar.zst
gsoc2013-evolution-32ffc3ca1ca80b2d843fbe28da7deab35fabcbf1.zip
Make the sidebar icon follow the folder icon.
Fix more runtime warnings. svn path=/branches/kill-bonobo/; revision=37130
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-shell-content.c10
-rw-r--r--mail/e-mail-shell-sidebar.c47
-rw-r--r--mail/e-mail-shell-view-private.c6
-rw-r--r--mail/em-folder-tree-model.c59
-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.h36
8 files changed, 165 insertions, 118 deletions
diff --git a/mail/e-mail-shell-content.c b/mail/e-mail-shell-content.c
index ece2e2ee3a..5019d234bc 100644
--- a/mail/e-mail-shell-content.c
+++ b/mail/e-mail-shell-content.c
@@ -97,6 +97,9 @@ mail_shell_content_message_list_scrolled_cb (EMailShellContent *mail_shell_conte
/* Save the scrollbar position for the current folder. */
+ if (message_list->folder == NULL)
+ return;
+
key = "evolution:list_scroll_position";
position = message_list_get_scrollbar_position (message_list);
value = g_strdup_printf ("%f", position);
@@ -225,7 +228,12 @@ mail_shell_content_message_selected_cb (EMailShellContent *mail_shell_content,
CamelFolder *folder;
folder = message_list->folder;
- g_return_if_fail (folder != NULL);
+
+ /* This also gets triggered when selecting a store name on
+ * the sidebar such as "On This Computer", in which case
+ * 'folder' will be NULL. */
+ if (folder == NULL)
+ return;
if (camel_object_meta_set (folder, key, selected_uid))
camel_object_state_write (folder);
diff --git a/mail/e-mail-shell-sidebar.c b/mail/e-mail-shell-sidebar.c
index 242216d602..c448be9782 100644
--- a/mail/e-mail-shell-sidebar.c
+++ b/mail/e-mail-shell-sidebar.c
@@ -25,6 +25,7 @@
#include <camel/camel.h>
#include "em-utils.h"
+#include "em-folder-utils.h"
#include "e-mail-shell-module.h"
@@ -44,6 +45,42 @@ enum {
static gpointer parent_class;
static void
+mail_shell_sidebar_selection_changed_cb (EShellSidebar *shell_sidebar,
+ GtkTreeSelection *selection)
+{
+ EShellView *shell_view;
+ EShellViewClass *shell_view_class;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ const gchar *icon_name;
+ gchar *display_name = NULL;
+ gboolean is_folder = FALSE;
+ guint flags = 0;
+
+ shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
+ shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ gtk_tree_model_get (
+ model, &iter,
+ COL_STRING_DISPLAY_NAME, &display_name,
+ COL_BOOL_IS_FOLDER, &is_folder,
+ COL_UINT_FLAGS, &flags, -1);
+
+ if (is_folder)
+ icon_name = em_folder_utils_get_icon_name (flags);
+ else {
+ icon_name = shell_view_class->icon_name;
+ display_name = g_strdup (shell_view_class->label);
+ }
+
+ e_shell_sidebar_set_icon_name (shell_sidebar, icon_name);
+ e_shell_sidebar_set_primary_text (shell_sidebar, display_name);
+
+ g_free (display_name);
+}
+
+static void
mail_shell_sidebar_get_property (GObject *object,
guint property_id,
GValue *value,
@@ -94,6 +131,8 @@ mail_shell_sidebar_constructed (GObject *object)
EShellSidebar *shell_sidebar;
EShellModule *shell_module;
EShellView *shell_view;
+ GtkTreeSelection *selection;
+ GtkTreeView *tree_view;
GtkWidget *container;
GtkWidget *widget;
@@ -127,6 +166,14 @@ mail_shell_sidebar_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (container), widget);
priv->folder_tree = g_object_ref (widget);
gtk_widget_show (widget);
+
+ tree_view = GTK_TREE_VIEW (priv->folder_tree);
+ selection = gtk_tree_view_get_selection (tree_view);
+
+ g_signal_connect_swapped (
+ selection, "changed",
+ G_CALLBACK (mail_shell_sidebar_selection_changed_cb),
+ shell_sidebar);
}
static guint32
diff --git a/mail/e-mail-shell-view-private.c b/mail/e-mail-shell-view-private.c
index 82a97352d9..160e1b8828 100644
--- a/mail/e-mail-shell-view-private.c
+++ b/mail/e-mail-shell-view-private.c
@@ -271,6 +271,8 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
guint32 num_unread;
guint32 num_visible;
+ /* FIXME The sidebar should handle icon name and primary text. */
+
g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
shell_view = E_SHELL_VIEW (mail_shell_view);
@@ -290,11 +292,12 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
gchar *label;
action = e_shell_view_get_action (shell_view);
+
g_object_get (action, "label", &label, NULL);
- e_shell_sidebar_set_primary_text (shell_sidebar, label);
e_shell_sidebar_set_secondary_text (shell_sidebar, NULL);
e_shell_view_set_title (shell_view, label);
g_free (label);
+
return;
}
@@ -390,7 +393,6 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
display_name = folder_name;
title = g_strdup_printf ("%s (%s)", display_name, buffer->str);
- e_shell_sidebar_set_primary_text (shell_sidebar, display_name);
e_shell_sidebar_set_secondary_text (shell_sidebar, buffer->str);
e_shell_view_set_title (shell_view, title);
g_free (title);
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 39c46fdbb0..5ddd8876e6 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -51,6 +51,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>
@@ -71,11 +72,13 @@ struct _EMFolderTreeModelPrivate {
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 */
};
@@ -555,6 +558,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite
{
EShellModule *shell_module;
GtkTreeRowReference *uri_row, *path_row;
+ GtkTreeStore *tree_store;
unsigned int unread;
GtkTreePath *path;
GtkTreeIter sub;
@@ -562,12 +566,14 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *ite
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);
shell_module = model->priv->shell_module;
if (!fully_loaded)
@@ -642,31 +648,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);
@@ -678,7 +693,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 0ab0f24d6d..8236f3c303 100644
--- a/mail/em-folder-tree-model.h
+++ b/mail/em-folder-tree-model.h
@@ -60,11 +60,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 97a6884566..ecfe5d29ad 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -363,87 +363,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", E_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_INBOX] = e_icon_factory_get_icon ("mail-inbox", E_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_OUTBOX] = e_icon_factory_get_icon ("mail-outbox", E_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_TRASH] = e_icon_factory_get_icon ("user-trash", E_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_JUNK] = e_icon_factory_get_icon ("mail-mark-junk", E_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_SHARED_TO_ME] = e_icon_factory_get_icon ("stock_shared-to-me", E_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_SHARED_BY_ME] = e_icon_factory_get_icon ("stock_shared-by-me", E_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_SENT] = e_icon_factory_get_icon ("mail-sent", E_ICON_SIZE_MENU);
- folder_icons[FOLDER_ICON_VIRTUAL] = e_icon_factory_get_icon ("folder-saved-search", E_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)
@@ -539,7 +458,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 aa9e6aa402..cb1c333bfb 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>
@@ -696,3 +694,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 19bedd46a3..e3161bdcc0 100644
--- a/mail/em-folder-utils.h
+++ b/mail/em-folder-utils.h
@@ -21,18 +21,36 @@
*
*/
-#ifndef _EM_FOLDER_UTILS_H
-#define _EM_FOLDER_UTILS_H
+#ifndef EM_FOLDER_UTILS_H
+#define EM_FOLDER_UTILS_H
-int em_folder_utils_copy_folders(CamelStore *fromstore, const char *frombase, CamelStore *tostore, const char *tobase, int delete);
+#include <glib.h>
+#include <camel/camel-folder.h>
+#include <camel/camel-store.h>
+#include <mail/em-folder-tree.h>
-/* FIXME: These api's are really busted, there is no consistency and most rely on the wrong data */
+G_BEGIN_DECLS
-void em_folder_utils_copy_folder (struct _CamelFolderInfo *folderinfo, int delete);
+gint em_folder_utils_copy_folders (CamelStore *fromstore,
+ const gchar *frombase,
+ CamelStore *tostore,
+ const gchar *tobase,
+ int delete);
-void em_folder_utils_delete_folder (struct _CamelFolder *folder);
-void em_folder_utils_rename_folder (struct _CamelFolder *folder);
+/* FIXME These API's are really busted. There is no consistency and
+ * most rely on the wrong data. */
-void em_folder_utils_create_folder (struct _CamelFolderInfo *folderinfo, EMFolderTree * emft);
+void em_folder_utils_copy_folder (CamelFolderInfo *folderinfo,
+ int delete);
-#endif
+void em_folder_utils_delete_folder (CamelFolder *folder);
+void em_folder_utils_rename_folder (CamelFolder *folder);
+
+void em_folder_utils_create_folder (CamelFolderInfo *folderinfo,
+ EMFolderTree * emft);
+
+const gchar * em_folder_utils_get_icon_name (guint32 flags);
+
+G_END_DECLS
+
+#endif /* EM_FOLDER_UTILS_H */