NeoMutt  2022-04-29-215-gc12b98
Teaching an old dog new tricks
DOXYGEN
ipanel.c
Go to the documentation of this file.
1
57#include "config.h"
58#include <stdbool.h>
59#include "private.h"
60#include "mutt/lib.h"
61#include "config/lib.h"
62#include "core/lib.h"
63#include "gui/lib.h"
64#include "ibar.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_index = nc->global_data;
81
82 if (mutt_str_equal(ev_c->name, "status_on_top"))
83 {
84 window_status_on_top(panel_index, 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;
101 return 0;
102
103 struct MuttWindow *panel_index = nc->global_data;
104 struct EventWindow *ev_w = nc->event_data;
105 if (ev_w->win != panel_index)
106 return 0;
107
109 notify_observer_remove(panel_index->notify, ipanel_window_observer, panel_index);
110 mutt_debug(LL_DEBUG5, "window delete done\n");
111
112 return 0;
113}
114
121struct MuttWindow *ipanel_new(bool status_on_top, struct IndexSharedData *shared)
122{
126
128 panel_index->wdata = priv;
129 panel_index->wdata_free = index_private_data_free;
130
131 struct MuttWindow *win_index = index_window_new(priv);
132 panel_index->focus = win_index;
133
134 struct MuttWindow *win_ibar = ibar_new(panel_index, shared, priv);
135 if (status_on_top)
136 {
137 mutt_window_add_child(panel_index, win_ibar);
138 mutt_window_add_child(panel_index, win_index);
139 }
140 else
141 {
142 mutt_window_add_child(panel_index, win_index);
143 mutt_window_add_child(panel_index, win_ibar);
144 }
145
147 notify_observer_add(panel_index->notify, NT_WINDOW, ipanel_window_observer, panel_index);
148
149 return panel_index;
150}
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
static int ipanel_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: ipanel.c:72
static int ipanel_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: ipanel.c:94
void index_private_data_free(struct MuttWindow *win, void **ptr)
Free Private Index Data - Implements MuttWindow::wdata_free() -.
Definition: private_data.c:36
Convenience wrapper for the gui headers.
struct MuttWindow * ibar_new(struct MuttWindow *parent, struct IndexSharedData *shared, struct IndexPrivateData *priv)
Create the Index Bar (status)
Definition: ibar.c:331
Index Bar (status)
struct IndexPrivateData * index_private_data_new(struct IndexSharedData *shared)
Create new Index Data.
Definition: private_data.c:51
struct MuttWindow * index_window_new(struct IndexPrivateData *priv)
Create a new Index Window (list of Emails)
Definition: index.c:592
struct MuttWindow * ipanel_new(bool status_on_top, struct IndexSharedData *shared)
Create the Windows for the Index panel.
Definition: ipanel.c:121
@ LL_DEBUG5
Log at debug level 5.
Definition: logging.h:44
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
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:807
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:759
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:439
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
@ WT_INDEX
A panel containing the Index Window.
Definition: mutt_window.h:97
@ 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:206
#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:55
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
Private state data for the Pager.
GUI display the mailboxes in a side panel.
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
Private state data for the Index.
Definition: private_data.h:35
struct IndexSharedData * shared
Shared Index data.
Definition: private_data.h:42
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:37
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
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:160
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