![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "gui/alert.h"#include "gui/application.h"#include "system/macros.h"#include "system/mem_alloc.h"#include "widgets/dialog.h"#include "widgets/widget_settings.h"#include "widgets/widget_style.h"#include <glib/gi18n.h>#include <gtk/gtk.h>
Include dependency graph for alert.c:Go to the source code of this file.
Data Structures | |
| struct | dt_gui_alert_t |
| struct | dt_gui_alert_button_t |
| struct | dt_alert_message_t |
Typedefs | |
| typedef struct dt_gui_alert_button_t | dt_gui_alert_button_t |
| typedef struct dt_alert_message_t | dt_alert_message_t |
Functions | |
| static void | _alert_window_destroyed (GtkWidget *window __attribute__((unused)), gpointer user_data) |
| static void | _alert_cancel (dt_gui_alert_t *alert) |
| static gboolean | _alert_delete (GtkWidget *window __attribute__((unused)), GdkEvent *event __attribute__((unused)), gpointer user_data) |
| static gboolean | _alert_key (GtkWidget *window, const GdkEventKey *event, gpointer user_data) |
| dt_gui_alert_t * | dt_gui_alert_new (const 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) |
| static void | _alert_button_clicked (GtkButton *button __attribute__((unused)), gpointer user_data) |
| 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) |
| static void | _alert_message_free (gpointer data) |
| static void | _alert_window_items_destroyed (GtkWidget *block, gpointer user_data) |
| static void | _alert_ok_clicked (dt_gui_alert_t *alert, void *data __attribute__((unused))) |
| static void | _alert_items_copy (GtkButton *button __attribute__((unused)), gpointer user_data) |
| static gboolean | _alert_show (gpointer user_data) |
| void | dt_gui_alert (const char *title, const char *message, const char *item, const gboolean once) |
Variables | |
| static GHashTable * | _alert_windows = NULL |
| static GHashTable * | _alert_closed = NULL |
| typedef struct dt_alert_message_t dt_alert_message_t |
| typedef struct dt_gui_alert_button_t dt_gui_alert_button_t |
|
static |
Definition at line 199 of file alert.c.
References dt_gui_alert_button_t::alert, dt_gui_alert_button_t::callback, and dt_gui_alert_button_t::data.
Referenced by dt_gui_alert_add_button().
|
static |
Definition at line 65 of file alert.c.
References dt_gui_alert_t::cancel, dt_gui_alert_t::cancel_data, and IS_NULL_PTR.
Referenced by _alert_delete(), and _alert_key().
|
static |
Definition at line 70 of file alert.c.
References _alert_cancel(), DT_GUI_ALERT_NOTICE, DT_GUI_ALERT_PROGRESS, DT_GUI_ALERT_QUESTION, FALSE, dt_gui_alert_t::kind, and TRUE.
Referenced by dt_gui_alert_new().
|
static |
|
static |
Definition at line 89 of file alert.c.
References _alert_cancel(), DT_GUI_ALERT_NOTICE, DT_GUI_ALERT_PROGRESS, DT_GUI_ALERT_QUESTION, FALSE, dt_gui_alert_t::kind, TRUE, and window.
Referenced by dt_gui_alert_new().
|
static |
Definition at line 275 of file alert.c.
References dt_free, dt_alert_message_t::item, dt_alert_message_t::message, and dt_alert_message_t::title.
Referenced by dt_gui_alert().
|
static |
Definition at line 293 of file alert.c.
References dt_gui_alert_destroy().
Referenced by _alert_show().
|
static |
Definition at line 313 of file alert.c.
References _alert_closed, _alert_items_copy(), _alert_ok_clicked(), _alert_window_items_destroyed(), _alert_windows, copy(), dt_free, dt_gui_add_class(), dt_gui_alert_add_button(), dt_gui_alert_add_text(), dt_gui_alert_add_widget(), dt_gui_alert_new(), DT_GUI_ALERT_NOTICE, dt_gui_alert_show(), DT_PIXEL_APPLY_DPI, FALSE, IS_NULL_PTR, dt_alert_message_t::item, items, key, dt_alert_message_t::message, dt_alert_message_t::once, dt_alert_message_t::title, and TRUE.
Referenced by dt_gui_alert().
|
static |
Definition at line 56 of file alert.c.
References dt_free, DT_GUI_ALERT_NOTICE, dt_gui_main_window(), dt_gui_refocus_parent(), and dt_gui_alert_t::kind.
Referenced by dt_gui_alert_new().
Definition at line 286 of file alert.c.
References _alert_closed, and _alert_windows.
Referenced by _alert_show().
| 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().
|
static |
Definition at line 273 of file alert.c.
Referenced by _alert_show(), and _alert_window_items_destroyed().
|
static |
Definition at line 270 of file alert.c.
Referenced by _alert_show(), and _alert_window_items_destroyed().