NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
ppanel.c
Go to the documentation of this file.
1
57#include "config.h"
58#include <stdbool.h>
59#include "mutt/lib.h"
60#include "config/lib.h"
61#include "core/lib.h"
62#include "gui/lib.h"
63#include "lib.h"
64#include "pbar.h"
65#include "private_data.h"
66
67struct IndexSharedData;
68
73{
74 if (nc->event_type != NT_CONFIG)
75 return 0;
76 if (!nc->global_data || !nc->event_data)
77 return -1;
78
79 struct EventConfig *ev_c = nc->event_data;
80 struct MuttWindow *panel_pager = nc->global_data;
81
82 if (mutt_str_equal(ev_c->name, "status_on_top"))
83 {
84 window_status_on_top(panel_pager, NeoMutt->sub);
85 mutt_debug(LL_DEBUG5, "config done\n");
86 }
87
88 return 0;
89}
90
95{
96 if (nc->event_type != NT_WINDOW)
97 return 0;
98 if (!nc->global_data || !nc->event_data)
99 return -1;
100
101 struct MuttWindow *panel_pager = nc->global_data;
103 {
104 panel_pager->actions |= WA_RECALC | WA_REPAINT;
105
106 struct PagerPrivateData *priv = panel_pager->wdata;
107 if (priv->pview)
109
110 mutt_debug(LL_NOTIFY, "window state done, request WA_RECALC\n");
111 }
112
114 return 0;
115
116 struct EventWindow *ev_w = nc->event_data;
117 if (ev_w->win != panel_pager)
118 return 0;
119
121 notify_observer_remove(panel_pager->notify, ppanel_window_observer, panel_pager);
122 mutt_debug(LL_DEBUG5, "window delete done\n");
123
124 return 0;
125}
126
133struct MuttWindow *ppanel_new(bool status_on_top, struct IndexSharedData *shared)
134{
138 panel_pager->state.visible = false; // The Pager and Pager Bar are initially hidden
139
141 panel_pager->wdata = priv;
142 panel_pager->wdata_free = pager_private_data_free;
143
144 struct MuttWindow *win_pager = pager_window_new(shared, priv);
145 panel_pager->focus = win_pager;
146
147 struct MuttWindow *win_pbar = pbar_new(shared, priv);
148 if (status_on_top)
149 {
150 mutt_window_add_child(panel_pager, win_pbar);
151 mutt_window_add_child(panel_pager, win_pager);
152 }
153 else
154 {
155 mutt_window_add_child(panel_pager, win_pager);
156 mutt_window_add_child(panel_pager, win_pbar);
157 }
158
160 notify_observer_add(panel_pager->notify, NT_WINDOW, ppanel_window_observer, panel_pager);
161
162 return panel_pager;
163}
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
void pager_queue_redraw(struct PagerPrivateData *priv, PagerRedrawFlags redraw)
Queue a request for a redraw.
Definition: dlg_pager.c:127
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int ppanel_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: ppanel.c:72
static int ppanel_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: ppanel.c:94
Convenience wrapper for the gui headers.
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
@ LL_NOTIFY
Log of notifications.
Definition: logging2.h:48
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:660
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:783
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:445
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:181
#define WA_RECALC
Recalculate the contents of the Window.
Definition: mutt_window.h:109
@ WT_PAGER
A panel containing the Pager Window.
Definition: mutt_window.h:99
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:38
@ NT_WINDOW_STATE
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:229
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:228
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:110
#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
#define PAGER_REDRAW_PAGER
Redraw the pager.
Definition: lib.h:191
struct MuttWindow * pager_window_new(struct IndexSharedData *shared, struct PagerPrivateData *priv)
Create a new Pager Window (list of Emails)
Definition: pager.c:418
struct PagerPrivateData * pager_private_data_new(void)
Create new Pager Data.
Definition: private_data.c:59
void pager_private_data_free(struct MuttWindow *win, void **ptr)
Free Pager Data.
Definition: private_data.c:39
Private state data for the Pager.
struct MuttWindow * pbar_new(struct IndexSharedData *shared, struct PagerPrivateData *priv)
Create the Pager Bar.
Definition: pbar.c:331
Pager Bar.
struct MuttWindow * ppanel_new(bool status_on_top, struct IndexSharedData *shared)
Create the Windows for the Pager panel.
Definition: ppanel.c:133
Key value store.
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:238
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:239
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:37
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:126
struct MuttWindow * focus
Focused Window.
Definition: mutt_window.h:139
void * wdata
Private data.
Definition: mutt_window.h:144
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:137
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:158
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:131
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
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
Private state data for the Pager.
Definition: private_data.h:41
struct PagerView * pview
Object to view in the pager.
Definition: private_data.h:42
bool visible
Window is visible.
Definition: mutt_window.h:59