![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include <gtk/gtk.h>
Include dependency graph for alert.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Typedefs | |
| typedef struct dt_gui_alert_t | dt_gui_alert_t |
| typedef enum dt_gui_alert_kind_t | dt_gui_alert_kind_t |
| typedef void(* | dt_gui_alert_callback_t) (dt_gui_alert_t *alert, void *data) |
Enumerations | |
| enum | dt_gui_alert_kind_t { DT_GUI_ALERT_NOTICE , DT_GUI_ALERT_QUESTION , DT_GUI_ALERT_PROGRESS } |
Functions | |
| dt_gui_alert_t * | dt_gui_alert_new (dt_gui_alert_kind_t kind, const char *title, const char *heading) |
| GtkWidget * | dt_gui_alert_add_text (dt_gui_alert_t *alert, const char *text) |
| void | dt_gui_alert_add_widget (dt_gui_alert_t *alert, GtkWidget *widget) |
| void | dt_gui_alert_add_button (dt_gui_alert_t *alert, const char *label, dt_gui_alert_callback_t callback, void *data) |
| void | dt_gui_alert_set_cancel (dt_gui_alert_t *alert, dt_gui_alert_callback_t callback, void *data) |
| void | dt_gui_alert_show (dt_gui_alert_t *alert) |
| void | dt_gui_alert_destroy (dt_gui_alert_t *alert) |
| void | dt_gui_alert (const char *title, const char *message, const char *item, const gboolean once) |
| typedef void(* dt_gui_alert_callback_t) (dt_gui_alert_t *alert, void *data) |
| typedef enum dt_gui_alert_kind_t dt_gui_alert_kind_t |
| typedef struct dt_gui_alert_t dt_gui_alert_t |
An alert window: Ansel's small window that says something which must not go unseen, with an icon on the left and, on its right, a bold heading over the lines and buttons the caller adds.
Everything about the window itself – its frame, its icon, which window it stays above, whether it is modal, what Escape and its title bar do, where the focus goes – is decided here, by the kind it is created with. A caller says what the window tells and what its buttons do, never how the window behaves.
Built and used from the GUI thread only, except dt_gui_alert(), which any thread may call.
| enum dt_gui_alert_kind_t |
| Enumerator | |
|---|---|
| DT_GUI_ALERT_NOTICE | Tells something, and lets the user go on working: not modal, kept above the main window. OK, Escape or its title bar close it, and the main window gets the focus back. |
| DT_GUI_ALERT_QUESTION | Asks something, and nothing else may change until it is answered: modal over the main window. Escape and its title bar answer with the callback of dt_gui_alert_set_cancel(). |
| DT_GUI_ALERT_PROGRESS | Says that something is under way, with a spinner, and goes away when it is done: only its owner closes it. Not attached to the main window, which may be hidden, but centred on the screen; in a window group of its own, so that a grab held over the others leaves it usable. |
| void dt_gui_alert | ( | const char * | title, |
| const char * | message, | ||
| const char * | item, | ||
| const gboolean | once | ||
| ) |
Tell the user something that must not go unseen: a NOTICE with a single OK button.
A toast goes away by itself; this is for what stays true after it would have – a module that failed, an image that was not updated. Nothing waits for the answer: the call returns at once, and the rest of the application stays usable while the window is up.
One window per kind of message – per title and message – which shows the message once and, under it, the items it was raised for, each once, in a list that scrolls past a height. A failure that repeats – a module failing on every thumbnail of a film roll – stays one window that lists which images it hit, instead of stacking windows or keeping only the last one. A repeat that adds nothing leaves the window as it is.
So the message says what went wrong, never where: the same text at every call from one place, built with no value in it. What changes from one call to the next – a file, a module, a profile – is the item.
Any thread: the window is built later, from the GUI thread's main loop, out of copies of the arguments – never inside the call, so a caller holding a lock may alert.
| title | the window's title and the bold line at the top, already translated; one line |
| message | the text under it, already translated; plain text, not markup |
| item | one line of the list under it – an image's full path, or a module's name and the image; plain text. NULL when there is nothing to list. |
| once | TRUE for a failure that repeats as long as its cause lasts: once its window is closed, this title and message do not open another this session. Its window, while up, lists every item all the same. |
Definition at line 412 of file alert.c.
References _alert_message_free(), _alert_show(), and copy().
Referenced by _pixelpipe_cache_alert(), and dt_gui_gtk_init().
| void dt_gui_alert_add_button | ( | dt_gui_alert_t * | alert, |
| const char * | label, | ||
| dt_gui_alert_callback_t | callback, | ||
| void * | data | ||
| ) |
Add a button at the bottom right, after those already there. The first one added has the focus when the window shows: put first what Enter should do.
Definition at line 206 of file alert.c.
References _alert_button_clicked(), dt_gui_alert_button_t::alert, dt_gui_alert_t::buttons, dt_gui_alert_button_t::callback, dt_gui_alert_t::column, dt_gui_alert_button_t::data, DT_PIXEL_APPLY_DPI, FALSE, dt_gui_alert_t::focus, and IS_NULL_PTR.
Referenced by _alert_show(), and _closing_window_new().
| GtkWidget * dt_gui_alert_add_text | ( | dt_gui_alert_t * | alert, |
| const char * | text | ||
| ) |
Add a line of text under what is already there, wrapped past 60 characters.
| text | plain text, already translated; NULL for a line the caller fills later |
Definition at line 184 of file alert.c.
References dt_gui_alert_t::column, FALSE, and TRUE.
Referenced by _alert_show(), and _closing_window_new().
| void dt_gui_alert_add_widget | ( | dt_gui_alert_t * | alert, |
| GtkWidget * | widget | ||
| ) |
Add a widget of the caller's under what is already there – a list, an expander. The window takes it.
Definition at line 194 of file alert.c.
References dt_gui_alert_t::column, and FALSE.
Referenced by _alert_show(), and _closing_window_new().
| void dt_gui_alert_destroy | ( | dt_gui_alert_t * | alert | ) |
Close the window and free the alert. The main window does not get the focus back: what comes after a question or a progress – going back to work, or quitting – is the caller's to say.
Definition at line 253 of file alert.c.
References dt_gui_alert_t::window.
Referenced by _alert_ok_clicked(), _closing_confirm(), and dt_gui_closing_wait().
| dt_gui_alert_t * dt_gui_alert_new | ( | dt_gui_alert_kind_t | kind, |
| const char * | title, | ||
| const char * | heading | ||
| ) |
Create an alert, not shown yet: add its lines and buttons, then dt_gui_alert_show() it.
| kind | how the window behaves, see dt_gui_alert_kind_t |
| title | the window's title, already translated |
| heading | the bold line at the top, already translated |
Definition at line 107 of file alert.c.
References _alert_delete(), _alert_key(), _alert_window_destroyed(), dt_gui_alert_t::column, dt_free, DT_GUI_ALERT_NOTICE, DT_GUI_ALERT_PROGRESS, DT_GUI_ALERT_QUESTION, dt_gui_main_window(), dt_osx_disallow_fullscreen(), DT_PIXEL_APPLY_DPI, FALSE, dt_gui_alert_t::kind, kind, TRUE, window, and dt_gui_alert_t::window.
Referenced by _alert_show(), and _closing_window_new().
| void dt_gui_alert_set_cancel | ( | dt_gui_alert_t * | alert, |
| dt_gui_alert_callback_t | callback, | ||
| void * | data | ||
| ) |
What Escape and the title bar of a QUESTION answer: a question cannot be closed without an answer. Ignored by the other kinds.
Definition at line 230 of file alert.c.
References dt_gui_alert_t::cancel, and dt_gui_alert_t::cancel_data.
Referenced by _closing_window_new().
| void dt_gui_alert_show | ( | dt_gui_alert_t * | alert | ) |
Show the window, in front, with the focus on its first button.
Definition at line 236 of file alert.c.
References DT_GUI_ALERT_NOTICE, dt_osx_focus_window(), dt_gui_alert_t::focus, IS_NULL_PTR, dt_gui_alert_t::kind, and dt_gui_alert_t::window.
Referenced by _alert_show(), and _closing_window_new().