![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "widgets/bauhaus.h"#include "common/paths.h"#include "database/image_repository.h"#include "common/variables.h"#include "metadata/colorlabels.h"#include "common/file_location.h"#include "common/image.h"#include "caches/image_cache.h"#include "metadata/metadata.h"#include "common/opencl.h"#include "common/utility.h"#include "metadata/tags.h"#include "common/datetime.h"#include "common/conf.h"#include <stdio.h>#include <string.h>#include <time.h>
Include dependency graph for src/common/variables.c:Go to the source code of this file.
Data Structures | |
| struct | dt_variables_data_t |
Typedefs | |
| typedef struct dt_variables_data_t | dt_variables_data_t |
| typedef enum _image_case | _image_case |
Enumerations | |
| enum | _image_case { NONE , FILENAME , IMGID } |
Functions | |
| static char * | _expand_source (dt_variables_params_t *params, char **source, char extra_stop) |
| gboolean | dt_get_user_pictures_dir (const gchar *homedir, gchar *picdir, size_t picdir_size) |
| Gets the path to the current OS pictures directory. | |
| static void | _init_expansion (dt_variables_params_t *params, gboolean iterate) |
| static void | _cleanup_expansion (dt_variables_params_t *params) |
| static gboolean | _has_prefix (char **str, const char *prefix) |
| static char * | _variables_get_longitude (dt_variables_params_t *params) |
| static char * | _variables_get_latitude (dt_variables_params_t *params) |
| static char * | _variables_get_iso_timestamp (const GTimeSpan gts) |
| static gboolean | _expand_datetime_now (dt_variables_params_t *params, char **variable, char **out) |
| Expand the current time, and the import/change/export/print timestamps. | |
| static gboolean | _expand_exif_datetime (dt_variables_params_t *params, char **variable, char **out) |
| Expand the capture time read from EXIF. | |
| static gboolean | _expand_exif_and_gps (dt_variables_params_t *params, char **variable, char **out) |
| Expand EXIF exposure settings, GPS position and camera identity. | |
| static gboolean | _expand_image_and_version (dt_variables_params_t *params, char **variable, char **out) |
| Expand image id, duplicate version, job code and film roll. | |
| static gboolean | _expand_file_and_folder (dt_variables_params_t *params, char **variable, char **out) |
| Expand the source file's path, name and mtime, plus the user's folders. | |
| static gboolean | _expand_rating_and_metadata (dt_variables_params_t *params, char **variable, char **out, gboolean *escape) |
| Expand star rating, colour labels and the Dublin Core fields. | |
| static gboolean | _expand_geometry_and_misc (dt_variables_params_t *params, char **variable, char **out) |
| Expand image dimensions, category, tags and build identity. | |
| static char * | _get_base_value (dt_variables_params_t *params, char **variable) |
| Expand one into its text. | |
| static char * | _variable_get_value (dt_variables_params_t *params, char **variable) |
| static void | _grow_buffer (char **result, char **result_iter, size_t *result_length, size_t extra_space) |
| char * | dt_variables_expand (dt_variables_params_t *params, gchar *source, gboolean iterate) |
| void | dt_variables_params_init (dt_variables_params_t **params) |
| void | dt_variables_params_destroy (dt_variables_params_t *params) |
| void | dt_variables_set_datetime (dt_variables_params_t *params, GDateTime *datetime) |
| void | dt_variables_set_max_width_height (dt_variables_params_t *params, int max_width, int max_height) |
| void | dt_variables_reset_sequence (dt_variables_params_t *params) |
| void | dt_variables_set_tags_flags (dt_variables_params_t *params, uint32_t flags) |
| typedef enum _image_case _image_case |
| typedef struct dt_variables_data_t dt_variables_data_t |
| enum _image_case |
| Enumerator | |
|---|---|
| NONE | |
| FILENAME | |
| IMGID | |
Definition at line 129 of file src/common/variables.c.
|
static |
Definition at line 269 of file src/common/variables.c.
References dt_free.
Referenced by dt_variables_expand().
|
static |
Expand the current time, and the import/change/export/print timestamps.
One link of the ordered chain _get_base_value() walks; see the contract documented there. Branch order inside this function is load-bearing for the same reason it is across the chain.
| params | expansion context. |
| variable | in/out: on a match, advanced past the name that was consumed. |
| out | written ONLY on a match, with a newly-allocated string the caller owns. |
Definition at line 344 of file src/common/variables.c.
References _has_prefix(), _variables_get_iso_timestamp(), DT_DATETIME_EXIF_LENGTH, dt_datetime_gdatetime_to_exif(), DT_DATETIME_LENGTH, FALSE, out, and TRUE.
Referenced by _get_base_value().
|
static |
Expand EXIF exposure settings, GPS position and camera identity.
One link of the ordered chain _get_base_value() walks; see the contract documented there. Branch order inside this function is load-bearing for the same reason it is across the chain.
| params | expansion context. |
| variable | in/out: on a match, advanced past the name that was consumed. |
| out | written ONLY on a match, with a newly-allocated string the caller owns. |
Definition at line 470 of file src/common/variables.c.
References _has_prefix(), _variables_get_latitude(), _variables_get_longitude(), dt_free, dt_util_format_exposure(), dt_util_str_replace(), FALSE, i, out, res, and TRUE.
Referenced by _get_base_value().
|
static |
Expand the capture time read from EXIF.
One link of the ordered chain _get_base_value() walks; see the contract documented there. Branch order inside this function is load-bearing for the same reason it is across the chain.
| params | expansion context. |
| variable | in/out: on a match, advanced past the name that was consumed. |
| out | written ONLY on a match, with a newly-allocated string the caller owns. |
Definition at line 416 of file src/common/variables.c.
References _has_prefix(), DT_DATETIME_EXIF_LENGTH, dt_datetime_gdatetime_to_exif(), DT_DATETIME_LENGTH, FALSE, out, and TRUE.
Referenced by _get_base_value().
|
static |
Expand the source file's path, name and mtime, plus the user's folders.
One link of the ordered chain _get_base_value() walks; see the contract documented there. Branch order inside this function is load-bearing for the same reason it is across the chain.
| params | expansion context. |
| variable | in/out: on a match, advanced past the name that was consumed. |
| out | written ONLY on a match, with a newly-allocated string the caller owns. |
Definition at line 609 of file src/common/variables.c.
References _has_prefix(), FALSE, out, and TRUE.
Referenced by _get_base_value().
|
static |
Expand image dimensions, category, tags and build identity.
One link of the ordered chain _get_base_value() walks; see the contract documented there. Branch order inside this function is load-bearing for the same reason it is across the chain.
| params | expansion context. |
| variable | in/out: on a match, advanced past the name that was consumed. |
| out | written ONLY on a match, with a newly-allocated string the caller owns. |
Definition at line 853 of file src/common/variables.c.
References _has_prefix(), darktable_package_version, dt_free, dt_free_gpointer(), dt_image_get_text_path(), DT_IMAGE_HAS_TXT, dt_tag_get_list_export(), dt_tag_get_subtags(), dt_util_glist_to_str(), FALSE, out, PACKAGE_NAME, and TRUE.
Referenced by _get_base_value().
|
static |
Expand image id, duplicate version, job code and film roll.
One link of the ordered chain _get_base_value() walks; see the contract documented there. Branch order inside this function is load-bearing for the same reason it is across the chain.
| params | expansion context. |
| variable | in/out: on a match, advanced past the name that was consumed. |
| out | written ONLY on a match, with a newly-allocated string the caller owns. |
Definition at line 541 of file src/common/variables.c.
References _has_prefix(), dt_free, dt_free_gpointer(), dt_image_cache_get(), dt_image_cache_read_release(), dt_image_print_exif(), dt_image_repository_get_duplicate_ids(), dt_metadata_get(), FALSE, IS_NULL_PTR, out, res, and TRUE.
Referenced by _get_base_value().
|
static |
Expand star rating, colour labels and the Dublin Core fields.
One link of the ordered chain _get_base_value() walks; see the contract documented there. Branch order inside this function is load-bearing for the same reason it is across the chain.
| params | expansion context. |
| variable | in/out: on a match, advanced past the name that was consumed. |
| out | written ONLY on a match, with a newly-allocated string the caller owns. |
| escape | cleared when the produced text must not be markup-escaped. |
Definition at line 709 of file src/common/variables.c.
References _has_prefix(), dt_bauhaus_t::colorlabels, dt_bauhaus_get_global(), dt_colorlabels_to_string(), dt_free_gpointer(), dt_metadata_get(), dt_opencl_is_enabled(), dt_util_dstrcat(), dt_util_glist_to_str(), FALSE, IS_NULL_PTR, out, res, and TRUE.
Referenced by _get_base_value().
|
static |
Definition at line 1260 of file src/common/variables.c.
References _grow_buffer(), _variable_get_value(), dt_free, and IS_NULL_PTR.
Referenced by _variable_get_value(), and dt_variables_expand().
|
static |
Expand one into its text.
The chain below is ORDERED and that order is load-bearing: _has_prefix() is g_str_has_prefix() plus a side effect – on a match it advances variable past the prefix – and it does not require a word boundary. A shorter prefix tried earlier therefore swallows every longer one starting with it, silently. Adding a name means placing it BEFORE any prefix of itself, not merely somewhere in the right group.
Split into one function per family only to keep each readable; the && short-circuit reproduces the single chain this used to be, link by link, in the same order.
| params | expansion context. |
| variable | in/out: advanced past whatever was consumed, including the characters skipped when nothing matched. |
Definition at line 957 of file src/common/variables.c.
References _expand_datetime_now(), _expand_exif_and_gps(), _expand_exif_datetime(), _expand_file_and_folder(), _expand_geometry_and_misc(), _expand_image_and_version(), _expand_rating_and_metadata(), dt_free, and TRUE.
Referenced by _variable_get_value().
|
static |
Definition at line 1249 of file src/common/variables.c.
Referenced by _expand_source().
|
inlinestatic |
Definition at line 283 of file src/common/variables.c.
References res.
Referenced by _expand_datetime_now(), _expand_exif_and_gps(), _expand_exif_datetime(), _expand_file_and_folder(), _expand_geometry_and_misc(), _expand_image_and_version(), and _expand_rating_and_metadata().
|
static |
Definition at line 159 of file src/common/variables.c.
References dt_image_t::camera_alias, dt_image_t::camera_maker, dt_image_t::change_timestamp, dt_image_t::crop_height, dt_image_t::crop_width, dt_conf_get_bool(), dt_datetime_img_to_gdatetime(), dt_datetime_utc_tz(), dt_get_user_pictures_dir(), dt_image_cache_get(), dt_image_cache_read_release(), DT_IMAGE_REJECTED, dt_loc_get_home_dir(), DT_PATH_MAX, dt_util_get_file_datetime(), dt_image_geoloc_t::elevation, dt_image_t::exif_aperture, dt_image_t::exif_exposure, dt_image_t::exif_exposure_bias, dt_image_t::exif_focal_length, dt_image_t::exif_focus_distance, dt_image_t::exif_iso, dt_image_t::exif_lens, dt_image_t::export_timestamp, FALSE, FILENAME, dt_image_t::flags, dt_image_t::geoloc, dt_image_t::height, IMGID, dt_image_t::import_timestamp, dt_image_geoloc_t::latitude, dt_image_geoloc_t::longitude, NONE, dt_image_t::p_height, dt_image_t::p_width, dt_image_t::print_timestamp, TRUE, UNKNOWN_IMAGE, dt_image_t::version, and dt_image_t::width.
Referenced by dt_variables_expand().
|
static |
Definition at line 988 of file src/common/variables.c.
References _expand_source(), _get_base_value(), dt_free, dt_util_str_replace(), MAX, MIN, and p.
Referenced by _expand_source().
|
static |
Definition at line 322 of file src/common/variables.c.
References dt_datetime_origin(), and IS_NULL_PTR.
Referenced by _expand_datetime_now().
|
static |
Definition at line 306 of file src/common/variables.c.
References dt_conf_get_bool(), and dt_util_latitude_str().
Referenced by _expand_exif_and_gps().
|
static |
Definition at line 290 of file src/common/variables.c.
References dt_conf_get_bool(), and dt_util_longitude_str().
Referenced by _expand_exif_and_gps().
| gboolean dt_get_user_pictures_dir | ( | const gchar * | homedir, |
| gchar * | picdir, | ||
| size_t | picdir_size | ||
| ) |
Gets the path to the current OS pictures directory.
| homedir | the user's home directory |
| picdir | the gchar* to set to the path of the pictures directory |
| picdir_size | the size of picdir |
gboolean Returns TRUE if success. Definition at line 138 of file src/common/variables.c.
References DT_PATH_MAX, and IS_NULL_PTR.
Referenced by _dt_check_basedir(), and _init_expansion().
| char * dt_variables_expand | ( | dt_variables_params_t * | params, |
| gchar * | source, | ||
| gboolean | iterate | ||
| ) |
expands variables in string. the result should be freed with g_free().
Definition at line 1315 of file src/common/variables.c.
References _cleanup_expansion(), _expand_source(), and _init_expansion().
Referenced by _dt_check_basedir(), _expand_text_for_preview(), _update_preview(), _watermark_get_svgdoc(), dt_build_filename_from_pattern(), dt_exif_xmp_attach_export(), dt_view_image_info_update(), run_test(), and store().
| void dt_variables_params_destroy | ( | dt_variables_params_t * | params | ) |
destroys an initialized dt_variables_params_t, pointer is garbage after this call.
Definition at line 1336 of file src/common/variables.c.
References dt_free.
Referenced by _clear_variables_cache(), _dt_check_basedir(), _update_preview(), _watermark_get_svgdoc(), dt_build_filename_from_pattern(), dt_exif_xmp_attach_export(), dt_view_image_info_update(), free_params(), run_test(), and store().
| void dt_variables_params_init | ( | dt_variables_params_t ** | params | ) |
allocate and initializes a dt_variables_params_t.
Definition at line 1325 of file src/common/variables.c.
Referenced by _dt_check_basedir(), _expand_text_for_preview(), _update_preview(), _watermark_get_svgdoc(), dt_build_filename_from_pattern(), dt_exif_xmp_attach_export(), dt_view_image_info_update(), get_params(), run_test(), and store().
| void dt_variables_reset_sequence | ( | dt_variables_params_t * | params | ) |
reset sequence number
Definition at line 1360 of file src/common/variables.c.
| void dt_variables_set_datetime | ( | dt_variables_params_t * | params, |
| GDateTime * | datetime | ||
| ) |
reset the date arbitrarily, decrementing reference count of the previous date
Definition at line 1348 of file src/common/variables.c.
Referenced by dt_build_filename_from_pattern().
| void dt_variables_set_max_width_height | ( | dt_variables_params_t * | params, |
| int | max_width, | ||
| int | max_height | ||
| ) |
set max image width and height defined for an export session in a dt_variables_params_t.
Definition at line 1354 of file src/common/variables.c.
Referenced by store().
| void dt_variables_set_tags_flags | ( | dt_variables_params_t * | params, |
| uint32_t | flags | ||
| ) |
set flags for tags to be exported
Definition at line 1365 of file src/common/variables.c.
References flags.
Referenced by _watermark_get_svgdoc(), and dt_exif_xmp_attach_export().