77 g_list_free(g_steal_pointer(&selection->
ids));
78 selection->
ids = NULL;
85 GList *last = g_list_last(selection->
ids);
97 "DELETE FROM main.selected_images"
99 " (SELECT imgid FROM memory.collected_images)", NULL, NULL, NULL);
111 "SELECT imgid FROM main.selected_images ORDER BY imgid DESC",
117 sqlite3_clear_bindings(stmt);
119 while(sqlite3_step(stmt) == SQLITE_ROW)
121 const int32_t imgid = sqlite3_column_int(stmt, 0);
122 list = g_list_prepend(list, GINT_TO_POINTER(imgid));
134 selection->
length = g_list_length(selection->
ids);
153 GList *link = g_list_find(selection->
ids, GINT_TO_POINTER(imgid));
156 selection->
ids = g_list_delete_link(selection->
ids, link);
164 if(!g_list_find(selection->
ids, GINT_TO_POINTER(imgid)))
166 selection->
ids = g_list_append(selection->
ids, GINT_TO_POINTER(imgid));
176 return g_list_copy(selection->
ids);
188 if(imgid < 0)
return;
190 gchar *query = g_strdup_printf(
"INSERT OR IGNORE INTO main.selected_images VALUES (%d)", imgid);
197 if(imgid < 0)
return;
199 gchar *query = g_strdup_printf(
"DELETE FROM main.selected_images WHERE imgid = %d", imgid);
211 " SELECT * FROM main.selected_images", NULL, NULL, NULL);
228 " SELECT * FROM memory.selected_backup", NULL, NULL, NULL);
255 (gpointer)selection);
256 g_list_free(selection->
ids);
257 selection->
ids = NULL;
300 if(g_list_find(selection->
ids, GINT_TO_POINTER(imgid)))
309 int32_t imgid = GPOINTER_TO_INT((*list)->data);
316 *list = g_list_next(*list);
323 GList *list = (GList *)l;
329 gchar *ids = g_strdup(
"");
330 while(list && count < 400)
333 ids =
dt_util_dstrcat(ids, (ids[0] !=
'\0') ?
", (%i)" :
"(%i)", imgid);
335 gchar *query = g_strdup_printf(
"INSERT OR IGNORE INTO main.selected_images VALUES %s", ids);
346 GList *list = (GList *)l;
352 gchar *ids = g_strdup(
"");
353 while(list && count < 400)
358 gchar *query = g_strdup_printf(
"DELETE FROM main.selected_images WHERE imgid IN (%s)", ids);
372 gchar **ids = g_malloc0_n(selection->
length + 1, 9 *
sizeof(
char *));
376 for(GList *
id = g_list_first(selection->
ids); id;
id = g_list_next(
id))
378 ids[
i] = g_strdup_printf(
"%i", GPOINTER_TO_INT(id->data));
386 gchar *result = g_strjoinv(
",", ids);
396 return (g_list_find(selection->
ids, GINT_TO_POINTER(imgid)) != NULL);
void dt_collection_hint_message(const dt_collection_t *collection)
dt_collection_properties_t
#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_EXEC(a, b, c, d, e)
#define DT_DEBUG_SQLITE3_PREPARE_V2(a, b, c, d, e)
static GList * _selection_database_to_glist(dt_selection_t *selection)
int32_t dt_selection_get_first_id(struct dt_selection_t *selection)
void dt_selection_deselect_list(struct dt_selection_t *selection, const GList *const l)
static sqlite3_stmt * _selection_database_to_glist_stmt
void dt_selection_reload_from_database_real(dt_selection_t *selection)
void dt_selection_push(dt_selection_t *selection)
static void _update_gui()
gchar * dt_selection_ids_to_string(struct dt_selection_t *selection)
static void _remove_id_link(dt_selection_t *selection, int32_t imgid)
static void _selection_update_collection(gpointer instance, dt_collection_change_t query_change, dt_collection_properties_t changed_property, gpointer imgs, uint32_t next, dt_selection_t *selection)
int dt_selection_get_length(struct dt_selection_t *selection)
static void _update_last_ids(dt_selection_t *selection)
static void _selection_deselect(dt_selection_t *selection, int32_t imgid)
void dt_selection_free(dt_selection_t *selection)
static int32_t _list_iterate(struct dt_selection_t *selection, GList **list, int *count, const gboolean add)
static void _selection_select(dt_selection_t *selection, int32_t imgid)
GList * dt_selection_get_list(struct dt_selection_t *selection)
gboolean dt_selection_is_id_selected(struct dt_selection_t *selection, int32_t imgid)
dt_selection_t * dt_selection_new()
void dt_selection_select_list(struct dt_selection_t *selection, const GList *const l)
static void _add_id_link(dt_selection_t *selection, int32_t imgid)
static void _clean_missing_ids(dt_selection_t *selection)
static void _reset_ids_list(dt_selection_t *selection)
void dt_selection_clear(dt_selection_t *selection)
void dt_selection_deselect(dt_selection_t *selection, int32_t imgid)
void dt_selection_select(dt_selection_t *selection, int32_t imgid)
void dt_selection_select_single(dt_selection_t *selection, int32_t imgid)
void dt_selection_pop(dt_selection_t *selection)
void dt_selection_toggle(dt_selection_t *selection, int32_t imgid)
#define dt_selection_reload_from_database(selection)
#define DT_DEBUG_CONTROL_SIGNAL_DISCONNECT(ctlsig, cb, user_data)
#define DT_DEBUG_CONTROL_SIGNAL_RAISE(ctlsig, signal,...)
@ DT_SIGNAL_SELECTION_CHANGED
This signal is raised when the selection is changed no param, no returned value.
@ DT_SIGNAL_COLLECTION_CHANGED
This signal is raised when collection changed. To avoid leaking the list, dt_collection_t is connecte...
#define DT_DEBUG_CONTROL_SIGNAL_CONNECT(ctlsig, signal, cb, user_data)
struct dt_gui_gtk_t * gui
struct dt_collection_t * collection
const struct dt_database_t * db
struct dt_control_signal_t * signals
gboolean selection_stacked
gchar * dt_util_dstrcat(gchar *str, const gchar *format,...)