diff --git a/Sources/libetk/Android.mk b/Sources/libetk/Android.mk index 76d9e2f3..25f7c1f5 100644 --- a/Sources/libetk/Android.mk +++ b/Sources/libetk/Android.mk @@ -12,12 +12,17 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +ifeq ($(DEBUG),1) LOCAL_CFLAGS := -D__PLATFORM__Android \ -Wno-write-strings \ - -DDATA_IN_APK \ - -DETK_DEBUG_LEVEL=3 - - + -DETK_DEBUG_LEVEL=3 \ + -Wall +else +LOCAL_CFLAGS := -D__PLATFORM__Android \ + -Wno-write-strings \ + -DETK_DEBUG_LEVEL=1 \ + -DMODE_RELEASE +endif diff --git a/Sources/libetk/Linux.mk b/Sources/libetk/Linux.mk index d3437028..3e6baf96 100644 --- a/Sources/libetk/Linux.mk +++ b/Sources/libetk/Linux.mk @@ -14,17 +14,12 @@ ifeq ($(DEBUG),1) LOCAL_CFLAGS := -D__PLATFORM__Linux \ -Wno-write-strings \ -DETK_DEBUG_LEVEL=3 \ - -DEWOL_DEBUG_LEVEL=3 \ - -DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \ - -DVERSION_BUILD_TIME="\"pasd_heure\"" \ -Wall else LOCAL_CFLAGS := -D__PLATFORM__Linux \ -Wno-write-strings \ -DETK_DEBUG_LEVEL=1 \ - -DEWOL_DEBUG_LEVEL=1 \ - -DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \ - -DVERSION_BUILD_TIME="\"pasd_heure\"" + -DMODE_RELEASE endif diff --git a/Sources/libetk/etk/File.cpp b/Sources/libetk/etk/File.cpp index 298d2a35..14ea100a 100644 --- a/Sources/libetk/etk/File.cpp +++ b/Sources/libetk/etk/File.cpp @@ -27,16 +27,131 @@ #include #include #include +#include -#if defined(DATA_IN_APK) +#ifdef __PLATFORM__Android # include # include #endif +// zip file of the apk file for Android ==> set to zip file apk access +static etk::UString s_fileAPK = ""; +etk::UString baseApplName = "ewolNoName"; +#ifdef __PLATFORM__Android + etk::UString baseFolderHome = "/sdcard/"; // home folder + etk::UString baseFolderData = "assets/"; // program Data + etk::UString baseFolderDataUser = "/sdcard/.tmp/userData/"; // Data specific user (local modification) + etk::UString baseFolderCache = "/sdcard/.tmp/cache/"; // Temporary data (can be removed the next time) +#else + etk::UString baseFolderHome = "~"; // home folder + etk::UString baseFolderData = "assets/"; // program Data + etk::UString baseFolderDataUser = "~/.tmp/userData/"; // Data specific user (local modification) + etk::UString baseFolderCache = "~/.tmp/cache/"; // Temporary data (can be removed the next time) +#endif + +// for specific device contraint : +void etk::SetBaseFolderData(const char * folder) +{ + #ifdef __PLATFORM__Android + baseFolderData = "assets/"; + s_fileAPK = folder; + loadAPK(s_fileAPK); + #else + TK_ERROR("Not Availlable Outside Android"); + #endif +} + +void etk::SetBaseFolderDataUser(const char * folder) +{ + #ifdef __PLATFORM__Android + baseFolderDataUser = folder; + #else + TK_ERROR("Not Availlable Outside Android"); + #endif +} + +void etk::SetBaseFolderCache(const char * folder) +{ + #ifdef __PLATFORM__Android + baseFolderCache = folder; + #else + TK_ERROR("Not Availlable Outside Android"); + #endif +} + + +void etk::InitDefaultFolder(const char * applName) +{ + baseApplName = applName; + char * basicPath = getenv("HOME"); + if (NULL == basicPath) { + TK_ERROR("ERROR while trying to get the path of the home folder"); + baseFolderHome = "~"; + } else { + baseFolderHome = basicPath; + } + #ifndef __PLATFORM__Android + + #ifdef MODE_RELEASE + baseFolderData = "/usr/share/"; + baseFolderData += baseApplName; + baseFolderData += "/"; + #else + char cCurrentPath[FILENAME_MAX]; + if (!getcwd(cCurrentPath, FILENAME_MAX)) { + baseFolderData = "./assets/"; + } else { + cCurrentPath[FILENAME_MAX - 1] = '\0'; + baseFolderData = cCurrentPath; + baseFolderData += "/assets/"; + } + #endif + baseFolderDataUser = baseFolderHome; + baseFolderDataUser += "/."; + baseFolderDataUser += baseApplName; + baseFolderDataUser += "/"; + + baseFolderCache = "/tmp/"; + baseFolderCache += baseApplName; + baseFolderCache += "/"; + #endif + TK_INFO("baseFolderHome : \"" << baseFolderHome << "\""); + TK_INFO("baseFolderData : \"" << baseFolderData << "\""); + TK_INFO("baseFolderDataUser : \"" << baseFolderDataUser << "\""); + TK_INFO("baseFolderCache : \"" << baseFolderCache << "\""); +} + +etk::UString etk::GetUserHomeFolder(void) +{ + return baseFolderHome; +} + +#ifdef __PLATFORM__Android + static struct zip * s_APKArchive = NULL; + static int32_t s_APKnbFiles = 0; + static void loadAPK(etk::UString& apkPath) + { + TK_DEBUG("Loading APK \"" << apkPath << "\""); + s_APKArchive = zip_open(apkPath.Utf8Data(), 0, NULL); + TK_ASSERT(s_APKArchive != NULL, "Error loading APK ... \"" << apkPath << "\""); + //Just for debug, print APK contents + s_APKnbFiles = zip_get_num_files(s_APKArchive); + TK_INFO("List all files in the APK : " << s_APKnbFiles << " files"); + for (int iii=0; iii 3 mode = "FILE_TYPE_DATA"; #endif - #if defined(DATA_IN_APK) + #ifdef __PLATFORM__Android etk::UString tmpFilename = baseFolderData + destFilename; for (int iii=0; iii= -1 && m_idZipFile < s_APKnbFiles) { return true; @@ -547,7 +613,7 @@ bool etk::File::Exist(void) bool etk::File::fOpenRead(void) { - #if defined(DATA_IN_APK) + #ifdef __PLATFORM__Android if (etk::FILE_TYPE_DATA == m_type) { return LoadDataZip(); } @@ -583,7 +649,7 @@ bool etk::File::fOpenRead(void) bool etk::File::fOpenWrite(void) { - #if defined(DATA_IN_APK) + #ifdef __PLATFORM__Android if (etk::FILE_TYPE_DATA == m_type) { return false; } @@ -619,7 +685,7 @@ bool etk::File::fOpenWrite(void) bool etk::File::fClose(void) { - #if defined(DATA_IN_APK) + #ifdef __PLATFORM__Android if (etk::FILE_TYPE_DATA == m_type) { if (NULL == m_zipData) { TK_CRITICAL("File Already closed : \"" << GetCompleateName() << "\""); @@ -644,7 +710,7 @@ bool etk::File::fClose(void) char * etk::File::fGets(char * elementLine, int32_t maxData) { memset(elementLine, 0, maxData); - #if defined(DATA_IN_APK) + #ifdef __PLATFORM__Android char * element = elementLine; if (etk::FILE_TYPE_DATA == m_type) {//char * tmpData = internalDataFiles[iii].data + m_readingOffset; if (NULL == m_zipData) { @@ -681,7 +747,7 @@ char * etk::File::fGets(char * elementLine, int32_t maxData) int32_t etk::File::fRead(void * data, int32_t blockSize, int32_t nbBlock) { - #if defined(DATA_IN_APK) + #ifdef __PLATFORM__Android if (etk::FILE_TYPE_DATA == m_type) { if (NULL == m_zipData) { ((char*)data)[0] = '\0'; @@ -702,7 +768,7 @@ int32_t etk::File::fRead(void * data, int32_t blockSize, int32_t nbBlock) int32_t etk::File::fWrite(void * data, int32_t blockSize, int32_t nbBlock) { - #if defined(DATA_IN_APK) + #ifdef __PLATFORM__Android if (etk::FILE_TYPE_DATA == m_type) { TK_CRITICAL("Can not write on data inside APK : \"" << GetCompleateName() << "\""); return 0; @@ -714,7 +780,7 @@ int32_t etk::File::fWrite(void * data, int32_t blockSize, int32_t nbBlock) bool etk::File::fSeek(long int offset, int origin) { - #if defined(DATA_IN_APK) + #ifdef __PLATFORM__Android if (etk::FILE_TYPE_DATA == m_type) { if (NULL == m_zipData) { return false; @@ -752,7 +818,7 @@ bool etk::File::fSeek(long int offset, int origin) char * etk::File::GetDirectPointer(void) { - #if defined(DATA_IN_APK) + #ifdef __PLATFORM__Android if (etk::FILE_TYPE_DATA == m_type) { if (NULL == m_zipData) { return NULL; diff --git a/Sources/libetk/etk/File.h b/Sources/libetk/etk/File.h index 42613e35..2c9b6a34 100644 --- a/Sources/libetk/etk/File.h +++ b/Sources/libetk/etk/File.h @@ -94,7 +94,7 @@ namespace etk private : etk::FileType_te m_type; FILE * m_PointerFile; - #if defined(DATA_IN_APK) + #ifdef __PLATFORM__Android bool LoadDataZip(void); int32_t m_idZipFile; char * m_zipData; @@ -111,6 +111,8 @@ namespace etk void SetBaseFolderData(const char * folder); void SetBaseFolderDataUser(const char * folder); void SetBaseFolderCache(const char * folder); + void InitDefaultFolder(const char * applName); + etk::UString GetUserHomeFolder(void); } diff --git a/Sources/libetk/etk/RegExp.h b/Sources/libetk/etk/RegExp.h index 5a22308b..2d1e73be 100644 --- a/Sources/libetk/etk/RegExp.h +++ b/Sources/libetk/etk/RegExp.h @@ -2119,4 +2119,7 @@ template class RegExp { }; // end of etk namespace +#undef __class__ +#define __class__ (NULL) + #endif diff --git a/Sources/libewol/ewol/base/MainThread.cpp b/Sources/libewol/ewol/base/MainThread.cpp index dd793416..ac526990 100644 --- a/Sources/libewol/ewol/base/MainThread.cpp +++ b/Sources/libewol/ewol/base/MainThread.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -91,6 +92,7 @@ static void* BaseAppEntry(void* param) EWOL_INFO("v" EWOL_VERSION_TAG_NAME); EWOL_INFO("Build Date: " VERSION_BUILD_TIME); + etk::InitDefaultFolder("ewolApplNoName"); /* struct sched_param pr; diff --git a/Sources/libewol/ewol/widget/Button.cpp b/Sources/libewol/ewol/widget/Button.cpp index 7b4ad9ee..2a7dc78e 100644 --- a/Sources/libewol/ewol/widget/Button.cpp +++ b/Sources/libewol/ewol/widget/Button.cpp @@ -101,6 +101,7 @@ void ewol::Button::SetImage(etk::UString imageName) m_imageSelected = imageName; m_hasAnImage = true; } + MarkToReedraw(); } //!< EObject name : @@ -168,6 +169,7 @@ bool ewol::Button::CalculateMinSize(void) void ewol::Button::SetLabel(etk::UString newLabel) { m_label = newLabel; + MarkToReedraw(); } void ewol::Button::SetValue(bool val) diff --git a/Sources/libewol/ewol/widget/Image.cpp b/Sources/libewol/ewol/widget/Image.cpp new file mode 100644 index 00000000..54b060c9 --- /dev/null +++ b/Sources/libewol/ewol/widget/Image.cpp @@ -0,0 +1,206 @@ +/** + ******************************************************************************* + * @file ewol/widget/Image.cpp + * @brief ewol Image widget system (Sources) + * @author Edouard DUPIN + * @date 12/05/2012 + * @par Project + * ewol + * + * @par Copyright + * Copyright 2011 Edouard DUPIN, all right reserved + * + * This software is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY. + * + * Licence summary : + * You can modify and redistribute the sources code and binaries. + * You can send me the bug-fix + * + * Term of the licence in in the file licence.txt. + * + ******************************************************************************* + */ + +#include + +#include +#include + + +extern const char * const ewolEventImagePressed = "ewol-image-Pressed"; + + +/** + * @brief Initilise the basic widget property ==> due to the android system + * @note all widget that have template might have this initializer ... + * @param --- + * @return --- + */ +void ewol::WIDGET_ImageInit(void) +{ + +} + +#undef __class__ +#define __class__ "Image" + + +void ewol::Image::Init(void) +{ + AddEventId(ewolEventImagePressed); + + #ifdef __PLATFORM__Android + m_padding.y = 12; + m_padding.x = 12; + #else + m_padding.y = 4; + m_padding.x = 4; + #endif + + m_textColorBg = etk::color::color_Black; + m_textColorBg.alpha = 0x00; + m_imageSize = 32; +} + + +ewol::Image::Image(etk::UString dataFile, int32_t size) +{ + m_imageSelected = dataFile; + Init(); + if (size>0) { + m_imageSize = size; + } +} + + +ewol::Image::~Image(void) +{ + +} + + +//!< EObject name : +extern const char * const ewol::TYPE_EOBJECT_WIDGET_IMAGE = "Image"; + +/** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ +bool ewol::Image::CheckObjectType(const char * const objectType) +{ + if (NULL == objectType) { + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_IMAGE << "\" != NULL(pointer) "); + return false; + } + if (objectType == ewol::TYPE_EOBJECT_WIDGET_IMAGE) { + return true; + } else { + if(true == ewol::Drawable::CheckObjectType(objectType)) { + return true; + } + EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_IMAGE << "\" != \"" << objectType << "\""); + return false; + } +} + +/** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ +const char * const ewol::Image::GetObjectType(void) +{ + return ewol::TYPE_EOBJECT_WIDGET_IMAGE; +} + + +void ewol::Image::SetPadding(coord2D_ts newPadding) +{ + m_padding = newPadding; +} + +bool ewol::Image::CalculateMinSize(void) +{ + m_minSize.x = m_padding.x*2 + m_imageSize; + m_minSize.y = m_padding.y*2 + m_imageSize; + MarkToReedraw(); + return true; +} + + +void ewol::Image::SetFile(etk::UString newFile) +{ + m_imageSelected = newFile; + MarkToReedraw(); +} + + +void ewol::Image::OnRegenerateDisplay(void) +{ + if (true == NeedRedraw()) { + // clean the object list ... + ClearOObjectList(); + + int32_t tmpSizeX = m_minSize.x; + int32_t tmpSizeY = m_minSize.y; + int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2; + int32_t tmpOriginY = (m_size.y - m_minSize.y) / 2; + + if (true==m_userFillX) { + tmpSizeX = m_size.x; + tmpOriginX = 0; + } + if (true==m_userFillY) { + tmpSizeY = m_size.y; + tmpOriginY = 0; + } + tmpOriginX += m_padding.x; + tmpOriginY += m_padding.y; + tmpSizeX -= 2*m_padding.x; + tmpSizeY -= 2*m_padding.y; + + + ewol::OObject2DTextured * tmpImage = NULL; + tmpImage = new ewol::OObject2DTextured(m_imageSelected, m_imageSize, m_imageSize); + tmpImage->Rectangle(tmpOriginX, tmpOriginY, m_imageSize, m_imageSize); + + + ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored; + tmpOObjects->SetColor(m_textColorBg); + tmpOObjects->Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY); + // add all needed objects ... + if (NULL != tmpOObjects) { + AddOObject(tmpOObjects); + } + if (NULL != tmpImage) { + AddOObject(tmpImage); + } + } +} + +/** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ +bool ewol::Image::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) +{ + //EWOL_DEBUG("Event on BT ..."); + if (1 == IdInput) { + if( ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent + || ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent + || ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) { + GenerateEventId(ewolEventImagePressed); + return true; + } + } + return false; +} + diff --git a/Sources/libewol/ewol/widget/Image.h b/Sources/libewol/ewol/widget/Image.h new file mode 100644 index 00000000..0407672e --- /dev/null +++ b/Sources/libewol/ewol/widget/Image.h @@ -0,0 +1,91 @@ +/** + ******************************************************************************* + * @file ewol/widget/Image.h + * @brief ewol Image widget system (header) + * @author Edouard DUPIN + * @date 12/05/2012 + * @par Project + * ewol + * + * @par Copyright + * Copyright 2011 Edouard DUPIN, all right reserved + * + * This software is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY. + * + * Licence summary : + * You can modify and redistribute the sources code and binaries. + * You can send me the bug-fix + * + * Term of the licence in in the file licence.txt. + * + ******************************************************************************* + */ + +#ifndef __EWOL_IMAGE_H__ +#define __EWOL_IMAGE_H__ + +#include +#include +#include + +extern const char * const ewolEventImagePressed; + +namespace ewol { + class Image :public ewol::Drawable + { + public: + Image(etk::UString dataFile, int32_t size=-1); // automatic considering in the appl Data older + /** + * @brief Check if the object has the specific type. + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type of the object we want to check + * @return true if the object is compatible, otherwise false + */ + virtual bool CheckObjectType(const char * const objectType); + + /** + * @brief Get the current Object type of the EObject + * @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it + * @param[in] objectType type description + * @return true if the object is compatible, otherwise false + */ + virtual const char * const GetObjectType(void); + void Init(void); + virtual ~Image(void); + virtual bool CalculateMinSize(void); + void SetFile(etk::UString newFile); + void SetPadding(coord2D_ts newPadding); + private: + etk::UString m_imageSelected; + coord2D_ts m_padding; + color_ts m_textColorBg; //!< Background color + int32_t m_imageSize; + public: + virtual void OnRegenerateDisplay(void); + public: + /** + * @brief Event on an input of this Widget + * @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger)) + * @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/... + * @param[in] pos Absolute position of the event + * @return true the event is used + * @return false the event is not used + */ + virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); + }; + + /** + * @brief Initilise the basic widget property ==> due to the android system + * @note all widget that have template might have this initializer ... + * @param --- + * @return --- + */ + void WIDGET_ImageInit(void); + + extern const char * const TYPE_EOBJECT_WIDGET_IMAGE; + +}; +#define EWOL_CAST_WIDGET_IMAGE(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_IMAGE,ewol::Image,curentPointer) + +#endif diff --git a/Sources/libewol/ewol/widgetMeta/FileChooser.cpp b/Sources/libewol/ewol/widgetMeta/FileChooser.cpp index 74605e3a..fa94a803 100644 --- a/Sources/libewol/ewol/widgetMeta/FileChooser.cpp +++ b/Sources/libewol/ewol/widgetMeta/FileChooser.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include //#include #include @@ -406,6 +407,7 @@ extern const char * const ewolEventFileChooserValidate = "ewol-event-file extern const char * const ewolEventFileChooserHidenFileChange = "ewol-event-file-chooser-Show/Hide-hiden-Files"; extern const char * const ewolEventFileChooserEntryFolder = "ewol-event-file-chooser-modify-entry-folder"; extern const char * const ewolEventFileChooserEntryFile = "ewol-event-file-chooser-modify-entry-file"; +extern const char * const ewolEventFileChooserHome = "ewol-event-file-chooser-home"; ewol::FileChooser::FileChooser(void) @@ -430,6 +432,7 @@ ewol::FileChooser::FileChooser(void) FileChooserFileList * myListFile = NULL; FileChooserFolderList * myListFolder = NULL; ewol::Label * myLabel = NULL; + ewol::Image * myImage = NULL; #ifdef __PLATFORM__Android m_folder = "/mnt/sdcard/"; SetDisplayRatio(0.90); @@ -449,21 +452,26 @@ ewol::FileChooser::FileChooser(void) mySizerHori = new ewol::SizerHori(); mySizerVert->SubWidgetAdd(mySizerHori); - myLabel = new ewol::Label("Folder : "); - myLabel->SetFillY(true); - mySizerHori->SubWidgetAdd(myLabel); + myImage = new ewol::Image("icon/Folder.svg"); + myImage->SetFillY(true); + mySizerHori->SubWidgetAdd(myImage); + m_widgetCurrentFolder = new ewol::Entry(m_folder); m_widgetCurrentFolder->RegisterOnEvent(this, ewolEventEntryModify, ewolEventFileChooserEntryFolder); m_widgetCurrentFolder->SetExpendX(true); m_widgetCurrentFolder->SetFillX(true); m_widgetCurrentFolder->SetWidth(200); mySizerHori->SubWidgetAdd(m_widgetCurrentFolder); + myImage = new ewol::Image("icon/Home.svg"); + myImage->RegisterOnEvent(this, ewolEventImagePressed, ewolEventFileChooserHome); + myImage->SetFillY(true); + mySizerHori->SubWidgetAdd(myImage); mySizerHori = new ewol::SizerHori(); mySizerVert->SubWidgetAdd(mySizerHori); - myLabel = new ewol::Label("File Name : "); - myLabel->SetFillY(true); - mySizerHori->SubWidgetAdd(myLabel); + myImage = new ewol::Image("icon/File.svg"); + myImage->SetFillY(true); + mySizerHori->SubWidgetAdd(myImage); m_widgetCurrentFileName = new ewol::Entry(m_file); m_widgetCurrentFileName->RegisterOnEvent(this, ewolEventEntryModify, ewolEventFileChooserEntryFile); m_widgetCurrentFileName->SetExpendX(true); @@ -508,9 +516,11 @@ ewol::FileChooser::FileChooser(void) mySpacer->SetExpendX(true); mySizerHori->SubWidgetAdd(mySpacer); m_widgetValidate = new ewol::Button("Validate"); + m_widgetValidate->SetImage("icon/Load.svg"); m_widgetValidate->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserValidate); mySizerHori->SubWidgetAdd(m_widgetValidate); m_widgetCancel = new ewol::Button("Cancel"); + m_widgetCancel->SetImage("icon/Remove.svg"); m_widgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserCancel); mySizerHori->SubWidgetAdd(m_widgetCancel); @@ -617,23 +627,19 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha if (ewolEventFileChooserEntryFolder == eventId) { //==> change the folder name // TODO : Change the folder, if it exit ... - return; } else if (ewolEventFileChooserEntryFile == eventId) { //==> change the file name if (NULL != m_widgetCurrentFileName) { m_file = m_widgetCurrentFileName->GetValue(); } // TODO : Remove file selection - return; } else if (ewolEventFileChooserCancel == eventId) { //==> Auto remove ... GenerateEventId(eventId); MarkToRemove(); - return; } else if (ewolEventFileChooserHidenFileChange == eventId) { // regenerate the display ... UpdateCurrentFolder(); - return; } else if (ewolEventFileChooserSelectFolder == eventId) { //==> this is an internal event ... FileChooserFolderList * myListFolder = EWOL_CAST_WIDGET_FOLDER_LIST(m_widgetListFolder); @@ -658,7 +664,6 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha SetFileName(""); UpdateCurrentFolder(); m_hasSelectedFile = false; - return; } else if (ewolEventFileChooserSelectFile == eventId) { m_hasSelectedFile = true; FileChooserFileList * myListFile = EWOL_CAST_WIDGET_FILE_LIST(m_widgetListFile); @@ -670,7 +675,26 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha // select the File ==> generate a validate GenerateEventId(ewolEventFileChooserValidate); MarkToRemove(); - return; + } else if(ewolEventFileChooserHome == eventId) { + etk::UString tmpUserFolder = etk::GetUserHomeFolder(); + char buf[MAX_FILE_NAME]; + memset(buf, 0, MAX_FILE_NAME); + char * ok; + EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\""); + + ok = realpath(tmpUserFolder.Utf8Data(), buf); + if (!ok) { + EWOL_ERROR("Error to get the real path"); + m_folder = "/"; + } else { + m_folder = buf; + } + if (m_folder != "/" ) { + m_folder += "/"; + } + SetFileName(""); + UpdateCurrentFolder(); + m_hasSelectedFile = false; } return; }; diff --git a/Sources/libewol/file.mk b/Sources/libewol/file.mk index 7eb95930..cd7855a0 100644 --- a/Sources/libewol/file.mk +++ b/Sources/libewol/file.mk @@ -28,6 +28,7 @@ FILE_LIST = ewol/ewol.cpp \ ewol/Windows.cpp \ ewol/ShortCutManager.cpp \ ewol/widget/Button.cpp \ + ewol/widget/Image.cpp \ ewol/widget/ButtonColor.cpp \ ewol/widget/CheckBox.cpp \ ewol/widget/ColorBar.cpp \