NeoMutt  2024-12-12-19-ge4b57e
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 "dialog.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.
 

Variables

struct MuttWindowAllDialogsWindow = NULL
 Parent of all Dialogs.
 

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:75
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
+ 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 || !AllDialogsWindow)
112 return;
113
114 struct MuttWindow *last = TAILQ_LAST(&AllDialogsWindow->children, MuttWindowList);
115 if (last)
116 last->state.visible = false;
117
120
121 // Notify the world, allowing plugins to integrate
122 mutt_debug(LL_NOTIFY, "NT_WINDOW_DIALOG visible: %s, %p\n",
123 mutt_window_win_name(dlg), (void *) dlg);
124 struct EventWindow ev_w = { dlg, WN_VISIBLE };
126
127 dlg->state.visible = true;
130
131#ifdef USE_DEBUG_WINDOW
133#endif
134}
void debug_win_dump(void)
Definition: window.c:96
struct MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition: dialog.c:80
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_NOTIFY
Log of notifications.
Definition: logging2.h:48
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.
Definition: mutt_window.c:344
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
Definition: mutt_window.c:735
@ NT_WINDOW_DIALOG
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
Definition: mutt_window.h:231
#define WN_VISIBLE
Window became visible.
Definition: mutt_window.h:215
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:57
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:827
#define TAILQ_LAST(head, headname)
Definition: queue.h:837
An Event that happened to a Window.
Definition: mutt_window.h:239
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:136
bool visible
Window is visible.
Definition: mutt_window.h:60
+ 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 142 of file dialog.c.

143{
144 if (!AllDialogsWindow)
145 return;
146
147 struct MuttWindow *last = TAILQ_LAST(&AllDialogsWindow->children, MuttWindowList);
148 if (!last)
149 return;
150
151 // Notify the world, allowing plugins to clean up
152 mutt_debug(LL_NOTIFY, "NT_WINDOW_DIALOG hidden: %s, %p\n",
153 mutt_window_win_name(last), (void *) last);
154 struct EventWindow ev_w = { last, WN_HIDDEN };
156
157 last->state.visible = false;
158 last->parent = NULL;
159 TAILQ_REMOVE(&AllDialogsWindow->children, last, entries);
160
161 last = TAILQ_LAST(&AllDialogsWindow->children, MuttWindowList);
162 if (last)
163 {
164 last->state.visible = true;
166 }
167 else
168 {
169 AllDialogsWindow->focus = NULL;
170 }
171#ifdef USE_DEBUG_WINDOW
173#endif
174}
#define WN_HIDDEN
Window became hidden.
Definition: mutt_window.h:216
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:862
struct MuttWindow * focus
Focused Window.
Definition: mutt_window.h:140
+ 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 210 of file dialog.c.

211{
215
217
218 AllDialogsWindow = win_alldlgs;
219
220 return win_alldlgs;
221}
static int alldialogs_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dialog.c:183
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.
Definition: mutt_window.c:182
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:39
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:53
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ AllDialogsWindow

struct MuttWindow* AllDialogsWindow = NULL

Parent of all Dialogs.

Definition at line 80 of file dialog.c.