NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
gui.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include <stdlib.h>
31 #include <string.h>
32 #include "mutt/lib.h"
33 #include "address/lib.h"
34 #include "config/lib.h"
35 #include "gui.h"
36 #include "lib.h"
37 #include "alias.h"
38 #include "mutt_menu.h"
39 #include "sort.h"
40 
45 {
46  if (!nc->event_data)
47  return -1;
48  if (nc->event_type != NT_CONFIG)
49  return 0;
50 
51  struct EventConfig *ec = nc->event_data;
52 
53  if (!mutt_str_equal(ec->name, "sort_alias"))
54  return 0;
55 
56  struct AliasMenuData *mdata = nc->global_data;
57 
58  alias_array_sort(&mdata->ava, mdata->sub);
59 
60  return 0;
61 }
62 
67 {
68  if ((nc->event_type != NT_COLOR) || !nc->event_data || !nc->global_data)
69  return -1;
70 
71  struct Menu *menu = nc->global_data;
72  menu->redraw = REDRAW_FULL;
73 
74  return 0;
75 }
76 
84 char *menu_create_alias_title(char *menu_name, char *limit)
85 {
86  if (limit)
87  {
88  char *tmp_str = NULL;
89  char *new_title = NULL;
90 
91  mutt_str_asprintf(&tmp_str, _("Limit: %s"), limit);
92  mutt_str_asprintf(&new_title, "%s - %s", menu_name, tmp_str);
93 
94  FREE(&tmp_str);
95 
96  return new_title;
97  }
98  else
99  {
100  return strdup(menu_name);
101  }
102 }
NotifyCallback
Data passed to a notification function.
Definition: observer.h:39
_
#define _(a)
Definition: message.h:28
alias_array_sort
void alias_array_sort(struct AliasViewArray *ava, const struct ConfigSubset *sub)
Sort and reindex an AliasViewArray.
Definition: sort.c:158
NT_CONFIG
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:37
FREE
#define FREE(x)
Definition: memory.h:40
alias.h
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
lib.h
AliasMenuData::ava
struct AliasViewArray ava
Array of AliasView.
Definition: gui.h:57
lib.h
NT_COLOR
@ NT_COLOR
Colour has changed, ColorId, EventColor.
Definition: notify_type.h:35
mutt_menu.h
REDRAW_FULL
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
lib.h
NotifyCallback::global_data
void * global_data
Data from notify_observer_add()
Definition: observer.h:45
AliasMenuData::sub
struct ConfigSubset * sub
Config items.
Definition: gui.h:58
EventConfig
A config-change event.
Definition: subset.h:70
alias_config_observer
int alias_config_observer(struct NotifyCallback *nc)
Listen for sort_alias configuration changes and reorders menu items accordingly.
Definition: gui.c:44
NotifyCallback::event_data
void * event_data
Data from notify_send()
Definition: observer.h:44
sort.h
menu_create_alias_title
char * menu_create_alias_title(char *menu_name, char *limit)
Create a title string for the Menu.
Definition: gui.c:84
EventConfig::name
const char * name
Name of config item that changed.
Definition: subset.h:73
AliasMenuData
AliasMenuData - AliasView array wrapper with Pattern information.
Definition: gui.h:53
Menu::redraw
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
gui.h
NotifyCallback::event_type
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
mutt_str_asprintf
int mutt_str_asprintf(char **strp, const char *fmt,...)
Definition: string.c:1095
Menu
GUI selectable list of items.
Definition: mutt_menu.h:52
alias_color_observer
int alias_color_observer(struct NotifyCallback *nc)
Listen for color configuration changes and refreshes the menu.
Definition: gui.c:66