#include "sort.h"
#include "mailbox.h"
#include "browser.h"
+#include "mx.h"
#ifdef USE_IMAP
#include "imap.h"
#endif
return ((BrowserSort & SORT_REVERSE) ? -r : r);
}
+static int browser_compare_desc (const void *a, const void *b)
+{
+ struct folder_file *pa = (struct folder_file *) a;
+ struct folder_file *pb = (struct folder_file *) b;
+
+ int r = mutt_strcoll (pa->desc, pb->desc);
+
+ return ((BrowserSort & SORT_REVERSE) ? -r : r);
+}
+
static int browser_compare_date (const void *a, const void *b)
{
struct folder_file *pa = (struct folder_file *) a;
return ((BrowserSort & SORT_REVERSE) ? -r : r);
}
+static int browser_compare_count (const void *a, const void *b)
+{
+ struct folder_file *pa = (struct folder_file *) a;
+ struct folder_file *pb = (struct folder_file *) b;
+
+ int r = pa->all - pb->all;
+
+ return ((BrowserSort & SORT_REVERSE) ? -r : r);
+}
+
+static int browser_compare_count_new (const void *a, const void *b)
+{
+ struct folder_file *pa = (struct folder_file *) a;
+ struct folder_file *pb = (struct folder_file *) b;
+
+ int r = pa->new - pb->new;
+
+ return ((BrowserSort & SORT_REVERSE) ? -r : r);
+}
+
static void browser_sort (struct browser_state *state)
{
int (*f) (const void *, const void *);
case SORT_SIZE:
f = browser_compare_size;
break;
+ case SORT_DESC:
+ f = browser_compare_desc;
+ break;
+ case SORT_COUNT:
+ f = browser_compare_count;
+ break;
+ case SORT_COUNT_NEW:
+ f = browser_compare_count_new;
+ break;
case SORT_SUBJECT:
default:
f = browser_compare_subject;
else
mutt_format_s (dest, destlen, fmt, "");
break;
-
+
+ case 'n':
+ if (!optional) {
+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+ snprintf (dest, destlen, tmp, folder->ff->all);
+ } else if (!folder->ff->all) {
+ optional = 0;
+ }
+ break;
+
case 'N':
#ifdef USE_IMAP
if (mx_is_imap (folder->ff->desc))
}
static void add_folder (MUTTMENU *m, struct browser_state *state,
- const char *name, const struct stat *s, unsigned int new)
+ const char *name, const char *desc,
+ const struct stat *s, unsigned int new, unsigned int all)
{
if (state->entrylen == state->entrymax)
{
}
(state->entry)[state->entrylen].new = new;
+ (state->entry)[state->entrylen].all = all;
(state->entry)[state->entrylen].name = safe_strdup (name);
- (state->entry)[state->entrylen].desc = safe_strdup (name);
+ (state->entry)[state->entrylen].desc = safe_strdup(desc ? desc : name);
#ifdef USE_IMAP
(state->entry)[state->entrylen].imap = 0;
#endif
tmp = Incoming;
while (tmp && mutt_strcmp (buffer, tmp->path))
tmp = tmp->next;
- add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
+ add_folder (menu, state, de->d_name, NULL, &s, (tmp) ? tmp->new : 0, 0);
}
closedir (dp);
browser_sort (state);
if (mx_is_imap (tmp->path))
{
imap_mailbox_state (tmp->path, &mbox);
- add_folder (menu, state, tmp->path, NULL, mbox.new);
+ add_folder (menu, state, tmp->path, NULL, NULL, mbox.new, mbox.messages);
continue;
}
#endif
#ifdef USE_POP
if (mx_is_pop (tmp->path))
{
- add_folder (menu, state, tmp->path, NULL, tmp->new);
+ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new, 0);
continue;
}
#endif
strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
mutt_pretty_mailbox (buffer, sizeof (buffer));
- add_folder (menu, state, buffer, &s, tmp->new);
+ add_folder (menu, state, buffer, NULL, &s, tmp->new, 0);
}
while ((tmp = tmp->next));
browser_sort (state);
int reverse = (i == OP_SORT_REVERSE);
switch (mutt_multi_choice ((reverse) ?
- _("Reverse sort by (d)ate, (a)lpha, si(z)e or do(n)'t sort? ") :
- _("Sort by (d)ate, (a)lpha, si(z)e or do(n)'t sort? "),
- _("dazn")))
+ _("Reverse sort by (d)ate, (a)lpha, si(z)e, d(e)scription, (c)ount, ne(w) count, or do(n)'t sort? ") :
+ _("Sort by (d)ate, (a)lpha, si(z)e, d(e)scription, (c)ount, ne(w) count, or do(n)'t sort? "),
+ _("dazecwn")))
{
case -1: /* abort */
resort = 0;
BrowserSort = SORT_SIZE;
break;
- case 4: /* do(n)'t sort */
+ case 4: /* d(e)scription */
+ BrowserSort = SORT_DESC;
+ break;
+
+ case 5: /* (c)ount */
+ BrowserSort = SORT_COUNT;
+ break;
+
+ case 6: /* ne(w) count */
+ BrowserSort = SORT_COUNT_NEW;
+ break;
+
+ case 7: /* do(n)'t sort */
BrowserSort = SORT_ORDER;
resort = 0;
break;