46#include <glib/gi18n.h>
184 if(
t && !g_strcmp0(
t + 1, subkey))
205 char *setting = g_strdup_printf(
"plugins/lighttable/metadata/%s_flag",
name);
230 for(GList *
i = list;
i;
i = g_list_next(
i))
232 if(
i->data && !g_strcmp0(
i->data,
data))
243 gchar *metadata_list = NULL;
248 GList *b2 = g_list_next(b);
249 gboolean different_value =
FALSE;
250 const char *
value = (
char *)b2->data;
253 GList *same2 = g_list_next(same_key);
254 different_value = g_strcmp0(same2->data, b2->data);
256 if(!same_key || different_value || !
value[0])
263 if(metadata_list) metadata_list[strlen(metadata_list) - 1] =
'\0';
264 return metadata_list;
282 GList *a2 = g_list_next(a);
283 gboolean different_value =
FALSE;
284 const char *
value = (
char *)a2->data;
287 GList *same2 = g_list_next(same_key);
288 different_value = g_strcmp0(same2->data, a2->data);
290 if((!same_key || different_value) &&
value[0])
293 .keyid = atoi(a->data),
295 g_array_append_val(rows,
row);
322 g_array_free(tobe_added_rows,
TRUE);
329 for(GList *list = (GList *)
data; list; list = g_list_next(list))
336 *imgs = g_list_prepend(*imgs, GINT_TO_POINTER(undometadata->
imgid));
352 metadata->
after = NULL;
358 GList *l = (GList *)
data;
370 c =
v + strlen(
v) - 1;
371 while(c >=
v && *c ==
' ') *c-- =
'\0';
373 while(*c ==
' ') c++;
375 c = g_strdup(c ? c :
"");
392 GList *result = NULL;
397 if(strncmp(
key,
"Xmp.xmp.Rating", 14) == 0)
399 else if(strncmp(
key,
"Xmp.dc.subject", 14) == 0)
401 else if(strncmp(
key,
"Xmp.darktable.colorlabels", 25) == 0)
410 if(!
IS_NULL_PTR(count)) *count = g_list_length(result);
421 const GList *
m = metadata;
424 GList *m2 = g_list_next(
m);
426 GList *same2 = g_list_next(same_key);
427 gboolean different_value =
FALSE;
428 if(same_key) different_value = g_strcmp0(same2->data, m2->data);
429 if(same_key && different_value)
433 same2->data = g_strdup(m2->data);
438 *list = g_list_append(*list, g_strdup(
m->data));
439 *list = g_list_append(*list, g_strdup(m2->data));
449 for(
const GList *
m = metadata;
m;
m = g_list_next(
m))
455 GList *same2 = g_list_next(same_key);
456 *list = g_list_remove_link(*list, same_key);
458 g_list_free(same_key);
460 *list = g_list_remove_link(*list, same2);
476 const gboolean undo_on,
const gint action)
478 for(
const GList *images = imgs; images; images = g_list_next(images))
480 const int32_t image_id = GPOINTER_TO_INT(images->data);
483 undometadata->
imgid = image_id;
488 undometadata->
after = metadata ? g_list_copy_deep((GList *)metadata, (GCopyFunc)g_strdup, NULL) : NULL;
491 undometadata->
after = g_list_copy_deep(undometadata->
before, (GCopyFunc)g_strdup, NULL);
495 undometadata->
after = g_list_copy_deep(undometadata->
before, (GCopyFunc)g_strdup, NULL);
499 undometadata->
after = g_list_copy_deep(undometadata->
before, (GCopyFunc)g_strdup, NULL);
506 *undo = g_list_append(*undo, undometadata);
523 imgs = g_list_prepend(imgs, GINT_TO_POINTER(imgid));
529 const gchar *ckey = g_strdup_printf(
"%d", keyid);
531 GList *metadata = NULL;
532 metadata = g_list_append(metadata, (gpointer)ckey);
533 metadata = g_list_append(metadata, (gpointer)cvalue);
563 char *setting = g_strdup_printf(
"plugins/lighttable/metadata/%s_flag",
name);
570 imgs = g_list_prepend(imgs, GINT_TO_POINTER(imgid));
575 const gchar *ckey = g_strdup_printf(
"%d", keyid);
577 GList *metadata = NULL;
578 metadata = g_list_append(metadata, (gpointer)ckey);
579 metadata = g_list_append(metadata, (gpointer)cvalue);
594 GList *metadata = NULL;
595 GList *kv = key_value;
598 const gchar *
key = (
const gchar *)kv->data;
602 const gchar *ckey = g_strdup_printf(
"%d", keyid);
603 kv = g_list_next(kv);
604 const gchar *
value = (
const gchar *)kv->data;
605 kv = g_list_next(kv);
608 metadata = g_list_append(metadata, (gchar *)ckey);
614 kv = g_list_next(kv);
615 kv = g_list_next(kv);
640 GList *metadata = NULL;
646 char *setting = g_strdup_printf(
"plugins/lighttable/metadata/%s_flag",
name);
652 metadata = g_list_prepend(metadata, g_strdup_printf(
"%d",
i));
659 metadata = g_list_reverse(metadata);
677 const gboolean undo_on)
698 char *
id = g_strconcat(filename,
"-", datetime, NULL);
GList * dt_act_on_get_images()
GList * dt_colorlabel_repository_get_list(const int32_t imgid)
The colours set on imgid, as a list rather than a bitmask.
main.color_labels: which of the five colour labels are set on an image.
int dt_conf_key_exists(const char *key)
Does key have a value?
void dt_conf_set_int(const char *name, int val)
int dt_conf_get_int(const char *name)
Integer for name, clamped to the bounds declared in the XML.
static void _pop_undo(gpointer user_data, const dt_undo_type_t type, dt_undo_data_t data, const dt_undo_action_t action, GList **imgs)
gboolean dt_image_get_xmp_mode()
GList * dt_image_repository_get_ratings(const int32_t imgid)
Star ratings, as main.images.flags encodes them: the low three bits, minus one.
Reading and writing one dt_image_t to and from the library database. The SQL half of what used to be ...
_lib_location_type_t type
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
static void dt_free_gpointer(gpointer ptr)
g_free() one pointer, with the signature GDestroyNotify wants.
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
GList * dt_tag_repository_get_attached_names(const int32_t imgid)
Names of the tags attached to an image.
data.tags and main.tagged_images.
void dt_undo_end_group(dt_undo_t *self)
void dt_undo_start_group(dt_undo_t *self, dt_undo_type_t type)
void dt_undo_record(dt_undo_t *self, gpointer user_data, dt_undo_type_t type, dt_undo_data_t data, void(*undo)(gpointer user_data, dt_undo_type_t type, dt_undo_data_t item, dt_undo_action_t action, GList **imgs), void(*free_data)(gpointer data))
dt_undo_t * dt_undo_get_global(void)
gchar * dt_util_dstrcat(gchar *str, const gchar *format,...)