dt_job_t *dt_camera_import_job_create(const char *jobcode, GList *images, struct dt_camera_t *camera, time_t time_override) { dt_job_t *job = dt_control_job_create(&dt_camera_import_job_run, "import selected images from camera"); if(!job) return NULL; dt_camera_import_t *params = dt_camera_import_alloc(); if(!params) { dt_control_job_dispose(job); return NULL; } dt_control_job_add_progress(job, _("import images from camera"), FALSE); dt_control_job_set_params(job, params, dt_camera_import_cleanup); /* intitialize import session for camera import job */ if(time_override != 0) dt_import_session_set_time(params->shared.session, time_override); dt_import_session_set_name(params->shared.session, jobcode); params->fraction = 0; params->images = g_list_copy(images); params->camera = camera; params->import_count = 0; params->job = job; return job; }
static void lua_job_cancelled(dt_progress_t *progress, gpointer user_data) { dt_job_t *job = dt_control_job_create(&lua_job_canceled_job, "lua: on background cancel"); if(!job) return; dt_control_job_set_params(job, progress); dt_control_add_job(darktable.control, DT_JOB_QUEUE_SYSTEM_BG, job); }
dt_job_t *dt_dev_process_image_job_create(dt_develop_t *dev) { dt_job_t *job = dt_control_job_create(&dt_dev_process_image_job_run, "develop process image"); if(!job) return NULL; dt_control_job_set_params(job, dev, NULL); return job; }
void dt_lua_init(lua_State*L,const char *lua_command) { /* Note to reviewers this is the only place where lua code is run without the lua lock. At this point, no user script has been called, so we are completely thread-safe. no need to lock This is also the only place where lua code is run with the gdk lock held, but this is not a problem because it is very brief, user calls are delegated to a secondary job */ char tmp_path[PATH_MAX]; // init the lua environment lua_CFunction* cur_type = init_funcs; while(*cur_type) { (*cur_type)(L); cur_type++; } // build the table containing the configuration info lua_getglobal(L,"package"); dt_lua_goto_subtable(L,"loaded"); lua_pushstring(L,"darktable"); dt_lua_push_darktable_lib(L); lua_settable(L,-3); lua_pop(L,1); lua_getglobal(L,"package"); lua_getfield(L,-1,"path"); lua_pushstring(L,";"); dt_loc_get_datadir(tmp_path, sizeof(tmp_path)); lua_pushstring(L,tmp_path); lua_pushstring(L,"/lua/?.lua"); lua_pushstring(L,";"); dt_loc_get_user_config_dir(tmp_path, sizeof(tmp_path)); lua_pushstring(L,tmp_path); lua_pushstring(L,"/lua/?.lua"); lua_concat(L,7); lua_setfield(L,-2,"path"); lua_pop(L,1); dt_job_t *job = dt_control_job_create(&run_early_script, "lua: run initial script"); dt_control_job_set_params(job, g_strdup(lua_command)); if(darktable.gui) { dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_BG, job); } else { run_early_script(job); dt_control_job_dispose(job); } }
static void free_params_wrapper(struct dt_imageio_module_storage_t *self, dt_imageio_module_data_t *data) { dt_job_t *job = dt_control_job_create(&free_param_wrapper_job, "lua: destroy storage param"); if(!job) return; free_param_wrapper_data *t = (free_param_wrapper_data *)calloc(1, sizeof(free_param_wrapper_data)); if(!t) { dt_control_job_dispose(job); return; } dt_control_job_set_params(job, t, free_param_wrapper_destroy); t->data = (lua_storage_t *)data; dt_control_add_job(darktable.control, DT_JOB_QUEUE_SYSTEM_BG, job); }
dt_job_t * dt_image_load_job_create(int32_t id, dt_mipmap_size_t mip) { dt_job_t *job = dt_control_job_create(&dt_image_load_job_run, "load image %d mip %d", id, mip); if(!job) return NULL; dt_image_load_t *params = (dt_image_load_t *)calloc(1, sizeof(dt_image_load_t)); if(!params) { dt_control_job_dispose(job); return NULL; } dt_control_job_set_params(job, params); params->imgid = id; params->mip = mip; return job; }
void dt_printers_discovery(void (*cb)(dt_printer_info_t *pr, void *user_data), void *user_data) { // asynchronously checks for available printers dt_job_t *job = dt_control_job_create(&_detect_printers_callback, "detect connected printers"); if(job) { dt_prtctl_t *prtctl = g_malloc0(sizeof(dt_prtctl_t)); prtctl->cb = cb; prtctl->user_data = user_data; dt_control_job_set_params(job, prtctl, g_free); dt_control_add_job(darktable.control, DT_JOB_QUEUE_SYSTEM_BG, job); } }
dt_job_t * dt_image_import_job_create(uint32_t filmid, const char *filename) { dt_image_import_t *params; dt_job_t *job = dt_control_job_create(&dt_image_import_job_run, "import image"); if(!job) return NULL; params = (dt_image_import_t *)calloc(1, sizeof(dt_image_import_t)); if(!params) { dt_control_job_dispose(job); return NULL; } dt_control_job_set_params(job, params); params->filename = g_strdup(filename); params->film_id = filmid; return job; }
static void on_image_imported(gpointer instance,uint32_t id, gpointer user_data){ dt_job_t *job = dt_control_job_create(&on_image_imported_callback_job, "lua: on image imported"); if(job) { on_image_imported_callback_data_t *t = (on_image_imported_callback_data_t*)calloc(1, sizeof(on_image_imported_callback_data_t)); if(!t) { dt_control_job_dispose(job); } else { dt_control_job_set_params(job, t); t->imgid = id; dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_FG, job); } } }
dt_job_t *dt_film_import1_create(dt_film_t *film) { dt_job_t *job = dt_control_job_create(&dt_film_import1_run, "cache load raw images for preview"); if(!job) return NULL; dt_film_import1_t *params = (dt_film_import1_t *)calloc(1, sizeof(dt_film_import1_t)); if(!params) { dt_control_job_dispose(job); return NULL; } dt_control_job_add_progress(job, _("import images"), FALSE); dt_control_job_set_params(job, params, dt_film_import1_cleanup); params->film = film; dt_pthread_mutex_lock(&film->images_mutex); film->ref++; dt_pthread_mutex_unlock(&film->images_mutex); return job; }
static void on_mouse_over_image_changed(gpointer instance, gpointer user_data) { dt_job_t *job = dt_control_job_create(&on_mouse_over_image_changed_callback_job, "lua: on mouse over image changed"); if(job) { on_mouse_over_image_changed_callback_data_t *t = (on_mouse_over_image_changed_callback_data_t *)calloc(1, sizeof(on_mouse_over_image_changed_callback_data_t)); if(!t) { dt_control_job_dispose(job); } else { dt_control_job_set_params(job, t); t->imgid = dt_control_get_mouse_over_id(); dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_FG, job); } } }
void dt_lua_do_chunk_later_internal(const char* function, int line,lua_State *L, int nargs) { #ifdef _DEBUG dt_print(DT_DEBUG_LUA,"LUA DEBUG : %s called from %s %d\n",__FUNCTION__,function,line); #endif lua_getfield(L, LUA_REGISTRYINDEX, "dt_lua_bg_threads"); lua_State *new_thread = lua_newthread(L); const int reference = luaL_ref(L,-2); lua_pop(L,1); lua_xmove(L,new_thread,nargs+1); dt_job_t *job = dt_control_job_create(&do_chunk_later_callback, "lua: later_chunk"); if(job) { dt_control_job_set_params(job, GINT_TO_POINTER(reference), NULL); dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_FG, job); } }
dt_job_t *dt_camera_get_previews_job_create(dt_camera_t *camera, dt_camctl_listener_t *listener, uint32_t flags, void *data) { dt_job_t *job = dt_control_job_create(&dt_camera_get_previews_job_run, "get camera previews job"); if(!job) return NULL; dt_camera_get_previews_t *params = dt_camera_get_previews_alloc(); if(!params) { dt_control_job_dispose(job); return NULL; } dt_control_job_set_params(job, params, dt_camera_get_previews_cleanup); memcpy(params->listener, listener, sizeof(dt_camctl_listener_t)); params->camera = camera; params->flags = flags; params->data = data; return job; }
static void on_view_changed(gpointer instance, dt_view_t *old_view, dt_view_t *new_view, gpointer user_data) { dt_job_t *job = dt_control_job_create(&view_changed_callback_job, "lua: on view changed"); if(job) { view_changed_callback_data_t *t = (view_changed_callback_data_t *)calloc(1, sizeof(view_changed_callback_data_t)); if(!t) { dt_control_job_dispose(job); } else { dt_control_job_set_params(job, t); t->old_view = old_view; t->new_view = new_view; dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_FG, job); } } }
dt_job_t * dt_camera_capture_job_create(const char *jobcode, uint32_t delay, uint32_t count, uint32_t brackets, uint32_t steps) { dt_job_t *job = dt_control_job_create(&dt_camera_capture_job_run, "remote capture of image(s)"); if(!job) return NULL; dt_camera_capture_t *params = (dt_camera_capture_t *)calloc(1, sizeof(dt_camera_capture_t)); if(!params) { dt_control_job_dispose(job); return NULL; } dt_control_job_set_params(job, params); params->shared.session = dt_import_session_new(); dt_import_session_set_name(params->shared.session, jobcode); params->delay=delay; params->count=count; params->brackets=brackets; params->steps=steps; return job; }
dt_job_t *dt_camera_capture_job_create(const char *jobcode, uint32_t delay, uint32_t count, uint32_t brackets, uint32_t steps) { dt_job_t *job = dt_control_job_create(&dt_camera_capture_job_run, "remote capture of image(s)"); if(!job) return NULL; dt_camera_capture_t *params = dt_camera_capture_alloc(); if(!params) { dt_control_job_dispose(job); return NULL; } dt_control_job_add_progress(job, _("capture images"), FALSE); dt_control_job_set_params(job, params, dt_camera_capture_cleanup); dt_import_session_set_name(params->shared.session, jobcode); params->delay = delay; params->count = count; params->brackets = brackets; params->steps = steps; return job; }
void dt_lua_widget_trigger_callback_async(lua_widget object,const char* name,const char* type_name,...) { dt_job_t *job = dt_control_job_create(&widget_callback_job, "lua: widget event"); if(job) { widget_callback_data*data = malloc(sizeof(widget_callback_data)); data->object = object; data->event_name = strdup(name); data->extra=NULL; va_list ap; va_start(ap,type_name); const char *cur_type = type_name; while(cur_type ){ data->extra=g_list_append(data->extra,GINT_TO_POINTER(cur_type)); data->extra=g_list_append(data->extra,va_arg(ap,gpointer)); cur_type = va_arg(ap,const char*); } va_end(ap); dt_control_job_set_params(job, data); dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_FG, job); } }
void dt_lua_do_chunk_async_internal(const char * call_function, int line, lua_CFunction pusher,dt_lua_async_call_arg_type arg_type,...) { #ifdef _DEBUG dt_print(DT_DEBUG_LUA,"LUA DEBUG : %s called from %s %d\n",__FUNCTION__,call_function,line); #endif dt_job_t *job = dt_control_job_create(&async_callback_job, "lua: async call"); if(job) { async_call_data*data = malloc(sizeof(async_call_data)); data->pusher = pusher; data->extra=NULL; va_list ap; va_start(ap,arg_type); dt_lua_async_call_arg_type cur_type = arg_type; while(cur_type != LUA_ASYNC_DONE){ data->extra=g_list_append(data->extra,GINT_TO_POINTER(cur_type)); switch(cur_type) { case LUA_ASYNC_TYPEID: data->extra=g_list_append(data->extra,GINT_TO_POINTER(va_arg(ap,luaA_Type))); data->extra=g_list_append(data->extra,va_arg(ap,gpointer)); break; case LUA_ASYNC_TYPEID_WITH_FREE: { data->extra=g_list_append(data->extra,GINT_TO_POINTER(va_arg(ap,luaA_Type))); data->extra=g_list_append(data->extra,va_arg(ap,gpointer)); GClosure* closure = va_arg(ap,GClosure*); g_closure_ref (closure); g_closure_sink (closure); g_closure_set_marshal(closure, g_cclosure_marshal_generic); data->extra=g_list_append(data->extra,closure); } break; case LUA_ASYNC_TYPENAME: data->extra=g_list_append(data->extra,va_arg(ap,char *)); data->extra=g_list_append(data->extra,va_arg(ap,gpointer)); break; case LUA_ASYNC_TYPENAME_WITH_FREE: { data->extra=g_list_append(data->extra,va_arg(ap,char *)); data->extra=g_list_append(data->extra,va_arg(ap,gpointer)); GClosure* closure = va_arg(ap,GClosure*); g_closure_ref (closure); g_closure_sink (closure); g_closure_set_marshal(closure, g_cclosure_marshal_generic); data->extra=g_list_append(data->extra,closure); } break; default: // should never happen g_assert(false); break; } cur_type = va_arg(ap,dt_lua_async_call_arg_type); } va_end(ap); dt_control_job_set_params(job, data, async_callback_job_destructor); dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_FG, job); } }