Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
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
98typedef struct dt_conf_t
99{
101 dt_pthread_mutex_t mutex;
105 GHashTable *table;
107 GHashTable *x_confgen;
110 GHashTable *override_entries;
115 GPtrArray *retired_values;
117
132
140
141void dt_conf_set_int(const char *name, int val);
142void dt_conf_set_int64(const char *name, int64_t val);
143void dt_conf_set_float(const char *name, float val);
144void dt_conf_set_bool(const char *name, int val);
145void dt_conf_set_string(const char *name, const char *val);
146void dt_conf_set_folder_from_file_chooser(const char *name, GtkFileChooser *chooser);
147/* The _fast readers return the STORED value. The plain readers return the same value
148 * CLAMPED to the min/max declared for that key in the generated XML, at the cost of two
149 * extra confgen lookups. "fast" therefore means "unclamped": for any key that declares
150 * bounds, the two can disagree, and a value out of range is exactly the case where it
151 * matters. Prefer the plain reader unless the key has no bounds or the caller clamps.
152 *
153 * All of them accept an arithmetic expression as the stored text -- it goes through the
154 * calculator -- and fall back to the XML default, then to 0, when it does not parse. */
155
157int dt_conf_get_int_fast(const char *name);
159int dt_conf_get_int(const char *name);
161int64_t dt_conf_get_int64_fast(const char *name);
163int64_t dt_conf_get_int64(const char *name);
165float dt_conf_get_float_fast(const char *name);
167float dt_conf_get_float(const char *name);
168int dt_conf_get_and_sanitize_int(const char *name, int min, int max);
169int64_t dt_conf_get_and_sanitize_int64(const char *name, int64_t min, int64_t max);
170float dt_conf_get_and_sanitize_float(const char *name, float min, float max);
171int dt_conf_get_bool(const char *name);
190const char *dt_conf_get_string_const(const char *name);
191
201gchar *dt_conf_get_string(const char *name);
202gboolean dt_conf_get_folder_to_file_chooser(const char *name, GtkFileChooser *chooser);
203gboolean dt_conf_is_equal(const char *name, const char *value);
215void dt_conf_init(dt_conf_t *cf, const char *filename, GSList *override_entries);
216
218void dt_conf_cleanup(dt_conf_t *cf);
219
221void dt_conf_save(dt_conf_t *cf);
222
231int dt_conf_key_exists(const char *key);
232gboolean dt_conf_key_not_empty(const char *key);
242GSList *dt_conf_all_string_entries(const char *dir);
243
246void dt_conf_string_entry_free(gpointer data);
247
248/* These three carry their own trailing semicolon, so a call site that adds one produces an
249 * empty statement -- harmless alone, but it makes `if(c) DT_CONF_SET_SANITIZED_INT(...);
250 * else ...` fail to compile. Brace the branch. */
251
253#define DT_CONF_SET_SANITIZED_INT(name, val, min, max) dt_conf_set_int(name, CLAMPS(val, min,max));
254
259#define DT_CONF_SET_SANITIZED_INT6464(name, val, min, max) dt_conf_set_int(name, CLAMPS(val, min,max));
260
262#define DT_CONF_SET_SANITIZED_FLOAT(name, val, min, max) dt_conf_set_float(name, CLAMPS(val, min,max));
263
264// conf generated from darktable config XML
265
266gboolean dt_confgen_exists(const char *name);
268
270
284const char *dt_confgen_get(const char *name, dt_confgen_value_kind_t kind);
285
288const char *dt_confgen_get_label(const char *name);
289
292const char *dt_confgen_get_tooltip(const char *name);
293
295gboolean dt_conf_is_default(const char *name);
296
301gchar* dt_conf_expand_default_dir(const char *dir);
302
303#ifdef __cplusplus
304}
305#endif
306
307#endif // DT_COMMON_CONF_H
308
309// clang-format off
310// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
311// vim: shiftwidth=2 expandtab tabstop=2 cindent
312// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
313// clang-format on
314
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...
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
Definition conf.h:134
@ DT_DEFAULT
Definition conf.h:135
@ DT_MAX
Definition conf.h:137
@ DT_MIN
Definition conf.h:136
@ DT_VALUES
Definition conf.h:138
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 conf.h:60
@ DT_BOOL
Definition conf.h:64
@ DT_STRING
Definition conf.h:66
@ DT_FLOAT
Definition conf.h:63
@ DT_INT64
Definition conf.h:62
@ DT_ENUM
Definition conf.h:67
@ DT_PATH
Definition conf.h:65
@ DT_INT
Definition 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
One key/value pair handed back by dt_conf_all_string_entries().
Definition conf.h:126
char * key
Definition conf.h:128
char * value
Definition conf.h:130
The whole configuration state. One instance lives at darktable.conf.
Definition conf.h:99
GHashTable * override_entries
Definition conf.h:110
GPtrArray * retired_values
Definition conf.h:115
dt_pthread_mutex_t mutex
Definition conf.h:101
GHashTable * x_confgen
Definition conf.h:107
GHashTable * table
Definition conf.h:105
char filename[DT_PATH_MAX]
Definition conf.h:103
char * enum_values
Definition conf.h:76
char * shortdesc
Definition conf.h:77
dt_confgen_type_t type
Definition conf.h:72
char * longdesc
Definition conf.h:78