NeoMutt  2025-12-11-769-g906513
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dialog.c File Reference

Dialog Windows. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "dialog.h"
#include "module_data.h"
#include "mutt_window.h"
+ Include dependency graph for dialog.c:

Go to the source code of this file.

Functions

struct MuttWindowdialog_find (struct MuttWindow *win)
 Find the parent Dialog of a Window.
 
void dialog_push (struct MuttWindow *dlg)
 Display a Window to the user.
 
void dialog_pop (void)
 Hide a Window from the user.
 
static int alldialogs_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
struct MuttWindowalldialogs_new (void)
 Create the AllDialogs Window.
 

Detailed Description

Dialog Windows.

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

Function Documentation

◆ dialog_find()

struct MuttWindow * dialog_find ( struct MuttWindow * win)

Find the parent Dialog of a Window.

Parameters
winWindow
Return values
ptrDialog

Dialog Windows will be owned by a MuttWindow of type WT_ALL_DIALOGS.

Definition at line 89 of file dialog.c.

90{
91 for (; win && win->parent; win = win->parent)
92 {
93 if (win->parent->type == WT_ALL_DIALOGS)
94 return win;
95 }
96
97 return NULL;
98}
@ WT_ALL_DIALOGS
Container for All Dialogs (nested Windows)
Definition mutt_window.h:74
struct MuttWindow * parent
Parent Window.
enum WindowType type
Window type, e.g. WT_SIDEBAR.
+ Here is the caller graph for this function:

◆ dialog_push()

void dialog_push ( struct MuttWindow * dlg)

Display a Window to the user.

Parameters
dlgWindow to display

The Dialog Windows are kept in a stack. The topmost is visible to the user, whilst the others are hidden.

When a Window is pushed, the old Window is marked as not visible.

Definition at line 109 of file dialog.c.

110{
111 if (!dlg)
112 return;
113
115 if (!mod_data || !mod_data->all_dialogs_window)
116 return;
117
118 struct MuttWindow *win_alldlgs = mod_data->all_dialogs_window;
119
120 struct MuttWindow **wp_last = ARRAY_LAST(&win_alldlgs->children);
121 if (wp_last)
122 (*wp_last)->state.visible = false;
123
124 ARRAY_ADD(&win_alldlgs->children, dlg);
125 notify_set_parent(dlg->notify, win_alldlgs->notify);
126
127 // Notify the world, allowing plugins to integrate
128 mutt_debug(LL_NOTIFY, "NT_WINDOW_DIALOG visible: %s, %p\n",
129 mutt_window_win_name(dlg), (void *) dlg);
130 struct EventWindow ev_w = { dlg, WN_VISIBLE };
132
133 dlg->state.visible = true;
134 dlg->parent = win_alldlgs;
135 mutt_window_reflow(win_alldlgs);
136
137#ifdef USE_DEBUG_WINDOW
139#endif
140}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:157
#define ARRAY_LAST(head)
Convenience method to get the last element.
Definition array.h:145
void debug_win_dump(void)
Dump all windows to debug output.
Definition window.c:116
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_NOTIFY
Log of notifications.
Definition logging2.h:50
@ MODULE_ID_GUI
ModuleGui, Graphical code
Definition module_api.h:45
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
@ NT_WINDOW_DIALOG
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
#define WN_VISIBLE
Window became visible.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:665
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition notify_type.h:57
An Event that happened to a Window.
Gui private Module data.
Definition module_data.h:32
struct MuttWindow * all_dialogs_window
Parent of all Dialogs.
Definition module_data.h:38
struct MuttWindowArray children
Children Windows.
struct WindowState state
Current state of the Window.
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Container for Accounts, Notifications.
Definition neomutt.h:41
bool visible
Window is visible.
Definition mutt_window.h:59
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dialog_pop()

void dialog_pop ( void )

Hide a Window from the user.

The topmost (visible) Window is removed from the stack and the next Window is marked as visible.

Definition at line 148 of file dialog.c.

149{
151 if (!mod_data || !mod_data->all_dialogs_window)
152 return;
153
154 struct MuttWindow *win_alldlgs = mod_data->all_dialogs_window;
155
156 struct MuttWindow **wp_last = ARRAY_LAST(&win_alldlgs->children);
157 if (!wp_last)
158 return;
159
160 struct MuttWindow *win_last = *wp_last;
161
162 // Notify the world, allowing plugins to clean up
163 mutt_debug(LL_NOTIFY, "NT_WINDOW_DIALOG hidden: %s, %p\n",
164 mutt_window_win_name(win_last), (void *) win_last);
165 struct EventWindow ev_w = { win_last, WN_HIDDEN };
166 notify_send(win_last->notify, NT_WINDOW, NT_WINDOW_DIALOG, &ev_w);
167
168 win_last->state.visible = false;
169 win_last->parent = NULL;
170 ARRAY_REMOVE(&win_alldlgs->children, wp_last);
171
172 wp_last = ARRAY_LAST(&win_alldlgs->children);
173 if (wp_last)
174 {
175 (*wp_last)->state.visible = true;
176 mutt_window_reflow(win_alldlgs);
177 }
178 else
179 {
180 win_alldlgs->focus = NULL;
181 }
182#ifdef USE_DEBUG_WINDOW
184#endif
185}
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition array.h:355
#define WN_HIDDEN
Window became hidden.
struct MuttWindow * focus
Focused Window.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alldialogs_new()

struct MuttWindow * alldialogs_new ( void )

Create the AllDialogs Window.

Return values
ptrNew AllDialogs Window

Create the container for all the Dialogs.

Definition at line 223 of file dialog.c.

224{
228
230
232 if (mod_data)
233 mod_data->all_dialogs_window = win_alldlgs;
234
235 return win_alldlgs;
236}
static int alldialogs_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition dialog.c:194
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition notify.c:191
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition mutt_window.h:38
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition mutt_window.h:52
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition mutt_window.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function: