The "SaveAs" feature was saving the image even if the filename field was leaved empty, because it was automatically adding the format suffix.
The SaveAsDialog is now most secured too: no empty filename field is allowed when pressing OK.
This commit is contained in:
@@ -974,10 +974,12 @@ void EditorPanel::saveAsPressed () {
|
|||||||
saveAsDialog->setInitialFileName (removeExtension (Glib::path_get_basename (openThm->getFileName())));
|
saveAsDialog->setInitialFileName (removeExtension (Glib::path_get_basename (openThm->getFileName())));
|
||||||
do {
|
do {
|
||||||
saveAsDialog->run ();
|
saveAsDialog->run ();
|
||||||
fname = saveAsDialog->getFileName ();
|
if (saveAsDialog->getResponse()==Gtk::RESPONSE_CANCEL)
|
||||||
if (fname=="")
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// The SaveAsDialog ensure that a filename has been specified
|
||||||
|
fname = saveAsDialog->getFileName ();
|
||||||
|
|
||||||
options.lastSaveAsPath = saveAsDialog->getDirectory ();
|
options.lastSaveAsPath = saveAsDialog->getDirectory ();
|
||||||
options.saveAsDialogWidth = saveAsDialog->get_width();
|
options.saveAsDialogWidth = saveAsDialog->get_width();
|
||||||
options.saveAsDialogHeight = saveAsDialog->get_height();
|
options.saveAsDialogHeight = saveAsDialog->get_height();
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#include "saveasdlg.h"
|
#include "saveasdlg.h"
|
||||||
#include <multilangmgr.h>
|
#include <multilangmgr.h>
|
||||||
#include <guiutils.h>
|
#include <guiutils.h>
|
||||||
|
#include <safegtk.h>
|
||||||
|
|
||||||
extern Options options;
|
extern Options options;
|
||||||
SaveAsDialog::SaveAsDialog (Glib::ustring initialDir) {
|
SaveAsDialog::SaveAsDialog (Glib::ustring initialDir) {
|
||||||
@@ -118,7 +119,11 @@ bool SaveAsDialog::getToTailOfQueue () {
|
|||||||
|
|
||||||
Glib::ustring SaveAsDialog::getFileName () {
|
Glib::ustring SaveAsDialog::getFileName () {
|
||||||
|
|
||||||
return removeExtension(fname) + Glib::ustring(".") + formatOpts->getFormat().format;
|
// fname is empty if the dialog has been cancelled
|
||||||
|
if (fname.length())
|
||||||
|
return removeExtension(fname) + Glib::ustring(".") + formatOpts->getFormat().format;
|
||||||
|
else
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring SaveAsDialog::getDirectory () {
|
Glib::ustring SaveAsDialog::getDirectory () {
|
||||||
@@ -134,12 +139,24 @@ SaveFormat SaveAsDialog::getFormat () {
|
|||||||
void SaveAsDialog::okPressed () {
|
void SaveAsDialog::okPressed () {
|
||||||
|
|
||||||
fname = fchooser->get_filename();
|
fname = fchooser->get_filename();
|
||||||
|
|
||||||
|
// checking if the filename field is empty. The user have to click Cancel if he don't want to specify a filename
|
||||||
|
// NB: There seem to be a bug in Gtkmm2.22 / FileChooserWidget : if you suppress the filename entry and
|
||||||
|
// click on a folder in the list, the filename field is empty but get_filename will return the folder's path :/
|
||||||
|
if (!fname.length() || safe_file_test (fname, Glib::FILE_TEST_IS_DIR)) {
|
||||||
|
Glib::ustring msg_ = Glib::ustring("<b>") + M("MAIN_MSG_EMPTYFILENAME") + "</b>";
|
||||||
|
Gtk::MessageDialog msgd (*this, msg_, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
|
||||||
|
msgd.run ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
response = Gtk::RESPONSE_OK;
|
||||||
hide ();
|
hide ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveAsDialog::cancelPressed () {
|
void SaveAsDialog::cancelPressed () {
|
||||||
|
|
||||||
fname = "";
|
fname = "";
|
||||||
|
response = Gtk::RESPONSE_CANCEL;
|
||||||
hide ();
|
hide ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,6 +37,7 @@ class SaveAsDialog : public Gtk::Dialog, public FormatChangeListener {
|
|||||||
Gtk::RadioButton* immediately;
|
Gtk::RadioButton* immediately;
|
||||||
Gtk::RadioButton* putToQueueHead;
|
Gtk::RadioButton* putToQueueHead;
|
||||||
Gtk::RadioButton* putToQueueTail;
|
Gtk::RadioButton* putToQueueTail;
|
||||||
|
Gtk::ResponseType response;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SaveAsDialog (Glib::ustring initialDir);
|
SaveAsDialog (Glib::ustring initialDir);
|
||||||
@@ -50,6 +51,7 @@ class SaveAsDialog : public Gtk::Dialog, public FormatChangeListener {
|
|||||||
bool getToTailOfQueue ();
|
bool getToTailOfQueue ();
|
||||||
|
|
||||||
void setInitialFileName (Glib::ustring iname);
|
void setInitialFileName (Glib::ustring iname);
|
||||||
|
Gtk::ResponseType getResponse () { return response; };
|
||||||
|
|
||||||
void okPressed ();
|
void okPressed ();
|
||||||
void cancelPressed ();
|
void cancelPressed ();
|
||||||
|
Reference in New Issue
Block a user