static void export_button_clicked (GtkWidget *widget, gpointer user_data) { char style[128]; // Let's get the max dimension restriction if any... // TODO: pass the relevant values directly, not using the conf ... int max_width = dt_conf_get_int ("plugins/lighttable/export/width"); int max_height = dt_conf_get_int ("plugins/lighttable/export/height"); char *format_name = dt_conf_get_string("plugins/lighttable/export/format_name"); char *storage_name = dt_conf_get_string("plugins/lighttable/export/storage_name"); int format_index = dt_imageio_get_index_of_format(dt_imageio_get_format_by_name(format_name)); int storage_index = dt_imageio_get_index_of_storage(dt_imageio_get_storage_by_name(storage_name)); g_free(format_name); g_free(storage_name); gboolean high_quality = dt_conf_get_bool("plugins/lighttable/export/high_quality_processing"); char* tmp = dt_conf_get_string("plugins/lighttable/export/style"); if (tmp) { g_strlcpy(style, tmp, sizeof(style)); g_free(tmp); } int imgid = dt_view_get_image_to_act_on(); GList *list = NULL; if (imgid != -1) list = g_list_append (list, GINT_TO_POINTER(imgid)); else list = dt_collection_get_selected(darktable.collection, -1); dt_control_export(list, max_width, max_height, format_index, storage_index, high_quality,style); }
void gui_reset (dt_lib_module_t *self) { // make sure we don't do anything useless: if(!dt_control_running()) return; dt_lib_export_t *d = (dt_lib_export_t *)self->data; gtk_spin_button_set_value(d->width, dt_conf_get_int("plugins/lighttable/export/width")); gtk_spin_button_set_value(d->height, dt_conf_get_int("plugins/lighttable/export/height")); // Set storage gchar *storage_name = dt_conf_get_string("plugins/lighttable/export/storage_name"); int storage_index = dt_imageio_get_index_of_storage(dt_imageio_get_storage_by_name(storage_name)); g_free(storage_name); gtk_combo_box_set_active(d->storage, storage_index); gtk_combo_box_set_active(d->intent, (int)dt_conf_get_int("plugins/lighttable/export/iccintent") + 1); // iccprofile int iccfound = 0; gchar *iccprofile = dt_conf_get_string("plugins/lighttable/export/iccprofile"); if(iccprofile) { GList *prof = d->profiles; while(prof) { dt_lib_export_profile_t *pp = (dt_lib_export_profile_t *)prof->data; if(!strcmp(pp->filename, iccprofile)) { gtk_combo_box_set_active(d->profile, pp->pos); iccfound = 1; } if(iccfound) break; prof = g_list_next(prof); } g_free(iccprofile); } // style // set it to none if the var is not set or the style doesn't exist anymore gboolean rc = FALSE; gchar *style = dt_conf_get_string("plugins/lighttable/export/style"); if (style != NULL) { rc = _combo_box_set_active_text(d->style, style); if (rc == FALSE) gtk_combo_box_set_active(d->style, 0); g_free(style); } else gtk_combo_box_set_active(d->style, 0); if(!iccfound) gtk_combo_box_set_active(d->profile, 0); dt_imageio_module_format_t *mformat = dt_imageio_get_format(); if(mformat) mformat->gui_reset(mformat); dt_imageio_module_storage_t *mstorage = dt_imageio_get_storage(); if(mstorage) mstorage->gui_reset(mstorage); }
static void on_storage_list_changed(gpointer instance,dt_lib_module_t *self) { dt_lib_export_t *d = self->data; dt_imageio_module_storage_t *storage = dt_imageio_get_storage(); GtkTreeModel *store = gtk_combo_box_get_model( d->storage ); gtk_list_store_clear( GTK_LIST_STORE( store ) ); GList *it = darktable.imageio->plugins_storage; while(it) { dt_imageio_module_storage_t *module = (dt_imageio_module_storage_t *)it->data; gtk_combo_box_append_text(d->storage, module->name(module)); it = g_list_next(it); } gtk_combo_box_set_active(d->storage,dt_imageio_get_index_of_storage(storage)); }
static void on_export_selection(gpointer instance,dt_control_image_enumerator_t * export_descriptor, gpointer user_data){ lua_State* L = darktable.lua_state; dt_control_export_t *export_data= (dt_control_export_t*)export_descriptor->data; dt_imageio_module_storage_t *mstorage = dt_imageio_get_storage_by_index(export_data->storage_index); g_assert(mstorage); dt_imageio_module_data_t *fdata = mstorage->get_params(mstorage); luaA_push_typeid(L,mstorage->parameter_lua_type,fdata); mstorage->free_params(mstorage,fdata); dt_imageio_module_format_t *mformat = dt_imageio_get_format_by_index(export_data->format_index); g_assert(mformat); fdata = mformat->get_params(mformat); luaA_push_typeid(L,mformat->parameter_lua_type,fdata); mformat->free_params(mformat,fdata); GList * elt = export_descriptor->index; lua_newtable(L); while(elt) { luaA_push(L,dt_lua_image_t,&elt->data); luaL_ref(L,-2); elt = g_list_next(elt); } g_list_free(export_descriptor->index); export_descriptor->index =NULL; dt_lua_trigger_event("pre-export",3,3); // get the new storage data and the new storage luaL_getmetafield(L,-3,"__associated_object"); mstorage = lua_touserdata(L,-1); lua_pop(L,1); fdata = mstorage->get_params(mstorage); luaL_getmetafield(L,-3,"__luaA_Type"); luaA_Type storage_type = lua_tointeger(L,-1); lua_pop(L,1); luaA_to_typeid(L,storage_type,fdata,-3); mstorage->set_params(mstorage,fdata,mstorage->params_size(mstorage)); mstorage->free_params(mstorage,fdata); export_data->storage_index = dt_imageio_get_index_of_storage(mstorage); // get the new format data and the new format luaL_getmetafield(L,-2,"__associated_object"); mformat = lua_touserdata(L,-1); lua_pop(L,1); fdata = mformat->get_params(mformat); luaL_getmetafield(L,-2,"__luaA_Type"); luaA_Type format_type = lua_tointeger(L,-1); lua_pop(L,1); luaA_to_typeid(L,format_type,fdata,-2); mformat->set_params(mformat,fdata,mstorage->params_size(mstorage)); mformat->free_params(mformat,fdata); export_data->format_index = dt_imageio_get_index_of_format(mformat); // load the new list of images to process if(lua_isnoneornil(L,-1)) {lua_pop(L,3); return; }// everything already has been removed luaA_to(L,dt_lua_image_t,&export_descriptor->index,-1); lua_pop(L,1); }