[DEV] sava and close multiple file done
This commit is contained in:
parent
9ca83d1718
commit
872fde6bc2
@ -20,6 +20,7 @@
|
||||
|
||||
appl::GlyphPainting::GlyphPainting(const std::string& _filename) :
|
||||
ewol::Resource(_filename) {
|
||||
addObjectType("appl::GlyphPainting");
|
||||
EWOL_DEBUG("SFP : load \"" << _filename << "\"");
|
||||
reload();
|
||||
}
|
||||
|
@ -22,9 +22,6 @@ namespace appl {
|
||||
GlyphPainting(const std::string& _filename);
|
||||
virtual ~GlyphPainting(void);
|
||||
public:
|
||||
const char* getType(void) {
|
||||
return "appl::GlyphPainting";
|
||||
};
|
||||
/**
|
||||
* @brief Load or reload data from config
|
||||
*/
|
||||
|
@ -271,6 +271,7 @@ MainWindows::MainWindows(void) {
|
||||
|
||||
|
||||
// Generic event ...
|
||||
registerMultiCast(ednMsgGuiSave);
|
||||
registerMultiCast(ednMsgGuiSaveAs);
|
||||
registerMultiCast(ednMsgProperties);
|
||||
registerMultiCast(ednMsgGuiNew);
|
||||
@ -360,84 +361,21 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
APPL_DEBUG("Request saving the file : " << _msg.getData());
|
||||
if (to_lower(_msg.getData()) == "current") {
|
||||
appl::WorkerSaveFile* tmpWorker = new appl::WorkerSaveFile("", false);
|
||||
#if 0
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->getBufferSelected();
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_WARNING("No buffer selected !!! ");
|
||||
createPopUpMessage(ewol::Windows::messageTypeError, "No buffer selected !!!");
|
||||
return;
|
||||
}
|
||||
// Note : for direct saving, we do not chack the saving status ==> all time saving ...
|
||||
if (tmpBuffer->hasFileName() == false) {
|
||||
saveAsPopUp(tmpBuffer);
|
||||
return;
|
||||
}
|
||||
if (tmpBuffer->storeFile() == false) {
|
||||
displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>");
|
||||
APPL_ERROR("can not save the file !!! '" << tmpBuffer->getFileName() << "'");
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
} else if (to_lower(_msg.getData()) == "all") {
|
||||
appl::WorkerSaveAllFile* tmpWorker = new appl::WorkerSaveAllFile();
|
||||
#if 0
|
||||
APPL_TODO("Need to save all the buffers ... ");
|
||||
for (esize_t iii=0; iii < m_bufferManager->size(); ++iii) {
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->get(iii);
|
||||
if (tmpBuffer == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->isModify() == false) {
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->hasFileName() == false) {
|
||||
// TODO : Has no name ==> must generate a save AS !!!
|
||||
APPL_TODO("Has no name ==> must generate a save AS");
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->storeFile() == false) {
|
||||
displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>");
|
||||
APPL_ERROR("can not save the file !!! '" << tmpBuffer->getFileName() << "'");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
} else {
|
||||
APPL_ERROR("UNKNOW request : " << _msg);
|
||||
}
|
||||
} else if (_msg.getMessage() == ednMsgGuiSaveAs) {
|
||||
appl::WorkerSaveFile* tmpWorker = new appl::WorkerSaveFile("", true);
|
||||
#if 0
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->getBufferSelected();
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer ... " << _msg.getData());
|
||||
return;
|
||||
}
|
||||
saveAsPopUp(tmpBuffer);
|
||||
#endif
|
||||
} else if (_msg.getMessage() == ednMsgGuiClose) {
|
||||
// Get a ref on the buffer selected (if null, no buffer was selected ...)
|
||||
if (_msg.getData() == "current") {
|
||||
appl::WorkerCloseFile* tmpWorker = new appl::WorkerCloseFile("");
|
||||
#if 0
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->getBufferSelected();
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer ... " << _msg.getData());
|
||||
return;
|
||||
}
|
||||
if (tmpBuffer->isModify() == true) {
|
||||
closeNotSavedFile(tmpBuffer);
|
||||
} else {
|
||||
tmpBuffer->removeObject();
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// ALL !!!
|
||||
appl::WorkerCloseAllFile* tmpWorker = new appl::WorkerCloseAllFile();
|
||||
#if 0
|
||||
// TODO : How to generate the save for all ...
|
||||
APPL_TODO("Close all the buffer.");
|
||||
#endif
|
||||
}
|
||||
} else if (_msg.getMessage() == mainWindowsRequestSaveFile) { // return after a choice of close...
|
||||
if (m_bufferManager->exist(_msg.getData()) == false) {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <ewol/widget/Spacer.h>
|
||||
#include <ewol/widget/Image.h>
|
||||
#include <ewol/widget/WidgetManager.h>
|
||||
#include <etk/Vector.h>
|
||||
#include <vector>
|
||||
#include <etk/tool.h>
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
|
@ -419,6 +419,13 @@ bool appl::TextViewer::onEventInput(const ewol::EventInput& _event) {
|
||||
if (relativePos.x()<0) {
|
||||
relativePos.setX(0);
|
||||
}
|
||||
if ( _event.getId() == 12
|
||||
&& _event.getStatus() == ewol::keyEvent::statusSingle) {
|
||||
APPL_DEBUG("kjhkjhkjh");
|
||||
// Rat5 save event
|
||||
sendMultiCast(ednMsgGuiSave, "current");
|
||||
return true;
|
||||
}
|
||||
// just forward event == > manage directly in the buffer
|
||||
if (_event.getId() == 1) {
|
||||
// mouse selection :
|
||||
|
@ -23,6 +23,7 @@ static const char* s_saveAsDone = "save-as-done";
|
||||
|
||||
appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
|
||||
m_bufferName(_bufferName),
|
||||
m_buffer(NULL),
|
||||
m_worker(NULL),
|
||||
m_bufferManager(NULL) {
|
||||
addEventId(eventCloseDone);
|
||||
@ -49,16 +50,15 @@ appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
|
||||
if (tmpBuffer == NULL) {
|
||||
m_buffer = m_bufferManager->get(m_bufferName);
|
||||
if (m_buffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
if (tmpBuffer->isModify() == false) {
|
||||
tmpBuffer->removeObject();
|
||||
if (m_buffer->isModify() == false) {
|
||||
generateEventId(eventCloseDone);
|
||||
autoDestroy();
|
||||
m_buffer->removeObject();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -68,21 +68,21 @@ appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
|
||||
return;
|
||||
}
|
||||
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
|
||||
tmpPopUp->setComment("The file named : <i>\"" + tmpBuffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
|
||||
tmpPopUp->setComment("The file named : <i>\"" + m_buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
|
||||
ewol::Widget* bt = NULL;
|
||||
if (tmpBuffer->hasFileName() == true) {
|
||||
if (m_buffer->hasFileName() == true) {
|
||||
bt = tmpPopUp->addButton("Save", true);
|
||||
if (bt != NULL) {
|
||||
bt->registerOnEvent(this, widget::Button::eventPressed, s_saveValidate, tmpBuffer->getFileName());
|
||||
bt->registerOnEvent(this, widget::Button::eventPressed, s_saveValidate);
|
||||
}
|
||||
}
|
||||
bt = tmpPopUp->addButton("Save As", true);
|
||||
if (bt != NULL) {
|
||||
bt->registerOnEvent(this, widget::Button::eventPressed, s_saveAsValidate, tmpBuffer->getFileName());
|
||||
bt->registerOnEvent(this, widget::Button::eventPressed, s_saveAsValidate);
|
||||
}
|
||||
bt = tmpPopUp->addButton("Close", true);
|
||||
if (bt != NULL) {
|
||||
bt->registerOnEvent(this, widget::Button::eventPressed, s_closeValidate, tmpBuffer->getFileName());
|
||||
bt->registerOnEvent(this, widget::Button::eventPressed, s_closeValidate);
|
||||
}
|
||||
tmpPopUp->addButton("Cancel", true);
|
||||
tmpPopUp->setRemoveOnExternClick(true);
|
||||
@ -106,46 +106,34 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
}
|
||||
APPL_DEBUG("have message : " << _msg);
|
||||
if (_msg.getMessage() == s_saveAsValidate) {
|
||||
|
||||
appl::WorkerSaveFile* tmpWorker = new appl::WorkerSaveFile(m_bufferName);
|
||||
m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone);
|
||||
m_worker = new appl::WorkerSaveFile(m_bufferName);
|
||||
if (m_worker != NULL) {
|
||||
m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone);
|
||||
}
|
||||
} else if (_msg.getMessage() == s_saveValidate) {
|
||||
if (m_bufferManager->exist(m_bufferName) == false) {
|
||||
APPL_ERROR("Try to close an non-existant file :" << m_bufferName);
|
||||
if (m_buffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer : oldName=" << m_bufferName);
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
if (tmpBuffer->storeFile() == false) {
|
||||
if (m_buffer->storeFile() == false) {
|
||||
ewol::Windows* tmpWindows = ewol::getContext().getWindows();
|
||||
if (tmpWindows == NULL) {
|
||||
return;
|
||||
}
|
||||
tmpWindows->displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>");
|
||||
tmpWindows->displayWarningMessage("We can not save the file : <br/><i>" + m_buffer->getFileName() + "</i>");
|
||||
} else {
|
||||
generateEventId(eventCloseDone);
|
||||
}
|
||||
} else if ( _msg.getMessage() == s_closeValidate
|
||||
|| _msg.getMessage() == s_saveAsDone) {
|
||||
if (m_bufferManager->exist(m_bufferName) == false) {
|
||||
APPL_ERROR("Try to close an non-existant file :" << m_bufferName);
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
|
||||
if (tmpBuffer == NULL) {
|
||||
if (m_buffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
tmpBuffer->removeObject();
|
||||
generateEventId(eventCloseDone);
|
||||
tmpBuffer = NULL;
|
||||
m_buffer->removeObject();
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,6 +145,9 @@ void appl::WorkerCloseFile::onObjectRemove(ewol::EObject* _removeObject) {
|
||||
} else if (_removeObject == m_bufferManager) {
|
||||
m_bufferManager = NULL;
|
||||
autoDestroy();
|
||||
} else if (_removeObject == m_buffer) {
|
||||
m_buffer = NULL;
|
||||
autoDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ namespace appl {
|
||||
virtual ~WorkerCloseFile(void);
|
||||
private:
|
||||
std::string m_bufferName;
|
||||
appl::Buffer* m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer
|
||||
appl::WorkerSaveFile* m_worker; //! sub-worker element...
|
||||
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
|
||||
public: // derived function
|
||||
|
@ -16,7 +16,7 @@ class HighlightPattern;
|
||||
|
||||
#include <etk/RegExp.h>
|
||||
#include <appl/GlyphPainting.h>
|
||||
#include <etk/Vector.h>
|
||||
#include <vector>
|
||||
#include <exml/exml.h>
|
||||
#include <etk/Buffer.h>
|
||||
|
||||
|
@ -109,6 +109,9 @@ etk::CCout& operator <<(etk::CCout& _os, const std::regex_error& _e) {
|
||||
bool APP_Init(ewol::eContext& _context) {
|
||||
APPL_INFO(" == > init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
|
||||
|
||||
//etk::theme::setName("COLOR", "colorBlack/");
|
||||
etk::theme::setName("COLOR", "colorWhite/");
|
||||
|
||||
// TODO : remove this : Move if in the windows properties
|
||||
_context.setSize(vec2(800, 600));
|
||||
|
||||
@ -123,9 +126,6 @@ bool APP_Init(ewol::eContext& _context) {
|
||||
// set the application icon ...
|
||||
_context.setIcon("DATA:icon.png");
|
||||
|
||||
etk::theme::setName("COLOR", "colorBlack/");
|
||||
etk::theme::setName("COLOR", "colorWhite/");
|
||||
|
||||
// init internal global value
|
||||
globals::init();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user