summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2007-05-21 17:14:17 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2007-05-21 17:14:17 +0200
commit41d41d7a970760ace88f13539a3969c85c351d8c (patch)
tree17329bbe98bd6827dcb413c8abe93f1dcb6f67fd /src
parentd2242935374419b6ee9c642104fc3a1cc09a5c37 (diff)
ask before overwriting profiles
Diffstat (limited to 'src')
-rw-r--r--src/GipfelWidget.H2
-rw-r--r--src/GipfelWidget.cxx8
-rw-r--r--src/gipfel.cxx9
3 files changed, 16 insertions, 3 deletions
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H
index 3671a87..7d1b5ba 100644
--- a/src/GipfelWidget.H
+++ b/src/GipfelWidget.H
@@ -128,7 +128,7 @@ class GipfelWidget : public Fl_Widget {
int get_distortion_profile_name(char *buf, int buflen);
- int save_distortion_params(const char *prof_name);
+ int save_distortion_params(const char *prof_name, int force);
int load_distortion_params(const char *prof_name);
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index a8efa97..2127e64 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -807,9 +807,15 @@ GipfelWidget::load_distortion_params(const char *prof_name) {
}
int
-GipfelWidget::save_distortion_params(const char *prof_name) {
+GipfelWidget::save_distortion_params(const char *prof_name, int force) {
+ int dummy;
Fl_Preferences prof(dist_prefs, prof_name);
+
+ if (!force && (prof.get("k0", dummy, 0) == 0)) {
+ return 1;
+ }
+
prof.set("k0", pan->parms.k0);
prof.set("k1", pan->parms.k1);
diff --git a/src/gipfel.cxx b/src/gipfel.cxx
index 2fcce48..108c3ad 100644
--- a/src/gipfel.cxx
+++ b/src/gipfel.cxx
@@ -176,6 +176,8 @@ void save_distortion_cb(Fl_Widget *, void *) {
const char * prof_name;
double k0, k1;
+ buf[0] = '\0';
+
gipf->get_distortion_params(&k0, &k1);
gipf->get_distortion_profile_name(buf, sizeof(buf));
prof_name = fl_input("Save Distortion Profile (k0=%f, k1=%f)",
@@ -185,7 +187,12 @@ void save_distortion_cb(Fl_Widget *, void *) {
return;
}
- gipf->save_distortion_params(prof_name);
+ if (gipf->save_distortion_params(prof_name, 0) != 0) {
+ if (fl_choice("A profile with this name exists.\n",
+ "Cancel", "Overwrite", NULL) == 1) {
+ gipf->save_distortion_params(prof_name, 1);
+ }
+ }
set_values();
}