From 08d94c1222d4fb60580b90f3c05a812907395602 Mon Sep 17 00:00:00 2001 From: Paul Mangan Date: Fri, 27 Dec 2002 12:12:53 +0000 Subject: [PATCH] fix 'sort by recipient' --- ChangeLog.claws | 12 +++ configure.in | 2 +- src/summaryview.c | 199 ++++++++++++++-------------------------------- 3 files changed, 73 insertions(+), 140 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index 4a8fdc55e..1ac304e2f 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,15 @@ +2002-12-27 [paul] 0.8.8claws10 + + * src/mainwindow.c + remove unneeded 'GtkWidget *vbox' + + * src/summaryview.c + further sync with 0.8.8 - make sort + by recipient work as expected + + * NEWS + sync with 0.8.8 + 2002-12-27 [paul] 0.8.8claws9 * po/pt_BR.po diff --git a/configure.in b/configure.in index 6e538d71a..d2a94b02c 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=8 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws9 +EXTRA_VERSION=claws10 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/summaryview.c b/src/summaryview.c index 155e25ee9..ae3badced 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -1069,6 +1069,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item) 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); @@ -5006,114 +5007,56 @@ static void summary_drag_data_get(GtkWidget *widget, /* 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) @@ -5147,14 +5090,20 @@ static gint summary_cmp_by_simplified_subject 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) @@ -5184,31 +5133,6 @@ 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; @@ -5496,6 +5420,3 @@ static gboolean summary_update_msg(gpointer source, gpointer data) { return FALSE; } -/* - * End of Source. - */ -- 2.25.1