NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
gui.h File Reference

Shared code for the Alias and Query Dialogs. More...

#include <stdbool.h>
#include "mutt/lib.h"
+ Include dependency graph for gui.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  AliasView
 GUI data wrapping an Alias. More...
 
struct  AliasMenuData
 AliasView array wrapper with Pattern information -. More...
 

Functions

 ARRAY_HEAD (AliasViewArray, struct AliasView)
 
int alias_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t. More...
 
int alias_array_alias_add (struct AliasViewArray *ava, struct Alias *alias)
 Add an Alias to the AliasViewArray. More...
 
int alias_array_alias_delete (struct AliasViewArray *ava, struct Alias *alias)
 Delete an Alias from the AliasViewArray. More...
 
int alias_array_count_visible (struct AliasViewArray *ava)
 Count number of visible Aliases. More...
 
void alias_set_title (struct MuttWindow *sbar, char *menu_name, char *limit)
 Create a title string for the Menu. More...
 
int alias_recalc (struct MuttWindow *win)
 Recalculate the display of the Alias Window - Implements MuttWindow::recalc() -. 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.h.

Function Documentation

◆ ARRAY_HEAD()

ARRAY_HEAD ( AliasViewArray  ,
struct AliasView   
)

◆ alias_config_observer()

int alias_config_observer ( struct NotifyCallback nc)

Notification that a Config Variable has changed - Implements observer_t.

The Address Book Window is affected by changes to $sort_alias.

Definition at line 43 of file gui.c.

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 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
Definition: lib.h:67
A config-change event.
Definition: subset.h:69
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
void * global_data
Data from notify_observer_add()
Definition: observer.h:45
#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
Log at debug level 5.
Definition: logging.h:44
const char * name
Name of config item that changed.
Definition: subset.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alias_array_alias_add()

int alias_array_alias_add ( struct AliasViewArray *  ava,
struct Alias alias 
)

Add an Alias to the AliasViewArray.

Parameters
avaArray of Aliases
aliasAlias to add
Note
The Alias is wrapped in an AliasView
Call alias_array_sort() to sort and reindex the AliasViewArray

Definition at line 45 of file array.c.

46 {
47  if (!ava || !alias)
48  return -1;
49 
50  struct AliasView av = {
51  .num = 0,
52  .orig_seq = ARRAY_SIZE(ava),
53  .is_tagged = false,
54  .is_deleted = false,
55  .is_visible = true,
56  .alias = alias,
57  };
58  ARRAY_ADD(ava, av);
59  return ARRAY_SIZE(ava);
60 }
GUI data wrapping an Alias.
Definition: gui.h:35
struct Alias * alias
Alias.
Definition: gui.h:44
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:152
int num
Index number in list.
Definition: gui.h:37
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:83
+ Here is the caller graph for this function:

◆ alias_array_alias_delete()

int alias_array_alias_delete ( struct AliasViewArray *  ava,
struct Alias alias 
)

Delete an Alias from the AliasViewArray.

Parameters
avaArray of Aliases
aliasAlias to remove
Note
Call alias_array_sort() to sort and reindex the AliasViewArray

Definition at line 69 of file array.c.

70 {
71  if (!ava || !alias)
72  return -1;
73 
74  struct AliasView *avp = NULL;
75  ARRAY_FOREACH(avp, ava)
76  {
77  if (avp->alias != alias)
78  continue;
79 
80  ARRAY_REMOVE(ava, avp);
81  break;
82  }
83 
84  return ARRAY_SIZE(ava);
85 }
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
GUI data wrapping an Alias.
Definition: gui.h:35
struct Alias * alias
Alias.
Definition: gui.h:44
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition: array.h:261
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:83
+ Here is the caller graph for this function:

◆ alias_array_count_visible()

int alias_array_count_visible ( struct AliasViewArray *  ava)

Count number of visible Aliases.

Parameters
avaArray of Aliases

Definition at line 91 of file array.c.

92 {
93  int count = 0;
94 
95  struct AliasView *avp = NULL;
96  ARRAY_FOREACH(avp, ava)
97  {
98  if (avp->is_visible)
99  count++;
100  }
101 
102  return count;
103 }
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
GUI data wrapping an Alias.
Definition: gui.h:35
bool is_visible
Is visible?
Definition: gui.h:43
+ Here is the caller graph for this function:

◆ alias_set_title()

void alias_set_title ( struct MuttWindow sbar,
char *  menu_name,
char *  limit 
)

Create a title string for the Menu.

Parameters
sbarSimple Bar Window
menu_nameMenu name
limitLimit being applied

Definition at line 67 of file gui.c.

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 }
#define _(a)
Definition: message.h:28
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:221
+ Here is the call graph for this function:
+ Here is the caller graph for this function: