Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
alert.c File Reference
#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 Documentation

◆ dt_alert_message_t

◆ dt_gui_alert_button_t

Function Documentation

◆ _alert_button_clicked()

static void _alert_button_clicked ( GtkButton *button   __attribute__(unused),
gpointer  user_data 
)
static

◆ _alert_cancel()

static void _alert_cancel ( dt_gui_alert_t *  alert)
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().

◆ _alert_delete()

static gboolean _alert_delete ( GtkWidget *window   __attribute__(unused),
GdkEvent *event   __attribute__(unused),
gpointer  user_data 
)
static

◆ _alert_items_copy()

static void _alert_items_copy ( GtkButton *button   __attribute__(unused),
gpointer  user_data 
)
static

Definition at line 299 of file alert.c.

References TRUE.

Referenced by _alert_show().

◆ _alert_key()

static gboolean _alert_key ( GtkWidget *  window,
const GdkEventKey *  event,
gpointer  user_data 
)
static

◆ _alert_message_free()

static void _alert_message_free ( gpointer  data)
static

◆ _alert_ok_clicked()

static void _alert_ok_clicked ( dt_gui_alert_t *  alert,
void *data   __attribute__(unused) 
)
static

Definition at line 293 of file alert.c.

References dt_gui_alert_destroy().

Referenced by _alert_show().

◆ _alert_show()

◆ _alert_window_destroyed()

static void _alert_window_destroyed ( GtkWidget *window   __attribute__(unused),
gpointer  user_data 
)
static

◆ _alert_window_items_destroyed()

static void _alert_window_items_destroyed ( GtkWidget *  block,
gpointer  user_data 
)
static

Definition at line 286 of file alert.c.

References _alert_closed, and _alert_windows.

Referenced by _alert_show().

◆ dt_gui_alert()

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.

Parameters
titlethe window's title and the bold line at the top, already translated; one line
messagethe text under it, already translated; plain text, not markup
itemone 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.
onceTRUE 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().

◆ dt_gui_alert_add_button()

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().

◆ dt_gui_alert_add_text()

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.

Parameters
textplain text, already translated; NULL for a line the caller fills later
Returns
the label, for the caller to update: gtk_label_set_text() or _set_markup()

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().

◆ dt_gui_alert_add_widget()

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().

◆ dt_gui_alert_destroy()

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_new()

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.

Parameters
kindhow the window behaves, see dt_gui_alert_kind_t
titlethe window's title, already translated
headingthe bold line at the top, already translated
Returns
the alert, owned by its window: a NOTICE is freed when the user closes it, the other kinds by dt_gui_alert_destroy()

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().

◆ dt_gui_alert_set_cancel()

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().

◆ dt_gui_alert_show()

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().

Variable Documentation

◆ _alert_closed

GHashTable* _alert_closed = NULL
static

Definition at line 273 of file alert.c.

Referenced by _alert_show(), and _alert_window_items_destroyed().

◆ _alert_windows

GHashTable* _alert_windows = NULL
static

Definition at line 270 of file alert.c.

Referenced by _alert_show(), and _alert_window_items_destroyed().