Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
history/notify.c
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include "history/notify.h"
20
21#include "system/mem_alloc.h"
22
23#include <stdarg.h>
24
25/* Written once, at startup, before any worker exists; read from whichever thread makes a
26 * change. A lock would be guarding against a race nobody can create. */
30
35
36void dt_history_message(const char *format, ...)
37{
39 if(handler == NULL) return; // headless, or a unit test: nothing to tell
40
41 va_list args;
42 va_start(args, format);
43 gchar *message = g_strdup_vprintf(format, args);
44 va_end(args);
45
46 if(message)
47 {
48 handler(message);
49 dt_free(message);
50 }
51}
52
54
59
60void dt_history_toast(const char *format, ...)
61{
63 if(handler == NULL) return;
64
65 va_list args;
66 va_start(args, format);
67 gchar *message = g_strdup_vprintf(format, args);
68 va_end(args);
69
70 if(message)
71 {
72 handler(message);
73 dt_free(message);
74 }
75}
76
81
87
92
98
99// clang-format off
100// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
101// vim: shiftwidth=2 expandtab tabstop=2 cindent
102// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
103// clang-format on
void dt_history_toast(const char *format,...)
static dt_history_changed_handler_t _changed_handler
static dt_history_message_handler_t _message_handler
void dt_history_message(const char *format,...)
void dt_history_set_toast_handler(dt_history_toast_handler_t handler)
void dt_history_changed_images(const GList *imgs)
void dt_history_changed(const dt_history_change_t what)
Raise it. Internal to this code.
void dt_history_set_images_changed_handler(dt_history_images_changed_handler_t handler)
static dt_history_images_changed_handler_t _images_changed_handler
static dt_history_toast_handler_t _toast_handler
void dt_history_set_changed_handler(dt_history_changed_handler_t handler)
void dt_history_set_message_handler(dt_history_message_handler_t handler)
Install the handler, or NULL to remove it. Messages raised with none installed are dropped.
Everything the history, styles and presets code says to the outside world: messages for the user,...
void(* dt_history_images_changed_handler_t)(const GList *imgs)
The development of these images changed. Was DT_SIGNAL_IMAGE_INFO_CHANGED.
void(* dt_history_changed_handler_t)(const dt_history_change_t what)
Whoever is displaying any of this should look again.
void typedef void(* dt_history_toast_handler_t)(const char *message)
Same contract, transient acknowledgement flavour. Was dt_toast_log().
G_BEGIN_DECLS typedef void(* dt_history_message_handler_t)(const char *message)
Receives one formatted, already-translated message for the user.
dt_history_change_t
What changed. Each value stands for one signal this code used to raise itself.
#define dt_free(ptr)
Definition mem_alloc.h:97