basic reply-finder
authorColin Leroy <colin@colino.net>
Sun, 5 Jan 2003 17:33:08 +0000 (17:33 +0000)
committerColin Leroy <colin@colino.net>
Sun, 5 Jan 2003 17:33:08 +0000 (17:33 +0000)
ChangeLog.claws
configure.in
src/account.c
src/account.h
src/compose.c
src/summaryview.c

index f29ad0e77b4df5dcb362e589adf09a3fdb3e97dd..39bde009c7ace4cdce6e738bab25e0080a5743ec 100644 (file)
@@ -1,3 +1,13 @@
+2003-01-05 [colin]     0.8.8claws49
+
+       * src/account.[ch]
+               Add account_get_reply_account function
+       * src/compose.c
+               Use account_get_reply_account function 
+       * src/summaryview.c
+               Basic reply-finder - click on the replied
+               icon gets you to the outbox using quick-search
+
 2003-01-05 [paul]      0.8.8claws48
 
        * src/prefs_common.c
index 39cdf0281695286fb32e5146e5eb79108359af54..a1b73f091c3ce4fbef33d2f9d09b078018531ead 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws48
+EXTRA_VERSION=claws49
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 3c72e1fa86f4366e4d1fc782d3c1d96c1e23aeee..04b8e5898a4609db26bf75bbba38ef1a6a8df1cf 100644 (file)
@@ -980,3 +980,48 @@ static void account_list_set(void)
             row++)
                account_list = g_list_append(account_list, ac_prefs);
 }
+
+/*!
+ *\brief       finds the PrefsAccounts which should be used to answer a mail
+ *
+ *\param       msginfo The message to be answered
+ *\param       reply_autosel Indicates whether reply account autoselection is on
+ *
+ *\return      PrefsAccount * the correct account, NULL if not found
+ */
+PrefsAccount *account_get_reply_account(MsgInfo *msginfo, gboolean reply_autosel)
+{
+       PrefsAccount *account = NULL;
+       /* select the account set in folderitem's property (if enabled) */
+       if (msginfo->folder->prefs && msginfo->folder->prefs->enable_default_account)
+               account = account_find_from_id(msginfo->folder->prefs->default_account);
+       
+       /* select the account for the whole folder (IMAP / NNTP) */
+       if (!account)
+               /* FIXME: this is not right, because folder may be nested. we should
+                * ascend the tree until we find a parent with proper account 
+                * information */
+               account = msginfo->folder->folder->account;
+
+       /* select account by to: and cc: header if enabled */
+       if (reply_autosel) {
+               if (!account && msginfo->to) {
+                       gchar *to;
+                       Xstrdup_a(to, msginfo->to, return);
+                       extract_address(to);
+                       account = account_find_from_address(to);
+               }
+               if (!account) {
+                       gchar cc[BUFFSIZE];
+                       if (!get_header_from_msginfo(msginfo, cc, sizeof(cc), "CC:")) { /* Found a CC header */
+                               extract_address(cc);
+                               account = account_find_from_address(cc);
+                       }        
+               }
+       }
+
+       /* select current account */
+       if (!account) account = cur_account;
+       
+       return account;
+}
index 697dd01818daf50e4378967deb9bcab84e921505..a54e5fd9b9cec657a94647caac4e40d1ddc0b356 100644 (file)
@@ -60,5 +60,7 @@ FolderItem   *account_get_special_folder(PrefsAccount         *ac_prefs,
                                         SpecialFolderItemType   type);
 
 void         account_destroy           (PrefsAccount   *ac_prefs);
+PrefsAccount *account_get_reply_account        (MsgInfo        *msginfo, 
+                                        gboolean        reply_autosel);
 
 #endif /* __ACCOUNT_H__ */
index ad9e20be06b293ab7694b6f110df5c8247e04cff..6a3b4e3c1029c5fd4212c2f200ecd634464e22f3 100644 (file)
@@ -807,44 +807,15 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
                                  const gchar *body)
 {
        Compose *compose;
-       PrefsAccount *account;
+       PrefsAccount *account = NULL;
        PrefsAccount *reply_account;
        GtkSText *text;
 
        g_return_if_fail(msginfo != NULL);
        g_return_if_fail(msginfo->folder != NULL);
 
-       account = NULL;
-       /* select the account set in folderitem's property (if enabled) */
-       if (msginfo->folder->prefs && msginfo->folder->prefs->enable_default_account)
-               account = account_find_from_id(msginfo->folder->prefs->default_account);
+       account = account_get_reply_account(msginfo, prefs_common.reply_account_autosel);
        
-       /* select the account for the whole folder (IMAP / NNTP) */
-       if (!account)
-               /* FIXME: this is not right, because folder may be nested. we should
-                * ascend the tree until we find a parent with proper account 
-                * information */
-               account = msginfo->folder->folder->account;
-
-       /* select account by to: and cc: header if enabled */
-       if (prefs_common.reply_account_autosel) {
-               if (!account && msginfo->to) {
-                       gchar *to;
-                       Xstrdup_a(to, msginfo->to, return);
-                       extract_address(to);
-                       account = account_find_from_address(to);
-               }
-               if (!account) {
-                       gchar cc[BUFFSIZE];
-                       if (!get_header_from_msginfo(msginfo, cc, sizeof(cc), "CC:")) { /* Found a CC header */
-                               extract_address(cc);
-                               account = account_find_from_address(cc);
-                       }        
-               }
-       }
-
-       /* select current account */
-       if (!account) account = cur_account;
        g_return_if_fail(account != NULL);
 
        if (ignore_replyto && account->protocol == A_NNTP &&
index 8af61fd23ac6f03034b4b87056a035a6affe9ebc..e1b3393a7d70865ca0413e55d2f570151c98dc94 100644 (file)
@@ -386,6 +386,9 @@ static void news_flag_crosspost             (MsgInfo *msginfo);
 static void tog_searchbar_cb           (GtkWidget      *w,
                                         gpointer        data);
 
+static void summary_find_answers       (SummaryView    *summaryview, 
+                                        MsgInfo        *msg);
+
 static gboolean summary_update_msg     (gpointer source, gpointer data);
 
 GtkTargetEntry summary_drag_types[1] =
@@ -4816,6 +4819,9 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
                         !MSG_IS_FORWARDED(msginfo->flags)) {
                        summary_mark_row_as_unread(summaryview, row);
                        summary_status_show(summaryview);
+               } else if (MSG_IS_REPLIED(msginfo->flags)) {
+                       summary_find_answers(summaryview, msginfo);
+                       return;
                }
                break;
        case S_COL_LOCKED:
@@ -5429,7 +5435,8 @@ void summary_save_prefs_to_folderitem(SummaryView *summaryview, FolderItem *item
        item->threaded = summaryview->threaded;
 }
 
-static gboolean summary_update_msg(gpointer source, gpointer data) {
+static gboolean summary_update_msg(gpointer source, gpointer data) 
+{
        MsgInfoUpdate *msginfo_update = (MsgInfoUpdate *) source;
        SummaryView *summaryview = (SummaryView *)data;
        GtkCTreeNode *node;
@@ -5445,3 +5452,44 @@ static gboolean summary_update_msg(gpointer source, gpointer data) {
        return FALSE;
 }
 
+static void summary_find_answers (SummaryView *summaryview, MsgInfo *msg)
+{
+       FolderItem *sent_folder = NULL;
+       PrefsAccount *account = NULL;
+       char *buf = NULL;
+       if (msg == NULL || msg->msgid == NULL)
+               return;
+       
+       account = account_get_reply_account(msg, prefs_common.reply_account_autosel);
+       if (account == NULL) 
+               return;
+       sent_folder = account_get_special_folder
+                               (account, F_OUTBOX);
+       
+       buf = g_strdup_printf("I %s", msg->msgid);
+
+       /*if (summaryview->folder_item->prefs->save_copy_to_folder)
+               sent_folder = summaryview->folder_item;
+       
+       if (sent_folder == NULL && prefs_common.reply_account_autosel)
+               sent_folder = account_get_special_folder(
+                       account_find_from_address(msg->to), F_OUTBOX);
+       
+       if (sent_folder == NULL)
+               sent_folder = account_get_special_folder(
+                                       summaryview->folder_item->folder->account, F_OUTBOX);
+       
+       if (sent_folder == NULL) {
+               debug_print("Can't find outgoing folder :(\n");
+               return;
+       }*/
+       
+       if (sent_folder != summaryview->folder_item) {
+               folderview_select(summaryview->mainwin->folderview, sent_folder);
+       }
+       
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(summaryview->toggle_search), TRUE);
+       gtk_entry_set_text(GTK_ENTRY(summaryview->search_string), buf);
+       g_free(buf);
+       summary_show(summaryview, summaryview->folder_item);
+}