Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fully configurable metadata module #18036

Merged
merged 41 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c8188d6
upgrade database schema
zisoft Oct 31, 2024
905e6b3
write metadata
zisoft Nov 1, 2024
a3bfba0
set metadata list
zisoft Nov 12, 2024
708af5a
update layout
zisoft Nov 13, 2024
b3ef3dd
update gui_reset
zisoft Nov 14, 2024
ac4fc73
upgrade get_params
zisoft Nov 14, 2024
e3af392
upgrade legacy_params
zisoft Nov 14, 2024
1868f34
upgrade set_params
zisoft Nov 14, 2024
dd5bdb7
code cleanup
zisoft Nov 14, 2024
167d549
use tag subkey for config string
zisoft Nov 15, 2024
5d0cdeb
upgrade dt_metadata util functions
zisoft Nov 15, 2024
f7a7b58
mutex for thread safety
zisoft Nov 18, 2024
6a9ad30
add dt_default flag to data.meta_data
zisoft Nov 20, 2024
dac9960
handle metadata in exif.cc
zisoft Nov 21, 2024
6b98b0d
upgrade import_metadata module
zisoft Nov 22, 2024
842e413
upgrade import module
zisoft Nov 22, 2024
05ab381
upgrade lua metadata register
zisoft Nov 22, 2024
7a3ad67
init metadata for import
zisoft Nov 22, 2024
abf38ab
upgrade import preset handling
zisoft Nov 22, 2024
106b8b1
remove unused functions
zisoft Nov 23, 2024
c2ea64a
upgrade collection module
zisoft Nov 23, 2024
ae50208
upgrade filtering module
zisoft Nov 23, 2024
75919d7
upgrade collection sort order
zisoft Nov 24, 2024
5244436
upgrade metadata_view module
zisoft Nov 24, 2024
a75619b
signals for metadata changes
zisoft Nov 30, 2024
589ab51
handle metadata prefences change
zisoft Dec 2, 2024
1b5ea17
remove old metadata structures
zisoft Dec 3, 2024
cfb6768
separate the metadata tags dialog
zisoft Dec 4, 2024
406f194
add/delete metadata by gui
zisoft Dec 6, 2024
7e4c4d0
ensure thread-safety
zisoft Dec 7, 2024
72a0b49
rebuild metadata grid on change
zisoft Dec 8, 2024
5385824
handle metadata tags on export
zisoft Dec 10, 2024
9892165
handle metadata in variables
zisoft Dec 11, 2024
995b848
cleanup metadata structure
zisoft Dec 16, 2024
0f83bd9
unregister signal handlers
zisoft Dec 17, 2024
0f09b64
simplify variables completion list handling
zisoft Dec 22, 2024
d21c8be
fix lua handling
zisoft Dec 22, 2024
2956ba8
fix glib-critical messages
zisoft Jan 8, 2025
0ea695e
set editing handler for treeview in preferences dialog
zisoft Jan 29, 2025
44d271a
fix collection filter handling
zisoft Feb 4, 2025
71e0089
simplify metadata locking
zisoft Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ src/gui/gtkentry.c
src/gui/guides.c
src/gui/hist_dialog.c
src/gui/import_metadata.c
src/gui/metadata_tags.c
src/gui/preferences.c
src/gui/presets.c
src/gui/splash.c
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ FILE(GLOB SOURCE_FILES
"gui/guides.c"
"gui/hist_dialog.c"
"gui/import_metadata.c"
"gui/metadata_tags.c"
"gui/preferences.c"
"gui/presets.c"
"gui/splash.c"
Expand Down
32 changes: 8 additions & 24 deletions src/common/collection.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,15 @@ int dt_collection_update(const dt_collection_t *collection)
{
dt_util_str_cat
(&selq_post,
" LEFT OUTER JOIN main.meta_data AS mt ON sel.id = mt.id AND mt.key = %d",
DT_METADATA_XMP_DC_TITLE);
" LEFT OUTER JOIN main.meta_data AS mt ON sel.id = mt.id"
" AND mt.key = (SELECT key FROM data.meta_data WHERE tagname = 'Xmp.dc.title')");
}
if(collection->params.sorts[DT_COLLECTION_SORT_DESCRIPTION])
{
dt_util_str_cat
(&selq_post,
" LEFT OUTER JOIN main.meta_data AS md ON sel.id = md.id AND md.key = %d",
DT_METADATA_XMP_DC_DESCRIPTION);
" LEFT OUTER JOIN main.meta_data AS md ON sel.id = md.id"
" AND md.key = (SELECT key FROM data.meta_data WHERE tagname = 'Xmp.dc.description')");
}
}

Expand Down Expand Up @@ -657,22 +657,7 @@ const char *dt_collection_name_untranslated(const dt_collection_properties_t pro
case DT_COLLECTION_PROP_LAST:
return NULL;
default:
{
if(prop >= DT_COLLECTION_PROP_METADATA
&& prop < DT_COLLECTION_PROP_METADATA + DT_METADATA_NUMBER)
{
const int i = prop - DT_COLLECTION_PROP_METADATA;
const int type = dt_metadata_get_type_by_display_order(i);
if(type != DT_METADATA_TYPE_INTERNAL)
{
char *name = (gchar *)dt_metadata_get_name_by_display_order(i);
char *setting = g_strdup_printf("plugins/lighttable/metadata/%s_flag", name);
const gboolean hidden = dt_conf_get_int(setting) & DT_METADATA_FLAG_HIDDEN;
free(setting);
if(!hidden) col_name = name;
}
}
}
return NULL;
}
return col_name;
}
Expand Down Expand Up @@ -2263,11 +2248,10 @@ static gchar *get_query_string(const dt_collection_properties_t property, const

default:
{
if(property >= DT_COLLECTION_PROP_METADATA
&& property < DT_COLLECTION_PROP_METADATA + DT_METADATA_NUMBER)
if(property >= DT_COLLECTION_PROP_METADATA_OFFSET)
{
const int keyid =
dt_metadata_get_keyid_by_display_order(property - DT_COLLECTION_PROP_METADATA);
// metadata
const int keyid = property - DT_COLLECTION_PROP_METADATA_OFFSET;
if(strcmp(escaped_text, _("not defined")) != 0)
// clang-format off
query = g_strdup_printf
Expand Down
9 changes: 6 additions & 3 deletions src/common/collection.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2024 darktable developers.
Copyright (C) 2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -99,7 +99,7 @@ typedef enum dt_collection_properties_t

// keep DT_COLLECTION_PROP_GROUPING to avoid breaking all presets based on
// filters defined after GROUPING here.
DT_COLLECTION_PROP_GROUPING = DT_COLLECTION_PROP_METADATA + DT_METADATA_NUMBER,
DT_COLLECTION_PROP_GROUPING = DT_COLLECTION_PROP_METADATA + DT_METADATA_LEGACY_NUMBER,
DT_COLLECTION_PROP_LOCAL_COPY,

DT_COLLECTION_PROP_HISTORY,
Expand All @@ -124,8 +124,11 @@ typedef enum dt_collection_properties_t
DT_COLLECTION_PROP_LAST,

DT_COLLECTION_PROP_UNDEF,
DT_COLLECTION_PROP_SORT
DT_COLLECTION_PROP_SORT,

// the number of metadata tags is variable, so we keep this at the end with
// a huge offset
DT_COLLECTION_PROP_METADATA_OFFSET = 10000
} dt_collection_properties_t;

typedef enum dt_collection_change_t
Expand Down
2 changes: 1 addition & 1 deletion src/common/colorlabels.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ static float _action_process_color_label(gpointer target,
const dt_imgid_t imgid = GPOINTER_TO_INT(imgs->data);
if(imgid == darktable.develop->preview_pipe->output_imgid)
{
GList *res = dt_metadata_get(imgid, "Xmp.darktable.colorlabels", NULL);
GList *res = dt_metadata_get_lock(imgid, "Xmp.darktable.colorlabels", NULL);
gchar *result = NULL;
for(GList *res_iter = res; res_iter; res_iter = g_list_next(res_iter))
{
Expand Down
4 changes: 4 additions & 0 deletions src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
dt_pthread_mutex_init(&(darktable.capabilities_threadsafe), NULL);
dt_pthread_mutex_init(&(darktable.exiv2_threadsafe), NULL);
dt_pthread_mutex_init(&(darktable.readFile_mutex), NULL);
dt_pthread_mutex_init(&(darktable.metadata_threadsafe), NULL);
darktable.control = (dt_control_t *)calloc(1, sizeof(dt_control_t));

// database
Expand Down Expand Up @@ -1761,7 +1762,9 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
dt_exif_set_exiv2_taglist();

// init metadata flags
dt_pthread_mutex_lock(&darktable.metadata_threadsafe);
dt_metadata_init();
dt_pthread_mutex_unlock(&darktable.metadata_threadsafe);

darktable_splash_screen_set_progress(_("synchronizing local copies"));
dt_image_local_copy_synch();
Expand Down Expand Up @@ -2171,6 +2174,7 @@ void dt_cleanup()
dt_pthread_mutex_destroy(&(darktable.capabilities_threadsafe));
dt_pthread_mutex_destroy(&(darktable.exiv2_threadsafe));
dt_pthread_mutex_destroy(&(darktable.readFile_mutex));
dt_pthread_mutex_destroy(&(darktable.metadata_threadsafe));

dt_exif_cleanup();

Expand Down
1 change: 1 addition & 0 deletions src/common/darktable.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ typedef struct darktable_t
dt_pthread_mutex_t capabilities_threadsafe;
dt_pthread_mutex_t exiv2_threadsafe;
dt_pthread_mutex_t readFile_mutex;
dt_pthread_mutex_t metadata_threadsafe;
char *progname;
char *datadir;
char *sharedir;
Expand Down
45 changes: 43 additions & 2 deletions src/common/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "common/iop_order.h"
#include "common/styles.h"
#include "common/history.h"
#include "common/metadata.h"
#include "common/metadata.h"
#ifdef HAVE_ICU
#include "common/sqliteicu.h"
#endif
Expand All @@ -53,7 +55,7 @@
#define LAST_FULL_DATABASE_VERSION_DATA 10
// You HAVE TO bump THESE versions whenever you add an update branches to _upgrade_*_schema_step()!
#define CURRENT_DATABASE_VERSION_LIBRARY 56
#define CURRENT_DATABASE_VERSION_DATA 12
#define CURRENT_DATABASE_VERSION_DATA 13

#define USE_NESTED_TRANSACTIONS
#define MAX_NESTED_TRANSACTIONS 5
Expand Down Expand Up @@ -3171,7 +3173,7 @@ static int _upgrade_data_schema_step(dt_database_t *db, int version)
"can't set multi_name_hand_edited column");

new_version = 10;
}
}
else if(version == 10)
{
TRY_EXEC("DELETE FROM styles WHERE name LIKE '_l10n_darktable camera styles|%'",
Expand All @@ -3197,6 +3199,45 @@ static int _upgrade_data_schema_step(dt_database_t *db, int version)

new_version = 12;
}
else if(version == 12)
{
TRY_EXEC("CREATE TABLE data.meta_data (key INTEGER PRIMARY KEY, tagname VARCHAR, "
"name VARCHAR, internal INTEGER, visible INTEGER, private INTEGER, display_order INTEGER)",
"can't create new meta_data_keys table");

TRY_EXEC("CREATE UNIQUE INDEX data.meta_data_tagname_idx ON meta_data (tagname)",
"can't create index `meta_data_name_idx' in database");

TRY_EXEC("CREATE UNIQUE INDEX data.meta_data_name_idx ON meta_data (name)",
"can't create index `meta_data_title_idx' in database");

const char *metadata_fields[][3] =
{
{"Xmp.dc.creator", _("creator"), "plugins/lighttable/metadata/creator_flag"},
{"Xmp.dc.publisher", _("publisher"), "plugins/lighttable/metadata/publisher_flag"},
{"Xmp.dc.title", _("title"), "plugins/lighttable/metadata/title_flag"},
{"Xmp.dc.description", _("description"), "plugins/lighttable/metadata/description_flag"},
{"Xmp.dc.rights", _("rights"), "plugins/lighttable/metadata/rights_flag"},
{"Xmp.acdsee.notes", _("notes"), "plugins/lighttable/metadata/notes_flag"},
{"Xmp.darktable.version_name", _("version name"), "plugins/lighttable/metadata/version name_flag"},
{"Xmp.darktable.image_id", _("image id"), NULL},
{"Xmp.xmpMM.PreservedFileName", _("preserved filename"), "plugins/lighttable/metadata/preserved filename_flag"},
};

const int display_order[] = {2,3,0,1,4,5,6,7,8};

for (int i = 0; i < sizeof(metadata_fields) / sizeof(metadata_fields[0]); i++)
{
gchar *query = g_strdup_printf("INSERT INTO data.meta_data VALUES(%d, '%s', '%s', %d, %d, 0, %d)",
i, metadata_fields[i][0], metadata_fields[i][1], (i == 7) ? 1 : 0,
metadata_fields[i][2] ? dt_conf_get_int(metadata_fields[i][2]) & 1 ? 0 : 1 : 0,
display_order[i]);
TRY_EXEC(query, "can't insert meta_data_key record");
g_free(query);
}

zisoft marked this conversation as resolved.
Show resolved Hide resolved
new_version = 13;
}
else
new_version = version; // should be the fallback so that calling code sees that we are in an infinite loop

Expand Down
Loading
Loading