Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
tag_repository.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 darktable is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 darktable is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with darktable. If not, see <http://www.gnu.org/licenses/>.
17*/
18
34#ifndef DT_DATABASE_TAG_REPOSITORY_H
35#define DT_DATABASE_TAG_REPOSITORY_H
36
37#include "metadata/tags.h"
38
39#include <glib.h>
40#include <stdint.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
47
58
59/* ---------------------------------------------------------------------------------------
60 * Identity and lifecycle -- `data.tags`
61 * ------------------------------------------------------------------------------------- */
62
64guint dt_tag_repository_find_by_name(const char *name);
65
68
70guint dt_tag_repository_insert(const char *name);
71
73gchar *dt_tag_repository_get_name(const guint tagid);
74
76void dt_tag_repository_rename(const guint tagid, const char *new_name);
77
80int dt_tag_repository_count_attachments(const guint tagid);
81
83void dt_tag_repository_delete(const guint tagid);
84
88
89/* ---------------------------------------------------------------------------------------
90 * `memory.darktable_tags` -- the cache of which tags are internal
91 * ------------------------------------------------------------------------------------- */
92
94void dt_tag_repository_mark_internal(const guint tagid);
95
98
99/* ---------------------------------------------------------------------------------------
100 * Flags and synonyms
101 * ------------------------------------------------------------------------------------- */
102
104gint dt_tag_repository_get_flags(const guint tagid);
105
107void dt_tag_repository_set_flags(const guint tagid, const gint flags);
108
111void dt_tag_repository_update_flags(const guint tagid, const gint set, const gint keep_mask);
112
114gchar *dt_tag_repository_get_synonyms(const guint tagid);
115
117void dt_tag_repository_set_synonyms(const guint tagid, const char *synonyms);
118
119/* ---------------------------------------------------------------------------------------
120 * Attachments -- `main.tagged_images`
121 * ------------------------------------------------------------------------------------- */
122
124gboolean dt_tag_repository_attach(const guint tagid, const int32_t imgid);
125
127gboolean dt_tag_repository_is_attached(const guint tagid, const int32_t imgid);
128
130GList *dt_tag_repository_get_images(const guint tagid);
131
134GList *dt_tag_repository_get_images_in_list(const guint tagid, const char *imgid_list);
135
144uint32_t dt_tag_repository_count_distinct_images(const guint tagid);
145
148void dt_tag_repository_detach_batch(const int32_t imgid, const char *tagid_list);
149
152void dt_tag_repository_attach_batch(const char *values);
153
154/* ---------------------------------------------------------------------------------------
155 * Attached-tag listings
156 *
157 * These return `dt_tag_t` with `id`, `tag`, `flags`, `synonym` and `count` filled.
158 * `leave` (the last path component) and `select` (how much of the selection carries the
159 * tag) are left to the caller: the first is string handling and the second needs the
160 * selection size, which is `common/selection.c`'s to know, not the database's.
161 * ------------------------------------------------------------------------------------- */
162
172GList *dt_tag_repository_get_attached(const int32_t imgid, const gboolean ignore_internal);
173
182
192
203
219
225
231GList *dt_tag_repository_get_names_under(const int32_t imgid, const char *category);
232
233/* ---------------------------------------------------------------------------------------
234 * Keyword search -- a tag and everything under it
235 *
236 * Both of these first fill `memory.similar_tags` with the tag whose name equals the
237 * keyword plus every tag whose name starts with `keyword|`, then read from that. The
238 * scratch table is emptied on the way out, as it always was.
239 * ------------------------------------------------------------------------------------- */
240
242void dt_tag_repository_count_similar(const char *keyword, int *tag_count, int *img_count);
243
250void dt_tag_repository_get_similar(const char *keyword, GList **tags, GList **imgids);
251
269 const char *recent_tags, const int nb_recent);
270
283void dt_tag_repository_get_agreement(GList *imgids, gboolean *same_tags,
284 gboolean *same_categories);
285
289
291typedef struct dt_tag_count_t
292{
293 guint id;
294 gchar *name;
295 guint count;
297
299void dt_tag_count_free(gpointer data);
300
309GList *dt_tag_repository_get_by_path_with_counts(const char *path, const char *path_prefix);
310
311
313
314
315#ifdef __cplusplus
316}
317#endif
318
319#endif // DT_DATABASE_TAG_REPOSITORY_H
320
321// clang-format off
322// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
323// vim: shiftwidth=2 expandtab tabstop=2 cindent
324// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
325// clang-format on
static const dt_adaptation_t kind
dt_mipmap_buffer_dsc_flags flags
Definition mipmap_cache.c:4
const char * name
Definition pdf.h:90
gboolean dt_tag_repository_attach(const guint tagid, const int32_t imgid)
Attach tagid to imgid, at the end of the tag order.
void dt_tag_repository_delete_batch(const char *id_list)
Delete every tag in id_list and its attachments.
void dt_tag_repository_rename(const guint tagid, const char *new_name)
Rename tagid. The caller checks first that the new name is free.
GList * dt_tag_repository_get_with_usage(const uint32_t nb_selected)
Every user tag with how often it is used and how much of the selection carries it.
GList * dt_tag_repository_get_collection_tags(void)
User tags attached to at least one image of the current collection, by name.
void dt_tag_repository_get_agreement(GList *imgids, gboolean *same_tags, gboolean *same_categories)
Do all of imgids carry exactly the same tags? The same categories?
gchar * dt_tag_repository_get_name(const guint tagid)
The name of tagid, newly allocated, or NULL.
int dt_tag_repository_count_attachments(const guint tagid)
How many attachment ROWS tagid has, or -1 if the count could not be read. See dt_tag_repository_count...
GList * dt_tag_repository_get_images(const guint tagid)
Images carrying tagid, GINT_TO_POINTER. Free with g_list_free().
dt_tag_kind_t
@ DT_TAG_KIND_INTERNAL
@ DT_TAG_KIND_USER
@ DT_TAG_KIND_ANY
GList * dt_tag_repository_get_suggestions(const uint32_t nb_selected, const int confidence, const char *recent_tags, const int nb_recent)
Tags worth suggesting for the current selection.
GList * dt_tag_repository_get_by_path_with_counts(const char *path, const char *path_prefix)
Tags at path or below it, each with the number of distinct images carrying it.
GList * dt_tag_repository_get_ids_for_images(const char *imgid_list, const dt_tag_kind_t kind)
Ids of the tags on a set of images, optionally restricted by kind.
void dt_tag_repository_mark_internal(const guint tagid)
Record tagid as an internal tag.
void dt_tag_repository_get_similar(const char *keyword, GList **tags, GList **imgids)
The tags matching keyword and the images carrying any of them.
guint dt_tag_repository_find_by_name(const char *name)
The id of the tag named name, or 0 when there is none.
GList * dt_tag_repository_get_attached_for_export(const int32_t imgid)
Tags attached to imgid for export, plus every ancestor on their paths.
GList * dt_tag_repository_get_names_under(const int32_t imgid, const char *category)
Names of the tags on imgid that start with category.
guint dt_tag_repository_find_by_name_nocase(const char *name)
The id of the tag whose name matches name case-INSENSITIVELY, or 0.
gint dt_tag_repository_get_flags(const guint tagid)
The flags word of tagid, or 0.
void dt_tag_repository_update_flags(const guint tagid, const gint set, const gint keep_mask)
Set the bits in set and clear those absent from keep_mask: flags = (IFNULL(flags,0) & keep_mask) | se...
G_BEGIN_DECLS GList * dt_tag_repository_get_attached_names(const int32_t imgid)
Names of the tags attached to an image.
void dt_tag_repository_count_similar(const char *keyword, int *tag_count, int *img_count)
How many tags match keyword, and how many images carry any of them.
GList * dt_tag_repository_get_images_in_list(const guint tagid, const char *imgid_list)
Images carrying tagid, restricted to imgid_list – a comma-separated list of decimal image ids compose...
void dt_tag_repository_delete(const guint tagid)
Delete tagid, its attachments, and its memory.darktable_tags entry.
void dt_tag_repository_cleanup(void)
Finalise whatever this repository still caches – today, nothing. See dt_colorlabel_repository_cleanup...
void dt_tag_repository_attach_batch(const char *values)
Attach rows given as the VALUES clause of the insert – "(imgid,tagid,pos),…". The position expression...
gchar * dt_tag_repository_get_synonyms(const guint tagid)
The synonyms of tagid, newly allocated, or NULL.
void dt_tag_repository_set_synonyms(const guint tagid, const char *synonyms)
Replace the synonyms of tagid.
void dt_tag_repository_rebuild_internal(void)
Rebuild the whole internal-tag cache from data.tags.
uint32_t dt_tag_repository_count_distinct_images(const guint tagid)
Distinct images carrying tagid.
void dt_tag_repository_set_flags(const guint tagid, const gint flags)
Replace the flags word of tagid.
void dt_tag_count_free(gpointer data)
Release one dt_tag_count_t, name included. Suits g_list_free_full().
gboolean dt_tag_repository_is_attached(const guint tagid, const int32_t imgid)
TRUE when tagid is attached to imgid.
void dt_tag_repository_detach_batch(const int32_t imgid, const char *tagid_list)
Detach every tag in tagid_list from imgid.
GList * dt_tag_repository_get_attached(const int32_t imgid, const gboolean ignore_internal)
Tags attached to one image or to the current selection, ordered by name.
guint dt_tag_repository_insert(const char *name)
Insert a tag named name and return its new id, or 0 on failure.