allow forwarding multiple selected messages
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Wed, 27 Jun 2001 19:28:01 +0000 (19:28 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Wed, 27 Jun 2001 19:28:01 +0000 (19:28 +0000)
ChangeLog.claws
src/compose.c
src/compose.h
src/mainwindow.c
src/summaryview.c

index 989b764..1d85954 100644 (file)
@@ -1,3 +1,11 @@
+2001-06-27 [alfons]
+
+               * src/summaryview.c
+               * src/compose.[ch]
+               * src/mainwindow.c
+                       if there are multiple messages selected, allow forwarding
+                       them as attachments.
+
 2001-06-27 [paul]
 
         * more sync with sylpheed 0.5.0pre3
index ce67361..db91a0d 100644 (file)
@@ -954,6 +954,60 @@ Compose * compose_forward(PrefsAccount * account, MsgInfo *msginfo,
 
 #undef INSERT_FW_HEADER
 
+Compose * compose_forward_multiple(PrefsAccount * account, 
+                         GSList *msginfo_list) 
+{
+       Compose *compose;
+       GtkSText *text;
+       GSList *msginfo;
+       gchar *msgfile;
+
+       g_return_val_if_fail(msginfo_list != NULL, NULL);
+       
+       for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
+               if ( ((MsgInfo *)msginfo->data)->folder == NULL )
+                       return NULL;
+       }
+       
+       if (account == NULL) {
+               account = cur_account;
+               /*
+               account = msginfo->folder->folder->account;
+               if (!account) account = cur_account;
+               */
+       }
+       g_return_val_if_fail(account != NULL, NULL);
+
+       compose = compose_create(account);
+       compose->mode = COMPOSE_FORWARD;
+
+       text = GTK_STEXT(compose->text);
+       gtk_stext_freeze(text);
+
+       for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
+               msgfile = procmsg_get_message_file_path((MsgInfo *)msginfo->data);
+               if (!is_file_exist(msgfile))
+                       g_warning(_("%s: file not exist\n"), msgfile);
+               else
+                       compose_attach_append(compose, msgfile,
+                               MIME_MESSAGE_RFC822);
+               g_free(msgfile);
+       }
+
+       if (prefs_common.auto_sig)
+               compose_insert_sig(compose);
+       gtk_editable_set_position(GTK_EDITABLE(compose->text), 0);
+       gtk_stext_set_point(GTK_STEXT(compose->text), 0);
+
+       gtk_stext_thaw(text);
+       if (account->protocol != A_NNTP)
+               gtk_widget_grab_focus(compose->to_entry);
+       else
+               gtk_widget_grab_focus(compose->newsgroups_entry);
+
+       return compose;
+}
+
 void compose_reedit(MsgInfo *msginfo)
 {
        Compose *compose;
index f60b47c..e885ead 100644 (file)
@@ -185,6 +185,9 @@ void compose_reply          (MsgInfo        *msginfo,
 Compose * compose_forward      (PrefsAccount *account,
                                 MsgInfo        *msginfo,
                                 gboolean        as_attach);
+Compose * compose_forward_multiple(PrefsAccount * account, 
+                         GSList *msginfo_list);
+                         
 void compose_reedit            (MsgInfo        *msginfo);
 
 GList *compose_get_compose_list        (void);
index b138095..f97d281 100644 (file)
@@ -1177,8 +1177,8 @@ void main_window_set_menu_sensitive(MainWindow *mainwin, gint selection)
        menu_set_sensitive(ifactory, "/Message/Reply", sens);
        menu_set_sensitive(ifactory, "/Message/Reply to sender", sens);
        menu_set_sensitive(ifactory, "/Message/Reply to all", sens);
-       menu_set_sensitive(ifactory, "/Message/Forward", sens);
-       menu_set_sensitive(ifactory, "/Message/Forward as attachment", sens);
+       menu_set_sensitive(ifactory, "/Message/Forward", TRUE);
+       menu_set_sensitive(ifactory, "/Message/Forward as attachment", TRUE);
        menu_set_sensitive(ifactory, "/Message/Open in new window", sens);
        menu_set_sensitive(ifactory, "/Message/Show all header", sens);
        menu_set_sensitive(ifactory, "/Message/View source", sens);
@@ -2223,6 +2223,7 @@ static void compose_news_cb(MainWindow *mainwin, guint action,
 
 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
+       GList  *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data
@@ -2250,10 +2251,21 @@ static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
                              TRUE, FALSE);
                break;
        case COMPOSE_FORWARD:
-               compose_forward(NULL, msginfo, FALSE);
-               break;
+               if (!sel->next) {
+                       compose_forward(NULL, msginfo, FALSE);
+                       break;
+               }
+               /* if (sel->next) FALL_THROUGH */
        case COMPOSE_FORWARD_AS_ATTACH:
-               compose_forward(NULL, msginfo, TRUE);
+               {
+                       GSList *msginfo_list = NULL;
+                       for ( ; sel != NULL; sel = sel->next)
+                               msginfo_list = g_slist_append(msginfo_list, 
+                                       gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
+                                               GTK_CTREE_NODE(sel->data)));
+                       compose_forward_multiple(NULL, msginfo_list);
+                       g_slist_free(msginfo_list);
+               }                       
                break;
        default:
                g_warning("reply_cb(): invalid action type: %d\n", action);
index 5725b8e..fd849fa 100644 (file)
@@ -936,9 +936,10 @@ static void summary_set_menu_sensitive(SummaryView *summaryview)
        menu_set_sensitive(ifactory, "/Reply",                    sens);
        menu_set_sensitive(ifactory, "/Reply to sender",          sens);
        menu_set_sensitive(ifactory, "/Reply to all",             sens);
-       menu_set_sensitive(ifactory, "/Forward",                  sens);
-       menu_set_sensitive(ifactory, "/Forward as attachment",    sens);
-
+       
+       menu_set_sensitive(ifactory, "/Forward",                                TRUE);
+       menu_set_sensitive(ifactory, "/Forward as attachment",  TRUE);
+       
        menu_set_sensitive(ifactory, "/Open in new window", sens);
        menu_set_sensitive(ifactory, "/View source", sens);
        menu_set_sensitive(ifactory, "/Show all header", sens);
@@ -3264,6 +3265,7 @@ static void summary_reply_cb(SummaryView *summaryview, guint action,
                             GtkWidget *widget)
 {
        MsgInfo *msginfo;
+       GList  *sel = GTK_CLIST(summaryview->ctree)->selection;
 
        msginfo = gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree),
                                              summaryview->selected);
@@ -3306,10 +3308,21 @@ static void summary_reply_cb(SummaryView *summaryview, guint action,
                compose_reply(msginfo, FALSE, TRUE, FALSE);
                break;
        case COMPOSE_FORWARD:
-               compose_forward(NULL, msginfo, FALSE);
-               break;
+               if (!sel->next) {
+                       compose_forward(NULL, msginfo, FALSE);
+                       break;
+               }
+               /* if (sel->next) FALL THROUGH */
        case COMPOSE_FORWARD_AS_ATTACH:
-               compose_forward(NULL, msginfo, TRUE);
+               {
+                       GSList *msginfo_list = NULL;
+                       for ( ; sel != NULL; sel = sel->next)
+                               msginfo_list = g_slist_append(msginfo_list, 
+                                       gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree),
+                                               GTK_CTREE_NODE(sel->data)));
+                       compose_forward_multiple(NULL, msginfo_list);
+                       g_slist_free(msginfo_list);
+               }                       
                break;
        default:
                g_warning("summary_reply_cb(): invalid action: %d\n", action);