NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
lib.h File Reference
#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 188 of file sidebar.c.

189 {
191 
192  // Listen for dialog creation events
194 }
+ 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 199 of file sidebar.c.

+ 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  const bool c_sidebar_next_new_wrap =
279  cs_subset_bool(NeoMutt->sub, "sidebar_next_new_wrap");
280  switch (op)
281  {
282  case OP_SIDEBAR_FIRST:
283  changed = select_first(wdata);
284  break;
285  case OP_SIDEBAR_LAST:
286  changed = select_last(wdata);
287  break;
288  case OP_SIDEBAR_NEXT:
289  changed = select_next(wdata);
290  break;
291  case OP_SIDEBAR_NEXT_NEW:
292  changed = select_next_new(wdata, c_sidebar_next_new_wrap);
293  break;
294  case OP_SIDEBAR_PAGE_DOWN:
295  changed = select_page_down(wdata);
296  break;
297  case OP_SIDEBAR_PAGE_UP:
298  changed = select_page_up(wdata);
299  break;
300  case OP_SIDEBAR_PREV:
301  changed = select_prev(wdata);
302  break;
303  case OP_SIDEBAR_PREV_NEW:
304  changed = select_prev_new(wdata, c_sidebar_next_new_wrap);
305  break;
306  default:
307  return;
308  }
309  if (changed)
310  win->actions |= WA_RECALC;
311 }
+ 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  const bool c_sidebar_visible =
59  cs_subset_bool(NeoMutt->sub, "sidebar_visible");
60  if (!c_sidebar_visible)
61  return NULL;
62 
63  struct SidebarWindowData *wdata = sb_wdata_get(win);
64  if (wdata->hil_index < 0)
65  return NULL;
66 
67  struct SbEntry **sbep = ARRAY_GET(&wdata->entries, wdata->hil_index);
68  if (!sbep)
69  return NULL;
70 
71  return (*sbep)->mailbox;
72 }
+ 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_buffer_string(path), "*"))
71  {
73  break;
74  }
77  } while (MoreArgs(s));
79 
80  return MUTT_CMD_SUCCESS;
81 }
+ 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 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:
MUTT_TOKEN_BACKTICK_VARS
#define MUTT_TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: mutt.h:78
MoreArgs
#define MoreArgs(buf)
Definition: buffer.h:40
Buffer
String manipulation buffer.
Definition: buffer.h:33
WA_RECALC
#define WA_RECALC
Recalculate the contents of the Window.
Definition: mutt_window.h:107
cs_subset_bool
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:69
sb_wdata_get
struct SidebarWindowData * sb_wdata_get(struct MuttWindow *win)
Get the Sidebar data for this window.
Definition: wdata.c:70
AllDialogsWindow
struct MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition: mutt_window.c:46
select_first
static bool select_first(struct SidebarWindowData *wdata)
Selects the first unhidden mailbox.
Definition: functions.c:226
select_next
bool select_next(struct SidebarWindowData *wdata)
Selects the next unhidden mailbox.
Definition: functions.c:44
SidebarWindowData
Sidebar private Window data -.
Definition: private.h:61
mutt_buffer_pool_release
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
SidebarWhitelist
struct ListHead SidebarWhitelist
List of mailboxes to always display in the sidebar.
Definition: sidebar.c:42
select_next_new
static bool select_next_new(struct SidebarWindowData *wdata, bool next_new_wrap)
Selects the next new mailbox.
Definition: functions.c:89
ARRAY_GET
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:105
select_prev
bool select_prev(struct SidebarWindowData *wdata)
Selects the previous unhidden mailbox.
Definition: functions.c:112
NT_WINDOW
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:43
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
sb_commands
static const struct Command sb_commands[]
Definition: sidebar.c:44
mutt_extract_token
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:393
mutt_buffer_pool_get
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
MuttWindow::notify
struct Notify * notify
Notifications system.
Definition: mutt_window.h:131
mutt_window_is_visible
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:657
add_to_stailq
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition: muttlib.c:1704
notify_observer_remove
bool notify_observer_remove(struct Notify *notify, observer_t callback, void *global_data)
Remove an observer from an object.
Definition: notify.c:207
MuttWindow::actions
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:125
select_last
static bool select_last(struct SidebarWindowData *wdata)
Selects the last unhidden mailbox.
Definition: functions.c:246
select_prev_new
static bool select_prev_new(struct SidebarWindowData *wdata, bool next_new_wrap)
Selects the previous new mailbox.
Definition: functions.c:161
MUTT_CMD_SUCCESS
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition: mutt_commands.h:38
SidebarWhitelist
struct ListHead SidebarWhitelist
List of mailboxes to always display in the sidebar.
Definition: sidebar.c:42
notify_observer_add
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
mutt_buffer_expand_path
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:323
mutt_buffer_string
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
select_page_down
static bool select_page_down(struct SidebarWindowData *wdata)
Selects the first entry in the next page of mailboxes.
Definition: functions.c:184
NeoMutt
Container for Accounts, Notifications.
Definition: neomutt.h:36
remove_from_stailq
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition: muttlib.c:1729
select_page_up
static bool select_page_up(struct SidebarWindowData *wdata)
Selects the last entry in the previous page of mailboxes.
Definition: functions.c:205
SidebarWindowData::hil_index
int hil_index
Highlighted mailbox.
Definition: private.h:67
SbEntry
Info about folders in the sidebar.
Definition: private.h:38
NeoMutt::sub
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
sb_insertion_observer
int sb_insertion_observer(struct NotifyCallback *nc)
Listen for new Dialogs - Implements observer_t.
Definition: observer.c:442
mutt_list_free
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
COMMANDS_REGISTER
#define COMMANDS_REGISTER(cmds)
Definition: mutt_commands.h:77
MuttWindow::wdata
void * wdata
Private data.
Definition: mutt_window.h:138