NeoMutt  2023-05-17-56-ga67199
Teaching an old dog new tricks
DOXYGEN
rootwin.c
Go to the documentation of this file.
1
92#include "config.h"
93#include <stdbool.h>
94#include <string.h>
95#include "mutt/lib.h"
96#include "config/lib.h"
97#include "core/lib.h"
98#include "helpbar/lib.h"
99#include "dialog.h"
100#include "msgcont.h"
101#include "msgwin.h"
102#include "mutt_window.h"
103
104struct MuttWindow *RootWindow = NULL;
105
112{
113 if (nc->event_type != NT_CONFIG)
114 return 0;
115 if (!nc->global_data || !nc->event_data)
116 return -1;
117
118 struct EventConfig *ev_c = nc->event_data;
119 struct MuttWindow *win_root = nc->global_data;
120
121 if (!mutt_str_equal(ev_c->name, "status_on_top"))
122 return 0;
123
124 struct MuttWindow *first = TAILQ_FIRST(&win_root->children);
125 if (!first)
126 return 0;
127
128 const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
129 if ((c_status_on_top && (first->type == WT_HELP_BAR)) ||
130 (!c_status_on_top && (first->type != WT_HELP_BAR)))
131 {
132 // Swap the HelpBar and the AllDialogsWindow
133 struct MuttWindow *next = TAILQ_NEXT(first, entries);
134 if (!next)
135 return 0;
136 TAILQ_REMOVE(&win_root->children, next, entries);
137 TAILQ_INSERT_HEAD(&win_root->children, next, entries);
138
139 mutt_window_reflow(win_root);
140 mutt_debug(LL_DEBUG5, "config done, request WA_REFLOW\n");
141 }
142
143 return 0;
144}
145
154{
155 if (nc->event_type != NT_WINDOW)
156 return 0;
157 if (!nc->global_data || !nc->event_data)
158 return -1;
160 return 0;
161
162 struct MuttWindow *win_root = nc->global_data;
163 struct EventWindow *ev_w = nc->event_data;
164 if (ev_w->win != win_root)
165 return 0;
166
168 if (NeoMutt)
170
171 mutt_debug(LL_DEBUG5, "window delete done\n");
172 return 0;
173}
174
178void rootwin_free(void)
179{
181}
182
188void rootwin_new(void)
189{
191 MUTT_WIN_SIZE_FIXED, 0, 0);
193 RootWindow = win_root;
194
195 struct MuttWindow *win_helpbar = helpbar_new();
196 struct MuttWindow *win_alldlgs = alldialogs_new();
197
198 const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
199 if (c_status_on_top)
200 {
201 mutt_window_add_child(win_root, win_alldlgs);
202 mutt_window_add_child(win_root, win_helpbar);
203 }
204 else
205 {
206 mutt_window_add_child(win_root, win_helpbar);
207 mutt_window_add_child(win_root, win_alldlgs);
208 }
209
210 struct MuttWindow *win_cont = msgcont_new();
211 struct MuttWindow *win_msg = msgwin_new();
212 mutt_window_add_child(win_cont, win_msg);
213 mutt_window_add_child(win_root, win_cont);
214
217}
218
226void rootwin_set_size(int cols, int rows)
227{
228 if (!RootWindow)
229 return;
230
231 bool changed = false;
232
233 if (RootWindow->state.rows != rows)
234 {
235 RootWindow->state.rows = rows;
236 changed = true;
237 }
238
239 if (RootWindow->state.cols != cols)
240 {
241 RootWindow->state.cols = cols;
242 changed = true;
243 }
244
245 if (changed)
246 {
248 }
249}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
struct MuttWindow * alldialogs_new(void)
Create the AllDialogs Window.
Definition: dialog.c:206
Dialog Windows.
#define mutt_debug(LEVEL,...)
Definition: logging2.h:87
static int rootwin_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: rootwin.c:111
static int rootwin_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: rootwin.c:153
Help Bar Convenience wrapper for the Help Bar headers.
struct MuttWindow * helpbar_new(void)
Create the Help Bar Window.
Definition: helpbar.c:333
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
struct MuttWindow * msgcont_new(void)
Create a new Message Container.
Definition: msgcont.c:45
Message Window.
struct MuttWindow * msgwin_new(void)
Create the Message Window.
Definition: msgwin.c:197
Message Window.
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: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
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:93
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:798
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:341
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:440
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
Window management.
@ WT_ROOT
Parent of All Windows.
Definition: mutt_window.h:72
@ WT_HELP_BAR
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:96
@ 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:205
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition: mutt_window.h:47
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
#define TAILQ_FIRST(head)
Definition: queue.h:723
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:841
#define TAILQ_NEXT(elm, field)
Definition: queue.h:832
#define TAILQ_INSERT_HEAD(head, elm, field)
Definition: queue.h:796
void rootwin_free(void)
Free all the default Windows.
Definition: rootwin.c:178
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition: rootwin.c:226
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: rootwin.c:104
void rootwin_new(void)
Create the default Windows.
Definition: rootwin.c:188
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:215
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:216
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:136
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
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
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61