NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_compose.c File Reference

Compose Email Dialog. More...

#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "attach/lib.h"
#include "envelope/lib.h"
#include "index/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "attach_data.h"
#include "cbar.h"
#include "functions.h"
#include "globals.h"
#include "hook.h"
#include "mutt_logging.h"
#include "shared_data.h"
+ Include dependency graph for dlg_compose.c:

Go to the source code of this file.

Functions

static int compose_recalc (struct MuttWindow *dlg)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int compose_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
static int compose_email_observer (struct NotifyCallback *nc)
 Notification that an Email has changed - Implements observer_t -.
 
static int compose_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
static void gen_attach_list (struct AttachCtx *actx, struct Body *b, int parent_type, int level)
 Generate the attachment list for the compose screen.
 
void update_menu (struct AttachCtx *actx, struct Menu *menu, bool init)
 Redraw the compose window.
 
static struct MuttWindowcompose_dlg_init (struct ConfigSubset *sub, struct Email *e, struct Buffer *fcc)
 Allocate the Windows for Compose.
 
int dlg_compose (struct Email *e, struct Buffer *fcc, uint8_t flags, struct ConfigSubset *sub)
 Allow the user to edit the message envelope -.
 

Variables

static const struct Mapping ComposeHelp []
 Help Bar for the Compose dialog.
 
static const struct Mapping ComposeNewsHelp []
 Help Bar for the News Compose dialog.
 

Detailed Description

Compose Email Dialog.

Authors
  • Richard Russon
  • Pietro Cerutti
  • Dennis Schön

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_compose.c.

Function Documentation

◆ gen_attach_list()

static void gen_attach_list ( struct AttachCtx actx,
struct Body b,
int  parent_type,
int  level 
)
static

Generate the attachment list for the compose screen.

Parameters
actxAttachment context
bAttachment
parent_typeAttachment type, e.g TYPE_MULTIPART
levelNesting depth of attachment

Definition at line 258 of file dlg_compose.c.

259{
260 for (; b; b = b->next)
261 {
262 struct AttachPtr *ap = mutt_aptr_new();
263 mutt_actx_add_attach(actx, ap);
264 ap->body = b;
265 b->aptr = ap;
267 ap->level = level;
268 if ((b->type == TYPE_MULTIPART) && b->parts &&
270 {
271 gen_attach_list(actx, b->parts, b->type, level + 1);
272 }
273 }
274}
void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach)
Add an Attachment to an Attachment Context.
Definition: attach.c:65
struct AttachPtr * mutt_aptr_new(void)
Create a new Attachment Pointer.
Definition: attach.c:40
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:443
static void gen_attach_list(struct AttachCtx *actx, struct Body *b, int parent_type, int level)
Generate the attachment list for the compose screen.
Definition: dlg_compose.c:258
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:96
#define WithCrypto
Definition: lib.h:122
An email to which things will be attached.
Definition: attach.h:35
struct Body * body
Attachment.
Definition: attach.h:36
int level
Nesting depth of attachment.
Definition: attach.h:40
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition: attach.h:38
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:73
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition: body.h:75
struct Body * next
next attachment in the list
Definition: body.h:72
unsigned int type
content-type primary type, ContentType
Definition: body.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_menu()

void update_menu ( struct AttachCtx actx,
struct Menu menu,
bool  init 
)

Redraw the compose window.

Parameters
actxAttachment context
menuCurrent menu
initIf true, initialise the attachment list

Definition at line 282 of file dlg_compose.c.

283{
284 if (init)
285 {
286 gen_attach_list(actx, actx->email->body, -1, 0);
287 mutt_attach_init(actx);
288
289 struct ComposeAttachData *adata = menu->mdata;
290 adata->actx = actx;
291 }
292
294
295 menu->max = actx->vcount;
296 if (menu->max)
297 {
298 int index = menu_get_index(menu);
299 if (index >= menu->max)
301 }
302 else
303 {
305 }
306
308}
#define MENU_REDRAW_INDEX
Redraw the index.
Definition: lib.h:56
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:184
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:160
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:174
void mutt_attach_init(struct AttachCtx *actx)
Create a new Attachment context.
Definition: recvattach.c:1189
void mutt_update_tree(struct AttachCtx *actx)
Refresh the list of attachments.
Definition: recvattach.c:122
short vcount
The number of virtual attachments.
Definition: attach.h:72
struct Email * email
Used by recvattach for updating.
Definition: attach.h:64
Data to fill the Compose Attach Window.
Definition: attach_data.h:33
struct Menu * menu
Menu displaying the attachments.
Definition: attach_data.h:35
struct AttachCtx * actx
Set of attachments.
Definition: attach_data.h:34
struct Body * body
List of MIME parts.
Definition: email.h:69
void * mdata
Private data.
Definition: lib.h:147
int max
Number of entries in the menu.
Definition: lib.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compose_dlg_init()

static struct MuttWindow * compose_dlg_init ( struct ConfigSubset sub,
struct Email e,
struct Buffer fcc 
)
static

Allocate the Windows for Compose.

Parameters
subConfigSubset
eEmail
fccBuffer to save FCC
Return values
ptrDialog containing nested Windows

Definition at line 317 of file dlg_compose.c.

319{
321 shared->sub = sub;
322 shared->email = e;
323
327 dlg->wdata = shared;
329 dlg->recalc = compose_recalc;
330
331 struct MuttWindow *win_env = env_window_new(e, fcc, sub);
332 struct MuttWindow *win_attach = attach_new(dlg, shared);
333 struct MuttWindow *win_cbar = cbar_new(shared);
334 struct MuttWindow *win_abar = sbar_new();
335 sbar_set_title(win_abar, _("-- Attachments"));
336 struct MuttWindow *win_preview_bar = sbar_new();
337 sbar_set_title(win_preview_bar, _("-- Preview"));
338 struct MuttWindow *win_preview = preview_window_new(e, win_preview_bar);
339
340 const bool c_preview_above_attachments = cs_subset_bool(shared->sub, "compose_preview_above_attachments");
341 const bool c_status_on_top = cs_subset_bool(sub, "status_on_top");
342 if (c_status_on_top)
343 {
344 mutt_window_add_child(dlg, win_cbar);
345 mutt_window_add_child(dlg, win_env);
346 if (c_preview_above_attachments)
347 {
348 mutt_window_add_child(dlg, win_preview_bar);
349 mutt_window_add_child(dlg, win_preview);
350 mutt_window_add_child(dlg, win_abar);
351 mutt_window_add_child(dlg, win_attach);
352 }
353 else
354 {
355 mutt_window_add_child(dlg, win_abar);
356 mutt_window_add_child(dlg, win_attach);
357 mutt_window_add_child(dlg, win_preview_bar);
358 mutt_window_add_child(dlg, win_preview);
359 }
360 }
361 else
362 {
363 mutt_window_add_child(dlg, win_env);
364 if (c_preview_above_attachments)
365 {
366 mutt_window_add_child(dlg, win_preview_bar);
367 mutt_window_add_child(dlg, win_preview);
368 mutt_window_add_child(dlg, win_abar);
369 mutt_window_add_child(dlg, win_attach);
370 }
371 else
372 {
373 mutt_window_add_child(dlg, win_abar);
374 mutt_window_add_child(dlg, win_attach);
375 mutt_window_add_child(dlg, win_preview_bar);
376 mutt_window_add_child(dlg, win_preview);
377 }
378 mutt_window_add_child(dlg, win_cbar);
379 }
380
381 shared->win_preview_bar = win_preview_bar;
382 shared->win_preview = win_preview;
383 shared->win_attach_bar = win_abar;
384
385 dlg->help_data = ComposeHelp;
386 dlg->help_menu = MENU_COMPOSE;
387
388 return dlg;
389}
struct MuttWindow * cbar_new(struct ComposeSharedData *shared)
Create the Compose Bar (status)
Definition: cbar.c:226
struct MuttWindow * attach_new(struct MuttWindow *parent, struct ComposeSharedData *shared)
Create the Attachments Menu.
Definition: attach.c:267
struct ComposeSharedData * compose_shared_data_new(void)
Free the compose shared data.
Definition: shared_data.c:48
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
static const struct Mapping ComposeHelp[]
Help Bar for the Compose dialog.
Definition: dlg_compose.c:93
struct MuttWindow * env_window_new(struct Email *e, struct Buffer *fcc, struct ConfigSubset *sub)
Create the Envelope Window.
Definition: window.c:944
static int compose_recalc(struct MuttWindow *dlg)
Recalculate the Window data - Implements MuttWindow::recalc() -.
Definition: dlg_compose.c:127
void compose_shared_data_free(struct MuttWindow *win, void **ptr)
Free the compose shared data - Implements MuttWindow::wdata_free() -.
Definition: shared_data.c:36
#define _(a)
Definition: message.h:28
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:446
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
Definition: mutt_window.c:182
@ WT_DLG_COMPOSE
Compose Dialog, dlg_compose()
Definition: mutt_window.h:83
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:39
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:53
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:49
struct MuttWindow * preview_window_new(struct Email *e, struct MuttWindow *bar)
Create the preview window.
Definition: preview.c:339
struct MuttWindow * sbar_new(void)
Add the Simple Bar (status)
Definition: sbar.c:203
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:227
Shared Compose Data.
Definition: shared_data.h:36
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:37
struct MuttWindow * win_preview
Message preview window.
Definition: shared_data.h:42
struct MuttWindow * win_preview_bar
Status bar divider above preview.
Definition: shared_data.h:43
struct Email * email
Email being composed.
Definition: shared_data.h:39
struct MuttWindow * win_attach_bar
Status bar divider above attachments.
Definition: shared_data.h:41
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:142
void * wdata
Private data.
Definition: mutt_window.h:145
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:173
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:159
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:141
@ MENU_COMPOSE
Compose an email.
Definition: type.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ ComposeHelp

const struct Mapping ComposeHelp[]
static
Initial value:
= {
{ N_("Send"), OP_COMPOSE_SEND_MESSAGE },
{ N_("Abort"), OP_EXIT },
{ N_("To"), OP_ENVELOPE_EDIT_TO },
{ N_("CC"), OP_ENVELOPE_EDIT_CC },
{ N_("Subj"), OP_ENVELOPE_EDIT_SUBJECT },
{ N_("Attach file"), OP_ATTACHMENT_ATTACH_FILE },
{ N_("Descrip"), OP_ATTACHMENT_EDIT_DESCRIPTION },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}
#define N_(a)
Definition: message.h:32

Help Bar for the Compose dialog.

Definition at line 93 of file dlg_compose.c.

◆ ComposeNewsHelp

const struct Mapping ComposeNewsHelp[]
static
Initial value:
= {
{ N_("Send"), OP_COMPOSE_SEND_MESSAGE },
{ N_("Abort"), OP_EXIT },
{ N_("Newsgroups"), OP_ENVELOPE_EDIT_NEWSGROUPS },
{ N_("Subj"), OP_ENVELOPE_EDIT_SUBJECT },
{ N_("Attach file"), OP_ATTACHMENT_ATTACH_FILE },
{ N_("Descrip"), OP_ATTACHMENT_EDIT_DESCRIPTION },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}

Help Bar for the News Compose dialog.

Definition at line 111 of file dlg_compose.c.