[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) :
|
appl::GlyphPainting::GlyphPainting(const std::string& _filename) :
|
||||||
ewol::Resource(_filename) {
|
ewol::Resource(_filename) {
|
||||||
|
addObjectType("appl::GlyphPainting");
|
||||||
EWOL_DEBUG("SFP : load \"" << _filename << "\"");
|
EWOL_DEBUG("SFP : load \"" << _filename << "\"");
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,6 @@ namespace appl {
|
|||||||
GlyphPainting(const std::string& _filename);
|
GlyphPainting(const std::string& _filename);
|
||||||
virtual ~GlyphPainting(void);
|
virtual ~GlyphPainting(void);
|
||||||
public:
|
public:
|
||||||
const char* getType(void) {
|
|
||||||
return "appl::GlyphPainting";
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* @brief Load or reload data from config
|
* @brief Load or reload data from config
|
||||||
*/
|
*/
|
||||||
|
@ -271,6 +271,7 @@ MainWindows::MainWindows(void) {
|
|||||||
|
|
||||||
|
|
||||||
// Generic event ...
|
// Generic event ...
|
||||||
|
registerMultiCast(ednMsgGuiSave);
|
||||||
registerMultiCast(ednMsgGuiSaveAs);
|
registerMultiCast(ednMsgGuiSaveAs);
|
||||||
registerMultiCast(ednMsgProperties);
|
registerMultiCast(ednMsgProperties);
|
||||||
registerMultiCast(ednMsgGuiNew);
|
registerMultiCast(ednMsgGuiNew);
|
||||||
@ -360,84 +361,21 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
|
|||||||
APPL_DEBUG("Request saving the file : " << _msg.getData());
|
APPL_DEBUG("Request saving the file : " << _msg.getData());
|
||||||
if (to_lower(_msg.getData()) == "current") {
|
if (to_lower(_msg.getData()) == "current") {
|
||||||
appl::WorkerSaveFile* tmpWorker = new appl::WorkerSaveFile("", false);
|
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;
|
return;
|
||||||
} else if (to_lower(_msg.getData()) == "all") {
|
} else if (to_lower(_msg.getData()) == "all") {
|
||||||
appl::WorkerSaveAllFile* tmpWorker = new appl::WorkerSaveAllFile();
|
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;
|
return;
|
||||||
} else {
|
} else {
|
||||||
APPL_ERROR("UNKNOW request : " << _msg);
|
APPL_ERROR("UNKNOW request : " << _msg);
|
||||||
}
|
}
|
||||||
} else if (_msg.getMessage() == ednMsgGuiSaveAs) {
|
} else if (_msg.getMessage() == ednMsgGuiSaveAs) {
|
||||||
appl::WorkerSaveFile* tmpWorker = new appl::WorkerSaveFile("", true);
|
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) {
|
} else if (_msg.getMessage() == ednMsgGuiClose) {
|
||||||
// Get a ref on the buffer selected (if null, no buffer was selected ...)
|
// Get a ref on the buffer selected (if null, no buffer was selected ...)
|
||||||
if (_msg.getData() == "current") {
|
if (_msg.getData() == "current") {
|
||||||
appl::WorkerCloseFile* tmpWorker = new appl::WorkerCloseFile("");
|
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 {
|
} else {
|
||||||
tmpBuffer->removeObject();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
// ALL !!!
|
|
||||||
appl::WorkerCloseAllFile* tmpWorker = new appl::WorkerCloseAllFile();
|
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...
|
} else if (_msg.getMessage() == mainWindowsRequestSaveFile) { // return after a choice of close...
|
||||||
if (m_bufferManager->exist(_msg.getData()) == false) {
|
if (m_bufferManager->exist(_msg.getData()) == false) {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <ewol/widget/Spacer.h>
|
#include <ewol/widget/Spacer.h>
|
||||||
#include <ewol/widget/Image.h>
|
#include <ewol/widget/Image.h>
|
||||||
#include <ewol/widget/WidgetManager.h>
|
#include <ewol/widget/WidgetManager.h>
|
||||||
#include <etk/Vector.h>
|
#include <vector>
|
||||||
#include <etk/tool.h>
|
#include <etk/tool.h>
|
||||||
#include <ewol/widget/Button.h>
|
#include <ewol/widget/Button.h>
|
||||||
#include <ewol/widget/Label.h>
|
#include <ewol/widget/Label.h>
|
||||||
|
@ -419,6 +419,13 @@ bool appl::TextViewer::onEventInput(const ewol::EventInput& _event) {
|
|||||||
if (relativePos.x()<0) {
|
if (relativePos.x()<0) {
|
||||||
relativePos.setX(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
|
// just forward event == > manage directly in the buffer
|
||||||
if (_event.getId() == 1) {
|
if (_event.getId() == 1) {
|
||||||
// mouse selection :
|
// mouse selection :
|
||||||
|
@ -23,6 +23,7 @@ static const char* s_saveAsDone = "save-as-done";
|
|||||||
|
|
||||||
appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
|
appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
|
||||||
m_bufferName(_bufferName),
|
m_bufferName(_bufferName),
|
||||||
|
m_buffer(NULL),
|
||||||
m_worker(NULL),
|
m_worker(NULL),
|
||||||
m_bufferManager(NULL) {
|
m_bufferManager(NULL) {
|
||||||
addEventId(eventCloseDone);
|
addEventId(eventCloseDone);
|
||||||
@ -49,16 +50,15 @@ appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
|
|||||||
autoDestroy();
|
autoDestroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
|
m_buffer = m_bufferManager->get(m_bufferName);
|
||||||
if (tmpBuffer == NULL) {
|
if (m_buffer == NULL) {
|
||||||
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
||||||
autoDestroy();
|
autoDestroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tmpBuffer->isModify() == false) {
|
if (m_buffer->isModify() == false) {
|
||||||
tmpBuffer->removeObject();
|
|
||||||
generateEventId(eventCloseDone);
|
generateEventId(eventCloseDone);
|
||||||
autoDestroy();
|
m_buffer->removeObject();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,21 +68,21 @@ appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
|
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;
|
ewol::Widget* bt = NULL;
|
||||||
if (tmpBuffer->hasFileName() == true) {
|
if (m_buffer->hasFileName() == true) {
|
||||||
bt = tmpPopUp->addButton("Save", true);
|
bt = tmpPopUp->addButton("Save", true);
|
||||||
if (bt != NULL) {
|
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);
|
bt = tmpPopUp->addButton("Save As", true);
|
||||||
if (bt != NULL) {
|
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);
|
bt = tmpPopUp->addButton("Close", true);
|
||||||
if (bt != NULL) {
|
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->addButton("Cancel", true);
|
||||||
tmpPopUp->setRemoveOnExternClick(true);
|
tmpPopUp->setRemoveOnExternClick(true);
|
||||||
@ -106,46 +106,34 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::EMessage& _msg) {
|
|||||||
}
|
}
|
||||||
APPL_DEBUG("have message : " << _msg);
|
APPL_DEBUG("have message : " << _msg);
|
||||||
if (_msg.getMessage() == s_saveAsValidate) {
|
if (_msg.getMessage() == s_saveAsValidate) {
|
||||||
|
m_worker = new appl::WorkerSaveFile(m_bufferName);
|
||||||
appl::WorkerSaveFile* tmpWorker = new appl::WorkerSaveFile(m_bufferName);
|
if (m_worker != NULL) {
|
||||||
m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone);
|
m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone);
|
||||||
|
}
|
||||||
} else if (_msg.getMessage() == s_saveValidate) {
|
} else if (_msg.getMessage() == s_saveValidate) {
|
||||||
if (m_bufferManager->exist(m_bufferName) == false) {
|
if (m_buffer == NULL) {
|
||||||
APPL_ERROR("Try to close an non-existant file :" << m_bufferName);
|
APPL_ERROR("Error to get the buffer : oldName=" << m_bufferName);
|
||||||
autoDestroy();
|
autoDestroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
|
if (m_buffer->storeFile() == false) {
|
||||||
if (tmpBuffer == NULL) {
|
|
||||||
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
|
||||||
autoDestroy();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (tmpBuffer->storeFile() == false) {
|
|
||||||
ewol::Windows* tmpWindows = ewol::getContext().getWindows();
|
ewol::Windows* tmpWindows = ewol::getContext().getWindows();
|
||||||
if (tmpWindows == NULL) {
|
if (tmpWindows == NULL) {
|
||||||
return;
|
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 {
|
} else {
|
||||||
generateEventId(eventCloseDone);
|
generateEventId(eventCloseDone);
|
||||||
}
|
}
|
||||||
} else if ( _msg.getMessage() == s_closeValidate
|
} else if ( _msg.getMessage() == s_closeValidate
|
||||||
|| _msg.getMessage() == s_saveAsDone) {
|
|| _msg.getMessage() == s_saveAsDone) {
|
||||||
if (m_bufferManager->exist(m_bufferName) == false) {
|
if (m_buffer == NULL) {
|
||||||
APPL_ERROR("Try to close an non-existant file :" << m_bufferName);
|
|
||||||
autoDestroy();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
|
|
||||||
if (tmpBuffer == NULL) {
|
|
||||||
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
||||||
autoDestroy();
|
autoDestroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tmpBuffer->removeObject();
|
|
||||||
generateEventId(eventCloseDone);
|
generateEventId(eventCloseDone);
|
||||||
tmpBuffer = NULL;
|
m_buffer->removeObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +145,9 @@ void appl::WorkerCloseFile::onObjectRemove(ewol::EObject* _removeObject) {
|
|||||||
} else if (_removeObject == m_bufferManager) {
|
} else if (_removeObject == m_bufferManager) {
|
||||||
m_bufferManager = NULL;
|
m_bufferManager = NULL;
|
||||||
autoDestroy();
|
autoDestroy();
|
||||||
|
} else if (_removeObject == m_buffer) {
|
||||||
|
m_buffer = NULL;
|
||||||
|
autoDestroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ namespace appl {
|
|||||||
virtual ~WorkerCloseFile(void);
|
virtual ~WorkerCloseFile(void);
|
||||||
private:
|
private:
|
||||||
std::string m_bufferName;
|
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::WorkerSaveFile* m_worker; //! sub-worker element...
|
||||||
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
|
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
|
||||||
public: // derived function
|
public: // derived function
|
||||||
|
@ -16,7 +16,7 @@ class HighlightPattern;
|
|||||||
|
|
||||||
#include <etk/RegExp.h>
|
#include <etk/RegExp.h>
|
||||||
#include <appl/GlyphPainting.h>
|
#include <appl/GlyphPainting.h>
|
||||||
#include <etk/Vector.h>
|
#include <vector>
|
||||||
#include <exml/exml.h>
|
#include <exml/exml.h>
|
||||||
#include <etk/Buffer.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) {
|
bool APP_Init(ewol::eContext& _context) {
|
||||||
APPL_INFO(" == > init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
|
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
|
// TODO : remove this : Move if in the windows properties
|
||||||
_context.setSize(vec2(800, 600));
|
_context.setSize(vec2(800, 600));
|
||||||
|
|
||||||
@ -123,9 +126,6 @@ bool APP_Init(ewol::eContext& _context) {
|
|||||||
// set the application icon ...
|
// set the application icon ...
|
||||||
_context.setIcon("DATA:icon.png");
|
_context.setIcon("DATA:icon.png");
|
||||||
|
|
||||||
etk::theme::setName("COLOR", "colorBlack/");
|
|
||||||
etk::theme::setName("COLOR", "colorWhite/");
|
|
||||||
|
|
||||||
// init internal global value
|
// init internal global value
|
||||||
globals::init();
|
globals::init();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user