NeoMutt  2020-09-25
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...
 
bool config_init_sidebar (struct ConfigSet *cs)
 Register sidebar config variables - Implements module_init_config_t. 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 189 of file sidebar.c.

190 {
192 
193  // Listen for dialog creation events
195 }
#define COMMANDS_REGISTER(cmds)
Definition: mutt_commands.h:77
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:42
struct Notify * notify
Notifications system.
Definition: mutt_window.h:131
int sb_insertion_observer(struct NotifyCallback *nc)
Listen for new Dialogs - Implements observer_t.
Definition: observer.c:429
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:169
struct MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition: mutt_window.c:46
+ 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 200 of file sidebar.c.

201 {
202  if (AllDialogsWindow)
205 }
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
struct Notify * notify
Notifications system.
Definition: mutt_window.h:131
int sb_insertion_observer(struct NotifyCallback *nc)
Listen for new Dialogs - Implements observer_t.
Definition: observer.c:429
struct MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition: mutt_window.c:46
bool notify_observer_remove(struct Notify *notify, observer_t callback, void *global_data)
Remove an observer from an object.
Definition: notify.c:207
+ 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 265 of file functions.c.

266 {
267  if (!mutt_window_is_visible(win))
268  return;
269 
270  struct SidebarWindowData *wdata = sb_wdata_get(win);
271  if (!wdata)
272  return;
273 
274  if (wdata->hil_index < 0) /* It'll get reset on the next draw */
275  return;
276 
277  bool changed = false;
278  switch (op)
279  {
280  case OP_SIDEBAR_FIRST:
281  changed = select_first(wdata);
282  break;
283  case OP_SIDEBAR_LAST:
284  changed = select_last(wdata);
285  break;
286  case OP_SIDEBAR_NEXT:
287  changed = select_next(wdata);
288  break;
289  case OP_SIDEBAR_NEXT_NEW:
290  changed = select_next_new(wdata, C_SidebarNextNewWrap);
291  break;
292  case OP_SIDEBAR_PAGE_DOWN:
293  changed = select_page_down(wdata);
294  break;
295  case OP_SIDEBAR_PAGE_UP:
296  changed = select_page_up(wdata);
297  break;
298  case OP_SIDEBAR_PREV:
299  changed = select_prev(wdata);
300  break;
301  case OP_SIDEBAR_PREV_NEW:
302  changed = select_prev_new(wdata, C_SidebarNextNewWrap);
303  break;
304  default:
305  return;
306  }
307  if (changed)
308  win->actions |= WA_RECALC;
309 }
Sidebar private Window data -.
Definition: private.h:62
int hil_index
Highlighted mailbox.
Definition: private.h:68
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:125
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:667
void * wdata
Private data.
Definition: mutt_window.h:138
#define WA_RECALC
Recalculate the contents of the Window.
Definition: mutt_window.h:107
+ 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 56 of file sidebar.c.

57 {
58  if (!C_SidebarVisible)
59  return NULL;
60 
61  struct SidebarWindowData *wdata = sb_wdata_get(win);
62  if (wdata->hil_index < 0)
63  return NULL;
64 
65  struct SbEntry **sbep = ARRAY_GET(&wdata->entries, wdata->hil_index);
66  if (!sbep)
67  return NULL;
68 
69  return (*sbep)->mailbox;
70 }
#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:38
int hil_index
Highlighted mailbox.
Definition: private.h:68
void * wdata
Private data.
Definition: mutt_window.h:138
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_parse_unwhitelist()

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()

Definition at line 61 of file commands.c.

63 {
64  struct Buffer *path = mutt_buffer_pool_get();
65 
66  do
67  {
69  /* Check for deletion of entire list */
70  if (mutt_str_equal(mutt_b2s(path), "*"))
71  {
73  break;
74  }
77  } while (MoreArgs(s));
79 
80  return MUTT_CMD_SUCCESS;
81 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
String manipulation buffer.
Definition: buffer.h:33
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
#define MoreArgs(buf)
Definition: buffer.h:43
#define mutt_b2s(buf)
Definition: buffer.h:41
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: muttlib.c:1725
Success: Command worked.
Definition: mutt_commands.h:38
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:323
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sb_parse_whitelist()

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()

Definition at line 42 of file commands.c.

44 {
45  struct Buffer *path = mutt_buffer_pool_get();
46 
47  do
48  {
52  } while (MoreArgs(s));
54 
55  return MUTT_CMD_SUCCESS;
56 }
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
String manipulation buffer.
Definition: buffer.h:33
#define MoreArgs(buf)
Definition: buffer.h:43
#define mutt_b2s(buf)
Definition: buffer.h:41
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: muttlib.c:1700
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:394
Success: Command worked.
Definition: mutt_commands.h:38
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:323
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ config_init_sidebar()

bool config_init_sidebar ( struct ConfigSet cs)

Register sidebar config variables - Implements module_init_config_t.

Definition at line 122 of file config.c.

123 {
124  return cs_register_variables(cs, SidebarVars, 0);
125 }
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[], int flags)
Register a set of config items.
Definition: set.c:286
+ Here is the call graph for this function: