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

GUI display the mailboxes in a side panel. More...

#include <stdbool.h>
#include <stdint.h>
#include "mutt_commands.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void sb_init (void)
 Set up the Sidebar. More...
 
void sb_shutdown (void)
 Clean up the Sidebar. More...
 
void sb_change_mailbox (struct MuttWindow *win, int op)
 Perform a Sidebar function. More...
 
struct Mailboxsb_get_highlight (struct MuttWindow *win)
 Get the Mailbox that's highlighted in the sidebar. More...
 
enum CommandResult sb_parse_unwhitelist (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsidebar_whitelist' command - Implements Command::parse() -. More...
 
enum CommandResult sb_parse_whitelist (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'sidebar_whitelist' command - Implements Command::parse() -. More...
 

Detailed Description

GUI display the mailboxes in a side panel.

Authors
  • Justin Hibbits
  • Thomer M. Gil
  • 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 lib.h.

Function Documentation

◆ sb_init()

void sb_init ( void  )

Set up the Sidebar.

Definition at line 191 of file sidebar.c.

192 {
194 
195  // Listen for dialog creation events
198 }
#define COMMANDS_REGISTER(cmds)
Definition: mutt_commands.h:82
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:53
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 MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition: dialog.c:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_shutdown()

void sb_shutdown ( void  )

Clean up the Sidebar.

Definition at line 203 of file sidebar.c.

204 {
205  if (AllDialogsWindow)
208 }
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
struct MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition: dialog.c:76
bool notify_observer_remove(struct Notify *notify, observer_t callback, void *global_data)
Remove an observer from an object.
Definition: notify.c:228
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_change_mailbox()

void sb_change_mailbox ( struct MuttWindow win,
int  op 
)

Perform a Sidebar function.

Parameters
winSidebar Window
opOperation to perform, e.g. OP_SIDEBAR_NEXT_NEW

Definition at line 266 of file functions.c.

267 {
268  if (!mutt_window_is_visible(win))
269  return;
270 
271  struct SidebarWindowData *wdata = sb_wdata_get(win);
272  if (!wdata)
273  return;
274 
275  if (wdata->hil_index < 0) /* It'll get reset on the next draw */
276  return;
277 
278  bool changed = false;
279  const bool c_sidebar_next_new_wrap =
280  cs_subset_bool(NeoMutt->sub, "sidebar_next_new_wrap");
281  switch (op)
282  {
283  case OP_SIDEBAR_FIRST:
284  changed = select_first(wdata);
285  break;
286  case OP_SIDEBAR_LAST:
287  changed = select_last(wdata);
288  break;
289  case OP_SIDEBAR_NEXT:
290  changed = select_next(wdata);
291  break;
292  case OP_SIDEBAR_NEXT_NEW:
293  changed = select_next_new(wdata, c_sidebar_next_new_wrap);
294  break;
295  case OP_SIDEBAR_PAGE_DOWN:
296  changed = select_page_down(wdata);
297  break;
298  case OP_SIDEBAR_PAGE_UP:
299  changed = select_page_up(wdata);
300  break;
301  case OP_SIDEBAR_PREV:
302  changed = select_prev(wdata);
303  break;
304  case OP_SIDEBAR_PREV_NEW:
305  changed = select_prev_new(wdata, c_sidebar_next_new_wrap);
306  break;
307  default:
308  return;
309  }
310  if (changed)
311  win->actions |= WA_RECALC;
312 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
Sidebar private Window data -.
Definition: private.h:62
int hil_index
Highlighted mailbox.
Definition: private.h:69
Container for Accounts, Notifications.
Definition: neomutt.h:36
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:529
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
void * wdata
Private data.
Definition: mutt_window.h:145
#define WA_RECALC
Recalculate the contents of the Window.
Definition: mutt_window.h:110
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_get_highlight()

struct Mailbox* sb_get_highlight ( struct MuttWindow win)

Get the Mailbox that's highlighted in the sidebar.

Parameters
winSidebar Window
Return values
ptrMailbox

Definition at line 58 of file sidebar.c.

59 {
60  const bool c_sidebar_visible =
61  cs_subset_bool(NeoMutt->sub, "sidebar_visible");
62  if (!c_sidebar_visible)
63  return NULL;
64 
65  struct SidebarWindowData *wdata = sb_wdata_get(win);
66  if (wdata->hil_index < 0)
67  return NULL;
68 
69  struct SbEntry **sbep = ARRAY_GET(&wdata->entries, wdata->hil_index);
70  if (!sbep)
71  return NULL;
72 
73  return (*sbep)->mailbox;
74 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:105
Sidebar private Window data -.
Definition: private.h:62
Info about folders in the sidebar.
Definition: private.h:39
int hil_index
Highlighted mailbox.
Definition: private.h:69
Container for Accounts, Notifications.
Definition: neomutt.h:36
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
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: