Is there a new patch for curent CVS???
2009/11/26 Frank van Maarseveen <fran...@frankvm.com>
> On Thu, Nov 26, 2009 at 11:12:53AM +0000, Milos Popovic wrote:
> > Is it possible to add an option for saving WB settings?
> >
> > Eg. I have home made ???difuzor??? which gives a bit red light. I would
> like
> > to save custom settings for it and use it whenever the difuzor is on.
> > Canon DPP and some other applications have this option.
> >
> > This could be done in preferences, so the users does not get more
> > options in already overloaded GUI.
>
> Haven't seen "preferences". Until there's a better solution... I still
> have this preset button patch lurking around (I use it). I don't have
> the time/urgency to improve it, at least not on the short term so anyone
> who wants to pick it up is welcome.
>
> It records/restores all image manipulation parameters (not GUI). But it
> could be smarter than always invalidating the raw phase but that would
> be a lot of work unless the set of parameters is reduced, something I'm
> not so sure of. Maybe it should be configurable.
>
> The "Options" menu has been extended with a "clear all presets" button
> but this is a bit redundant because "rm $HOME/.ufraw/?.ufraw" will do too.
>
> The "restore" button is a kind of master reset.
>
> --
> Frank
>
> diff --git a/ufraw.h b/ufraw.h
> index 1a5ec9e..c047ac7 100644
> --- a/ufraw.h
> +++ b/ufraw.h
> @@ -20,6 +20,8 @@
> #include "nikon_curve.h"
> #include "uf_progress.h"
>
> +#define ARRAYSIZE(x) ((int)(sizeof (x) / sizeof ((x)[0])))
> +
> /* macro to clamp a number between two values */
> #ifndef LIM
> #define LIM(x,min,max) MAX(min,MIN(x,max))
> @@ -392,7 +394,7 @@ void ptr_array_insert_index (GPtrArray *array, const
> void *item, int index);
>
> /* prototypes for functions in ufraw_conf.c */
> int conf_load(conf_data *c, const char *confFilename);
> -int conf_save(conf_data *c, char *confFilename, char **confBuffer);
> +int conf_save(conf_data *c, char *confFilename, char **confBuffer,
> gboolean preset);
> /* copy default config to given instance and initialize non-const fields
> */
> void conf_init (conf_data *c);
> /* Copy the image manipulation options from *src to *dst */
> diff --git a/ufraw_conf.c b/ufraw_conf.c
> index 03b5833..6bbfc71 100644
> --- a/ufraw_conf.c
> +++ b/ufraw_conf.c
> @@ -819,7 +819,7 @@ int conf_load(conf_data *c, const char *IDFilename)
> return UFRAW_SUCCESS;
> }
>
> -int conf_save(conf_data *c, char *IDFilename, char **confBuffer)
> +int conf_save(conf_data *c, char *IDFilename, char **confBuffer, gboolean
> preset)
> {
> char *buf=NULL;
> int i, j;
> @@ -828,17 +828,17 @@ int conf_save(conf_data *c, char *IDFilename, char
> **confBuffer)
>
> buf = uf_markup_buf(buf, "<?xml version=\"1.0\"
> encoding=\"utf-8\"?>\n");
> buf = uf_markup_buf(buf, "<UFRaw Version='%d'>\n", c->version);
> - if (strlen(c->inputFilename)>0 && IDFilename!=NULL) {
> + if (strlen(c->inputFilename)>0 && IDFilename!=NULL && !preset) {
> char *utf8 = g_filename_display_name(c->inputFilename);
> buf = uf_markup_buf(buf, "<InputFilename>%s</InputFilename>\n",
> utf8);
> g_free(utf8);
> }
> - if (strlen(c->outputFilename)>0 && IDFilename!=NULL) {
> + if (strlen(c->outputFilename)>0 && IDFilename!=NULL && !preset) {
> char *utf8=g_filename_display_name(c->outputFilename);
> buf = uf_markup_buf(buf, "<OutputFilename>%s</OutputFilename>\n",
> utf8);
> g_free(utf8);
> }
> - if (strlen(c->outputPath)>0) {
> + if (strlen(c->outputPath)>0 && !preset) {
> char *utf8=g_filename_display_name(c->outputPath);
> buf = uf_markup_buf(buf, "<OutputPath>%s</OutputPath>\n", utf8);
> g_free(utf8);
> @@ -1158,7 +1158,7 @@ int conf_save(conf_data *c, char *IDFilename, char
> **confBuffer)
> * to know if the WB setting is relevant */
> buf = uf_markup_buf(buf, "<Make>%s</Make>\n", c->make);
> buf = uf_markup_buf(buf, "<Model>%s</Model>\n", c->model);
> - if (IDFilename!=NULL) {
> + if (IDFilename!=NULL && !preset) {
> if (strcmp(c->darkframeFile, conf_default.darkframeFile)!=0)
> buf = uf_markup_buf(buf,
> "<DarkframeFile>%s</DarkframeFile>\n",
> c->darkframeFile);
> diff --git a/ufraw_preview.c b/ufraw_preview.c
> index 7fe501a..f9a9a78 100644
> --- a/ufraw_preview.c
> +++ b/ufraw_preview.c
> @@ -27,6 +27,7 @@
> #include "uf_gtk.h"
> #include <gdk/gdkkeysyms.h>
> #include <glib/gi18n.h>
> +#include <glib/gstdio.h>
> #include "ufraw.h"
> #include "ufraw_ui.h"
> #include "curveeditor_widget.h"
> @@ -69,6 +70,14 @@ static const char *grayscaleModeNames[5] = {
> N_("Channel Mixer")
> };
>
> +struct preset {
> + char *idfile;
> + char *tooltip_load;
> + char *tooltip_save;
> + GtkWidget *button;
> +};
> +static struct preset presets[6];
> +
> preview_data *get_preview_data(void *object)
> {
> GtkWidget *widget;
> @@ -216,7 +225,7 @@ static void load_curve(GtkWidget *widget, long
> curveType)
> cp = g_path_get_dirname(list->data);
> g_strlcpy(CFG->curvePath, cp, max_path);
> g_strlcpy(RC->curvePath, cp, max_path);
> - conf_save(RC, NULL, NULL);
> + conf_save(RC, NULL, NULL, FALSE);
> g_free(cp);
> g_free(list->data);
> }
> @@ -381,7 +390,7 @@ static void load_profile(GtkWidget *widget, long type)
> /* Add profile to .ufrawrc but don't make it default */
> RC->profile[type][RC->profileCount[type]++] = p;
> g_strlcpy(RC->profilePath, cp, max_path);
> - conf_save(RC, NULL, NULL);
> + conf_save(RC, NULL, NULL, FALSE);
> g_free(cp);
> g_free(list->data);
> }
> @@ -1544,11 +1553,11 @@ static void update_scales(preview_data *data)
> gtk_widget_set_sensitive(data->ResetWBButton,
> ( strcmp(CFG->wb, data->initialWB)
> ||fabs(CFG->temperature-data->initialTemperature)>1
> - ||fabs(CFG->green-data->initialGreen)>0.001
> - ||CFG->chanMul[0]!=data->initialChanMul[0]
> - ||CFG->chanMul[1]!=data->initialChanMul[1]
> - ||CFG->chanMul[2]!=data->initialChanMul[2]
> - ||CFG->chanMul[3]!=data->initialChanMul[3] ) );
> + ||fabs(CFG->green-data->initialGreen)>0.000001
> + ||fabs(CFG->chanMul[0]-data->initialChanMul[0]) > 0.000001
> + ||fabs(CFG->chanMul[1]-data->initialChanMul[1]) > 0.000001
> + ||fabs(CFG->chanMul[2]-data->initialChanMul[2]) > 0.000001
> + ||fabs(CFG->chanMul[3]-data->initialChanMul[3]) > 0.000001 ) );
> gtk_widget_set_sensitive(data->ResetGammaButton,
> fabs(
> profile_default_gamma(&CFG->profile[0][CFG->profileIndex[0]])
> - CFG->profile[0][CFG->profileIndex[0]].gamma) > 0.001);
> @@ -3491,11 +3500,83 @@ static void delete_from_list(GtkWidget *widget,
> gpointer user_data)
> gtk_dialog_response(dialog, GTK_RESPONSE_APPLY);
> }
>
> +static void preset_update_state(GtkWidget *widget, struct preset *p, int
> state)
> +{
> + if (!state) {
> + state = g_file_test(p->idfile, G_FILE_TEST_EXISTS) ? 1 : -1;
> + }
> + if (state > 0) {
> + gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
> + uf_widget_set_tooltip(widget, p->tooltip_load);
> + } else {
> + gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NONE);
> + uf_widget_set_tooltip(widget, p->tooltip_save);
> + }
> +}
> +
> +static void preset_set(GtkWidget *widget, gpointer user_data)
> +{
> + preview_data *data = user_data;
> + int i;
> +
> + (void)widget;
> + for (i = 0; i < ARRAYSIZE(presets); ++i)
> + preset_update_state(presets[i].button, &presets[i],
> data->preset_set ? 0 : -1);
> + data->preset_set = !data->preset_set;
> +}
> +
> +static void preset_clicked(GtkWidget *widget, gpointer user_data)
> +{
> + preview_data *data = get_preview_data(widget);
> + struct preset *p = user_data;
> + gboolean load = TRUE;
> + conf_data c;
> +
> + if (p) {
> + if (gtk_button_get_relief(GTK_BUTTON(widget)) == GTK_RELIEF_NORMAL)
> {
> + if (conf_load(&c, p->idfile) != UFRAW_SUCCESS)
> + load = FALSE;
> + } else {
> + conf_save(CFG, p->idfile, NULL, TRUE);
> + preset_update_state(widget, p, 0);
> + load = FALSE;
> + }
> + } else {
> + c = data->restore_image;
> + }
> + if (data->preset_set)
> + preset_set(NULL, data);
> + if (load) {
> + conf_copy_image(CFG, &c);
> + /* TODO: factor out a generic conf_apply_prepare() */
> + if (CFG->autoExposure == enabled_state)
> + CFG->autoExposure = apply_state;
> + if (CFG->autoBlack == enabled_state)
> + CFG->autoBlack = apply_state;
> + curveeditor_widget_set_curve(data->BaseCurveWidget,
> + &CFG->BaseCurve[CFG->BaseCurveIndex]);
> + /* TODO: conf_copy_image() should yield invalidation info */
> + ufraw_invalidate_layer(data->UF, ufraw_raw_phase);
> + update_scales(data);
> + }
> +}
> +
> +static void preset_clear(GtkWidget *widget, gpointer user_data)
> +{
> + preview_data *data = get_preview_data(widget);
> + int i;
> +
> + (void)user_data;
> + for (i = 0; i < ARRAYSIZE(presets); ++i)
> + g_unlink(presets[i].idfile);
> + preset_set(NULL, data);
> +}
> +
> static void configuration_save(GtkWidget *widget, gpointer user_data)
> {
> preview_data *data = get_preview_data(widget);
> user_data = user_data;
> - conf_save(CFG, NULL, NULL);
> + conf_save(CFG, NULL, NULL, FALSE);
> *RC = *data->UF->conf;
> }
>
> @@ -3508,7 +3589,7 @@ static void gimp_reset_clicked(GtkWidget *widget,
> GtkEntry *entry)
> static void options_dialog(preview_data *data)
> {
> GtkWidget *optionsDialog, *profileTable[profile_types];
> - GtkWidget *notebook, *label, *page, *button, *text, *box, *image;
> + GtkWidget *notebook, *label, *page, *button, *text, *box, *hBox,
> *image;
> GtkTable *baseCurveTable, *curveTable;
> GtkTextBuffer *confBuffer, *buffer;
> char txt[max_name], *buf;
> @@ -3526,7 +3607,7 @@ static void options_dialog(preview_data *data)
> GTK_DIALOG_DESTROY_WITH_PARENT,
> GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
> GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
> - gtk_window_resize(GTK_WINDOW(optionsDialog), 600, 400);
> + gtk_window_resize(GTK_WINDOW(optionsDialog), 600, 425);
> g_object_set_data(G_OBJECT(optionsDialog), "Preview-Data", data);
> ufraw_focus(optionsDialog, TRUE);
> gtk_dialog_set_default_response(GTK_DIALOG(optionsDialog),
> @@ -3585,7 +3666,16 @@ static void options_dialog(preview_data *data)
> gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
> confBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
>
> - GtkWidget *hBox = gtk_hbox_new(FALSE, 0);
> + hBox = gtk_hbox_new(FALSE, 0);
> + gtk_box_pack_start(GTK_BOX(box), hBox, FALSE, FALSE, 0);
> + button = gtk_button_new_with_label(_("Clear all presets"));
> + gtk_box_pack_start(GTK_BOX(hBox), button, FALSE, FALSE, 0);
> + uf_widget_set_tooltip(button,
> + _("Remove the .ufraw files associated with the numbered preset
> buttons below the preview"));
> + g_signal_connect(G_OBJECT(button), "clicked",
> + G_CALLBACK(preset_clear), NULL);
> +
> + hBox = gtk_hbox_new(FALSE, 0);
> gtk_box_pack_start(GTK_BOX(box), hBox, FALSE, FALSE, 0);
> button = gtk_button_new_with_label(_("Save configuration"));
> gtk_box_pack_start(GTK_BOX(hBox), button, FALSE, FALSE, 0);
> @@ -3672,7 +3762,7 @@ static void options_dialog(preview_data *data)
> G_CALLBACK(delete_from_list), (gpointer)i);
> gtk_table_attach(curveTable, button, 1, 2, i, i+1, 0, 0, 0, 0);
> }
> - conf_save(CFG, NULL, &buf);
> + conf_save(CFG, NULL, &buf, FALSE);
> gtk_text_buffer_set_text(confBuffer, buf, -1);
> g_free(buf);
> gtk_widget_show_all(optionsDialog);
> @@ -3720,7 +3810,7 @@ static void options_dialog(preview_data *data)
> RC->profile[i][j] = CFG->profile[i][j];
> RC->profileCount[i] = CFG->profileCount[i];
> }
> - conf_save(RC, NULL, NULL);
> + conf_save(RC, NULL, NULL, FALSE);
> } else { /* response==GTK_RESPONSE_CANCEL or window closed */
> /* Copy profiles and curves from RC to CFG */
>
> @@ -5456,6 +5546,17 @@ static void exif_fill_interface(preview_data *data,
> /* End of EXIF page */
> }
>
> +static const char *ufraw_get_datadir(void)
> +{
> + static char *dd;
> +
> + if (dd==NULL) {
> + dd = g_build_filename(uf_get_home_dir(), ".ufraw", NULL);
> + g_mkdir(dd, 0755);
> + }
> + return dd;
> +}
> +
> int ufraw_preview(ufraw_data *uf, conf_data *rc, int plugin,
> long (*save_func)())
> {
> @@ -5469,6 +5570,7 @@ int ufraw_preview(ufraw_data *uf, conf_data *rc, int
> plugin,
> int status, curveeditorHeight;
> preview_data PreviewData;
> preview_data *data = &PreviewData;
> + const char *dd = ufraw_get_datadir();
>
> /* Fill the whole structure with zeros, to avoid surprises */
> memset(&PreviewData, 0, sizeof(PreviewData));
> @@ -5720,9 +5822,39 @@ int ufraw_preview(ufraw_data *uf, conf_data *rc, int
> plugin,
> gtk_box_pack_start(GTK_BOX(vBox), GTK_WIDGET(data->ProgressBar),
> FALSE, FALSE, 0);
>
> - /* Control buttons at the bottom */
> + /* Start of control buttons. They are at the bottom */
> GtkBox *ControlsBox = GTK_BOX(gtk_hbox_new(FALSE, 6));
> gtk_box_pack_start(GTK_BOX(vBox), GTK_WIDGET(ControlsBox), FALSE,
> FALSE, 6);
> +
> + // Restore and the preset buttons are aligned to the left
> + box = GTK_BOX(gtk_hbox_new(FALSE, 0));
> + gtk_box_pack_start(GTK_BOX(ControlsBox), GTK_WIDGET(box), FALSE,
> FALSE, 0);
> + button = gtk_button_new_with_label(_("Restore"));
> + gtk_box_pack_start(box, button, FALSE, FALSE, 0);
> + uf_widget_set_tooltip(button, _("Restore image manipulation
> parameters"));
> + g_signal_connect(G_OBJECT(button), "clicked",
> + G_CALLBACK(preset_clicked), NULL);
> + for (i = 0; i < ARRAYSIZE(presets); ++i) {
> + struct preset *p = presets + i;
> + char num[10];
> + char name[20];
> + sprintf(num, "%d", i + 1);
> + sprintf(name, "%s.ufraw", num);
> + p->idfile = g_build_filename(dd, name, NULL);
> + p->tooltip_load = g_strdup_printf(_("Load %s"), p->idfile);
> + p->tooltip_save = g_strdup_printf(_("Initialize preset %s"),
> p->idfile);
> + p->button = gtk_button_new_with_label(_(num));
> + gtk_box_pack_start(box, p->button, FALSE, FALSE, 0);
> + preset_update_state(p->button, p, 0);
> + g_signal_connect(G_OBJECT(p->button), "clicked",
> + G_CALLBACK(preset_clicked), p);
> + }
> + button = gtk_button_new_with_label(_("Set"));
> + gtk_box_pack_start(box, button, FALSE, FALSE, 0);
> + uf_widget_set_tooltip(button, _("Initialize any preset button"));
> + g_signal_connect(G_OBJECT(button), "clicked",
> + G_CALLBACK(preset_set), data);
> +
> // Zoom buttons are centered:
> GtkBox *ZoomBox = GTK_BOX(gtk_hbox_new(FALSE, 0));
> gtk_box_pack_start(ControlsBox, GTK_WIDGET(ZoomBox), TRUE, FALSE, 0);
> @@ -5759,7 +5891,7 @@ int ufraw_preview(ufraw_data *uf, conf_data *rc, int
> plugin,
> gtk_box_pack_start(ZoomBox, button, FALSE, FALSE, 0);
>
> // The rest of the control button are aligned to the right
> - box = GTK_BOX(gtk_hbox_new(FALSE, 6));
> + box = GTK_BOX(gtk_hbox_new(FALSE, 0));
> gtk_box_pack_start(GTK_BOX(ControlsBox), GTK_WIDGET(box), FALSE, FALSE,
> 0);
> /* Options button */
> button = gtk_button_new();
> @@ -5871,6 +6003,9 @@ int ufraw_preview(ufraw_data *uf, conf_data *rc, int
> plugin,
> CFG->size = 0;
> }
>
> + /* For "restore" button */
> + data->restore_image = *data->UF->conf;
> +
> /* Save initial WB data for the sake of "Reset WB" */
> g_strlcpy(data->initialWB, CFG->wb, max_name);
> data->initialTemperature = CFG->temperature;
> @@ -5941,7 +6076,7 @@ int ufraw_preview(ufraw_data *uf, conf_data *rc, int
> plugin,
> if ( CFG->saveConfiguration==enabled_state ) {
> /* Save configuration from CFG, but not the output filename. */
> strcpy(CFG->outputFilename, "");
> - conf_save(CFG, NULL, NULL);
> + conf_save(CFG, NULL, NULL, FALSE);
> conf_copy_image(RC, CFG);
> conf_copy_save(RC, CFG);
> /* If save 'only this once' was chosen, then so be it */
> @@ -5949,7 +6084,7 @@ int ufraw_preview(ufraw_data *uf, conf_data *rc, int
> plugin,
> CFG->saveConfiguration = disabled_state;
> /* Save configuration from CFG, but not the output filename. */
> strcpy(CFG->outputFilename, "");
> - conf_save(CFG, NULL, NULL);
> + conf_save(CFG, NULL, NULL, FALSE);
> conf_copy_image(RC, CFG);
> conf_copy_save(RC, CFG);
> } else if ( CFG->saveConfiguration==disabled_state ) {
> @@ -5957,9 +6092,9 @@ int ufraw_preview(ufraw_data *uf, conf_data *rc, int
> plugin,
> * need to save this setting */
> if ( RC->saveConfiguration!=disabled_state ) {
> RC->saveConfiguration = disabled_state;
> - conf_save(RC, NULL, NULL);
> + conf_save(RC, NULL, NULL, FALSE);
> } else if ( SaveRC ) {
> - conf_save(RC, NULL, NULL);
> + conf_save(RC, NULL, NULL, FALSE);
> }
> strcpy(RC->inputFilename, "");
> strcpy(RC->outputFilename, "");
> @@ -5976,6 +6111,11 @@ int ufraw_preview(ufraw_data *uf, conf_data *rc, int
> plugin,
> g_free(data->DevLabels);
> g_free(data->OverLabels);
> g_free(data->UnderLabels);
> + for (i = 0; i < ARRAYSIZE(presets); ++i) {
> + g_free(presets[i].idfile);
> + g_free(presets[i].tooltip_load);
> + g_free(presets[i].tooltip_save);
> + }
>
> if (status!=GTK_RESPONSE_OK) return UFRAW_CANCEL;
> return UFRAW_SUCCESS;
> diff --git a/ufraw_saver.c b/ufraw_saver.c
> index 8b75955..c04338d 100644
> --- a/ufraw_saver.c
> +++ b/ufraw_saver.c
> @@ -91,7 +91,7 @@ long ufraw_send_to_gimp(ufraw_data *uf)
> char *buffer;
> int saveCreateID = uf->conf->createID;
> uf->conf->createID = send_id;
> - conf_save(uf->conf, confFilename, &buffer);
> + conf_save(uf->conf, confFilename, &buffer, FALSE);
> uf->conf->createID = saveCreateID;
> if ( fwrite(buffer, strlen(buffer), 1, out)!=1 ) {
> g_free(buffer);
> diff --git a/ufraw_ui.h b/ufraw_ui.h
> index 7446fa4..d245ace 100644
> --- a/ufraw_ui.h
> +++ b/ufraw_ui.h
> @@ -40,7 +40,7 @@ enum { base_curve, luminosity_curve };
> /* All the "global" information is here: */
> typedef struct {
> ufraw_data *UF;
> - conf_data *rc;
> + conf_data *rc, restore_image;
> char initialWB[max_name];
> double initialTemperature, initialGreen;
> double initialChanMul[4];
> @@ -185,6 +185,7 @@ typedef struct {
> /* The event source number when the highlight blink function is
> enabled. */
> guint BlinkTimer;
> guint DrawCropID;
> + gboolean preset_set;
> } preview_data;
>
> /* Response can be any unique positive integer */
> diff --git a/ufraw_writer.c b/ufraw_writer.c
> index db59a7c..b8eb6a8 100644
> --- a/ufraw_writer.c
> +++ b/ufraw_writer.c
> @@ -260,7 +260,7 @@ int ufraw_write_image(ufraw_data *uf)
> }
> }
> if (uf->conf->createID==only_id) {
> - int status = conf_save(uf->conf, confFilename, NULL);
> + int status = conf_save(uf->conf, confFilename, NULL, FALSE);
> g_free(confFilename);
> return status;
> }
> @@ -778,7 +778,7 @@ int ufraw_write_image(ufraw_data *uf)
> if ( ufraw_get_message(uf)!=NULL )
> ufraw_message(UFRAW_SET_LOG, ufraw_get_message(uf));
> // TODO: error handling
> - conf_save(uf->conf, confFilename, NULL);
> + conf_save(uf->conf, confFilename, NULL, FALSE);
> g_free(confFilename);
> }
> return ufraw_get_status(uf);
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> ufraw-devel mailing list
> ufraw-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ufraw-devel
>
>
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
ufraw-devel mailing list
ufraw-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ufraw-devel