Fix Reply from mainwindow menu and toolbar when mainwindow's
authorColin Leroy <colin@colino.net>
Wed, 3 Oct 2018 07:15:30 +0000 (09:15 +0200)
committerColin Leroy <colin@colino.net>
Wed, 3 Oct 2018 07:15:30 +0000 (09:15 +0200)
messageview is hidden.

src/mainwindow.c
src/summaryview.c
src/summaryview.h
src/toolbar.c

index 930c71e..30376f0 100644 (file)
@@ -4121,7 +4121,9 @@ static void main_window_reply_cb(GtkAction *gaction, gpointer data)
        msginfo_list = summary_get_selection(mainwin->summaryview);
        cm_return_if_fail(msginfo_list != NULL);
 
        msginfo_list = summary_get_selection(mainwin->summaryview);
        cm_return_if_fail(msginfo_list != NULL);
 
-       if (summary_is_opened_message_selected(mainwin->summaryview)) {
+       if (!summary_has_opened_message(mainwin->summaryview)) {
+               compose_reply_from_messageview(NULL, msginfo_list, action);
+       } else if (summary_is_opened_message_selected(mainwin->summaryview)) {
                compose_reply_from_messageview(msgview, msginfo_list, action);
        } else {
                compose_reply_from_messageview(msgview, NULL, action);
                compose_reply_from_messageview(msgview, msginfo_list, action);
        } else {
                compose_reply_from_messageview(msgview, NULL, action);
index 522a126..8fe0484 100644 (file)
@@ -8433,12 +8433,14 @@ static void summary_reply_cb(GtkAction *gaction, gpointer data)
 gboolean summary_is_opened_message_selected(SummaryView *summaryview)
 {
        GList *sel = NULL;
 gboolean summary_is_opened_message_selected(SummaryView *summaryview)
 {
        GList *sel = NULL;
-       
+
        cm_return_val_if_fail(summaryview != NULL, FALSE);
 
        sel = GTK_CMCLIST(summaryview->ctree)->selection;
 
        cm_return_val_if_fail(summaryview != NULL, FALSE);
 
        sel = GTK_CMCLIST(summaryview->ctree)->selection;
 
-       cm_return_val_if_fail(sel != NULL, FALSE);
+       if (summaryview->displayed == NULL || sel == NULL) {
+               return FALSE;
+       }
 
        for ( ; sel != NULL; sel = sel->next) {
                if (summaryview->displayed == GTK_CMCTREE_NODE(sel->data)) {
 
        for ( ; sel != NULL; sel = sel->next) {
                if (summaryview->displayed == GTK_CMCTREE_NODE(sel->data)) {
@@ -8448,3 +8450,14 @@ gboolean summary_is_opened_message_selected(SummaryView *summaryview)
        return FALSE;
 }
 
        return FALSE;
 }
 
+gboolean summary_has_opened_message(SummaryView *summaryview)
+{
+       GList *sel = NULL;
+
+       cm_return_val_if_fail(summaryview != NULL, FALSE);
+
+       sel = GTK_CMCLIST(summaryview->ctree)->selection;
+
+       return (summaryview->displayed != NULL);
+}
+
index e00f133..5824761 100644 (file)
@@ -336,4 +336,5 @@ void summary_update_unread(SummaryView *summaryview, FolderItem *removed_item);
 gboolean summary_is_list(SummaryView *summaryview);
 gboolean summaryview_search_root_progress(gpointer data, guint at, guint matched, guint total);
 gboolean summary_is_opened_message_selected(SummaryView *summaryview);
 gboolean summary_is_list(SummaryView *summaryview);
 gboolean summaryview_search_root_progress(gpointer data, guint at, guint matched, guint total);
 gboolean summary_is_opened_message_selected(SummaryView *summaryview);
+gboolean summary_has_opened_message(SummaryView *summaryview);
 #endif /* __SUMMARY_H__ */
 #endif /* __SUMMARY_H__ */
index 9fcb7ea..4c16c47 100644 (file)
@@ -2967,6 +2967,7 @@ static void toolbar_reply(gpointer data, guint action)
        MessageView *msgview;
        GSList *msginfo_list = NULL;
        gboolean msg_is_selected = FALSE;
        MessageView *msgview;
        GSList *msginfo_list = NULL;
        gboolean msg_is_selected = FALSE;
+       gboolean msg_is_opened = FALSE;
 
        cm_return_if_fail(toolbar_item != NULL);
 
 
        cm_return_if_fail(toolbar_item != NULL);
 
@@ -2975,12 +2976,14 @@ static void toolbar_reply(gpointer data, guint action)
                mainwin = (MainWindow*)toolbar_item->parent;
                msginfo_list = summary_get_selection(mainwin->summaryview);
                msgview = (MessageView*)mainwin->messageview;
                mainwin = (MainWindow*)toolbar_item->parent;
                msginfo_list = summary_get_selection(mainwin->summaryview);
                msgview = (MessageView*)mainwin->messageview;
+               msg_is_opened = summary_has_opened_message(mainwin->summaryview);
                msg_is_selected = summary_is_opened_message_selected(mainwin->summaryview);
                break;
        case TOOLBAR_MSGVIEW:
                msgview = (MessageView*)toolbar_item->parent;
                cm_return_if_fail(msgview != NULL);     
                msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
                msg_is_selected = summary_is_opened_message_selected(mainwin->summaryview);
                break;
        case TOOLBAR_MSGVIEW:
                msgview = (MessageView*)toolbar_item->parent;
                cm_return_if_fail(msgview != NULL);     
                msginfo_list = g_slist_append(msginfo_list, msgview->msginfo);
+               msg_is_opened = TRUE;
                msg_is_selected = TRUE;
                break;
        default:
                msg_is_selected = TRUE;
                break;
        default:
@@ -2989,7 +2992,9 @@ static void toolbar_reply(gpointer data, guint action)
 
        cm_return_if_fail(msgview != NULL);
        cm_return_if_fail(msginfo_list != NULL);
 
        cm_return_if_fail(msgview != NULL);
        cm_return_if_fail(msginfo_list != NULL);
-       if (msg_is_selected) {
+       if (!msg_is_opened) {
+               compose_reply_from_messageview(NULL, msginfo_list, action);
+       } else if (msg_is_selected) {
                compose_reply_from_messageview(msgview, msginfo_list, action);
        } else {
                compose_reply_from_messageview(msgview, NULL, action);
                compose_reply_from_messageview(msgview, msginfo_list, action);
        } else {
                compose_reply_from_messageview(msgview, NULL, action);