NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
ipanel.c File Reference

Index Panel. More...

#include "config.h"
#include <stdbool.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "ibar.h"
#include "private_data.h"
+ Include dependency graph for ipanel.c:

Go to the source code of this file.

Functions

static int ipanel_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t. More...
 
static int ipanel_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t. More...
 
struct MuttWindowipanel_new (bool status_on_top, struct IndexSharedData *shared)
 Create the Windows for the Index panel. More...
 

Detailed Description

Index Panel.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file ipanel.c.

Function Documentation

◆ ipanel_config_observer()

static int ipanel_config_observer ( struct NotifyCallback nc)
static

Notification that a Config Variable has changed - Implements observer_t.

Definition at line 74 of file ipanel.c.

75 {
76  if ((nc->event_type != NT_CONFIG) || !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 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
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
Container for Accounts, Notifications.
Definition: neomutt.h:36
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
void * global_data
Data from notify_observer_add()
Definition: observer.h:45
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
void * event_data
Data from notify_send()
Definition: observer.h:44
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
Log at debug level 5.
Definition: logging.h:44
const char * name
Name of config item that changed.
Definition: subset.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ipanel_window_observer()

static int ipanel_window_observer ( struct NotifyCallback nc)
static

Notification that a Window has changed - Implements observer_t.

Definition at line 94 of file ipanel.c.

95 {
96  if ((nc->event_type != NT_WINDOW) || !nc->global_data || !nc->event_data)
97  return -1;
98 
100  return 0;
101 
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;
106 
108  notify_observer_remove(panel_index->notify, ipanel_window_observer, panel_index);
109  mutt_debug(LL_DEBUG5, "window delete done\n");
110 
111  return 0;
112 }
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
An Event that happened to a Window.
Definition: mutt_window.h:215
Window is about to be deleted.
Definition: mutt_window.h:206
Container for Accounts, Notifications.
Definition: neomutt.h:36
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
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 Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
void * global_data
Data from notify_observer_add()
Definition: observer.h:45
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
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
Log at debug level 5.
Definition: logging.h:44
static int ipanel_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t.
Definition: ipanel.c:94
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ipanel_new()

struct MuttWindow* ipanel_new ( bool  status_on_top,
struct IndexSharedData shared 
)

Create the Windows for the Index panel.

Parameters
status_on_toptrue, if the Index bar should be on top
sharedShared Index data
Return values
ptrNew Index Panel

Definition at line 120 of file ipanel.c.

121 {
122  struct MuttWindow *panel_index =
125 
126  struct IndexPrivateData *priv = index_private_data_new(shared);
127  panel_index->wdata = priv;
128  panel_index->wdata_free = index_private_data_free;
129 
130  struct MuttWindow *win_index = index_window_new(shared, priv);
131  panel_index->focus = win_index;
132 
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  }
144 
146  notify_observer_add(panel_index->notify, NT_WINDOW, ipanel_window_observer, panel_index);
147 
148  return panel_index;
149 }
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:160
Private state data for the Index.
Definition: private_data.h:34
Window uses all available vertical space.
Definition: mutt_window.h:38
struct MuttWindow * index_window_new(struct IndexSharedData *shared, struct IndexPrivateData *priv)
Create a new Index Window (list of Emails)
Definition: index.c:416
Container for Accounts, Notifications.
Definition: neomutt.h:36
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
A panel containing the Index Window.
Definition: mutt_window.h:97
struct MuttWindow * focus
Focussed Window.
Definition: mutt_window.h:140
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
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
struct IndexPrivateData * index_private_data_new(struct IndexSharedData *shared)
Create new Index Data.
Definition: private_data.c:52
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:52
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
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
static int ipanel_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t.
Definition: ipanel.c:74
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 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
static int ipanel_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t.
Definition: ipanel.c:94
+ Here is the call graph for this function:
+ Here is the caller graph for this function: