Esempio n. 1
0
void CloseEditorCmd::Execute () {
    Editor* ed = GetEditor();
    Iterator i;
    unidraw->First(i);
    unidraw->Next(i);

    if (!unidraw->Done(i)) {
	ModifStatusVar* mv = (ModifStatusVar*) ed->GetState("ModifStatusVar");

	if (mv != nil && mv->GetModifStatus() && !FoundAnyExcept(ed)) {
            ConfirmDialog dialog("Save changes?");

	    ed->InsertDialog(&dialog);
	    char resp = dialog.Confirm();
	    ed->RemoveDialog(&dialog);

	    if (resp == '\007') {
		return;

            } else if (resp == 'y') {
		SaveCompCmd saveComp(ed);
		saveComp.Execute();

                if (mv->GetModifStatus()) {
                    return;                         // save dialog was aborted
                }
	    }
	}
        unidraw->Close(ed);
    }
}
Esempio n. 2
0
static boolean ReadyToClose (Editor* ed) {
    ModifStatusVar* mv = (ModifStatusVar*) ed->GetState("ModifStatusVar");

    if (mv != nil && Writable(mv->GetComponent()) && mv->GetModifStatus()) {
        ConfirmDialog dialog("Save changes?");

        ed->InsertDialog(&dialog);
        char resp = dialog.Confirm();
        ed->RemoveDialog(&dialog);

        if (resp == '\007') {
            return false;                       // confirm dialog aborted

        } else if (resp == 'y') {
            SaveCompCmd saveComp(ed);
            saveComp.Execute();

            if (mv->GetModifStatus()) {
                return false;                   // save dialog was aborted
            }
        }
    }
    return true;
}