NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
module.c File Reference

Definition of the Sidebar Module. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/module_data.h"
#include "lib.h"
#include "module_data.h"
+ Include dependency graph for module.c:

Go to the source code of this file.

Functions

static bool sidebar_init (struct NeoMutt *n)
 Initialise a Module - Implements Module::init()
 
static bool sidebar_config_define_variables (struct NeoMutt *n, struct ConfigSet *cs)
 Define the Config Variables - Implements Module::config_define_variables()
 
static bool sidebar_commands_register (struct NeoMutt *n, struct CommandArray *ca)
 Register NeoMutt Commands - Implements Module::commands_register()
 
static bool sidebar_cleanup (struct NeoMutt *n, void *data)
 Clean up a Module - Implements Module::cleanup()
 
static bool sidebar_gui_init (struct NeoMutt *n)
 Initialise the GUI - Implements Module::gui_init()
 
static void sidebar_gui_cleanup (struct NeoMutt *n)
 Clean up the GUI - Implements Module::gui_cleanup()
 

Variables

struct ConfigDef SidebarVars []
 Config definitions for the sidebar.
 
const struct Command SbCommands []
 Sidebar Commands.
 
const struct Module ModuleSidebar
 Module for the Sidebar library.
 

Detailed Description

Definition of the Sidebar Module.

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 module.c.

Function Documentation

◆ sidebar_init()

static bool sidebar_init ( struct NeoMutt * n)
static

Initialise a Module - Implements Module::init()

Definition at line 46 of file module.c.

47{
48 struct SidebarModuleData *mod_data = MUTT_MEM_CALLOC(1, struct SidebarModuleData);
49 STAILQ_INIT(&mod_data->sidebar_pinned);
51
52 mod_data->notify = notify_new();
53 notify_set_parent(mod_data->notify, n->notify);
54
55 return true;
56}
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ MODULE_ID_SIDEBAR
ModuleSidebar, Sidebar
Definition module_api.h:91
struct Notify * notify_new(void)
Create a new notifications handler.
Definition notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
void neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition neomutt.c:677
#define STAILQ_INIT(head)
Definition queue.h:410
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
Sidebar private Module data.
Definition module_data.h:32
struct ListHead sidebar_pinned
List of mailboxes to always display in the sidebar.
Definition module_data.h:36
struct Notify * notify
Notifications.
Definition module_data.h:33
+ Here is the call graph for this function:

◆ sidebar_config_define_variables()

static bool sidebar_config_define_variables ( struct NeoMutt * n,
struct ConfigSet * cs )
static

Define the Config Variables - Implements Module::config_define_variables()

Definition at line 61 of file module.c.

62{
64}
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition set.c:290
struct ConfigDef SidebarVars[]
Config definitions for the sidebar.
Definition config.c:94
+ Here is the call graph for this function:

◆ sidebar_commands_register()

static bool sidebar_commands_register ( struct NeoMutt * n,
struct CommandArray * ca )
static

Register NeoMutt Commands - Implements Module::commands_register()

Definition at line 69 of file module.c.

70{
71 return commands_register(ca, SbCommands);
72}
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
const struct Command SbCommands[]
Sidebar Commands.
Definition sidebar.c:48
+ Here is the call graph for this function:

◆ sidebar_cleanup()

static bool sidebar_cleanup ( struct NeoMutt * n,
void * data )
static

Clean up a Module - Implements Module::cleanup()

Definition at line 77 of file module.c.

78{
79 struct SidebarModuleData *mod_data = data;
80
81 notify_free(&mod_data->notify);
82
84 FREE(&mod_data);
85 return true;
86}
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition list.c:123
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
+ Here is the call graph for this function:

◆ sidebar_gui_init()

static bool sidebar_gui_init ( struct NeoMutt * n)
static

Initialise the GUI - Implements Module::gui_init()

Definition at line 91 of file module.c.

92{
94 sb_init(gui_data ? gui_data->all_dialogs_window : NULL);
95 return true;
96}
@ MODULE_ID_GUI
ModuleGui, Graphical code
Definition module_api.h:45
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
void sb_init(struct MuttWindow *all_dialogs_window)
Set up the Sidebar.
Definition sidebar.c:214
Gui private Module data.
Definition module_data.h:32
struct MuttWindow * all_dialogs_window
Parent of all Dialogs.
Definition module_data.h:38
+ Here is the call graph for this function:

◆ sidebar_gui_cleanup()

static void sidebar_gui_cleanup ( struct NeoMutt * n)
static

Clean up the GUI - Implements Module::gui_cleanup()

Definition at line 101 of file module.c.

102{
105 sb_cleanup(&mod_data->sidebar_pinned, (gui_data ? gui_data->all_dialogs_window : NULL));
106}
void sb_cleanup(struct ListHead *sidebar_pinned, struct MuttWindow *all_dialogs_window)
Clean up the Sidebar.
Definition sidebar.c:234
+ Here is the call graph for this function:

Variable Documentation

◆ SidebarVars

struct ConfigDef SidebarVars[]
extern

Config definitions for the sidebar.

Definition at line 94 of file config.c.

94 {
95 // clang-format off
96 { "sidebar_component_depth", DT_NUMBER, 0, 0, NULL,
97 "(sidebar) Strip leading path components from sidebar folders"
98 },
99 { "sidebar_delim_chars", DT_STRING, IP "/.", 0, NULL,
100 "(sidebar) Characters that separate nested folders"
101 },
102 { "sidebar_divider_char", DT_STRING, IP "\342\224\202", 0, NULL, // Box Drawings Light Vertical, U+2502
103 "(sidebar) Character to draw between the sidebar and index"
104 },
105 { "sidebar_folder_indent", DT_BOOL, false, 0, NULL,
106 "(sidebar) Indent nested folders"
107 },
108 { "sidebar_format", DT_EXPANDO|D_NOT_EMPTY, IP "%D%* %n", IP &SidebarFormatDef, NULL,
109 "(sidebar) printf-like format string for the sidebar panel"
110 },
111 { "sidebar_indent_string", DT_STRING, IP " ", 0, NULL,
112 "(sidebar) Indent nested folders using this string"
113 },
114 { "sidebar_new_mail_only", DT_BOOL, false, 0, NULL,
115 "(sidebar) Only show folders with new/flagged mail"
116 },
117 { "sidebar_next_new_wrap", DT_BOOL, false, 0, NULL,
118 "(sidebar) Wrap around when searching for the next mailbox with new mail"
119 },
120 { "sidebar_non_empty_mailbox_only", DT_BOOL, false, 0, NULL,
121 "(sidebar) Only show folders with a non-zero number of mail"
122 },
123 { "sidebar_on_right", DT_BOOL, false, 0, NULL,
124 "(sidebar) Display the sidebar on the right"
125 },
126 { "sidebar_short_path", DT_BOOL, false, 0, NULL,
127 "(sidebar) Abbreviate the paths using the `$folder` variable"
128 },
129 { "sidebar_sort", DT_SORT, SB_SORT_UNSORTED, IP SidebarSortMethods, NULL,
130 "(sidebar) Method to sort the sidebar"
131 },
132 { "sidebar_visible", DT_BOOL, false, 0, NULL,
133 "(sidebar) Show the sidebar"
134 },
135 { "sidebar_width", DT_NUMBER|D_INTEGER_NOT_NEGATIVE, 30, 0, NULL,
136 "(sidebar) Width of the sidebar"
137 },
138
139 { "sidebar_sort_method", DT_SYNONYM, IP "sidebar_sort", IP "2024-11-20" },
140
141 { NULL },
142 // clang-format on
143};
#define IP
Definition set.h:55
static const struct Mapping SidebarSortMethods[]
Sort methods for the sidebar.
Definition config.c:43
static const struct ExpandoDefinition SidebarFormatDef[]
Expando definitions.
Definition config.c:66
@ SB_SORT_UNSORTED
Sort into the order the mailboxes were configured.
Definition sort.h:36
@ DT_NUMBER
a number
Definition types.h:38
@ DT_BOOL
boolean option
Definition types.h:32
@ DT_SYNONYM
synonym for another variable
Definition types.h:45
@ DT_STRING
a string
Definition types.h:44
@ DT_SORT
sorting methods
Definition types.h:43
@ DT_EXPANDO
an expando
Definition types.h:34
#define D_NOT_EMPTY
Empty strings are not allowed.
Definition types.h:80
#define D_INTEGER_NOT_NEGATIVE
Negative numbers are not allowed.
Definition types.h:101

◆ SbCommands

const struct Command SbCommands[]
extern

Sidebar Commands.

Definition at line 48 of file sidebar.c.

48 {
49 // clang-format off
50 { "sidebar-pin", CMD_SIDEBAR_PIN, parse_sidebar_pin,
51 N_("Pin a mailbox in the sidebar (keep visible)"),
52 N_("sidebar-pin <mailbox> [ <mailbox> ... ]"),
53 "optionalfeatures.html#sidebar-pin" },
54 { "sidebar-unpin", CMD_SIDEBAR_UNPIN, parse_sidebar_unpin,
55 N_("Unpin a previously pinned mailbox in the sidebar"),
56 N_("sidebar-unpin { * | <mailbox> ... }"),
57 "optionalfeatures.html#sidebar-pin" },
58
59 // Deprecated
60 { "sidebar_pin", CMD_NONE, NULL, "sidebar-pin", NULL, NULL, CF_SYNONYM },
61 { "sidebar_unpin", CMD_NONE, NULL, "sidebar-unpin", NULL, NULL, CF_SYNONYM },
62 { "sidebar_whitelist", CMD_NONE, NULL, "sidebar-pin", NULL, NULL, CF_SYNONYM },
63 { "unsidebar_whitelist", CMD_NONE, NULL, "sidebar-unpin", NULL, NULL, CF_SYNONYM },
64
65 { NULL, CMD_NONE, NULL, NULL, NULL, NULL, CF_NONE },
66 // clang-format on
67};
@ CF_SYNONYM
Command is a synonym for another command.
Definition command.h:50
@ CF_NONE
No flags are set.
Definition command.h:49
@ CMD_SIDEBAR_PIN
:sidebar-pin
Definition command.h:114
@ CMD_SIDEBAR_UNPIN
:sidebar-unpin
Definition command.h:115
@ CMD_NONE
No Command.
Definition command.h:62
enum CommandResult parse_sidebar_pin(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'sidebar-pin' command - Implements Command::parse() -.
Definition commands.c:45
enum CommandResult parse_sidebar_unpin(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'sidebar-unpin' command - Implements Command::parse() -.
Definition commands.c:76
#define N_(a)
Definition message.h:32

◆ ModuleSidebar

const struct Module ModuleSidebar
Initial value:
= {
"sidebar",
NULL,
}
static bool sidebar_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
Define the Config Variables - Implements Module::config_define_variables()
Definition module.c:61
static bool sidebar_cleanup(struct NeoMutt *n, void *data)
Clean up a Module - Implements Module::cleanup()
Definition module.c:77
static void sidebar_gui_cleanup(struct NeoMutt *n)
Clean up the GUI - Implements Module::gui_cleanup()
Definition module.c:101
static bool sidebar_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register()
Definition module.c:69
static bool sidebar_init(struct NeoMutt *n)
Initialise a Module - Implements Module::init()
Definition module.c:46
static bool sidebar_gui_init(struct NeoMutt *n)
Initialise the GUI - Implements Module::gui_init()
Definition module.c:91

Module for the Sidebar library.

Definition at line 111 of file module.c.

111 {
113 "sidebar",
115 NULL, // config_define_types
121};