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

struct  dt_undo_metadata_t
 

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)
 
GListdt_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)
 
GListdt_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

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()

static 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()

static 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, L, v, and value.

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

◆ _get_tb_added_metadata_rows()

static 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, dt_metadata_row_t::imgid, L, row, and value.

Referenced by _pop_undo_execute().

◆ _get_tb_removed_metadata_string_values()

static 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, L, and value.

Referenced by _pop_undo_execute().

◆ _list_find_custom()

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

◆ _metadata_add_metadata_to_list()

static 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, L, and m.

Referenced by _metadata_execute().

◆ _metadata_execute()

◆ _metadata_remove_metadata_from_list()

static 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, L, and m.

Referenced by _metadata_execute().

◆ _metadata_undo_data_free()

static void _metadata_undo_data_free ( gpointer  data)
static

◆ _pop_undo()

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 
)
static

◆ _pop_undo_execute()

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

◆ _undo_metadata_free()

static 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, L, 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, key, and L.

Referenced by _get_base_value(), _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, DT_METADATA_NUMBER, and L.

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, L, 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, key, and L.

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, L, 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, i, and L.

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, L, 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, L, 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()

◆ 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, L, 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(), dt_undo_start_group(), and L.

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 _accels_recent_get(), _accels_recent_set(), _append_kv(), _area_key_press_callback(), _area_key_press_callback(), _attached_key_pressed(), _callback_bool(), _color_history_key(), _color_history_valid_key(), _completion_match_func(), _completion_match_func(), _conf_add(), _conf_get_guide(), _conf_mapping_profile(), _connect_accel(), _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(), _folder_survey_save_locked(), _for_each_accel(), _for_each_accel_create_treeview_row(), _for_each_non_virtual_accel(), _for_each_path_create_treeview_row(), _get_current_work_profile_key(), _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(), _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_tagging_tag_key_press(), _load_color_history(), _metadata_view_update_values(), _mipmap_subcache_collect(), _non_threadsafe_cache_get_entry(), _panel_handle_resize(), _panel_is_visible(), _piwigo_load_account(), _polygon_events_key_pressed(), _raster_combo_populate(), _read_float(), _read_usercrop_candidate(), _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(), _store_color_history(), _timezone_key_pressed(), _ui_init_panel_size(), _update(), _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_patches_to_array(), alloc_dummy(), append_pair_to_json(), append_views(), PermutohedralLattice< D, VD >::blur(), 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_conf_print(), dt_conf_save(), dt_dev_modules_update_multishow(), dt_dev_pixelpipe_cache_flush_clmem(), dt_dev_pixelpipe_cache_get_entries_stats(), dt_dev_pixelpipe_cache_get_entry_by_data(), 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_import(), dt_metadata_set_list(), dt_mipmap_cache_get_with_caller_and_shutdown(), 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_pwstorage_kwallet_get(), dt_pwstorage_kwallet_set(), 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< KD, VD >::lookupOffset(), parse_cht(), parse_csv(), parse_it8(), PNGwriteRawProfile(), print_patches(), read_history_v2(), read_masks_v3(), secret_to_attributes(), PermutohedralLattice< D, VD >::splat(), topological_sort(), tree_key_press_presets(), and write_image().

◆ name

◆ type

int type