NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
Go to the documentation of this file.
59 #include "config.h"
60 #include <stdbool.h>
61 #include "private.h"
62 #include "mutt/lib.h"
63 #include "config/lib.h"
64 #include "core/lib.h"
65 #include "gui/lib.h"
66 #include "ibar.h"
67 #include "private_data.h"
69 struct IndexSharedData;
74 static int ipanel_config_observer(struct NotifyCallback *nc)
75 {
76  if ((nc->event_type != NT_CONFIG) || !nc->global_data || !nc->event_data)
77  return -1;
79  struct EventConfig *ev_c = nc->event_data;
80  struct MuttWindow *panel_index = nc->global_data;
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  }
88  return 0;
89 }
94 static int ipanel_window_observer(struct NotifyCallback *nc)
95 {
96  if ((nc->event_type != NT_WINDOW) || !nc->global_data || !nc->event_data)
97  return -1;
100  return 0;
102  struct MuttWindow *panel_index = nc->global_data;
103  struct EventWindow *ev_w = nc->event_data;
104  if (ev_w->win != panel_index)
105  return 0;
108  notify_observer_remove(panel_index->notify, ipanel_window_observer, panel_index);
109  mutt_debug(LL_DEBUG5, "window delete done\n");
111  return 0;
112 }
120 struct MuttWindow *ipanel_new(bool status_on_top, struct IndexSharedData *shared)
121 {
122  struct MuttWindow *panel_index =
126  struct IndexPrivateData *priv = index_private_data_new(shared);
127  panel_index->wdata = priv;
128  panel_index->wdata_free = index_private_data_free;
130  struct MuttWindow *win_index = index_window_new(shared, priv);
131  panel_index->focus = win_index;
133  struct MuttWindow *win_ibar = ibar_new(panel_index, shared, priv);
134  if (status_on_top)
135  {
136  mutt_window_add_child(panel_index, win_ibar);
137  mutt_window_add_child(panel_index, win_index);
138  }
139  else
140  {
141  mutt_window_add_child(panel_index, win_index);
142  mutt_window_add_child(panel_index, win_ibar);
143  }
146  notify_observer_add(panel_index->notify, NT_WINDOW, ipanel_window_observer, panel_index);
148  return panel_index;
149 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
Convenience wrapper for the gui headers.
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:160
Data passed to a notification function.
Definition: observer.h:39
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
An Event that happened to a Window.
Definition: mutt_window.h:215
Private state data for the Index.
Definition: private_data.h:34
Window uses all available vertical space.
Definition: mutt_window.h:38
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:780
A config-change event.
Definition: subset.h:69
struct MuttWindow * index_window_new(struct IndexSharedData *shared, struct IndexPrivateData *priv)
Create a new Index Window (list of Emails)
Definition: index.c:416
Private state data for the Index.
Window is about to be deleted.
Definition: mutt_window.h:206
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:36
Container for Accounts, Notifications.
Definition: neomutt.h:36
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
Convenience wrapper for the config headers.
A panel containing the Index Window.
Definition: mutt_window.h:97
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:43
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
struct MuttWindow * focus
Focussed Window.
Definition: mutt_window.h:140
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
Convenience wrapper for the core headers.
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 index_private_data_free(struct MuttWindow *win, void **ptr)
Free Index Data.
Definition: private_data.c:38
void * global_data
Data from notify_observer_add()
Definition: observer.h:45
struct IndexPrivateData * index_private_data_new(struct IndexSharedData *shared)
Create new Index Data.
Definition: private_data.c:52
Use as much space as possible.
Definition: mutt_window.h:52
struct MuttWindow * ipanel_new(bool status_on_top, struct IndexSharedData *shared)
Create the Windows for the Index panel.
Definition: ipanel.c:120
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
void * event_data
Data from notify_send()
Definition: observer.h:44
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:468
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:42
Index Bar (status)
bool notify_observer_remove(struct Notify *notify, observer_t callback, void *global_data)
Remove an observer from an object.
Definition: notify.c:228
static int ipanel_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t.
Definition: ipanel.c:74
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
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
Log at debug level 5.
Definition: logging.h:44
Convenience wrapper for the library headers.
Window wants as much space as possible.
Definition: mutt_window.h:48
struct MuttWindow * ibar_new(struct MuttWindow *parent, struct IndexSharedData *shared, struct IndexPrivateData *priv)
Create the Index Bar (status)
Definition: ibar.c:333
void * wdata
Private data.
Definition: mutt_window.h:145
const char * name
Name of config item that changed.
Definition: subset.h:72
static int ipanel_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t.
Definition: ipanel.c:94
Private Index Functions.