summaryrefslogtreecommitdiff
path: root/plugingui/filebrowser.cc
diff options
context:
space:
mode:
authorJonas Suhr Christensen <jsc@umbraculum.org>2013-05-15 18:14:01 +0200
committerJonas Suhr Christensen <jsc@umbraculum.org>2013-05-15 18:14:01 +0200
commit976ce209938be1bfc088d5f6cdd523a4089e1dd0 (patch)
tree8ef16aeefd3a4d9a675dc140c0daa84bdf8bb9b0 /plugingui/filebrowser.cc
parentb61c55a43c21a95234d79f6afd9a64964f5fffec (diff)
Make it possible to type a path and have browser switch accordingly.
Diffstat (limited to 'plugingui/filebrowser.cc')
-rw-r--r--plugingui/filebrowser.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc
index 6eaca8a..3c8b89d 100644
--- a/plugingui/filebrowser.cc
+++ b/plugingui/filebrowser.cc
@@ -68,7 +68,6 @@ static void changeDir(void *ptr)
struct GUI::FileBrowser::private_data *prv =
(struct GUI::FileBrowser::private_data *) ptr;
-
GUI::ListBox *lb = prv->listbox;
GUI::LineEdit *le = prv->lineedit;
std::string value = lb->selectedValue();
@@ -87,6 +86,12 @@ static void changeDir(void *ptr)
}
#endif
+ if(value.empty() && !dir->isDir()) {
+ DEBUG(filebrowser, "Selecting file '%s'\n", dir->path().c_str());
+ if(prv->filesel_handler) prv->filesel_handler(prv->ptr, dir->path().c_str());
+ return;
+ }
+
if(!value.empty() && dir->fileExists(value)) {
std::string file = dir->path() + "/" + value;
DEBUG(filebrowser, "Selecting file '%s'\n", file.c_str());
@@ -137,6 +142,19 @@ static void changeDir(void *ptr)
lb->addItems(items);
}
+static void handleKeyEvent(void *ptr) {
+ struct GUI::FileBrowser::private_data *prv =
+ (struct GUI::FileBrowser::private_data *) ptr;
+
+ GUI::ListBox *lb = prv->listbox;
+ lb->clearSelectedValue();
+ GUI::LineEdit *le = prv->lineedit;
+
+ printf("AAA: %s\n", le->text().c_str());
+ prv->dir->setPath(le->text());
+ changeDir(ptr);
+}
+
GUI::FileBrowser::FileBrowser(GUI::Widget *parent)
: GUI::Widget(parent),
lbl_path(this), lineedit(this), listbox(this), btn_sel(this), btn_esc(this),
@@ -152,8 +170,9 @@ GUI::FileBrowser::FileBrowser(GUI::Widget *parent)
lbl_path.setText("Path:");
- lineedit.setReadOnly(true);
+// lineedit.setReadOnly(true);
prv->lineedit = &lineedit;
+ prv->lineedit->registerEnterPressedHandler(handleKeyEvent, prv);
prv->listbox = &listbox;
listbox.registerSelectHandler(changeDir, prv);