Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
collection.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010-2012 Henrik Andersson.
4 Copyright (C) 2010-2011, 2013 johannes hanika.
5 Copyright (C) 2012 José Carlos García Sogo.
6 Copyright (C) 2012, 2018, 2020 Pascal Obry.
7 Copyright (C) 2012 Richard Wonka.
8 Copyright (C) 2012 Simon Spannagel.
9 Copyright (C) 2013 Gaspard Jankowiak.
10 Copyright (C) 2013-2016, 2019 Tobias Ellinghaus.
11 Copyright (C) 2013 Ulrich Pegelow.
12 Copyright (C) 2014, 2016 Roman Lebedev.
13 Copyright (C) 2015-2016 Jérémy Rosen.
14 Copyright (C) 2015 Pedro Côrte-Real.
15 Copyright (C) 2016, 2020-2022 Aldric Renaudin.
16 Copyright (C) 2016 itinerarium.
17 Copyright (C) 2017 luzpaz.
18 Copyright (C) 2018 Mario Lueder.
19 Copyright (C) 2018 Rick Yorgason.
20 Copyright (C) 2018 Rikard Öxler.
21 Copyright (C) 2018 Sam Smith.
22 Copyright (C) 2018 Simon Legner.
23 Copyright (C) 2019 rrd1.
24 Copyright (C) 2020 Hanno Schwalm.
25 Copyright (C) 2020 JP Verrue.
26 Copyright (C) 2020-2021 Philippe Weyland.
27 Copyright (C) 2021 Arnaud TANGUY.
28 Copyright (C) 2021 Ralf Brown.
29 Copyright (C) 2022-2023, 2025 Aurélien PIERRE.
30 Copyright (C) 2022 Martin Bařinka.
31
32 darktable is free software: you can redistribute it and/or modify
33 it under the terms of the GNU General Public License as published by
34 the Free Software Foundation, either version 3 of the License, or
35 (at your option) any later version.
36
37 darktable is distributed in the hope that it will be useful,
38 but WITHOUT ANY WARRANTY; without even the implied warranty of
39 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 GNU General Public License for more details.
41
42 You should have received a copy of the GNU General Public License
43 along with darktable. If not, see <http://www.gnu.org/licenses/>.
44*/
45
46#ifndef DT_COMMON_COLLECTION_H
47#define DT_COMMON_COLLECTION_H
48
49#include <glib.h>
50#include <glib/gi18n.h>
51#include <inttypes.h>
52#include "metadata/metadata.h"
53
54#define NUM_LAST_COLLECTIONS 10
55
56/* Recording the N most recently used collections is a GUI feature: the list exists to fill a
57 * menu, and nothing in the collection backend reads it back. It lived here only because this
58 * is where a collection change is noticed.
59 *
60 * It must run BEFORE DT_SIGNAL_COLLECTION_CHANGED is raised -- some listeners read the recents
61 * list -- so it cannot simply become another listener. The backend therefore calls the handler
62 * at exactly the point the old code did. */
64
67
69{
70 COLLECTION_QUERY_SIMPLE = 0, // a query with only select and where statement
71 COLLECTION_QUERY_USE_SORT = 1 << 0, // if query should include order by statement
72 COLLECTION_QUERY_USE_LIMIT = 1 << 1, // if query should include "limit ?1,?2" part
73 COLLECTION_QUERY_USE_WHERE_EXT = 1 << 2, // if query should include extended where part
74 COLLECTION_QUERY_USE_ONLY_WHERE_EXT = 1 << 3 // if query should only use extended where part
76#define COLLECTION_QUERY_FULL (COLLECTION_QUERY_USE_SORT | COLLECTION_QUERY_USE_LIMIT)
77
98
115
116#define DT_COLLECTION_ORDER_FLAG 0x8000
117
118/* NOTE: any reordeing in this module require a legacy_preset entry in src/libs/collect.c */
158
160{
162 DT_COLLECTION_CHANGE_NEW_QUERY = 1, // a completly different query
163 DT_COLLECTION_CHANGE_FILTER = 2, // base query has been finetuned (filter, ...)
164 DT_COLLECTION_CHANGE_RELOAD = 3, // we have just reload the collection after images changes (query is identical)
165 // Something changed elsewhere (e.g. an import landing outside the browsed folder) that
166 // listeners with their own independent state may care about, but that is NOT a navigational
167 // event: nothing about what the user is currently looking at changed. Listeners driven by user
168 // navigation (scroll/focus/zoom resets) should treat this the same as NONE and do nothing;
169 // listeners that keep their own counts (e.g. the Collect module's tag/camera/lens lists) should
170 // still refresh. Deliberately its own value rather than reusing NONE: NONE already means "no
171 // value" in non-signal contexts (see gui/actions/file.c's one-time init call), and overloading
172 // it with this second, signal-specific meaning would make every future listener re-derive which
173 // sense of NONE it is looking at.
176
188
205
215
216/* returns the name for the given collection property */
218
220// Interim accessor (Strategy B, doc/globals-migration.md): implemented by the module itself; long-term the handle should be carried on the job/view context (Strategy C).
221// NULL in a GUI-less process (ansel-cli): the collection is lighttable query state, created by
222// dt_gui_gtk_init() through dt_collection_init_global(). Every public function here accepts a
223// NULL collection and degrades to a no-op / neutral result, so shared code paths need no guard.
229
232void dt_collection_free(const dt_collection_t *collection);
236void dt_collection_get_makermodels(const gchar *filter, GList **sanitized, GList **exif);
238gchar *dt_collection_get_makermodel(const char *exif_maker, const char *exif_model);
240int dt_collection_update(const dt_collection_t *collection);
242void dt_collection_reset(const dt_collection_t *collection);
246void dt_collection_set_rules(const dt_collection_t *collection, const dt_collection_rule_t *rules,
247 const int n_rules);
248
253
258
260char *dt_collection_get_text_filter(const dt_collection_t *collection);
262void dt_collection_set_text_filter(const dt_collection_t *collection, char *text_filter);
263
265void dt_collection_set_tag_id(dt_collection_t *collection, const uint32_t tagid);
266
279
294void dt_collection_load_filmroll(dt_collection_t *collection, const int32_t imgid,
295 dt_collection_import_view_t view_policy, gboolean set_mouse_over);
296
302gboolean dt_collection_get_browsed_folder(gchar *folder, size_t len, gboolean *recursive);
303
333void dt_collection_notify_imported(const int32_t imgid, const gchar *known_image_folder, gint64 *last_refresh_us);
334
336void dt_collection_set_sort(const dt_collection_t *collection, dt_collection_sort_t sort, gint reverse);
340gboolean dt_collection_get_sort_descending(const dt_collection_t *collection);
343
345uint32_t dt_collection_get_count(const dt_collection_t *collection);
347int dt_collection_get_nth(const dt_collection_t *collection, int nth);
350GList *dt_collection_get_all(const dt_collection_t *collection, int limit);
351
356GList *dt_collection_get_images_for_rule(const dt_collection_properties_t property, const char *text,
357 gboolean recursive);
358
361{
362 char *name; // raw/display value: folder path, tag name, formatted number/date, ...
363 int id; // film_roll id / tag id / running index, or 0
364 int count; // number of matching images
365 int status; // folder reachability (1 = reachable) for folders/film-rolls, else -1
367
372GList *dt_collection_get_property_values(const dt_collection_properties_t property, const int rule);
374
376void dt_collection_update_query(const dt_collection_t *collection, dt_collection_change_t query_change,
377 dt_collection_properties_t changed_property, GList *list);
378
380void dt_collection_hint_message(const dt_collection_t *collection);
381
382/* serialize and deserialize into a string. */
383void dt_collection_deserialize(const char *buf);
384int dt_collection_serialize(char *buf, int bufsize);
385
386/* splits an input string into a number part and an optional operator part */
387void dt_collection_split_operator_number(const gchar *input, char **number1, char **number2, char **op);
388void dt_collection_split_operator_datetime(const gchar *input, char **number1, char **number2, char **op);
389void dt_collection_split_operator_exposure(const gchar *input, char **number1, char **number2, char **op);
390
391/* initialize memory table */
393
398
399#endif // DT_COMMON_COLLECTION_H
400
401// clang-format off
402// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
403// vim: shiftwidth=2 expandtab tabstop=2 cindent
404// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
405// clang-format on
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
const char * dt_collection_name(dt_collection_properties_t prop)
Definition collection.c:390
void dt_collection_update_query(const dt_collection_t *collection, dt_collection_change_t query_change, dt_collection_properties_t changed_property, GList *list)
Definition collection.c:837
void dt_culling_mode_to_selection()
Definition collection.c:897
void dt_collection_reset(const dt_collection_t *collection)
Definition collection.c:275
void dt_collection_set_query_flags(const dt_collection_t *collection, dt_collection_query_flags_t flags)
Definition collection.c:330
void dt_collection_split_operator_exposure(const gchar *input, char **number1, char **number2, char **op)
Definition collection.c:584
void dt_collection_split_operator_datetime(const gchar *input, char **number1, char **number2, char **op)
Definition collection.c:523
void dt_collection_deserialize(const char *buf)
Definition collection.c:763
const dt_collection_params_t * dt_collection_params(const dt_collection_t *collection)
Definition collection.c:185
void dt_collection_set_text_filter(const dt_collection_t *collection, char *text_filter)
Definition collection.c:316
dt_collection_t * dt_collection_get_global(void)
Definition collection.c:138
char * dt_collection_get_text_filter(const dt_collection_t *collection)
Definition collection.c:310
gboolean dt_collection_get_sort_descending(const dt_collection_t *collection)
Definition collection.c:384
dt_collection_properties_t
Definition collection.h:120
@ DT_COLLECTION_PROP_EXPOSURE
Definition collection.h:128
@ DT_COLLECTION_PROP_MODULE
Definition collection.h:147
@ DT_COLLECTION_PROP_RATING
Definition collection.h:149
@ DT_COLLECTION_PROP_QUERY
Definition collection.h:151
@ DT_COLLECTION_PROP_TIME
Definition collection.h:133
@ DT_COLLECTION_PROP_METADATA
Definition collection.h:142
@ DT_COLLECTION_PROP_GROUPING
Definition collection.h:143
@ DT_COLLECTION_PROP_TAG
Definition collection.h:140
@ DT_COLLECTION_PROP_FILMROLL
Definition collection.h:121
@ DT_COLLECTION_PROP_LENS
Definition collection.h:126
@ DT_COLLECTION_PROP_SORT
Definition collection.h:156
@ DT_COLLECTION_PROP_CAMERA
Definition collection.h:125
@ DT_COLLECTION_PROP_LAST
Definition collection.h:153
@ DT_COLLECTION_PROP_LOCAL_COPY
Definition collection.h:144
@ DT_COLLECTION_PROP_GEOTAGGING
Definition collection.h:139
@ DT_COLLECTION_PROP_FILENAME
Definition collection.h:123
@ DT_COLLECTION_PROP_ISO
Definition collection.h:130
@ DT_COLLECTION_PROP_COLORLABEL
Definition collection.h:141
@ DT_COLLECTION_PROP_UNDEF
Definition collection.h:155
@ DT_COLLECTION_PROP_DAY
Definition collection.h:132
@ DT_COLLECTION_PROP_ORDER
Definition collection.h:148
@ DT_COLLECTION_PROP_FOLDERS
Definition collection.h:122
@ DT_COLLECTION_PROP_APERTURE
Definition collection.h:127
@ DT_COLLECTION_PROP_IMPORT_TIMESTAMP
Definition collection.h:134
@ DT_COLLECTION_PROP_FOCAL_LENGTH
Definition collection.h:129
@ DT_COLLECTION_PROP_EXPORT_TIMESTAMP
Definition collection.h:136
@ DT_COLLECTION_PROP_CHANGE_TIMESTAMP
Definition collection.h:135
@ DT_COLLECTION_PROP_HISTORY
Definition collection.h:146
@ DT_COLLECTION_PROP_PRINT_TIMESTAMP
Definition collection.h:137
void dt_selection_to_culling_mode()
Definition collection.c:256
void dt_collection_set_filter_flags(const dt_collection_t *collection, dt_collection_filter_flag_t flags)
Definition collection.c:303
void dt_collection_memory_update()
Definition collection.c:216
void dt_collection_set_recents_handler(dt_collection_recents_handler_t handler)
Definition collection.c:831
dt_collection_filter_flag_t dt_collection_get_filter_flags(const dt_collection_t *collection)
Definition collection.c:297
dt_collection_query_flags_t
Definition collection.h:69
@ COLLECTION_QUERY_USE_ONLY_WHERE_EXT
Definition collection.h:74
@ COLLECTION_QUERY_USE_WHERE_EXT
Definition collection.h:73
@ COLLECTION_QUERY_USE_SORT
Definition collection.h:71
@ COLLECTION_QUERY_SIMPLE
Definition collection.h:70
@ COLLECTION_QUERY_USE_LIMIT
Definition collection.h:72
void dt_collection_get_makermodels(const gchar *filter, GList **sanitized, GList **exif)
Definition collection.c:646
dt_collection_filter_flag_t
Definition collection.h:79
@ COLLECTION_FILTER_ALTERED
Definition collection.h:81
@ COLLECTION_FILTER_UNALTERED
Definition collection.h:82
@ COLLECTION_FILTER_GREEN
Definition collection.h:92
@ COLLECTION_FILTER_NONE
Definition collection.h:80
@ COLLECTION_FILTER_2_STAR
Definition collection.h:86
@ COLLECTION_FILTER_MAGENTA
Definition collection.h:94
@ COLLECTION_FILTER_0_STAR
Definition collection.h:84
@ COLLECTION_FILTER_1_STAR
Definition collection.h:85
@ COLLECTION_FILTER_BLUE
Definition collection.h:93
@ COLLECTION_FILTER_5_STAR
Definition collection.h:89
@ COLLECTION_FILTER_YELLOW
Definition collection.h:91
@ COLLECTION_FILTER_ALL
Definition collection.h:96
@ COLLECTION_FILTER_REJECTED
Definition collection.h:83
@ COLLECTION_FILTER_4_STAR
Definition collection.h:88
@ COLLECTION_FILTER_3_STAR
Definition collection.h:87
@ COLLECTION_FILTER_RED
Definition collection.h:90
@ COLLECTION_FILTER_WHITE
Definition collection.h:95
void(* dt_collection_recents_handler_t)(void)
Definition collection.h:63
GList * dt_collection_get_images_for_rule(const dt_collection_properties_t property, const char *text, gboolean recursive)
Definition collection.c:667
void dt_collection_split_operator_number(const gchar *input, char **number1, char **number2, char **op)
Definition collection.c:455
void dt_collection_notify_imported(const int32_t imgid, const gchar *known_image_folder, gint64 *last_refresh_us)
gboolean dt_collection_get_browsed_folder(gchar *folder, size_t len, gboolean *recursive)
dt_collection_query_flags_t dt_collection_get_query_flags(const dt_collection_t *collection)
Definition collection.c:324
void dt_collection_set_rules(const dt_collection_t *collection, const dt_collection_rule_t *rules, const int n_rules)
Definition collection.c:337
dt_collection_sort_t dt_collection_get_sort_field(const dt_collection_t *collection)
Definition collection.c:378
void dt_collection_set_tag_id(dt_collection_t *collection, const uint32_t tagid)
Definition collection.c:361
void dt_collection_name_value_free(gpointer value)
Definition collection.c:673
int dt_collection_get_nth(const dt_collection_t *collection, int nth)
Definition collection.c:236
dt_collection_change_t
Definition collection.h:160
@ DT_COLLECTION_CHANGE_RELOAD
Definition collection.h:164
@ DT_COLLECTION_CHANGE_NEW_QUERY
Definition collection.h:162
@ DT_COLLECTION_CHANGE_BACKGROUND_SYNC
Definition collection.h:174
@ DT_COLLECTION_CHANGE_FILTER
Definition collection.h:163
@ DT_COLLECTION_CHANGE_NONE
Definition collection.h:161
gchar * dt_collection_get_makermodel(const char *exif_maker, const char *exif_model)
Definition collection.c:651
dt_collection_import_view_t
Definition collection.h:269
@ DT_COLLECTION_IMPORT_VIEW_KEEP
Definition collection.h:273
@ DT_COLLECTION_IMPORT_VIEW_GRID
Definition collection.h:275
@ DT_COLLECTION_IMPORT_VIEW_IMAGE
Definition collection.h:277
void dt_collection_hint_message(const dt_collection_t *collection)
Definition collection.c:912
void dt_collection_cleanup_global(void)
Definition collection.c:148
int dt_collection_serialize(char *buf, int bufsize)
Definition collection.c:720
uint32_t dt_collection_get_count(const dt_collection_t *collection)
Definition collection.c:269
void dt_collection_init_global(void)
Definition collection.c:143
int dt_collection_update(const dt_collection_t *collection)
Definition collection.c:198
dt_collection_sort_t
Definition collection.h:100
@ DT_COLLECTION_SORT_EXPORT_TIMESTAMP
Definition collection.h:106
@ DT_COLLECTION_SORT_IMPORT_TIMESTAMP
Definition collection.h:104
@ DT_COLLECTION_SORT_DATETIME
Definition collection.h:103
@ DT_COLLECTION_SORT_GROUP
Definition collection.h:111
@ DT_COLLECTION_SORT_FILENAME
Definition collection.h:102
@ DT_COLLECTION_SORT_RATING
Definition collection.h:108
@ DT_COLLECTION_SORT_PATH
Definition collection.h:112
@ DT_COLLECTION_SORT_TITLE
Definition collection.h:113
@ DT_COLLECTION_SORT_CHANGE_TIMESTAMP
Definition collection.h:105
@ DT_COLLECTION_SORT_NONE
Definition collection.h:101
@ DT_COLLECTION_SORT_PRINT_TIMESTAMP
Definition collection.h:107
@ DT_COLLECTION_SORT_ID
Definition collection.h:109
@ DT_COLLECTION_SORT_COLOR
Definition collection.h:110
dt_collection_t * dt_collection_new()
Definition collection.c:154
void dt_collection_set_sort(const dt_collection_t *collection, dt_collection_sort_t sort, gint reverse)
void dt_collection_load_filmroll(dt_collection_t *collection, const int32_t imgid, dt_collection_import_view_t view_policy, gboolean set_mouse_over)
GList * dt_collection_get_property_values(const dt_collection_properties_t property, const int rule)
Definition collection.c:682
GList * dt_collection_get_all(const dt_collection_t *collection, int limit)
Definition collection.c:442
gchar * dt_collection_get_sort_query(const dt_collection_t *collection)
void dt_collection_free(const dt_collection_t *collection)
Definition collection.c:168
GtkWidget * folder
destination folder chooser
@ DT_METADATA_NUMBER
Definition metadata.h:57
dt_mipmap_buffer_dsc_flags flags
Definition mipmap_cache.c:4
static const dt_aligned_pixel_simd_t value
Definition simd.h:144
dt_collection_query_flags_t query_flags
Definition collection.h:192
dt_collection_sort_t sort
Definition collection.h:201
dt_collection_filter_flag_t filter_flags
Definition collection.h:195
dt_collection_properties_t property
Definition collection.h:183
const char * text
Definition collection.h:185
dt_collection_params_t store
Definition collection.h:213
unsigned int count
Definition collection.h:210
dt_collection_params_t params
Definition collection.h:212
unsigned int tagid
Definition collection.h:211
dt_collection_rule_t * rules
Definition collection.h:208