[Commits] [SCM] claws branch, master, updated. 3.17.0-62-g5d3761f

Colin colin at claws-mail.org
Fri Sep 28 10:34:54 CEST 2018


The branch, master has been updated
       via  5d3761fe8f2dafd4eb30fd9322b00f5e6bdbaf4f (commit)
       via  d15c76ad8978cea678fe5a262b558e6eda2753be (commit)
      from  029c9c58d48e7784950e252e9b4f2e30dc9c9aef (commit)

Summary of changes:
 src/compose.c     |   18 +++++++++----
 src/mainwindow.c  |    8 +++++-
 src/messageview.c |    4 +--
 src/summaryview.c |   74 ++++++++++++++++++++++++++++++++++++++++++++---------
 src/summaryview.h |    5 +++-
 src/toolbar.c     |    9 ++++++-
 6 files changed, 96 insertions(+), 22 deletions(-)


- Log -----------------------------------------------------------------
commit 5d3761fe8f2dafd4eb30fd9322b00f5e6bdbaf4f
Author: Colin Leroy <colin at colino.net>
Date:   Fri Sep 28 10:33:20 2018 +0200

    Fix bug #3889.
    * Fix right-click replying to messages in summaryview
    * Fix corner-case when selected and opened messages are different,
      and one of them is to a mailing-list.

diff --git a/src/compose.c b/src/compose.c
index 7aaa2b8..1aa2dc4 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -12150,11 +12150,9 @@ static void compose_reply_from_messageview_real(MessageView *msgview, GSList *ms
 	Compose *compose = NULL;
 	gchar *s_system = NULL;
 
-	cm_return_if_fail(msgview != NULL);
-
 	cm_return_if_fail(msginfo_list != NULL);
 
-	if (g_slist_length(msginfo_list) == 1 && !opening_multiple) {
+	if (g_slist_length(msginfo_list) == 1 && !opening_multiple && msgview != NULL) {
 		MimeInfo *mimeinfo = messageview_get_selected_mime_part(msgview);
 		MsgInfo *orig_msginfo = (MsgInfo *)msginfo_list->data;
 
@@ -12179,7 +12177,7 @@ static void compose_reply_from_messageview_real(MessageView *msgview, GSList *ms
 		}
 	}
 
-	if (!opening_multiple)
+	if (!opening_multiple && msgview != NULL)
 		body = messageview_get_selection(msgview);
 
 	if (new_msglist) {
@@ -12205,6 +12203,7 @@ void compose_reply_from_messageview(MessageView *msgview, GSList *msginfo_list,
 				    guint action)
 {
 	if ((!prefs_common.forward_as_attachment || action != COMPOSE_FORWARD) 
+	&&  msginfo_list != NULL
 	&&  action != COMPOSE_FORWARD_AS_ATTACH && g_slist_length(msginfo_list) > 1) {
 		GSList *cur = msginfo_list;
 		gchar *msg = g_strdup_printf(_("You are about to reply to %d "
@@ -12232,7 +12231,16 @@ void compose_reply_from_messageview(MessageView *msgview, GSList *msginfo_list,
 	} else {
 		/* forwarding multiple mails as attachments is done via a
 		 * single compose window */
-		compose_reply_from_messageview_real(msgview, msginfo_list, action, FALSE);
+		if (msginfo_list != NULL) {
+			compose_reply_from_messageview_real(msgview, msginfo_list, action, FALSE);
+		} else if (msgview != NULL) {
+			GSList tmplist;
+			tmplist.data = msgview->msginfo;
+			tmplist.next = NULL;
+			compose_reply_from_messageview_real(msgview, &tmplist, action, FALSE);
+		} else {
+			debug_print("Nothing to reply to\n");
+		}
 	}
 }
 
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 40fe077..930c71e 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -4120,7 +4120,13 @@ static void main_window_reply_cb(GtkAction *gaction, gpointer data)
 
 	msginfo_list = summary_get_selection(mainwin->summaryview);
 	cm_return_if_fail(msginfo_list != NULL);
-	compose_reply_from_messageview(msgview, msginfo_list, action);
+
+	if (summary_is_opened_message_selected(mainwin->summaryview)) {
+		compose_reply_from_messageview(msgview, msginfo_list, action);
+	} else {
+		compose_reply_from_messageview(msgview, NULL, action);
+	}
+
 	g_slist_free(msginfo_list);
 }
 
diff --git a/src/summaryview.c b/src/summaryview.c
index 0f7a6bd..522a126 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -418,16 +418,21 @@ GtkTargetEntry summary_drag_types[3] =
 	{"claws-mail/msg-path-list", 0, TARGET_MAIL_CM_PATH_LIST},
 };
 
-#define DO_ACTION(name, act) {						\
-	if(!strcmp(name, a_name)) {					\
-		act;							\
-	}								\
-}
+static void summary_reply_cb(GtkAction *gaction, gpointer data);
 
+/* Only submenus and specifically-handled menu entries here */
 static GtkActionEntry summary_popup_entries[] =
 {
 	{"SummaryViewPopup",                      NULL, "SummaryViewPopup", NULL, NULL, NULL },
+	{"SummaryViewPopup/Reply",                NULL, N_("_Reply"), NULL, NULL, G_CALLBACK(summary_reply_cb) }, /* COMPOSE_REPLY */
 	{"SummaryViewPopup/ReplyTo",              NULL, N_("Repl_y to"), NULL, NULL, NULL },
+	{"SummaryViewPopup/ReplyTo/All",          NULL, N_("_All"), NULL, NULL, G_CALLBACK(summary_reply_cb) }, /* COMPOSE_REPLY_TO_ALL */
+	{"SummaryViewPopup/ReplyTo/Sender",       NULL, N_("_Sender"), NULL, NULL, G_CALLBACK(summary_reply_cb) }, /* COMPOSE_REPLY_TO_SENDER */
+	{"SummaryViewPopup/ReplyTo/List",         NULL, N_("Mailing _list"), NULL, NULL, G_CALLBACK(summary_reply_cb) }, /* COMPOSE_REPLY_TO_LIST */
+
+	{"SummaryViewPopup/Forward",              NULL, N_("_Forward"), NULL, NULL, G_CALLBACK(summary_reply_cb) }, /* COMPOSE_FORWARD_INLINE */
+	{"SummaryViewPopup/ForwardAtt",           NULL, N_("For_ward as attachment"), NULL, NULL, G_CALLBACK(summary_reply_cb) }, /* COMPOSE_FORWARD_AS_ATTACH */
+	{"SummaryViewPopup/Redirect",             NULL, N_("Redirec_t"), NULL, NULL, G_CALLBACK(summary_reply_cb) }, /* COMPOSE_REDIRECT */
 	{"SummaryViewPopup/Mark",                 NULL, N_("_Mark"), NULL, NULL, NULL },
 	{"SummaryViewPopup/ColorLabel",           NULL, N_("Color la_bel"), NULL, NULL, NULL },
 	{"SummaryViewPopup/Tags",                 NULL, N_("Ta_gs"), NULL, NULL, NULL },
@@ -659,17 +664,21 @@ SummaryView *summary_create(MainWindow *mainwin)
 	gtk_action_group_add_actions(mainwin->action_group, summary_popup_entries,
 			G_N_ELEMENTS(summary_popup_entries), (gpointer)summaryview);
 
+	summaryview->ui_manager = gtk_ui_manager_new();
+	summaryview->action_group = cm_menu_create_action_group_full(summaryview->ui_manager,"Menu", summary_popup_entries,
+			G_N_ELEMENTS(summary_popup_entries), (gpointer)summaryview);
+
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/", "Menus", "Menus", GTK_UI_MANAGER_MENUBAR)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus", "SummaryViewPopup", "SummaryViewPopup", GTK_UI_MANAGER_MENU)
-	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Reply", "Message/Reply", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Reply", "SummaryViewPopup/Reply", GTK_UI_MANAGER_MENUITEM)
 #ifndef GENERIC_UMPC
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "ReplyTo", "SummaryViewPopup/ReplyTo", GTK_UI_MANAGER_MENU)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Separator1", "Message/---", GTK_UI_MANAGER_SEPARATOR)
 #endif
-	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Forward", "Message/Forward", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Forward", "SummaryViewPopup/Forward", GTK_UI_MANAGER_MENUITEM)
 #ifndef GENERIC_UMPC
-	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "ForwardAtt", "Message/ForwardAtt", GTK_UI_MANAGER_MENUITEM)
-	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Redirect", "Message/Redirect", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "ForwardAtt", "SummaryViewPopup/ForwardAtt", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Redirect", "SummaryViewPopup/Redirect", GTK_UI_MANAGER_MENUITEM)
 #endif
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Separator2", "Message/---", GTK_UI_MANAGER_SEPARATOR)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Move", "Message/Move", GTK_UI_MANAGER_MENUITEM)
@@ -701,9 +710,9 @@ SummaryView *summary_create(MainWindow *mainwin)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Separator6", "File/---", GTK_UI_MANAGER_SEPARATOR)
 
 	/* submenus - replyto */
-	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup/ReplyTo", "All", "Message/ReplyTo/All", GTK_UI_MANAGER_MENUITEM)
-	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup/ReplyTo", "Sender", "Message/ReplyTo/Sender", GTK_UI_MANAGER_MENUITEM)
-	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup/ReplyTo", "MailingList", "Message/ReplyTo/List", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup/ReplyTo", "All", "SummaryViewPopup/ReplyTo/All", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup/ReplyTo", "Sender", "SummaryViewPopup/ReplyTo/Sender", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup/ReplyTo", "MailingList", "SummaryViewPopup/ReplyTo/List", GTK_UI_MANAGER_MENUITEM)
 
 	/* submenus - mark */
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup/Mark", "Mark", "Message/Mark/Mark", GTK_UI_MANAGER_MENUITEM)
@@ -8398,3 +8407,44 @@ void summaryview_unlock(SummaryView *summaryview, FolderItem *item)
 {
 	gtk_widget_set_sensitive(summaryview->ctree, TRUE);
 }
+
+#define DO_ACTION(name, act)	{ if (!strcmp(a_name, name)) action = act; }
+static void summary_reply_cb(GtkAction *gaction, gpointer data)
+{
+	SummaryView *summaryview = (SummaryView *)data;
+	GSList *msginfo_list = NULL;
+	gint action = COMPOSE_REPLY;
+	const gchar *a_name = gtk_action_get_name(gaction);
+
+	DO_ACTION("SummaryViewPopup/Reply", COMPOSE_REPLY);
+	DO_ACTION("SummaryViewPopup/ReplyTo/All", COMPOSE_REPLY_TO_ALL);
+	DO_ACTION("SummaryViewPopup/ReplyTo/Sender", COMPOSE_REPLY_TO_SENDER);
+	DO_ACTION("SummaryViewPopup/ReplyTo/List", COMPOSE_REPLY_TO_LIST);
+	DO_ACTION("SummaryViewPopup/Forward", COMPOSE_FORWARD_INLINE);
+	DO_ACTION("SummaryViewPopup/ForwardAtt", COMPOSE_FORWARD_AS_ATTACH);
+	DO_ACTION("SummaryViewPopup/Redirect", COMPOSE_REDIRECT);
+
+	msginfo_list = summary_get_selection(summaryview);
+	cm_return_if_fail(msginfo_list != NULL);
+	compose_reply_from_messageview(NULL, msginfo_list, action);
+	g_slist_free(msginfo_list);
+}
+
+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(sel != NULL, FALSE);
+
+	for ( ; sel != NULL; sel = sel->next) {
+		if (summaryview->displayed == GTK_CMCTREE_NODE(sel->data)) {
+			return TRUE;
+		}
+	}
+	return FALSE;
+}
+
diff --git a/src/summaryview.h b/src/summaryview.h
index 258672c..e00f133 100644
--- a/src/summaryview.h
+++ b/src/summaryview.h
@@ -110,7 +110,6 @@ struct _SummaryView
 	GtkWidget *popupmenu;
 	GtkWidget *colorlabel_menu;
 	GtkWidget *tags_menu;
-
 	GtkWidget *window;
 
 	GtkCMCTreeNode *selected;
@@ -174,6 +173,9 @@ private:
 	FolderItem *search_root_folder;
 
 	guint mark_as_read_timeout_tag;
+
+	GtkActionGroup *action_group;
+	GtkUIManager *ui_manager;
 };
 
 SummaryView	*summary_create(MainWindow *mainwin);
@@ -333,4 +335,5 @@ void summary_relayout(SummaryView *summaryview);
 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);
 #endif /* __SUMMARY_H__ */
diff --git a/src/toolbar.c b/src/toolbar.c
index 15b05b5..9fcb7ea 100644
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -2966,6 +2966,7 @@ static void toolbar_reply(gpointer data, guint action)
 	MainWindow *mainwin;
 	MessageView *msgview;
 	GSList *msginfo_list = NULL;
+	gboolean msg_is_selected = FALSE;
 
 	cm_return_if_fail(toolbar_item != NULL);
 
@@ -2974,11 +2975,13 @@ static void toolbar_reply(gpointer data, guint action)
 		mainwin = (MainWindow*)toolbar_item->parent;
 		msginfo_list = summary_get_selection(mainwin->summaryview);
 		msgview = (MessageView*)mainwin->messageview;
+		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 = TRUE;
 		break;
 	default:
 		return;
@@ -2986,7 +2989,11 @@ static void toolbar_reply(gpointer data, guint action)
 
 	cm_return_if_fail(msgview != NULL);
 	cm_return_if_fail(msginfo_list != NULL);
-	compose_reply_from_messageview(msgview, msginfo_list, action);
+	if (msg_is_selected) {
+		compose_reply_from_messageview(msgview, msginfo_list, action);
+	} else {
+		compose_reply_from_messageview(msgview, NULL, action);
+	}
 	g_slist_free(msginfo_list);
 
 	/* TODO: update reply state ion summaryview */

commit d15c76ad8978cea678fe5a262b558e6eda2753be
Author: Colin Leroy <colin at colino.net>
Date:   Fri Sep 28 10:29:27 2018 +0200

    Fix possible null-dereference (thanks Coverity)

diff --git a/src/messageview.c b/src/messageview.c
index a87c2c2..6a73c63 100644
--- a/src/messageview.c
+++ b/src/messageview.c
@@ -1269,8 +1269,8 @@ static gboolean messageview_try_select_mimeinfo(MessageView *messageview, MsgInf
 			return TRUE;
 		} else if (!strcasecmp(mimeinfo->subtype, "html")
 				&& mimeinfo->disposition != DISPOSITIONTYPE_ATTACHMENT
-				&& (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS
-					|| (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT
+				&& ((msginfo->folder && msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS)
+					|| ((msginfo->folder && msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT)
 						&& prefs_common.promote_html_part))) {
 			mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
 			return TRUE;

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list