Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
pipeline_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
20
21#include "system/mem_alloc.h"
22
23#include <stdarg.h>
24
25/* Written once, at startup, before any pipeline exists; read from the worker threads.
26 * A lock would be guarding against a race nobody can create. */
29
34
35void dt_pipeline_message(const char *format, ...)
36{
38 if(handler == NULL) return; // headless export, or a unit test: nothing to tell
39
40 va_list args;
41 va_start(args, format);
42 gchar *message = g_strdup_vprintf(format, args);
43 va_end(args);
44
45 if(message)
46 {
47 handler(message);
48 dt_free(message);
49 }
50}
51
56
57void dt_pipeline_busy_printf(const char *format, ...)
58{
60 if(handler == NULL) return;
61
62 va_list args;
63 va_start(args, format);
64 gchar *message = g_strdup_vprintf(format, args);
65 va_end(args);
66
67 if(message)
68 {
69 handler(message);
70 dt_free(message);
71 }
72}
73
75{
77 if(handler) handler(NULL);
78}
79
80// clang-format off
81// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
82// vim: shiftwidth=2 expandtab tabstop=2 cindent
83// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
84// clang-format on
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
Definition mem_alloc.h:171
void dt_pipeline_set_message_handler(dt_pipeline_message_handler_t handler)
Install the handler, or NULL to remove it. Messages raised with none installed are dropped.
void dt_pipeline_set_busy_handler(dt_pipeline_busy_handler_t handler)
void dt_pipeline_message(const char *format,...)
void dt_pipeline_busy_printf(const char *format,...)
static dt_pipeline_busy_handler_t _busy_handler
void dt_pipeline_busy_clear(void)
Processing finished; clear the banner.
static dt_pipeline_message_handler_t _message_handler
Everything the pixel pipeline says to whoever is watching: messages for the user, and the busy banner...
G_BEGIN_DECLS typedef void(* dt_pipeline_message_handler_t)(const char *message)
Receives one formatted, already-translated message for the user. Was dt_control_log() from pipeline c...
void typedef void(* dt_pipeline_busy_handler_t)(const char *message_or_null)
Receives the busy-banner text, or NULL when processing finished and the banner should clear....