Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
common/conf.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010-2011, 2014 Henrik Andersson.
4 Copyright (C) 2010-2013 johannes hanika.
5 Copyright (C) 2010, 2012-2017 Tobias Ellinghaus.
6 Copyright (C) 2012 Christian Tellefsen.
7 Copyright (C) 2012 Jérémy Rosen.
8 Copyright (C) 2012 Richard Wonka.
9 Copyright (C) 2012 Simon Spannagel.
10 Copyright (C) 2012, 2014 Ulrich Pegelow.
11 Copyright (C) 2013 Jean-Sébastien Pédron.
12 Copyright (C) 2013 Jesper Pedersen.
13 Copyright (C) 2014 parafin.
14 Copyright (C) 2014, 2020-2021 Pascal Obry.
15 Copyright (C) 2014, 2016 Roman Lebedev.
16 Copyright (C) 2016-2018 Peter Budai.
17 Copyright (C) 2019 jakubfi.
18 Copyright (C) 2020 Hubert Kowalski.
19 Copyright (C) 2020 Philippe Weyland.
20 Copyright (C) 2021 Marco Carrarini.
21 Copyright (C) 2021 Mark-64.
22 Copyright (C) 2021 Ralf Brown.
23 Copyright (C) 2022 Hanno Schwalm.
24 Copyright (C) 2022 Martin Bařinka.
25 Copyright (C) 2025 Alynx Zhou.
26 Copyright (C) 2026 Aurélien PIERRE.
27 Copyright (C) 2026 Guillaume Stutin.
28
29 darktable is free software: you can redistribute it and/or modify
30 it under the terms of the GNU General Public License as published by
31 the Free Software Foundation, either version 3 of the License, or
32 (at your option) any later version.
33
34 darktable is distributed in the hope that it will be useful,
35 but WITHOUT ANY WARRANTY; without even the implied warranty of
36 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 GNU General Public License for more details.
38
39 You should have received a copy of the GNU General Public License
40 along with darktable. If not, see <http://www.gnu.org/licenses/>.
41*/
42
43#ifndef DT_COMMON_CONF_H
44#define DT_COMMON_CONF_H
45
46#ifdef HAVE_CONFIG_H
47#include "config.h"
48#endif
49
50#include "system/dtpthread.h"
51#include "common/paths.h" // DT_PATH_MAX
52
53#include <glib.h>
54#include <gtk/gtk.h>
55#include <inttypes.h>
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
71
82
100typedef struct dt_conf_t
101{
103 dt_pthread_mutex_t mutex;
107 GHashTable *table;
109 GHashTable *x_confgen;
112 GHashTable *override_entries;
117 GPtrArray *retired_values;
119
134
142
159
160void dt_conf_set_int(const char *name, int val);
161void dt_conf_set_int64(const char *name, int64_t val);
162void dt_conf_set_float(const char *name, float val);
163void dt_conf_set_bool(const char *name, int val);
164void dt_conf_set_string(const char *name, const char *val);
165void dt_conf_set_folder_from_file_chooser(const char *name, GtkFileChooser *chooser);
166/* The _fast readers return the STORED value. The plain readers return the same value
167 * CLAMPED to the min/max declared for that key in the generated XML, at the cost of two
168 * extra confgen lookups. "fast" therefore means "unclamped": for any key that declares
169 * bounds, the two can disagree, and a value out of range is exactly the case where it
170 * matters. Prefer the plain reader unless the key has no bounds or the caller clamps.
171 *
172 * All of them accept an arithmetic expression as the stored text -- it goes through the
173 * calculator -- and fall back to the XML default, then to 0, when it does not parse. */
174
176int dt_conf_get_int_fast(const char *name);
178int dt_conf_get_int(const char *name);
180int64_t dt_conf_get_int64_fast(const char *name);
182int64_t dt_conf_get_int64(const char *name);
184float dt_conf_get_float_fast(const char *name);
186float dt_conf_get_float(const char *name);
187int dt_conf_get_and_sanitize_int(const char *name, int min, int max);
188int64_t dt_conf_get_and_sanitize_int64(const char *name, int64_t min, int64_t max);
189float dt_conf_get_and_sanitize_float(const char *name, float min, float max);
190int dt_conf_get_bool(const char *name);
209const char *dt_conf_get_string_const(const char *name);
210
220gchar *dt_conf_get_string(const char *name);
221gboolean dt_conf_get_folder_to_file_chooser(const char *name, GtkFileChooser *chooser);
222gboolean dt_conf_is_equal(const char *name, const char *value);
234void dt_conf_init(dt_conf_t *cf, const char *filename, GSList *override_entries);
235
237void dt_conf_cleanup(dt_conf_t *cf);
238
245int dt_conf_flush(void);
246
255int dt_conf_key_exists(const char *key);
256gboolean dt_conf_key_not_empty(const char *key);
266GSList *dt_conf_all_string_entries(const char *dir);
267
270void dt_conf_string_entry_free(gpointer data);
271
272/* These three carry their own trailing semicolon, so a call site that adds one produces an
273 * empty statement -- harmless alone, but it makes `if(c) DT_CONF_SET_SANITIZED_INT(...);
274 * else ...` fail to compile. Brace the branch. */
275
277#define DT_CONF_SET_SANITIZED_INT(name, val, min, max) dt_conf_set_int(name, CLAMPS(val, min,max));
278
283#define DT_CONF_SET_SANITIZED_INT6464(name, val, min, max) dt_conf_set_int(name, CLAMPS(val, min,max));
284
286#define DT_CONF_SET_SANITIZED_FLOAT(name, val, min, max) dt_conf_set_float(name, CLAMPS(val, min,max));
287
288// conf generated from darktable config XML
289
290gboolean dt_confgen_exists(const char *name);
292
294
308const char *dt_confgen_get(const char *name, dt_confgen_value_kind_t kind);
309
312const char *dt_confgen_get_label(const char *name);
313
316const char *dt_confgen_get_tooltip(const char *name);
317
319gboolean dt_conf_is_default(const char *name);
320
325gchar* dt_conf_expand_default_dir(const char *dir);
326
327#ifdef __cplusplus
328}
329#endif
330
331#endif // DT_COMMON_CONF_H
332
333// clang-format off
334// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
335// vim: shiftwidth=2 expandtab tabstop=2 cindent
336// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
337// clang-format on
338
static const dt_adaptation_t kind
static const float const float const float min
const float max
void dt_conf_cleanup(dt_conf_t *cf)
Free everything cf owns. No dt_conf_*() call is valid afterwards.
void dt_conf_string_entry_free(gpointer data)
Free one dt_conf_string_entry_t. Shaped as a GDestroyNotify so it can be handed to g_slist_free_full(...
void dt_conf_set_bool(const char *name, int val)
int dt_conf_flush(void)
Write the settings to their file now. Overridden keys keep their stored value.
int dt_conf_get_bool(const char *name)
gboolean dt_conf_key_not_empty(const char *key)
int dt_conf_key_exists(const char *key)
Does key have a value?
float dt_confgen_get_float(const char *name, dt_confgen_value_kind_t kind)
int64_t dt_conf_get_int64_fast(const char *name)
Stored 64-bit integer for name, NOT clamped.
void dt_conf_init(dt_conf_t *cf, const char *filename, GSList *override_entries)
Populate cf from filename and from the generated defaults.
void dt_conf_set_float(const char *name, float val)
float dt_conf_get_float(const char *name)
Float for name, clamped to its declared bounds.
const char * dt_confgen_get_tooltip(const char *name)
Translated long description of name, borrowed and valid for the process lifetime. NULL when name is n...
uint64_t dt_conf_generation(void)
A counter that advances whenever a conf value actually changes.
gchar * dt_conf_get_string(const char *name)
Read the stored string for name as a private copy.
int dt_conf_get_int_fast(const char *name)
Stored integer for name, NOT clamped to its declared bounds.
int dt_conf_get_and_sanitize_int(const char *name, int min, int max)
void dt_conf_set_int(const char *name, int val)
gboolean dt_confgen_get_bool(const char *name, dt_confgen_value_kind_t kind)
void dt_conf_set_int64(const char *name, int64_t val)
gchar * dt_conf_expand_default_dir(const char *dir)
Expand the placeholders in a default directory string.
GSList * dt_conf_all_string_entries(const char *dir)
Every key under dir, as a list of copies.
gboolean dt_conf_is_default(const char *name)
Is name still at the value declared in the XML? FALSE for an undeclared key.
dt_confgen_value_kind_t
@ DT_DEFAULT
@ DT_MAX
@ DT_MIN
@ DT_VALUES
int dt_conf_get_int(const char *name)
Integer for name, clamped to the bounds declared in the XML.
int64_t dt_conf_get_int64(const char *name)
64-bit integer for name, clamped to its declared bounds.
gboolean dt_confgen_value_exists(const char *name, dt_confgen_value_kind_t kind)
int64_t dt_confgen_get_int64(const char *name, dt_confgen_value_kind_t kind)
gboolean dt_confgen_exists(const char *name)
int dt_confgen_get_int(const char *name, dt_confgen_value_kind_t kind)
void dt_conf_set_string(const char *name, const char *val)
float dt_conf_get_float_fast(const char *name)
Stored float for name, NOT clamped.
const char * dt_conf_get_string_const(const char *name)
Borrow the stored string for name without copying it.
const char * dt_confgen_get(const char *name, dt_confgen_value_kind_t kind)
One declared attribute of name from the generated XML, as text.
int64_t dt_conf_get_and_sanitize_int64(const char *name, int64_t min, int64_t max)
void dt_conf_set_folder_from_file_chooser(const char *name, GtkFileChooser *chooser)
dt_confgen_type_t dt_confgen_type(const char *name)
gboolean dt_conf_is_equal(const char *name, const char *value)
const char * dt_confgen_get_label(const char *name)
Translated short description of name, borrowed and valid for the process lifetime....
gboolean dt_conf_get_folder_to_file_chooser(const char *name, GtkFileChooser *chooser)
float dt_conf_get_and_sanitize_float(const char *name, float min, float max)
dt_confgen_type_t
Definition common/conf.h:62
@ DT_BOOL
Definition common/conf.h:66
@ DT_STRING
Definition common/conf.h:68
@ DT_FLOAT
Definition common/conf.h:65
@ DT_INT64
Definition common/conf.h:64
@ DT_ENUM
Definition common/conf.h:69
@ DT_PATH
Definition common/conf.h:67
@ DT_INT
Definition common/conf.h:63
dev roi_request value
void * data
Definition geometry.h:111
char * key
#define DT_PATH_MAX
Buffer size for a filesystem path anywhere in Ansel.
Definition paths.h:57
const char * name
Definition pdf.h:90
unsigned __int64 uint64_t
Definition strptime.c:75
One key/value pair handed back by dt_conf_all_string_entries().
char * key
char * value
The whole configuration state. One instance lives at darktable.conf.
GHashTable * override_entries
GPtrArray * retired_values
dt_pthread_mutex_t mutex
GHashTable * x_confgen
GHashTable * table
char filename[DT_PATH_MAX]
dt_confgen_type_t type
Definition common/conf.h:74