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; }
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; }
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; }
void init(struct dt_lib_module_t *self) { lua_State *L = darktable.lua_state.state; int my_type = dt_lua_module_entry_get_type(L, "lib", self->plugin_name); lua_pushcfunction(L, direction_member); dt_lua_type_register_type(L, my_type, "direction"); lua_pushcfunction(L, ratio_member); dt_lua_type_register_type(L, my_type, "ratio"); lua_pushcfunction(L, max_snapshot_member); dt_lua_type_register_const_type(L, my_type, "max_snapshot"); lua_pushlightuserdata(L, self); lua_pushcclosure(L, lua_take_snapshot, 1); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, my_type, "take_snapshot"); lua_pushcfunction(L, snapshots_length); lua_pushcfunction(L, number_member); dt_lua_type_register_number_const_type(L, my_type); lua_pushcfunction(L, selected_member); dt_lua_gtk_wrap(L); dt_lua_type_register_const_type(L, my_type, "selected"); dt_lua_init_int_type(L, dt_lua_snapshot_t); lua_pushlightuserdata(L, self); lua_pushcclosure(L, filename_member, 1); dt_lua_type_register_const(L, dt_lua_snapshot_t, "filename"); lua_pushlightuserdata(L, self); lua_pushcclosure(L, name_member, 1); dt_lua_gtk_wrap(L); dt_lua_type_register_const(L, dt_lua_snapshot_t, "name"); lua_pushlightuserdata(L, self); lua_pushcclosure(L, lua_select, 1); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_snapshot_t, "select"); lua_pushlightuserdata(L, self); lua_pushcclosure(L, name_member, 1); dt_lua_gtk_wrap(L); dt_lua_type_setmetafield(L,dt_lua_snapshot_t,"__tostring"); luaA_enum(L, snapshot_direction_t); luaA_enum_value_name(L, snapshot_direction_t, SNS_LEFT, "left"); luaA_enum_value_name(L, snapshot_direction_t, SNS_RIGHT, "right"); luaA_enum_value_name(L, snapshot_direction_t, SNS_TOP, "top"); luaA_enum_value_name(L, snapshot_direction_t, SNS_BOTTOM, "bottom"); }
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; }
void init(dt_lib_module_t *self) { lua_State *L = darktable.lua_state.state; int my_type = dt_lua_module_entry_get_type(L, "lib", self->plugin_name); lua_pushlightuserdata(L,self); lua_pushcclosure(L, lua_register_widget,1); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, my_type, "register_widget"); }
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; }
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; }
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; }
void init(struct dt_lib_module_t *self) { lua_State *L = darktable.lua_state.state; int my_type = dt_lua_module_entry_get_type(L, "lib", self->plugin_name); lua_pushlightuserdata(L, self); lua_pushcclosure(L, lua_register_selection ,1); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, my_type, "register_selection"); dt_lua_module_entry_push(L,"lib",self->plugin_name); lua_getuservalue(L,-1); lua_newtable(L); lua_setfield(L,-2,"callbacks"); lua_pop(L,2); }
void dt_lua_type_register_struct_type(lua_State *L, luaA_Type type_id) { const char *member_name = luaA_struct_next_member_name_type(L, type_id, LUAA_INVALID_MEMBER_NAME); while(member_name != LUAA_INVALID_MEMBER_NAME) { lua_pushvalue(L, -1); luaA_Type member_type = luaA_struct_typeof_member_name_type(L, type_id, member_name); if(luaA_conversion_to_registered_type(L, member_type) || luaA_struct_registered_type(L, member_type) || luaA_enum_registered_type(L, member_type)) { dt_lua_type_register_type(L, type_id, member_name); } else { dt_lua_type_register_const_type(L, type_id, member_name); } member_name = luaA_struct_next_member_name_type(L, type_id, member_name); } lua_pop(L, 1); }
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; }
int dt_lua_init_cairo(lua_State *L) { int cairo_type = dt_lua_init_gpointer_type(L, dt_lua_cairo_t); lua_pushcfunction(L, _draw_line); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "draw_line"); lua_pushcfunction(L, _save); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "save"); lua_pushcfunction(L, _restore); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "restore"); lua_pushcfunction(L, _new_sub_path); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "new_sub_path"); lua_pushcfunction(L, _scale); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "scale"); lua_pushcfunction(L, _translate); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "translate"); lua_pushcfunction(L, _rotate); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "rotate"); lua_pushcfunction(L, _move_to); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "move_to"); lua_pushcfunction(L, _line_to); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "line_to"); lua_pushcfunction(L, _arc); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "arc"); lua_pushcfunction(L, _arc_negative); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "arc_negative"); lua_pushcfunction(L, _rectangle); dt_lua_gtk_wrap(L); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, cairo_type, "rectangle"); return 0; }