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
27 darktable is free software: you can redistribute it and/or modify
28 it under the terms of the GNU General Public License as published by
29 the Free Software Foundation, either version 3 of the License, or
30 (at your option) any later version.
31
32 darktable is distributed in the hope that it will be useful,
33 but WITHOUT ANY WARRANTY; without even the implied warranty of
34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 GNU General Public License for more details.
36
37 You should have received a copy of the GNU General Public License
38 along with darktable. If not, see <http://www.gnu.org/licenses/>.
39*/
40
41#ifndef DT_COMMON_CONF_H
42#define DT_COMMON_CONF_H
43
44#ifdef HAVE_CONFIG_H
45#include "config.h"
46#endif
47
48#include "system/dtpthread.h"
49#include "common/paths.h" // DT_PATH_MAX
50
51#include <glib.h>
52#include <gtk/gtk.h>
53#include <inttypes.h>
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
69
80
117
132
140
157
158void dt_conf_set_int(const char *name, int val);
159void dt_conf_set_int64(const char *name, int64_t val);
160void dt_conf_set_float(const char *name, float val);
161void dt_conf_set_bool(const char *name, int val);
162void dt_conf_set_string(const char *name, const char *val);
164/* The _fast readers return the STORED value. The plain readers return the same value
165 * CLAMPED to the min/max declared for that key in the generated XML, at the cost of two
166 * extra confgen lookups. "fast" therefore means "unclamped": for any key that declares
167 * bounds, the two can disagree, and a value out of range is exactly the case where it
168 * matters. Prefer the plain reader unless the key has no bounds or the caller clamps.
169 *
170 * All of them accept an arithmetic expression as the stored text -- it goes through the
171 * calculator -- and fall back to the XML default, then to 0, when it does not parse. */
172
174int dt_conf_get_int_fast(const char *name);
176int dt_conf_get_int(const char *name);
178int64_t dt_conf_get_int64_fast(const char *name);
180int64_t dt_conf_get_int64(const char *name);
182float dt_conf_get_float_fast(const char *name);
184float dt_conf_get_float(const char *name);
185int dt_conf_get_and_sanitize_int(const char *name, int min, int max);
186int64_t dt_conf_get_and_sanitize_int64(const char *name, int64_t min, int64_t max);
187float dt_conf_get_and_sanitize_float(const char *name, float min, float max);
188int dt_conf_get_bool(const char *name);
207const char *dt_conf_get_string_const(const char *name);
208
218gchar *dt_conf_get_string(const char *name);
220gboolean dt_conf_is_equal(const char *name, const char *value);
232void dt_conf_init(dt_conf_t *cf, const char *filename, GSList *override_entries);
233
236
239
248int dt_conf_key_exists(const char *key);
249gboolean dt_conf_key_not_empty(const char *key);
259GSList *dt_conf_all_string_entries(const char *dir);
260
263void dt_conf_string_entry_free(gpointer data);
264
265/* These three carry their own trailing semicolon, so a call site that adds one produces an
266 * empty statement -- harmless alone, but it makes `if(c) DT_CONF_SET_SANITIZED_INT(...);
267 * else ...` fail to compile. Brace the branch. */
268
270#define DT_CONF_SET_SANITIZED_INT(name, val, min, max) dt_conf_set_int(name, CLAMPS(val, min,max));
271
276#define DT_CONF_SET_SANITIZED_INT6464(name, val, min, max) dt_conf_set_int(name, CLAMPS(val, min,max));
277
279#define DT_CONF_SET_SANITIZED_FLOAT(name, val, min, max) dt_conf_set_float(name, CLAMPS(val, min,max));
280
281// conf generated from darktable config XML
282
283gboolean dt_confgen_exists(const char *name);
285
287
301const char *dt_confgen_get(const char *name, dt_confgen_value_kind_t kind);
302
305const char *dt_confgen_get_label(const char *name);
306
309const char *dt_confgen_get_tooltip(const char *name);
310
312gboolean dt_conf_is_default(const char *name);
313
318gchar* dt_conf_expand_default_dir(const char *dir);
319
320#ifdef __cplusplus
321}
322#endif
323
324#endif // DT_COMMON_CONF_H
325
326// clang-format off
327// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
328// vim: shiftwidth=2 expandtab tabstop=2 cindent
329// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
330// clang-format on
331
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_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.
void dt_conf_save(dt_conf_t *cf)
Write cf back to its file. Overridden keys keep their stored value.
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:60
@ DT_BOOL
Definition common/conf.h:64
@ DT_STRING
Definition common/conf.h:66
@ DT_FLOAT
Definition common/conf.h:63
@ DT_INT64
Definition common/conf.h:62
@ DT_ENUM
Definition common/conf.h:67
@ DT_PATH
Definition common/conf.h:65
@ DT_INT
Definition common/conf.h:61
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
static const dt_aligned_pixel_simd_t value
Definition simd.h:144
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.
Definition common/conf.h:99
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:72