aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog31
-rw-r--r--mail/folder-browser.h8
-rw-r--r--mail/mail-callbacks.c151
-rw-r--r--mail/mail-config.c43
-rw-r--r--mail/mail-config.h5
-rw-r--r--mail/message-list.c16
-rw-r--r--mail/message-list.h2
7 files changed, 241 insertions, 15 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 299490ce88..c422b0feb5 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,34 @@
+2002-02-19 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-callbacks.c (confirm_goto_next_folder): Prompt the user to
+ find out if he/she wants to go to the next folder with unread mail
+ in it.
+ (find_current_folder): Find a given CamelFolderInfo node based on
+ a given uri.
+ (find_next_folder_r): Recursively look for a CamelFOlderInfo node
+ which has unread messages.
+ (find_next_folder): Given a currently selected CamelFolderInfo
+ node, look for the next node containing unread messages.
+ (do_evil_kludgy_goto_next_folder_hack): Find the currently
+ selected folder and then find the very next folder after it that
+ contains unread messages and then select it via a CORBA call to
+ the shell.
+ (next_unread_msg): If we fail to find an unread message in the
+ message-list, prompt the user to find out if we should jump to the
+ next fodler containing unread messages. If so, call
+ do_evil_kludgy_goto_next_folder_hack().
+
+ * message-list.c (message_list_select): Return a boolean value
+ based on whether the call was successfull or not.
+
+ * mail-config.c (mail_config_get_confirm_goto_next_folder):
+ (mail_config_set_confirm_goto_next_folder):
+ (mail_config_get_goto_next_folder):
+ (mail_config_set_goto_next_folder): All new functions, yay.
+ (config_read): Read in the confirm_goto_next_folder and
+ goto_next_folder config options.
+ (mail_config_write_on_exit): Same the options here.
+
2002-02-15 Jeffrey Stedfast <fejj@ximian.com>
* mail-account-gui.c (basename_from_uri): Ack, strip off the
diff --git a/mail/folder-browser.h b/mail/folder-browser.h
index 1b76f82c97..fd399df930 100644
--- a/mail/folder-browser.h
+++ b/mail/folder-browser.h
@@ -36,7 +36,7 @@ typedef enum _FolderBrowserSelectionState {
struct _FolderBrowser {
GtkTable parent;
-
+
BonoboPropertyBag *properties;
GNOME_Evolution_Shell shell;
@@ -57,7 +57,7 @@ struct _FolderBrowser {
char *new_uid; /* place to save the next uid during idle timeout */
char *loaded_uid; /* what we have loaded */
guint loading_id, seen_id;
-
+
/* a folder we are expunging, dont use other than to compare the pointer value */
CamelFolder *expunging;
@@ -84,10 +84,10 @@ struct _FolderBrowser {
GtkWidget *invisible;
GByteArray *clipboard_selection;
-
+
/* for async events */
struct _MailAsyncEvent *async_event;
-
+
int get_id; /* for getting folder op */
};
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index fa59e0e254..41733c7f23 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -2331,6 +2331,151 @@ undelete_msg (GtkWidget *button, gpointer user_data)
flag_messages (FOLDER_BROWSER (user_data), CAMEL_MESSAGE_DELETED, 0);
}
+
+static gboolean
+confirm_goto_next_folder (FolderBrowser *fb)
+{
+ GtkWidget *dialog, *label, *checkbox;
+ int button;
+
+ if (!mail_config_get_confirm_goto_next_folder ())
+ return mail_config_get_goto_next_folder ();
+
+ dialog = gnome_dialog_new (_("Go to next folder with unread messages?"),
+ GNOME_STOCK_BUTTON_YES,
+ GNOME_STOCK_BUTTON_NO,
+ NULL);
+
+ e_gnome_dialog_set_parent (GNOME_DIALOG (dialog), FB_WINDOW (fb));
+
+ label = gtk_label_new (_("There are no more new messages in this folder.\n"
+ "Would you like to go to the next folder?"));
+
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4);
+
+ checkbox = gtk_check_button_new_with_label (_("Do not ask me again."));
+ gtk_object_ref (GTK_OBJECT (checkbox));
+ gtk_widget_show (checkbox);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), checkbox, TRUE, TRUE, 4);
+
+ button = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)))
+ mail_config_set_confirm_goto_next_folder (FALSE);
+
+ gtk_object_unref (GTK_OBJECT (checkbox));
+
+ if (button == 0) {
+ mail_config_set_goto_next_folder (TRUE);
+ return TRUE;
+ } else {
+ mail_config_set_goto_next_folder (FALSE);
+ return FALSE;
+ }
+}
+
+static CamelFolderInfo *
+find_current_folder (CamelFolderInfo *root, const char *current_uri)
+{
+ CamelFolderInfo *node, *current = NULL;
+
+ node = root;
+ while (node) {
+ if (!strcmp (current_uri, node->url)) {
+ current = node;
+ break;
+ }
+
+ current = find_current_folder (node->child, current_uri);
+ if (current)
+ break;
+
+ node = node->sibling;
+ }
+
+ return current;
+}
+
+static CamelFolderInfo *
+find_next_folder_r (CamelFolderInfo *node)
+{
+ CamelFolderInfo *next;
+
+ while (node) {
+ if (node->unread_message_count > 0)
+ return node;
+
+ next = find_next_folder_r (node->child);
+ if (next)
+ return next;
+
+ node = node->sibling;
+ }
+
+ return NULL;
+}
+
+static CamelFolderInfo *
+find_next_folder (CamelFolderInfo *current)
+{
+ CamelFolderInfo *next;
+
+ /* first search subfolders... */
+ next = find_next_folder_r (current->child);
+ if (next)
+ return next;
+
+ /* now search siblings... */
+ next = find_next_folder_r (current->sibling);
+ if (next)
+ return next;
+
+ /* now go up one level (if we can) and search... */
+ if (current->parent && current->parent->sibling) {
+ return find_next_folder_r (current->parent->sibling);
+ } else {
+ return NULL;
+ }
+}
+
+static void
+do_evil_kludgy_goto_next_folder_hack (FolderBrowser *fb)
+{
+ CamelFolderInfo *root, *current, *node;
+ CORBA_Environment ev;
+ CamelStore *store;
+
+ store = camel_folder_get_parent_store (fb->folder);
+
+ /* FIXME: loop over all available mail stores? */
+
+ root = camel_store_get_folder_info (store, "", CAMEL_STORE_FOLDER_INFO_RECURSIVE |
+ CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, NULL);
+
+ if (!root)
+ return;
+
+ current = find_current_folder (root, fb->uri);
+ g_assert (current != NULL);
+
+ node = find_next_folder (current);
+ if (node) {
+ g_warning ("doin' my thang...");
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_ShellView_changeCurrentView (fb->shell_view, "evolution:/local/Inbox", &ev);
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_warning ("got an exception");
+ CORBA_exception_free (&ev);
+ } else {
+ g_warning ("can't find a folder with unread mail?");
+ }
+
+ camel_store_free_folder_info (store, root);
+}
+
void
next_msg (GtkWidget *button, gpointer user_data)
{
@@ -2350,8 +2495,10 @@ next_unread_msg (GtkWidget *button, gpointer user_data)
if (FOLDER_BROWSER_IS_DESTROYED (fb))
return;
- message_list_select (fb->message_list, MESSAGE_LIST_SELECT_NEXT,
- 0, CAMEL_MESSAGE_SEEN, TRUE);
+ if (!message_list_select (fb->message_list, MESSAGE_LIST_SELECT_NEXT, 0, CAMEL_MESSAGE_SEEN, TRUE)) {
+ if (confirm_goto_next_folder (fb))
+ do_evil_kludgy_goto_next_folder_hack (fb);
+ }
}
void
diff --git a/mail/mail-config.c b/mail/mail-config.c
index a5112b570b..2cc841b0d0 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -84,6 +84,8 @@ typedef struct {
gboolean prompt_empty_subject;
gboolean prompt_only_bcc;
gboolean confirm_expunge;
+ gboolean confirm_goto_next_folder;
+ gboolean goto_next_folder;
gboolean do_seen_timeout;
int seen_timeout;
gboolean empty_trash_on_exit;
@@ -605,6 +607,10 @@ config_read (void)
config->paned_size = bonobo_config_get_long_with_default (config->db,
"/Mail/Display/paned_size", 200, NULL);
+ /* Goto next folder when user has reached the bottom of the message-list */
+ config->goto_next_folder = bonobo_config_get_boolean_with_default (
+ config->db, "/Mail/MessageList/goto_next_folder", FALSE, NULL);
+
/* Empty Subject */
config->prompt_empty_subject = bonobo_config_get_boolean_with_default (
config->db, "/Mail/Prompts/empty_subject", TRUE, NULL);
@@ -617,6 +623,10 @@ config_read (void)
config->confirm_expunge = bonobo_config_get_boolean_with_default (
config->db, "/Mail/Prompts/confirm_expunge", TRUE, NULL);
+ /* Goto next folder */
+ config->confirm_goto_next_folder = bonobo_config_get_boolean_with_default (
+ config->db, "/Mail/Prompts/confirm_goto_next_folder", TRUE, NULL);
+
/* PGP/GPG */
config->pgp_path = bonobo_config_get_string (config->db,
"/Mail/PGP/path", NULL);
@@ -910,7 +920,7 @@ mail_config_write_on_exit (void)
/* Format */
bonobo_config_set_boolean (config->db, "/Mail/Format/send_html",
config->send_html, NULL);
-
+
/* Confirm Sending Unwanted HTML */
bonobo_config_set_boolean (config->db, "/Mail/Format/confirm_unwanted_html",
config->confirm_unwanted_html, NULL);
@@ -923,6 +933,10 @@ mail_config_write_on_exit (void)
bonobo_config_set_long (config->db, "/Mail/Display/citation_color",
config->citation_color, NULL);
+ /* Goto next folder */
+ bonobo_config_set_boolean (config->db, "/Mail/MessageList/goto_next_folder",
+ config->goto_next_folder, NULL);
+
/* Empty Subject */
bonobo_config_set_boolean (config->db, "/Mail/Prompts/empty_subject",
config->prompt_empty_subject, NULL);
@@ -935,6 +949,10 @@ mail_config_write_on_exit (void)
bonobo_config_set_boolean (config->db, "/Mail/Prompts/confirm_expunge",
config->confirm_expunge, NULL);
+ /* Goto next folder */
+ bonobo_config_set_boolean (config->db, "/Mail/Prompts/confirm_goto_next_folder",
+ config->confirm_goto_next_folder, NULL);
+
/* PGP/GPG */
bonobo_config_set_string_wrapper (config->db, "/Mail/PGP/path",
config->pgp_path, NULL);
@@ -1362,6 +1380,29 @@ mail_config_set_confirm_expunge (gboolean value)
config->confirm_expunge = value;
}
+gboolean
+mail_config_get_confirm_goto_next_folder (void)
+{
+ return config->confirm_goto_next_folder;
+}
+
+void
+mail_config_set_confirm_goto_next_folder (gboolean value)
+{
+ config->confirm_goto_next_folder = value;
+}
+
+gboolean
+mail_config_get_goto_next_folder (void)
+{
+ return config->goto_next_folder;
+}
+
+void
+mail_config_set_goto_next_folder (gboolean value)
+{
+ config->goto_next_folder = value;
+}
struct {
char *bin;
diff --git a/mail/mail-config.h b/mail/mail-config.h
index 82dd654e8a..00065fdfd8 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -172,6 +172,11 @@ void mail_config_set_prompt_only_bcc (gboolean value);
gboolean mail_config_get_confirm_expunge (void);
void mail_config_set_confirm_expunge (gboolean value);
+gboolean mail_config_get_confirm_goto_next_folder (void);
+void mail_config_set_confirm_goto_next_folder (gboolean value);
+gboolean mail_config_get_goto_next_folder (void);
+void mail_config_set_goto_next_folder (gboolean value);
+
CamelPgpType mail_config_pgp_type_detect_from_path (const char *pgp);
CamelPgpType mail_config_get_pgp_type (void);
diff --git a/mail/message-list.c b/mail/message-list.c
index f2dfcf1918..030791faa8 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -403,8 +403,10 @@ search_func (ETreeModel *model, ETreePath path, struct search_func_data *data)
* message, or %MESSAGE_LIST_SELECT_PREVIOUS if it should find the
* previous. If no suitable row is found, the selection will be
* unchanged.
+ *
+ * Returns %TRUE if a new message has been selected or %FALSE otherwise.
**/
-void
+gboolean
message_list_select (MessageList *message_list,
MessageListSelectDirection direction,
guint32 flags,
@@ -413,23 +415,23 @@ message_list_select (MessageList *message_list,
{
struct search_func_data data;
ETreeFindNextParams params = 0;
-
+
if (!GTK_WIDGET_HAS_FOCUS (message_list))
gtk_widget_grab_focus (GTK_WIDGET (message_list));
-
+
data.message_list = message_list;
data.flags = flags;
data.mask = mask;
-
+
if (direction == MESSAGE_LIST_SELECT_NEXT)
params |= E_TREE_FIND_NEXT_FORWARD;
else
params |= E_TREE_FIND_NEXT_BACKWARD;
-
+
if (wraparound)
params |= E_TREE_FIND_NEXT_WRAP;
-
- e_tree_find_next (message_list->tree, params, (ETreePathFunc) search_func, &data);
+
+ return e_tree_find_next (message_list->tree, params, (ETreePathFunc) search_func, &data);
}
diff --git a/mail/message-list.h b/mail/message-list.h
index 42de65cbd8..d6965b5c71 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -116,7 +116,7 @@ void message_list_foreach (MessageList *message_list,
MessageListForeachFunc callback,
gpointer user_data);
-void message_list_select (MessageList *message_list,
+gboolean message_list_select (MessageList *message_list,
MessageListSelectDirection direction,
guint32 flags,
guint32 mask,