NeoMutt  2021-10-29-43-g6b8931
Teaching an old dog new tricks
dlg_postpone.c File Reference

Postponed Email Selection Dialog. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "menu/lib.h"
#include "pattern/lib.h"
#include "format_flags.h"
#include "hdrline.h"
#include "opcodes.h"
#include "protos.h"
+ Include dependency graph for dlg_postpone.c:

Go to the source code of this file.


static void post_make_entry (struct Menu *menu, char *buf, size_t buflen, int line)
 Format a menu item for the email list - Implements Menu::make_entry() -. More...
static int postponed_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -. More...
static int postponed_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -. More...
struct Emaildlg_select_postponed_email (struct Mailbox *m)
 Create a Menu to select a postponed message. More...


static const struct Mapping PostponeHelp []
 Help Bar for the Postponed email selection dialog. More...

Detailed Description

Postponed Email Selection Dialog.

  • Michael R. Elkins
  • Thomas Roessler

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

Definition in file dlg_postpone.c.

Function Documentation

◆ dlg_select_postponed_email()

struct Email* dlg_select_postponed_email ( struct Mailbox m)

Create a Menu to select a postponed message.

Return values

Definition at line 167 of file dlg_postpone.c.

168 {
169  int r = -1;
170  bool done = false;
174  struct Menu *menu = dlg->wdata;
175  menu->make_entry = post_make_entry;
176  menu->max = m->msg_count;
177  menu->mdata = m;
178  menu->custom_search = true;
180  struct MuttWindow *win_menu = menu->win;
182  // NT_COLOR is handled by the SimpleDialog
186  struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
187  sbar_set_title(sbar, _("Postponed Messages"));
189  /* The postponed mailbox is setup to have sorting disabled, but the global
190  * `$sort` variable may indicate something different. Sorting has to be
191  * disabled while the postpone menu is being displayed. */
192  const short c_sort = cs_subset_sort(NeoMutt->sub, "sort");
195  while (!done)
196  {
197  const int op = menu_loop(menu);
198  switch (op)
199  {
200  case OP_DELETE:
201  case OP_UNDELETE:
202  {
203  const int index = menu_get_index(menu);
204  /* should deleted draft messages be saved in the trash folder? */
205  mutt_set_flag(m, m->emails[index], MUTT_DELETE, (op == OP_DELETE));
206  PostCount = m->msg_count - m->msg_deleted;
207  const bool c_resolve = cs_subset_bool(NeoMutt->sub, "resolve");
208  if (c_resolve && (index < (menu->max - 1)))
209  {
210  menu_set_index(menu, index + 1);
211  if (index >= (menu->top + menu->pagelen))
212  {
213  menu->top = index;
215  }
216  }
217  else
219  break;
220  }
222  // All search operations must exist to show the menu
224  case OP_SEARCH_NEXT:
226  case OP_SEARCH:
227  {
228  int index = menu_get_index(menu);
229  index = mutt_search_command(m, menu, index, op);
230  if (index != -1)
231  menu_set_index(menu, index);
232  break;
233  }
236  r = menu_get_index(menu);
237  done = true;
238  break;
240  case OP_EXIT:
241  done = true;
242  break;
243  }
244  }
246  cs_subset_str_native_set(NeoMutt->sub, "sort", c_sort, NULL);
247  simple_dialog_free(&dlg);
249  return (r > -1) ? m->emails[r] : NULL;
250 }
static const struct Mapping PostponeHelp[]
Help Bar for the Postponed email selection dialog.
Definition: dlg_postpone.c:88
static void post_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the email list - Implements Menu::make_entry() -.
Definition: dlg_postpone.c:101
static int postponed_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_postpone.c:140
static int postponed_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_postpone.c:116
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:126
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:163
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:292
Redraw the index.
Definition: lib.h:52
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:632
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:608
int menu_loop(struct Menu *menu)
Menu event loop.
Definition: menu.c:283
Redraw the current line of the menu.
Definition: lib.h:54
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:622
#define _(a)
Definition: message.h:28
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:189
Messages to be deleted.
Definition: mutt.h:94
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:520
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
Postpone Dialog, dlg_select_postponed_email()
Definition: mutt_window.h:89
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:42
int mutt_search_command(struct Mailbox *m, struct Menu *menu, int cur, int op)
Perform a search.
Definition: pattern.c:497
short PostCount
Definition: postpone.c:57
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:66
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:219
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:48
int msg_count
Total number of messages.
Definition: mailbox.h:91
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
int msg_deleted
Number of deleted messages.
Definition: mailbox.h:96
Definition: lib.h:67
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:74
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:103
int top
Entry that is the top of the current page.
Definition: lib.h:87
int pagelen
Number of entries per screen.
Definition: lib.h:72
void * mdata
Private data.
Definition: lib.h:153
int max
Number of entries in the menu.
Definition: lib.h:69
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: lib.h:91
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition: subset.c:305
Select a postponed email.
Definition: type.h:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ PostponeHelp

const struct Mapping PostponeHelp[]
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ N_("Del"), OP_DELETE },
{ N_("Undel"), OP_UNDELETE },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
#define N_(a)
Definition: message.h:32

Help Bar for the Postponed email selection dialog.

Definition at line 1 of file dlg_postpone.c.