NeoMutt  2024-02-01-23-g345d7b
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
simple.c
Go to the documentation of this file.
1
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 "simple.h"
70#include "menu/lib.h"
71#include "dialog.h"
72#include "mutt_window.h"
73#include "sbar.h"
74
81{
82 if (nc->event_type != NT_CONFIG)
83 return 0;
84 if (!nc->global_data || !nc->event_data)
85 return -1;
86
87 struct EventConfig *ev_c = nc->event_data;
88 if (!mutt_str_equal(ev_c->name, "status_on_top"))
89 return 0;
90
91 struct MuttWindow *dlg = nc->global_data;
93 mutt_debug(LL_DEBUG5, "config done\n");
94 return 0;
95}
96
105{
106 if (nc->event_type != NT_WINDOW)
107 return 0;
108 if (!nc->global_data || !nc->event_data)
109 return -1;
111 return 0;
112
113 struct MuttWindow *dlg = nc->global_data;
114 struct EventWindow *ev_w = nc->event_data;
115 if (ev_w->win != dlg)
116 return 0;
117
120
121 mutt_debug(LL_DEBUG5, "window delete done\n");
122 return 0;
123}
124
132struct MuttWindow *simple_dialog_new(enum MenuType mtype, enum WindowType wtype,
133 const struct Mapping *help_data)
134{
138 dlg->help_menu = mtype;
139 dlg->help_data = help_data;
140
141 struct MuttWindow *win_menu = menu_window_new(mtype, NeoMutt->sub);
142 dlg->wdata = win_menu->wdata;
143
144 struct MuttWindow *win_sbar = sbar_new();
145 const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
146 if (c_status_on_top)
147 {
148 mutt_window_add_child(dlg, win_sbar);
149 mutt_window_add_child(dlg, win_menu);
150 }
151 else
152 {
153 mutt_window_add_child(dlg, win_menu);
154 mutt_window_add_child(dlg, win_sbar);
155 }
156
159 dialog_push(dlg);
160
161 return dlg;
162}
163
169{
170 if (!ptr || !*ptr)
171 return;
172
173 dialog_pop();
174 mutt_window_free(ptr);
175}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
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:109
void dialog_pop(void)
Hide a Window from the user.
Definition: dialog.c:142
Dialog Windows.
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int simple_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: simple.c:80
static int simple_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: simple.c:104
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:168
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:132
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
GUI present the user with a selectable list.
struct MuttWindow * menu_window_new(enum MenuType type, struct ConfigSubset *sub)
Create a new Menu Window.
Definition: window.c:140
Convenience wrapper for the library headers.
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition: notify.c:230
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:191
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:709
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:784
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:202
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
Window management.
WindowType
Type of Window.
Definition: mutt_window.h:70
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:38
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:229
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:52
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:48
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
struct MuttWindow * sbar_new(void)
Add the Simple Bar (status)
Definition: sbar.c:203
Simple Bar.
Simple Dialog Windows.
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition: subset.h:52
A config-change event.
Definition: subset.h:71
const char * name
Name of config item that changed.
Definition: subset.h:73
An Event that happened to a Window.
Definition: mutt_window.h:239
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:240
Mapping between user-readable string and a constant.
Definition: mapping.h:33
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:142
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:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
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
MenuType
Types of GUI selections.
Definition: type.h:36