summaryrefslogtreecommitdiffstats
path: root/mview.h
blob: 9eafafa2d2290cba94562deff7a72dfb941e77c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
 * @file
 * View of a Mailbox
 *
 * @authors
 * Copyright (C) 2017 Richard Russon <rich@flatcap.org>
 *
 * @copyright
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MUTT_MVIEW_H
#define MUTT_MVIEW_H

#include <stdbool.h>
#include <sys/types.h>

struct Email;
struct EmailArray;
struct Mailbox;
struct Notify;
struct NotifyCallback;

/**
 * struct MailboxView - View of a Mailbox
 */
struct MailboxView
{
  off_t vsize;                       ///< Size (in bytes) of the messages shown
  char *pattern;                     ///< Limit pattern string
  struct PatternList *limit_pattern; ///< Compiled limit pattern
  struct ThreadsContext *threads;    ///< Threads context
  int msg_in_pager;                  ///< Message currently shown in the pager

  struct Menu *menu;                 ///< Needed for pattern compilation

  bool collapsed : 1;                ///< Are all threads collapsed?

  struct Mailbox *mailbox;           ///< Current Mailbox
  struct Notify *notify;             ///< Notifications: #NotifyMview, #EventMview
};

/**
 * enum NotifyMview - Types of MailboxView Event
 *
 * Observers of #NT_MVIEW will be passed an #EventMview.
 */
enum NotifyMview
{
  NT_MVIEW_ADD = 1, ///< The Mview has been opened
  NT_MVIEW_DELETE,  ///< The Mview is about to be destroyed
  NT_MVIEW_CHANGE,  ///< The Mview has changed
};

/**
 * struct EventMview - An Event that happened to an MailboxView
 */
struct EventMview
{
  struct MailboxView *mv; ///< The MailboxView this Event relates to
};

void                mview_free            (struct MailboxView **ptr);
int                 mview_mailbox_observer(struct NotifyCallback *nc);
struct MailboxView *mview_new             (struct Mailbox *m, struct Notify *parent);
void                mview_update          (struct MailboxView *mv);
bool                mview_has_limit       (const struct MailboxView *mv);
struct Mailbox *    mview_mailbox         (struct MailboxView *mv);

bool message_is_tagged(struct Email *e);
struct Email *mutt_get_virt_email(struct Mailbox *m, int vnum);

int ea_add_tagged(struct EmailArray *ea, struct MailboxView *mv, struct Email *e, bool use_tagged);

bool mutt_limit_current_thread(struct MailboxView *mv, struct Email *e);

#endif /* MUTT_MVIEW_H */