gui: move "(Up A Level)" in file selector to resource string
Doing it at display time is easier.
Change-Id: Ic0f2ca1f425f6267452157524a05b51d9324be16
diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp
index 23f235c..9275d97 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -31,8 +31,6 @@
#include "../data.hpp"
#include "../twrp-functions.hpp"
-#define TW_FILESELECTOR_UP_A_LEVEL "(Up A Level)"
-
int GUIFileSelector::mSortOrder = 0;
GUIFileSelector::GUIFileSelector(xml_node<>* node) : GUIScrollList(node)
@@ -186,9 +184,9 @@
return -1;
if (d2.fileName == ".")
return 0;
- if (d1.fileName == TW_FILESELECTOR_UP_A_LEVEL)
+ if (d1.fileName == "..")
return -1;
- if (d2.fileName == TW_FILESELECTOR_UP_A_LEVEL)
+ if (d2.fileName == "..")
return 0;
switch (mSortOrder) {
@@ -251,12 +249,8 @@
continue;
if (data.fileName == ".." && folder == "/")
continue;
- if (data.fileName == "..") {
- data.fileName = TW_FILESELECTOR_UP_A_LEVEL;
- data.fileType = DT_DIR;
- } else {
- data.fileType = de->d_type;
- }
+
+ data.fileType = de->d_type;
std::string path = folder + "/" + data.fileName;
stat(path.c_str(), &st);
@@ -272,7 +266,7 @@
data.fileType = TWFunc::Get_D_Type_From_Stat(path);
}
if (data.fileType == DT_DIR) {
- if (mShowNavFolders || (data.fileName != "." && data.fileName != TW_FILESELECTOR_UP_A_LEVEL))
+ if (mShowNavFolders || (data.fileName != "." && data.fileName != ".."))
mFolderList.push_back(data);
} else if (data.fileType == DT_REG || data.fileType == DT_LNK || data.fileType == DT_BLK) {
if (mExtn.empty() || (data.fileName.length() > mExtn.length() && data.fileName.substr(data.fileName.length() - mExtn.length()) == mExtn)) {
@@ -319,6 +313,8 @@
if (itemindex < folderSize) {
text = mFolderList.at(itemindex).fileName;
icon = mFolderIcon;
+ if (text == "..")
+ text = gui_lookup("up_a_level", "(Up A Level)");
} else {
text = mFileList.at(itemindex - folderSize).fileName;
icon = mFileIcon;
@@ -345,7 +341,7 @@
// Ignore requests to do nothing
if (str == ".") return;
- if (str == TW_FILESELECTOR_UP_A_LEVEL) {
+ if (str == "..") {
if (cwd != "/") {
size_t found;
found = cwd.find_last_of('/');