aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-08-22 06:32:01 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-08-22 06:32:01 +0000
commitf2cd5cfc7b9a7d0b95255b63ca1182cc13746c49 (patch)
tree1f8a2fe9112884bd00407bf8986b7dc72f046277
parent2fea3b70ce247c9dc66fbdefa98007befef8116b (diff)
fall back to date comparison on sorting.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@496 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.ja6
-rw-r--r--src/procmsg.c75
-rw-r--r--src/summaryview.c36
4 files changed, 93 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index d7b0e96f..11b6b07b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-08-22
+
+ * src/procmsg.c
+ src/summaryview.c: fall back to date comparison on sorting
+ (fixes random date order when sorting by subject etc.).
+
2005-08-19
* src/utils.c: path_cmp(): allow both '/' and G_DIR_SEPARATOR as
diff --git a/ChangeLog.ja b/ChangeLog.ja
index e9cc6a7b..a68b9ab9 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,9 @@
+2005-08-22
+
+ * src/procmsg.c
+ src/summaryview.c: ソートで日付による比較にフォールバックするように
+ した(件名等でソートしたときに日付順がランダムになるのを修正)。
+
2005-08-19
* src/utils.c: path_cmp(): '/' と G_DIR_SEPARATOR の両方をセパレータ
diff --git a/src/procmsg.c b/src/procmsg.c
index 8931536d..11ff996d 100644
--- a/src/procmsg.c
+++ b/src/procmsg.c
@@ -1530,10 +1530,8 @@ gint procmsg_cmp_msgnum_for_sort(gconstpointer a, gconstpointer b)
const MsgInfo *msginfo1 = a;
const MsgInfo *msginfo2 = b;
- if (!msginfo1)
- return -1;
- if (!msginfo2)
- return -1;
+ if (!msginfo1 || !msginfo2)
+ return 0;
return msginfo1->msgnum - msginfo2->msgnum;
}
@@ -1543,11 +1541,16 @@ static gint func_name(gconstpointer a, gconstpointer b) \
{ \
const MsgInfo *msginfo1 = a; \
const MsgInfo *msginfo2 = b; \
+ gint ret; \
\
if (!msginfo1 || !msginfo2) \
- return -1; \
+ return 0; \
\
- return (val) * (cmp_func_sort_type == SORT_ASCENDING ? 1 : -1); \
+ ret = (val); \
+ if (ret == 0) \
+ ret = msginfo1->date_t - msginfo2->date_t; \
+ \
+ return ret * (cmp_func_sort_type == SORT_ASCENDING ? 1 : -1); \
}
CMP_FUNC_DEF(procmsg_cmp_by_mark,
@@ -1559,9 +1562,22 @@ CMP_FUNC_DEF(procmsg_cmp_by_mime,
CMP_FUNC_DEF(procmsg_cmp_by_label,
MSG_GET_COLORLABEL(msginfo1->flags) -
MSG_GET_COLORLABEL(msginfo2->flags))
+CMP_FUNC_DEF(procmsg_cmp_by_size, msginfo1->size - msginfo2->size)
+
+#undef CMP_FUNC_DEF
+#define CMP_FUNC_DEF(func_name, val) \
+static gint func_name(gconstpointer a, gconstpointer b) \
+{ \
+ const MsgInfo *msginfo1 = a; \
+ const MsgInfo *msginfo2 = b; \
+ \
+ if (!msginfo1 || !msginfo2) \
+ return 0; \
+ \
+ return (val) * (cmp_func_sort_type == SORT_ASCENDING ? 1 : -1); \
+}
CMP_FUNC_DEF(procmsg_cmp_by_number, msginfo1->msgnum - msginfo2->msgnum)
-CMP_FUNC_DEF(procmsg_cmp_by_size, msginfo1->size - msginfo2->size)
CMP_FUNC_DEF(procmsg_cmp_by_date, msginfo1->date_t - msginfo2->date_t)
#undef CMP_FUNC_DEF
@@ -1570,15 +1586,20 @@ static gint func_name(gconstpointer a, gconstpointer b) \
{ \
const MsgInfo *msginfo1 = a; \
const MsgInfo *msginfo2 = b; \
+ gint ret; \
\
if (!msginfo1->var_name) \
- return (msginfo2->var_name != NULL); \
+ return (msginfo2->var_name != NULL) * \
+ (cmp_func_sort_type == SORT_ASCENDING ? -1 : 1);\
if (!msginfo2->var_name) \
- return -1; \
+ return (cmp_func_sort_type == SORT_ASCENDING ? 1 : -1); \
+ \
+ ret = g_ascii_strcasecmp \
+ (msginfo1->var_name, msginfo2->var_name); \
+ if (ret == 0) \
+ ret = msginfo1->date_t - msginfo2->date_t; \
\
- return g_ascii_strcasecmp \
- (msginfo1->var_name, msginfo2->var_name) * \
- (cmp_func_sort_type == SORT_ASCENDING ? 1 : -1);\
+ return ret * (cmp_func_sort_type == SORT_ASCENDING ? 1 : -1); \
}
CMP_FUNC_DEF(procmsg_cmp_by_from, fromname)
@@ -1586,17 +1607,21 @@ CMP_FUNC_DEF(procmsg_cmp_by_to, to)
#undef CMP_FUNC_DEF
-static gint procmsg_cmp_by_subject(gconstpointer a, gconstpointer b) \
-{ \
- const MsgInfo *msginfo1 = a; \
- const MsgInfo *msginfo2 = b; \
- \
- if (!msginfo1->subject) \
- return (msginfo2->subject != NULL); \
- if (!msginfo2->subject) \
- return -1; \
- \
- return subject_compare_for_sort \
- (msginfo1->subject, msginfo2->subject) * \
- (cmp_func_sort_type == SORT_ASCENDING ? 1 : -1); \
+static gint procmsg_cmp_by_subject(gconstpointer a, gconstpointer b)
+{
+ const MsgInfo *msginfo1 = a;
+ const MsgInfo *msginfo2 = b;
+ gint ret;
+
+ if (!msginfo1->subject)
+ return (msginfo2->subject != NULL) *
+ (cmp_func_sort_type == SORT_ASCENDING ? -1 : 1);
+ if (!msginfo2->subject)
+ return (cmp_func_sort_type == SORT_ASCENDING ? 1 : -1);
+
+ ret = subject_compare_for_sort(msginfo1->subject, msginfo2->subject);
+ if (ret == 0)
+ ret = msginfo1->date_t - msginfo2->date_t;
+
+ return ret * (cmp_func_sort_type == SORT_ASCENDING ? 1 : -1);
}
diff --git a/src/summaryview.c b/src/summaryview.c
index 5332ce92..26ed11da 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -4845,6 +4845,7 @@ static gint func_name(GtkTreeModel *model, \
GtkTreeIter *a, GtkTreeIter *b, gpointer data) \
{ \
MsgInfo *msginfo_a = NULL, *msginfo_b = NULL; \
+ gint ret; \
\
gtk_tree_model_get(model, a, S_COL_MSG_INFO, &msginfo_a, -1); \
gtk_tree_model_get(model, b, S_COL_MSG_INFO, &msginfo_b, -1); \
@@ -4852,7 +4853,9 @@ static gint func_name(GtkTreeModel *model, \
if (!msginfo_a || !msginfo_b) \
return 0; \
\
- return (val); \
+ ret = (val); \
+ return (ret != 0) ? ret : \
+ (msginfo_a->date_t - msginfo_b->date_t); \
}
CMP_FUNC_DEF(summary_cmp_by_mark,
@@ -4864,9 +4867,25 @@ CMP_FUNC_DEF(summary_cmp_by_mime,
CMP_FUNC_DEF(summary_cmp_by_label,
MSG_GET_COLORLABEL(msginfo_a->flags) -
MSG_GET_COLORLABEL(msginfo_b->flags))
+CMP_FUNC_DEF(summary_cmp_by_size, msginfo_a->size - msginfo_b->size)
+
+#undef CMP_FUNC_DEF
+#define CMP_FUNC_DEF(func_name, val) \
+static gint func_name(GtkTreeModel *model, \
+ GtkTreeIter *a, GtkTreeIter *b, gpointer data) \
+{ \
+ MsgInfo *msginfo_a = NULL, *msginfo_b = NULL; \
+ \
+ gtk_tree_model_get(model, a, S_COL_MSG_INFO, &msginfo_a, -1); \
+ gtk_tree_model_get(model, b, S_COL_MSG_INFO, &msginfo_b, -1); \
+ \
+ if (!msginfo_a || !msginfo_b) \
+ return 0; \
+ \
+ return (val); \
+}
CMP_FUNC_DEF(summary_cmp_by_num, msginfo_a->msgnum - msginfo_b->msgnum)
-CMP_FUNC_DEF(summary_cmp_by_size, msginfo_a->size - msginfo_b->size)
CMP_FUNC_DEF(summary_cmp_by_date, msginfo_a->date_t - msginfo_b->date_t)
#undef CMP_FUNC_DEF
@@ -4875,6 +4894,7 @@ static gint func_name(GtkTreeModel *model, \
GtkTreeIter *a, GtkTreeIter *b, gpointer data) \
{ \
MsgInfo *msginfo_a = NULL, *msginfo_b = NULL; \
+ gint ret; \
\
gtk_tree_model_get(model, a, S_COL_MSG_INFO, &msginfo_a, -1); \
gtk_tree_model_get(model, b, S_COL_MSG_INFO, &msginfo_b, -1); \
@@ -4887,8 +4907,11 @@ static gint func_name(GtkTreeModel *model, \
if (msginfo_b->var_name == NULL) \
return (msginfo_a->var_name != NULL); \
\
- return g_ascii_strcasecmp \
+ ret = g_ascii_strcasecmp \
(msginfo_a->var_name, msginfo_b->var_name); \
+ \
+ return (ret != 0) ? ret : \
+ (msginfo_a->date_t - msginfo_b->date_t); \
}
CMP_FUNC_DEF(summary_cmp_by_from, fromname)
@@ -4901,6 +4924,7 @@ static gint summary_cmp_by_subject(GtkTreeModel *model,
gpointer data)
{
MsgInfo *msginfo_a = NULL, *msginfo_b = NULL;
+ gint ret;
gtk_tree_model_get(model, a, S_COL_MSG_INFO, &msginfo_a, -1);
gtk_tree_model_get(model, b, S_COL_MSG_INFO, &msginfo_b, -1);
@@ -4913,6 +4937,8 @@ static gint summary_cmp_by_subject(GtkTreeModel *model,
if (msginfo_b->subject == NULL)
return (msginfo_a->subject != NULL);
- return subject_compare_for_sort
- (msginfo_a->subject, msginfo_b->subject);
+ ret = subject_compare_for_sort(msginfo_a->subject, msginfo_b->subject);
+
+ return (ret != 0) ? ret :
+ (msginfo_a->date_t - msginfo_b->date_t);
}