NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
gui.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include <stdio.h>
31 #include "mutt/lib.h"
32 #include "config/lib.h"
33 #include "gui/lib.h"
34 #include "gui.h"
35 #include "lib.h"
36 #include "menu/lib.h"
37 
44 {
45  if ((nc->event_type != NT_CONFIG) || !nc->global_data || !nc->event_data)
46  return -1;
47 
48  struct EventConfig *ev_c = nc->event_data;
49 
50  if (!mutt_str_equal(ev_c->name, "sort_alias"))
51  return 0;
52 
53  struct Menu *menu = nc->global_data;
54 
56  mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
57 
58  return 0;
59 }
60 
67 void alias_set_title(struct MuttWindow *sbar, char *menu_name, char *limit)
68 {
69  if (!limit)
70  {
71  sbar_set_title(sbar, menu_name);
72  return;
73  }
74 
75  char buf[256] = { 0 };
76 
77  int len = snprintf(buf, sizeof(buf), "%s - ", menu_name);
78 
79  snprintf(buf + len, sizeof(buf) - len, _("Limit: %s"), limit);
80 
81  sbar_set_title(sbar, buf);
82 }
83 
88 {
89  struct Menu *menu = win->wdata;
90  struct AliasMenuData *mdata = menu->mdata;
91 
92  alias_array_sort(&mdata->ava, mdata->sub);
93 
94  win->actions |= WA_REPAINT;
95  mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
96  return 0;
97 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
Convenience wrapper for the gui headers.
Definition: lib.h:67
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
Data passed to a notification function.
Definition: observer.h:39
AliasView array wrapper with Pattern information -.
Definition: gui.h:52
A config-change event.
Definition: subset.h:69
#define _(a)
Definition: message.h:28
void alias_set_title(struct MuttWindow *sbar, char *menu_name, char *limit)
Create a title string for the Menu.
Definition: gui.c:67
Convenience wrapper for the config headers.
void alias_array_sort(struct AliasViewArray *ava, const struct ConfigSubset *sub)
Sort and reindex an AliasViewArray.
Definition: sort.c:157
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
Email Aliases.
void * global_data
Data from notify_observer_add()
Definition: observer.h:45
int alias_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t.
Definition: gui.c:43
void * mdata
Private data.
Definition: lib.h:155
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:221
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
void * event_data
Data from notify_send()
Definition: observer.h:44
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:42
struct ConfigSubset * sub
Config items.
Definition: gui.h:56
struct AliasViewArray ava
Array of AliasView.
Definition: gui.h:55
Log at debug level 5.
Definition: logging.h:44
Convenience wrapper for the library headers.
void * wdata
Private data.
Definition: mutt_window.h:145
Shared code for the Alias and Query Dialogs.
const char * name
Name of config item that changed.
Definition: subset.h:72
int alias_recalc(struct MuttWindow *win)
Recalculate the display of the Alias Window - Implements MuttWindow::recalc() -.
Definition: gui.c:87