int dt_lua_init_widget_combobox(lua_State* L) { dt_lua_init_widget_type(L,&combobox_type,lua_combobox,DT_BAUHAUS_WIDGET_TYPE); lua_pushcfunction(L, tostring_member); dt_lua_gtk_wrap(L); dt_lua_type_setmetafield(L, lua_combobox, "__tostring"); lua_pushcfunction(L,combobox_len); dt_lua_gtk_wrap(L); lua_pushcfunction(L,combobox_numindex); dt_lua_gtk_wrap(L); dt_lua_type_register_number(L,lua_combobox); lua_pushcfunction(L,value_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_combobox, "value"); lua_pushcfunction(L,selected_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_combobox, "selected"); dt_lua_widget_register_gtk_callback(L,lua_combobox,"value-changed","changed_callback",G_CALLBACK(changed_callback)); lua_pushcfunction(L,label_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_combobox, "label"); lua_pushcfunction(L,editable_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_combobox, "editable"); return 0; }
int dt_lua_init_widget_entry(lua_State* L) { dt_lua_init_widget_type(L,&entry_type,lua_entry,GTK_TYPE_ENTRY); lua_pushcfunction(L, tostring_member); dt_lua_gtk_wrap(L); dt_lua_type_setmetafield(L, lua_entry, "__tostring"); lua_pushcfunction(L,text_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_entry, "text"); lua_pushcfunction(L,is_password_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_entry, "is_password"); lua_pushcfunction(L,placeholder_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_entry, "placeholder"); lua_pushcfunction(L,editable_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_entry, "editable"); return 0; }
int dt_lua_init_widget_slider(lua_State* L) { dt_lua_init_widget_type(L,&slider_type,lua_slider,DT_BAUHAUS_WIDGET_TYPE); lua_pushcfunction(L, tostring_member); dt_lua_gtk_wrap(L); dt_lua_type_setmetafield(L, lua_slider, "__tostring"); lua_pushcfunction(L,digits_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_slider, "digits"); lua_pushcfunction(L,step_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_slider, "step"); lua_pushcfunction(L,hard_min_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_slider, "hard_min"); lua_pushcfunction(L,hard_max_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_slider, "hard_max"); lua_pushcfunction(L,soft_min_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_slider, "soft_min"); lua_pushcfunction(L,soft_max_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_slider, "soft_max"); lua_pushcfunction(L,value_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_slider, "value"); lua_pushcfunction(L,label_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_slider, "label"); return 0; }
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; }
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; }
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_widget_button(lua_State* L) { dt_lua_init_widget_type(L,&button_type,lua_button,GTK_TYPE_BUTTON); lua_pushcfunction(L, tostring_member); dt_lua_gtk_wrap(L); dt_lua_type_setmetafield(L, lua_button, "__tostring"); lua_pushcfunction(L,label_member); dt_lua_gtk_wrap(L); dt_lua_type_register(L, lua_button, "label"); dt_lua_widget_register_gtk_callback(L,lua_button,"clicked","clicked_callback",G_CALLBACK(clicked_callback)); 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_widget_label(lua_State* L) { dt_lua_init_widget_type(L,&label_type,lua_label,GTK_TYPE_LABEL); lua_pushcfunction(L, tostring_member); lua_pushcclosure(L, dt_lua_gtk_wrap, 1); dt_lua_type_setmetafield(L, lua_label, "__tostring"); lua_pushcfunction(L,label_member); lua_pushcclosure(L,dt_lua_gtk_wrap,1); dt_lua_type_register(L, lua_label, "label"); lua_pushcfunction(L,selectable_member); lua_pushcclosure(L,dt_lua_gtk_wrap,1); dt_lua_type_register(L, lua_label, "selectable"); lua_pushcfunction(L, halign_member); lua_pushcclosure(L, dt_lua_gtk_wrap, 1); dt_lua_type_register(L, lua_label, "halign"); lua_pushcfunction(L,ellipsize_member); lua_pushcclosure(L,dt_lua_gtk_wrap,1); dt_lua_type_register(L, lua_label, "ellipsize"); return 0; }
int dt_lua_init_image(lua_State *L) { luaA_struct(L, dt_image_t); luaA_struct_member(L, dt_image_t, exif_exposure, float); luaA_struct_member(L, dt_image_t, exif_aperture, float); luaA_struct_member(L, dt_image_t, exif_iso, float); luaA_struct_member(L, dt_image_t, exif_focal_length, float); luaA_struct_member(L, dt_image_t, exif_focus_distance, float); luaA_struct_member(L, dt_image_t, exif_crop, float); luaA_struct_member(L, dt_image_t, exif_maker, char_64); luaA_struct_member(L, dt_image_t, exif_model, char_64); luaA_struct_member(L, dt_image_t, exif_lens, char_128); luaA_struct_member(L, dt_image_t, exif_datetime_taken, char_20); luaA_struct_member(L, dt_image_t, filename, const char_filename_length); luaA_struct_member(L, dt_image_t, width, const int32_t); luaA_struct_member(L, dt_image_t, height, const int32_t); luaA_struct_member(L, dt_image_t, longitude, protected_double); // set to NAN if value is not set luaA_struct_member(L, dt_image_t, latitude, protected_double); // set to NAN if value is not set luaA_struct_member(L, dt_image_t, elevation, protected_double); // set to NAN if value is not set dt_lua_init_int_type(L, dt_lua_image_t); const char *member_name = luaA_struct_next_member_name(L, dt_image_t, LUAA_INVALID_MEMBER_NAME); while(member_name != LUAA_INVALID_MEMBER_NAME) { lua_pushcfunction(L, image_luaautoc_member); luaA_Type member_type = luaA_struct_typeof_member_name(L, dt_image_t, 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(L, dt_lua_image_t, member_name); } else { dt_lua_type_register_const(L, dt_lua_image_t, member_name); } member_name = luaA_struct_next_member_name(L, dt_image_t, member_name); } // read only members lua_pushcfunction(L, path_member); dt_lua_type_register_const(L, dt_lua_image_t, "path"); lua_pushcfunction(L, sidecar_member); dt_lua_type_register_const(L, dt_lua_image_t, "sidecar"); lua_pushcfunction(L, duplicate_index_member); dt_lua_type_register_const(L, dt_lua_image_t, "duplicate_index"); lua_pushcfunction(L, is_ldr_member); dt_lua_type_register_const(L, dt_lua_image_t, "is_ldr"); lua_pushcfunction(L, is_hdr_member); dt_lua_type_register_const(L, dt_lua_image_t, "is_hdr"); lua_pushcfunction(L, is_raw_member); dt_lua_type_register_const(L, dt_lua_image_t, "is_raw"); lua_pushcfunction(L, id_member); dt_lua_type_register_const(L, dt_lua_image_t, "id"); lua_pushcfunction(L, film_member); dt_lua_type_register_const(L, dt_lua_image_t, "film"); lua_pushcfunction(L, group_leader_member); dt_lua_type_register_const(L, dt_lua_image_t, "group_leader"); // read/write functions lua_pushcfunction(L, has_txt_member); dt_lua_type_register(L, dt_lua_image_t, "has_txt"); lua_pushcfunction(L, rating_member); dt_lua_type_register(L, dt_lua_image_t, "rating"); lua_pushcfunction(L, creator_member); dt_lua_type_register(L, dt_lua_image_t, "creator"); lua_pushcfunction(L, publisher_member); dt_lua_type_register(L, dt_lua_image_t, "publisher"); lua_pushcfunction(L, title_member); dt_lua_type_register(L, dt_lua_image_t, "title"); lua_pushcfunction(L, description_member); dt_lua_type_register(L, dt_lua_image_t, "description"); lua_pushcfunction(L, rights_member); dt_lua_type_register(L, dt_lua_image_t, "rights"); lua_pushcfunction(L, local_copy_member); dt_lua_type_register(L, dt_lua_image_t, "local_copy"); const char **name = dt_colorlabels_name; while(*name) { lua_pushcfunction(L, colorlabel_member); dt_lua_type_register(L, dt_lua_image_t, *name); name++; } // constant functions (i.e class methods) lua_pushcfunction(L, dt_lua_duplicate_image); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "duplicate"); lua_pushcfunction(L, dt_lua_delete_image); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "delete"); lua_pushcfunction(L, group_with); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "group_with"); lua_pushcfunction(L, make_group_leader); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "make_group_leader"); lua_pushcfunction(L, get_group); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "get_group_members"); lua_pushcfunction(L, dt_lua_tag_attach); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "attach_tag"); lua_pushcfunction(L, dt_lua_tag_detach); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "detach_tag"); lua_pushcfunction(L, dt_lua_tag_get_attached); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "get_tags"); lua_pushcfunction(L, dt_lua_style_apply); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "apply_style"); lua_pushcfunction(L, dt_lua_style_create_from_image); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "create_style"); lua_pushcfunction(L, history_delete); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "reset"); lua_pushcfunction(L, dt_lua_move_image); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "move"); lua_pushcfunction(L, dt_lua_copy_image); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "copy"); lua_pushcfunction(L, drop_cache); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const(L, dt_lua_image_t, "drop_cache"); lua_pushcfunction(L, image_tostring); dt_lua_type_setmetafield(L,dt_lua_image_t,"__tostring"); return 0; }
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; }