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

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0a13fdd
upgrade database schema
zisoft Oct 31, 2024
13242f4
write metadata
zisoft Nov 1, 2024
2832003
set metadata list
zisoft Nov 12, 2024
cfb4819
update layout
zisoft Nov 13, 2024
fc5b8f4
update gui_reset
zisoft Nov 14, 2024
2230cff
upgrade get_params
zisoft Nov 14, 2024
8a4ccf7
upgrade legacy_params
zisoft Nov 14, 2024
8a35501
upgrade set_params
zisoft Nov 14, 2024
685a48b
code cleanup
zisoft Nov 14, 2024
593dc8b
use tag subkey for config string
zisoft Nov 15, 2024
495acfa
upgrade dt_metadata util functions
zisoft Nov 15, 2024
d03b6ff
mutex for thread safety
zisoft Nov 18, 2024
bc48968
add dt_default flag to data.meta_data
zisoft Nov 20, 2024
855e66c
handle metadata in exif.cc
zisoft Nov 21, 2024
9b9d60f
upgrade import_metadata module
zisoft Nov 22, 2024
645b15c
upgrade import module
zisoft Nov 22, 2024
59fedc8
upgrade lua metadata register
zisoft Nov 22, 2024
8f0cdae
init metadata for import
zisoft Nov 22, 2024
8d9650b
upgrade import preset handling
zisoft Nov 22, 2024
4e2bf25
remove unused functions
zisoft Nov 23, 2024
2faa76a
upgrade collection module
zisoft Nov 23, 2024
e90cc63
upgrade filtering module
zisoft Nov 23, 2024
9481892
upgrade collection sort order
zisoft Nov 24, 2024
3917a22
upgrade metadata_view module
zisoft Nov 24, 2024
2e07e29
signals for metadata changes
zisoft Nov 30, 2024
b2d56a5
handle metadata prefences change
zisoft Dec 2, 2024
76cac25
remove old metadata structures
zisoft Dec 3, 2024
1185d84
separate the metadata tags dialog
zisoft Dec 4, 2024
8bfe431
add/delete metadata by gui
zisoft Dec 6, 2024
6d7f7d9
ensure thread-safety
zisoft Dec 7, 2024
1696556
rebuild metadata grid on change
zisoft Dec 8, 2024
3a3526c
handle metadata tags on export
zisoft Dec 10, 2024
5588400
handle metadata in variables
zisoft Dec 11, 2024
942ca21
cleanup metadata structure
zisoft Dec 16, 2024
835dd04
unregister signal handlers
zisoft Dec 17, 2024
1e160a8
simplify variables completion list handling
zisoft Dec 22, 2024
df8d418
fix lua handling
zisoft Dec 22, 2024
bef6e83
fix glib-critical messages
zisoft Jan 8, 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 @@ -196,6 +196,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 @@ -340,15 +340,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 @@ -660,22 +660,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 @@ -2266,11 +2251,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 && property < DT_COLLECTION_PROP_METADATA + DT_METADATA_MAX_NUMBER)
{
const int keyid =
dt_metadata_get_keyid_by_display_order(property - DT_COLLECTION_PROP_METADATA);
// metadata
const int keyid = property - DT_COLLECTION_PROP_METADATA;
if(strcmp(escaped_text, _("not defined")) != 0)
// clang-format off
query = g_strdup_printf
Expand Down
2 changes: 1 addition & 1 deletion src/common/collection.h
Original file line number Diff line number Diff line change
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_MAX_NUMBER,
DT_COLLECTION_PROP_LOCAL_COPY,

DT_COLLECTION_PROP_HISTORY,
Expand Down
2 changes: 2 additions & 0 deletions src/common/colorlabels.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ 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)
{
dt_pthread_mutex_lock(&darktable.metadata_threadsafe);
GList *res = dt_metadata_get(imgid, "Xmp.darktable.colorlabels", NULL);
dt_pthread_mutex_unlock(&darktable.metadata_threadsafe);
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 @@ -925,6 +925,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 @@ -1735,7 +1736,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 @@ -2167,6 +2170,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 @@ -396,6 +396,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
73 changes: 72 additions & 1 deletion src/common/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "common/iop_order.h"
#include "common/styles.h"
#include "common/history.h"
#include "common/metadata.h"
#ifdef HAVE_ICU
#include "common/sqliteicu.h"
#endif
Expand All @@ -53,7 +54,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 10
#define CURRENT_DATABASE_VERSION_DATA 11

#define USE_NESTED_TRANSACTIONS
#define MAX_NESTED_TRANSACTIONS 5
Expand Down Expand Up @@ -3171,6 +3172,76 @@ 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("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");

int visible;
gchar *query = NULL;
visible = (dt_conf_get_int("plugins/lighttable/metadata/creator_flag") & 1) ? 0 : 1;
query = g_strdup_printf("INSERT INTO data.meta_data VALUES(0, 'Xmp.dc.creator', '%s', 0, %d, 0, 2)",
_("creator"), visible);
TRY_EXEC(query, "can't insert meta_data_key record");
g_free(query);

visible = (dt_conf_get_int("plugins/lighttable/metadata/publisher_flag") & 1) ? 0 : 1;
query = g_strdup_printf("INSERT INTO data.meta_data VALUES(1, 'Xmp.dc.publisher', '%s', 0, %d, 0, 3)",
_("publisher"), visible);
TRY_EXEC(query, "can't insert meta_data_key record");
g_free(query);

visible = (dt_conf_get_int("plugins/lighttable/metadata/title_flag") & 1) ? 0 : 1;
query = g_strdup_printf("INSERT INTO data.meta_data VALUES(2, 'Xmp.dc.title', '%s', 0, %d, 0, 0)",
_("title"), visible);
TRY_EXEC(query, "can't insert meta_data_key record");
g_free(query);

visible = (dt_conf_get_int("plugins/lighttable/metadata/description_flag") & 1) ? 0 : 1;
query = g_strdup_printf("INSERT INTO data.meta_data VALUES(3, 'Xmp.dc.description', '%s', 0, %d, 0, 1)",
_("description"), visible);
TRY_EXEC(query, "can't insert meta_data_key record");
g_free(query);

visible = (dt_conf_get_int("plugins/lighttable/metadata/rights_flag") & 1) ? 0 : 1;
query = g_strdup_printf("INSERT INTO data.meta_data VALUES(4, 'Xmp.dc.rights', '%s', 0, %d, 0, 4)",
_("rights"), visible);
TRY_EXEC(query, "can't insert meta_data_key record");
g_free(query);

visible = (dt_conf_get_int("plugins/lighttable/metadata/notes_flag") & 1) ? 0 : 1;
query = g_strdup_printf("INSERT INTO data.meta_data VALUES(5, 'Xmp.acdsee.notes', '%s', 0, %d, 0, 5)",
_("notes"), visible);
TRY_EXEC(query, "can't insert meta_data_key record");
g_free(query);

visible = (dt_conf_get_int("plugins/lighttable/metadata/version name_flag") & 1) ? 0 : 1;
query = g_strdup_printf("INSERT INTO data.meta_data VALUES(6, 'Xmp.darktable.version_name', '%s', 0, %d, 0, 6)",
_("version name"), visible);
TRY_EXEC(query, "can't insert meta_data_key record");
g_free(query);

visible = 0;
query = g_strdup_printf("INSERT INTO data.meta_data VALUES(7, 'Xmp.darktable.image_id', '%s', 1, %d, 0, 7)",
_("image id"), visible);
TRY_EXEC(query, "can't insert meta_data_key record");
g_free(query);

visible = (dt_conf_get_int("plugins/lighttable/metadata/preserved filename_flag") & 1) ? 0 : 1;
query = g_strdup_printf("INSERT INTO data.meta_data VALUES(8, 'Xmp.xmpMM.PreservedFileName', '%s', 0, %d, 0, 8)",
_("preserved filename"), visible);
TRY_EXEC(query, "can't insert meta_data_key record");
g_free(query);

new_version = 11;
}
else
new_version = version; // should be the fallback so that calling code sees that we are in an infinite loop
Expand Down
Loading
Loading