toolbar reply refactoring: part 2
authorOliver Haertel <o.h.a@gmx.net>
Mon, 3 Mar 2003 19:07:28 +0000 (19:07 +0000)
committerOliver Haertel <o.h.a@gmx.net>
Mon, 3 Mar 2003 19:07:28 +0000 (19:07 +0000)
ChangeLog.claws
configure.ac
src/compose.c
src/compose.h
src/folderview.c
src/toolbar.c
src/toolbar.h

index 6e80d44..7ca9e3b 100644 (file)
@@ -1,3 +1,16 @@
+2003-03-03 [oliver]    0.8.10claws74
+
+       * src/toolbar.[ch]
+               cleanups and refactoring
+       * src/compose.[ch]
+               compose_reply_mode reply & forwarding interface for
+               toolbar buttons
+       * src/folderview.c
+               act on messages marked for deletion in folderview_selected
+               based on prefs_common.immediate_exec since a message might 
+               have been deleted by messageview in a folder we are changing 
+               to (does anybody understand what I'm on about ?)
+
 2003-03-03 [oliver]    0.8.10claws73
        
        * src/messageview.[ch]
@@ -58,7 +71,8 @@
 
 2003-03-01 [oliver]    0.8.10claws67
 
-       * ???
+       * src/summaryview.c
+               menu callbacks call toolbar_menu_reply
 
 2003-03-01 [oliver]    0.8.10claws66
 
index 0313306..7433f35 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws73
+EXTRA_VERSION=claws74
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index dcd979d..743b47c 100644 (file)
@@ -787,6 +787,93 @@ Compose *compose_new_followup_and_replyto(PrefsAccount *account,
 }
 */
 
+void compose_reply_mode(ComposeMode mode, GSList *msginfo_list, gchar *body)
+{
+       MsgInfo *msginfo;
+       guint list_len;
+
+       g_return_if_fail(msginfo_list != NULL);
+
+       msginfo = (MsgInfo*)g_slist_nth_data(msginfo_list, 0);
+       g_return_if_fail(msginfo != NULL);
+
+       list_len = g_slist_length(msginfo_list);
+
+       switch (mode) {
+       case COMPOSE_REPLY:
+               compose_reply(msginfo, prefs_common.reply_with_quote,
+                             FALSE, prefs_common.default_reply_list, FALSE, body);
+               break;
+       case COMPOSE_REPLY_WITH_QUOTE:
+               compose_reply(msginfo, TRUE, FALSE, prefs_common.default_reply_list, FALSE, body);
+               break;
+       case COMPOSE_REPLY_WITHOUT_QUOTE:
+               compose_reply(msginfo, FALSE, FALSE, prefs_common.default_reply_list, FALSE, NULL);
+               break;
+       case COMPOSE_REPLY_TO_SENDER:
+               compose_reply(msginfo, prefs_common.reply_with_quote,
+                             FALSE, FALSE, TRUE, body);
+               break;
+       case COMPOSE_FOLLOWUP_AND_REPLY_TO:
+               compose_followup_and_reply_to(msginfo,
+                                             prefs_common.reply_with_quote,
+                                             FALSE, FALSE, body);
+               break;
+       case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
+               compose_reply(msginfo, TRUE, FALSE, FALSE, TRUE, body);
+               break;
+       case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
+               compose_reply(msginfo, FALSE, FALSE, FALSE, TRUE, NULL);
+               break;
+       case COMPOSE_REPLY_TO_ALL:
+               compose_reply(msginfo, prefs_common.reply_with_quote,
+                             TRUE, FALSE, FALSE, body);
+               break;
+       case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
+               compose_reply(msginfo, TRUE, TRUE, FALSE, FALSE, body);
+               break;
+       case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
+               compose_reply(msginfo, FALSE, TRUE, FALSE, FALSE, NULL);
+               break;
+       case COMPOSE_REPLY_TO_LIST:
+               compose_reply(msginfo, prefs_common.reply_with_quote,
+                             FALSE, TRUE, FALSE, body);
+               break;
+       case COMPOSE_REPLY_TO_LIST_WITH_QUOTE:
+               compose_reply(msginfo, TRUE, FALSE, TRUE, FALSE, body);
+               break;
+       case COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE:
+               compose_reply(msginfo, FALSE, FALSE, TRUE, FALSE, NULL);
+               break;
+       case COMPOSE_FORWARD:
+               if (prefs_common.forward_as_attachment) {
+                       compose_reply_mode(COMPOSE_FORWARD_AS_ATTACH, msginfo_list, body);
+                       return;
+               } else {
+                       compose_reply_mode(COMPOSE_FORWARD_INLINE, msginfo_list, body);
+                       return;
+               }
+               break;
+       case COMPOSE_FORWARD_INLINE:
+               /* check if we reply to more than one Message */
+               if (list_len == 1) {
+                       compose_forward(NULL, msginfo, FALSE, body);
+                       break;
+               } 
+               /* more messages FALL THROUGH */
+       case COMPOSE_FORWARD_AS_ATTACH:
+               compose_forward_multiple(NULL, msginfo_list);
+               break;
+       case COMPOSE_REDIRECT:
+               compose_redirect(NULL, msginfo);
+               break;
+       default:
+               g_warning("compose_reply(): invalid Compose Mode: %d\n", mode);
+       }
+       
+       //summary_set_marks_selected(summaryview);
+}
+
 void compose_reply(MsgInfo *msginfo, gboolean quote, gboolean to_all,
                   gboolean to_ml, gboolean to_sender, 
                   const gchar *body)
index 3856778..da18ab9 100644 (file)
@@ -222,6 +222,10 @@ Compose *compose_new                       (PrefsAccount   *account,
 Compose *compose_new_with_folderitem   (PrefsAccount   *account,
                                         FolderItem     *item);
 
+void compose_reply_mode                        (ComposeMode     mode, 
+                                        GSList         *msginfo_list, 
+                                        gchar          *body);
+/* remove */
 void compose_followup_and_reply_to     (MsgInfo        *msginfo,
                                         gboolean        quote,
                                         gboolean        to_all,
@@ -239,6 +243,8 @@ Compose *compose_forward            (PrefsAccount *account,
                                         const gchar    *body);
 Compose *compose_forward_multiple      (PrefsAccount   *account, 
                                         GSList         *msginfo_list);
+/* remove end */
+
 Compose *compose_redirect              (PrefsAccount   *account,
                                         MsgInfo        *msginfo);
 void compose_reedit                    (MsgInfo        *msginfo);
index 8dca3fc..bd9cd28 100644 (file)
@@ -1759,6 +1759,10 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
        /* Show messages */
        summary_set_prefs_from_folderitem(folderview->summaryview, item);
        opened = summary_show(folderview->summaryview, item);
+       
+       /* messageview could have deleted messages in this folder */
+       if (prefs_common.immediate_exec)
+               summary_execute(folderview->summaryview);
 
        folder_clean_cache_memory();
 
index 045baca..d068047 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "intl.h"
 #include "mainwindow.h"
+#include "summaryview.h"
 #include "compose.h"
 #include "utils.h"
 #include "xml.h"
@@ -1071,9 +1072,7 @@ static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
        switch (toolbar_item->type) {
        case TOOLBAR_MSGVIEW:
                msgview = (MessageView*)toolbar_item->parent;
-               /* make sure the selected msg in summaryview is 
-                  the one we are asked to delete */
-               delete_msgview_cb(msgview, 0, widget);
+               messageview_delete(msgview);
                break;
         case TOOLBAR_MAIN:
                mainwin = (MainWindow*)toolbar_item->parent;
@@ -1920,191 +1919,47 @@ void toolbar_init(Toolbar * toolbar) {
        toolbar_destroy(toolbar);
 }
 
-/* exported functions */
-
-void delete_msgview_cb(gpointer data, guint action, GtkWidget *widget)
-{
-       MessageView *msgview = (MessageView*)data;
-
-       if (msgview->mainwin->summaryview->selected) {
-               SummaryView *summaryview = msgview->mainwin->summaryview;
-               GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
-               MsgInfo *msginfo = gtk_ctree_node_get_row_data(ctree, 
-                                                              summaryview->selected);  
-               if (msginfo->msgnum != msgview->msginfo->msgnum) {
-                       alertpanel_error(_("Message already removed from folder."));
-                       return;
-               }
-       }
-       
-       summary_delete(msgview->mainwin->summaryview);  
-       
-       if (msgview->mainwin->summaryview->selected) {
-               SummaryView *summaryview = msgview->mainwin->summaryview;
-               GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
-               MsgInfo *msginfo = gtk_ctree_node_get_row_data(ctree, 
-                                                              summaryview->selected);
-               messageview_show(msgview, msginfo, 
-                                msgview->all_headers);
-       } else {
-               toolbar_clear_list(TOOLBAR_MSGVIEW);
-               toolbar_destroy(msgview->toolbar);
-               gtk_widget_destroy(msgview->window);
-       }       
-}
-
-void toolbar_menu_reply(ToolbarType type, gpointer data, guint action)
-{
-       ToolbarItem *item;
-
-       g_return_if_fail(data != NULL);
-
-       item = g_new0(ToolbarItem, 1);
-       item->parent = data;
-       item->type = type;
-       toolbar_reply(item, action);
-       g_free(item);   
-}
-
+/*
+ */
 static void toolbar_reply(gpointer data, guint action)
 {
        ToolbarItem *toolbar_item = (ToolbarItem*)data;
        MainWindow *mainwin;
        MessageView *msgview;
-       SummaryView *summaryview;
-       GList *sel = NULL;
-       MsgInfo *msginfo = NULL;
-       gchar *text;
+       GSList *msginfo_list = NULL;
+       gchar *body;
+
+       g_return_if_fail(toolbar_item != NULL);
 
        switch (toolbar_item->type) {
        case TOOLBAR_MAIN:
                mainwin = (MainWindow*)toolbar_item->parent;
-               summaryview = mainwin->summaryview;
-               msginfo = gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree),
-                                                     summaryview->selected);
-               msgview = mainwin->summaryview->messageview;
-               sel = GTK_CLIST(summaryview->ctree)->selection;
+               msginfo_list = summary_get_selection(mainwin->summaryview);
+               msgview = (MessageView*)mainwin->messageview;
                break;
        case TOOLBAR_MSGVIEW:
                msgview = (MessageView*)toolbar_item->parent;
-               summaryview = msgview->mainwin->summaryview;
-               msginfo = msgview->msginfo;
+               msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
                break;
        default:
                return;
        }
 
-       g_return_if_fail (msginfo != NULL);
-       g_return_if_fail (summaryview != NULL);
+       g_return_if_fail(msgview != NULL);
+       body = messageview_get_selection(msgview);
 
-       text = gtkut_editable_get_selection
-               (GTK_EDITABLE(msgview->textview->text));
-       
-       if (!text && msgview->type == MVIEW_MIME
-           && msgview->mimeview->type == MIMEVIEW_TEXT
-           && msgview->mimeview->textview
-           && !msgview->mimeview->textview->default_text) {
-               text = gtkut_editable_get_selection 
-                       (GTK_EDITABLE(msgview->mimeview->textview->text));   
-       }
+       g_return_if_fail(msginfo_list != NULL);
+       compose_reply_mode((ComposeMode)action, msginfo_list, body);
 
-       switch (action) {
-       case COMPOSE_REPLY:
-               compose_reply(msginfo, prefs_common.reply_with_quote,
-                             FALSE, prefs_common.default_reply_list, FALSE, text);
-               break;
-       case COMPOSE_REPLY_WITH_QUOTE:
-               compose_reply(msginfo, TRUE, FALSE, prefs_common.default_reply_list, FALSE, text);
-               break;
-       case COMPOSE_REPLY_WITHOUT_QUOTE:
-               compose_reply(msginfo, FALSE, FALSE, prefs_common.default_reply_list, FALSE, NULL);
-               break;
-       case COMPOSE_REPLY_TO_SENDER:
-               compose_reply(msginfo, prefs_common.reply_with_quote,
-                             FALSE, FALSE, TRUE, text);
-               break;
-       case COMPOSE_FOLLOWUP_AND_REPLY_TO:
-               compose_followup_and_reply_to(msginfo,
-                                             prefs_common.reply_with_quote,
-                                             FALSE, FALSE, text);
-               break;
-       case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
-               compose_reply(msginfo, TRUE, FALSE, FALSE, TRUE, text);
-               break;
-       case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
-               compose_reply(msginfo, FALSE, FALSE, FALSE, TRUE, NULL);
-               break;
-       case COMPOSE_REPLY_TO_ALL:
-               compose_reply(msginfo, prefs_common.reply_with_quote,
-                             TRUE, FALSE, FALSE, text);
-               break;
-       case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
-               compose_reply(msginfo, TRUE, TRUE, FALSE, FALSE, text);
-               break;
-       case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
-               compose_reply(msginfo, FALSE, TRUE, FALSE, FALSE, NULL);
-               break;
-       case COMPOSE_REPLY_TO_LIST:
-               compose_reply(msginfo, prefs_common.reply_with_quote,
-                             FALSE, TRUE, FALSE, text);
-               break;
-       case COMPOSE_REPLY_TO_LIST_WITH_QUOTE:
-               compose_reply(msginfo, TRUE, FALSE, TRUE, FALSE, text);
-               break;
-       case COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE:
-               compose_reply(msginfo, FALSE, FALSE, TRUE, FALSE, NULL);
-               break;
-       case COMPOSE_FORWARD:
-               if (prefs_common.forward_as_attachment) {
-                       toolbar_reply(data, COMPOSE_FORWARD_AS_ATTACH);
-                       return;
-               } else {
-                       toolbar_reply(data, COMPOSE_FORWARD_INLINE);
-                       return;
-               }
-               break;
-       case COMPOSE_FORWARD_INLINE:
-               /* check if we reply to more than one Message */
-               if (sel && !sel->next && toolbar_item->type == TOOLBAR_MAIN) {
-                               compose_forward(NULL, msginfo, FALSE, text);
-                               break;
-               } else if (sel == NULL && toolbar_item->type == TOOLBAR_MSGVIEW) {
-                       compose_forward(NULL, msginfo, FALSE, text);
-                       break;
-               }
-               /* more messages FALL THROUGH */
-       case COMPOSE_FORWARD_AS_ATTACH:
-               {
-                       GSList *msginfo_list = NULL;
-                       /* check if we reply to more than one Message */
-                       if (sel != 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)));
-                       } else {
-                               /* invoked from messageview */
-                               msginfo_list = g_slist_append(msginfo_list, msginfo);
-                       }
-                       
-                       compose_forward_multiple(NULL, msginfo_list);
-                       g_slist_free(msginfo_list);
-
-               }                       
-               break;
-       case COMPOSE_REDIRECT:
-               compose_redirect(NULL, msginfo);
-               break;
-       default:
-               g_warning("toolbar_reply(): invalid action: %d\n", action);
-       }
-       
-       summary_set_marks_selected(summaryview);
+       g_free(body);
+       g_slist_free(msginfo_list);
 
-       g_free(text);   
+       /* TODO: update reply state ion summaryview */
 }
 
+
+/* exported functions */
+
 void inc_mail_cb(gpointer data, guint action, GtkWidget *widget)
 {
        MainWindow *mainwin = (MainWindow*)data;
index 3dc483d..2d6cb54 100644 (file)
@@ -227,7 +227,5 @@ void        toolbar_set_style               (GtkWidget      *toolbar_wid,
                                         guint           action);
 void   toolbar_destroy                 (Toolbar        *toolbar);
 void   toolbar_init                    (Toolbar        *toolbar);
-void   toolbar_menu_reply              (ToolbarType     type,
-                                        gpointer        data,  
-                                        guint           action);
+
 #endif /* __CUSTOM_TOOLBAR_H__ */