Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
tags.c File Reference
#include "common/tags.h"
#include "common/collection.h"
#include "common/darktable.h"
#include "common/debug.h"
#include "common/grouping.h"
#include "common/selection.h"
#include "common/undo.h"
#include "control/conf.h"
#include "control/control.h"
#include <glib.h>
+ Include dependency graph for common/tags.c:

Data Structures

struct  dt_undo_tags_t
 

Typedefs

typedef struct dt_undo_tags_t dt_undo_tags_t
 
typedef enum dt_tag_type_t dt_tag_type_t
 
typedef enum dt_tag_actions_t dt_tag_actions_t
 

Enumerations

enum  dt_tag_type_t {
  DT_TAG_TYPE_DT ,
  DT_TAG_TYPE_USER ,
  DT_TAG_TYPE_ALL
}
 
enum  dt_tag_actions_t {
  DT_TA_ATTACH = 0 ,
  DT_TA_DETACH ,
  DT_TA_SET ,
  DT_TA_SET_ALL
}
 

Functions

static gchar * _get_tb_removed_tag_string_values (GList *before, GList *after)
 
static gchar * _get_tb_added_tag_string_values (const int img, GList *before, GList *after)
 
static void _bulk_remove_tags (const int img, const gchar *tag_list)
 
static void _bulk_add_tags (const gchar *tag_list)
 
static void _pop_undo_execute (const int32_t imgid, GList *before, GList *after)
 
static void _pop_undo (gpointer user_data, dt_undo_type_t type, dt_undo_data_t data, dt_undo_action_t action, GList **imgs)
 
static void _undo_tags_free (gpointer data)
 
static void _tags_undo_data_free (gpointer data)
 
gboolean dt_tag_new (const char *name, guint *tagid)
 
gboolean dt_tag_new_from_gui (const char *name, guint *tagid)
 
guint dt_tag_remove (const guint tagid, gboolean final)
 
void dt_tag_delete_tag_batch (const char *flatlist)
 
guint dt_tag_remove_list (GList *tag_list)
 
gchar * dt_tag_get_name (const guint tagid)
 
void dt_tag_rename (const guint tagid, const gchar *new_tagname)
 
gboolean dt_tag_exists (const char *name, guint *tagid)
 
static gboolean _tag_add_tags_to_list (GList **list, const GList *tags)
 
static gboolean _tag_remove_tags_from_list (GList **list, const GList *tags)
 
static GList * _tag_get_tags (const int32_t imgid, const dt_tag_type_t type)
 
static gboolean _tag_execute (const GList *tags, const GList *imgs, GList **undo, const gboolean undo_on, const gint action)
 
gboolean dt_tag_attach_images (const guint tagid, const GList *img, const gboolean undo_on)
 
gboolean dt_tag_attach (const guint tagid, const int32_t imgid, const gboolean undo_on, const gboolean group_on)
 
gboolean dt_tag_set_tags (const GList *tags, const GList *img, const gboolean ignore_dt_tags, const gboolean clear_on, const gboolean undo_on)
 
gboolean dt_tag_attach_string_list (const gchar *tags, const GList *img, const gboolean undo_on)
 
gboolean dt_tag_detach_images (const guint tagid, const GList *img, const gboolean undo_on)
 
gboolean dt_tag_detach (const guint tagid, const int32_t imgid, const gboolean undo_on, const gboolean group_on)
 
gboolean dt_tag_detach_by_string (const char *name, const int32_t imgid, const gboolean undo_on, const gboolean group_on)
 
void dt_set_darktable_tags ()
 
uint32_t dt_tag_get_attached (const int32_t imgid, GList **result, const gboolean ignore_dt_tags)
 
static uint32_t _tag_get_attached_export (const int32_t imgid, GList **result)
 
static gint sort_tag_by_path (gconstpointer a, gconstpointer b)
 
static gint sort_tag_by_leave (gconstpointer a, gconstpointer b)
 
static gint sort_tag_by_count (gconstpointer a, gconstpointer b)
 
GList * dt_sort_tag (GList *tags, gint sort_type)
 
GList * dt_tag_get_list (int32_t imgid)
 
GList * dt_tag_get_hierarchical (int32_t imgid)
 
GList * dt_tag_get_tags (const int32_t imgid, const gboolean ignore_dt_tags)
 
static gint _is_not_exportable_tag (gconstpointer a, gconstpointer b)
 
GList * dt_tag_get_list_export (int32_t imgid, int32_t flags)
 
GList * dt_tag_get_hierarchical_export (int32_t imgid, int32_t flags)
 
gboolean dt_is_tag_attached (const guint tagid, const int32_t imgid)
 
GList * dt_tag_get_images (const gint tagid)
 
GList * dt_tag_get_images_from_list (const GList *img, const gint tagid)
 
uint32_t dt_tag_get_suggestions (GList **result)
 
void dt_tag_count_tags_images (const gchar *keyword, int *tag_count, int *img_count)
 
void dt_tag_get_tags_images (const gchar *keyword, GList **tag_list, GList **img_list)
 
uint32_t dt_tag_images_count (gint tagid)
 
uint32_t dt_tag_get_with_usage (GList **result)
 
static gchar * dt_cleanup_synonyms (gchar *synonyms_entry)
 
gchar * dt_tag_get_synonyms (gint tagid)
 
void dt_tag_set_synonyms (gint tagid, gchar *synonyms_entry)
 
gint dt_tag_get_flags (gint tagid)
 
void dt_tag_set_flags (gint tagid, gint flags)
 
void dt_tag_add_synonym (gint tagid, gchar *synonym)
 
static void _free_result_item (gpointer data)
 
void dt_tag_free_result (GList **result)
 
uint32_t dt_tag_get_recent_used (GList **result)
 
ssize_t dt_tag_import (const char *filename)
 
ssize_t dt_tag_export (const char *filename)
 
char * dt_tag_get_subtags (const int32_t imgid, const char *category, const int level)
 
gboolean dt_tag_get_tag_order_by_id (const uint32_t tagid, uint32_t *sort, gboolean *descending)
 
uint32_t dt_tag_get_tag_id_by_name (const char *const name)
 
void dt_tag_set_tag_order_by_id (const uint32_t tagid, const uint32_t sort, const gboolean descending)
 

Typedef Documentation

◆ dt_tag_actions_t

◆ dt_tag_type_t

◆ dt_undo_tags_t

Enumeration Type Documentation

◆ dt_tag_actions_t

Enumerator
DT_TA_ATTACH 
DT_TA_DETACH 
DT_TA_SET 
DT_TA_SET_ALL 

◆ dt_tag_type_t

Enumerator
DT_TAG_TYPE_DT 
DT_TAG_TYPE_USER 
DT_TAG_TYPE_ALL 

Function Documentation

◆ _bulk_add_tags()

static void _bulk_add_tags ( const gchar *  tag_list)
static

◆ _bulk_remove_tags()

static void _bulk_remove_tags ( const int  img,
const gchar *  tag_list 
)
static

◆ _free_result_item()

static void _free_result_item ( gpointer  data)
static

References dt_tag_t::synonym, and dt_tag_t::tag.

Referenced by dt_tag_free_result().

◆ _get_tb_added_tag_string_values()

static gchar * _get_tb_added_tag_string_values ( const int  img,
GList *  before,
GList *  after 
)
static

References dt_util_dstrcat().

Referenced by _pop_undo_execute().

◆ _get_tb_removed_tag_string_values()

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

References dt_util_dstrcat().

Referenced by _pop_undo_execute().

◆ _is_not_exportable_tag()

static gint _is_not_exportable_tag ( gconstpointer  a,
gconstpointer  b 
)
static

◆ _pop_undo()

◆ _pop_undo_execute()

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

◆ _tag_add_tags_to_list()

static gboolean _tag_add_tags_to_list ( GList **  list,
const GList *  tags 
)
static

References FALSE, and TRUE.

Referenced by _tag_execute().

◆ _tag_execute()

◆ _tag_get_attached_export()

static uint32_t _tag_get_attached_export ( const int32_t  imgid,
GList **  result 
)
static

◆ _tag_get_tags()

static GList * _tag_get_tags ( const int32_t  imgid,
const dt_tag_type_t  type 
)
static

◆ _tag_remove_tags_from_list()

static gboolean _tag_remove_tags_from_list ( GList **  list,
const GList *  tags 
)
static

Referenced by _tag_execute().

◆ _tags_undo_data_free()

static void _tags_undo_data_free ( gpointer  data)
static

◆ _undo_tags_free()

static void _undo_tags_free ( gpointer  data)
static

◆ dt_cleanup_synonyms()

static gchar * dt_cleanup_synonyms ( gchar *  synonyms_entry)
static

References dt_util_dstrcat().

Referenced by dt_tag_set_synonyms().

◆ dt_is_tag_attached()

gboolean dt_is_tag_attached ( const guint  tagid,
const int32_t  imgid 
)

check if a tag is attached to the given image

References darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_BIND_INT, and DT_DEBUG_SQLITE3_PREPARE_V2.

Referenced by dt_tag_attach().

◆ dt_set_darktable_tags()

void dt_set_darktable_tags ( )

◆ dt_sort_tag()

GList * dt_sort_tag ( GList *  tags,
gint  sort_type 
)

◆ dt_tag_add_synonym()

◆ dt_tag_attach()

gboolean dt_tag_attach ( const guint  tagid,
const int32_t  imgid,
const gboolean  undo_on,
const gboolean  group_on 
)

◆ dt_tag_attach_images()

gboolean dt_tag_attach_images ( const guint  tagid,
const GList *  img,
const gboolean  undo_on 
)

attach a tag on images list. tagid id of tag to attach. img the list of image id to attach tag to

References _pop_undo(), _tag_execute(), _tags_undo_data_free(), darktable, DT_TA_ATTACH, dt_undo_end_group(), dt_undo_record(), dt_undo_start_group(), DT_UNDO_TAGS, FALSE, and darktable_t::undo.

Referenced by _event_dnd_received(), and dt_tag_attach().

◆ dt_tag_attach_string_list()

gboolean dt_tag_attach_string_list ( const gchar *  tags,
const GList *  img,
const gboolean  undo_on 
)

attach a list of tags on list of images.

Parameters
[in]tagsa comma separated string of tags.
[in]imgthe list of images to attach tag to.
Note
If tag does not exist, it's created.

References _pop_undo(), _tag_execute(), _tags_undo_data_free(), darktable, DT_TA_ATTACH, dt_tag_new(), dt_undo_end_group(), dt_undo_record(), dt_undo_start_group(), DT_UNDO_TAGS, FALSE, and darktable_t::undo.

Referenced by _new_button_clicked().

◆ dt_tag_count_tags_images()

void dt_tag_count_tags_images ( const gchar *  keyword,
int *  tag_count,
int *  img_count 
)

retrieves count of tagged images.

Parameters
[in]keywordthe keyword to search
Returns
the count
Note
the limit of result is decided by conf value "xxx"

References darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_EXEC, and DT_DEBUG_SQLITE3_PREPARE_V2.

Referenced by _pop_menu_dictionary_change_path(), _pop_menu_dictionary_delete_node(), and _pop_menu_dictionary_edit_tag().

◆ dt_tag_delete_tag_batch()

void dt_tag_delete_tag_batch ( const char *  flatlist)

◆ dt_tag_detach()

gboolean dt_tag_detach ( const guint  tagid,
const int32_t  imgid,
const gboolean  undo_on,
const gboolean  group_on 
)

detach tag from images.

Parameters
[in]tagidof tag to detach.
[in]imgidthe image id to detach tag from, if < 0 images to act on are used.

References dt_act_on_get_images(), dt_grouping_add_grouped_images(), dt_tag_detach_images(), and UNKNOWN_IMAGE.

Referenced by dt_control_export_job_run(), dt_control_local_copy_images_job_run(), dt_lua_tag_detach(), dt_map_location_update_images(), dt_map_location_update_locations(), and dt_tag_detach_by_string().

◆ dt_tag_detach_by_string()

gboolean dt_tag_detach_by_string ( const char *  name,
const int32_t  imgid,
const gboolean  undo_on,
const gboolean  group_on 
)

detach tags from images that matches name, it is valid to use % to match tag

References dt_tag_detach(), dt_tag_exists(), FALSE, and name.

Referenced by _image_duplicate_with_version(), dt_history_delete_on_image_ext(), and dt_imageio_update_monochrome_workflow_tag().

◆ dt_tag_detach_images()

gboolean dt_tag_detach_images ( const guint  tagid,
const GList *  img,
const gboolean  undo_on 
)

detach tag from images.

Parameters
[in]tagidof tag to detach.
[in]imgthe list of image id to detach tag from

References _pop_undo(), _tag_execute(), _tags_undo_data_free(), darktable, DT_TA_DETACH, dt_undo_end_group(), dt_undo_record(), dt_undo_start_group(), DT_UNDO_TAGS, FALSE, and darktable_t::undo.

Referenced by _detach_selected_tag(), and dt_tag_detach().

◆ dt_tag_exists()

gboolean dt_tag_exists ( const char *  name,
guint *  tagid 
)

◆ dt_tag_export()

ssize_t dt_tag_export ( const char *  filename)

◆ dt_tag_free_result()

◆ dt_tag_get_attached()

◆ dt_tag_get_flags()

gint dt_tag_get_flags ( gint  tagid)

◆ dt_tag_get_hierarchical()

GList * dt_tag_get_hierarchical ( int32_t  imgid)

get a flat list of only hierarchical tags, the difference to dt_tag_get_attached() is that this one filters out the "darktable|" tags.

References dt_tag_free_result(), dt_tag_get_attached(), dt_tag_t::tag, and TRUE.

Referenced by _exif_xmp_read_data().

◆ dt_tag_get_hierarchical_export()

GList * dt_tag_get_hierarchical_export ( int32_t  imgid,
int32_t  flags 
)

get a flat list of only hierarchical tags, the difference to dt_tag_get_hierarchical() is that this one checks option for exportation

References DT_META_PRIVATE_TAG, dt_tag_free_result(), dt_tag_get_attached(), DT_TF_PRIVATE, flags, dt_tag_t::flags, dt_tag_t::tag, and TRUE.

Referenced by _exif_xmp_read_data_export().

◆ dt_tag_get_images()

GList * dt_tag_get_images ( const gint  tagid)

get the subset of images that have a given tag attached

References darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_BIND_INT, and DT_DEBUG_SQLITE3_PREPARE_V2.

Referenced by dt_map_location_update_images().

◆ dt_tag_get_images_from_list()

GList * dt_tag_get_images_from_list ( const GList *  img,
const gint  tagid 
)

get the subset of images from the given list that have a given tag attached

References darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_PREPARE_V2, and dt_util_dstrcat().

Referenced by _detach_selected_tag().

◆ dt_tag_get_list()

GList * dt_tag_get_list ( int32_t  imgid)

get a list of tags, the difference to dt_tag_get_attached() is that this one splits at '|' and filters out the "darktable|" tags.

References dt_conf_get_bool(), dt_tag_free_result(), dt_tag_get_attached(), dt_util_glist_uniq(), dt_tag_t::tag, and TRUE.

Referenced by _exif_xmp_read_data().

◆ dt_tag_get_list_export()

GList * dt_tag_get_list_export ( int32_t  imgid,
int32_t  flags 
)

◆ dt_tag_get_name()

◆ dt_tag_get_recent_used()

uint32_t dt_tag_get_recent_used ( GList **  result)

retrieves a list of recent tags used.

Parameters
[out]resulta pointer to list populated with result.
Returns
the count
Note
the limit of result is decided by conf value "xxx"

◆ dt_tag_get_subtags()

char * dt_tag_get_subtags ( const int32_t  imgid,
const char *  category,
const int  level 
)

◆ dt_tag_get_suggestions()

uint32_t dt_tag_get_suggestions ( GList **  result)

retrieves a list of suggested tags matching keyword.

Parameters
[in]keywordthe keyword to search
[out]resulta pointer to list populated with result.
Returns
the count
Note
the limit of result is decided by conf value "xxx"

References dt_tag_t::count, darktable, darktable_t::db, dt_conf_get_int(), dt_conf_get_string_const(), dt_database_get(), DT_DEBUG_SQLITE3_EXEC, DT_DEBUG_SQLITE3_PREPARE_V2, dt_selection_get_length(), DT_TS_ALL_IMAGES, DT_TS_NO_IMAGE, DT_TS_SOME_IMAGES, dt_tag_t::flags, dt_tag_t::id, dt_tag_t::leave, dt_tag_t::select, darktable_t::selection, dt_tag_t::synonym, and dt_tag_t::tag.

Referenced by _init_treeview().

◆ dt_tag_get_synonyms()

gchar * dt_tag_get_synonyms ( gint  tagid)

◆ dt_tag_get_tag_id_by_name()

uint32_t dt_tag_get_tag_id_by_name ( const char *const  name)

return the tagid of that tag - follow tag sensitivity - return 0 if not found

References darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, and name.

Referenced by row_activated_with_event().

◆ dt_tag_get_tag_order_by_id()

gboolean dt_tag_get_tag_order_by_id ( const uint32_t  tagid,
uint32_t *  sort,
gboolean *  descending 
)

◆ dt_tag_get_tags()

GList * dt_tag_get_tags ( const int32_t  imgid,
const gboolean  ignore_dt_tags 
)

get a flat list of tags id attached to image id

References _tag_get_tags(), DT_TAG_TYPE_ALL, and DT_TAG_TYPE_USER.

◆ dt_tag_get_tags_images()

void dt_tag_get_tags_images ( const gchar *  keyword,
GList **  tag_list,
GList **  img_list 
)

retrieves list of tags and tagged images.

Parameters
[in]keywordthe keyword to search.
[out]resultpointers to list populated with result.
Note
the limit of result is decided by conf value "xxx"

References darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_EXEC, DT_DEBUG_SQLITE3_PREPARE_V2, dt_tag_t::id, and dt_tag_t::tag.

Referenced by _apply_rename_path(), _pop_menu_dictionary_delete_node(), and _pop_menu_dictionary_edit_tag().

◆ dt_tag_get_with_usage()

uint32_t dt_tag_get_with_usage ( GList **  result)

retrieves the list of tags matching keyword.

Parameters
[in]keywordthe keyword to search
[out]resulta pointer to list populated with result.
Returns
the count
Note
the limit of result is decided by conf value "xxx"

References dt_tag_t::count, darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_EXEC, DT_DEBUG_SQLITE3_PREPARE_V2, dt_selection_get_length(), DT_TS_ALL_IMAGES, DT_TS_NO_IMAGE, DT_TS_SOME_IMAGES, dt_tag_t::flags, dt_tag_t::id, dt_tag_t::leave, dt_tag_t::select, darktable_t::selection, dt_tag_t::synonym, and dt_tag_t::tag.

Referenced by _init_treeview(), and dt_tag_export().

◆ dt_tag_images_count()

uint32_t dt_tag_images_count ( gint  tagid)

◆ dt_tag_import()

◆ dt_tag_new()

gboolean dt_tag_new ( const char *  name,
guint *  tagid 
)

◆ dt_tag_new_from_gui()

gboolean dt_tag_new_from_gui ( const char *  name,
guint *  tagid 
)

creates a new tag, returns tagid

Parameters
[in]namethe tag name.
[in]tagida pointer to tagid of new tag, this can be NULL
Returns
false if failed to create a tag and indicates that tagid is invalid to use.
Note
If tag already exists the existing tag id is returned. This function will also raise a DT_SIGNAL_TAG_CHANGED signal if necessary, so keywords GUI can refresh.

References darktable, DT_DEBUG_CONTROL_SIGNAL_RAISE, DT_SIGNAL_TAG_CHANGED, dt_tag_new(), name, and darktable_t::signals.

Referenced by tag_lib_create().

◆ dt_tag_remove()

guint dt_tag_remove ( const guint  tagid,
gboolean  final 
)

removes a tag from db and from assigned images.

Parameters
finalTRUE actually performs the remove
Returns
the amount of images affected.

References darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and TRUE.

Referenced by _pop_menu_dictionary_delete_tag(), dt_map_location_delete(), and tag_delete().

◆ dt_tag_remove_list()

guint dt_tag_remove_list ( GList *  tag_list)

removes a list of tags from db and from assigned images.

Returns
the number of tags deleted

References dt_tag_delete_tag_batch(), and dt_util_dstrcat().

Referenced by _pop_menu_dictionary_delete_node().

◆ dt_tag_rename()

void dt_tag_rename ( const guint  tagid,
const gchar *  new_tagname 
)

◆ dt_tag_set_flags()

void dt_tag_set_flags ( gint  tagid,
gint  flags 
)

◆ dt_tag_set_synonyms()

◆ dt_tag_set_tag_order_by_id()

void dt_tag_set_tag_order_by_id ( const uint32_t  tagid,
const uint32_t  sort,
const gboolean  descending 
)

◆ dt_tag_set_tags()

gboolean dt_tag_set_tags ( const GList *  tags,
const GList *  img,
const gboolean  ignore_dt_tags,
const gboolean  clear_on,
const gboolean  undo_on 
)

attach a list of tags on selected images.

Parameters
[in]tagsa list of ids of tags.
[in]imgidthe image id to attach tag to, if < 0 selected images are used.
Note
If tag not exists it's created if clear_on TRUE the image tags are cleared before attaching the new ones

References _pop_undo(), _tag_execute(), _tags_undo_data_free(), darktable, DT_TA_ATTACH, DT_TA_SET, DT_TA_SET_ALL, dt_undo_end_group(), dt_undo_record(), dt_undo_start_group(), DT_UNDO_TAGS, FALSE, and darktable_t::undo.

Referenced by _exif_decode_xmp_data(), and set_params().

◆ sort_tag_by_count()

static gint sort_tag_by_count ( gconstpointer  a,
gconstpointer  b 
)
static

References dt_tag_t::count.

Referenced by dt_sort_tag().

◆ sort_tag_by_leave()

static gint sort_tag_by_leave ( gconstpointer  a,
gconstpointer  b 
)
static

References dt_tag_t::leave.

Referenced by dt_sort_tag().

◆ sort_tag_by_path()

static gint sort_tag_by_path ( gconstpointer  a,
gconstpointer  b 
)
static

References dt_tag_t::tag.

Referenced by dt_sort_tag().