int group_with(lua_State *L) { dt_lua_image_t first_image; luaA_to(L,dt_lua_image_t,&first_image,1); if(lua_isnoneornil(L,2)) { dt_grouping_remove_from_group(first_image); return 0; } dt_lua_image_t second_image; luaA_to(L,dt_lua_image_t,&second_image,2); const dt_image_t *cimg = dt_image_cache_read_get(darktable.image_cache, second_image); int group_id = cimg->group_id; dt_image_cache_read_release(darktable.image_cache, cimg); dt_grouping_add_to_group(group_id,first_image); return 0; }
/** merges all the selected images into a single group. * if there is an expanded group, then they will be joined there, otherwise a new one will be created. */ static void _group_helper_function(void) { int new_group_id = darktable.gui->expanded_group_id; sqlite3_stmt *stmt; DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "select distinct imgid from selected_images", -1, &stmt, NULL); while(sqlite3_step(stmt) == SQLITE_ROW) { int id = sqlite3_column_int(stmt, 0); if(new_group_id == -1) new_group_id = id; dt_grouping_add_to_group(new_group_id, id); } sqlite3_finalize(stmt); if(darktable.gui->grouping) darktable.gui->expanded_group_id = new_group_id; else darktable.gui->expanded_group_id = -1; dt_collection_update_query(darktable.collection); dt_control_queue_redraw_center(); }