aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-07-01 04:05:47 +0800
committerDan Winship <danw@src.gnome.org>2000-07-01 04:05:47 +0800
commit6f95a96083dc0c00b18a612e2309a008b9cc0e21 (patch)
treee8eb7c3517da349a0bb655982d036c39bbc18818
parent39361c665a62e68991e51a9c13c2b2074a130ed4 (diff)
downloadgsoc2013-evolution-6f95a96083dc0c00b18a612e2309a008b9cc0e21.tar
gsoc2013-evolution-6f95a96083dc0c00b18a612e2309a008b9cc0e21.tar.gz
gsoc2013-evolution-6f95a96083dc0c00b18a612e2309a008b9cc0e21.tar.bz2
gsoc2013-evolution-6f95a96083dc0c00b18a612e2309a008b9cc0e21.tar.lz
gsoc2013-evolution-6f95a96083dc0c00b18a612e2309a008b9cc0e21.tar.xz
gsoc2013-evolution-6f95a96083dc0c00b18a612e2309a008b9cc0e21.tar.zst
gsoc2013-evolution-6f95a96083dc0c00b18a612e2309a008b9cc0e21.zip
New function, a wrapper around e_table_selected_row_foreach, which calls
* message-list.c (message_list_foreach): New function, a wrapper around e_table_selected_row_foreach, which calls the callback function with UIDs rather than row numbers. * folder-browser-factory.c: Remove never-used "Find" button from the toolbar and replace it with "Refile". (We need a better icon for this...). Hook up "Refile" to "refile_msg". * mail-ops.c (refile_msg): Call the shell's user_select_folder routine, and then use message_list_foreach and real_refile_msg to do the work. (delete_msg): Update to use message_list_foreach. * folder-browser.c (mail_uri_to_folder): new function, extracted from folder_browser_load_folder, to turn a URI into a folder. (folder_browser_load_folder): Use it. svn path=/trunk/; revision=3833
-rw-r--r--mail/ChangeLog19
-rw-r--r--mail/folder-browser-factory.c3
-rw-r--r--mail/folder-browser.c65
-rw-r--r--mail/mail-ops.c95
-rw-r--r--mail/mail.h4
-rw-r--r--mail/message-list.c36
-rw-r--r--mail/message-list.h8
7 files changed, 178 insertions, 52 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index a6cb7ce46d..1313c25481 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,22 @@
+2000-06-30 Dan Winship <danw@helixcode.com>
+
+ * message-list.c (message_list_foreach): New function, a wrapper
+ around e_table_selected_row_foreach, which calls the callback
+ function with UIDs rather than row numbers.
+
+ * folder-browser-factory.c: Remove never-used "Find" button from
+ the toolbar and replace it with "Refile". (We need a better icon
+ for this...). Hook up "Refile" to "refile_msg".
+
+ * mail-ops.c (refile_msg): Call the shell's user_select_folder
+ routine, and then use message_list_foreach and real_refile_msg to
+ do the work.
+ (delete_msg): Update to use message_list_foreach.
+
+ * folder-browser.c (mail_uri_to_folder): new function, extracted
+ from folder_browser_load_folder, to turn a URI into a folder.
+ (folder_browser_load_folder): Use it.
+
2000-06-30 Peter Williams <peterw@curious-george.helixcode.com>
* component-factory.c (create_news_storage, create_imap_storage):
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index d53f1d5480..4ffabc6e75 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -34,7 +34,6 @@ random_cb (GtkWidget *button, gpointer user_data)
static GnomeUIInfo gnome_toolbar [] = {
GNOMEUIINFO_ITEM_STOCK (N_("Get mail"), N_("Check for new mail"), fetch_mail, GNOME_STOCK_PIXMAP_MAIL_RCV),
GNOMEUIINFO_ITEM_STOCK (N_("Compose"), N_("Compose a new message"), compose_msg, GNOME_STOCK_PIXMAP_MAIL_NEW),
- GNOMEUIINFO_ITEM_STOCK (N_("Find"), N_("Find messages"), random_cb, GNOME_STOCK_PIXMAP_SEARCH),
GNOMEUIINFO_SEPARATOR,
@@ -45,6 +44,8 @@ static GnomeUIInfo gnome_toolbar [] = {
GNOMEUIINFO_SEPARATOR,
+ GNOMEUIINFO_ITEM_STOCK (N_("Refile"), N_("Move message to a new folder"), refile_msg, GNOME_STOCK_PIXMAP_MAIL_SND),
+
GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print the selected message"), random_cb, GNOME_STOCK_PIXMAP_PRINT),
GNOMEUIINFO_ITEM_STOCK (N_("Delete"), N_("Delete this message"), delete_msg, GNOME_STOCK_PIXMAP_TRASH),
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index 61378cd0c2..be56b78b56 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -54,12 +54,12 @@ folder_browser_class_init (GtkObjectClass *object_class)
folder_browser_parent_class = gtk_type_class (PARENT_TYPE);
}
-static gboolean
-folder_browser_load_folder (FolderBrowser *fb, const char *name)
+CamelFolder *
+mail_uri_to_folder (const char *name)
{
char *store_name, *msg;
CamelStore *store;
- CamelFolder *new_folder = NULL;
+ CamelFolder *folder = NULL;
CamelException *ex;
ex = camel_exception_new ();
@@ -77,24 +77,18 @@ folder_browser_load_folder (FolderBrowser *fb, const char *name)
store = camel_session_get_store (session, store_name, ex);
if (store) {
- new_folder = camel_store_get_folder (store, newquery, TRUE, ex);
+ folder = camel_store_get_folder (store, newquery, TRUE, ex);
/* FIXME: do this properly rather than hardcoding */
#warning "Find a way not to hardcode vfolder source"
{
- CamelStore *st;
- char *stname;
CamelFolder *source_folder;
extern char *evolution_dir;
- stname = g_strdup_printf("mbox://%s/local/Inbox", evolution_dir);
- st = camel_session_get_store (session, stname, ex);
- g_free (stname);
- if (st) {
- source_folder = camel_store_get_folder (st, "mbox", FALSE, ex);
- if (source_folder) {
- camel_vee_folder_add_folder (new_folder, source_folder);
- }
- }
+ name = g_strdup_printf ("mbox://%s/local/Inbox", evolution_dir);
+ source_folder = mail_uri_to_folder (name);
+ g_free (name);
+ if (source_folder)
+ camel_vee_folder_add_folder (folder, source_folder);
}
}
g_free (newquery);
@@ -131,7 +125,7 @@ folder_browser_load_folder (FolderBrowser *fb, const char *name)
folder_name = g_strdup (ptr);
fprintf (stderr, "getting folder: %s\n", folder_name);
- new_folder = camel_store_get_folder (store, folder_name, TRUE, ex);
+ folder = camel_store_get_folder (store, folder_name, TRUE, ex);
g_free (folder_name);
}
}
@@ -142,7 +136,7 @@ folder_browser_load_folder (FolderBrowser *fb, const char *name)
folder_name = name + 5;
- new_folder = camel_store_get_folder (store, folder_name, FALSE, ex);
+ folder = camel_store_get_folder (store, folder_name, FALSE, ex);
}
} else if (!strncmp (name, "file:", 5)) {
/* Change "file:" to "mbox:". */
@@ -150,36 +144,45 @@ folder_browser_load_folder (FolderBrowser *fb, const char *name)
store = camel_session_get_store (session, store_name, ex);
g_free (store_name);
if (store) {
- new_folder = camel_store_get_folder (store, "mbox", FALSE, ex);
+ folder = camel_store_get_folder (store, "mbox", FALSE, ex);
}
} else {
- char *msg;
-
msg = g_strdup_printf ("Can't open URI %s", name);
gnome_error_dialog (msg);
g_free (msg);
- camel_exception_free (ex);
- return FALSE;
}
-
- if (store)
- gtk_object_unref (GTK_OBJECT (store));
if (camel_exception_get_id (ex)) {
msg = g_strdup_printf ("Unable to get folder %s: %s\n", name,
camel_exception_get_description (ex));
gnome_error_dialog (msg);
camel_exception_free (ex);
- if (new_folder)
- gtk_object_unref(GTK_OBJECT (new_folder));
- return FALSE;
+ if (folder) {
+ gtk_object_unref (GTK_OBJECT (folder));
+ folder = NULL;
+ }
}
-
+ camel_exception_free (ex);
+
+ if (store)
+ gtk_object_unref (GTK_OBJECT (store));
+
+ return folder;
+}
+
+static gboolean
+folder_browser_load_folder (FolderBrowser *fb, const char *name)
+{
+ CamelFolder *new_folder;
+
+ new_folder = mail_uri_to_folder (name);
+ if (!new_folder)
+ return FALSE;
+
if (fb->folder)
gtk_object_unref (GTK_OBJECT (fb->folder));
-
fb->folder = new_folder;
-
+
message_list_set_folder (fb->message_list, new_folder);
return TRUE;
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index b0b6b4cb89..169566cd99 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -38,6 +38,8 @@
#include "Evolution.h"
#include "evolution-storage.h"
+#include "evolution-shell-client.h"
+
#ifndef HAVE_MKSTEMP
#include <fcntl.h>
#include <sys/stat.h>
@@ -65,9 +67,6 @@ typedef struct rsm_s {
} rsm_t;
static void
-real_delete_msg( int model_row, gpointer user_data );
-
-static void
real_fetch_mail( gpointer user_data );
static void
@@ -614,29 +613,78 @@ forward_msg (GtkWidget *button, gpointer user_data)
gtk_widget_show (GTK_WIDGET (composer));
}
+struct refile_data {
+ CamelFolder *source, *dest;
+ CamelException *ex;
+};
+
static void
-real_delete_msg (int model_row, gpointer user_data)
+real_refile_msg (MessageList *ml, const char *uid, gpointer user_data)
+{
+ struct refile_data *rfd = user_data;
+
+ if (camel_exception_is_set (rfd->ex))
+ return;
+
+ camel_folder_move_message_to (rfd->source, uid, rfd->dest, rfd->ex);
+}
+
+void
+refile_msg (GtkWidget *button, gpointer user_data)
{
FolderBrowser *fb = user_data;
MessageList *ml = fb->message_list;
- CamelMessageInfo *info;
- CamelException ex;
+ char *uri, *physical, *path;
+ struct refile_data rfd;
- camel_exception_init (&ex);
-
- g_assert (model_row < ml->summary_table->len);
- info = ml->summary_table->pdata[model_row];
-
- /* Toggle the deleted flag without touching other flags. */
- camel_folder_set_message_flags (fb->folder, info->uid,
- CAMEL_MESSAGE_DELETED,
- ~(info->flags), &ex);
+ extern EvolutionShellClient *global_shell_client;
+ static char *last;
- if (camel_exception_is_set (&ex)) {
- mail_exception_dialog ("Could not toggle deleted flag", &ex, fb);
- camel_exception_clear (&ex);
+ if (last == NULL)
+ last = g_strdup ("");
+
+ evolution_shell_client_user_select_folder (global_shell_client,
+ _("Refile message(s) to"),
+ last, &uri, &physical);
+ if (!uri)
return;
+
+ path = strchr (uri, '/');
+ if (path && strcmp (last, path) != 0) {
+ g_free (last);
+ last = g_strdup (path);
}
+ g_free (uri);
+
+ rfd.source = ml->folder;
+ rfd.dest = mail_uri_to_folder (physical);
+ g_free (physical);
+ if (!rfd.dest)
+ return;
+ rfd.ex = camel_exception_new ();
+
+ message_list_foreach (ml, real_refile_msg, &rfd);
+ gtk_object_unref (GTK_OBJECT (rfd.dest));
+
+ if (camel_exception_is_set (rfd.ex))
+ mail_exception_dialog ("Could not move message", rfd.ex, fb);
+ camel_exception_free (rfd.ex);
+}
+
+static void
+real_delete_msg (MessageList *ml, const char *uid, gpointer user_data)
+{
+ CamelException *ex = user_data;
+ guint32 flags;
+
+ if (camel_exception_is_set (ex))
+ return;
+
+ /* Toggle the deleted flag without touching other flags. */
+ flags = camel_folder_get_message_flags (ml->folder, uid, ex);
+ camel_folder_set_message_flags (ml->folder, uid,
+ CAMEL_MESSAGE_DELETED,
+ ~flags, ex);
}
void
@@ -645,8 +693,17 @@ delete_msg (GtkWidget *button, gpointer user_data)
FolderBrowser *fb = user_data;
MessageList *ml = fb->message_list;
int cursor = e_table_get_cursor_row (E_TABLE (ml->etable));
+ CamelException ex;
+
+ camel_exception_init (&ex);
+ message_list_foreach (ml, real_delete_msg, &ex);
+ if (camel_exception_is_set (&ex)) {
+ mail_exception_dialog ("Could not toggle deleted flag",
+ &ex, fb);
+ camel_exception_clear (&ex);
+ return;
+ }
- e_table_selected_row_foreach (E_TABLE (ml->etable), real_delete_msg, fb);
/* Move the cursor down a row... FIXME: should skip other
* deleted messages. FIXME: this implementation is a bit
* questionable
diff --git a/mail/mail.h b/mail/mail.h
index 2619879f80..4f006776ee 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -28,6 +28,9 @@
void folder_browser_factory_init (void);
BonoboControl *folder_browser_factory_new_control (const char *uri);
+/* folder-browser */
+CamelFolder *mail_uri_to_folder (const char *uri);
+
/* mail-config */
void mail_config_druid (void);
@@ -54,6 +57,7 @@ void forward_msg (GtkWidget *button, gpointer user_data);
void reply_to_sender (GtkWidget *button, gpointer user_data);
void reply_to_all (GtkWidget *button, gpointer user_data);
void delete_msg (GtkWidget *button, gpointer user_data);
+void refile_msg (GtkWidget *button, gpointer user_data);
void expunge_folder (BonoboUIHandler *uih, void *user_data, const char *path);
void filter_edit (BonoboUIHandler *uih, void *user_data, const char *path);
diff --git a/mail/message-list.c b/mail/message-list.c
index 3167a3fe8c..7ca6140b8f 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -1073,7 +1073,6 @@ on_row_selection (ETable *table, int row, gboolean selected,
/* FIXME: this is all a kludge. */
-
static gint
idle_select_row (gpointer user_data)
{
@@ -1088,3 +1087,38 @@ select_row (ETable *table, gpointer user_data)
gtk_idle_add (idle_select_row, message_list->etable);
}
+
+
+struct message_list_foreach_data {
+ MessageList *message_list;
+ MessageListForeachFunc callback;
+ gpointer user_data;
+};
+
+static void
+mlfe_callback (int row, gpointer user_data)
+{
+ struct message_list_foreach_data *mlfe_data = user_data;
+ CamelMessageInfo *info;
+
+ info = get_message_info (mlfe_data->message_list, row);
+ if (info) {
+ mlfe_data->callback (mlfe_data->message_list,
+ info->uid,
+ mlfe_data->user_data);
+ }
+}
+
+void
+message_list_foreach (MessageList *message_list,
+ MessageListForeachFunc callback,
+ gpointer user_data)
+{
+ struct message_list_foreach_data mlfe_data;
+
+ mlfe_data.message_list = message_list;
+ mlfe_data.callback = callback;
+ mlfe_data.user_data = user_data;
+ e_table_selected_row_foreach (E_TABLE (message_list->etable),
+ mlfe_callback, &mlfe_data);
+}
diff --git a/mail/message-list.h b/mail/message-list.h
index d01021d14c..8e43888663 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -84,6 +84,10 @@ typedef struct {
BonoboObjectClass parent_class;
} MessageListClass;
+typedef void (*MessageListForeachFunc) (MessageList *message_list,
+ const char *uid,
+ gpointer user_data);
+
GtkType message_list_get_type (void);
BonoboObject *message_list_new (FolderBrowser *parent_folder_browser);
void message_list_set_folder (MessageList *message_list,
@@ -91,5 +95,9 @@ void message_list_set_folder (MessageList *message_list,
void message_list_set_search (MessageList *message_list, const char *search);
GtkWidget *message_list_get_widget (MessageList *message_list);
+void message_list_foreach (MessageList *message_list,
+ MessageListForeachFunc callback,
+ gpointer user_data);
+
#endif /* _MESSAGE_LIST_H_ */