NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
Go to the documentation of this file.
66 #include "config.h"
67 #include <stdbool.h>
68 #include "mutt/lib.h"
69 #include "config/lib.h"
70 #include "core/lib.h"
71 #include "lib.h"
72 #include "menu/lib.h"
79 static int simple_config_observer(struct NotifyCallback *nc)
80 {
81  if ((nc->event_type != NT_CONFIG) || !nc->global_data || !nc->event_data)
82  return -1;
84  struct EventConfig *ev_c = nc->event_data;
85  if (!mutt_str_equal(ev_c->name, "status_on_top"))
86  return 0;
88  struct MuttWindow *dlg = nc->global_data;
90  mutt_debug(LL_DEBUG5, "config done\n");
91  return 0;
92 }
102 {
103  if ((nc->event_type != NT_WINDOW) || !nc->global_data || !nc->event_data)
104  return -1;
106  if (nc->event_subtype != NT_WINDOW_DELETE)
107  return 0;
109  struct MuttWindow *dlg = nc->global_data;
110  struct EventWindow *ev_w = nc->event_data;
111  if (ev_w->win != dlg)
112  return 0;
117  mutt_debug(LL_DEBUG5, "window delete done\n");
118  return 0;
119 }
128 struct MuttWindow *simple_dialog_new(enum MenuType mtype, enum WindowType wtype,
129  const struct Mapping *help_data)
130 {
131  struct MuttWindow *dlg =
134  dlg->help_menu = mtype;
135  dlg->help_data = help_data;
137  struct MuttWindow *win_index = menu_new_window(mtype, NeoMutt->sub);
138  dlg->focus = win_index;
139  dlg->wdata = win_index->wdata;
141  struct MuttWindow *win_sbar = sbar_new(dlg);
142  const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
143  if (c_status_on_top)
144  {
145  mutt_window_add_child(dlg, win_sbar);
146  mutt_window_add_child(dlg, win_index);
147  }
148  else
149  {
150  mutt_window_add_child(dlg, win_index);
151  mutt_window_add_child(dlg, win_sbar);
152  }
156  dialog_push(dlg);
158  return dlg;
159 }
165 void simple_dialog_free(struct MuttWindow **ptr)
166 {
167  if (!ptr || !*ptr)
168  return;
170  dialog_pop();
171  mutt_window_free(ptr);
172 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
Types of GUI selections.
Definition: type.h:35
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:165
Data passed to a notification function.
Definition: observer.h:39
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
An Event that happened to a Window.
Definition: mutt_window.h:215
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:141
Window uses all available vertical space.
Definition: mutt_window.h:38
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:780
static int simple_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t.
Definition: simple.c:101
struct MuttWindow * sbar_new(struct MuttWindow *parent)
Add the Simple Bar (status)
Definition: sbar.c:197
Type of Window.
Definition: mutt_window.h:69
A config-change event.
Definition: subset.h:69
Window is about to be deleted.
Definition: mutt_window.h:206
Container for Accounts, Notifications.
Definition: neomutt.h:36
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
Convenience wrapper for the config headers.
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:200
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:43
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
struct MuttWindow * focus
Focussed Window.
Definition: mutt_window.h:140
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
Convenience wrapper for the core headers.
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
Definition: dialog.c:105
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 * global_data
Data from notify_observer_add()
Definition: observer.h:45
static int simple_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t.
Definition: simple.c:79
Use as much space as possible.
Definition: mutt_window.h:52
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:142
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
void * event_data
Data from notify_send()
Definition: observer.h:44
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:468
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:42
void dialog_pop(void)
Hide a Window from the user.
Definition: dialog.c:139
Mapping between user-readable string and a constant.
Definition: mapping.h:31
bool notify_observer_remove(struct Notify *notify, observer_t callback, void *global_data)
Remove an observer from an object.
Definition: notify.c:228
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:128
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
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:180
Log at debug level 5.
Definition: logging.h:44
Convenience wrapper for the library headers.
Window wants as much space as possible.
Definition: mutt_window.h:48
void * wdata
Private data.
Definition: mutt_window.h:145
const char * name
Name of config item that changed.
Definition: subset.h:72