NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
gui.c File Reference
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "gui.h"
#include "lib.h"
#include "alias.h"
#include "mutt_menu.h"
#include "sort.h"
+ Include dependency graph for gui.c:

Go to the source code of this file.

Functions

int alias_config_observer (struct NotifyCallback *nc)
 Listen for sort_alias configuration changes and reorders menu items accordingly. More...
 
int alias_color_observer (struct NotifyCallback *nc)
 Listen for color configuration changes and refreshes the menu. More...
 
char * menu_create_alias_title (char *menu_name, char *limit)
 Create a title string for the Menu. More...
 

Detailed Description

Shared code for the Alias and Query Dialogs

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

Function Documentation

◆ alias_config_observer()

int alias_config_observer ( struct NotifyCallback nc)

Listen for sort_alias configuration changes and reorders menu items accordingly.

Definition at line 44 of file gui.c.

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 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alias_color_observer()

int alias_color_observer ( struct NotifyCallback nc)

Listen for color configuration changes and refreshes the menu.

Definition at line 66 of file gui.c.

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 }
+ Here is the caller graph for this function:

◆ menu_create_alias_title()

char* menu_create_alias_title ( char *  menu_name,
char *  limit 
)

Create a title string for the Menu.

Parameters
menu_nameMenu name
limitLimit being applied
Note
Caller must free the returned string

Definition at line 84 of file gui.c.

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 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:
_
#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
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
AliasMenuData::ava
struct AliasViewArray ava
Array of AliasView.
Definition: gui.h:57
NT_COLOR
@ NT_COLOR
Colour has changed, ColorId, EventColor.
Definition: notify_type.h:35
REDRAW_FULL
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
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
NotifyCallback::event_data
void * event_data
Data from notify_send()
Definition: observer.h:44
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
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