From 958a04bd86b0911a1298d85110e55f08c33c6f98 Mon Sep 17 00:00:00 2001 From: fredrik Date: Mon, 7 May 2007 19:50:24 +0000 Subject: [PATCH] Check dirty var. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@1023 959494ce-11ee-0310-bf91-de5d638817bd --- config/dolconf.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/config/dolconf.c b/config/dolconf.c index 3a2a95a..629752f 100644 --- a/config/dolconf.c +++ b/config/dolconf.c @@ -498,6 +498,23 @@ void cfw2conf(void) } } +struct cfvar *cfwvalid(void) +{ + struct cfvar *cv; + + for(cv = config; cv->name != NULL; cv++) { + if((cv->vld != NULL) && !cv->vld->check(cv->val)) { + if(cv->rname) { + return(cv); + } else { + msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Internal error (Auto-generated variable %s has an invalid value \"%s\")"), cv->name, cv->val); + abort(); + } + } + } + return(NULL); +} + void astcancel(GtkWidget *widget, gpointer uudata) { if(ignoreclose) @@ -703,15 +720,9 @@ void cb_cfw_save_activate(GtkWidget *widget, gpointer uudata) { struct cfvar *cv; - for(cv = config; cv->name != NULL; cv++) { - if((cv->vld != NULL) && !cv->vld->check(cv->val)) { - if(cv->rname) { - msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, cv->vld->invmsg, cv->rname); - } else { - msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Internal error (Auto-generated variable %s has an invalid value \"%s\")"), cv->name, cv->val); - } - return; - } + if((cv = cfwvalid()) != NULL) { + msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, cv->vld->invmsg, cv->rname); + return; } cfw2conf(); writeconfig(); @@ -719,6 +730,12 @@ void cb_cfw_save_activate(GtkWidget *widget, gpointer uudata) void cb_cfw_quit_activate(GtkWidget *widget, gpointer uudata) { + + cfw2conf(); + if(dirty) { + if(msgbox(GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, _("There are unsaved settings. Do you wish to discard the changes and exit anyway?")) == GTK_RESPONSE_NO) + return; + } gtk_main_quit(); state = -1; } -- 2.11.0