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_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_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"); }
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, grouping_member); lua_pushcclosure(L,dt_lua_gtk_wrap,1); dt_lua_type_register_type(L, my_type, "grouping"); lua_pushcfunction(L, show_overlays_member); lua_pushcclosure(L,dt_lua_gtk_wrap,1); dt_lua_type_register_type(L, my_type, "show_overlays"); lua_pushcfunction(L, dt_lua_event_multiinstance_register); lua_pushcfunction(L, dt_lua_event_multiinstance_trigger); dt_lua_event_add(L, "global_toolbox-grouping_toggle"); lua_pushcfunction(L, dt_lua_event_multiinstance_register); lua_pushcfunction(L, dt_lua_event_multiinstance_trigger); dt_lua_event_add(L, "global_toolbox-overlay_toggle"); }
void dt_lua_widget_register_gtk_callback_type(lua_State *L,luaA_Type type_id,const char* signal_name, const char* lua_name,GCallback callback) { lua_pushstring(L,signal_name); lua_pushcclosure(L,gtk_signal_member,1); dt_lua_type_register_type(L, type_id, lua_name); luaL_newmetatable(L, luaA_typename(L, type_id)); lua_getfield(L,-1,"__gtk_signals"); lua_pushlightuserdata(L,callback); lua_setfield(L,-2,signal_name); 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); }