Example #1
0
static int lua_job_progress(lua_State *L)
{
    dt_progress_t *progress;
    luaA_to(L, dt_lua_backgroundjob_t, &progress, 1);
    dt_lua_unlock(false);
    gboolean i_own_lock = dt_control_gdk_lock();
    dt_pthread_mutex_lock(&darktable.control->progress_system.mutex);
    GList *iter = g_list_find(darktable.control->progress_system.list, progress);
    dt_pthread_mutex_unlock(&darktable.control->progress_system.mutex);
    if(i_own_lock) dt_control_gdk_unlock();
    dt_lua_lock();
    if(!iter) luaL_error(L,"Accessing an invalid job");
    if(lua_isnone(L, 3))
    {
        dt_lua_unlock(false);
        double result = dt_control_progress_get_progress(progress);
        dt_lua_lock();
        if(!dt_control_progress_has_progress_bar(progress))
            lua_pushnil(L);
        else
            lua_pushnumber(L, result);
        return 1;
    }
    else
    {
        double value;
        luaA_to(L,progress_double,&value,3);
        dt_lua_unlock(false);
        dt_control_progress_set_progress(darktable.control, progress, value);
        dt_lua_lock();
        return 0;
    }
}
Example #2
0
double dt_control_job_get_progress(dt_job_t *job)
{
  if(!job || !job->progress) return -1.0;
  return dt_control_progress_get_progress(job->progress);
}