2006-11-09 [colin] 2.6.0cvs22
authorColin Leroy <colin@colino.net>
Thu, 9 Nov 2006 18:09:10 +0000 (18:09 +0000)
committerColin Leroy <colin@colino.net>
Thu, 9 Nov 2006 18:09:10 +0000 (18:09 +0000)
* src/account.c
* src/compose.c
Search for one of our accounts in Delivered-To
(helps for auto-account selection when
 replying/forwarding)
* src/folderview.c
* src/mainwindow.c
* src/mainwindow.h
* src/plugins/trayicon/trayicon.c
Allow opening a new mail with any account from
the contextual menu

ChangeLog
PATCHSETS
configure.ac
src/account.c
src/compose.c
src/folderview.c
src/mainwindow.c
src/mainwindow.h
src/plugins/trayicon/trayicon.c

index 9791c778474f9aed92d2fa6fefb19f7f4c204946..540f480fd7223218364d15cf76285b489e787129 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2006-11-09 [colin]     2.6.0cvs22
+
+       * src/account.c
+       * src/compose.c
+               Search for one of our accounts in Delivered-To
+               (helps for auto-account selection when 
+                replying/forwarding)
+       * src/folderview.c
+       * src/mainwindow.c
+       * src/mainwindow.h
+       * src/plugins/trayicon/trayicon.c
+               Allow opening a new mail with any account from
+               the contextual menu
+
 2006-11-09 [wwp]       2.6.0cvs21
 
        * src/compose.c
index 9019c0a9120e7cc15b97cd2225a5b46532715404..8a925ab1fb21aad08bbe1f70881251717d18eb86 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.27 -r 1.1.2.28 src/gtk/authors.h;  ) > 2.6.0cvs19.patchset
 ( cvs diff -u -r 1.1.2.28 -r 1.1.2.29 src/gtk/authors.h;  ) > 2.6.0cvs20.patchset
 ( cvs diff -u -r 1.382.2.324 -r 1.382.2.325 src/compose.c;  cvs diff -u -r 1.204.2.108 -r 1.204.2.109 src/prefs_common.c;  cvs diff -u -r 1.103.2.66 -r 1.103.2.67 src/prefs_common.h;  cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/prefs_compose_writing.c;  ) > 2.6.0cvs21.patchset
+( cvs diff -u -r 1.61.2.54 -r 1.61.2.55 src/account.c;  cvs diff -u -r 1.382.2.325 -r 1.382.2.326 src/compose.c;  cvs diff -u -r 1.207.2.131 -r 1.207.2.132 src/folderview.c;  cvs diff -u -r 1.274.2.154 -r 1.274.2.155 src/mainwindow.c;  cvs diff -u -r 1.39.2.26 -r 1.39.2.27 src/mainwindow.h;  cvs diff -u -r 1.14.2.41 -r 1.14.2.42 src/plugins/trayicon/trayicon.c;  ) > 2.6.0cvs22.patchset
index 6bd4aab64bc60aadf4bb089df45c6d46725efddc..e430802e21b6ca8b2bf19224982a204d0a8e8847 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=6
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=21
+EXTRA_VERSION=22
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index d873e9fa2ee76a3b86a434c755ec11b6dc7b35d4..5e883e0e525841c535a1b9f49614efbbbc7c6e19 100644 (file)
@@ -1335,6 +1335,15 @@ PrefsAccount *account_get_reply_account(MsgInfo *msginfo, gboolean reply_autosel
                                }
                        }
                }
+               if (!account) {
+                       gchar deliveredto[BUFFSIZE];
+                       if (!procheader_get_header_from_msginfo
+                               (msginfo, deliveredto,sizeof deliveredto , "Delivered-To:")) { 
+                               gchar *buf = deliveredto + strlen("Delivered-To:");
+                               extract_address(buf);
+                               account = account_find_from_address(buf);
+                       }
+               }
        }
 
        /* select the account for the whole folder (IMAP / NNTP) */
index a0f14802a7a2a55a0d3643246032444172c84e03..a6ef740f8a48d9cbb497c39deb4a501b5a50f44a 100644 (file)
@@ -9194,9 +9194,20 @@ static PrefsAccount *compose_guess_forward_account_from_msginfo(MsgInfo *msginfo
        if (!account && prefs_common.forward_account_autosel) {
                gchar cc[BUFFSIZE];
                if (!procheader_get_header_from_msginfo
-                       (msginfo, cc,sizeof cc , "CC:")) { /* Found a CC header */
-                       extract_address(cc);
-                       account = account_find_from_address(cc);
+                       (msginfo, cc,sizeof cc , "Cc:")) { 
+                       gchar *buf = cc + strlen("Cc:");
+                       extract_address(buf);
+                       account = account_find_from_address(buf);
+                }
+       }
+       
+       if (!account && prefs_common.forward_account_autosel) {
+               gchar deliveredto[BUFFSIZE];
+               if (!procheader_get_header_from_msginfo
+                       (msginfo, deliveredto,sizeof deliveredto , "Delivered-To:")) { 
+                       gchar *buf = deliveredto + strlen("Delivered-To:");
+                       extract_address(buf);
+                       account = account_find_from_address(buf);
                 }
        }
        
index 6234b8f5762dc493bde4264ea10081acc3e6a5e5..4b520d5c000de1ed89683ac1a03d3d32c724d894 100644 (file)
@@ -1684,6 +1684,7 @@ gboolean folderview_update_item_claws(gpointer source, gpointer data)
        ctree = GTK_CTREE(folderview->ctree);
 
        node = gtk_ctree_find_by_row_data(ctree, NULL, update_info->item);
+
        if (node) {
                if (update_info->update_flags & (F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_NAME))
                        folderview_update_node(folderview, node);
index 6963422ef65c3f4238871d7d687f50838dbe5fa5..fb41eddaaaf6ee918105cd28d8083ac5e0ab6a95 100644 (file)
@@ -1792,6 +1792,7 @@ void main_window_set_account_menu(GList *account_list)
                main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
                main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
        }
+       hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
 }
 
 void main_window_set_account_menu_only_toolbar(GList *account_list)
index 2b592ae8b0c6aede15072761f1831b2e94ab1161..708434471365627d25b366ae8286cc3b71c28043 100644 (file)
@@ -32,6 +32,7 @@ typedef struct _MainWindow  MainWindow;
 #include "toolbar.h"
 
 #define OFFLINE_SWITCH_HOOKLIST "offline_switch"
+#define ACCOUNT_LIST_CHANGED_HOOKLIST "account_list_changed"
 
 typedef enum
 {
index 604cbae0864c9faee840759618fcdc132deeb909..b92bb29b4faaa2acf70dfb3f46c69d87940f3ad8 100644 (file)
@@ -58,6 +58,7 @@
 static guint item_hook_id;
 static guint folder_hook_id;
 static guint offline_hook_id;
+static guint account_hook_id;
 
 static GdkPixmap *newmail_pixmap[2];
 static GdkPixmap *newmail_bitmap[2];
@@ -91,6 +92,7 @@ typedef enum
 
 static void trayicon_get_all_cb            (gpointer data, guint action, GtkWidget *widget);
 static void trayicon_compose_cb            (gpointer data, guint action, GtkWidget *widget);
+static void trayicon_compose_acc_cb (GtkMenuItem *menuitem, gpointer data );
 static void trayicon_addressbook_cb (gpointer data, guint action, GtkWidget *widget);
 static void trayicon_exit_cb       (gpointer data, guint action, GtkWidget *widget);
 static void trayicon_toggle_offline_cb (gpointer data, guint action, GtkWidget *widget);
@@ -101,6 +103,8 @@ static GtkItemFactoryEntry trayicon_popup_menu_entries[] =
        {N_("/_Get Mail"),              NULL, trayicon_get_all_cb,              0, NULL},
        {N_("/---"),                    NULL, NULL,                             0, "<Separator>"},
        {N_("/_Email"),                 NULL, trayicon_compose_cb,              0, NULL},
+       {N_("/_Email from account"),    NULL, NULL,                             0, "<Branch>"},
+       {N_("/---"),                    NULL, NULL,                             0, "<Separator>"},
        {N_("/Open A_ddressbook"),      NULL, trayicon_addressbook_cb,          0, NULL},
        {N_("/---"),                    NULL, NULL,                             0, "<Separator>"},
        {N_("/_Work Offline"),          NULL, trayicon_toggle_offline_cb,       0, "<CheckItem>"},
@@ -108,6 +112,41 @@ static GtkItemFactoryEntry trayicon_popup_menu_entries[] =
        {N_("/E_xit Claws Mail"),       NULL, trayicon_exit_cb,                 0, NULL}
 };
 
+static gboolean trayicon_set_accounts_hook(gpointer source, gpointer data)
+{
+       GList *cur_ac, *cur_item = NULL;
+       GtkWidget *menu;
+       GtkWidget *menuitem;
+       PrefsAccount *ac_prefs;
+
+       GList *account_list = account_get_list();
+
+       menu = gtk_item_factory_get_widget(traymenu_factory,
+                                          "/Email from account");
+
+       /* destroy all previous menu item */
+       cur_item = GTK_MENU_SHELL(menu)->children;
+       while (cur_item != NULL) {
+               GList *next = cur_item->next;
+               gtk_widget_destroy(GTK_WIDGET(cur_item->data));
+               cur_item = next;
+       }
+
+       for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
+               ac_prefs = (PrefsAccount *)cur_ac->data;
+
+               menuitem = gtk_menu_item_new_with_label
+                       (ac_prefs->account_name ? ac_prefs->account_name
+                        : _("Untitled"));
+               gtk_widget_show(menuitem);
+               gtk_menu_append(GTK_MENU(menu), menuitem);
+               g_signal_connect(G_OBJECT(menuitem), "activate",
+                                G_CALLBACK(trayicon_compose_acc_cb),
+                                ac_prefs);
+       }
+       return FALSE;
+}
+
 static void set_trayicon_pixmap(TrayIconType icontype)
 {
        GdkPixmap *pixmap = NULL;
@@ -339,7 +378,14 @@ int plugin_init(gchar **error)
                return -1;
        }
 
+       account_hook_id = hooks_register_hook (ACCOUNT_LIST_CHANGED_HOOKLIST, trayicon_set_accounts_hook, NULL);
+       if (offline_hook_id == -1) {
+               *error = g_strdup(_("Failed to register offline switch hook"));
+               return -1;
+       }
+
        create_trayicon();
+       trayicon_set_accounts_hook(NULL, NULL);
 
        return 0;
 }
@@ -349,6 +395,7 @@ void plugin_done(void)
        hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, item_hook_id);
        hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, folder_hook_id);
        hooks_unregister_hook(OFFLINE_SWITCH_HOOKLIST, offline_hook_id);
+       hooks_unregister_hook(ACCOUNT_LIST_CHANGED_HOOKLIST, account_hook_id);
 
        if (sylpheed_is_exiting())
                return;
@@ -406,6 +453,11 @@ static void trayicon_compose_cb( gpointer data, guint action, GtkWidget *widget
        compose_mail_cb(mainwin, 0, NULL);
 }
 
+static void trayicon_compose_acc_cb( GtkMenuItem *menuitem, gpointer data )
+{
+       compose_new((PrefsAccount *)data, NULL, NULL);
+}
+
 static void trayicon_addressbook_cb( gpointer data, guint action, GtkWidget *widget )
 {
        addressbook_open(NULL);