static int local_copy_member(lua_State *L) { if(lua_gettop(L) != 3) { const dt_image_t *my_image = checkreadimage(L, 1); lua_pushboolean(L, my_image->flags & DT_IMAGE_LOCAL_COPY); releasereadimage(L, my_image); return 1; } else { dt_image_t *my_image = checkwriteimage(L, 1); int imgid = my_image->id; luaL_checktype(L, 3, LUA_TBOOLEAN); // we need to release write image for the other functions to use it releasewriteimage(L, my_image); if(lua_toboolean(L, 3)) { dt_image_local_copy_set(imgid); } else { dt_image_local_copy_reset(imgid); } return 0; } }
int32_t dt_control_local_copy_images_job_run(dt_job_t *job) { int imgid = -1; dt_control_image_enumerator_t *t1 = (dt_control_image_enumerator_t *)job->param; GList *t = t1->index; guint tagid = 0; const int total = g_list_length(t); double fraction=0; gboolean is_copy = GPOINTER_TO_INT(job->user_data) == 1; char message[512]= {0}; if (is_copy) snprintf(message, 512, ngettext ("creating local copy of %d image", "creating local copies of %d images", total), total); else snprintf(message, 512, ngettext ("removing local copy of %d image", "removing local copies of %d images", total), total); dt_control_log(message); dt_tag_new("darktable|local-copy",&tagid); /* create a cancellable bgjob ui template */ const guint *jid = dt_control_backgroundjobs_create(darktable.control, 0, message); dt_control_backgroundjobs_set_cancellable(darktable.control, jid, job); const dt_control_t *control = darktable.control; while(t && dt_control_job_get_state(job) != DT_JOB_STATE_CANCELLED) { imgid = GPOINTER_TO_INT(t->data); if (GPOINTER_TO_INT(job->user_data) == 1) { dt_image_local_copy_set(imgid); dt_tag_attach(tagid, imgid); } else { dt_image_local_copy_reset(imgid); dt_tag_detach(tagid, imgid); } t = g_list_delete_link(t, t); fraction += 1.0/total; dt_control_backgroundjobs_progress(control, jid, fraction); } dt_control_backgroundjobs_destroy(control, jid); dt_control_signal_raise(darktable.signals, DT_SIGNAL_FILMROLLS_CHANGED); return 0; }
int32_t dt_control_local_copy_images_job_run(dt_job_t *job) { long int imgid = -1; dt_control_image_enumerator_t *t1 = (dt_control_image_enumerator_t *)job->param; GList *t = t1->index; while(t) { imgid = (long int)t->data; if ((long int)job->user_data == 1) dt_image_local_copy_set(imgid); else dt_image_local_copy_reset(imgid); t = g_list_delete_link(t, t); } return 0; }
static int image_newindex(lua_State *L) { const char* membername = lua_tostring(L, -2); dt_image_t * my_image=checkwriteimage(L,-3); if(luaA_struct_has_member_name(L,dt_image_t,membername)) { if(luaA_type_has_to_func(luaA_struct_typeof_member_name(L,dt_image_t,membername))) { luaA_struct_to_member_name(L, dt_image_t, my_image, membername,-1); } else { releasewriteimage(L,my_image); luaL_error(L,"%s is read only",membername); } releasewriteimage(L,my_image); return 0; } switch(luaL_checkoption(L,-2,NULL,image_fields_name)) { case RATING: { int my_score = luaL_checkinteger(L,-1); if(my_score > 5) { releasewriteimage(L,my_image); return luaL_error(L,"rating too high : %d",my_score); } if(my_score == -1) my_score = 6; if(my_score < -1) { releasewriteimage(L,my_image); return luaL_error(L,"rating too low : %d",my_score); } my_image->flags &= ~0x7; my_image->flags |= my_score; break; } case CREATOR: dt_metadata_set(my_image->id,"Xmp.dc.creator",luaL_checkstring(L,-1)); dt_image_synch_xmp(my_image->id); break; case PUBLISHER: dt_metadata_set(my_image->id,"Xmp.dc.publisher",luaL_checkstring(L,-1)); dt_image_synch_xmp(my_image->id); break; case TITLE: dt_metadata_set(my_image->id,"Xmp.dc.title",luaL_checkstring(L,-1)); dt_image_synch_xmp(my_image->id); break; case DESCRIPTION: dt_metadata_set(my_image->id,"Xmp.dc.description",luaL_checkstring(L,-1)); dt_image_synch_xmp(my_image->id); break; case RIGHTS: dt_metadata_set(my_image->id,"Xmp.dc.title",luaL_checkstring(L,-1)); dt_image_synch_xmp(my_image->id); break; case LOCAL_COPY: { int imgid = my_image->id; luaL_checktype(L,-1,LUA_TBOOLEAN); // we need to release write image for the other functions to use it releasewriteimage(L,my_image); if(lua_toboolean(L,-1)) { dt_image_local_copy_set(imgid); } else { dt_image_local_copy_reset(imgid); } return 0; } default: releasewriteimage(L,my_image); return luaL_error(L,"unknown index for image : ",lua_tostring(L,-2)); } releasewriteimage(L,my_image); return 0; }