diff options
author | jsc@umbraculum.org <jsc@umbraculum.org> | 2013-04-26 11:05:11 +0200 |
---|---|---|
committer | jsc@umbraculum.org <jsc@umbraculum.org> | 2013-04-26 11:05:11 +0200 |
commit | 5e2e2a6b4eed3a06a048f2ea1c609b2bb9659a5a (patch) | |
tree | c772952c039620312e14254335f52725a9bc0de6 | |
parent | 4cb91eb29feb454c3e7162100508a2ea64b3ab6a (diff) |
Is capable of selecting a file.
-rw-r--r-- | plugingui/directory.cc | 36 | ||||
-rw-r--r-- | plugingui/filebrowser.cc | 8 |
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; |