48#include <gdk/gdkkeysyms.h>
52 "red",
"yellow",
"green",
"blue",
"purple",
73 return _(
"unknown/invalid");
95 "SELECT color FROM main.color_labels WHERE imgid = ?1",
101 sqlite3_clear_bindings(stmt);
106 while(sqlite3_step(stmt) == SQLITE_ROW)
107 colors |= (1 << sqlite3_column_int(stmt, 0));
113 for(
int color = 0; color < 5; color++)
128 for(
int color = 0; color < 5; color++)
130 if(after & (1 << color))
132 if (!(before & (1 << color)))
135 else if (before & (1 << color))
148 for(GList *list = (GList *)data; list; list = g_list_next(list))
155 *imgs = g_list_prepend(*imgs, GINT_TO_POINTER(undocolorlabels->
imgid));
163 GList *l = (GList *)data;
173 "DELETE FROM main.color_labels WHERE imgid=?1",
178 sqlite3_clear_bindings(stmt);
189 "INSERT OR IGNORE INTO main.color_labels (imgid, color) VALUES (?1, ?2)",
195 sqlite3_clear_bindings(stmt);
207 "DELETE FROM main.color_labels WHERE imgid=?1 AND color=?2",
213 sqlite3_clear_bindings(stmt);
251static void _colorlabels_execute(GList *imgs,
const int labels, GList **undo,
const gboolean undo_on,
int action)
256 for(
const GList *image = g_list_first(imgs); image; image = g_list_next((GList *)image))
258 const int32_t image_id = GPOINTER_TO_INT(image->data);
268 if(!(before & labels))
276 for(GList *image = g_list_first(imgs); image; image = g_list_next((GList *)image))
278 const int32_t image_id = GPOINTER_TO_INT(image->data);
291 after = before | labels;
294 after = (before & labels) ? before & (~labels) : before | labels;
307 undocolorlabels->
imgid = image_id;
308 undocolorlabels->
before = before;
309 undocolorlabels->
after = after;
310 *undo = g_list_append(*undo, undocolorlabels);
317 const int label = 1<<color;
341 if(imgid <= 0)
return 0;
345 "SELECT * FROM main.color_labels WHERE imgid=?1 AND color=?2 LIMIT 1",
350 if(sqlite3_step(stmt) == SQLITE_ROW)
352 sqlite3_finalize(stmt);
357 sqlite3_finalize(stmt);
void dt_collection_hint_message(const dt_collection_t *collection)
static void _pop_undo(gpointer user_data, dt_undo_type_t type, dt_undo_data_t data, dt_undo_action_t action, GList **imgs)
void dt_colorlabels_remove_label(const int32_t imgid, const int color)
static void _colorlabels_execute(GList *imgs, const int labels, GList **undo, const gboolean undo_on, int action)
void dt_colorlabels_remove_labels(const int32_t imgid)
static void _colorlabels_undo_data_free(gpointer data)
static sqlite3_stmt * _colorlabels_remove_label_stmt
void dt_colorlabels_cleanup(void)
static sqlite3_stmt * _colorlabels_get_labels_stmt
int dt_colorlabels_get_labels(const int32_t imgid)
int dt_colorlabels_check_label(const int32_t imgid, const int color)
static void _pop_undo_execute(const int32_t imgid, const int before, const int after)
static sqlite3_stmt * _colorlabels_set_label_stmt
void dt_colorlabels_set_label(const int32_t imgid, const int color)
static sqlite3_stmt * _colorlabels_remove_labels_stmt
void dt_colorlabels_toggle_label_on_list(GList *list, const int color, const gboolean undo_on)
const char * dt_colorlabels_to_string(int label)
char * dt_colorlabels_get_name(const int label)
const char * dt_colorlabels_name[]
void dt_colorlabels_set_labels(const int32_t imgid, const int colors)
void dt_toast_log(const char *msg,...)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
sqlite3 * dt_database_get(const dt_database_t *db)
#define DT_DEBUG_SQLITE3_PREPARE_V2(a, b, c, d, e)
#define DT_DEBUG_SQLITE3_BIND_INT(a, b, c)
const dt_collection_filter_flag_t colors[6]
void dt_image_cache_read_release(dt_image_cache_t *cache, const dt_image_t *img)
dt_image_t * dt_image_cache_get(dt_image_cache_t *cache, const int32_t imgid, char mode)
void dt_image_cache_write_release(dt_image_cache_t *cache, dt_image_t *img, dt_image_cache_write_mode_t mode)
struct dt_collection_t * collection
const struct dt_database_t * db
struct dt_image_cache_t * image_cache
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))