예제 #1
0
void dt_lua_init(lua_State*L,const int init_gui)
{
  char tmp_path[PATH_MAX];

  // init the lua environment
  lua_CFunction* cur_type = init_funcs;
  while(*cur_type)
  {
    (*cur_type)(L);
    cur_type++;
  }
  dt_lua_push_darktable_lib(L);
  // 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, PATH_MAX);
  lua_pushstring(L,tmp_path);
  lua_pushstring(L,"/lua/?.lua");
  lua_pushstring(L,";");
  dt_loc_get_user_config_dir(tmp_path, PATH_MAX);
  lua_pushstring(L,tmp_path);
  lua_pushstring(L,"/lua/?.lua");
  lua_concat(L,7);
  lua_setfield(L,-2,"path");
  lua_pop(L,1);



  if(init_gui)
  {
    // run global init script
    dt_loc_get_datadir(tmp_path, PATH_MAX);
    g_strlcat(tmp_path,"/rc.lua",PATH_MAX);
    dt_lua_dofile(darktable.lua_state,tmp_path);
    // run user init script
    dt_loc_get_user_config_dir(tmp_path, PATH_MAX);
    g_strlcat(tmp_path,"/rc.lua",PATH_MAX);
    dt_lua_dofile(darktable.lua_state,tmp_path);
  }

}
예제 #2
0
int dt_lua_init_database(lua_State *L)
{

  /* database type */
  dt_lua_push_darktable_lib(L);
  luaA_Type type_id = dt_lua_init_singleton(L, "image_database", NULL);
  lua_setfield(L, -2, "database");
  lua_pop(L, 1);

  lua_pushcfunction(L, database_len);
  lua_pushcfunction(L, database_numindex);
  dt_lua_type_register_number_const_type(L, type_id);
  lua_pushcfunction(L, dt_lua_duplicate_image);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "duplicate");
  lua_pushcfunction(L, dt_lua_delete_image);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "delete");
  lua_pushcfunction(L, import_images);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "import");
  lua_pushcfunction(L, dt_lua_move_image);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "move_image");
  lua_pushcfunction(L, dt_lua_copy_image);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "copy_image");

  /* database type */
  dt_lua_push_darktable_lib(L);
  type_id = dt_lua_init_singleton(L, "image_collection", NULL);
  lua_setfield(L, -2, "collection");
  lua_pop(L, 1);

  lua_pushcfunction(L, collection_len);
  lua_pushcfunction(L, collection_numindex);
  dt_lua_type_register_number_const_type(L, type_id);

  lua_pushcfunction(L, dt_lua_event_multiinstance_register);
  lua_pushcfunction(L, dt_lua_event_multiinstance_trigger);
  dt_lua_event_add(L, "post-import-film");
  dt_control_signal_connect(darktable.signals, DT_SIGNAL_FILMROLLS_IMPORTED, G_CALLBACK(on_film_imported),
                            NULL);

  lua_pushcfunction(L, dt_lua_event_multiinstance_register);
  lua_pushcfunction(L, dt_lua_event_multiinstance_trigger);
  dt_lua_event_add(L, "post-import-image");
  dt_control_signal_connect(darktable.signals, DT_SIGNAL_IMAGE_IMPORT, G_CALLBACK(on_image_imported), NULL);
  return 0;
}
예제 #3
0
파일: film.c 프로젝트: bartokk/darktable
int dt_lua_init_film(lua_State * L)
{

  dt_lua_init_int_type(L,dt_lua_film_t);
  dt_lua_register_type_callback_list(L,dt_lua_film_t,film_index,NULL,film_fields_name);
  dt_lua_register_type_callback_number(L,dt_lua_film_t,film_getnum,NULL,film_len);
  lua_pushcfunction(L,dt_lua_move_image);
  dt_lua_register_type_callback_stack(L,dt_lua_film_t,"move_image");
  lua_pushcfunction(L,dt_lua_copy_image);
  dt_lua_register_type_callback_stack(L,dt_lua_film_t,"copy_image");
  luaL_getmetatable(L,"dt_lua_film_t");
  lua_pushcfunction(L,film_tostring);
  lua_setfield(L,-2,"__tostring");
  lua_pop(L,1);

  /* film table */
  dt_lua_push_darktable_lib(L);
  luaA_Type type_id = dt_lua_init_singleton(L,"film_database",NULL);
  lua_setfield(L,-2,"films");
  lua_pop(L,1);

  dt_lua_register_type_callback_number_typeid(L,type_id,films_index,NULL,films_len);
  lua_pushcfunction(L,films_new);
  dt_lua_register_type_callback_stack_typeid(L,type_id,"new");
  lua_pushcfunction(L,film_delete);
  dt_lua_register_type_callback_stack_typeid(L,type_id,"delete");

  return 0;
}
예제 #4
0
int dt_lua_init_gui(lua_State * L)
{

    if(darktable.gui != NULL) {
        /* images */
        dt_lua_push_darktable_lib(L);
        luaA_Type type_id = dt_lua_init_singleton(L,"gui_lib",NULL);
        lua_setfield(L,-2,"gui");
        lua_pop(L,1);

        lua_pushcfunction(L,selection_cb);
        lua_pushcclosure(L,dt_lua_type_member_common,1);
        dt_lua_type_register_const_type(L,type_id,"selection");
        lua_pushcfunction(L,hovered_cb);
        dt_lua_type_register_const_type(L,type_id,"hovered");
        lua_pushcfunction(L,act_on_cb);
        dt_lua_type_register_const_type(L,type_id,"action_images");
        lua_pushcfunction(L,current_view_cb);
        lua_pushcclosure(L,dt_lua_type_member_common,1);
        dt_lua_type_register_const_type(L,type_id,"current_view");
        lua_pushcfunction(L, lua_create_job);
        lua_pushcclosure(L, dt_lua_type_member_common, 1);
        dt_lua_type_register_const_type(L, type_id, "create_job");



        // create a type describing a job object
        int job_type = dt_lua_init_gpointer_type(L, dt_lua_backgroundjob_t);
        lua_pushcfunction(L, lua_job_progress);
        dt_lua_type_register_type(L, job_type, "percent");
        lua_pushcfunction(L, lua_job_valid);
        dt_lua_type_register_type(L, job_type, "valid");
    }
    return 0;
}
예제 #5
0
파일: init.c 프로젝트: AlicVB/darktable
/*
   Note to proofreaders
   argv is a char*[]
   lua strings are const char*
   gtk takes argv and modifies it to remove gtk specific parts

   so we need to copy (strdup) parameters from lua
   but because gtk might do crazy stuff, we keep a copy of our original argv to be able to free() it
   */
static int load_from_lua(lua_State *L)
{
  if(darktable.lua_state.state)
  {
    luaL_error(L, "Attempt to load darktable multiple time.");
  }
  int argc = lua_gettop(L);

  char **argv = calloc(argc + 1, sizeof(char *));
  char **argv_copy = malloc((argc + 1) * sizeof(char *));
  argv[0] = strdup("lua");
  argv_copy[0] = argv[0];
  for(int i = 1; i < argc; i++)
  {
    argv[i] = strdup(luaL_checkstring(L, i + 1));
    argv_copy[i] = argv[i];
  }
  lua_pop(L, lua_gettop(L));
  argv[argc] = NULL;
  argv_copy[argc] = NULL;
  gtk_init(&argc, &argv);
  if(dt_init(argc, argv, FALSE, TRUE, L)) {
    luaL_error(L,"Starting darktable failed.");
  }
  for(int i = 0; i < argc; i++)
  {
    free(argv_copy[i]);
  }
  free(argv_copy);
  free(argv);
  dt_lua_push_darktable_lib(L);
  return 1;
}
예제 #6
0
파일: call.c 프로젝트: PkmX/darktable
int dt_lua_init_call(lua_State *L)
{

  dt_lua_push_darktable_lib(L);
  luaA_Type type_id = dt_lua_init_singleton(L, "control", NULL);
  lua_setfield(L, -2, "control");
  lua_pop(L, 1);
  
  lua_pushcfunction(L, ending_cb);
  dt_lua_type_register_const_type(L, type_id, "ending");
  lua_pushcfunction(L, dispatch_cb);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "dispatch");
  lua_pushcfunction(L,execute_cb);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "execute");
  lua_pushcfunction(L,sleep_cb);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "sleep");
  lua_pushcfunction(L,read_cb);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "read");

  lua_newtable(L);
  lua_setfield(L, LUA_REGISTRYINDEX, "dt_lua_bg_threads");
  // create stuff in init to avoid race conditions
  darktable.lua_state.context = g_main_context_new();
  stacked_job_init();
  alien_job_init();
  string_job_init();
  end_job_init();

  g_thread_new("lua thread",lua_thread_main,NULL);
  return 0;
}
예제 #7
0
파일: init.c 프로젝트: AlicVB/darktable
void dt_lua_init_early(lua_State *L)
{
  if(!L)
  {
    L = luaL_newstate();
  }
  darktable.lua_state.state = L;
  darktable.lua_state.ending = false;
  darktable.lua_state.loop = NULL;;
  darktable.lua_state.context = NULL;;
  darktable.lua_state.stacked_job_queue = NULL;;
  dt_lua_init_lock(); // lock is initialized in the locked state
  luaL_openlibs(darktable.lua_state.state);
  luaA_open(L);
  dt_lua_push_darktable_lib(L);
  // set the metatable
  lua_getmetatable(L, -1);
  lua_pushcfunction(L, dt_call_after_load);
  lua_setfield(L, -2, "__call");
  lua_pushcfunction(L, dt_luacleanup);
  lua_setfield(L, -2, "__gc");
  lua_pop(L, 1);

  lua_pop(L, 1);

  lua_CFunction *cur_type = early_init_funcs;
  while(*cur_type)
  {
    (*cur_type)(L);
    cur_type++;
  }
}
예제 #8
0
파일: init.c 프로젝트: grinoscar/darktable
// function used by the lua interpreter to load darktable
int luaopen_darktable(lua_State *L) {
  dt_lua_push_darktable_lib(L);
  lua_getmetatable(L,-1);
  lua_pushcfunction(L,load_from_lua);
  lua_setfield(L,-2,"__call");
  lua_pop(L,1);
  return 1;
}
예제 #9
0
파일: init.c 프로젝트: grinoscar/darktable
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);
  }

}
예제 #10
0
파일: tags.c 프로젝트: AlicVB/darktable
int dt_lua_init_tags(lua_State *L)
{
  dt_lua_init_int_type(L, dt_lua_tag_t);
  lua_pushcfunction(L, tag_length);
  lua_pushcfunction(L, tag_index);
  dt_lua_type_register_number_const(L, dt_lua_tag_t);
  lua_pushcfunction(L, tag_name);
  dt_lua_type_register_const(L, dt_lua_tag_t, "name");
  lua_pushcfunction(L, tag_delete);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const(L, dt_lua_tag_t, "delete");
  lua_pushcfunction(L, dt_lua_tag_attach);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const(L, dt_lua_tag_t, "attach");
  lua_pushcfunction(L, dt_lua_tag_detach);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const(L, dt_lua_tag_t, "detach");
  lua_pushcfunction(L, tag_tostring);
  dt_lua_type_setmetafield(L,dt_lua_tag_t,"__tostring");

  /* tags */
  dt_lua_push_darktable_lib(L);
  luaA_Type type_id = dt_lua_init_singleton(L, "tag_table", NULL);
  lua_setfield(L, -2, "tags");
  lua_pop(L, 1);

  lua_pushcfunction(L, tag_lib_length);
  lua_pushcfunction(L, tag_lib_index);
  dt_lua_type_register_number_const_type(L, type_id);
  lua_pushcfunction(L, tag_lib_create);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "create");
  lua_pushcfunction(L, tag_lib_find);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "find");
  lua_pushcfunction(L, tag_delete);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "delete");
  lua_pushcfunction(L, dt_lua_tag_attach);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "attach");
  lua_pushcfunction(L, dt_lua_tag_detach);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "detach");
  lua_pushcfunction(L, dt_lua_tag_get_attached);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "get_tags");
  lua_pushcfunction(L, dt_lua_tag_get_tagged_images);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "get_tagged_images");


  return 0;
}
예제 #11
0
int dt_lua_init_luastorages(lua_State *L)
{
  dt_lua_push_darktable_lib(L);
  lua_pushstring(L, "register_storage");
  lua_pushcfunction(L, &register_storage);
  lua_settable(L, -3);
  lua_pop(L, 1);

  lua_newtable(L);
  lua_setfield(L, LUA_REGISTRYINDEX, "dt_lua_storages");
  return 0;
}
예제 #12
0
파일: init.c 프로젝트: BloodyD/darktable
void dt_lua_init(lua_State *L, const char *lua_command)
{
  char tmp_path[PATH_MAX] = { 0 };
  // init the lua environment
  lua_CFunction *cur_type = init_funcs;
  while(*cur_type)
  {
    (*cur_type)(L);
    cur_type++;
  }
  assert(lua_gettop(L)
         == 0); // if you are here, you have probably added an initialisation function that is not stack clean

  // 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);



  lua_pushcfunction(L,run_early_script);
  lua_pushstring(L,lua_command);

  if(darktable.gui)
  {
    dt_lua_do_chunk_later(L,1);
  }
  else
  {
    dt_lua_do_chunk_silent(L,1,0);
  }
  // allow other threads to wake up and do their job
  dt_lua_unlock();
}
예제 #13
0
int dt_lua_init_gui(lua_State *L)
{

  if(darktable.gui != NULL)
  {
    /* images */
    dt_lua_push_darktable_lib(L);
    luaA_Type type_id = dt_lua_init_singleton(L, "gui_lib", NULL);
    lua_setfield(L, -2, "gui");
    lua_pop(L, 1);

    lua_pushcfunction(L, selection_cb);
    lua_pushcclosure(L,dt_lua_gtk_wrap,1);
    lua_pushcclosure(L, dt_lua_type_member_common, 1);
    dt_lua_type_register_const_type(L, type_id, "selection");
    lua_pushcfunction(L, hovered_cb);
    dt_lua_type_register_const_type(L, type_id, "hovered");
    lua_pushcfunction(L, act_on_cb);
    dt_lua_type_register_const_type(L, type_id, "action_images");
    lua_pushcfunction(L, current_view_cb);
    lua_pushcclosure(L, dt_lua_type_member_common, 1);
    dt_lua_type_register_const_type(L, type_id, "current_view");
    lua_pushcfunction(L, lua_create_job);
    lua_pushcclosure(L, dt_lua_type_member_common, 1);
    dt_lua_type_register_const_type(L, type_id, "create_job");
    dt_lua_module_push(L, "lib");
    lua_pushcclosure(L, dt_lua_type_member_common, 1);
    dt_lua_type_register_const_type(L, type_id, "libs");
    dt_lua_module_push(L, "view");
    lua_pushcclosure(L, dt_lua_type_member_common, 1);
    dt_lua_type_register_const_type(L, type_id, "views");



    // create a type describing a job object
    int job_type = dt_lua_init_gpointer_type(L, dt_lua_backgroundjob_t);
    lua_pushcfunction(L, lua_job_progress);
    dt_lua_type_register_type(L, job_type, "percent");
    lua_pushcfunction(L, lua_job_valid);
    dt_lua_type_register_type(L, job_type, "valid");

    // allow to react to highlighting an image
    lua_pushcfunction(L, dt_lua_event_multiinstance_register);
    lua_pushcfunction(L, dt_lua_event_multiinstance_trigger);
    dt_lua_event_add(L, "mouse-over-image-changed");
    dt_control_signal_connect(darktable.signals, DT_SIGNAL_MOUSE_OVER_IMAGE_CHANGE, G_CALLBACK(on_mouse_over_image_changed), NULL);
  }
  return 0;
}
예제 #14
0
int dt_lua_init_modules(lua_State *L)
{

  dt_lua_push_darktable_lib(L);
  dt_lua_goto_subtable(L,"modules");

  dt_lua_init_singleton(L,"format_table");
  lua_setfield(L,-2,"format");

  dt_lua_init_singleton(L,"module_table");
  lua_setfield(L,-2,"storage");

  lua_pop(L,1);

  return 0;
}
예제 #15
0
파일: widget.c 프로젝트: fhrtms/darktable
int dt_lua_init_widget(lua_State* L)
{

  lua_newtable(L);
  lua_setfield(L, LUA_REGISTRYINDEX,"dt_lua_widget_bind_table");

  dt_lua_module_new(L,"widget");

  widget_type.associated_type = dt_lua_init_gpointer_type(L,lua_widget);
  lua_pushcfunction(L,tooltip_member);
  dt_lua_gtk_wrap(L);
  dt_lua_type_register(L, lua_widget, "tooltip");
  lua_pushcfunction(L,widget_gc);
  dt_lua_gtk_wrap(L);
  dt_lua_type_setmetafield(L,lua_widget,"__gc");
  lua_pushcfunction(L,reset_member);
  dt_lua_type_register(L, lua_widget, "reset_callback");
  lua_pushcfunction(L,widget_call);
  dt_lua_type_setmetafield(L,lua_widget,"__call");
  lua_pushcfunction(L,sensitive_member);
  dt_lua_gtk_wrap(L);
  dt_lua_type_register(L, lua_widget, "sensitive");
  lua_pushcfunction(L, dt_lua_widget_tostring_member);
  dt_lua_gtk_wrap(L);
  dt_lua_type_setmetafield(L,lua_widget,"__tostring");

  dt_lua_init_widget_container(L);

  dt_lua_init_widget_box(L);
  dt_lua_init_widget_button(L);
  dt_lua_init_widget_check_button(L);
  dt_lua_init_widget_combobox(L);
  dt_lua_init_widget_label(L);
  dt_lua_init_widget_entry(L);
  dt_lua_init_widget_file_chooser_button(L);
  dt_lua_init_widget_separator(L);
  dt_lua_init_widget_slider(L);
  dt_lua_init_widget_stack(L);
  dt_lua_init_widget_text_view(L);

  dt_lua_push_darktable_lib(L);
  lua_pushstring(L, "new_widget");
  lua_pushcfunction(L, &new_widget);
  lua_settable(L, -3);
  lua_pop(L, 1);
  return 0;
}
예제 #16
0
int dt_lua_init_database(lua_State * L)
{

  /* database type */
  dt_lua_push_darktable_lib(L);
  luaA_Type type_id = dt_lua_init_singleton(L,"image_database");
  lua_setfield(L,-2,"database");
  lua_pop(L,1);

  dt_lua_register_type_callback_number_typeid(L,type_id,database_index,NULL,database_len);
  lua_pushcfunction(L,dt_lua_duplicate_image);
  dt_lua_register_type_callback_stack_typeid(L,type_id,"duplicate");
  lua_pushcfunction(L,import_images);
  dt_lua_register_type_callback_stack_typeid(L,type_id,"import");

  return 0;
}
예제 #17
0
int dt_lua_init_widget(lua_State* L)
{
  dt_lua_module_new(L,"widget");

  widget_type.associated_type = dt_lua_init_gpointer_type(L,lua_widget);
  lua_pushcfunction(L,tooltip_member);
  lua_pushcclosure(L,dt_lua_gtk_wrap,1);
  dt_lua_type_register(L, lua_widget, "tooltip");
  lua_pushcfunction(L,widget_gc);
  lua_pushcclosure(L,dt_lua_gtk_wrap,1);
  dt_lua_type_setmetafield(L,lua_widget,"__gc");
  lua_pushcfunction(L,reset_member);
  dt_lua_type_register(L, lua_widget, "reset_callback");
  lua_pushcfunction(L,widget_call);
  dt_lua_type_setmetafield(L,lua_widget,"__call");
  lua_pushcfunction(L,sensitive_member);
  lua_pushcclosure(L,dt_lua_gtk_wrap,1);
  dt_lua_type_register(L, lua_widget, "sensitive");
  
  dt_lua_init_widget_container(L);

  dt_lua_init_widget_box(L);
  dt_lua_init_widget_button(L);
  dt_lua_init_widget_check_button(L);
  dt_lua_init_widget_combobox(L);
  dt_lua_init_widget_label(L);
  dt_lua_init_widget_entry(L);
  dt_lua_init_widget_file_chooser_button(L);
  dt_lua_init_widget_separator(L);
  dt_lua_init_widget_slider(L);
  dt_lua_init_widget_stack(L);

  luaA_enum(L,dt_lua_orientation_t);
  luaA_enum_value_name(L,dt_lua_orientation_t,GTK_ORIENTATION_HORIZONTAL,"horizontal");
  luaA_enum_value_name(L,dt_lua_orientation_t,GTK_ORIENTATION_VERTICAL,"vertical");



  dt_lua_push_darktable_lib(L);
  lua_pushstring(L, "new_widget");
  lua_pushcfunction(L, &new_widget);
  lua_settable(L, -3);
  lua_pop(L, 1);
  return 0;
}
예제 #18
0
int dt_lua_init_preferences(lua_State * L)
{

  dt_lua_push_darktable_lib(L);
  dt_lua_goto_subtable(L,"preferences");

  lua_pushcfunction(L,register_pref);
  lua_setfield(L,-2,"register");

  lua_pushcfunction(L,read_pref);
  lua_setfield(L,-2,"read");

  lua_pushcfunction(L,write_pref);
  lua_setfield(L,-2,"write");

  lua_pop(L,1);
  return 0;
}
예제 #19
0
파일: database.c 프로젝트: ealasu/darktable
int dt_lua_init_database(lua_State * L)
{

    /* database type */
    dt_lua_init_type(L,dt_lua_database_t);
    dt_lua_register_type_callback_number(L,dt_lua_database_t,database_index,NULL,database_len);
    lua_pushcfunction(L,dt_lua_duplicate_image);
    dt_lua_register_type_callback_stack(L,dt_lua_database_t,"duplicate");
    lua_pushcfunction(L,import_images);
    dt_lua_register_type_callback_stack(L,dt_lua_database_t,"import");

    /* darktable.images() */
    dt_lua_push_darktable_lib(L);
    void * tmp= NULL;
    luaA_push(L,dt_lua_database_t,&tmp);
    lua_setfield(L,-2,"database");
    return 0;
}
예제 #20
0
파일: film.c 프로젝트: Coshibu/darktable
int dt_lua_init_film(lua_State * L)
{

  dt_lua_init_int_type(L,dt_lua_film_t);
  lua_pushcfunction(L,film_delete);
  lua_pushcclosure(L,dt_lua_type_member_common,1);
  dt_lua_type_register_const(L,dt_lua_film_t,"delete");
  lua_pushcfunction(L,path_member);
  dt_lua_type_register(L,dt_lua_film_t,"path");
  lua_pushcfunction(L,id_member);
  dt_lua_type_register(L,dt_lua_film_t,"id");

  lua_pushcfunction(L,film_len);
  lua_pushcfunction(L,film_getnum);
  dt_lua_type_register_number_const(L,dt_lua_film_t);
  lua_pushcfunction(L,dt_lua_move_image);
  lua_pushcclosure(L,dt_lua_type_member_common,1);
  dt_lua_type_register_const(L,dt_lua_film_t,"move_image");
  lua_pushcfunction(L,dt_lua_copy_image);
  lua_pushcclosure(L,dt_lua_type_member_common,1);
  dt_lua_type_register_const(L,dt_lua_film_t,"copy_image");
  luaL_getmetatable(L,"dt_lua_film_t");
  lua_pushcfunction(L,film_tostring);
  lua_setfield(L,-2,"__tostring");
  lua_pop(L,1);

  /* film table */
  dt_lua_push_darktable_lib(L);
  luaA_Type type_id = dt_lua_init_singleton(L,"film_database",NULL);
  lua_setfield(L,-2,"films");
  lua_pop(L,1);

  lua_pushcfunction(L,films_len);
  lua_pushcfunction(L,films_index);
  dt_lua_type_register_number_const_type(L,type_id);
  lua_pushcfunction(L,films_new);
  lua_pushcclosure(L,dt_lua_type_member_common,1);
  dt_lua_type_register_const_type(L,type_id,"new");
  lua_pushcfunction(L,film_delete);
  lua_pushcclosure(L,dt_lua_type_member_common,1);
  dt_lua_type_register_const_type(L,type_id,"delete");

  return 0;
}
예제 #21
0
void dt_lua_register_storage_typeid(lua_State* L, dt_imageio_module_storage_t* module, luaA_Type type_id)
{
  dt_lua_register_type_callback_list_typeid(L,type_id,storage_index,NULL,storage_fields_name);
  luaL_getmetatable(L,luaA_type_name(type_id));
  lua_pushlightuserdata(L,module);
  lua_setfield(L,-2,"__associated_object");
  lua_pushstring(L,"storage");
  lua_setfield(L,-2,"__module_type");
  lua_pop(L,1); // pop the metatable
  // add to the table
  dt_lua_push_darktable_lib(L);
  dt_lua_goto_subtable(L,"modules");
  dt_lua_goto_subtable(L,"storage");
  lua_getmetatable(L,-1);
  lua_getfield(L,-1,"__luaA_Type");
  luaA_Type storage_table_type = luaL_checkint(L,-1);
  dt_lua_register_type_callback_typeid(L,storage_table_type,get_storage_params,NULL,module->plugin_name,NULL);
  lua_pop(L,3);

};
예제 #22
0
int dt_lua_init_events(lua_State *L) {
  lua_newtable(L);
  lua_setfield(L,LUA_REGISTRYINDEX,"dt_lua_event_data");
  lua_newtable(L);
  event_handler * handler = event_list;
  while(handler->evt_name) {
    lua_pushlightuserdata(L,handler);
    lua_setfield(L,-2,handler->evt_name);
    handler++;
  }
  lua_setfield(L,LUA_REGISTRYINDEX,"dt_lua_event_list");
  dt_lua_push_darktable_lib(L);
  lua_pushstring(L,"register_event");
  lua_pushcfunction(L,&lua_register_event);
  lua_settable(L,-3);
  lua_pop(L,1);
  dt_control_signal_connect(darktable.signals,DT_SIGNAL_IMAGE_IMPORT,G_CALLBACK(on_image_imported),NULL);
  //dt_control_signal_connect(darktable.signals,DT_SIGNAL_IMAGE_EXPORT_MULTIPLE,G_CALLBACK(on_export_selection),NULL);
  dt_control_signal_connect(darktable.signals,DT_SIGNAL_IMAGE_EXPORT_TMPFILE,G_CALLBACK(on_export_image_tmpfile),NULL);
  return 0;
}
예제 #23
0
void dt_lua_init_early(lua_State*L)
{
  if(!L)
    L= luaL_newstate();
  darktable.lua_state= L;
  luaL_openlibs(darktable.lua_state);
  luaA_open();
  dt_lua_push_darktable_lib(L);
  // set the metatable
  lua_newtable(L);
  lua_pushcfunction(L,dt_luacleanup);
  lua_setfield(L,-2,"__gc");
  lua_setmetatable(L,-2);

  lua_pop(L,1);

  /* types need to be initialized early */
  dt_lua_initialize_types(L);
  /* modules need to be initialized before the are used */
  dt_lua_init_modules(L);

}
예제 #24
0
int dt_lua_init_configuration(lua_State*L){
  char tmp_path[PATH_MAX];

  dt_lua_push_darktable_lib(L);

  dt_lua_goto_subtable(L,"configuration");
  // build the table containing the configuration info 

  lua_pushstring(L,"tmp_dir");
  dt_loc_get_tmp_dir(tmp_path, PATH_MAX);
  lua_pushstring(L,tmp_path);
  lua_settable(L,-3);

  lua_pushstring(L,"config_dir");
  dt_loc_get_user_config_dir(tmp_path, PATH_MAX);
  lua_pushstring(L,tmp_path);
  lua_settable(L,-3);

  lua_pushstring(L,"cache_dir");
  dt_loc_get_user_cache_dir(tmp_path, PATH_MAX);
  lua_pushstring(L,tmp_path);
  lua_settable(L,-3);

  lua_pushstring(L,"version");
  lua_pushstring(darktable.lua_state,PACKAGE_VERSION);
  lua_settable(L,-3);

  lua_pushstring(L,"verbose");
  lua_pushboolean(L,darktable.unmuted & DT_DEBUG_LUA);
  lua_settable(L,-3);

  lua_pushstring(L,"has_gui");
  lua_pushboolean(L,darktable.gui != NULL);
  lua_settable(L,-3);

  lua_pop(L,-1); //remove the configuration table from the stack
  return 0;
  
}
예제 #25
0
파일: call.c 프로젝트: Nitrosito/darktable
int dt_lua_init_call(lua_State *L)
{
  luaA_enum(L, yield_type);
  luaA_enum_value(L, yield_type, WAIT_MS);
  luaA_enum_value(L, yield_type, FILE_READABLE);
  luaA_enum_value(L, yield_type, RUN_COMMAND);

  dt_lua_push_darktable_lib(L);
  luaA_Type type_id = dt_lua_init_singleton(L, "control", NULL);
  lua_setfield(L, -2, "control");
  lua_pop(L, 1);


  
  lua_pushcfunction(L, ending_cb);
  dt_lua_type_register_const_type(L, type_id, "ending");
  lua_pushcfunction(L, dispatch_cb);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "dispatch");
  lua_newtable(L);
  lua_setfield(L, LUA_REGISTRYINDEX, "dt_lua_bg_threads");
  return 0;
}
예제 #26
0
파일: gettext.c 프로젝트: AlicVB/darktable
int dt_lua_init_gettext(lua_State *L)
{
  
  dt_lua_push_darktable_lib(L);
  dt_lua_goto_subtable(L,"gettext");

  lua_pushcfunction(L,lua_gettext);
  lua_setfield(L,-2,"gettext");
  lua_pushcfunction(L,lua_dgettext);
  lua_setfield(L,-2,"dgettext");
  //lua_pushcfunction(L,lua_dcgettext);
  //lua_setfield(L,-2,"dcgettext");
  lua_pushcfunction(L,lua_ngettext);
  lua_setfield(L,-2,"ngettext");
  lua_pushcfunction(L,lua_dngettext);
  lua_setfield(L,-2,"dngettext");
  //lua_pushcfunction(L,lua_dcngettext);
  //lua_setfield(L,-2,"dcngettext");
  lua_pushcfunction(L,lua_bindtextdomain);
  lua_setfield(L,-2,"bindtextdomain");

  lua_pop(L,1);
  return 0;
}
예제 #27
0
int dt_lua_init_configuration(lua_State *L)
{
  char tmp_path[PATH_MAX] = { 0 };

  dt_lua_push_darktable_lib(L);

  dt_lua_goto_subtable(L, "configuration");
  // build the table containing the configuration info

  lua_pushstring(L, "tmp_dir");
  dt_loc_get_tmp_dir(tmp_path, sizeof(tmp_path));
  lua_pushstring(L, tmp_path);
  lua_settable(L, -3);

  lua_pushstring(L, "config_dir");
  dt_loc_get_user_config_dir(tmp_path, sizeof(tmp_path));
  lua_pushstring(L, tmp_path);
  lua_settable(L, -3);

  lua_pushstring(L, "cache_dir");
  dt_loc_get_user_cache_dir(tmp_path, sizeof(tmp_path));
  lua_pushstring(L, tmp_path);
  lua_settable(L, -3);

  lua_pushstring(L, "version");
  lua_pushstring(L, darktable_package_version);
  lua_settable(L, -3);

  lua_pushstring(L, "verbose");
  lua_pushboolean(L, darktable.unmuted & DT_DEBUG_LUA);
  lua_settable(L, -3);

  lua_pushstring(L, "has_gui");
  lua_pushboolean(L, darktable.gui != NULL);
  lua_settable(L, -3);

  lua_pushstring(L, "api_version_major");
  lua_pushinteger(L, LUA_API_VERSION_MAJOR);
  lua_settable(L, -3);

  lua_pushstring(L, "api_version_minor");
  lua_pushinteger(L, LUA_API_VERSION_MINOR);
  lua_settable(L, -3);

  lua_pushstring(L, "api_version_patch");
  lua_pushinteger(L, LUA_API_VERSION_PATCH);
  lua_settable(L, -3);

  lua_pushstring(L, "api_version_suffix");
  lua_pushstring(L, LUA_API_VERSION_SUFFIX);
  lua_settable(L, -3);

  lua_pushstring(L, "api_version_string");
  if(LUA_API_VERSION_SUFFIX[0] == '\0')
  {
    lua_pushfstring(L, "%d.%d.%d", LUA_API_VERSION_MAJOR, LUA_API_VERSION_MINOR, LUA_API_VERSION_PATCH);
  }
  else
  {
    lua_pushfstring(L, "%d.%d.%d-%s", LUA_API_VERSION_MAJOR, LUA_API_VERSION_MINOR, LUA_API_VERSION_PATCH,
                    LUA_API_VERSION_SUFFIX);
  }
  lua_settable(L, -3);

  lua_pushstring(L, "check_version");
  lua_pushcfunction(L, check_version);
  lua_settable(L, -3);

  luaA_enum(L, lua_os_type);
  luaA_enum_value_name(L, lua_os_type, os_windows, "windows");
  luaA_enum_value_name(L, lua_os_type, os_macos, "macos");
  luaA_enum_value_name(L, lua_os_type, os_linux, "linux");
  luaA_enum_value_name(L, lua_os_type, os_unix, "unix");
  lua_pushstring(L, "running_os");
  luaA_push(L, lua_os_type, &cur_os);
  lua_settable(L, -3);

  lua_pop(L, 1); // remove the configuration table from the stack
  return 0;
}
예제 #28
0
파일: styles.c 프로젝트: AlicVB/darktable
int dt_lua_init_styles(lua_State *L)
{
  // dt_style
  dt_lua_init_type(L, dt_style_t);
  lua_pushcfunction(L, name_member);
  dt_lua_type_register_const(L, dt_style_t, "name");
  lua_pushcfunction(L, description_member);
  dt_lua_type_register_const(L, dt_style_t, "description");
  lua_pushcfunction(L, style_length);
  lua_pushcfunction(L, style_getnumber);
  dt_lua_type_register_number_const(L, dt_style_t);
  lua_pushcfunction(L, style_duplicate);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const(L, dt_style_t, "duplicate");
  lua_pushcfunction(L, style_delete);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const(L, dt_style_t, "delete");
  lua_pushcfunction(L, dt_lua_style_apply);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const(L, dt_style_t, "apply");
  lua_pushcfunction(L, dt_lua_style_export);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const(L, dt_style_t, "export");
  lua_pushcfunction(L, style_gc);
  dt_lua_type_setmetafield(L,dt_style_t,"__gc");
  lua_pushcfunction(L, style_tostring);
  dt_lua_type_setmetafield(L,dt_style_t,"__tostring");

  // dt_style_item_t
  dt_lua_init_type(L, dt_style_item_t);
  luaA_struct(L, dt_style_item_t);
  luaA_struct_member(L, dt_style_item_t, num, const int);
  luaA_struct_member(L, dt_style_item_t, name, const_string);
  lua_pushcfunction(L, dt_lua_type_member_luaautoc);
  dt_lua_type_register_struct(L, dt_style_item_t);
  lua_pushcfunction(L, style_item_gc);
  dt_lua_type_setmetafield(L,dt_style_item_t,"__gc");
  lua_pushcfunction(L, style_item_tostring);
  dt_lua_type_setmetafield(L,dt_style_item_t,"__tostring");



  /* style table type */
  dt_lua_push_darktable_lib(L);
  luaA_Type type_id = dt_lua_init_singleton(L, "style_table", NULL);
  lua_setfield(L, -2, "styles");
  lua_pop(L, 1);

  lua_pushcfunction(L, style_table_len);
  lua_pushcfunction(L, style_table_index);
  dt_lua_type_register_number_const_type(L, type_id);
  lua_pushcfunction(L, style_duplicate);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "duplicate");
  lua_pushcfunction(L, style_delete);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "delete");
  lua_pushcfunction(L, dt_lua_style_create_from_image);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "create");
  lua_pushcfunction(L, dt_lua_style_apply);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "apply");
  lua_pushcfunction(L, dt_lua_style_import);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "import");
  lua_pushcfunction(L, dt_lua_style_export);
  lua_pushcclosure(L, dt_lua_type_member_common, 1);
  dt_lua_type_register_const_type(L, type_id, "export");

  return 0;
}
예제 #29
0
int dt_lua_init_configuration(lua_State*L)
{
  char tmp_path[PATH_MAX];

  dt_lua_push_darktable_lib(L);

  dt_lua_goto_subtable(L,"configuration");
  // build the table containing the configuration info

  lua_pushstring(L,"tmp_dir");
  dt_loc_get_tmp_dir(tmp_path, PATH_MAX);
  lua_pushstring(L,tmp_path);
  lua_settable(L,-3);

  lua_pushstring(L,"config_dir");
  dt_loc_get_user_config_dir(tmp_path, PATH_MAX);
  lua_pushstring(L,tmp_path);
  lua_settable(L,-3);

  lua_pushstring(L,"cache_dir");
  dt_loc_get_user_cache_dir(tmp_path, PATH_MAX);
  lua_pushstring(L,tmp_path);
  lua_settable(L,-3);

  lua_pushstring(L,"version");
  lua_pushstring(L,PACKAGE_VERSION);
  lua_settable(L,-3);

  lua_pushstring(L,"verbose");
  lua_pushboolean(L,darktable.unmuted & DT_DEBUG_LUA);
  lua_settable(L,-3);

  lua_pushstring(L,"has_gui");
  lua_pushboolean(L,darktable.gui != NULL);
  lua_settable(L,-3);

  lua_pushstring(L,"api_version_major");
  lua_pushnumber(L,API_VERSION_MAJOR);
  lua_settable(L,-3);

  lua_pushstring(L,"api_version_minor");
  lua_pushnumber(L,API_VERSION_MINOR);
  lua_settable(L,-3);

  lua_pushstring(L,"api_version_patch");
  lua_pushnumber(L,API_VERSION_PATCH);
  lua_settable(L,-3);

  lua_pushstring(L,"api_version_suffix");
  lua_pushstring(L,API_VERSION_SUFFIX);
  lua_settable(L,-3);

  lua_pushstring(L,"api_version_string");
  if (strcmp(API_VERSION_SUFFIX, "") == 0) {
    lua_pushfstring(L,"%d.%d.%d",API_VERSION_MAJOR,API_VERSION_MINOR,API_VERSION_PATCH);
  } else {
    lua_pushfstring(L,"%d.%d.%d-%s",API_VERSION_MAJOR,API_VERSION_MINOR,API_VERSION_PATCH,API_VERSION_SUFFIX);
  }
  lua_settable(L,-3);

  lua_pop(L,1); //remove the configuration table from the stack
  return 0;

}