[Commits] main.c 1.115.2.246 1.115.2.247 mainwindow.c 1.274.2.342 1.274.2.343 messageview.c 1.94.2.226 1.94.2.227 messageview.h 1.19.2.27 1.19.2.28 prefs_common.c 1.204.2.207 1.204.2.208 prefs_common.h 1.103.2.136 1.103.2.137 procmsg.c 1.150.2.121 1.150.2.122 procmsg.h 1.60.2.58 1.60.2.59 summaryview.c 1.395.2.443 1.395.2.444 summaryview.h 1.68.2.58 1.68.2.59

colin at claws-mail.org colin at claws-mail.org
Sun Feb 5 21:00:38 CET 2012


Update of /home/claws-mail/claws/src
In directory srv:/tmp/cvs-serv23686/src

Modified Files:
      Tag: gtk2
	main.c mainwindow.c messageview.c messageview.h prefs_common.c 
	prefs_common.h procmsg.c procmsg.h summaryview.c summaryview.h 
Log Message:
2012-02-05 [colin]	3.8.0cvs26

	* src/main.c
	* src/mainwindow.c
	* src/messageview.c
	* src/messageview.h
	* src/prefs_common.c
	* src/prefs_common.h
	* src/procmsg.c
	* src/procmsg.h
	* src/summaryview.c
	* src/summaryview.h
		Add an history to navigate in mails

Index: summaryview.h
===================================================================
RCS file: /home/claws-mail/claws/src/summaryview.h,v
retrieving revision 1.68.2.58
retrieving revision 1.68.2.59
diff -u -d -r1.68.2.58 -r1.68.2.59
--- summaryview.h	19 Nov 2011 15:14:01 -0000	1.68.2.58
+++ summaryview.h	5 Feb 2012 20:00:36 -0000	1.68.2.59
@@ -115,7 +115,6 @@
 
 	GtkCMCTreeNode *selected;
 	GtkCMCTreeNode *displayed;
-	GtkCMCTreeNode *last_displayed;
 
 	gboolean display_msg;
 
@@ -204,10 +203,11 @@
 void summary_select_next_marked	  (SummaryView		*summaryview);
 void summary_select_prev_labeled  (SummaryView		*summaryview);
 void summary_select_next_labeled  (SummaryView		*summaryview);
-void summary_select_last_read     (SummaryView		*summaryview);
 void summary_select_parent        (SummaryView		*summaryview);
 void summary_select_by_msgnum	  (SummaryView		*summaryview,
 				   guint		 msgnum);
+void summary_display_by_msgnum	  (SummaryView		*summaryview,
+				   guint		 msgnum);
 void summary_select_by_msg_list   (SummaryView		*summaryview, GSList *msginfos);
 guint summary_get_current_msgnum  (SummaryView		*summaryview);
 void summary_select_node	  (SummaryView		*summaryview,

Index: procmsg.h
===================================================================
RCS file: /home/claws-mail/claws/src/procmsg.h,v
retrieving revision 1.60.2.58
retrieving revision 1.60.2.59
diff -u -d -r1.60.2.58 -r1.60.2.59
--- procmsg.h	2 Feb 2012 16:12:16 -0000	1.60.2.58
+++ procmsg.h	5 Feb 2012 20:00:35 -0000	1.60.2.59
@@ -401,4 +401,6 @@
 void procmsg_msginfo_update_tags(MsgInfo *msginfo, gboolean set, gint id);
 void procmsg_msginfo_clear_tags(MsgInfo *msginfo);
 void procmsg_msginfo_commit_tags(GSList *msglist);
+MsgInfo *procmsg_get_msginfo_from_identifier(const gchar *id);
+gchar *procmsg_msginfo_get_identifier(MsgInfo *msginfo);
 #endif /* __PROCMSG_H__ */

Index: prefs_common.c
===================================================================
RCS file: /home/claws-mail/claws/src/prefs_common.c,v
retrieving revision 1.204.2.207
retrieving revision 1.204.2.208
diff -u -d -r1.204.2.207 -r1.204.2.208
--- prefs_common.c	19 Nov 2011 17:47:47 -0000	1.204.2.207
+++ prefs_common.c	5 Feb 2012 20:00:35 -0000	1.204.2.208
@@ -1165,6 +1165,9 @@
 	{"flush_metadata", "TRUE", &prefs_common.flush_metadata, P_BOOL,
 	 NULL, NULL, NULL},
 
+	{"nav_history_length", "50", &prefs_common.nav_history_length, P_INT,
+	 NULL, NULL, NULL},
+
 	{NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 

Index: summaryview.c
===================================================================
RCS file: /home/claws-mail/claws/src/summaryview.c,v
retrieving revision 1.395.2.443
retrieving revision 1.395.2.444
diff -u -d -r1.395.2.443 -r1.395.2.444
--- summaryview.c	9 Jan 2012 18:47:13 -0000	1.395.2.443
+++ summaryview.c	5 Feb 2012 20:00:35 -0000	1.395.2.444
@@ -1134,7 +1134,6 @@
 	if (!summaryview->mainwin)
 		return FALSE;
 	START_TIMING("");
-	summaryview->last_displayed = NULL;
 	summary_switch_from_to(summaryview, item);
 
 	inc_lock();
@@ -1383,7 +1382,6 @@
 
 	if (is_refresh) {
 		if (!quicksearch_is_in_typing(summaryview->quicksearch)) {
-			summaryview->last_displayed = summaryview->displayed;
 			summaryview->displayed =
 				summary_find_msg_by_msgnum(summaryview,
 							   displayed_msgnum);
@@ -2044,12 +2042,6 @@
 		summary_select_node(summaryview, node, TRUE, FALSE);
 }
 
-void summary_select_last_read(SummaryView *summaryview)
-{
-	if (summaryview->last_displayed)
-		summary_select_node(summaryview, summaryview->last_displayed, TRUE, FALSE);
-}
-
 void summary_select_parent(SummaryView *summaryview)
 {
 	GtkCMCTreeNode *node = NULL;
@@ -2068,6 +2060,14 @@
 	summary_select_node(summaryview, node, FALSE, TRUE);
 }
 
+void summary_display_by_msgnum(SummaryView *summaryview, guint msgnum)
+{
+	GtkCMCTreeNode *node;
+
+	node = summary_find_msg_by_msgnum(summaryview, msgnum);
+	summary_select_node(summaryview, node, TRUE, FALSE);
+}
+
 void summary_select_by_msg_list(SummaryView	*summaryview, GSList *msginfos)
 {
 	GtkCMCTree *ctree;
@@ -3502,7 +3502,6 @@
 			else
 				gtkut_window_popup(summaryview->ext_messageview->window);
 			msgview = summaryview->ext_messageview;
-			summaryview->last_displayed = summaryview->displayed;
 			summaryview->displayed = row;
 			val = messageview_show(msgview, msginfo, all_headers);
 			if (mimeview_tree_is_empty(msgview->mimeview))
@@ -3511,7 +3510,6 @@
 				GTK_CMCLIST(summaryview->ctree)->focus_row);
 		} else {
 			msgview = summaryview->messageview;
-			summaryview->last_displayed = summaryview->displayed;
 			summaryview->displayed = row;
 			if (!messageview_is_visible(msgview) &&
 			    gtk_window_is_active(GTK_WINDOW(summaryview->mainwin->window))) {
@@ -6518,7 +6516,6 @@
 
 	summaryview->selected = summary_find_msg_by_msgnum(summaryview, selected_msgnum);
 	summaryview->displayed = summary_find_msg_by_msgnum(summaryview, displayed_msgnum);
-	summaryview->last_displayed = summaryview->displayed;
 	if (!summaryview->displayed)
 		messageview_clear(summaryview->messageview);
 	else

Index: prefs_common.h
===================================================================
RCS file: /home/claws-mail/claws/src/prefs_common.h,v
retrieving revision 1.103.2.136
retrieving revision 1.103.2.137
diff -u -d -r1.103.2.136 -r1.103.2.137
--- prefs_common.h	19 Nov 2011 17:47:47 -0000	1.103.2.136
+++ prefs_common.h	5 Feb 2012 20:00:35 -0000	1.103.2.137
@@ -519,6 +519,7 @@
 	gboolean inherit_folder_props;
 	gboolean flush_metadata;
 
+	gint nav_history_length;
 };
 
 extern PrefsCommon prefs_common;

Index: procmsg.c
===================================================================
RCS file: /home/claws-mail/claws/src/procmsg.c,v
retrieving revision 1.150.2.121
retrieving revision 1.150.2.122
diff -u -d -r1.150.2.121 -r1.150.2.122
--- procmsg.c	1 Feb 2012 18:26:54 -0000	1.150.2.121
+++ procmsg.c	5 Feb 2012 20:00:35 -0000	1.150.2.122
@@ -756,6 +756,52 @@
 	return mailac;
 }
 
+gchar *procmsg_msginfo_get_identifier(MsgInfo *msginfo)
+{
+	gchar *folder_id;
+	const gchar *msgid;
+	gchar *id;
+
+	cm_return_val_if_fail(msginfo != NULL, NULL);
+	folder_id = folder_item_get_identifier(msginfo->folder);
+	msgid = msginfo->msgid;
+
+	id = g_strconcat(folder_id, G_DIR_SEPARATOR_S, msgid, NULL);
+
+	g_free(folder_id);
+
+	return id;
+}
+
+MsgInfo *procmsg_get_msginfo_from_identifier(const gchar *id)
+{
+	gchar *folder_id = g_strdup(id);
+	gchar *separator = strrchr(folder_id, G_DIR_SEPARATOR);
+	const gchar *msgid;
+	FolderItem *item;
+	MsgInfo *msginfo;
+
+	if (separator == NULL) {
+		g_free(folder_id);
+		return NULL;
+	}
+
+	*separator = '\0';
+	msgid = separator + 1;
+
+	item = folder_find_item_from_identifier(folder_id);
+
+	if (item == NULL) {
+		g_free(folder_id);
+		return NULL;
+	}
+
+	msginfo = folder_item_get_msginfo_by_msgid(item, msgid);
+	g_free(folder_id);
+
+	return msginfo;
+}
+
 static GSList *procmsg_list_sort_by_account(FolderItem *queue, GSList *list)
 {
 	GSList *result = NULL;

Index: messageview.h
===================================================================
RCS file: /home/claws-mail/claws/src/messageview.h,v
retrieving revision 1.19.2.27
retrieving revision 1.19.2.28
diff -u -d -r1.19.2.27 -r1.19.2.28
--- messageview.h	2 Feb 2012 16:12:16 -0000	1.19.2.27
+++ messageview.h	5 Feb 2012 20:00:35 -0000	1.19.2.28
@@ -82,6 +82,8 @@
 	gboolean show_full_text;
 	gboolean partial_display_shown;
 	GtkUIManager *ui_manager;
+	GList *trail;
+	gint trail_pos;
 };
 
 MessageView *messageview_create			(MainWindow	*mainwin);
@@ -128,4 +130,9 @@
 void messageview_show_partial_display		(MessageView 	*msgview, 
 						 MsgInfo 	*msginfo,
 						 size_t 	 length);
+gboolean messageview_nav_has_prev(MessageView *messageview);
+gboolean messageview_nav_has_next(MessageView *messageview);
+MsgInfo *messageview_nav_get_prev(MessageView *messageview);
+MsgInfo *messageview_nav_get_next(MessageView *messageview);
+
 #endif /* __MESSAGEVIEW_H__ */

Index: mainwindow.c
===================================================================
RCS file: /home/claws-mail/claws/src/mainwindow.c,v
retrieving revision 1.274.2.342
retrieving revision 1.274.2.343
diff -u -d -r1.274.2.342 -r1.274.2.343
--- mainwindow.c	2 Feb 2012 21:49:41 -0000	1.274.2.342
+++ mainwindow.c	5 Feb 2012 20:00:35 -0000	1.274.2.343
@@ -306,7 +306,9 @@
 				  gpointer	 data);
 static void next_labeled_cb	 (GtkAction	*action,
 				  gpointer	 data);
-static void last_read_cb	 (GtkAction	*action,
+static void prev_history_cb	 (GtkAction	*action,
+				  gpointer	 data);
+static void next_history_cb	 (GtkAction	*action,
 				  gpointer	 data);
 static void parent_cb		 (GtkAction	*action,
 				  gpointer	 data);
@@ -557,7 +559,9 @@
 	{"View/Goto/PrevLabeled",		NULL, N_("Previous _labeled message"), NULL, NULL, G_CALLBACK(prev_labeled_cb) },
 	{"View/Goto/NextLabeled",		NULL, N_("Next la_beled message"), NULL, NULL, G_CALLBACK(next_labeled_cb) },
 	/* {"View/Goto/---",			NULL, "---", NULL, NULL, NULL }, */
-	{"View/Goto/LastRead",			NULL, N_("Last read message"), NULL, NULL, G_CALLBACK(last_read_cb) },
+	{"View/Goto/PrevHistory",		NULL, N_("Previous opened message"), "<alt>Left", NULL, G_CALLBACK(prev_history_cb) },
+	{"View/Goto/NextHistory",		NULL, N_("Next opened message"), "<alt>Right", NULL, G_CALLBACK(next_history_cb) },
+	/* {"View/Goto/---",			NULL, "---", NULL, NULL, NULL }, */
 	{"View/Goto/ParentMessage",		NULL, N_("Parent message"), "<control>Up", NULL, G_CALLBACK(parent_cb) },
 	/* {"View/Goto/---",			NULL, "---", NULL, NULL, NULL }, */
 	{"View/Goto/NextUnreadFolder",		NULL, N_("Next unread _folder"), "<shift>G", NULL, G_CALLBACK(goto_unread_folder_cb) },
@@ -1020,7 +1024,6 @@
 	for (; sel != NULL; sel = sel->next) {
 		MsgInfo *msginfo;
 		GSList *tags = NULL;
-		gint id;
 		GtkCheckMenuItem *item;
 		msginfo = (MsgInfo *)sel->data;
 		sel_len++;
@@ -1031,7 +1034,6 @@
 
 			for (; tags; tags = tags->next) {
 				gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, tags->data));
-				id = GPOINTER_TO_INT(tags->data);
 				item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
 				if (item && !gtk_check_menu_item_get_active(item)) {
 					gtk_check_menu_item_set_active
@@ -1742,9 +1744,11 @@
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevLabeled", "View/Goto/PrevLabeled", GTK_UI_MANAGER_MENUITEM)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextLabeled", "View/Goto/NextLabeled", GTK_UI_MANAGER_MENUITEM)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator5", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
-	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "LastRead", "View/Goto/LastRead", GTK_UI_MANAGER_MENUITEM)
-	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "PrevHistory", "View/Goto/PrevHistory", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextHistory", "View/Goto/NextHistory", GTK_UI_MANAGER_MENUITEM)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator6", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "Separator7", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "NextUnreadFolder", "View/Goto/NextUnreadFolder", GTK_UI_MANAGER_MENUITEM)
 	MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Goto", "OtherFolder", "View/Goto/OtherFolder", GTK_UI_MANAGER_MENUITEM)
         MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Scroll", "View/Scroll", GTK_UI_MANAGER_MENU)
@@ -3236,7 +3240,6 @@
 		{"Menu/View/Goto/PrevMarked" , M_MSG_EXIST},
 		{"Menu/View/Goto/PrevLabeled", M_MSG_EXIST},
 		{"Menu/View/Goto/NextLabeled", M_MSG_EXIST},
-		{"Menu/View/Goto/LastRead"   , M_SINGLE_TARGET_EXIST},
 		{"Menu/View/Goto/ParentMessage"      , M_SINGLE_TARGET_EXIST},
 		{"Menu/View/OpenNewWindow"        , M_SINGLE_TARGET_EXIST},
 		{"Menu/View/MessageSource"            , M_SINGLE_TARGET_EXIST},
@@ -3400,7 +3403,12 @@
 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadThreads", FALSE);
 	if (mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_threads)
 		cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadMessages", FALSE);
-		
+
+	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Goto/PrevHistory",
+		messageview_nav_has_prev(mainwin->messageview));
+	cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/Goto/NextHistory",
+		messageview_nav_has_next(mainwin->messageview));
+
 	main_window_menu_callback_unblock(mainwin);
 }
 
@@ -3896,7 +3904,7 @@
 {
 	while (mainwin_list != NULL) {
 		MainWindow *mainwin = (MainWindow*)mainwin_list->data;
-		
+
 		/* free toolbar stuff */
 		toolbar_clear_list(TOOLBAR_MAIN);
 		TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
@@ -4818,10 +4826,33 @@
 	summary_select_next_labeled(mainwin->summaryview);
 }
 
-static void last_read_cb(GtkAction *action, gpointer data)
+static void prev_history_cb(GtkAction *action, gpointer data)
 {
 	MainWindow *mainwin = (MainWindow *)data;
-	summary_select_last_read(mainwin->summaryview);
+	MsgInfo *info = messageview_nav_get_prev(mainwin->messageview);
+	if (info) {
+		if (info->folder != mainwin->summaryview->folder_item)
+			folderview_select(mainwin->folderview, info->folder);
+		summary_display_by_msgnum(mainwin->summaryview, info->msgnum);
+		summary_display_msg_selected(mainwin->summaryview, FALSE);
+		procmsg_msginfo_free(info);
+		main_window_set_menu_sensitive(mainwindow_get_mainwindow());
+		toolbar_main_set_sensitive(mainwindow_get_mainwindow());
+	}
+}
+
+static void next_history_cb(GtkAction *action, gpointer data)
+{
+	MainWindow *mainwin = (MainWindow *)data;
+	MsgInfo *info = messageview_nav_get_next(mainwin->messageview);
+	if (info) {
+		if (info->folder != mainwin->summaryview->folder_item)
+			folderview_select(mainwin->folderview, info->folder);
+		summary_display_by_msgnum(mainwin->summaryview, info->msgnum);
+		procmsg_msginfo_free(info);
+		main_window_set_menu_sensitive(mainwindow_get_mainwindow());
+		toolbar_main_set_sensitive(mainwindow_get_mainwindow());
+	}
 }
 
 static void parent_cb(GtkAction *action, gpointer data)

Index: messageview.c
===================================================================
RCS file: /home/claws-mail/claws/src/messageview.c,v
retrieving revision 1.94.2.226
retrieving revision 1.94.2.227
diff -u -d -r1.94.2.226 -r1.94.2.227
--- messageview.c	2 Feb 2012 16:12:16 -0000	1.94.2.226
+++ messageview.c	5 Feb 2012 20:00:35 -0000	1.94.2.227
@@ -126,7 +126,9 @@
 					 gpointer	 data);
 static void next_labeled_cb		(GtkAction	*action,
 					 gpointer	 data);
-static void last_read_cb		(GtkAction	*action,
+static void prev_history_cb		(GtkAction	*action,
+					 gpointer	 data);
+static void next_history_cb		(GtkAction	*action,
 					 gpointer	 data);
 static void parent_cb			(GtkAction	*action,
 					 gpointer	 data);
@@ -227,8 +229,10 @@
 	/* {"View/Goto/---",		NULL, "---", NULL, NULL, NULL }, */
 	{"View/Goto/PrevLabeled",	NULL, N_("Previous _labeled message"), NULL, NULL, G_CALLBACK(prev_labeled_cb) },
 	{"View/Goto/NextLabeled",	NULL, N_("Next la_beled message"), NULL, NULL, G_CALLBACK(next_labeled_cb) },
+	/* {"View/Goto/---",			NULL, "---", NULL, NULL, NULL }, */
+	{"View/Goto/PrevHistory",	NULL, N_("Previous opened message"), "<alt>Left", NULL, G_CALLBACK(prev_history_cb) },
+	{"View/Goto/NextHistory",	NULL, N_("Next opened message"), "<alt>Right", NULL, G_CALLBACK(next_history_cb) },
 	/* {"View/Goto/---",		NULL, "---", NULL, NULL, NULL }, */
-	{"View/Goto/LastRead",		NULL, N_("Last read message"), NULL, NULL, G_CALLBACK(last_read_cb) },
 	{"View/Goto/ParentMessage",	NULL, N_("Parent message"), "<control>Up", NULL, G_CALLBACK(parent_cb) },
 	/* {"View/Goto/---",		NULL, "---", NULL, NULL, NULL }, */
 	{"View/Goto/NextUnreadFolder",	NULL, N_("Next unread _folder"), "<shift>G", NULL, G_CALLBACK(goto_unread_folder_cb) },
@@ -495,9 +499,11 @@
 	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "PrevLabeled", "View/Goto/PrevLabeled", GTK_UI_MANAGER_MENUITEM)
 	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "NextLabeled", "View/Goto/NextLabeled", GTK_UI_MANAGER_MENUITEM)
 	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "Separator5", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
-	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "LastRead", "View/Goto/LastRead", GTK_UI_MANAGER_MENUITEM)
-	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "PrevHistory", "View/Goto/PrevHistory", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "NextHistory", "View/Goto/NextHistory", GTK_UI_MANAGER_MENUITEM)
 	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "Separator6", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
+	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM)
+	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "Separator7", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
 	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "NextUnreadFolder", "View/Goto/NextUnreadFolder", GTK_UI_MANAGER_MENUITEM)
 	MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "OtherFolder", "View/Goto/OtherFolder", GTK_UI_MANAGER_MENUITEM)
 
@@ -1133,6 +1139,118 @@
 	return brokeninfo;
 }
 
+static void messageview_register_nav(MessageView *messageview)
+{
+	gchar *id;
+	gint pos = -1;
+	GList *existing;
+
+	cm_return_if_fail(messageview);
+	cm_return_if_fail(messageview->msginfo);
+
+	id = procmsg_msginfo_get_identifier(messageview->msginfo);
+	existing = g_list_find_custom(messageview->trail, id, (GCompareFunc)g_strcmp0);
+
+	if (existing != NULL)
+		pos = g_list_position(messageview->trail, existing);
+	else
+		pos = -1;
+
+	if (pos != -1) {
+		messageview->trail_pos = pos;
+		g_free(id);
+	} else {
+		/* Cut the end of the list */
+		GList *end = g_list_nth(messageview->trail, messageview->trail_pos + 1);
+		if (end) {
+			if (end->prev) {
+				end->prev->next = NULL;
+				end->prev = NULL;
+				list_free_strings(end);
+				g_list_free(end);
+			} else {
+				list_free_strings(messageview->trail);
+				g_list_free(messageview->trail);
+				messageview->trail = NULL;
+			}
+		}
+		messageview->trail = g_list_append(messageview->trail, id);
+		messageview->trail_pos = g_list_length(messageview->trail) - 1;
+		
+		/* Cut the beginning if needed */
+		while (messageview->trail_pos > prefs_common.nav_history_length) {
+			g_free(messageview->trail->data);
+			messageview->trail = g_list_delete_link(messageview->trail,
+						messageview->trail);
+			messageview->trail_pos--;
+		}
+	}
+	messageview_set_menu_sensitive(messageview);
+}
+
+gboolean messageview_nav_has_prev(MessageView *messageview) {
+	return messageview->trail != NULL &&  messageview->trail_pos > 0;
+}
+
+gboolean messageview_nav_has_next(MessageView *messageview) {
+	if (!messageview->trail)
+		return FALSE;
+	
+	return sc_g_list_bigger(messageview->trail, messageview->trail_pos + 1);
+}
+
+MsgInfo *messageview_nav_get_prev(MessageView *messageview) {
+	GList *item;
+	MsgInfo *info;
+
+	cm_return_val_if_fail(messageview, NULL);
+	cm_return_val_if_fail(messageview->trail, NULL);
+
+	do {
+		if (!messageview_nav_has_prev(messageview))
+			return NULL;
+
+		item = g_list_nth(messageview->trail, messageview->trail_pos - 1);
+		cm_return_val_if_fail(item != NULL, NULL);
+
+		info = procmsg_get_msginfo_from_identifier((const gchar *)item->data);
+		if (info != NULL)
+			break;
+
+		g_free(item->data);
+		messageview->trail = g_list_delete_link(messageview->trail, item);
+		if (messageview->trail_pos > 0)
+			messageview->trail_pos--;
+	} while (info == NULL);
+
+	return info;
+}
+
+MsgInfo *messageview_nav_get_next(MessageView *messageview) {
+	GList *item;
+	MsgInfo *info;
+
+	cm_return_val_if_fail(messageview, NULL);
+	cm_return_val_if_fail(messageview->trail, NULL);
+
+	do {
+		if (!messageview_nav_has_next(messageview))
+			return NULL;
+
+		item = g_list_nth(messageview->trail, messageview->trail_pos + 1);
+		cm_return_val_if_fail(item != NULL, NULL);
+
+		info = procmsg_get_msginfo_from_identifier((const gchar *)item->data);
+		if (info != NULL)
+			break;
+
+		g_free(item->data);
+		messageview->trail = g_list_delete_link(messageview->trail, item);
+	} while (info == NULL);
+	
+	return info;
+}
+
 gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
 		      gboolean all_headers)
 {
@@ -1244,6 +1362,7 @@
 	}
 	headerview_show(messageview->headerview, messageview->msginfo);
 
+	messageview_register_nav(messageview);
 	messageview_set_position(messageview, 0);
 
 #ifdef MAEMO
@@ -1489,7 +1608,9 @@
 		toolbar_destroy(messageview->toolbar);
 		g_free(messageview->toolbar);
 	}
-	
+
+	list_free_strings(messageview->trail);
+	g_list_free(messageview->trail);
 	msgview_list = g_list_remove(msgview_list, messageview); 
 
 	if (messageview->window)
@@ -2369,28 +2490,39 @@
 	}
 }
 
-static void last_read_cb(GtkAction *action, gpointer data)
+static void prev_history_cb(GtkAction *action, gpointer data)
 {
 	MessageView *messageview = (MessageView *)data;
-	messageview->updating = TRUE;
-	summary_select_last_read(messageview->mainwin->summaryview);
-	messageview->updating = FALSE;
-
-	if (messageview->deferred_destroy) {
-		debug_print("messageview got away!\n");
-		messageview_destroy(messageview);
-		return;
+	MsgInfo *info = messageview_nav_get_prev(messageview);
+	if (info) {
+		messageview->updating = TRUE;
+		messageview_show(messageview, info, 
+					 messageview->all_headers);
+		messageview->updating = FALSE;
+		procmsg_msginfo_free(info);
+		if (messageview->deferred_destroy) {
+			debug_print("messageview got away!\n");
+			messageview_destroy(messageview);
+			return;
+		}
 	}
-	if (messageview->mainwin->summaryview->selected) {
-#ifndef GENERIC_UMPC
-		MsgInfo * msginfo = summary_get_selected_msg(messageview->mainwin->summaryview);
-		       
-		if (msginfo)
-			messageview_show(messageview, msginfo, 
+}
+
+static void next_history_cb(GtkAction *action, gpointer data)
+{
+	MessageView *messageview = (MessageView *)data;
+	MsgInfo *info = messageview_nav_get_next(messageview);
+	if (info) {
+		messageview->updating = TRUE;
+		messageview_show(messageview, info, 
 					 messageview->all_headers);
-#endif
-	} else {
-		gtk_widget_destroy(messageview->window);
+		messageview->updating = FALSE;
+		procmsg_msginfo_free(info);
+		if (messageview->deferred_destroy) {
+			debug_print("messageview got away!\n");
+			messageview_destroy(messageview);
+			return;
+		}
 	}
 }
 
@@ -2792,6 +2924,8 @@
 	cm_toggle_menu_set_active_full(messageview->ui_manager, "Menu/View/Quotes/CollapseAll", (prefs_common.hide_quotes == 1));
 	cm_toggle_menu_set_active_full(messageview->ui_manager, "Menu/View/Quotes/Collapse2", (prefs_common.hide_quotes == 2));
 	cm_toggle_menu_set_active_full(messageview->ui_manager, "Menu/View/Quotes/Collapse3", (prefs_common.hide_quotes == 3));
+	cm_menu_set_sensitive_full(messageview->ui_manager, "Menu/View/Goto/PrevHistory", messageview_nav_has_prev(messageview));
+	cm_menu_set_sensitive_full(messageview->ui_manager, "Menu/View/Goto/NextHistory", messageview_nav_has_next(messageview));
 }
 
 void messageview_learn (MessageView *msgview, gboolean is_spam)

Index: main.c
===================================================================
RCS file: /home/claws-mail/claws/src/main.c,v
retrieving revision 1.115.2.246
retrieving revision 1.115.2.247
diff -u -d -r1.115.2.246 -r1.115.2.247
--- main.c	5 Jan 2012 11:09:00 -0000	1.115.2.246
+++ main.c	5 Feb 2012 20:00:35 -0000	1.115.2.247
@@ -2554,7 +2554,7 @@
 		if (folder_name)
 			folderItem = folder_find_item_from_identifier(folder_name);
 		if (folder_name && folderItem == NULL) {
-			debug_print("Unknow folder item : '%s', searching folder\n",folder_name);
+			debug_print("Unknown folder item : '%s', searching folder\n",folder_name);
 			Folder* folder = folder_find_from_path(folder_name);
 			if (folder != NULL)
 				folderItem = FOLDER_ITEM(folder->node->data);



More information about the Commits mailing list