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 init(dt_view_t *self) { self->data = malloc(sizeof(dt_capture_t)); memset(self->data,0,sizeof(dt_capture_t)); dt_capture_t *lib = (dt_capture_t *)self->data; // initialize capture data struct const int i = dt_conf_get_int("plugins/capture/mode"); lib->mode = i; // Setup variable expanding, shares configuration as camera import uses... dt_variables_params_init(&lib->vp); lib->basedirectory = dt_conf_get_string("plugins/capture/storage/basedirectory"); lib->subdirectory = dt_conf_get_string("plugins/capture/storage/subpath"); lib->filenamepattern = dt_conf_get_string("plugins/capture/storage/namepattern"); // prefetch next few from first selected image on. dt_view_filmstrip_prefetch(); /* setup the tethering view proxy */ darktable.view_manager->proxy.tethering.view = self; darktable.view_manager->proxy.tethering.get_film_id = _capture_view_get_film_id; darktable.view_manager->proxy.tethering.get_session_filename = _capture_view_get_session_filename; darktable.view_manager->proxy.tethering.get_session_path = _capture_view_get_session_path; darktable.view_manager->proxy.tethering.get_job_code = _capture_view_get_jobcode; darktable.view_manager->proxy.tethering.set_job_code = _capture_view_set_jobcode; darktable.view_manager->proxy.tethering.get_selected_imgid = _capture_view_get_selected_imgid; }
void gui_init(dt_imageio_module_storage_t *self) { latex_t *d = (latex_t *)malloc(sizeof(latex_t)); self->gui_data = (void *)d; self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_PIXEL_APPLY_DPI(5)); GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DT_PIXEL_APPLY_DPI(8)); gtk_box_pack_start(GTK_BOX(self->widget), hbox, TRUE, TRUE, 0); GtkWidget *widget; widget = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0); gchar *dir = dt_conf_get_string("plugins/imageio/storage/latex/file_directory"); if(dir) { gtk_entry_set_text(GTK_ENTRY(widget), dir); g_free(dir); } d->entry = GTK_ENTRY(widget); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(d->entry)); dt_gtkentry_setup_completion(GTK_ENTRY(widget), dt_gtkentry_get_default_path_compl_list()); char *tooltip_text = dt_gtkentry_build_completion_tooltip_text( _("enter the path where to put exported images\nrecognized variables:"), dt_gtkentry_get_default_path_compl_list()); gtk_widget_set_tooltip_text(widget, tooltip_text); g_signal_connect(G_OBJECT(widget), "changed", G_CALLBACK(entry_changed_callback), self); g_free(tooltip_text); widget = dtgtk_button_new(dtgtk_cairo_paint_directory, CPF_DO_NOT_USE_BORDER); gtk_widget_set_tooltip_text(widget, _("select directory")); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(button_clicked), self); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DT_PIXEL_APPLY_DPI(10)); gtk_box_pack_start(GTK_BOX(self->widget), hbox, TRUE, TRUE, 0); widget = gtk_label_new(_("title")); gtk_widget_set_halign(widget, GTK_ALIGN_START); g_object_set(G_OBJECT(widget), "xalign", 0.0, NULL); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 0); d->title_entry = GTK_ENTRY(gtk_entry_new()); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(d->title_entry), TRUE, TRUE, 0); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(d->title_entry)); // TODO: support title, author, subject, keywords (collect tags?) gtk_widget_set_tooltip_text(GTK_WIDGET(d->title_entry), _("enter the title of the book")); dir = dt_conf_get_string("plugins/imageio/storage/latex/title"); if(dir) { gtk_entry_set_text(GTK_ENTRY(d->title_entry), dir); g_free(dir); } g_signal_connect(G_OBJECT(d->title_entry), "changed", G_CALLBACK(title_changed_callback), self); }
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 dt_gphoto_context_t *gphoto_api_init() { dt_gphoto_context_t *ctx = (dt_gphoto_context_t *)g_malloc0(sizeof(dt_gphoto_context_t)); ctx->curl_ctx = curl_easy_init(); ctx->errmsg = g_string_new(""); ctx->response = g_string_new(""); ctx->json_parser = json_parser_new(); ctx->google_client_id = dt_conf_get_string("plugins/imageio/storage/gphoto/id"); ctx->google_client_secret = dt_conf_get_string("plugins/imageio/storage/gphoto/secret"); return ctx; }
/** Creates a gconf widget. */ _camera_gconf_widget_t *_camera_import_gconf_widget(_camera_import_dialog_t *dlg,gchar *label,gchar *confstring) { _camera_gconf_widget_t *gcw=malloc(sizeof(_camera_gconf_widget_t)); memset(gcw,0,sizeof(_camera_gconf_widget_t)); GtkWidget *vbox,*hbox; gcw->widget=vbox=GTK_WIDGET(gtk_vbox_new(FALSE,0)); hbox=GTK_WIDGET(gtk_hbox_new(FALSE,0)); g_object_set_data(G_OBJECT(vbox),"gconf:string",confstring); gcw->dialog=dlg; gcw->entry=gtk_entry_new(); char* value = NULL; if((value = dt_conf_get_string (confstring))) { gtk_entry_set_text( GTK_ENTRY( gcw->entry ),dt_conf_get_string (confstring)); gcw->value=g_strdup(value); g_free(value); } gtk_box_pack_start(GTK_BOX(hbox),GTK_WIDGET(gcw->entry),TRUE,TRUE,0); GtkWidget *button=dtgtk_button_new(dtgtk_cairo_paint_store,CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); g_object_set(button,"tooltip-text",_("store value as default"),(char *)NULL); gtk_widget_set_size_request(button,13,13); gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,FALSE,0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (_gcw_store_callback), gcw); button=dtgtk_button_new(dtgtk_cairo_paint_reset,CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); g_object_set(button,"tooltip-text",_("reset value to default"),(char *)NULL); gtk_widget_set_size_request(button,13,13); gtk_box_pack_start(GTK_BOX(hbox),button,FALSE,FALSE,0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (_gcw_reset_callback), gcw); GtkWidget *l=gtk_label_new(label); gtk_misc_set_alignment(GTK_MISC(l), 0.0, 0.0); gtk_box_pack_start(GTK_BOX(vbox),l,FALSE,FALSE,0); gtk_box_pack_start(GTK_BOX(vbox),GTK_WIDGET(hbox),FALSE,FALSE,0); g_signal_connect (G_OBJECT(gtk_entry_get_buffer(GTK_ENTRY(gcw->entry))), "inserted-text", G_CALLBACK (entry_it_callback), gcw); g_signal_connect (G_OBJECT(gtk_entry_get_buffer(GTK_ENTRY(gcw->entry))), "deleted-text", G_CALLBACK (entry_dt_callback), gcw); return gcw; }
/* Update the params struct with active ruleset */ static void _lib_collect_update_params(dt_lib_collect_t *d) { /* reset params */ dt_lib_collect_params_t *p = d->params; memset(p,0,sizeof(dt_lib_collect_params_t)); /* for each active rule set update params */ const int active = CLAMP(dt_conf_get_int("plugins/lighttable/collect/num_rules") - 1, 0, (MAX_RULES-1)); char confname[200]; for (int i=0; i<=active; i++) { /* get item */ snprintf(confname, 200, "plugins/lighttable/collect/item%1d", i); p->rule[i].item = dt_conf_get_int(confname); /* get mode */ snprintf(confname, 200, "plugins/lighttable/collect/mode%1d", i); p->rule[i].mode = dt_conf_get_int(confname); /* get string */ snprintf(confname, 200, "plugins/lighttable/collect/string%1d", i); gchar* string = dt_conf_get_string(confname); if (string != NULL) { snprintf(p->rule[i].string,PARAM_STRING_SIZE,"%s", string); g_free(string); } fprintf(stderr,"[%i] %d,%d,%s\n",i, p->rule[i].item, p->rule[i].mode, p->rule[i].string); } p->rules = active+1; }
void enter(dt_view_t *self) { dt_capture_t *lib = (dt_capture_t *)self->data; lib->mode = dt_conf_get_int("plugins/capture/mode"); /* connect signal for mipmap update for a redraw */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_DEVELOP_MIPMAP_UPDATED, G_CALLBACK(_capture_mipamps_updated_signal_callback), (gpointer)self); /* connect signal for fimlstrip image activate */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_VIEWMANAGER_FILMSTRIP_ACTIVATE, G_CALLBACK(_view_capture_filmstrip_activate_callback), self); dt_view_filmstrip_scroll_to_image(darktable.view_manager, lib->image_id, TRUE); // initialize a default session... char* tmp = dt_conf_get_string("plugins/capture/jobcode"); _capture_view_set_jobcode(self, tmp); g_free(tmp); }
static void import_button_clicked(GtkButton *button, gpointer user_data) { char *last_dirname = dt_conf_get_string("plugins/lighttable/tagging/last_import_export_location"); if(!last_dirname || !*last_dirname) { g_free(last_dirname); last_dirname = g_strdup(g_get_home_dir()); } GtkWidget *win = dt_ui_main_window(darktable.gui->ui); GtkWidget *filechooser = gtk_file_chooser_dialog_new(_("Select a keyword file"), GTK_WINDOW(win), GTK_FILE_CHOOSER_ACTION_OPEN, _("_cancel"), GTK_RESPONSE_CANCEL, _("_import"), GTK_RESPONSE_ACCEPT, (char *)NULL); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filechooser), last_dirname); gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(filechooser), FALSE); if(gtk_dialog_run(GTK_DIALOG(filechooser)) == GTK_RESPONSE_ACCEPT) { char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooser)); char *dirname = g_path_get_dirname(filename); dt_conf_set_string("plugins/lighttable/tagging/last_import_export_location", dirname); ssize_t count = dt_tag_import(filename); if(count < 0) dt_control_log(_("error importing tags")); else dt_control_log(_("%zd tags imported"), count); g_free(filename); g_free(dirname); } g_free(last_dirname); gtk_widget_destroy(filechooser); }
void dt_dev_init(dt_develop_t *dev, int32_t gui_attached) { memset(dev,0,sizeof(dt_develop_t)); dev->preview_downsampling = 1.0f; dev->gui_module = NULL; dev->timestamp = 0; dev->average_delay = DT_DEV_AVERAGE_DELAY_START; dev->preview_average_delay = DT_DEV_PREVIEW_AVERAGE_DELAY_START; dev->gui_leaving = 0; dev->gui_synch = 0; dt_pthread_mutex_init(&dev->history_mutex, NULL); dev->history_end = 0; dev->history = NULL; // empty list dev->gui_attached = gui_attached; dev->width = -1; dev->height = -1; dt_image_init(&dev->image_storage); dev->image_dirty = dev->preview_dirty = 1; dev->image_loading = dev->preview_loading = 0; dev->image_force_reload = 0; dev->preview_input_changed = 0; dev->pipe = dev->preview_pipe = NULL; dev->histogram = NULL; dev->histogram_pre_tonecurve = NULL; dev->histogram_pre_levels = NULL; if(g_strcmp0(dt_conf_get_string("plugins/darkroom/histogram/mode"), "linear") == 0) dev->histogram_linear = TRUE; else dev->histogram_linear = FALSE; if(dev->gui_attached) { dev->pipe = (dt_dev_pixelpipe_t *)malloc(sizeof(dt_dev_pixelpipe_t)); dev->preview_pipe = (dt_dev_pixelpipe_t *)malloc(sizeof(dt_dev_pixelpipe_t)); dt_dev_pixelpipe_init(dev->pipe); dt_dev_pixelpipe_init_preview(dev->preview_pipe); dev->histogram = (float *)malloc(sizeof(float)*4*256); dev->histogram_pre_tonecurve = (float *)malloc(sizeof(float)*4*256); dev->histogram_pre_levels = (float*)malloc(sizeof(float) * 4 * 256); memset(dev->histogram, 0, sizeof(float)*256*4); memset(dev->histogram_pre_tonecurve, 0, sizeof(float)*256*4); memset(dev->histogram_pre_levels, 0, sizeof(float)*256*4); dev->histogram_max = -1; dev->histogram_pre_tonecurve_max = -1; dev->histogram_pre_levels_max = -1; } dev->iop_instance = 0; dev->iop = NULL; dev->overexposed.enabled = FALSE; dev->overexposed.colorscheme = dt_conf_get_int("darkroom/ui/overexposed/colorscheme"); dev->overexposed.lower = dt_conf_get_int("darkroom/ui/overexposed/lower"); dev->overexposed.upper = dt_conf_get_int("darkroom/ui/overexposed/upper"); }
void enter(dt_view_t *self) { dt_capture_t *lib = (dt_capture_t *)self->data; /* connect signal for mipmap update for a redraw */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_DEVELOP_MIPMAP_UPDATED, G_CALLBACK(_capture_mipmaps_updated_signal_callback), (gpointer)self); /* connect signal for fimlstrip image activate */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_VIEWMANAGER_FILMSTRIP_ACTIVATE, G_CALLBACK(_view_capture_filmstrip_activate_callback), self); dt_view_filmstrip_scroll_to_image(darktable.view_manager, lib->image_id, TRUE); /* initialize a session */ lib->session = dt_import_session_new(); char *tmp = dt_conf_get_string("plugins/capture/jobcode"); if(tmp != NULL) { _capture_view_set_jobcode(self, tmp); g_free(tmp); } // register listener lib->listener = g_malloc0(sizeof(dt_camctl_listener_t)); lib->listener->data = lib; lib->listener->image_downloaded = _camera_capture_image_downloaded; lib->listener->request_image_path = _camera_request_image_path; lib->listener->request_image_filename = _camera_request_image_filename; dt_camctl_register_listener(darktable.camctl, lib->listener); }
/** Listener interface for import job */ void _camera_image_downloaded(const dt_camera_t *camera,const char *filename,void *data) { // Import downloaded image to import filmroll dt_camera_import_t *t = (dt_camera_import_t *)data; dt_film_image_import(t->film,filename, FALSE); dt_control_log(_("%d/%d imported to %s"), t->import_count+1,g_list_length(t->images), g_path_get_basename(filename)); t->fraction+=1.0/g_list_length(t->images); dt_control_backgroundjobs_progress(darktable.control, t->bgj, t->fraction ); if( dt_conf_get_bool("plugins/capture/camera/import/backup/enable") == TRUE ) { // Backup is enable, let's initialize a backup job of imported image... char *base=dt_conf_get_string("plugins/capture/storage/basedirectory"); char *fixed_base=dt_util_fix_path(base); dt_variables_expand( t->vp, fixed_base, FALSE ); g_free(base); const char *sdpart=dt_variables_get_result(t->vp); if( sdpart ) { // Initialize a image backup job of file dt_job_t j; dt_camera_import_backup_job_init(&j, filename,filename+strlen(sdpart)); dt_control_add_job(darktable.control, &j); } } t->import_count++; }
int dt_collection_serialize(char *buf, int bufsize) { char confname[200]; int c; const int num_rules = dt_conf_get_int("plugins/lighttable/collect/num_rules"); c = snprintf(buf, bufsize, "%d:", num_rules); buf += c; bufsize -= c; for(int k=0; k<num_rules; k++) { snprintf(confname, sizeof(confname), "plugins/lighttable/collect/mode%1d", k); const int mode = dt_conf_get_int(confname); c = snprintf(buf, bufsize, "%d:", mode); buf += c; bufsize -= c; snprintf(confname, sizeof(confname), "plugins/lighttable/collect/item%1d", k); const int item = dt_conf_get_int(confname); c = snprintf(buf, bufsize, "%d:", item); buf += c; bufsize -= c; snprintf(confname, sizeof(confname), "plugins/lighttable/collect/string%1d", k); gchar *str = dt_conf_get_string(confname); if(str && (str[0] != '\0')) c = snprintf(buf, bufsize, "%s$", str); else c = snprintf(buf, bufsize, "%%$"); buf += c; bufsize -= c; g_free(str); } return 0; }
static int read_pref(lua_State*L) { const char *script = luaL_checkstring(L,1); const char *name = luaL_checkstring(L,2); const char* type_name = luaL_checkstring(L,3); int i; for (i=0; pref_type_name[i]; i++) if (strcmp(pref_type_name[i], type_name) == 0) { break; } if(!pref_type_name[i]) luaL_argerror(L,3,NULL); char pref_name[1024]; get_pref_name(pref_name,1024,script,name); switch(i) { case pref_string: lua_pushstring(L,dt_conf_get_string(pref_name)); break; case pref_bool: lua_pushboolean(L,dt_conf_get_bool(pref_name)); break; case pref_int: lua_pushnumber(L,dt_conf_get_int(pref_name)); break; } return 1; }
void gui_init (dt_imageio_module_storage_t *self) { disk_t *d = (disk_t *)malloc(sizeof(disk_t)); self->gui_data = (void *)d; self->widget = gtk_hbox_new(FALSE, 5); GtkWidget *widget; widget = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(self->widget), widget, TRUE, TRUE, 0); gchar *dir = dt_conf_get_string("plugins/imageio/storage/disk/file_directory"); if(dir) { gtk_entry_set_text(GTK_ENTRY(widget), dir); g_free(dir); } dt_gtkentry_setup_completion(GTK_ENTRY(widget), dt_gtkentry_get_default_path_compl_list()); char *tooltip_text = dt_gtkentry_build_completion_tooltip_text ( _("enter the path where to put exported images\nrecognized variables:"), dt_gtkentry_get_default_path_compl_list()); d->entry = GTK_ENTRY(widget); dt_gui_key_accel_block_on_focus (GTK_WIDGET (d->entry)); g_object_set(G_OBJECT(widget), "tooltip-text", tooltip_text, (char *)NULL); widget = dtgtk_button_new(dtgtk_cairo_paint_directory, 0); gtk_widget_set_size_request(widget, 18, 18); g_object_set(G_OBJECT(widget), "tooltip-text", _("select directory"), (char *)NULL); gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(button_clicked), self); g_free(tooltip_text); }
static void _database_migrate_to_xdg_structure() { gchar dbfilename[DT_MAX_PATH_LEN]= {0}; gchar *conf_db = dt_conf_get_string("database"); gchar datadir[DT_MAX_PATH_LEN] = {0}; dt_loc_get_datadir(datadir, DT_MAX_PATH_LEN); if (conf_db && conf_db[0] != '/') { char *homedir = getenv ("HOME"); snprintf (dbfilename,DT_MAX_PATH_LEN,"%s/%s", homedir, conf_db); if (g_file_test (dbfilename, G_FILE_TEST_EXISTS)) { fprintf(stderr, "[init] moving database into new XDG directory structure\n"); char destdbname[DT_MAX_PATH_LEN]= {0}; snprintf(destdbname,DT_MAX_PATH_LEN,"%s/%s",datadir,"library.db"); if(!g_file_test (destdbname,G_FILE_TEST_EXISTS)) { rename(dbfilename,destdbname); dt_conf_set_string("database","library.db"); } } } g_free(conf_db); }
static void button_pressed (GtkButton *button, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; dt_lib_recentcollect_t *d = (dt_lib_recentcollect_t *) self->data; // deserialize this button's preset int n = -1; for(int k=0; k<NUM_LINES; k++) { if(button == GTK_BUTTON(d->item[k].button)) { n = k; break; } } if(n < 0) return; char confname[200]; snprintf(confname, 200, "plugins/lighttable/recentcollect/line%1d", n); gchar *line = dt_conf_get_string(confname); if(line) { dt_collection_deserialize(line); g_free(line); // position will be updated when the list of recent collections is. // that way it'll also catch cases when this is triggered by a signal, // not only our button press here. } }
void *get_params(dt_imageio_module_storage_t *self) { dt_imageio_gallery_t *d = (dt_imageio_gallery_t *)calloc(1, sizeof(dt_imageio_gallery_t)); d->vp = NULL; d->l = NULL; dt_variables_params_init(&d->vp); char *text = dt_conf_get_string("plugins/imageio/storage/gallery/file_directory"); g_strlcpy(d->filename, text, sizeof(d->filename)); g_free(text); text = dt_conf_get_string("plugins/imageio/storage/gallery/title"); g_strlcpy(d->title, text, sizeof(d->title)); g_free(text); return d; }
cmsHPROFILE dt_colorspaces_create_output_profile(const int imgid) { char profile[1024]; profile[0] = '\0'; // db lookup colorout params, and dt_conf_() for override gchar *overprofile = dt_conf_get_string("plugins/lighttable/export/iccprofile"); if(!overprofile || !strcmp(overprofile, "image")) { const dt_iop_colorout_params_t *params; // sqlite: sqlite3_stmt *stmt; DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "select op_params from history where imgid=?1 and operation='colorout'", -1, &stmt, NULL); DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid); if(sqlite3_step(stmt) == SQLITE_ROW) { params = sqlite3_column_blob(stmt, 0); g_strlcpy(profile, params->iccprofile, 1024); } sqlite3_finalize(stmt); } if(!overprofile && profile[0] == '\0') { g_strlcpy(profile, "sRGB", 1024); } else if(profile[0] == '\0') { g_strlcpy(profile, overprofile, 1024); } if(overprofile) { g_free(overprofile); } cmsHPROFILE output = NULL; if(!strcmp(profile, "sRGB")) output = dt_colorspaces_create_srgb_profile(); else if(!strcmp(profile, "linear_rgb")) output = dt_colorspaces_create_linear_rgb_profile(); else if(!strcmp(profile, "XYZ")) output = dt_colorspaces_create_xyz_profile(); else if(!strcmp(profile, "adobergb")) output = dt_colorspaces_create_adobergb_profile(); else if(!strcmp(profile, "X profile") && darktable.control->xprofile_data) output = cmsOpenProfileFromMem(darktable.control->xprofile_data, darktable.control->xprofile_size); else { // else: load file name char filename[1024]; dt_colorspaces_find_profile(filename, 1024, profile, "out"); output = cmsOpenProfileFromFile(filename, "r"); } if(!output) output = dt_colorspaces_create_srgb_profile(); return output; }
static void set_storage_by_name (dt_lib_export_t *d, const char *name) { int k=-1; GList *it = g_list_first(darktable.imageio->plugins_storage); dt_imageio_module_storage_t *module = NULL; if( it != NULL ) do { k++; if( strcmp( ((dt_imageio_module_storage_t *)it->data)->name(((dt_imageio_module_storage_t *)it->data)),name) == 0 || strcmp( ((dt_imageio_module_storage_t *)it->data)->plugin_name,name) == 0) { module = (dt_imageio_module_storage_t*)it->data; break; } } while( ( it = g_list_next(it) ) ); if(!module) return; if(!darktable.gui->reset) gtk_combo_box_set_active(d->storage, k); dt_conf_set_string("plugins/lighttable/export/storage_name", module->plugin_name); GtkWidget *old = gtk_bin_get_child(GTK_BIN(d->storage_box)); if(old != module->widget) { if(old) gtk_container_remove(d->storage_box, old); if(module->widget) gtk_container_add(d->storage_box, module->widget); } // Check if plugin recommends a max dimension and set // if not implemented the stored conf values are used.. uint32_t w=0,h=0; w = dt_conf_get_int("plugins/lighttable/export/width"); h = dt_conf_get_int("plugins/lighttable/export/height"); module->recommended_dimension( module, &w, &h ); // Set the recommended dimension, prevent signal changed... g_signal_handlers_block_by_func( d->width, width_changed, NULL ); g_signal_handlers_block_by_func( d->height, height_changed, NULL ); gtk_spin_button_set_value( d->width, w ); gtk_spin_button_set_value( d->height, h ); g_signal_handlers_unblock_by_func( d->width, width_changed, NULL ); g_signal_handlers_unblock_by_func( d->height, height_changed, NULL ); // Let's update formats combobox with supported formats of selected storage module... _update_formats_combobox( d ); // Lets try to set selected format if fail select first in list.. gchar *format_name = dt_conf_get_string("plugins/lighttable/export/format_name"); dt_imageio_module_format_t *format = dt_imageio_get_format_by_name(format_name); g_free(format_name); if( format==NULL || _combo_box_set_active_text( d->format, format->name() ) == FALSE ) gtk_combo_box_set_active( d->format, 0); gtk_widget_show_all(GTK_WIDGET(d->storage_box)); }
static void _lib_collect_gui_update (dt_lib_module_t *self) { dt_lib_collect_t *d = (dt_lib_collect_t *)self->data; const int old = darktable.gui->reset; darktable.gui->reset = 1; const int active = CLAMP(dt_conf_get_int("plugins/lighttable/collect/num_rules") - 1, 0, (MAX_RULES-1)); char confname[200]; for(int i=0; i<MAX_RULES; i++) { gtk_widget_set_no_show_all(d->rule[i].hbox, TRUE); gtk_widget_set_visible(d->rule[i].hbox, FALSE); } for(int i=0; i<=active; i++) { gtk_widget_set_no_show_all(d->rule[i].hbox, FALSE); gtk_widget_set_visible(d->rule[i].hbox, TRUE); gtk_widget_show_all(d->rule[i].hbox); snprintf(confname, 200, "plugins/lighttable/collect/item%1d", i); gtk_combo_box_set_active(GTK_COMBO_BOX(d->rule[i].combo), dt_conf_get_int(confname)); snprintf(confname, 200, "plugins/lighttable/collect/string%1d", i); gchar *text = dt_conf_get_string(confname); if(text) { gtk_entry_set_text(GTK_ENTRY(d->rule[i].text), text); g_free(text); } GtkDarktableButton *button = DTGTK_BUTTON(d->rule[i].button); if(i == MAX_RULES - 1) { // only clear button->icon = dtgtk_cairo_paint_cancel; g_object_set(G_OBJECT(button), "tooltip-text", _("clear this rule"), (char *)NULL); } else if(i == active) { button->icon = dtgtk_cairo_paint_dropdown; g_object_set(G_OBJECT(button), "tooltip-text", _("clear this rule or add new rules"), (char *)NULL); } else { snprintf(confname, 200, "plugins/lighttable/collect/mode%1d", i+1); const int mode = dt_conf_get_int(confname); if(mode == DT_LIB_COLLECT_MODE_AND) button->icon = dtgtk_cairo_paint_and; if(mode == DT_LIB_COLLECT_MODE_OR) button->icon = dtgtk_cairo_paint_or; if(mode == DT_LIB_COLLECT_MODE_AND_NOT) button->icon = dtgtk_cairo_paint_andnot; g_object_set(G_OBJECT(button), "tooltip-text", _("clear this rule"), (char *)NULL); } } // update list of proposals changed_callback(NULL, d->rule + d->active_rule); darktable.gui->reset = old; }
dt_imageio_module_storage_t *dt_imageio_get_storage() { dt_imageio_t *iio = darktable.imageio; gchar *storage_name = dt_conf_get_string("plugins/lighttable/export/storage_name"); dt_imageio_module_storage_t *storage = dt_imageio_get_storage_by_name(storage_name); g_free(storage_name); // if the storage from the config isn't available default to disk, if that's not available either just use the first we have if(!storage) storage = dt_imageio_get_storage_by_name("disk"); if(!storage) storage = iio->plugins_storage->data; return storage; }
dt_imageio_module_format_t *dt_imageio_get_format() { dt_imageio_t *iio = darktable.imageio; gchar *format_name = dt_conf_get_string("plugins/lighttable/export/format_name"); dt_imageio_module_format_t *format = dt_imageio_get_format_by_name(format_name); g_free(format_name); // if the format from the config isn't available default to jpeg, if that's not available either just use the first we have if(!format) format = dt_imageio_get_format_by_name("jpeg"); if(!format) format = iio->plugins_format->data; return format; }
static gboolean _goto_previous(GtkAccelGroup *accel_group, GObject *acceleratable, guint keyval, GdkModifierType modifier, gpointer data) { gchar *line = dt_conf_get_string("plugins/lighttable/recentcollect/line1"); if(line) { dt_collection_deserialize(line); g_free(line); } return TRUE; }
static gboolean _lib_geotagging_offset_focus_out(GtkWidget *widget, GdkEvent *event, dt_lib_module_t *self) { dt_lib_geotagging_t *d = (dt_lib_geotagging_t*)self->data; const gchar* value = gtk_entry_get_text(GTK_ENTRY(d->offset_entry)); if(_lib_geotagging_parse_offset(value, NULL)) dt_conf_set_string("plugins/lighttable/geotagging/offset", value); else gtk_entry_set_text(GTK_ENTRY(d->offset_entry), dt_conf_get_string("plugins/lighttable/geotagging/offset")); return FALSE; }
static void _gcw_reset_callback(GtkDarktableButton *button, gpointer user_data) { _camera_gconf_widget_t *gcw = (_camera_gconf_widget_t *)user_data; gchar *configstring = g_object_get_data(G_OBJECT(gcw->widget), "gconf:string"); gchar *value = dt_conf_get_string(configstring); if(value) { gtk_entry_set_text(GTK_ENTRY(gcw->entry), value); g_free(gcw->value); gcw->value = value; } }
void gui_init(dt_lib_module_t *self) { dt_lib_map_settings_t *d = (dt_lib_map_settings_t *)malloc(sizeof(dt_lib_map_settings_t)); self->data = d; self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); GtkBox *hbox; GtkWidget *label; d->show_osd_checkbutton = gtk_check_button_new_with_label(_("show OSD")); g_object_set(G_OBJECT(d->show_osd_checkbutton), "tooltip-text", _("toggle the visibility of the map overlays"), (char *)NULL); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(d->show_osd_checkbutton), dt_conf_get_bool("plugins/map/show_map_osd")); gtk_box_pack_start(GTK_BOX(self->widget), d->show_osd_checkbutton, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(d->show_osd_checkbutton), "toggled", G_CALLBACK(_show_osd_toggled), NULL); hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5)); label = gtk_label_new(_("map source")); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_box_pack_start(hbox, label, TRUE, TRUE, 0); GtkListStore *model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); d->map_source_dropdown = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model)); g_object_set(G_OBJECT(d->map_source_dropdown), "tooltip-text", _("select the source of the map. some entries might not work"), (char *)NULL); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(d->map_source_dropdown), renderer, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(d->map_source_dropdown), renderer, "text", 0, NULL); gchar *map_source = dt_conf_get_string("plugins/map/map_source"); int selection = OSM_GPS_MAP_SOURCE_OPENSTREETMAP - 1, entry = 0; GtkTreeIter iter; for(int i = 1; i < OSM_GPS_MAP_SOURCE_LAST; i++) { if(osm_gps_map_source_is_valid(i)) { const gchar *name = osm_gps_map_source_get_friendly_name(i); gtk_list_store_append(model, &iter); gtk_list_store_set(model, &iter, 0, name, 1, i, -1); if(!g_strcmp0(name, map_source)) selection = entry; entry++; } } gtk_combo_box_set_active(GTK_COMBO_BOX(d->map_source_dropdown), selection); gtk_box_pack_start(hbox, d->map_source_dropdown, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(d->map_source_dropdown), "changed", G_CALLBACK(_map_source_changed), NULL); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox), TRUE, TRUE, 0); g_object_unref(model); g_free(map_source); }
void gui_init(dt_lib_module_t *self) { dt_lib_geotagging_t *d = (dt_lib_geotagging_t *)malloc(sizeof(dt_lib_geotagging_t)); self->data = (void *)d; d->timezones = _lib_geotagging_get_timezones(); self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); GtkBox *hbox; GtkWidget *button, *label; /* the offset line */ hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5)); label = GTK_WIDGET(gtk_label_new(_("time offset"))); gtk_widget_set_halign(label, GTK_ALIGN_START); gtk_box_pack_start(hbox, label, TRUE, TRUE, 0); d->offset_entry = gtk_entry_new(); dt_gui_key_accel_block_on_focus_connect(d->offset_entry); gtk_entry_set_max_length(GTK_ENTRY(d->offset_entry), 9); gtk_entry_set_width_chars(GTK_ENTRY(d->offset_entry), 0); gtk_box_pack_start(hbox, d->offset_entry, TRUE, TRUE, 0); g_signal_connect(d->offset_entry, "key-press-event", G_CALLBACK(_lib_geotagging_offset_key_press), self); g_signal_connect(d->offset_entry, "focus-out-event", G_CALLBACK(_lib_geotagging_offset_focus_out), self); g_object_set(G_OBJECT(d->offset_entry), "tooltip-text", _("time offset\nformat: [+-]?[[hh:]mm:]ss"), (char *)NULL); gchar *str = dt_conf_get_string("plugins/lighttable/geotagging/offset"); if(_lib_geotagging_parse_offset(str, NULL)) gtk_entry_set_text(GTK_ENTRY(d->offset_entry), str); else gtk_entry_set_text(GTK_ENTRY(d->offset_entry), "+00:00:00"); g_free(str); GtkBox *button_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5)); button = dtgtk_button_new(dtgtk_cairo_paint_zoom, CPF_STYLE_FLAT | CPF_DO_NOT_USE_BORDER); g_object_set(G_OBJECT(button), "tooltip-text", _("calculate the time offset from an image"), (char *)NULL); gtk_box_pack_start(button_box, button, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(_lib_geotagging_show_offset_window), self); button = dtgtk_button_new(dtgtk_cairo_paint_check_mark, CPF_STYLE_FLAT | CPF_DO_NOT_USE_BORDER); g_object_set(G_OBJECT(button), "tooltip-text", _("apply time offset to selected images"), (char *)NULL); gtk_box_pack_start(button_box, button, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(_lib_geotagging_apply_offset_callback), self); gtk_box_pack_start(hbox, GTK_WIDGET(button_box), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox), TRUE, TRUE, 0); /* gpx */ button = gtk_button_new_with_label(_("apply GPX track file")); g_object_set(G_OBJECT(button), "tooltip-text", _("parses a GPX file and updates location of selected images"), (char *)NULL); gtk_box_pack_start(GTK_BOX(self->widget), button, TRUE, TRUE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(_lib_geotagging_gpx_callback), self); }
static void _get_max_output_dimension(dt_lib_export_t *d,uint32_t *width, uint32_t *height) { gchar *storage_name = dt_conf_get_string("plugins/lighttable/export/storage_name"); dt_imageio_module_storage_t *storage = dt_imageio_get_storage_by_name(storage_name); g_free(storage_name); char *format_name = dt_conf_get_string("plugins/lighttable/export/format_name"); dt_imageio_module_format_t *format = dt_imageio_get_format_by_name(format_name); g_free(format_name); if( storage && format ) { uint32_t fw,fh,sw,sh; fw=fh=sw=sh=0; // We are all equals!!! storage->dimension(storage, &sw,&sh); format->dimension(format, &fw,&fh); if( sw==0 || fw==0) *width=sw>fw?sw:fw; else *width=sw<fw?sw:fw; if( sh==0 || fh==0) *height=sh>fh?sh:fh; else *height=sh<fh?sh:fh; } }
int32_t dt_camera_import_backup_job_run(dt_job_t *job) { // copy sourcefile to each found destination dt_camera_import_backup_t *t = (dt_camera_import_backup_t *)job->param; GVolumeMonitor *vmgr= g_volume_monitor_get(); GList *mounts=g_volume_monitor_get_mounts(vmgr); GMount *mount=NULL; GFile *root=NULL; if( mounts !=NULL ) do { mount=G_MOUNT(mounts->data); if( ( root=g_mount_get_root( mount ) ) != NULL ) { // Got the mount point lets check for backup folder gchar *backuppath=NULL; gchar *rootpath=g_file_get_path(root); backuppath=g_build_path(G_DIR_SEPARATOR_S,rootpath,dt_conf_get_string("plugins/capture/backup/foldername"),(char *)NULL); g_free(rootpath); if( g_file_test(backuppath,G_FILE_TEST_EXISTS)==TRUE) { // Found a backup storage, lets copy file here.. gchar *destinationfile=g_build_filename(G_DIR_SEPARATOR_S,backuppath,t->destinationfile,(char *)NULL); if( g_mkdir_with_parents(g_path_get_dirname(destinationfile),0755) >= 0 ) { gchar *content; gsize size; if( g_file_get_contents(t->sourcefile,&content,&size,NULL) == TRUE ) { GError *err=NULL; if( g_file_set_contents(destinationfile,content,size,&err) != TRUE) { fprintf(stderr,"Failed to set content of file with reason: %s\n",err->message); g_error_free(err); } g_free(content); } } g_free(destinationfile); } g_free(backuppath); } } while( (mounts=g_list_next(mounts)) !=NULL); // Release volume manager g_object_unref(vmgr); return 0; }