From fdb31916a63eba82d44025939bb4bb96d64cb53c Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 22 Jun 2014 10:41:18 -0400 Subject: [PATCH] gui: Change chooser directory when selected path is changed Signed-off-by: Anna Schumaker --- gui/collection_mgr.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/gui/collection_mgr.cpp b/gui/collection_mgr.cpp index f8f2dce9..ead9262b 100644 --- a/gui/collection_mgr.cpp +++ b/gui/collection_mgr.cpp @@ -11,6 +11,20 @@ static Gtk::FileChooserWidget *c_chooser; static Gtk::TreeView *c_treeview; +static void cd_chooser(const std::string &dir) +{ + if (c_chooser->get_current_folder() != dir) + c_chooser->set_current_folder(dir); +} + +static bool find_cur_path(Gtk::TreePath &path) +{ + Gtk::TreeViewColumn *col; + c_treeview->get_cursor(path, col); + return !path.empty(); +} + + static void on_ok() { colmgr :: add_path(c_chooser->get_filename()); @@ -25,18 +39,21 @@ static void on_update() static void on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col) { - //c_chooser->set_current_folder(colmgr :: get_path(path)); colmgr :: update_path(path); enable_idle(); } +static void on_cursor_changed() +{ + Gtk::TreePath path; + if (find_cur_path(path)) + cd_chooser(colmgr :: get_path(path)); +} + static void on_delete() { Gtk::TreePath path; - Gtk::TreeViewColumn *col; - - c_treeview->get_cursor(path, col); - if (path) + if (find_cur_path(path)) colmgr :: del_path(path); } @@ -67,6 +84,7 @@ void collection_mgr_init() connect_button("o_collection_update", on_update); c_treeview->signal_row_activated().connect(sigc::ptr_fun(on_row_activated)); + c_treeview->signal_cursor_changed().connect(sigc::ptr_fun(on_cursor_changed)); c_treeview->signal_key_press_event().connect(sigc::ptr_fun(on_key_pressed)); toggle->signal_toggled().connect(sigc::ptr_fun(on_toggled));