[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sylpheed
Subject:    [sylpheed:17801] NEW PATCH: Sort by Recipient
From:       Sylpheed Patches <sylpheed () thewildbeast ! co ! uk>
Date:       2002-12-30 12:56:07
[Download RAW message or body]

ANNOUNCING THE RELEASE OF A NEW PATCH

Patch Author: Marcel Arndt <arndtm@iam.uni-bonn.de>
Title:        Sort by Recipient
Filename:     sortbyrecipient_v2_0.8.8.patch (7.6 kb)
Works with:   0.8.8

Description:
Sylpheed allows you to display the recipient instead of the 
sender in the from column, if the sender is yourself. But this 
does not affect the sorting order for this column. The patch 
allows you to specify whether to sort by recipient (with or 
without the leading -->) or by sender (original behaviour). 
You can set this in Common Preferences->Display.
Difference 
to the "sort by recipient" feature in the main brach since 0.8.8: 
The standard feature allows you to sort either on the sender 
or on the recipient, the patch allows you to sort on what is 
really displayed in the from column. The patch is esp. useful 
in case of mixed folders which contain messages both from yourself 
and from others.

Notes:
Apply in the sylpheed source directory with patch -p0

--------------------------
This is an automated message from the Sylpheed Patch homepage.
<http://www.thewildbeast.co.uk/sylpheed>

If you have made a patch that you want included at the
Sylpheed Patch homepage, request details from
<sylpheed@thewildbeast.co.uk>.

["sortbyrecipient_v2_0.8.8.patch" (application/octet-stream)]

Common subdirectories: src_orig/pixmaps and src/pixmaps
diff -u src_orig/prefs_common.c src/prefs_common.c
--- src_orig/prefs_common.c	Thu Dec 19 05:02:28 2002
+++ src/prefs_common.c	Mon Dec 30 10:05:28 2002
@@ -125,6 +125,7 @@
 	GtkWidget *chkbtn_transhdr;
 
 	GtkWidget *chkbtn_swapfrom;
+	GtkWidget *optmenu_sortbyrecipient;
 	GtkWidget *chkbtn_expand_thread;
 	GtkWidget *entry_datefmt;
 } display;
@@ -204,6 +205,8 @@
 static void prefs_common_charset_set_optmenu	      (PrefParam *pparam);
 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam);
 static void prefs_common_recv_dialog_set_optmenu(PrefParam *pparam);
+static void prefs_common_sort_by_recipient_set_data_from_optmenu(PrefParam *pparam);
+static void prefs_common_sort_by_recipient_set_optmenu(PrefParam *pparam);
 
 /*
    parameter name, default value, pointer to the prefs variable, data type,
@@ -358,6 +361,10 @@
 	{"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL,
 	 &display.chkbtn_swapfrom,
 	 prefs_set_data_from_toggle, prefs_set_toggle},
+	{"sort_by_recipient_mode", "1", &prefs_common.sort_by_recipient_mode, P_ENUM,
+	 &display.optmenu_sortbyrecipient,
+	 prefs_common_sort_by_recipient_set_data_from_optmenu,
+	 prefs_common_sort_by_recipient_set_optmenu},
 	{"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format,
 	 P_STRING, &display.entry_datefmt,
 	 prefs_set_data_from_entry, prefs_set_entry},
@@ -1448,6 +1455,12 @@
 	GtkWidget *frame_summary;
 	GtkWidget *vbox2;
 	GtkWidget *chkbtn_swapfrom;
+	GtkWidget *hbox2;
+	GtkWidget *hbox2_spc;
+	GtkWidget *label_sortbyrecipient;
+	GtkWidget *optmenu_sortbyrecipient;
+	GtkWidget *menu_sortbyrecipient;
+	GtkWidget *menuitem;
 	GtkWidget *chkbtn_expand_thread;
 	GtkWidget *vbox3;
 	GtkWidget *label_datefmt;
@@ -1535,6 +1548,36 @@
 	PACK_CHECK_BUTTON
 		(vbox2, chkbtn_swapfrom,
 		 _("Display recipient on `From' column if sender is yourself"));
+
+	hbox2 = gtk_hbox_new (FALSE, 8);
+	gtk_widget_show (hbox2);
+	gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
+
+	hbox2_spc = gtk_hbox_new (FALSE, 0);
+	gtk_widget_show (hbox2_spc);
+	gtk_box_pack_start (GTK_BOX (hbox2), hbox2_spc, FALSE, FALSE, 0);
+	gtk_widget_set_usize (hbox2_spc, 16, -1);
+
+	label_sortbyrecipient = gtk_label_new (_("Sort own messages by"));
+	gtk_widget_show (label_sortbyrecipient);
+	gtk_box_pack_start (GTK_BOX (hbox2), label_sortbyrecipient, FALSE, FALSE, 0);
+
+	optmenu_sortbyrecipient = gtk_option_menu_new ();
+	gtk_widget_show (optmenu_sortbyrecipient);
+	gtk_box_pack_start (GTK_BOX (hbox2), optmenu_sortbyrecipient, FALSE, FALSE, 0);
+
+	menu_sortbyrecipient = gtk_menu_new ();
+	MENUITEM_ADD (menu_sortbyrecipient, menuitem, _("Sender"),
+		      SORTBYRECIPIENT_FROM);
+	MENUITEM_ADD (menu_sortbyrecipient, menuitem, _("Recipient without \"-->\""),
+		      SORTBYRECIPIENT_TO);
+	MENUITEM_ADD (menu_sortbyrecipient, menuitem, _("Recipient with \"-->\""),
+		      SORTBYRECIPIENT_TOWITHARROW);
+
+	gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_sortbyrecipient), menu_sortbyrecipient);
+
+ 	SET_TOGGLE_SENSITIVITY (chkbtn_swapfrom, hbox2);
+
 	PACK_CHECK_BUTTON
 		(vbox2, chkbtn_expand_thread, _("Expand threads"));
 
@@ -1580,9 +1623,10 @@
 	display.spinbtn_ng_abbrev_len     = spinbtn_ng_abbrev_len;
 	display.spinbtn_ng_abbrev_len_adj = spinbtn_ng_abbrev_len_adj;
 
-	display.chkbtn_swapfrom      = chkbtn_swapfrom;
-	display.chkbtn_expand_thread = chkbtn_expand_thread;
-	display.entry_datefmt        = entry_datefmt;
+	display.chkbtn_swapfrom         = chkbtn_swapfrom;
+	display.optmenu_sortbyrecipient = optmenu_sortbyrecipient;
+	display.chkbtn_expand_thread    = chkbtn_expand_thread;
+	display.entry_datefmt           = entry_datefmt;
 }
 
 static void prefs_message_create(void)
@@ -3329,6 +3373,43 @@
 		gtk_option_menu_set_history(optmenu, 2);
 		break;
 	default:
+		break;
+	}
+
+	menu = gtk_option_menu_get_menu(optmenu);
+	menuitem = gtk_menu_get_active(GTK_MENU(menu));
+	gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
+}
+
+static void prefs_common_sort_by_recipient_set_data_from_optmenu(PrefParam *pparam)
+{
+	GtkWidget *menu;
+	GtkWidget *menuitem;
+
+	menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
+	menuitem = gtk_menu_get_active(GTK_MENU(menu));
+	*((SortByRecipientMode *)pparam->data) = GPOINTER_TO_INT
+		(gtk_object_get_user_data(GTK_OBJECT(menuitem)));
+}
+
+static void prefs_common_sort_by_recipient_set_optmenu(PrefParam *pparam)
+{
+	SortByRecipientMode mode = *((SortByRecipientMode *)pparam->data);
+	GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
+	GtkWidget *menu;
+	GtkWidget *menuitem;
+
+	switch (mode) {
+	case SORTBYRECIPIENT_FROM:
+		gtk_option_menu_set_history(optmenu, 0);
+		break;
+	case SORTBYRECIPIENT_TO:
+		gtk_option_menu_set_history(optmenu, 1);
+		break;
+	case SORTBYRECIPIENT_TOWITHARROW:
+		gtk_option_menu_set_history(optmenu, 2);
+		break;
+	default:
 		break;
 	}
 
diff -u src_orig/prefs_common.h src/prefs_common.h
--- src_orig/prefs_common.h	Wed Nov 27 04:41:55 2002
+++ src/prefs_common.h	Mon Dec 30 10:06:17 2002
@@ -39,6 +39,12 @@
 	RECV_DIALOG_NEVER
 } RecvDialogMode;
 
+typedef enum {
+	SORTBYRECIPIENT_FROM,
+	SORTBYRECIPIENT_TO,
+	SORTBYRECIPIENT_TOWITHARROW
+} SortByRecipientMode;
+
 struct _PrefsCommon
 {
 	/* Receive */
@@ -92,6 +98,7 @@
 	gint ng_abbrev_len;
 
 	gboolean swap_from;
+	SortByRecipientMode sort_by_recipient_mode;
 	gboolean expand_thread;
 	gchar *date_format;
 
diff -u src_orig/summaryview.c src/summaryview.c
--- src_orig/summaryview.c	Wed Dec 25 04:16:47 2002
+++ src/summaryview.c	Mon Dec 30 10:21:28 2002
@@ -4064,8 +4064,49 @@
 	return strcasecmp(msginfo1->var_name, msginfo2->var_name);	 \
 }
 
-CMP_FUNC_DEF(summary_cmp_by_from, fromname)
 CMP_FUNC_DEF(summary_cmp_by_subject, subject);
 CMP_FUNC_DEF(summary_cmp_by_to, to);
 
+static gint summary_cmp_by_from(GtkCList *clist,
+                               gconstpointer ptr1, gconstpointer ptr2)
+{
+        MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
+        MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
+
+        gchar *cmpstring1 = msginfo1->fromname;
+        gchar *cmpstring2 = msginfo2->fromname;
+
+        if (prefs_common.swap_from && 
+            prefs_common.sort_by_recipient_mode!=SORTBYRECIPIENT_FROM &&
+            cur_account && cur_account->address) {
+                if (msginfo1->from && msginfo1->to) {
+                        gchar *from;
+                        Xstrdup_a(from, msginfo1->from, return);
+                        extract_address(from);
+                        if (!strcmp(from, cur_account->address))
+                                if (prefs_common.sort_by_recipient_mode==SORTBYRECIPIENT_TO)
+                                        cmpstring1 = msginfo1->to;
+                                else
+                                        Xstrcat_a(cmpstring1, "-->", msginfo1->to, return -1);
+                }
+                if (msginfo2->from && msginfo2->to) {
+                        gchar *from;
+                        Xstrdup_a(from, msginfo2->from, return);
+                        extract_address(from);
+                        if (!strcmp(from, cur_account->address))
+                                if (prefs_common.sort_by_recipient_mode==SORTBYRECIPIENT_TO)
+                                        cmpstring2 = msginfo2->to;
+                                else
+                                        Xstrcat_a(cmpstring2, "-->", msginfo2->to, return -1);
+                }
+        }
+
+        if (!cmpstring1)
+                return (cmpstring2 != NULL);
+        if (!cmpstring2)
+                return -1;
+
+        return strcasecmp(cmpstring1, cmpstring2);
+}
+
 #undef CMP_FUNC_DEF


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic