NeoMutt  2021-10-29-43-g6b8931
Teaching an old dog new tricks
Go to the documentation of this file.
64 #include "config.h"
65 #include <stdbool.h>
66 #include "mutt/lib.h"
67 #include "config/lib.h"
68 #include "core/lib.h"
69 #include "lib.h"
70 #include "menu/lib.h"
77 static int simple_config_observer(struct NotifyCallback *nc)
78 {
79  if ((nc->event_type != NT_CONFIG) || !nc->global_data || !nc->event_data)
80  return -1;
82  struct EventConfig *ev_c = nc->event_data;
83  if (!mutt_str_equal(ev_c->name, "status_on_top"))
84  return 0;
86  struct MuttWindow *dlg = nc->global_data;
88  mutt_debug(LL_DEBUG5, "config done\n");
89  return 0;
90 }
99 static int simple_window_observer(struct NotifyCallback *nc)
100 {
101  if ((nc->event_type != NT_WINDOW) || !nc->global_data || !nc->event_data)
102  return -1;
104  if (nc->event_subtype != NT_WINDOW_DELETE)
105  return 0;
107  struct MuttWindow *dlg = nc->global_data;
108  struct EventWindow *ev_w = nc->event_data;
109  if (ev_w->win != dlg)
110  return 0;
115  mutt_debug(LL_DEBUG5, "window delete done\n");
116  return 0;
117 }
126 struct MuttWindow *simple_dialog_new(enum MenuType mtype, enum WindowType wtype,
127  const struct Mapping *help_data)
128 {
129  struct MuttWindow *dlg =
132  dlg->help_menu = mtype;
133  dlg->help_data = help_data;
135  struct MuttWindow *win_index = menu_new_window(mtype, NeoMutt->sub);
136  dlg->focus = win_index;
137  dlg->wdata = win_index->wdata;
139  struct MuttWindow *win_sbar = sbar_new();
140  const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
141  if (c_status_on_top)
142  {
143  mutt_window_add_child(dlg, win_sbar);
144  mutt_window_add_child(dlg, win_index);
145  }
146  else
147  {
148  mutt_window_add_child(dlg, win_index);
149  mutt_window_add_child(dlg, win_sbar);
150  }
154  dialog_push(dlg);
156  return dlg;
157 }
163 void simple_dialog_free(struct MuttWindow **ptr)
164 {
165  if (!ptr || !*ptr)
166  return;
168  dialog_pop();
169  mutt_window_free(ptr);
170 }
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
Definition: dialog.c:103
void dialog_pop(void)
Hide a Window from the user.
Definition: dialog.c:137
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
static int simple_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: simple.c:77
static int simple_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: simple.c:99
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
Log at debug level 5.
Definition: logging.h:44
GUI present the user with a selectable list.
struct MuttWindow * menu_new_window(enum MenuType type, struct ConfigSubset *sub)
Create a new Menu Window.
Definition: window.c:122
Convenience wrapper for the library headers.
bool notify_observer_remove(struct Notify *notify, observer_t callback, void *global_data)
Remove an observer from an object.
Definition: notify.c:228
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
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:715
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:750
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:200
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:438
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
Type of Window.
Definition: mutt_window.h:70
Window uses all available vertical space.
Definition: mutt_window.h:38
Window is about to be deleted.
Definition: mutt_window.h:206
Use as much space as possible.
Definition: mutt_window.h:52
Window wants as much space as possible.
Definition: mutt_window.h:48
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:42
struct MuttWindow * sbar_new(void)
Add the Simple Bar (status)
Definition: sbar.c:195
Key value store.
A config-change event.
Definition: subset.h:70
const char * name
Name of config item that changed.
Definition: subset.h:72
An Event that happened to a Window.
Definition: mutt_window.h:216
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
Mapping between user-readable string and a constant.
Definition: mapping.h:32
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:142
struct MuttWindow * focus
Focused Window.
Definition: mutt_window.h:140
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:141
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 passed to a notification function.
Definition: observer.h:34
void * event_data
Data from notify_send()
Definition: observer.h:38
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:36
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:37
void * global_data
Data from notify_observer_add()
Definition: observer.h:39
Types of GUI selections.
Definition: type.h:36