forked from neomutt/neomutt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.c
99 lines (83 loc) · 2.58 KB
/
gui.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* @file
* Shared code for the Alias and Query Dialogs
*
* @authors
* Copyright (C) 2020 Richard Russon <[email protected]>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* 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/>.
*/
/**
* @page alias_gui Shared code for alias dialogs
*
* Shared code for the Alias and Query Dialogs
*/
#include "config.h"
#include <stdio.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "gui/lib.h"
#include "gui.h"
#include "menu/lib.h"
#include "functions.h"
/**
* alias_config_observer - Notification that a Config Variable has changed - Implements ::observer_t - @ingroup observer_api
*
* The Address Book Window is affected by changes to `$sort_alias`.
*/
int alias_config_observer(struct NotifyCallback *nc)
{
if (nc->event_type != NT_CONFIG)
return 0;
if (!nc->global_data || !nc->event_data)
return -1;
struct EventConfig *ev_c = nc->event_data;
if (!mutt_str_equal(ev_c->name, "sort_alias"))
return 0;
struct Menu *menu = nc->global_data;
menu_queue_redraw(menu, MENU_REDRAW_FULL);
mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
return 0;
}
/**
* alias_set_title - Create a title string for the Menu
* @param sbar Simple Bar Window
* @param menu_name Menu name
* @param limit Limit being applied
*/
void alias_set_title(struct MuttWindow *sbar, char *menu_name, char *limit)
{
if (!limit)
{
sbar_set_title(sbar, menu_name);
return;
}
char buf[256] = { 0 };
int len = snprintf(buf, sizeof(buf), "%s - ", menu_name);
snprintf(buf + len, sizeof(buf) - len, _("Limit: %s"), limit);
sbar_set_title(sbar, buf);
}
/**
* alias_recalc - Recalculate the display of the Alias Window - Implements MuttWindow::recalc() - @ingroup window_recalc
*/
int alias_recalc(struct MuttWindow *win)
{
struct Menu *menu = win->wdata;
struct AliasMenuData *mdata = menu->mdata;
alias_array_sort(&mdata->ava, mdata->sub);
win->actions |= WA_REPAINT;
mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
return 0;
}