From 3e156797056778d065d616dcb490ecd358749b89 Mon Sep 17 00:00:00 2001 From: tedjk Date: Fri, 10 Apr 2015 10:39:46 +0200 Subject: [PATCH] moved directory signal functions to notebook from window --- juci/notebook.cc | 25 ++++++++++++++++++++++++- juci/notebook.h | 2 ++ juci/window.cc | 25 +------------------------ juci/window.h | 3 +-- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/juci/notebook.cc b/juci/notebook.cc index 7ae7bf5..4c57857 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -104,6 +104,9 @@ source_config_(source_cfg) { [this]() { Search(false); }); + directories().m_TreeView.signal_row_activated() + .connect(sigc::mem_fun(*this, + &Notebook::Controller::OnDirectoryNavigation)); }//Constructor @@ -315,7 +318,27 @@ void Notebook::Controller::OnBufferChange() { delete scroll; } } - +void Notebook::Controller::OnDirectoryNavigation(const Gtk::TreeModel::Path& path, + Gtk::TreeViewColumn* column) { + Gtk::TreeModel::iterator iter = directories().m_refTreeModel->get_iter(path); + if(iter) { + Gtk::TreeModel::Row row = *iter; + boost::filesystem::path fs_path(Glib::ustring(row[directories() + .view().m_col_path])); + if (boost::filesystem::is_directory(fs_path)) { + std::cout << "Expand folder: " << row[directories().view().m_col_path] << std::endl; + directories().m_TreeView.row_expanded(path) ? + directories().m_TreeView.collapse_row(path) : + directories().m_TreeView.expand_row(path, false); + } else { + std::stringstream sstm; + sstm << row[directories().view().m_col_path]; + std::string file = sstm.str(); + std::cout << "open file: "<< row[directories().view().m_col_path] << std::endl; + OnOpenFile(file); + } + } +} Gtk::TextView& Notebook::Controller::CurrentTextView() { return text_vec_.at(CurrentPage())->view(); diff --git a/juci/notebook.h b/juci/notebook.h index 84c2591..3b77beb 100644 --- a/juci/notebook.h +++ b/juci/notebook.h @@ -46,6 +46,8 @@ namespace Notebook { void OnFileNewEmptyfile(); void OnFileNewHeaderFile(); void OnFileOpenFolder(); + void OnDirectoryNavigation(const Gtk::TreeModel::Path& path, + Gtk::TreeViewColumn* column); void OnNewPage(std::string name); void OnOpenFile(std::string filename); void OnCreatePage(); diff --git a/juci/window.cc b/juci/window.cc index a1fb705..99485c2 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -26,10 +26,6 @@ Window::Window() : [this]() { OnFileOpenFolder(); }); - - notebook_.directories().m_TreeView.signal_row_activated() - .connect(sigc::mem_fun(*this, - &Window::OnDirectoryNavigation)); PluginApi::menu_ = &menu_; PluginApi::notebook_ = ¬ebook_; PluginApi::InitPlugins(); @@ -82,26 +78,7 @@ void Window::OnFileOpenFolder() { } } -void Window::OnDirectoryNavigation(const Gtk::TreeModel::Path& path, - Gtk::TreeViewColumn* column) { - Gtk::TreeModel::iterator iter = notebook_.directories().m_refTreeModel->get_iter(path); - if(iter) { - Gtk::TreeModel::Row row = *iter; - boost::filesystem::path fs_path(Glib::ustring(row[notebook_.directories().view().m_col_path])); - if(boost::filesystem::is_directory(fs_path)) { - std::cout << "Expand folder: " << row[notebook_.directories().view().m_col_path] << std::endl; - notebook_.directories().m_TreeView.row_expanded(path) ? - notebook_.directories().m_TreeView.collapse_row(path) : - notebook_.directories().m_TreeView.expand_row(path, false); - } else { - std::stringstream sstm; - sstm << row[notebook_.directories().view().m_col_path]; - std::string file = sstm.str(); - std::cout << "open file: "<< row[notebook_.directories().view().m_col_path] << std::endl; - notebook_.OnOpenFile(file); - } - } -} + void Window::OnOpenFile() { Gtk::FileChooserDialog dialog("Please choose a file", Gtk::FILE_CHOOSER_ACTION_OPEN); diff --git a/juci/window.h b/juci/window.h index f3a00fa..2b79755 100644 --- a/juci/window.h +++ b/juci/window.h @@ -29,8 +29,7 @@ public: void OnWindowHide(); void OnOpenFile(); void OnFileOpenFolder(); - void OnDirectoryNavigation(const Gtk::TreeModel::Path& path, - Gtk::TreeViewColumn* column); + }; #endif // JUCI_WINDOW_H