edn/sources/appl/Gui/MainWindows.cpp

544 lines
21 KiB
C++
Raw Normal View History

/**
* @author Edouard DUPIN
2012-11-25 11:55:06 +01:00
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
2012-11-25 11:55:06 +01:00
2013-10-25 20:49:26 +02:00
#include <appl/debug.h>
2012-04-24 09:42:14 +02:00
#include <appl/global.h>
2013-11-23 18:30:52 +01:00
#include <appl/Gui/MainWindows.h>
#include <appl/Gui/BufferView.h>
#include <appl/Gui/TextViewer.h>
#include <appl/Gui/Search.h>
#include <ewol/widget/Button.h>
#include <ewol/widget/CheckBox.h>
#include <ewol/widget/Sizer.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/Entry.h>
#include <ewol/widget/List.h>
2012-02-16 18:18:04 +01:00
#include <ewol/widget/ContextMenu.h>
#include <ewol/widget/PopUp.h>
#include <ewol/widget/Spacer.h>
2012-09-07 16:31:49 +02:00
#include <ewol/widget/Slider.h>
2012-02-16 23:29:48 +01:00
#include <ewol/widget/Menu.h>
#include <ewol/widget/meta/FileChooser.h>
#include <ewol/widget/meta/Parameter.h>
2013-12-13 21:50:40 +01:00
#include <ewol/widget/Manager.h>
#include <ewol/object/Object.h>
#include <ewol/context/Context.h>
#include <date/date.h>
#include <ewol/widget/meta/StdPopUp.h>
#include <appl/Gui/WorkerSaveFile.h>
#include <appl/Gui/WorkerSaveAllFile.h>
#include <appl/Gui/WorkerCloseFile.h>
#include <appl/Gui/WorkerCloseAllFile.h>
2013-11-23 18:30:52 +01:00
namespace appl {
std::string getVersion() {
#define FIRST_YEAR (2010)
2014-08-13 22:30:47 +02:00
std::string tmpOutput = etk::to_string(date::getYear()-FIRST_YEAR);
tmpOutput += ".";
2014-08-13 22:30:47 +02:00
tmpOutput += etk::to_string(date::getMonth());
tmpOutput += ".";
2014-08-13 22:30:47 +02:00
tmpOutput += etk::to_string(date::getDay());
return tmpOutput;
}
}
2012-07-24 13:01:40 +02:00
#undef __class__
#define __class__ "AboutGui"
#include <ewol/widget/Label.h>
#include <ewol/widget/Spacer.h>
2013-12-13 21:50:40 +01:00
class ParameterAboutGui : public ewol::widget::Sizer {
2012-07-24 13:01:40 +02:00
public :
ParameterAboutGui() {
addObjectType("appl::ParameterAboutGui");
}
void init() {
ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
std::shared_ptr<ewol::widget::Spacer> mySpacer;
2012-07-24 13:01:40 +02:00
mySpacer = ewol::widget::Spacer::create();
2014-06-05 22:01:24 +02:00
if (nullptr == mySpacer) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-24 13:01:40 +02:00
} else {
2016-02-15 22:04:10 +01:00
mySpacer->propertyExpand.set(bvec2(true,true));
2013-10-07 22:04:21 +02:00
subWidgetAdd(mySpacer);
2012-07-24 13:01:40 +02:00
}
2013-11-14 21:57:10 +01:00
std::string tmpLabel = "<left>";
tmpLabel += " <b>Editeur De N'ours</b> : v:";
2013-10-07 22:04:21 +02:00
tmpLabel += appl::getVersion();
tmpLabel += "<br/>";
tmpLabel += " <b>Build Time</b> : ";
2013-10-07 22:04:21 +02:00
tmpLabel += date::getYear();
tmpLabel += "/";
2013-10-07 22:04:21 +02:00
tmpLabel += date::getMonth();
tmpLabel += "/";
2013-10-07 22:04:21 +02:00
tmpLabel += date::getDay();
tmpLabel += " ";
2013-10-07 22:04:21 +02:00
tmpLabel += date::getHour();
tmpLabel += "h";
2013-10-07 22:04:21 +02:00
tmpLabel += date::getMinute();
tmpLabel += "<br/>";
tmpLabel += " <b>Website</b> : https://github.com/HeeroYui/edn<br/>";
tmpLabel += " <b>License</b> : GPL v3<br/>";
tmpLabel += " <b>Copyright</b> : 2010 Edouard DUPIN<br/>";
tmpLabel += "<br/>";
tmpLabel += " dependency librairies :<br/>";
tmpLabel += " libPng, ogg-tremor, portaudio, libZip<br/>";
tmpLabel += " tinyXml, freetype, agg2.4, etk<br/>";
tmpLabel += "</left>";
std::shared_ptr<ewol::widget::Label> myLabel = ewol::widget::Label::create(tmpLabel);
2014-06-05 22:01:24 +02:00
if (nullptr == myLabel) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-24 13:01:40 +02:00
} else {
2016-02-15 22:04:10 +01:00
myLabel->propertyExpand.set(bvec2(true,false));
2013-10-07 22:04:21 +02:00
subWidgetAdd(myLabel);
2012-07-24 13:01:40 +02:00
}
};
~ParameterAboutGui() {
2013-10-09 22:00:24 +02:00
};
2012-07-24 13:01:40 +02:00
};
// Local main windows event :
static const char* mainWindowsRequestSaveFile = "appl-event-main-windows-save-file";
static const char* mainWindowsRequestSaveFileAs = "appl-event-main-windows-save-file-as";
static const char* mainWindowsRequestcloseFileNoCheck = "appl-event-main-windows-close-file-no-check";
2014-01-18 14:34:33 +01:00
static const char* l_MsgNameGuiChangeShape = "appl-event-main-windows-Change-shape";
2012-07-24 13:01:40 +02:00
const char* l_smoothChick = "tmpEvent_smooth";
const char* l_smoothMin = "tmpEvent_minChange";
const char* l_smoothMax = "tmpEvent_maxChange";
2012-09-07 16:31:49 +02:00
#undef __class__
2013-10-09 22:00:24 +02:00
#define __class__ "MainWindows"
MainWindows::MainWindows() {
addObjectType("appl::MainWindows");
}
void MainWindows::init() {
ewol::widget::Windows::init();
2012-04-23 10:15:43 +02:00
APPL_DEBUG("CREATE WINDOWS ... ");
std::shared_ptr<ewol::widget::Sizer> mySizerVert;
std::shared_ptr<ewol::widget::Sizer> mySizerVert2;
std::shared_ptr<ewol::widget::Sizer> mySizerHori;
std::shared_ptr<appl::TextViewer> myTextView;
std::shared_ptr<appl::TextViewer> myTextView2;
std::shared_ptr<BufferView> myBufferView;
std::shared_ptr<ewol::widget::Menu> myMenu;
2013-11-07 21:08:57 +01:00
// load buffer manager:
m_bufferManager = appl::BufferManager::create();
m_viewerManager = appl::ViewerManager::create();
2013-11-07 21:08:57 +01:00
mySizerVert = ewol::widget::Sizer::create(ewol::widget::Sizer::modeVert);
2016-02-15 22:04:10 +01:00
mySizerVert->propertyName.set("plop 1111111");
2013-10-07 22:04:21 +02:00
setSubWidget(mySizerVert);
mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
2016-02-15 22:04:10 +01:00
mySizerHori->propertyName.set("plop 222222222");
2013-10-07 22:04:21 +02:00
mySizerVert->subWidgetAdd(mySizerHori);
myBufferView = BufferView::create();
2016-02-15 22:04:10 +01:00
myBufferView->propertyName.set("plop 3333333");
myBufferView->propertyExpand.set(bvec2(false,true));
myBufferView->propertyFill.set(bvec2(true,true));
2013-10-07 22:04:21 +02:00
mySizerHori->subWidgetAdd(myBufferView);
mySizerVert2 = ewol::widget::Sizer::create(ewol::widget::Sizer::modeVert);
2013-10-07 22:04:21 +02:00
mySizerHori->subWidgetAdd(mySizerVert2);
2016-02-15 22:04:10 +01:00
mySizerVert2->propertyName.set("appl-view-code-sizer");
// main buffer Area :
#if defined(__TARGET_OS__Android)
int32_t sizeText = 16;
#else
int32_t sizeText = 11;
#endif
myTextView2 = appl::TextViewer::create("FreeMono;DejaVuSansMono;FreeSerif", sizeText);
2016-02-15 22:04:10 +01:00
myTextView2->propertyName.set("appl-text-viewer2");
myTextView2->propertyExpand.set(bvec2(true,true));
myTextView2->propertyFill.set(bvec2(true,true));
myTextView2->propertyHide.set(true);
mySizerVert2->subWidgetAdd(myTextView2);
myTextView = appl::TextViewer::create("FreeMono;DejaVuSansMono;FreeSerif", sizeText);
2016-02-15 22:04:10 +01:00
myTextView->propertyName.set("appl-text-viewer1");
myTextView->propertyExpand.set(bvec2(true,true));
myTextView->propertyFill.set(bvec2(true,true));
mySizerVert2->subWidgetAdd(myTextView);
// search area :
m_widgetSearch = appl::widget::Search::create();
mySizerVert2->subWidgetAdd(m_widgetSearch);
mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
2016-02-15 22:04:10 +01:00
mySizerHori->propertyName.set("plop 555555");
2013-10-07 22:04:21 +02:00
mySizerVert->subWidgetAdd(mySizerHori);
2012-02-16 23:29:48 +01:00
myMenu = ewol::widget::Menu::create();
2016-02-15 22:04:10 +01:00
myMenu->propertyName.set("appl-menu-interface");
2013-10-07 22:04:21 +02:00
mySizerHori->subWidgetAdd(myMenu);
int32_t idMenuFile = myMenu->addTitle("File");
myMenu->add(idMenuFile, "New", "", "menu:new");
myMenu->addSpacer();
myMenu->add(idMenuFile, "Open", "THEME:GUI:Load.edf", "menu:open");
myMenu->add(idMenuFile, "Close", "THEME:GUI:Close.edf", "menu:close");
myMenu->add(idMenuFile, "Close (all)", "", "menu:close-all");
myMenu->add(idMenuFile, "Save", "THEME:GUI:Save.edf", "menu:save");
myMenu->add(idMenuFile, "Save As ...", "", "menu:save-as");
myMenu->addSpacer();
myMenu->add(idMenuFile, "Properties", "THEME:GUI:Parameter.edf", "menu:property");
2013-10-07 22:04:21 +02:00
int32_t idMenuEdit = myMenu->addTitle("Edit");
myMenu->add(idMenuEdit, "Goto line ...","", "menu:goto-line");
2013-10-07 22:04:21 +02:00
int32_t idMenuSearch = myMenu->addTitle("Search");
myMenu->add(idMenuSearch, "Search", "THEME:GUI:Search.edf", "menu:search");
myMenu->add(idMenuSearch, "Replace", "THEME:GUI:Replace.edf", "menu:replace");
myMenu->addSpacer();
myMenu->add(idMenuSearch, "Find (previous)","", "menu:find:previous");
myMenu->add(idMenuSearch, "Find (next)", "", "menu:find:next");
myMenu->add(idMenuSearch, "Find (all)", "", "menu:find:all");
myMenu->add(idMenuSearch, "Un-Select", "", "menu:find:none");
2013-10-07 22:04:21 +02:00
int32_t idMenugDisplay = myMenu->addTitle("Display");
myMenu->add(idMenugDisplay, "Color Black", "", "menu:color:color/black/");
myMenu->add(idMenugDisplay, "Color White", "", "menu:color:color/white/");
myMenu->add(idMenugDisplay, "Shape square", "", "menu:shape:shape/square/");
myMenu->add(idMenugDisplay, "Shape round", "", "menu:shape:shape/round/");
myMenu->addSpacer();
myMenu->add(idMenugDisplay, "Reload openGl Shader", "", "menu:reloadShape");
myMenu->addSpacer();
myMenu->add(idMenugDisplay, "Split", "", "menu:split:enable");
myMenu->add(idMenugDisplay, "Unsplit", "", "menu:split:disable");
myMenu->add(idMenugDisplay, "Vertical", "", "menu:split:vert");
myMenu->add(idMenugDisplay, "Horizontal", "", "menu:split:hori");
2016-02-19 23:33:00 +01:00
myMenu->signalSelect.connect(shared_from_this(), &MainWindows::onCallbackMenuEvent);
m_widgetLabelFileName = ewol::widget::Label::create("FileName");
2016-02-15 22:04:10 +01:00
m_widgetLabelFileName->propertyName.set("appl-widget-display-name");
m_widgetLabelFileName->propertyExpand.set(bvec2(true,false));
m_widgetLabelFileName->propertyFill.set(bvec2(true,false));;
2013-10-07 22:04:21 +02:00
mySizerHori->subWidgetAdd(m_widgetLabelFileName);
2012-11-25 11:55:06 +01:00
// add generic shortcut ...
shortCutAdd("ctrl+o", "menu:open");
shortCutAdd("ctrl+n", "menu:new");
2012-11-25 11:55:06 +01:00
shortCutAdd("ctrl+s", "menu:save");
shortCutAdd("ctrl+shift+s", "menu:save-all");
2012-11-25 11:55:06 +01:00
shortCutAdd("ctrl+q", "menu:close");
shortCutAdd("ctrl+shift+q", "menu:close-all");
2012-11-25 11:55:06 +01:00
shortCutAdd("ctrl+l", "menu:goto-line");
2012-11-25 11:55:06 +01:00
shortCutAdd("ctrl+f", "menu:search");
shortCutAdd("F12", "menu:reloade-shader");
2016-02-19 23:33:00 +01:00
// TODO : auto-connect on shortcut event ==> maybe do beter later ...
signalShortcut.connect(shared_from_this(), &MainWindows::onCallbackShortCut);
m_bufferManager->signalSelectFile.connect(shared_from_this(), &MainWindows::onCallbackShortCut);
}
MainWindows::~MainWindows() {
2014-05-20 21:35:41 +02:00
}
void MainWindows::onCallbackShortCut(const std::string& _value) {
APPL_WARNING("Event from ShortCut : " << _value);
onCallbackMenuEvent(_value);
}
void MainWindows::onCallbackMenuEvent(const std::string& _value) {
APPL_WARNING("Event from Menu : " << _value);
if (_value == "menu:new") {
if (m_bufferManager != nullptr) {
m_bufferManager->createNewBuffer();
2013-11-07 21:08:57 +01:00
}
} else if (_value == "menu:open") {
displayOpen();
} else if (_value == "menu:close") {
std::shared_ptr<appl::WorkerCloseFile> worker = appl::WorkerCloseFile::create();
worker->startAction("");
} else if (_value == "menu:close-all") {
appl::WorkerCloseAllFile::create();
} else if (_value == "menu:save") {
appl::WorkerSaveFile::create("", false);
} else if (_value == "menu:save-all") {
appl::WorkerSaveAllFile::create();
} else if (_value == "menu:save-as") {
appl::WorkerSaveFile::create("", true);
} else if (_value == "menu:property") {
displayProperty();
} else if (_value == "menu:search") {
if (m_widgetSearch == nullptr) {
2013-11-07 21:08:57 +01:00
return;
}
2016-02-24 22:31:46 +01:00
if (m_widgetSearch->propertyHide.get() == true) {
2016-02-15 22:04:10 +01:00
m_widgetSearch->propertyHide.set(false);
m_widgetSearch->selectSearch();
} else {
if (m_widgetSearch->isSelectSearch()) {
2016-02-15 22:04:10 +01:00
m_widgetSearch->propertyHide.set(true);
if (m_viewerManager != nullptr) {
std::shared_ptr<appl::TextViewer> tmp = m_viewerManager->getViewerSelected();
if (tmp != nullptr) {
tmp->keepFocus();
}
}
} else {
m_widgetSearch->selectSearch();
}
}
} else if (_value == "menu:replace") {
if (m_widgetSearch == nullptr) {
return;
2013-11-07 21:08:57 +01:00
}
2016-02-24 22:31:46 +01:00
if (m_widgetSearch->propertyHide.get() == true) {
2016-02-15 22:04:10 +01:00
m_widgetSearch->propertyHide.set(false);
m_widgetSearch->selectReplace();
} else {
if (m_widgetSearch->isSelectReplace()) {
2016-02-15 22:04:10 +01:00
m_widgetSearch->propertyHide.set(true);
if (m_viewerManager != nullptr) {
std::shared_ptr<appl::TextViewer> tmp = m_viewerManager->getViewerSelected();
if (tmp != nullptr) {
tmp->keepFocus();
}
}
} else {
m_widgetSearch->selectReplace();
}
}
} else if (_value == "menu:find:previous") {
APPL_TODO("Event from Menu : " << _value);
} else if (_value == "menu:find:next") {
APPL_TODO("Event from Menu : " << _value);
} else if (_value == "menu:find:all") {
APPL_TODO("Event from Menu : " << _value);
} else if (_value == "menu:find:none") {
APPL_TODO("Event from Menu : " << _value);
} else if ( _value == "menu:color:color/black/"
|| _value == "menu:color:color/white/") {
etk::theme::setName("COLOR", std::string(_value, 12));
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
} else if ( _value == "menu:shape:shape/square/"
|| _value == "menu:shape:shape/round/") {
etk::theme::setName("GUI", std::string(_value, 12));
2014-01-18 14:34:33 +01:00
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
} else if (_value == "menu:reloadShape") {
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
} else if (_value == "menu:split:enable") {
propertySetOnWidgetNamed("appl-text-viewer2", "hide", "false");
} else if (_value == "menu:split:disable") {
propertySetOnWidgetNamed("appl-text-viewer2", "hide", "true");
} else if (_value == "menu:split:vert") {
propertySetOnWidgetNamed("appl-view-code-sizer", "mode", "vert");
} else if (_value == "menu:split:hori") {
propertySetOnWidgetNamed("appl-view-code-sizer", "mode", "hori");
} else {
APPL_ERROR("Event from Menu UNKNOW : '" << _value << "'");
}
}
/* TODO :
} else if (_msg.getMessage() == mainWindowsRequestSaveFile) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
2014-06-05 22:01:24 +02:00
if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
if (tmpBuffer->hasFileName() == false) {
APPL_ERROR("Will never arrive");
saveAsPopUp(tmpBuffer);
} else {
if (tmpBuffer->storeFile() == false) {
APPL_ERROR("Error when loading the file " << _msg.getData());
displayErrorMessage("Error when loading the file <br/><i>" + _msg.getData() + "</i>");
}
}
} else if (_msg.getMessage() == mainWindowsRequestSaveFileAs) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
2014-06-05 22:01:24 +02:00
if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
saveAsPopUp(tmpBuffer);
} else if (_msg.getMessage() == mainWindowsRequestcloseFileNoCheck) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
2014-06-05 22:01:24 +02:00
if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
// note: just remove ==> no check : normal case ...
//tmpBuffer->removeObject();
EWOL_TODO("call remove buffer ...");
2012-07-24 13:01:40 +02:00
}
*/
void MainWindows::displayOpen() {
std::shared_ptr<ewol::widget::FileChooser> tmpWidget = ewol::widget::FileChooser::create();
if (tmpWidget == nullptr) {
APPL_ERROR("Can not open File chooser !!! ");
return;
}
2016-02-15 22:04:10 +01:00
tmpWidget->propertyLabelTitle.set("TRANSLATE:Open files ...");
tmpWidget->propertyLabelValidate.set("TRANSLATE:Open");
if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... ");
return;
}
// Get a ref on the buffer selected (if null, no buffer was selected ...)
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->getBufferSelected();
if (tmpBuffer != nullptr) {
etk::FSNode tmpFile = tmpBuffer->getFileName();
2016-02-15 22:04:10 +01:00
tmpWidget->propertyPath.set(tmpFile.getNameFolder());
}
// apply widget pop-up ...
popUpWidgetPush(tmpWidget);
2016-02-19 23:33:00 +01:00
tmpWidget->signalValidate.connect(shared_from_this(), &MainWindows::onCallbackPopUpFileSelected);
}
void MainWindows::displayProperty() {
// Request the parameter GUI
std::shared_ptr<ewol::widget::Parameter> tmpWidget = ewol::widget::Parameter::create();
if (nullptr == tmpWidget) {
APPL_ERROR("Can not allocate widget == > display might be in error");
} else {
#ifdef SDGSDFGSDFGSDFGSDFGSTERGDHFGHFDS
std::string menuDescription = "<title>Properties</title>\n";
menuDescription += "<group title='Editor'>\n";
menuDescription += " <menu title='Editor Interface' short-title='Editor' widget='appl-text-viewer'>\n";
menuDescription += "</group>\n";
menuDescription += "<group title='Gui'>\n";
menuDescription += " <menu title='Font selection' short-title='Font' widget=''>\n";
menuDescription += " <menu title='Color selection' short-title='Color' widget=''>\n";
menuDescription += " <menu title='Theme selection' short-title='Theme' widget=''>\n";
menuDescription += "</group>\n";
tmpWidget->setMenu(menuDescription);
#endif
2016-02-15 22:04:10 +01:00
tmpWidget->propertyLabelTitle.set("TRANSLATE:Properties");
popUpWidgetPush(tmpWidget);
tmpWidget->menuAddGroup("Editor");
std::shared_ptr<ewol::Widget> tmpSubWidget = globals::ParameterGlobalsGui::create();
tmpWidget->menuAdd("Editor", "", tmpSubWidget);
tmpWidget->menuAdd("Font & Color", "", nullptr);
tmpWidget->menuAdd("Highlight", "", nullptr);
tmpWidget->menuAddGroup("General");
tmpWidget->menuAdd("Display", "", nullptr);
tmpSubWidget = ParameterAboutGui::create();
tmpWidget->menuAdd("About", "", tmpSubWidget);
}
2011-07-21 18:03:41 +02:00
}
void MainWindows::onCallbackselectNewFile(const std::string& _value) {
2014-09-12 21:36:20 +02:00
APPL_INFO("onCallbackselectNewFile(" << _value << ")");
if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... ");
return;
}
2016-02-19 23:33:00 +01:00
// TODO : Remove all previous connecting from the old buffer ...
onCallbackTitleUpdate();
std::shared_ptr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
if (tmpp != nullptr) {
2016-02-19 23:33:00 +01:00
tmpp->signalIsSave.connect(shared_from_this(), &MainWindows::onCallbackTitleUpdate);
tmpp->signalIsModify.connect(shared_from_this(), &MainWindows::onCallbackTitleUpdate);
tmpp->signalChangeName.connect(shared_from_this(), &MainWindows::onCallbackTitleUpdate);
}
}
void MainWindows::onCallbackPopUpFileSelected(const std::string& _value) {
2014-09-12 21:36:20 +02:00
APPL_INFO("onCallbackPopUpFileSelected(" << _value << ")");
APPL_DEBUG("Request opening the file : " << _value);
m_bufferManager->open(_value);
}
void MainWindows::onCallbackTitleUpdate() {
2014-09-12 21:36:20 +02:00
APPL_INFO("onCallbackTitleUpdate()");
if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... ");
return;
}
// select a new Buffer ==> change title:
std::shared_ptr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
if (tmpp == nullptr) {
setTitle("Edn");
if (m_widgetLabelFileName != nullptr) {
2016-02-15 22:04:10 +01:00
m_widgetLabelFileName->propertyValue.set("");
}
} else {
std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName();
setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem);
if (m_widgetLabelFileName != nullptr) {
2016-02-15 22:04:10 +01:00
m_widgetLabelFileName->propertyValue.set(nameFileSystem + (tmpp->isModify()==true?" *":""));
}
}
}
void MainWindows::saveAsPopUp(const std::shared_ptr<appl::Buffer>& _buffer) {
2014-06-05 22:01:24 +02:00
if (_buffer == nullptr) {
APPL_ERROR("Call With nullptr input...");
return;
}
std::shared_ptr<appl::WorkerSaveFile> tmpObject = appl::WorkerSaveFile::create(_buffer->getFileName());
}
void MainWindows::closeNotSavedFile(const std::shared_ptr<appl::Buffer>& _buffer) {
2014-06-05 22:01:24 +02:00
if (_buffer == nullptr) {
APPL_ERROR("Call With nullptr input...");
return;
}
std::shared_ptr<ewol::widget::StdPopUp> tmpPopUp = ewol::widget::StdPopUp::create();
2014-06-05 22:01:24 +02:00
if (tmpPopUp == nullptr) {
APPL_ERROR("Can not create a simple pop-up");
return;
}
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
tmpPopUp->setComment("The file named : <i>\"" + _buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
std::shared_ptr<ewol::widget::Button> bt = nullptr;
if (_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("Save", true);
2014-06-05 22:01:24 +02:00
if (bt != nullptr) {
// TODO : The element is removed before beeing pressed
2016-02-19 23:33:00 +01:00
// TODO : bt->signalPressed.connect(shared_from_this(), mainWindowsRequestSaveFile, _buffer->getFileName());
// TODO : bt->signalPressed.connect(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
}
}
bt = tmpPopUp->addButton("Save As", true);
2014-06-05 22:01:24 +02:00
if (bt != nullptr) {
2016-02-19 23:33:00 +01:00
// TODO : bt->signalPressed.connect(shared_from_this(), mainWindowsRequestSaveFileAs, _buffer->getFileName());
//bt->signalPressed.connect(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
// TODO : Request the close when saved ...
}
bt = tmpPopUp->addButton("Close", true);
2014-06-05 22:01:24 +02:00
if (bt != nullptr) {
2016-02-19 23:33:00 +01:00
// TODO : bt->signalPressed.connect(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
}
tmpPopUp->addButton("Cancel", true);
2016-02-15 22:04:10 +01:00
tmpPopUp->propertyCloseOutEvent.set(true);
popUpWidgetPush(tmpPopUp);
}