summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugingui/directory.cc36
-rw-r--r--plugingui/filebrowser.cc8
2 files changed, 39 insertions, 5 deletions
diff --git a/plugingui/directory.cc b/plugingui/directory.cc
index 9515060..5f80508 100644
--- a/plugingui/directory.cc
+++ b/plugingui/directory.cc
@@ -53,9 +53,12 @@ void Directory::refresh() {
bool Directory::cd(std::string dir) {
DEBUG(directory, "Changing to '%s'\n", dir.c_str());
- int r = chdir(dir.c_str());
- refresh();
- if(!r) return true;
+ int r = chdir( (path() + "/" + dir).c_str() );
+ if(!r) {
+ _path += "/" + dir;
+ refresh();
+ return true;
+ }
else return false;
}
@@ -81,7 +84,32 @@ std::string Directory::cwd() {
}
std::string Directory::cleanPath(std::string path) {
- // TODO!
+/*
+ size_t c = 0;
+ std::string current_char;
+ std::string prev_char;
+
+ for(; c < path.size(); c++) {
+ current_char = path.at(c);
+ prev_char = current_char;
+ }
+*/
+/*
+
+ size_t current_pos;
+ size_t prev_pos = 1;
+ DEBUG(directory, "Looking at path '%s'\n", path.c_str());
+ while( (current_pos = path.find("/", prev_pos + 1)) != std::string::npos) {
+ DEBUG(directory, "%d - %d", prev_pos, current_pos);
+ std::string dir = path.substr(prev_pos, current_pos - prev_pos + 1);
+ DEBUG(directory, "Dir '%s'\n", dir.c_str());
+ prev_pos = current_pos;
+ }
+
+ std::string dir = path.substr(prev_pos, current_pos - prev_pos + 1);
+ DEBUG(directory, "Dir '%s'\n", dir.c_str());
+*/
+
return path;
}
diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc
index 9a0521a..d64a0ab 100644
--- a/plugingui/filebrowser.cc
+++ b/plugingui/filebrowser.cc
@@ -69,7 +69,7 @@ static void changeDir(void *ptr) {
GUI::ListBox *lb = prv->listbox;
-// GUI::LineEdit *le = prv->lineedit;
+ GUI::LineEdit *le = prv->lineedit;
std::string value = lb->selectedValue();
Directory* dir = prv->dir;
@@ -89,6 +89,9 @@ static void changeDir(void *ptr) {
}
//TODO: If root and windows show drives instead of files
+
+ DEBUG(filebrowser, "Setting path of lineedit to %s\n", dir->path().c_str());
+ le->setText(Directory::cleanPath(dir->path()));
lb->clear();
std::vector<GUI::ListBoxBasic::Item> items;
@@ -268,6 +271,9 @@ static bool isDir(std::string d)
void GUI::FileBrowser::setPath(std::string path)
{
+ // TODO: Remove this check to directoy.cc
+ if(path.empty()) return;
+
prv->dir->setPath(path);
/*
std::string dir;