From 7031a911d71eb1f527f8ff9336f050679a7b74f9 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 16 May 2001 21:40:52 +0000 Subject: Functions to determine if a folderbrowser is one of the drafts, sent, or * folder-browser.c (folder_browser_is_drafts, folder_browser_is_sent, folder_browser_is_outbox): Functions to determine if a folderbrowser is one of the drafts, sent, or outbox folders. (got_folder): Pass TRUE for the "outgoing" flag to message_list_set_folder if this is a Sent, Drafts, or Outbox folder. * message-list.c (message_list_set_folder): Take a flag saying whether or not the folder is an "outgoing" folder. (message_list_setup_etree): Ditto. Use that rather than a hardcoded list of foldernames for deciding whether to swap From and To in the default layout. * mail-config.c (mail_config_folder_to_cachename): Make IMAP folders have unique cachenames rather than only one per store, so that IMAP Sent and Drafts folders don't get forced into having the same layout as the INBOX. * mail-callbacks.c: (is_sent_folder, is_drafts_folder): Gone. Replaced with simpler folder_browser_is_* routines. (edit_msg, resend_msg, open_msg): Use folder_browser_is_* routines. * mail-local.c (reconfigure_clicked): Update call to message_list_set_folder. svn path=/trunk/; revision=9857 --- mail/folder-browser.c | 99 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 20 deletions(-) (limited to 'mail/folder-browser.c') diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 5469a2d782..81c27f450f 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -137,25 +137,6 @@ folder_browser_class_init (GtkObjectClass *object_class) gtk_object_class_add_signals (object_class, folder_browser_signals, LAST_SIGNAL); } -/* - * static gboolean - * folder_browser_load_folder (FolderBrowser *fb, const char *name) - * { - * CamelFolder *new_folder; - * - * new_folder = mail_tool_uri_to_folder_noex (name); - * - * if (!new_folder) - * return FALSE; - * - * if (fb->folder) - * camel_object_unref (CAMEL_OBJECT (fb->folder)); - * fb->folder = new_folder; - * message_list_set_folder (fb->message_list, new_folder); - * return TRUE; - * } - */ - static void update_unread_count_main(CamelObject *object, gpointer event_data, gpointer user_data) { @@ -224,7 +205,10 @@ got_folder(char *uri, CamelFolder *folder, void *data) gtk_widget_set_sensitive(GTK_WIDGET(fb->search), camel_folder_has_search_capability(folder)); message_list_set_threaded(fb->message_list, mail_config_get_thread_list()); - message_list_set_folder(fb->message_list, folder); + message_list_set_folder(fb->message_list, folder, + folder_browser_is_drafts (fb) || + folder_browser_is_sent (fb) || + folder_browser_is_outbox (fb)); vfolder_register_source(folder); done: gtk_object_unref((GtkObject *)fb); @@ -251,6 +235,81 @@ folder_browser_set_uri (FolderBrowser *folder_browser, const char *uri) return TRUE; } + +extern CamelFolder *drafts_folder, *sent_folder, *outbox_folder; + +/** + * folder_browser_is_drafts: + * @fb: a FolderBrowser + * + * Return value: %TRUE if @fb refers to /local/Drafts or any other + * configured Drafts folder. + **/ +gboolean +folder_browser_is_drafts (FolderBrowser *fb) +{ + const GSList *accounts; + MailConfigAccount *account; + + g_return_val_if_fail (IS_FOLDER_BROWSER (fb) && fb->uri, FALSE); + + if (fb->folder == drafts_folder) + return TRUE; + + accounts = mail_config_get_accounts (); + while (accounts) { + account = accounts->data; + if (account->drafts_folder_uri && + !strcmp (account->drafts_folder_uri, fb->uri)) + return TRUE; + accounts = accounts->next; + } + return FALSE; +} + +/** + * folder_browser_is_sent: + * @fb: a FolderBrowser + * + * Return value: %TRUE if @fb refers to /local/Sent or any other + * configured Sent folder. + **/ +gboolean +folder_browser_is_sent (FolderBrowser *fb) +{ + const GSList *accounts; + MailConfigAccount *account; + + g_return_val_if_fail (IS_FOLDER_BROWSER (fb) && fb->uri, FALSE); + + if (fb->folder == sent_folder) + return TRUE; + + accounts = mail_config_get_accounts (); + while (accounts) { + account = accounts->data; + if (account->sent_folder_uri && + !strcmp (account->sent_folder_uri, fb->uri)) + return TRUE; + accounts = accounts->next; + } + return FALSE; +} + +/** + * folder_browser_is_outbox: + * @fb: a FolderBrowser + * + * Return value: %TRUE if @fb refers to /local/Outbox or any other + * configured Outbox folder. + **/ +gboolean +folder_browser_is_outbox (FolderBrowser *fb) +{ + /* There can be only one. */ + return fb->folder == outbox_folder; +} + void folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show_message_preview) { -- cgit