aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/e-mail-shell-content.c118
-rw-r--r--mail/e-mail-shell-content.h20
-rw-r--r--mail/e-mail-shell-sidebar.c39
-rw-r--r--mail/e-mail-shell-sidebar.h10
-rw-r--r--mail/e-mail-shell-view-actions.c133
-rw-r--r--mail/e-mail-shell-view-actions.h2
-rw-r--r--mail/e-mail-shell-view-private.c125
-rw-r--r--mail/e-mail-shell-view-private.h11
-rw-r--r--mail/e-mail-shell-view.c49
-rw-r--r--mail/em-folder-properties.c7
-rw-r--r--mail/em-folder-selection-button.c47
-rw-r--r--mail/em-folder-tree.c259
-rw-r--r--mail/em-folder-view.c261
13 files changed, 618 insertions, 463 deletions
diff --git a/mail/e-mail-shell-content.c b/mail/e-mail-shell-content.c
index 025b49c18a..f6b07ea728 100644
--- a/mail/e-mail-shell-content.c
+++ b/mail/e-mail-shell-content.c
@@ -22,6 +22,7 @@
#include "e-mail-shell-content.h"
#include <glib/gi18n.h>
+#include <camel/camel-store.h>
#include <libedataserver/e-data-server-util.h>
#include "e-util/gconf-bridge.h"
@@ -197,6 +198,7 @@ mail_shell_content_constructed (GObject *object)
/* XXX Kill EMFolderView? */
priv->folder_view = em_folder_view_new ();
+ g_object_ref_sink (priv->folder_view);
widget = GTK_WIDGET (((EMFolderView *) priv->folder_view)->list);
gtk_paned_add1 (GTK_PANED (container), widget);
gtk_widget_show (widget);
@@ -236,11 +238,123 @@ static guint32
mail_shell_content_check_state (EShellContent *shell_content)
{
EMailShellContent *mail_shell_content;
+ EMFolderView *folder_view;
+ GPtrArray *uids;
+ CamelFolder *folder;
+ CamelStore *store;
+ const gchar *folder_uri;
+ const gchar *tag;
+ gboolean can_clear_flags = FALSE;
+ gboolean can_flag_completed = FALSE;
+ gboolean can_flag_for_followup = FALSE;
+ gboolean has_deleted = FALSE;
+ gboolean has_important = FALSE;
+ gboolean has_junk = FALSE;
+ gboolean has_not_junk = FALSE;
+ gboolean has_read = FALSE;
+ gboolean has_undeleted = FALSE;
+ gboolean has_unimportant = FALSE;
+ gboolean has_unread = FALSE;
+ gboolean draft_or_outbox;
guint32 state = 0;
-
- /* FIXME */
+ guint ii;
mail_shell_content = E_MAIL_SHELL_CONTENT (shell_content);
+ folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);
+ uids = message_list_get_selected (folder_view->list);
+ folder_uri = folder_view->folder_uri;
+ folder = folder_view->folder;
+ store = CAMEL_STORE (folder->parent_store);
+
+ draft_or_outbox =
+ em_utils_folder_is_drafts (folder, folder_uri) ||
+ em_utils_folder_is_outbox (folder, folder_uri);
+ if (!draft_or_outbox) {
+ has_junk = !(store->flags & CAMEL_STORE_VJUNK);
+ has_not_junk = TRUE;
+ }
+
+ for (ii = 0; ii < uids->len; ii++) {
+ CamelMessageInfo *info;
+ guint32 flags;
+
+ info = camel_folder_get_message_info (
+ folder, uids->pdata[ii]);
+ if (info == NULL)
+ continue;
+
+ flags = camel_message_info_flags (info);
+
+ if (flags & CAMEL_MESSAGE_SEEN)
+ has_read = TRUE;
+ else
+ has_unread = TRUE;
+
+ if (flags & CAMEL_MESSAGE_DELETED)
+ has_deleted = TRUE;
+ else
+ has_undeleted = TRUE;
+
+ if (flags & CAMEL_MESSAGE_FLAGGED)
+ has_important = TRUE;
+ else
+ has_unimportant = TRUE;
+
+ tag = camel_message_info_user_tag (info, "follow-up");
+ if (tag != NULL && *tag != '\0') {
+ can_clear_flags = TRUE;
+ tag = camel_message_info_user_tag (
+ info, "completed-on");
+ if (tag != NULL && *tag != '\0')
+ can_flag_completed = TRUE;
+ } else
+ can_flag_for_followup = TRUE;
+ }
+
+ if (uids->len == 1)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_SINGLE;
+ if (uids->len > 1)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_MULTIPLE;
+ if (!draft_or_outbox && uids->len == 1)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_CAN_ADD_SENDER;
+#if 0 /* FIXME */
+ if (can_edit)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_CAN_EDIT;
+#endif
+ if (can_clear_flags)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_FLAG_CLEAR;
+ if (can_flag_completed)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_FLAG_COMPLETED;
+ if (can_flag_for_followup)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_FLAG_FOLLOWUP;
+ if (has_deleted)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_DELETED;
+ if (has_important)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_IMPORTANT;
+ if (has_junk)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_JUNK;
+ if (has_not_junk)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_NOT_JUNK;
+ if (has_read)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_READ;
+ if (has_undeleted)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNDELETED;
+ if (has_unimportant)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNIMPORTANT;
+ if (has_unread)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNREAD;
+#if 0 /* FIXME */
+ if (has_callto_uri)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_URI_CALLTO;
+ if (has_http_uri)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_URI_HTTP;
+ if (has_mailto_uri)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_HAS_URI_MAILTO;
+ if (is_mailing_list)
+ state |= E_MAIL_SHELL_CONTENT_SELECTION_IS_MAILING_LIST;
+#endif
+
+ em_utils_uids_free (uids);
return state;
}
diff --git a/mail/e-mail-shell-content.h b/mail/e-mail-shell-content.h
index a804919c2d..593969e5a5 100644
--- a/mail/e-mail-shell-content.h
+++ b/mail/e-mail-shell-content.h
@@ -57,16 +57,16 @@ enum {
E_MAIL_SHELL_CONTENT_SELECTION_SINGLE = 1 << 0,
E_MAIL_SHELL_CONTENT_SELECTION_MULTIPLE = 1 << 1,
E_MAIL_SHELL_CONTENT_SELECTION_CAN_ADD_SENDER = 1 << 2,
- E_MAIL_SHELL_CONTENT_SELECTION_CAN_DELETE = 1 << 3,
- E_MAIL_SHELL_CONTENT_SELECTION_CAN_EDIT = 1 << 4,
- E_MAIL_SHELL_CONTENT_SELECTION_CAN_UNDELETE = 1 << 5,
- E_MAIL_SHELL_CONTENT_SELECTION_FLAG_CLEAR = 1 << 6,
- E_MAIL_SHELL_CONTENT_SELECTION_FLAG_COMPLETED = 1 << 7,
- E_MAIL_SHELL_CONTENT_SELECTION_FLAG_FOLLOWUP = 1 << 8,
- E_MAIL_SHELL_CONTENT_SELECTION_HAS_IMPORTANT = 1 << 9,
- E_MAIL_SHELL_CONTENT_SELECTION_HAS_JUNK = 1 << 10,
- E_MAIL_SHELL_CONTENT_SELECTION_HAS_NOT_JUNK = 1 << 11,
- E_MAIL_SHELL_CONTENT_SELECTION_HAS_READ = 1 << 12,
+ E_MAIL_SHELL_CONTENT_SELECTION_CAN_EDIT = 1 << 3,
+ E_MAIL_SHELL_CONTENT_SELECTION_FLAG_CLEAR = 1 << 4,
+ E_MAIL_SHELL_CONTENT_SELECTION_FLAG_COMPLETED = 1 << 5,
+ E_MAIL_SHELL_CONTENT_SELECTION_FLAG_FOLLOWUP = 1 << 6,
+ E_MAIL_SHELL_CONTENT_SELECTION_HAS_DELETED = 1 << 7,
+ E_MAIL_SHELL_CONTENT_SELECTION_HAS_IMPORTANT = 1 << 8,
+ E_MAIL_SHELL_CONTENT_SELECTION_HAS_JUNK = 1 << 9,
+ E_MAIL_SHELL_CONTENT_SELECTION_HAS_NOT_JUNK = 1 << 10,
+ E_MAIL_SHELL_CONTENT_SELECTION_HAS_READ = 1 << 11,
+ E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNDELETED = 1 << 12,
E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNIMPORTANT = 1 << 13,
E_MAIL_SHELL_CONTENT_SELECTION_HAS_UNREAD = 1 << 14,
E_MAIL_SHELL_CONTENT_SELECTION_HAS_URI_CALLTO = 1 << 15,
diff --git a/mail/e-mail-shell-sidebar.c b/mail/e-mail-shell-sidebar.c
index 29f82b328a..242216d602 100644
--- a/mail/e-mail-shell-sidebar.c
+++ b/mail/e-mail-shell-sidebar.c
@@ -24,6 +24,8 @@
#include <string.h>
#include <camel/camel.h>
+#include "em-utils.h"
+
#include "e-mail-shell-module.h"
#define E_MAIL_SHELL_SIDEBAR_GET_PRIVATE(obj) \
@@ -130,7 +132,6 @@ mail_shell_sidebar_constructed (GObject *object)
static guint32
mail_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
{
-#if 0
EMailShellSidebar *mail_shell_sidebar;
EShellModule *shell_module;
EShellView *shell_view;
@@ -144,10 +145,12 @@ mail_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
CamelStore *store;
gchar *full_name;
gchar *uri;
- gboolean is_virtual = FALSE;
+ gboolean allows_children = TRUE;
gboolean can_delete = TRUE;
+ gboolean is_junk = FALSE;
gboolean is_outbox = FALSE;
gboolean is_store;
+ gboolean is_trash = FALSE;
guint32 folder_flags = 0;
guint32 state = 0;
@@ -169,29 +172,41 @@ mail_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
COL_STRING_FULL_NAME, &full_name,
COL_BOOL_IS_STORE, &is_store,
COL_UINT_FLAGS, &folder_flags,
- COL_STRING_URI, &uri, NULL);
+ COL_STRING_URI, &uri, -1);
if (!is_store) {
- if (strcmp (full_name, CAMEL_VJUNK_NAME) == 0)
- is_virtual = TRUE;
-
- if (strcmp (full_name, CAMEL_VTRASH_NAME) == 0)
- is_virtual = TRUE;
+ is_junk = (strcmp (full_name, CAMEL_VJUNK_NAME) == 0);
+ is_trash = (strcmp (full_name, CAMEL_VTRASH_NAME) == 0);
+ allows_children = !(is_junk || is_trash);
+
+ /* Don't allow deletion of special local folders. */
+ if (store == local_store)
+ can_delete =
+ (strcmp (full_name, "Drafts") != 0) &&
+ (strcmp (full_name, "Inbox") != 0) &&
+ (strcmp (full_name, "Outbox") != 0) &&
+ (strcmp (full_name, "Sent") != 0) &&
+ (strcmp (full_name, "Templates") != 0);
folder = em_folder_tree_get_selected_folder (folder_tree);
is_outbox = em_utils_folder_is_outbox (folder, NULL);
+ can_delete &= !(folder_flags & CAMEL_FOLDER_SYSTEM);
}
- if (is_virtual)
- state |= E_MAIL_SHELL_SIDEBAR_ALLOWS_CHILDREN;
+ if (allows_children)
+ state |= E_MAIL_SHELL_SIDEBAR_FOLDER_ALLOWS_CHILDREN;
+ if (can_delete)
+ state |= E_MAIL_SHELL_SIDEBAR_FOLDER_CAN_DELETE;
+ if (is_junk)
+ state |= E_MAIL_SHELL_SIDEBAR_FOLDER_IS_JUNK;
if (is_outbox)
state |= E_MAIL_SHELL_SIDEBAR_FOLDER_IS_OUTBOX;
if (is_store)
state |= E_MAIL_SHELL_SIDEBAR_FOLDER_IS_STORE;
+ if (is_trash)
+ state |= E_MAIL_SHELL_SIDEBAR_FOLDER_IS_TRASH;
return state;
-#endif
- return 0;
}
static void
diff --git a/mail/e-mail-shell-sidebar.h b/mail/e-mail-shell-sidebar.h
index 8c4e2404b3..e53c803db0 100644
--- a/mail/e-mail-shell-sidebar.h
+++ b/mail/e-mail-shell-sidebar.h
@@ -52,10 +52,12 @@ typedef struct _EMailShellSidebarClass EMailShellSidebarClass;
typedef struct _EMailShellSidebarPrivate EMailShellSidebarPrivate;
enum {
- E_BOOK_SHELL_SIDEBAR_FOLDER_ALLOWS_CHILDREN = 1 << 0,
- E_BOOK_SHELL_SIDEBAR_FOLDER_CAN_DELETE = 1 << 1,
- E_BOOK_SHELL_SIDEBAR_FOLDER_IS_OUTBOX = 1 << 2,
- E_BOOK_SHELL_SIDEBAR_FOLDER_IS_STORE = 1 << 3
+ E_MAIL_SHELL_SIDEBAR_FOLDER_ALLOWS_CHILDREN = 1 << 0,
+ E_MAIL_SHELL_SIDEBAR_FOLDER_CAN_DELETE = 1 << 1,
+ E_MAIL_SHELL_SIDEBAR_FOLDER_IS_JUNK = 1 << 2,
+ E_MAIL_SHELL_SIDEBAR_FOLDER_IS_OUTBOX = 1 << 3,
+ E_MAIL_SHELL_SIDEBAR_FOLDER_IS_STORE = 1 << 4,
+ E_MAIL_SHELL_SIDEBAR_FOLDER_IS_TRASH = 1 << 5
};
struct _EMailShellSidebar {
diff --git a/mail/e-mail-shell-view-actions.c b/mail/e-mail-shell-view-actions.c
index 6195dce936..9b857aff83 100644
--- a/mail/e-mail-shell-view-actions.c
+++ b/mail/e-mail-shell-view-actions.c
@@ -202,32 +202,32 @@ static void
action_mail_filter_on_mailing_list_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ e_mail_shell_view_create_filter_from_selected (
+ mail_shell_view, AUTO_MLIST);
}
static void
action_mail_filter_on_recipients_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ e_mail_shell_view_create_filter_from_selected (
+ mail_shell_view, AUTO_TO);
}
static void
action_mail_filter_on_sender_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ e_mail_shell_view_create_filter_from_selected (
+ mail_shell_view, AUTO_FROM);
}
static void
action_mail_filter_on_subject_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ e_mail_shell_view_create_filter_from_selected (
+ mail_shell_view, AUTO_SUBJECT);
}
static void
@@ -282,24 +282,40 @@ static void
action_mail_flush_outbox_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ mail_send ();
}
static void
action_mail_folder_copy_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ EMailShellSidebar *mail_shell_sidebar;
+ CamelFolderInfo *folder_info;
+ EMFolderTree *folder_tree;
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+ folder_info = em_folder_tree_get_selected_folder_info (folder_tree);
+ g_return_if_fail (folder_info != NULL);
+
+ /* XXX Leaking folder_info? */
+ em_folder_utils_copy_folder (folder_info, FALSE);
}
static void
action_mail_folder_delete_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ EMailShellSidebar *mail_shell_sidebar;
+ EMFolderTree *folder_tree;
+ CamelFolder *folder;
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+ folder = em_folder_tree_get_selected_folder (folder_tree);
+ g_return_if_fail (folder != NULL);
+
+ em_folder_utils_delete_folder (folder);
}
static void
@@ -322,40 +338,93 @@ static void
action_mail_folder_move_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ EMailShellSidebar *mail_shell_sidebar;
+ CamelFolderInfo *folder_info;
+ EMFolderTree *folder_tree;
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+ folder_info = em_folder_tree_get_selected_folder_info (folder_tree);
+ g_return_if_fail (folder_info != NULL);
+
+ /* XXX Leaking folder_info? */
+ em_folder_utils_copy_folder (folder_info, TRUE);
}
static void
action_mail_folder_new_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ EMailShellSidebar *mail_shell_sidebar;
+ CamelFolderInfo *folder_info;
+ EMFolderTree *folder_tree;
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+ folder_info = em_folder_tree_get_selected_folder_info (folder_tree);
+ g_return_if_fail (folder_info != NULL);
+
+ em_folder_utils_create_folder (folder_info, folder_tree);
+ camel_folder_info_free (folder_info);
}
static void
action_mail_folder_properties_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ EMailShellSidebar *mail_shell_sidebar;
+ EMFolderTree *folder_tree;
+ EShellView *shell_view;
+ GtkTreeSelection *selection;
+ GtkTreeView *tree_view;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar *uri;
+
+ shell_view = E_SHELL_VIEW (mail_shell_view);
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+
+ tree_view = GTK_TREE_VIEW (folder_tree);
+ selection = gtk_tree_view_get_selection (tree_view);
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return;
+
+ gtk_tree_model_get (model, &iter, COL_STRING_URI, &uri, -1);
+ em_folder_properties_show (shell_view, NULL, uri);
+ g_free (uri);
}
static void
action_mail_folder_refresh_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ EMailShellSidebar *mail_shell_sidebar;
+ EMFolderTree *folder_tree;
+ CamelFolder *folder;
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+ folder = em_folder_tree_get_selected_folder (folder_tree);
+ g_return_if_fail (folder != NULL);
+
+ mail_refresh_folder (folder, NULL, NULL);
}
static void
action_mail_folder_rename_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ EMailShellSidebar *mail_shell_sidebar;
+ EMFolderTree *folder_tree;
+ CamelFolder *folder;
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+ folder = em_folder_tree_get_selected_folder (folder_tree);
+ g_return_if_fail (folder != NULL);
+
+ em_folder_utils_rename_folder (folder);
}
static void
@@ -1042,32 +1111,32 @@ static void
action_mail_search_folder_from_mailing_list_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ e_mail_shell_view_create_vfolder_from_selected (
+ mail_shell_view, AUTO_MLIST);
}
static void
action_mail_search_folder_from_recipients_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ e_mail_shell_view_create_vfolder_from_selected (
+ mail_shell_view, AUTO_TO);
}
static void
action_mail_search_folder_from_sender_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ e_mail_shell_view_create_vfolder_from_selected (
+ mail_shell_view, AUTO_FROM);
}
static void
action_mail_search_folder_from_subject_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- /* FIXME */
- g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
+ e_mail_shell_view_create_vfolder_from_selected (
+ mail_shell_view, AUTO_SUBJECT);
}
static void
diff --git a/mail/e-mail-shell-view-actions.h b/mail/e-mail-shell-view-actions.h
index 98500b40e1..5538385911 100644
--- a/mail/e-mail-shell-view-actions.h
+++ b/mail/e-mail-shell-view-actions.h
@@ -61,6 +61,8 @@
E_SHELL_WINDOW_ACTION ((window), "mail-flag-completed")
#define E_SHELL_WINDOW_ACTION_MAIL_FLAG_FOR_FOLLOWUP(window) \
E_SHELL_WINDOW_ACTION ((window), "mail-flag-for-followup")
+#define E_SHELL_WINDOW_ACTION_MAIL_FLUSH_OUTBOX(window) \
+ E_SHELL_WINDOW_ACTION ((window), "mail-flush-outbox")
#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_COPY(window) \
E_SHELL_WINDOW_ACTION ((window), "mail-folder-copy")
#define E_SHELL_WINDOW_ACTION_MAIL_FOLDER_DELETE(window) \
diff --git a/mail/e-mail-shell-view-private.c b/mail/e-mail-shell-view-private.c
index 1dfe6c430d..1ead83c162 100644
--- a/mail/e-mail-shell-view-private.c
+++ b/mail/e-mail-shell-view-private.c
@@ -156,7 +156,7 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
/* Cache these to avoid lots of awkward casting. */
priv->mail_shell_content = g_object_ref (shell_content);
- priv->mail_shell_sidebar = g_object_ref (shell_content);
+ priv->mail_shell_sidebar = g_object_ref (shell_sidebar);
mail_shell_content = E_MAIL_SHELL_CONTENT (shell_content);
folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);
@@ -372,3 +372,126 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
camel_object_free (folder, CAMEL_FOLDER_NAME, folder_name);
g_string_free (buffer, TRUE);
}
+
+/* Helper for e_mail_shell_view_create_filter_from_selected() */
+static void
+mail_shell_view_create_filter_cb (CamelFolder *folder,
+ const gchar *uid,
+ CamelMimeMessage *message,
+ gpointer user_data)
+{
+ struct {
+ const gchar *source;
+ gint type;
+ } *filter_data = user_data;
+
+ if (message != NULL)
+ filter_gui_add_from_message (
+ message, filter_data->source, filter_data->type);
+
+ g_free (filter_data);
+}
+
+void
+e_mail_shell_view_create_filter_from_selected (EMailShellView *mail_shell_view,
+ gint filter_type)
+{
+ EMailShellContent *mail_shell_content;
+ EMFolderView *folder_view;
+ CamelFolder *folder;
+ const gchar *filter_source;
+ const gchar *folder_uri;
+ GPtrArray *uids;
+
+ struct {
+ const gchar *source;
+ gint type;
+ } *filter_data;
+
+ g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
+
+ mail_shell_content = mail_shell_view->priv->mail_shell_content;
+ folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);
+ folder_uri = folder_view->folder_uri;
+ folder = folder_view->folder;
+
+ if (em_utils_folder_is_sent (folder, folder_uri))
+ filter_source = FILTER_SOURCE_OUTGOING;
+ else if (em_utils_folder_is_outbox (folder, folder_uri))
+ filter_source = FILTER_SOURCE_OUTGOING;
+ else
+ filter_source = FILTER_SOURCE_INCOMING;
+
+ uids = message_list_get_selected (folder_view->list);
+
+ if (uids->len == 1) {
+ filter_data = g_malloc (sizeof (*filter_data));
+ filter_data->source = filter_source;
+ filter_data->type = filter_type;
+
+ mail_get_message (
+ folder, uids->pdata[0],
+ mail_shell_view_create_filter_cb,
+ filter_data, mail_msg_unordered_push);
+ }
+
+ em_utils_uids_free (uids);
+}
+
+/* Helper for e_mail_shell_view_create_vfolder_from_selected() */
+static void
+mail_shell_view_create_vfolder_cb (CamelFolder *folder,
+ const gchar *uid,
+ CamelMimeMessage *message,
+ gpointer user_data)
+{
+ struct {
+ gchar *uri;
+ gint type;
+ } *vfolder_data = user_data;
+
+ if (message != NULL)
+ vfolder_gui_add_from_message (
+ message, vfolder_data->type, vfolder_data->uri);
+
+ g_free (vfolder_data->uri);
+ g_free (vfolder_data);
+}
+
+void
+e_mail_shell_view_create_vfolder_from_selected (EMailShellView *mail_shell_view,
+ gint vfolder_type)
+{
+ EMailShellContent *mail_shell_content;
+ EMFolderView *folder_view;
+ CamelFolder *folder;
+ const gchar *folder_uri;
+ GPtrArray *uids;
+
+ struct {
+ gchar *uri;
+ gint type;
+ } *vfolder_data;
+
+ g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
+
+ mail_shell_content = mail_shell_view->priv->mail_shell_content;
+ folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);
+ folder_uri = folder_view->folder_uri;
+ folder = folder_view->folder;
+
+ uids = message_list_get_selected (folder_view->list);
+
+ if (uids->len == 1) {
+ vfolder_data = g_malloc (sizeof (*vfolder_data));
+ vfolder_data->uri = g_strdup (folder_uri);
+ vfolder_data->type = vfolder_type;
+
+ mail_get_message (
+ folder, uids->pdata[0],
+ mail_shell_view_create_vfolder_cb,
+ vfolder_data, mail_msg_unordered_push);
+ }
+
+ em_utils_uids_free (uids);
+}
diff --git a/mail/e-mail-shell-view-private.h b/mail/e-mail-shell-view-private.h
index db21203cae..4cee370dba 100644
--- a/mail/e-mail-shell-view-private.h
+++ b/mail/e-mail-shell-view-private.h
@@ -32,9 +32,14 @@
#include "widgets/menus/gal-view-instance.h"
#include "em-composer-utils.h"
+#include "em-folder-properties.h"
#include "em-folder-selector.h"
+#include "em-folder-utils.h"
#include "em-utils.h"
+#include "mail-autofilter.h"
#include "mail-ops.h"
+#include "mail-send-recv.h"
+#include "mail-vfolder.h"
#include "e-mail-shell-content.h"
#include "e-mail-shell-module.h"
@@ -129,6 +134,12 @@ void e_mail_shell_view_actions_init
(EMailShellView *mail_shell_view);
void e_mail_shell_view_update_sidebar
(EMailShellView *mail_shell_view);
+void e_mail_shell_view_create_filter_from_selected
+ (EMailShellView *mail_shell_view,
+ gint filter_type);
+void e_mail_shell_view_create_vfolder_from_selected
+ (EMailShellView *mail_shell_view,
+ gint vfolder_type);
G_END_DECLS
diff --git a/mail/e-mail-shell-view.c b/mail/e-mail-shell-view.c
index 315cc0be0d..6de3896d50 100644
--- a/mail/e-mail-shell-view.c
+++ b/mail/e-mail-shell-view.c
@@ -67,9 +67,10 @@ mail_shell_view_constructed (GObject *object)
static void
mail_shell_view_update_actions (EShellView *shell_view)
{
-#if 0 /* FIXME */
EMailShellViewPrivate *priv;
EMailShellSidebar *mail_shell_sidebar;
+ EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
EShellWindow *shell_window;
EMFolderTree *folder_tree;
GtkAction *action;
@@ -77,6 +78,15 @@ mail_shell_view_update_actions (EShellView *shell_view)
gchar *uri;
gboolean sensitive;
gboolean visible;
+ guint32 state;
+
+ /* Be descriptive. */
+ gboolean folder_allows_children;
+ gboolean folder_can_be_deleted;
+ gboolean folder_is_junk;
+ gboolean folder_is_outbox;
+ gboolean folder_is_store;
+ gboolean folder_is_trash;
priv = E_MAIL_SHELL_VIEW_GET_PRIVATE (shell_view);
@@ -85,48 +95,63 @@ mail_shell_view_update_actions (EShellView *shell_view)
mail_shell_sidebar = priv->mail_shell_sidebar;
folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+ shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+ state = e_shell_sidebar_check_state (shell_sidebar);
+
+ folder_allows_children =
+ (state & E_MAIL_SHELL_SIDEBAR_FOLDER_ALLOWS_CHILDREN);
+ folder_can_be_deleted =
+ (state & E_MAIL_SHELL_SIDEBAR_FOLDER_CAN_DELETE);
+ folder_is_junk =
+ (state & E_MAIL_SHELL_SIDEBAR_FOLDER_IS_JUNK);
+ folder_is_outbox =
+ (state & E_MAIL_SHELL_SIDEBAR_FOLDER_IS_OUTBOX);
+ folder_is_store =
+ (state & E_MAIL_SHELL_SIDEBAR_FOLDER_IS_STORE);
+ folder_is_trash =
+ (state & E_MAIL_SHELL_SIDEBAR_FOLDER_IS_TRASH);
+
uri = em_folder_tree_get_selected_uri (folder_tree);
camel_url = camel_url_new (uri, NULL);
g_free (uri);
action = ACTION (MAIL_EMPTY_TRASH);
- visible = is_trash;
+ visible = folder_is_trash;
gtk_action_set_visible (action, visible);
action = ACTION (MAIL_FLUSH_OUTBOX);
- visible = is_outbox;
+ visible = folder_is_outbox;
gtk_action_set_visible (action, visible);
action = ACTION (MAIL_FOLDER_COPY);
- sensitive = is_folder && is_selected;
+ sensitive = !folder_is_store;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MAIL_FOLDER_DELETE);
- sensitive = is_folder && can_delete;
+ sensitive = !folder_is_store && folder_can_be_deleted;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MAIL_FOLDER_MOVE);
- sensitive = is_folder && can_delete;
+ sensitive = !folder_is_store && folder_can_be_deleted;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MAIL_FOLDER_NEW);
- sensitive = inferiors;
+ sensitive = folder_allows_children;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MAIL_FOLDER_PROPERTIES);
- sensitive = is_folder && is_selected;
+ sensitive = !folder_is_store;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MAIL_FOLDER_REFRESH);
- sensitive = is_folder && is_selected;
- visible = nonstatic;
+ sensitive = !folder_is_store;
+ visible = !folder_is_outbox;
gtk_action_set_sensitive (action, sensitive);
gtk_action_set_visible (action, visible);
action = ACTION (MAIL_FOLDER_RENAME);
- sensitive = is_folder && can_delete;
+ sensitive = !folder_is_store && folder_can_be_deleted;
gtk_action_set_sensitive (action, sensitive);
-#endif
}
static void
diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c
index d25e624bd3..0eed463144 100644
--- a/mail/em-folder-properties.c
+++ b/mail/em-folder-properties.c
@@ -458,6 +458,9 @@ em_folder_properties_show (EShellView *shell_view,
CamelFolder *folder,
const gchar *uri)
{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+ g_return_if_fail (uri != NULL);
+
/* HACK: its the old behaviour, not very 'neat' but it works */
if (!strncmp (uri, "vfolder:", 8)) {
CamelURL *url = camel_url_new (uri, NULL);
@@ -476,7 +479,7 @@ em_folder_properties_show (EShellView *shell_view,
}
if (folder == NULL)
- mail_get_folder(uri, 0, emfp_dialog_got_folder, NULL, mail_msg_unordered_push);
+ mail_get_folder(uri, 0, emfp_dialog_got_folder, shell_view, mail_msg_unordered_push);
else
- emfp_dialog_got_folder((char *)uri, folder, NULL);
+ emfp_dialog_got_folder((char *)uri, folder, shell_view);
}
diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c
index f85d3d84fb..1368fb1ed1 100644
--- a/mail/em-folder-selection-button.c
+++ b/mail/em-folder-selection-button.c
@@ -322,6 +322,50 @@ folder_selection_button_class_init (EMFolderSelectionButtonClass *class)
button_class = GTK_BUTTON_CLASS (class);
button_class->clicked = folder_selection_button_clicked;
+ g_object_class_install_property (
+ object_class,
+ PROP_CAPTION,
+ g_param_spec_string (
+ "caption",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_MODEL,
+ g_param_spec_object (
+ "model",
+ NULL,
+ NULL,
+ EM_TYPE_FOLDER_TREE_MODEL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_MULTISELECT,
+ g_param_spec_boolean (
+ "multiselect",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_TITLE,
+ g_param_spec_string (
+ "title",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
signals[SELECTED] = g_signal_new (
"selected",
G_OBJECT_CLASS_TYPE (object_class),
@@ -335,7 +379,6 @@ folder_selection_button_class_init (EMFolderSelectionButtonClass *class)
static void
folder_selection_button_init (EMFolderSelectionButton *emfsb)
{
- struct _EMFolderSelectionButtonPrivate *priv;
GtkWidget *box;
emfsb->priv = EM_FOLDER_SELECTION_BUTTON_GET_PRIVATE (emfsb);
@@ -345,7 +388,7 @@ folder_selection_button_init (EMFolderSelectionButton *emfsb)
box = gtk_hbox_new (FALSE, 4);
emfsb->priv->icon = gtk_image_new ();
- gtk_widget_show (priv->icon);
+ gtk_widget_show (emfsb->priv->icon);
gtk_box_pack_start (GTK_BOX (box), emfsb->priv->icon, FALSE, TRUE, 0);
emfsb->priv->label = gtk_label_new ("");
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 8d450e35d3..97a6884566 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -2012,53 +2012,6 @@ emft_tree_row_activated (GtkTreeView *treeview, GtkTreePath *tree_path, GtkTreeV
g_free(uri);
}
-#if 0
-static void
-emft_popup_view (GtkWidget *item, EMFolderTree *emft)
-{
-
-}
-
-static void
-emft_popup_open_new (GtkWidget *item, EMFolderTree *emft)
-{
-}
-#endif
-
-static void
-emft_popup_copy(EPopup *ep, EPopupItem *item, void *data)
-{
- EMFolderTree *emft = data;
- CamelFolderInfo *fi = NULL;
-
- /* FIXME: use async apis */
- if ((fi = em_folder_tree_get_selected_folder_info (emft)) != NULL)
- em_folder_utils_copy_folder(fi, FALSE);
-}
-
-static void
-emft_popup_move(EPopup *ep, EPopupItem *item, void *data)
-{
- EMFolderTree *emft = data;
- CamelFolderInfo *fi = NULL;
-
- /* FIXME: use async apis */
- if ((fi = em_folder_tree_get_selected_folder_info (emft)) != NULL)
- em_folder_utils_copy_folder(fi, TRUE);
-}
-
-static void
-emft_popup_new_folder (EPopup *ep, EPopupItem *pitem, void *data)
-{
- EMFolderTree *emft = data;
- CamelFolderInfo *fi;
-
- if ((fi = em_folder_tree_get_selected_folder_info (emft)) != NULL) {
- em_folder_utils_create_folder(fi, emft);
- camel_folder_info_free(fi);
- }
-}
-
static void
selfunc (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
{
@@ -2085,219 +2038,15 @@ emft_selection_get_selected (GtkTreeSelection *selection, GtkTreeModel **model,
}
}
-static void
-emft_popup_delete_folder (EPopup *ep, EPopupItem *pitem, void *data)
-{
- EMFolderTree *emft = data;
- CamelFolder *folder;
-
- if ((folder = em_folder_tree_get_selected_folder (emft)) != NULL) {
- em_folder_utils_delete_folder(folder);
- }
-}
-
-static void
-emft_popup_rename_folder (EPopup *ep, EPopupItem *pitem, void *data)
-{
- EMFolderTree *emft = data;
- CamelFolder *folder;
-
- if ((folder = em_folder_tree_get_selected_folder (emft)) != NULL) {
- em_folder_utils_rename_folder(folder);
- }
-}
-
-static void
-emft_popup_refresh_folder (EPopup *ep, EPopupItem *pitem, void *data)
-{
- EMFolderTree *emft = data;
- CamelFolder *folder;
-
- if ((folder = em_folder_tree_get_selected_folder (emft)) != NULL)
- mail_refresh_folder(folder, NULL, NULL);
-}
-
-static void
-emft_popup_flush_outbox (EPopup *ep, EPopupItem *pitem, void *data)
-{
- mail_send ();
-}
-
-static void
-emft_popup_empty_trash (EPopup *ep, EPopupItem *pitem, void *data)
-{
- em_utils_empty_trash (data);
-}
-
-static void
-emft_popup_properties (EPopup *ep, EPopupItem *pitem, void *data)
-{
- EMFolderTree *emft = data;
- GtkTreeSelection *selection;
- GtkTreeView *tree_view;
- GtkTreeModel *model;
- GtkTreeIter iter;
- char *uri;
-
- tree_view = GTK_TREE_VIEW (emft);
- selection = gtk_tree_view_get_selection (tree_view);
- if (!emft_selection_get_selected (selection, &model, &iter))
- return;
-
- gtk_tree_model_get (model, &iter, COL_STRING_URI, &uri, -1);
- em_folder_properties_show (NULL, NULL, uri);
- g_free (uri);
-}
-
-static EPopupItem emft_popup_items[] = {
-#if 0
- { E_POPUP_ITEM, "00.emc.00", N_("_View"), emft_popup_view, NULL, NULL, EM_POPUP_FOLDER_SELECT },
- { E_POPUP_ITEM, "00.emc.01", N_("Open in _New Window"), emft_popup_open_new, NULL, NULL, EM_POPUP_FOLDER_SELECT },
-
- { E_POPUP_BAR, "10.emc" },
-#endif
- /* FIXME: need to disable for nochildren folders */
- { E_POPUP_ITEM, "10.emc.00", N_("_New Folder..."), emft_popup_new_folder, NULL, "folder-new", 0, EM_POPUP_FOLDER_INFERIORS },
-
- { E_POPUP_ITEM, "10.emc.05", N_("_Copy..."), emft_popup_copy, NULL, "folder-copy", 0, EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT },
- { E_POPUP_ITEM, "10.emc.06", N_("_Move..."), emft_popup_move, NULL, "folder-move", 0, EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE },
-
- /* FIXME: need to disable for undeletable folders */
- { E_POPUP_BAR, "20.emc" },
- { E_POPUP_ITEM, "20.emc.01", N_("_Delete"), emft_popup_delete_folder, NULL, "edit-delete", 0, EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE },
-
- { E_POPUP_BAR, "30.emc" },
- { E_POPUP_ITEM, "30.emc.02", N_("_Rename..."), emft_popup_rename_folder, NULL, NULL, 0, EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE },
- { E_POPUP_ITEM, "30.emc.03", N_("Re_fresh"), emft_popup_refresh_folder, NULL, "view-refresh", EM_POPUP_FOLDER_NONSTATIC, EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT},
- { E_POPUP_ITEM, "30.emc.04", N_("Fl_ush Outbox"), emft_popup_flush_outbox, NULL, "mail-send", EM_POPUP_FOLDER_OUTBOX, 0 },
-
-
- { E_POPUP_BAR, "99.emc" },
- { E_POPUP_ITEM, "99.emc.00", N_("_Properties"), emft_popup_properties, NULL, "document-properties", 0, EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT }
-};
-static EPopupItem trash_popup_item = {E_POPUP_ITEM, "30.emc.05", N_("_Empty Trash"), emft_popup_empty_trash,NULL,NULL, 1, EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT};
-
-static void
-emft_popup_free(EPopup *ep, GSList *items, void *data)
-{
- g_slist_free(items);
-}
-
static gboolean
-emft_popup (EMFolderTree *emft, GdkEvent *event)
+emft_popup_menu (GtkWidget *widget)
{
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
- CamelStore *local, *store;
- EMPopupTargetFolder *target;
- EShellModule *shell_module;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GSList *menus = NULL;
- guint32 info_flags = 0;
- guint32 flags = 0;
- guint32 folder_type_flags = 0;
- gboolean isstore;
- char *uri, *full_name;
- GtkMenu *menu;
- EMPopup *emp;
- CamelFolder *selfolder = NULL;
- int i;
-
- tree_view = GTK_TREE_VIEW (emft);
-
- /* this centralises working out when the user's done something */
- emft_tree_user_event(tree_view, (GdkEvent *)event, emft);
-
- /* FIXME: we really need the folderinfo to build a proper menu */
- selection = gtk_tree_view_get_selection (tree_view);
- if (!emft_selection_get_selected (selection, &model, &iter))
- return FALSE;
-
- shell_module = em_folder_tree_model_get_shell_module (emft->priv->model);
-
- gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store,
- COL_STRING_URI, &uri, COL_STRING_FULL_NAME, &full_name,
- COL_BOOL_IS_STORE, &isstore, COL_UINT_FLAGS, &folder_type_flags, -1);
-
- /* Stores have full_name == NULL, otherwise its just a placeholder */
- /* NB: This is kind of messy */
- if (!isstore && full_name == NULL) {
- g_free (uri);
- return FALSE;
- }
-
- /* TODO: em_popup_target_folder_new? */
- if (isstore) {
- flags |= EM_POPUP_FOLDER_STORE;
- } else {
- flags |= EM_POPUP_FOLDER_FOLDER;
-
- local = e_mail_shell_module_get_local_store (shell_module);
-
- /* don't allow deletion of special local folders */
- if (!(store == local && is_special_local_folder (full_name)))
- flags |= EM_POPUP_FOLDER_DELETE;
-
- /* hack for vTrash/vJunk */
- if (!strcmp (full_name, CAMEL_VTRASH_NAME) || !strcmp (full_name, CAMEL_VJUNK_NAME))
- info_flags |= CAMEL_FOLDER_VIRTUAL | CAMEL_FOLDER_NOINFERIORS;
-
- selfolder = em_folder_tree_get_selected_folder (emft);
-
- if (folder_type_flags & CAMEL_FOLDER_SYSTEM)
- flags &= ~EM_POPUP_FOLDER_DELETE;
-
- if (em_utils_folder_is_outbox (selfolder, NULL))
- info_flags |= CAMEL_FOLDER_TYPE_OUTBOX;
- }
-
- folder_tree_emit_popup_event (emft, event);
-
-#if 0 /* KILL-BONOBO */
- /** @HookPoint-EMPopup: Folder Tree Context Menu
- * @Id: org.gnome.evolution.mail.foldertree.popup
- * @Class: org.gnome.evolution.mail.popup:1.0
- * @Target: EMPopupTargetFolder
- *
- * This is the context menu shown on the folder tree.
- */
- emp = em_popup_new ("org.gnome.evolution.mail.foldertree.popup");
-
- /* FIXME: pass valid fi->flags here */
- target = em_popup_target_new_folder (emp, uri, info_flags, flags);
-
- for (i = 0; i < sizeof (emft_popup_items) / sizeof (emft_popup_items[0]); i++)
- menus = g_slist_prepend (menus, &emft_popup_items[i]);
-
- if ((folder_type_flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_TRASH)
- menus = g_slist_prepend (menus, &trash_popup_item);
-
- e_popup_add_items ((EPopup *)emp, menus, NULL, emft_popup_free, emft);
-
- menu = e_popup_create_menu_once ((EPopup *)emp, (EPopupTarget *)target, 0);
-
- if (event == NULL || event->type == GDK_KEY_PRESS) {
- /* FIXME: menu pos function */
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
- } else {
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button.button, event->button.time);
- }
-#endif
-
- g_free (full_name);
- g_free (uri);
+ folder_tree_emit_popup_event (EM_FOLDER_TREE (widget), NULL);
return TRUE;
}
static gboolean
-emft_popup_menu (GtkWidget *widget)
-{
- return emft_popup (EM_FOLDER_TREE (widget), NULL);
-}
-
-static gboolean
emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTree *emft)
{
GtkTreeSelection *selection;
@@ -2325,7 +2074,9 @@ emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTr
gtk_tree_path_free (tree_path);
- return emft_popup (emft, (GdkEvent *)event);
+ folder_tree_emit_popup_event (emft, (GdkEvent *) event);
+
+ return TRUE;
}
/* This is called for keyboard and mouse events, it seems the only way
diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c
index 1b851eb196..8b624934a3 100644
--- a/mail/em-folder-view.c
+++ b/mail/em-folder-view.c
@@ -126,9 +126,6 @@ static void emfv_set_folder_uri(EMFolderView *emfv, const char *uri);
static void emfv_set_message(EMFolderView *emfv, const char *uid, int nomarkseen);
static void emfv_activate(EMFolderView *emfv, BonoboUIComponent *uic, int state);
-static void vfolder_type_current (EMFolderView *emfv, int type);
-static void filter_type_current (EMFolderView *emfv, int type);
-
static void emfv_setting_setup(EMFolderView *emfv);
static void emfv_on_url_cb(GObject *emitter, const char *url, EMFolderView *emfv);
@@ -1138,23 +1135,23 @@ emfv_popup_label_new (EPopup *ep, EPopupItem *pitem, void *data)
/* filter callbacks, this will eventually be a wizard, see
filter_type_current/vfolder_type_current for implementation */
-#define EMFV_POPUP_AUTO_TYPE(autotype, name, type) \
-static void \
-name(EPopup *ep, EPopupItem *item, void *data) \
-{ \
- EMFolderView *emfv = data; \
- autotype(emfv, type); \
-}
+//#define EMFV_POPUP_AUTO_TYPE(autotype, name, type) \
+//static void \
+//name(EPopup *ep, EPopupItem *item, void *data) \
+//{ \
+// EMFolderView *emfv = data; \
+// autotype(emfv, type); \
+//}
-EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_subject, AUTO_SUBJECT)
-EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_sender, AUTO_FROM)
-EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_recipients, AUTO_TO)
-EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_mlist, AUTO_MLIST)
+//EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_subject, AUTO_SUBJECT)
+//EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_sender, AUTO_FROM)
+//EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_recipients, AUTO_TO)
+//EMFV_POPUP_AUTO_TYPE(vfolder_type_current, emfv_popup_vfolder_mlist, AUTO_MLIST)
-EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_subject, AUTO_SUBJECT)
-EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_sender, AUTO_FROM)
-EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_recipients, AUTO_TO)
-EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_mlist, AUTO_MLIST)
+//EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_subject, AUTO_SUBJECT)
+//EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_sender, AUTO_FROM)
+//EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_recipients, AUTO_TO)
+//EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_mlist, AUTO_MLIST)
/* TODO: Move some of these to be 'standard' menu's */
@@ -1202,19 +1199,19 @@ static EPopupItem emfv_popup_items[] = {
{ E_POPUP_BAR, "90.filter", NULL, NULL, NULL, NULL },
{ E_POPUP_SUBMENU, "90.filter.00", N_("Crea_te Rule From Message"), NULL, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
/* Translators: The following strings are used while creating a new search folder, to specify what parameter the search folder would be based on. */
- { E_POPUP_ITEM, "90.filter.00/00.00", N_("Search Folder based on _Subject"), emfv_popup_vfolder_subject, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
- { E_POPUP_ITEM, "90.filter.00/00.01", N_("Search Folder based on Se_nder"), emfv_popup_vfolder_sender, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
- { E_POPUP_ITEM, "90.filter.00/00.02", N_("Search Folder based on _Recipients"), emfv_popup_vfolder_recipients, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
- { E_POPUP_ITEM, "90.filter.00/00.03", N_("Search Folder based on Mailing _List"),
- emfv_popup_vfolder_mlist, NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST|EM_FOLDER_VIEW_SELECT_LISTONLY },
+// { E_POPUP_ITEM, "90.filter.00/00.00", N_("Search Folder based on _Subject"), emfv_popup_vfolder_subject, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+// { E_POPUP_ITEM, "90.filter.00/00.01", N_("Search Folder based on Se_nder"), emfv_popup_vfolder_sender, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+// { E_POPUP_ITEM, "90.filter.00/00.02", N_("Search Folder based on _Recipients"), emfv_popup_vfolder_recipients, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+// { E_POPUP_ITEM, "90.filter.00/00.03", N_("Search Folder based on Mailing _List"),
+// emfv_popup_vfolder_mlist, NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST|EM_FOLDER_VIEW_SELECT_LISTONLY },
{ E_POPUP_BAR, "90.filter.00/10", NULL, NULL, NULL, NULL },
/* Translators: The following strings are used while creating a new message filter, to specify what parameter the filter would be based on. */
- { E_POPUP_ITEM, "90.filter.00/10.00", N_("Filter based on Sub_ject"), emfv_popup_filter_subject, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
- { E_POPUP_ITEM, "90.filter.00/10.01", N_("Filter based on Sen_der"), emfv_popup_filter_sender, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
- { E_POPUP_ITEM, "90.filter.00/10.02", N_("Filter based on Re_cipients"), emfv_popup_filter_recipients, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
- { E_POPUP_ITEM, "90.filter.00/10.03", N_("Filter based on _Mailing List"),
- emfv_popup_filter_mlist, NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST|EM_FOLDER_VIEW_SELECT_LISTONLY },
+// { E_POPUP_ITEM, "90.filter.00/10.00", N_("Filter based on Sub_ject"), emfv_popup_filter_subject, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+// { E_POPUP_ITEM, "90.filter.00/10.01", N_("Filter based on Sen_der"), emfv_popup_filter_sender, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+// { E_POPUP_ITEM, "90.filter.00/10.02", N_("Filter based on Re_cipients"), emfv_popup_filter_recipients, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+// { E_POPUP_ITEM, "90.filter.00/10.03", N_("Filter based on _Mailing List"),
+// emfv_popup_filter_mlist, NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST|EM_FOLDER_VIEW_SELECT_LISTONLY },
};
static enum _e_popup_t
@@ -1708,77 +1705,77 @@ emfv_message_search(BonoboUIComponent *uic, void *data, const char *path)
/* ********************************************************************** */
-struct _filter_data {
- const char *source;
- char *uri;
- int type;
-};
-
-static void
-filter_data_free (struct _filter_data *fdata)
-{
- g_free (fdata->uri);
- g_free (fdata);
-}
-
-static void
-filter_type_got_message (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *user_data)
-{
- struct _filter_data *data = user_data;
-
- if (msg)
- filter_gui_add_from_message (msg, data->source, data->type);
-
- filter_data_free (data);
-}
-
-static void
-filter_type_uid (CamelFolder *folder, const char *uid, const char *source, int type)
-{
- struct _filter_data *data;
-
- data = g_malloc0 (sizeof (*data));
- data->type = type;
- data->source = source;
-
- mail_get_message (folder, uid, filter_type_got_message, data, mail_msg_unordered_push);
-}
-
-static void
-filter_type_current (EMFolderView *emfv, int type)
-{
- const char *source;
- GPtrArray *uids;
-
- if (em_utils_folder_is_sent (emfv->folder, emfv->folder_uri)
- || em_utils_folder_is_outbox (emfv->folder, emfv->folder_uri))
- source = FILTER_SOURCE_OUTGOING;
- else
- source = FILTER_SOURCE_INCOMING;
-
- uids = message_list_get_selected (emfv->list);
+//struct _filter_data {
+// const char *source;
+// char *uri;
+// int type;
+//};
- if (uids->len == 1)
- filter_type_uid (emfv->folder, (char *) uids->pdata[0], source, type);
+//static void
+//filter_data_free (struct _filter_data *fdata)
+//{
+// g_free (fdata->uri);
+// g_free (fdata);
+//}
- em_utils_uids_free (uids);
-}
+//static void
+//filter_type_got_message (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *user_data)
+//{
+// struct _filter_data *data = user_data;
+//
+// if (msg)
+// filter_gui_add_from_message (msg, data->source, data->type);
+//
+// filter_data_free (data);
+//}
-EMFV_MAP_CALLBACK(emfv_tools_filter_subject, emfv_popup_filter_subject)
-EMFV_MAP_CALLBACK(emfv_tools_filter_sender, emfv_popup_filter_sender)
-EMFV_MAP_CALLBACK(emfv_tools_filter_recipient, emfv_popup_filter_recipients)
-EMFV_MAP_CALLBACK(emfv_tools_filter_mlist, emfv_popup_filter_mlist)
+//static void
+//filter_type_uid (CamelFolder *folder, const char *uid, const char *source, int type)
+//{
+// struct _filter_data *data;
+//
+// data = g_malloc0 (sizeof (*data));
+// data->type = type;
+// data->source = source;
+//
+// mail_get_message (folder, uid, filter_type_got_message, data, mail_msg_unordered_push);
+//}
-static void
-vfolder_type_got_message (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *user_data)
-{
- struct _filter_data *data = user_data;
+//static void
+//filter_type_current (EMFolderView *emfv, int type)
+//{
+// const char *source;
+// GPtrArray *uids;
+//
+// if (em_utils_folder_is_sent (emfv->folder, emfv->folder_uri)
+// || em_utils_folder_is_outbox (emfv->folder, emfv->folder_uri))
+// source = FILTER_SOURCE_OUTGOING;
+// else
+// source = FILTER_SOURCE_INCOMING;
+//
+// uids = message_list_get_selected (emfv->list);
+//
+// if (uids->len == 1)
+// filter_type_uid (emfv->folder, (char *) uids->pdata[0], source, type);
+//
+// em_utils_uids_free (uids);
+//}
- if (msg)
- vfolder_gui_add_from_message (msg, data->type, data->uri);
+//EMFV_MAP_CALLBACK(emfv_tools_filter_subject, emfv_popup_filter_subject)
+//EMFV_MAP_CALLBACK(emfv_tools_filter_sender, emfv_popup_filter_sender)
+//EMFV_MAP_CALLBACK(emfv_tools_filter_recipient, emfv_popup_filter_recipients)
+//EMFV_MAP_CALLBACK(emfv_tools_filter_mlist, emfv_popup_filter_mlist)
- filter_data_free (data);
-}
+//static void
+//vfolder_type_got_message (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *user_data)
+//{
+// struct _filter_data *data = user_data;
+//
+// if (msg)
+// vfolder_gui_add_from_message (msg, data->type, data->uri);
+//
+// filter_data_free (data);
+//}
static void
emp_uri_popup_vfolder_sender(EPopup *ep, EPopupItem *pitem, void *data)
@@ -1836,39 +1833,39 @@ emp_uri_popup_vfolder_recipient(EPopup *ep, EPopupItem *pitem, void *data)
camel_url_free(url);
}
-static void
-vfolder_type_uid (CamelFolder *folder, const char *uid, const char *uri, int type)
-{
- struct _filter_data *data;
-
- data = g_malloc0 (sizeof (*data));
- data->type = type;
- data->uri = g_strdup (uri);
-
- mail_get_message (folder, uid, vfolder_type_got_message, data, mail_msg_unordered_push);
-}
-
-static void
-vfolder_type_current (EMFolderView *emfv, int type)
-{
- GPtrArray *uids;
-
- uids = message_list_get_selected (emfv->list);
-
- if (uids->len == 1) {
- /* ensures vfolder is running */
- vfolder_load_storage ();
-
- vfolder_type_uid (emfv->folder, (char *) uids->pdata[0], emfv->folder_uri, type);
- }
+//static void
+//vfolder_type_uid (CamelFolder *folder, const char *uid, const char *uri, int type)
+//{
+// struct _filter_data *data;
+//
+// data = g_malloc0 (sizeof (*data));
+// data->type = type;
+// data->uri = g_strdup (uri);
+//
+// mail_get_message (folder, uid, vfolder_type_got_message, data, mail_msg_unordered_push);
+//}
- em_utils_uids_free (uids);
-}
+//static void
+//vfolder_type_current (EMFolderView *emfv, int type)
+//{
+// GPtrArray *uids;
+//
+// uids = message_list_get_selected (emfv->list);
+//
+// if (uids->len == 1) {
+// /* ensures vfolder is running */
+// vfolder_load_storage ();
+//
+// vfolder_type_uid (emfv->folder, (char *) uids->pdata[0], emfv->folder_uri, type);
+// }
+//
+// em_utils_uids_free (uids);
+//}
-EMFV_MAP_CALLBACK(emfv_tools_vfolder_subject, emfv_popup_vfolder_subject)
-EMFV_MAP_CALLBACK(emfv_tools_vfolder_sender, emfv_popup_vfolder_sender)
-EMFV_MAP_CALLBACK(emfv_tools_vfolder_recipient, emfv_popup_vfolder_recipients)
-EMFV_MAP_CALLBACK(emfv_tools_vfolder_mlist, emfv_popup_vfolder_mlist)
+//EMFV_MAP_CALLBACK(emfv_tools_vfolder_subject, emfv_popup_vfolder_subject)
+//EMFV_MAP_CALLBACK(emfv_tools_vfolder_sender, emfv_popup_vfolder_sender)
+//EMFV_MAP_CALLBACK(emfv_tools_vfolder_recipient, emfv_popup_vfolder_recipients)
+//EMFV_MAP_CALLBACK(emfv_tools_vfolder_mlist, emfv_popup_vfolder_mlist)
/* ********************************************************************** */
@@ -1933,14 +1930,14 @@ static BonoboUIVerb emfv_message_verbs[] = {
// BONOBO_UI_UNSAFE_VERB ("MailCompose", emfv_mail_compose),
/* TODO: This stuff should just be 1 item that runs a wizard */
- BONOBO_UI_UNSAFE_VERB ("ToolsFilterMailingList", emfv_tools_filter_mlist),
- BONOBO_UI_UNSAFE_VERB ("ToolsFilterRecipient", emfv_tools_filter_recipient),
- BONOBO_UI_UNSAFE_VERB ("ToolsFilterSender", emfv_tools_filter_sender),
- BONOBO_UI_UNSAFE_VERB ("ToolsFilterSubject", emfv_tools_filter_subject),
- BONOBO_UI_UNSAFE_VERB ("ToolsVFolderMailingList", emfv_tools_vfolder_mlist),
- BONOBO_UI_UNSAFE_VERB ("ToolsVFolderRecipient", emfv_tools_vfolder_recipient),
- BONOBO_UI_UNSAFE_VERB ("ToolsVFolderSender", emfv_tools_vfolder_sender),
- BONOBO_UI_UNSAFE_VERB ("ToolsVFolderSubject", emfv_tools_vfolder_subject),
+// BONOBO_UI_UNSAFE_VERB ("ToolsFilterMailingList", emfv_tools_filter_mlist),
+// BONOBO_UI_UNSAFE_VERB ("ToolsFilterRecipient", emfv_tools_filter_recipient),
+// BONOBO_UI_UNSAFE_VERB ("ToolsFilterSender", emfv_tools_filter_sender),
+// BONOBO_UI_UNSAFE_VERB ("ToolsFilterSubject", emfv_tools_filter_subject),
+// BONOBO_UI_UNSAFE_VERB ("ToolsVFolderMailingList", emfv_tools_vfolder_mlist),
+// BONOBO_UI_UNSAFE_VERB ("ToolsVFolderRecipient", emfv_tools_vfolder_recipient),
+// BONOBO_UI_UNSAFE_VERB ("ToolsVFolderSender", emfv_tools_vfolder_sender),
+// BONOBO_UI_UNSAFE_VERB ("ToolsVFolderSubject", emfv_tools_vfolder_subject),
// BONOBO_UI_UNSAFE_VERB ("ViewLoadImages", emfv_view_load_images),
/* ViewHeaders stuff is a radio */