Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
metadata.c File Reference
#include "metadata/metadata.h"
#include "common/act_on.h"
#include "database/colorlabel_repository.h"
#include "database/image_repository.h"
#include "database/metadata_repository.h"
#include "database/tag_repository.h"
#include "common/undo.h"
#include "common/conf.h"
#include <stdlib.h>
#include "common/utility.h"
#include <glib/gi18n.h>
#include "common/image.h"
#include "system/macros.h"
#include "system/mem_alloc.h"
Include dependency graph for metadata/metadata.c:

Go to the source code of this file.

Data Structures

Typedefs

typedef struct dt_undo_metadata_t dt_undo_metadata_t
typedef enum dt_tag_actions_t dt_tag_actions_t

Enumerations

enum  dt_tag_actions_t {
  DT_MA_SET = 0 ,
  DT_MA_ADD ,
  DT_MA_REMOVE
}

Functions

unsigned int dt_metadata_get_nb_user_metadata ()
const char * dt_metadata_get_name_by_display_order (const uint32_t order)
dt_metadata_t dt_metadata_get_keyid_by_display_order (const uint32_t order)
dt_metadata_t dt_metadata_get_keyid_by_name (const char *name)
int dt_metadata_get_type_by_display_order (const uint32_t order)
const char * dt_metadata_get_name (const uint32_t keyid)
dt_metadata_t dt_metadata_get_keyid (const char *key)
const char * dt_metadata_get_key (const uint32_t keyid)
const char * dt_metadata_get_subkey (const uint32_t keyid)
const char * dt_metadata_get_key_by_subkey (const char *subkey)
int dt_metadata_get_type (const uint32_t keyid)
void dt_metadata_init ()
static GList * _list_find_custom (GList *list, gpointer data)
static gchar * _get_tb_removed_metadata_string_values (GList *before, GList *after)
static GArray * _get_tb_added_metadata_rows (const int img, GList *before, GList *after)
static void _bulk_remove_metadata (const int img, const gchar *metadata_list)
static void _bulk_add_metadata (GArray *rows)
static void _pop_undo_execute (const int32_t imgid, GList *before, GList *after)
static void _pop_undo (gpointer user_data, const dt_undo_type_t type, dt_undo_data_t data, const dt_undo_action_t action, GList **imgs)
GList * dt_metadata_get_list_id (const int id)
static void _undo_metadata_free (gpointer data)
static void _metadata_undo_data_free (gpointer data)
gchar * _cleanup_metadata_value (const gchar *value)
GList * dt_metadata_get (const int id, const char *key, uint32_t *count)
void dt_metadata_cleanup (void)
static void _metadata_add_metadata_to_list (GList **list, const GList *metadata)
static void _metadata_remove_metadata_from_list (GList **list, const GList *metadata)
static void _metadata_execute (const GList *imgs, const GList *metadata, GList **undo, const gboolean undo_on, const gint action)
void dt_metadata_set (const int32_t imgid, const char *key, const char *value, const gboolean undo_on)
void dt_metadata_set_import (const int32_t imgid, const char *key, const char *value)
void dt_metadata_set_list (const GList *imgs, GList *key_value, const gboolean undo_on)
void dt_metadata_clear (const GList *imgs, const gboolean undo_on)
void dt_metadata_set_list_id (const GList *img, const GList *metadata, const gboolean clear_on, const gboolean undo_on)
int dt_metadata_already_imported (const char *filename, const char *datetime)

Variables

struct { 
   char *   key 
   char *   name 
   int   type 
   uint32_t   display_order 
} dt_metadata_def []

Typedef Documentation

◆ dt_tag_actions_t

◆ dt_undo_metadata_t

typedef struct dt_undo_metadata_t dt_undo_metadata_t

Enumeration Type Documentation

◆ dt_tag_actions_t

Enumerator
DT_MA_SET 
DT_MA_ADD 
DT_MA_REMOVE 

Definition at line 468 of file metadata/metadata.c.

Function Documentation

◆ _bulk_add_metadata()

void _bulk_add_metadata ( GArray * rows)
static

Definition at line 308 of file metadata/metadata.c.

References dt_metadata_repository_add().

Referenced by _pop_undo_execute().

◆ _bulk_remove_metadata()

void _bulk_remove_metadata ( const int img,
const gchar * metadata_list )
static

Definition at line 303 of file metadata/metadata.c.

References dt_metadata_repository_remove().

Referenced by _pop_undo_execute().

◆ _cleanup_metadata_value()

gchar * _cleanup_metadata_value ( const gchar * value)

Definition at line 363 of file metadata/metadata.c.

References dt_free, v, and value.

Referenced by dt_metadata_set(), dt_metadata_set_import(), and dt_metadata_set_list().

◆ _get_tb_added_metadata_rows()

GArray * _get_tb_added_metadata_rows ( const int img,
GList * before,
GList * after )
static

Definition at line 273 of file metadata/metadata.c.

References _list_find_custom(), FALSE, row, and value.

Referenced by _pop_undo_execute().

◆ _get_tb_removed_metadata_string_values()

gchar * _get_tb_removed_metadata_string_values ( GList * before,
GList * after )
static

Definition at line 239 of file metadata/metadata.c.

References _list_find_custom(), dt_util_dstrcat(), FALSE, and value.

Referenced by _pop_undo_execute().

◆ _list_find_custom()

GList * _list_find_custom ( GList * list,
gpointer data )
static

◆ _metadata_add_metadata_to_list()

void _metadata_add_metadata_to_list ( GList ** list,
const GList * metadata )
static

Definition at line 419 of file metadata/metadata.c.

References _list_find_custom(), dt_free, FALSE, and m.

Referenced by _metadata_execute().

◆ _metadata_execute()

◆ _metadata_remove_metadata_from_list()

void _metadata_remove_metadata_from_list ( GList ** list,
const GList * metadata )
static

Definition at line 446 of file metadata/metadata.c.

References _list_find_custom(), dt_free, and m.

Referenced by _metadata_execute().

◆ _metadata_undo_data_free()

void _metadata_undo_data_free ( gpointer data)
static

◆ _pop_undo()

void _pop_undo ( gpointer user_data,
const dt_undo_type_t type,
dt_undo_data_t data,
const dt_undo_action_t action,
GList ** imgs )
static

◆ _pop_undo_execute()

void _pop_undo_execute ( const int32_t imgid,
GList * before,
GList * after )
static

◆ _undo_metadata_free()

void _undo_metadata_free ( gpointer data)
static

◆ dt_metadata_already_imported()

int dt_metadata_already_imported ( const char * filename,
const char * datetime )

Return the first imgid of the filename-datetime "Xmp.darktable.image_id" if it already exists

Definition at line 694 of file metadata/metadata.c.

References dt_free, dt_metadata_repository_find_image_by_value(), FALSE, IS_NULL_PTR, and UNKNOWN_IMAGE.

Referenced by _is_in_library_by_metadata().

◆ dt_metadata_cleanup()

void dt_metadata_cleanup ( void )

cleanup cached statements

Definition at line 414 of file metadata/metadata.c.

References dt_metadata_repository_cleanup().

Referenced by dt_cleanup().

◆ dt_metadata_clear()

◆ dt_metadata_get()

GList * dt_metadata_get ( int id,
const char * key,
uint32_t * count )

Get metadata (named keys) for a specific image, or all selected for id == -1. For keys which return a string, the caller has to make sure that it is freed after usage.

Definition at line 380 of file metadata/metadata.c.

References dt_colorlabel_repository_get_list(), dt_image_repository_get_ratings(), dt_metadata_get_keyid(), dt_metadata_repository_get_values(), dt_tag_repository_get_attached_names(), IS_NULL_PTR, and key.

Referenced by _expand_image_and_version(), _expand_rating_and_metadata(), _metadata_view_update_values(), _print_button_clicked(), _write_xmp_id(), dt_exif_read_blob(), and store().

◆ dt_metadata_get_key()

const char * dt_metadata_get_key ( const uint32_t keyid)

return the key of the metadata keyid

Definition at line 159 of file metadata/metadata.c.

References dt_metadata_def, and DT_METADATA_NUMBER.

Referenced by _metadata_set_list(), _metadata_view_update_values(), _xmp_append_metadata(), dt_exif_decode_xmp_data(), and set_params().

◆ dt_metadata_get_key_by_subkey()

const char * dt_metadata_get_key_by_subkey ( const char * subkey)

return the key of the metadata subkey

Definition at line 177 of file metadata/metadata.c.

References dt_metadata_def, DT_METADATA_NUMBER, i, key, and t.

◆ dt_metadata_get_keyid()

dt_metadata_t dt_metadata_get_keyid ( const char * key)

return the keyid of the metadata key

Definition at line 148 of file metadata/metadata.c.

References dt_metadata_def, DT_METADATA_NUMBER, i, IS_NULL_PTR, and key.

Referenced by dt_metadata_get(), dt_metadata_set(), dt_metadata_set_import(), and dt_metadata_set_list().

◆ dt_metadata_get_keyid_by_display_order()

◆ dt_metadata_get_keyid_by_name()

dt_metadata_t dt_metadata_get_keyid_by_name ( const char * name)

return the metadata keyid by name

Definition at line 116 of file metadata/metadata.c.

References dt_metadata_def, DT_METADATA_NUMBER, i, IS_NULL_PTR, and name.

◆ dt_metadata_get_list_id()

GList * dt_metadata_get_list_id ( int id)

Get metadata (id keys) for a specific image. The caller has to free the list after usage.

Definition at line 341 of file metadata/metadata.c.

References dt_metadata_repository_get_all().

Referenced by _metadata_execute().

◆ dt_metadata_get_name()

const char * dt_metadata_get_name ( const uint32_t keyid)

◆ dt_metadata_get_name_by_display_order()

const char * dt_metadata_get_name_by_display_order ( const uint32_t order)

return the metadata key by display order

Definition at line 90 of file metadata/metadata.c.

References display_order, dt_metadata_def, DT_METADATA_NUMBER, and i.

Referenced by _menuitem_preferences(), _update_layout(), dt_collection_name(), gui_init(), and gui_reset().

◆ dt_metadata_get_nb_user_metadata()

unsigned int dt_metadata_get_nb_user_metadata ( )

return the number of user metadata (!= DT_METADATA_TYPE_INTERNAL)

Definition at line 79 of file metadata/metadata.c.

References dt_metadata_def, DT_METADATA_NUMBER, DT_METADATA_TYPE_INTERNAL, i, and type.

Referenced by add_rights_preset().

◆ dt_metadata_get_subkey()

const char * dt_metadata_get_subkey ( const uint32_t keyid)

return the metadata subeky of the metadata keyid

Definition at line 167 of file metadata/metadata.c.

References dt_metadata_def, DT_METADATA_NUMBER, key, and t.

◆ dt_metadata_get_type()

◆ dt_metadata_get_type_by_display_order()

int dt_metadata_get_type_by_display_order ( const uint32_t order)

return the metadata type by display order

Definition at line 127 of file metadata/metadata.c.

References display_order, dt_metadata_def, DT_METADATA_NUMBER, and i.

Referenced by _menuitem_preferences(), _update_layout(), dt_collection_name(), get_params(), gui_cleanup(), gui_init(), gui_reset(), and set_params().

◆ dt_metadata_init()

◆ dt_metadata_set()

◆ dt_metadata_set_import()

void dt_metadata_set_import ( const int32_t imgid,
const char * key,
const char * value )

◆ dt_metadata_set_list()

void dt_metadata_set_list ( const GList * imgs,
GList * key_value,
const gboolean undo_on )

Set metadata (named keys) for a specific image, or all selected for id == -1. list is a set of key, value

Definition at line 592 of file metadata/metadata.c.

References _cleanup_metadata_value(), _metadata_execute(), _metadata_undo_data_free(), _pop_undo(), dt_free_gpointer(), DT_MA_ADD, dt_metadata_get_keyid(), dt_undo_end_group(), dt_undo_get_global(), DT_UNDO_METADATA, dt_undo_record(), dt_undo_start_group(), key, and value.

Referenced by _write_metadata(), and set_params().

◆ dt_metadata_set_list_id()

void dt_metadata_set_list_id ( const GList * img,
const GList * metadata,
const gboolean clear_on,
const gboolean undo_on )

Set metadata (id keys) for a list of images. list is a set of keyid, value if clear_on TRUE the image metadata are cleared before attaching the new ones

Definition at line 676 of file metadata/metadata.c.

References _metadata_execute(), _metadata_undo_data_free(), _pop_undo(), DT_MA_ADD, DT_MA_SET, dt_undo_end_group(), dt_undo_get_global(), DT_UNDO_METADATA, dt_undo_record(), and dt_undo_start_group().

Variable Documentation

◆ display_order

◆ [struct]

const struct { ... } dt_metadata_def[]
Initial value:
= {
{"Xmp.dc.creator", N_("creator"), DT_METADATA_TYPE_USER, 2},
{"Xmp.dc.publisher", N_("publisher"), DT_METADATA_TYPE_USER, 3},
{"Xmp.dc.title", N_("title"), DT_METADATA_TYPE_USER, 0},
{"Xmp.dc.description", N_("description"), DT_METADATA_TYPE_USER, 1},
{"Xmp.dc.rights", N_("rights"), DT_METADATA_TYPE_USER, 4},
{"Xmp.acdsee.notes", N_("notes"), DT_METADATA_TYPE_USER, 5},
{"Xmp.darktable.version_name", N_("version name"), DT_METADATA_TYPE_OPTIONAL, 6},
{"Xmp.darktable.image_id", N_("image id"), DT_METADATA_TYPE_INTERNAL, 7}
}
@ DT_METADATA_TYPE_OPTIONAL
Definition metadata.h:64
@ DT_METADATA_TYPE_INTERNAL
Definition metadata.h:65
@ DT_METADATA_TYPE_USER
Definition metadata.h:63

Referenced by dt_metadata_get_key(), dt_metadata_get_key_by_subkey(), dt_metadata_get_keyid(), dt_metadata_get_keyid_by_display_order(), dt_metadata_get_keyid_by_name(), dt_metadata_get_name(), dt_metadata_get_name_by_display_order(), dt_metadata_get_nb_user_metadata(), dt_metadata_get_subkey(), dt_metadata_get_type(), and dt_metadata_get_type_by_display_order().

◆ key

char* key

Definition at line 62 of file metadata/metadata.c.

Referenced by _a_user_binding_wins_over_the_default(), _accels_recent_get(), _accels_recent_set(), _add_device_section(), _add_mem_section(), _alert_show(), _append_kv(), _area_key_press_callback(), _area_key_press_callback(), _attached_key_pressed(), _cache_get_newest(), _cache_get_oldest(), _cache_sum_evictable(), _callback_bool(), _color_history_key(), _color_history_valid_key(), _completion_match_func(), _completion_match_func(), _conf_add(), _conf_get_guide(), _conf_save(), _connect_accel(), _darkroom_compose_fallback(), _darkroom_compose_key(), _darkroom_compose_locked(), _darkroom_composed_already(), _datetime_key_pressed(), _dictionary_key_pressed(), _draw_boxes(), _dt_digraph_nodes_hashtable_free_full(), _dt_opencl_get_conf_int(), _edit_key_press(), _enter_key_pressed(), _entry_get_locked(), _exif_decode_iptc_data(), _find_path_for_keys(), _folded_key(), _folder_holds(), _folder_survey_save_locked(), _for_each_accel(), _for_each_accel_create_treeview_row(), _for_each_non_virtual_accel(), _for_each_path_create_treeview_row(), _for_each_remove(), _for_each_remove_old(), _gpu_runtime_crash_streak(), _gpu_runtime_set_crash_streak(), _gradient_slider_key_press_event(), _grid_handle_key(), _grid_horizontal_changed(), _grid_subdiv_changed(), _grid_vertical_changed(), _group_events_key_pressed(), _gtk_log_writer_filter(), _guides_add_guide(), _guides_gui_grid(), _hash_raster_masks(), _hm_collect_labels_from_history_map(), _hm_topo_resolve_incompatible_constraints(), _is_scroll_captured_by_widget(), _key_press_on_list(), _key_pressed(), _layer_cache_matches(), _lib_navigation_compose(), _lib_navigation_draw_callback(), _lib_navigation_picture_key(), _lib_tagging_tag_key_press(), _ls_find_camera(), _ls_find_lens(), _match_last_hierarchical_token(), _mem_list(), _metadata_view_update_values(), _mipmap_subcache_collect(), _non_threadsafe_cache_get_entry(), _non_threadsafe_stats_append(), _on_mem_section_expanded(), _panel_handle_resize(), _panel_is_visible(), _polygon_events_key_pressed(), _pressure_alert_expired(), _print_cache_lines(), _print_size_changed(), _raster_combo_populate(), _read_float(), _read_usercrop_candidate(), _refresh(), _register_and_read(), _remove_one_size(), _remove_xmp_keys(), _rename_module_key_press(), _search_entry_key_pressed(), _search_func(), _settings_flip_changed(), _settings_flip_update(), _settings_guides_changed(), _shortcut_edited(), _shortcut_search_recent_completion_match(), _skip_key_value_pair(), _solid_key(), _static_layer_ensure(), _store_color_history(), _timezone_key_pressed(), _ui_init_panel_size(), _update_shortcut_state(), _widget_key_press(), _widget_store_bool(), _widget_store_int(), _widget_stored_bool(), _widget_stored_int(), _xmp_append_history(), _xmp_append_mask(), add_non_clone_mask_entries_to_db(), add_patches_to_array(), alloc_dummy(), append_views(), PermutohedralLattice< D, VD >::blur(), collect_reference_patches_foreach(), collect_source_patches_foreach(), draw_color_boxes_inside(), dt_accels_new_widget_shortcut(), dt_bauhaus_popup_key_press(), dt_cache_contains(), dt_cache_for_all(), dt_cache_get_with_caller(), dt_cache_remove(), dt_cache_seed(), dt_cache_testget(), dt_collection_query_get_makermodels(), dt_conf_init(), dt_conf_key_exists(), dt_dev_modules_update_multishow(), dt_dev_pixelpipe_cache_flush_clmem(), dt_dev_pixelpipe_cache_get_entry_by_data(), dt_drawlayer_conf_load_color_history(), dt_drawlayer_conf_mapping_profile(), dt_drawlayer_current_work_profile_key(), dt_exif_decode_xmp_data(), dt_exif_read_exif_tag(), dt_exif_read_iptc_tag(), dt_exif_read_xmp_tag(), dt_exif_write_blob(), dt_exif_xmp_attach_export(), dt_gui_preferences_bool(), dt_gui_preferences_bool_reset(), dt_gui_preferences_bool_update(), dt_gui_preferences_enum(), dt_gui_preferences_enum_reset(), dt_gui_preferences_enum_update(), dt_gui_preferences_int(), dt_gui_preferences_int_reset(), dt_gui_preferences_int_update(), dt_gui_preferences_string(), dt_gui_preferences_string_reset(), dt_gui_preferences_string_update(), dt_guides_button_toggled(), dt_guides_draw(), dt_guides_draw_grid(), dt_guides_update_button_state(), dt_guides_update_popover_values(), dt_handle_dialog_enter(), dt_image_cache_get_entries_stats(), dt_iop_autoset_get_conf_key(), dt_iop_autoset_module_is_enabled(), dt_iop_autoset_module_set_enabled(), dt_iop_basecurve_key_press(), dt_iop_colorcorrection_key_press(), dt_iop_is_raster_mask_used(), dt_iop_set_mask_mode(), dt_iop_tonecurve_key_press(), dt_iop_update_multi_priority(), dt_lib_is_visible(), dt_lib_set_visible(), dt_masks_events_key_pressed(), dt_metadata_get(), dt_metadata_get_key_by_subkey(), dt_metadata_get_keyid(), dt_metadata_get_subkey(), dt_metadata_set(), dt_metadata_set(), dt_metadata_set_import(), dt_metadata_set_import(), dt_metadata_set_list(), dt_mipmap_cache_get_with_caller_and_shutdown(), dt_mipmap_cache_remove(), dt_mipmap_cache_remove_at_size(), dt_mipmap_cache_swap_at_size(), dt_opencl_detected_device_enabled(), dt_opencl_detected_device_headroom(), dt_opencl_detected_device_pinned_memory(), dt_opencl_set_detected_device_enabled(), dt_opencl_set_detected_device_headroom(), dt_opencl_set_detected_device_pinned_memory(), dt_pixel_cache_new_entry(), dt_remove_exif_key(), dt_remove_iptc_key(), dt_remove_known_keys(), dt_remove_xmp_key(), dt_supervisor_cache_wait(), dt_supervisor_form(), dt_supervisor_image(), dt_supervisor_mipmap(), dt_supervisor_thumbnail(), dt_thumbtable_key_pressed_grid(), dt_ui_panel_get_size(), dt_ui_panel_show(), dt_ui_restore_panels(), dt_ui_toggle_panels_visibility(), dt_widget_store_bool(), dt_widget_store_int(), dt_widget_stored_bool(), dt_widget_stored_int(), encrypt_tea(), exif_get_ascii_datafield(), export_raw(), find_patch(), flatten_nodes(), get_imgid(), get_size(), key_pressed(), key_pressed(), HashTablePermutohedral< D, VD >::lookupOffset(), on_match_func(), parse_cht(), parse_csv(), parse_it8(), PNGwriteRawProfile(), print_patches(), read_history_v2(), read_masks_v3(), PermutohedralLattice< D, VD >::splat(), topological_sort(), tree_key_press_presets(), update_entry(), and write_image().

◆ name

char* name

Definition at line 63 of file metadata/metadata.c.

◆ type

int type

Definition at line 64 of file metadata/metadata.c.