summary_select_node(summaryview, node, FALSE, TRUE);
}
+ summary_set_column_titles(summaryview);
summary_status_show(summaryview);
summary_set_menu_sensitive(summaryview);
toolbar_main_set_sensitive(summaryview->mainwin);
/* custom compare functions for sorting */
-static gint summary_cmp_by_mark(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
-
- return MSG_IS_MARKED(msginfo1->flags) - MSG_IS_MARKED(msginfo2->flags);
-}
-
-static gint summary_cmp_by_unread(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
-
- return MSG_IS_UNREAD(msginfo1->flags) - MSG_IS_UNREAD(msginfo2->flags);
-}
-
-static gint summary_cmp_by_mime(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
-
- return MSG_IS_MIME(msginfo1->flags) - MSG_IS_MIME(msginfo2->flags);
-}
-
-static gint summary_cmp_by_num(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
-
- return msginfo1->msgnum - msginfo2->msgnum;
-}
-
-static gint summary_cmp_by_size(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
-
- return msginfo1->size - msginfo2->size;
-}
-
-static gint summary_cmp_by_date(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
-
- return msginfo1->date_t - msginfo2->date_t;
-}
-
-static gint summary_cmp_by_from(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
-
- if (!msginfo1->fromname)
- return (msginfo2->fromname != NULL);
- if (!msginfo2->fromname)
- return -1;
-
- return strcasecmp(msginfo1->fromname, msginfo2->fromname);
-}
-
-static gint summary_cmp_by_to(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- const gchar *str1, *str2;
- const GtkCListRow *r1 = (const GtkCListRow *) ptr1;
- const GtkCListRow *r2 = (const GtkCListRow *) ptr2;
- const SummaryView *sv = gtk_object_get_data(GTK_OBJECT(clist), "summaryview");
-
- g_return_val_if_fail(sv, -1);
-
- str1 = GTK_CELL_TEXT(r1->cell[sv->col_pos[S_COL_FROM]])->text;
- str2 = GTK_CELL_TEXT(r2->cell[sv->col_pos[S_COL_FROM]])->text;
-
- if (!str1)
- return str2 != NULL;
-
- if (!str2)
- return -1;
-
- if (g_strncasecmp(str1, "-->", 3) == 0)
- str1 += 3;
- if (g_strncasecmp(str2, "-->", 3) == 0)
- str2 += 3;
-
- return strcasecmp(str1, str2);
-}
-
-static gint summary_cmp_by_subject(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
-
- if (!msginfo1->subject)
- return (msginfo2->subject != NULL);
- if (!msginfo2->subject)
- return -1;
-
- return strcasecmp(msginfo1->subject, msginfo2->subject);
-}
+#define CMP_FUNC_DEF(func_name, val) \
+static gint func_name(GtkCList *clist, \
+ gconstpointer ptr1, gconstpointer ptr2) \
+{ \
+ MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data; \
+ MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data; \
+ \
+ if (!msginfo1 || !msginfo2) \
+ return -1; \
+ \
+ return (val); \
+}
+
+CMP_FUNC_DEF(summary_cmp_by_mark,
+ MSG_IS_MARKED(msginfo1->flags) - MSG_IS_MARKED(msginfo2->flags))
+CMP_FUNC_DEF(summary_cmp_by_unread,
+ MSG_IS_UNREAD(msginfo1->flags) - MSG_IS_UNREAD(msginfo2->flags))
+CMP_FUNC_DEF(summary_cmp_by_mime,
+ MSG_IS_MIME(msginfo1->flags) - MSG_IS_MIME(msginfo2->flags))
+CMP_FUNC_DEF(summary_cmp_by_label,
+ MSG_GET_COLORLABEL(msginfo1->flags) -
+ MSG_GET_COLORLABEL(msginfo2->flags))
+CMP_FUNC_DEF(summary_cmp_by_locked,
+ MSG_IS_LOCKED(msginfo1->flags) - MSG_IS_LOCKED(msginfo2->flags))
+
+CMP_FUNC_DEF(summary_cmp_by_num, msginfo1->msgnum - msginfo2->msgnum)
+CMP_FUNC_DEF(summary_cmp_by_size, msginfo1->size - msginfo2->size)
+CMP_FUNC_DEF(summary_cmp_by_date, msginfo1->date_t - msginfo2->date_t)
+
+#undef CMP_FUNC_DEF
+#define CMP_FUNC_DEF(func_name, var_name) \
+static gint func_name(GtkCList *clist, \
+ gconstpointer ptr1, gconstpointer ptr2) \
+{ \
+ MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data; \
+ MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data; \
+ \
+ if (!msginfo1->var_name) \
+ return (msginfo2->var_name != NULL); \
+ if (!msginfo2->var_name) \
+ return -1; \
+ \
+ 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);
+
+#undef CMP_FUNC_DEF
static gint summary_cmp_by_simplified_subject
(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
return strcasecmp(str1, str2);
}
-static gint summary_cmp_by_label(GtkCList *clist,
+static gint summary_cmp_by_score(GtkCList *clist,
gconstpointer ptr1, gconstpointer ptr2)
{
MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
+ int diff;
+
+ /* if score are equal, sort by date */
- return MSG_GET_COLORLABEL(msginfo1->flags) -
- MSG_GET_COLORLABEL(msginfo2->flags);
+ diff = msginfo1->threadscore - msginfo2->threadscore;
+ if (diff != 0)
+ return diff;
+ else
+ return summary_cmp_by_date(clist, ptr1, ptr2);
}
static void news_flag_crosspost(MsgInfo *msginfo)
}
}
-static gint summary_cmp_by_score(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
- int diff;
-
- /* if score are equal, sort by date */
-
- diff = msginfo1->threadscore - msginfo2->threadscore;
- if (diff != 0)
- return diff;
- else
- return summary_cmp_by_date(clist, ptr1, ptr2);
-}
-
-static gint summary_cmp_by_locked(GtkCList *clist,
- gconstpointer ptr1, gconstpointer ptr2)
-{
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
-
- return MSG_IS_LOCKED(msginfo1->flags) - MSG_IS_LOCKED(msginfo2->flags);
-}
-
static void summary_ignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpointer data)
{
SummaryView *summaryview = (SummaryView *) data;
return FALSE;
}
-/*
- * End of Source.
- */