NeoMutt  2023-05-17-56-ga67199
Teaching an old dog new tricks
DOXYGEN
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 "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "index/lib.h"
#include "menu/lib.h"
#include "format_flags.h"
#include "functions.h"
#include "hdrline.h"
#include "keymap.h"
#include "mutt_logging.h"
#include "mview.h"
#include "opcodes.h"
+ Include dependency graph for dlg_postpone.c:

Go to the source code of this file.

Functions

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...
 
static struct AttrColorpost_color (struct Menu *menu, int line)
 Calculate the colour for a line of the postpone index - Implements Menu::color() -. More...
 
struct Emaildlg_select_postponed_email (struct Mailbox *m)
 Create a Menu to select a postponed message. More...
 

Variables

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

Detailed Description

Postponed Email Selection Dialog.

Authors
  • 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 http://www.gnu.org/licenses/.

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.

Parameters
mMailbox
Return values
ptrEmail

Definition at line 195 of file dlg_postpone.c.

196{
198 // Required to number the emails
199 struct MailboxView *mv = mview_new(m, NeoMutt->notify);
200
201 struct Menu *menu = dlg->wdata;
203 menu->color = post_color;
204 menu->max = m->msg_count;
205 menu->mdata = mv;
206 menu->mdata_free = NULL; // Menu doesn't own the data
207 menu->custom_search = true;
208
209 struct PostponeData pd = { mv, menu, NULL, false };
210 dlg->wdata = &pd;
211
212 // NT_COLOR is handled by the SimpleDialog
215
216 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
217 sbar_set_title(sbar, _("Postponed Messages"));
218
219 /* The postponed mailbox is setup to have sorting disabled, but the global
220 * `$sort` variable may indicate something different. Sorting has to be
221 * disabled while the postpone menu is being displayed. */
222 const enum SortType c_sort = cs_subset_sort(NeoMutt->sub, "sort");
224
225 // ---------------------------------------------------------------------------
226 // Event Loop
227 int op = OP_NULL;
228 do
229 {
230 menu_tagging_dispatcher(menu->win, op);
231 window_redraw(NULL);
232
234 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
235 if (op < 0)
236 continue;
237 if (op == OP_NULL)
238 {
240 continue;
241 }
243
244 int rc = postpone_function_dispatcher(dlg, op);
245
246 if (rc == FR_UNKNOWN)
247 rc = menu_function_dispatcher(menu->win, op);
248 if (rc == FR_UNKNOWN)
249 rc = global_function_dispatcher(NULL, op);
250 } while (!pd.done);
251 // ---------------------------------------------------------------------------
252
253 mview_free(&mv);
254 cs_subset_str_native_set(NeoMutt->sub, "sort", c_sort, NULL);
255 simple_dialog_free(&dlg);
256
257 return pd.email;
258}
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:292
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
static const struct Mapping PostponeHelp[]
Help Bar for the Postponed email selection dialog.
Definition: dlg_postpone.c:89
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int postpone_function_dispatcher(struct MuttWindow *win, int op)
Perform a Postpone function - Implements function_dispatcher_t -.
Definition: functions.c:134
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:317
#define mutt_debug(LEVEL,...)
Definition: logging2.h:87
static struct AttrColor * post_color(struct Menu *menu, int line)
Calculate the colour for a line of the postpone index - Implements Menu::color() -.
Definition: dlg_postpone.c:169
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:102
static int postponed_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_postpone.c:143
static int postponed_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_postpone.c:117
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:166
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:129
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:803
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1077
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
#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
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:73
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:605
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:523
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
@ WT_DLG_POSTPONE
Postpone Dialog, dlg_select_postponed_email()
Definition: mutt_window.h:89
void mview_free(struct MailboxView **ptr)
Free a MailboxView.
Definition: mview.c:49
struct MailboxView * mview_new(struct Mailbox *m, struct Notify *parent)
Create a new MailboxView.
Definition: mview.c:78
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:48
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:224
SortType
Methods for sorting.
Definition: sort2.h:38
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:44
View of a Mailbox.
Definition: mview.h:39
int msg_count
Total number of messages.
Definition: mailbox.h:88
Definition: lib.h:70
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:77
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:97
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
struct AttrColor *(* color)(struct Menu *menu, int line)
Definition: lib.h:134
void * mdata
Private data.
Definition: lib.h:138
int max
Number of entries in the menu.
Definition: lib.h:72
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: lib.h:85
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
Data to pass to the Postpone Functions.
Definition: functions.h:34
struct Email * email
Selected Email.
Definition: functions.h:37
bool done
Should we close the Dialog?
Definition: functions.h:38
struct Menu * menu
Postponed Menu.
Definition: functions.h:36
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:310
@ MENU_POSTPONE
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[]
static
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 89 of file dlg_postpone.c.