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

Pager Panel. More...

#include "config.h"
#include <inttypes.h>
#include <stdbool.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "pbar.h"
#include "private_data.h"
+ Include dependency graph for ppanel.c:

Go to the source code of this file.

Functions

static int ppanel_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t. More...
 
static int ppanel_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t. More...
 
struct MuttWindowppanel_new (bool status_on_top, struct IndexSharedData *shared)
 Create the Windows for the Pager panel. More...
 

Detailed Description

Pager 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 ppanel.c.

Function Documentation

◆ ppanel_config_observer()

static int ppanel_config_observer ( struct NotifyCallback nc)
static

Notification that a Config Variable has changed - Implements observer_t.

Definition at line 75 of file ppanel.c.

76 {
77  if ((nc->event_type != NT_CONFIG) || !nc->global_data || !nc->event_data)
78  return -1;
79 
80  struct EventConfig *ev_c = nc->event_data;
81  struct MuttWindow *panel_pager = nc->global_data;
82 
83  if (mutt_str_equal(ev_c->name, "status_on_top"))
84  {
85  window_status_on_top(panel_pager, NeoMutt->sub);
86  mutt_debug(LL_DEBUG5, "config done\n");
87  }
88 
89  return 0;
90 }
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:

◆ ppanel_window_observer()

static int ppanel_window_observer ( struct NotifyCallback nc)
static

Notification that a Window has changed - Implements observer_t.

Definition at line 95 of file ppanel.c.

96 {
97  if ((nc->event_type != NT_WINDOW) || !nc->global_data || !nc->event_data)
98  return -1;
99 
100  if (nc->event_subtype != NT_WINDOW_DELETE)
101  return 0;
102 
103  struct MuttWindow *panel_pager = nc->global_data;
104  struct EventWindow *ev_w = nc->event_data;
105  if (ev_w->win != panel_pager)
106  return 0;
107 
109  notify_observer_remove(panel_pager->notify, ppanel_window_observer, panel_pager);
110  mutt_debug(LL_DEBUG5, "window delete done\n");
111 
112  return 0;
113 }
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
static int ppanel_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t.
Definition: ppanel.c:95
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
static int ppanel_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t.
Definition: ppanel.c:75
bool notify_observer_remove(struct Notify *notify, observer_t callback, void *global_data)
Remove an observer from an object.
Definition: notify.c:228
Log at debug level 5.
Definition: logging.h:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ppanel_new()

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

Create the Windows for the Pager panel.

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

Definition at line 121 of file ppanel.c.

122 {
123  struct MuttWindow *panel_pager =
126  panel_pager->state.visible = false; // The Pager and Pager Bar are initially hidden
127 
128  struct PagerPrivateData *priv = pager_private_data_new();
129  panel_pager->wdata = priv;
130  panel_pager->wdata_free = pager_private_data_free;
131 
132  struct MuttWindow *win_pager = pager_window_new(panel_pager, shared, priv);
133  panel_pager->focus = win_pager;
134 
135  struct MuttWindow *win_pbar = pbar_new(panel_pager, shared, priv);
136  if (status_on_top)
137  {
138  mutt_window_add_child(panel_pager, win_pbar);
139  mutt_window_add_child(panel_pager, win_pager);
140  }
141  else
142  {
143  mutt_window_add_child(panel_pager, win_pager);
144  mutt_window_add_child(panel_pager, win_pbar);
145  }
146 
148  notify_observer_add(panel_pager->notify, NT_WINDOW, ppanel_window_observer, panel_pager);
149 
150  return panel_pager;
151 }
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:160
Window uses all available vertical space.
Definition: mutt_window.h:38
struct MuttWindow * pager_window_new(struct MuttWindow *parent, struct IndexSharedData *shared, struct PagerPrivateData *priv)
Create a new Pager Window (list of Emails)
Definition: pager.c:241
Container for Accounts, Notifications.
Definition: neomutt.h:36
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
Private state data for the Pager.
Definition: private_data.h:39
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
struct PagerPrivateData * pager_private_data_new(void)
Create new Pager Data.
Definition: private_data.c:52
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
bool visible
Window is visible.
Definition: mutt_window.h:59
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:52
static int ppanel_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t.
Definition: ppanel.c:95
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
A panel containing the Pager Window.
Definition: mutt_window.h:100
static int ppanel_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t.
Definition: ppanel.c:75
struct MuttWindow * pbar_new(struct MuttWindow *parent, struct IndexSharedData *shared, struct PagerPrivateData *priv)
Create the Pager Bar.
Definition: pbar.c:337
void pager_private_data_free(struct MuttWindow *win, void **ptr)
Free Pager Data.
Definition: private_data.c:38
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
void * wdata
Private data.
Definition: mutt_window.h:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function: