diff --git a/juci/juci.cc b/juci/juci.cc index 5402b10..1a6ec46 100644 --- a/juci/juci.cc +++ b/juci/juci.cc @@ -37,7 +37,7 @@ void Juci::on_activate() { if(directory!="") { //TODO: use the following instead, window->notebook_.open_directory(directory); window->notebook_.project_path=directory; - window->notebook_.directories().open_folder(directory); + window->notebook_.directories.open_folder(directory); } for(auto &f: files) window->notebook_.OnOpenFile(f); diff --git a/juci/juci.h b/juci/juci.h index 9d55502..4ce2cb2 100644 --- a/juci/juci.h +++ b/juci/juci.h @@ -1,3 +1,6 @@ +#ifndef JUCI_JUCI_H_ +#define JUCI_JUCI_H_ + #include "window.h" #include "logging.h" @@ -13,3 +16,5 @@ private: std::string directory; std::vector files; }; + +#endif // JUCI_JUCI_H_ \ No newline at end of file diff --git a/juci/notebook.cc b/juci/notebook.cc index a813162..d0ba733 100644 --- a/juci/notebook.cc +++ b/juci/notebook.cc @@ -17,12 +17,12 @@ Notebook::Controller::Controller(Gtk::Window* window, Keybindings::Controller& keybindings, Source::Config& source_cfg, Directories::Config& dir_cfg) : - directories_(dir_cfg), - source_config_(source_cfg) { + directories(dir_cfg), + source_config(source_cfg) { INFO("Create notebook"); window_ = window; refClipboard_ = Gtk::Clipboard::get(); - view().pack1(directories_.widget(), true, true); + view().pack1(directories.widget(), true, true); CreateKeybindings(keybindings); INFO("Notebook Controller Success"); } // Constructor @@ -31,7 +31,7 @@ Notebook::Controller::Controller(Gtk::Window* window, void Notebook::Controller::CreateKeybindings(Keybindings::Controller &keybindings) { INFO("Notebook create signal handlers"); - directories().m_TreeView.signal_row_activated() + directories.m_TreeView.signal_row_activated() .connect(sigc::mem_fun(*this, &Notebook::Controller::OnDirectoryNavigation)); @@ -191,7 +191,7 @@ Gtk::Box& Notebook::Controller::entry_view() { void Notebook::Controller::OnOpenFile(std::string path) { INFO("Notebook open file"); INFO("Notebook create page"); - text_vec_.emplace_back(new Source::Controller(source_config(), path, project_path)); + text_vec_.emplace_back(new Source::Controller(source_config, path, project_path)); scrolledtext_vec_.push_back(new Gtk::ScrolledWindow()); editor_vec_.push_back(new Gtk::HBox()); scrolledtext_vec_.back()->add(*text_vec_.back()->view); @@ -204,7 +204,18 @@ void Notebook::Controller::OnOpenFile(std::string path) { Notebook().show_all_children(); Notebook().set_current_page(Pages()-1); Notebook().set_focus_child(*text_vec_.back()->view); - set_source_handlers(*text_vec_.back()); + //Add star on tab label when the page is not saved: + text_vec_.back()->buffer()->signal_changed().connect([this]() { + if(text_vec_.at(CurrentPage())->is_saved) { + std::string path=text_vec_.at(CurrentPage())->view->file_path; + size_t pos = path.find_last_of("/\\"); + std::string filename=path; + if(pos!=std::string::npos) + filename=path.substr(pos+1); + Notebook().set_tab_label_text(*(Notebook().get_nth_page(CurrentPage())), filename+"*"); + } + text_vec_.at(CurrentPage())->is_saved=false; + }); } void Notebook::Controller::OnCloseCurrentPage() { @@ -310,18 +321,18 @@ void Notebook::Controller ::OnDirectoryNavigation(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column) { INFO("Notebook directory navigation"); - Gtk::TreeModel::iterator iter = directories().m_refTreeModel->get_iter(path); + Gtk::TreeModel::iterator iter = directories.m_refTreeModel->get_iter(path); if (iter) { Gtk::TreeModel::Row row = *iter; - std::string upath = Glib::ustring(row[directories().view().m_col_path]); + std::string upath = Glib::ustring(row[directories.view().m_col_path]); boost::filesystem::path fs_path(upath); if (boost::filesystem::is_directory(fs_path)) { - directories().m_TreeView.row_expanded(path) ? - directories().m_TreeView.collapse_row(path) : - directories().m_TreeView.expand_row(path, false); + 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]; + sstm << row[directories.view().m_col_path]; std::string file = sstm.str(); OnOpenFile(file); } @@ -357,21 +368,6 @@ void Notebook::Controller::BufferChangeHandler(Glib::RefPtr }); } -void Notebook::Controller::set_source_handlers(Source::Controller& controller) { - //Add star on tab label when the page is not saved: - controller.buffer()->signal_changed().connect([this]() { - if(text_vec_.at(CurrentPage())->is_saved) { - std::string path=text_vec_.at(CurrentPage())->view->file_path; - size_t pos = path.find_last_of("/\\"); - std::string filename=path; - if(pos!=std::string::npos) - filename=path.substr(pos+1); - Notebook().set_tab_label_text(*(Notebook().get_nth_page(CurrentPage())), filename+"*"); - } - text_vec_.at(CurrentPage())->is_saved=false; - }); -} - std::string Notebook::Controller::CurrentPagePath(){ return text_vec_.at(CurrentPage())->view->file_path; } diff --git a/juci/notebook.h b/juci/notebook.h index 21791ba..98af702 100644 --- a/juci/notebook.h +++ b/juci/notebook.h @@ -61,25 +61,20 @@ namespace Notebook { void OnOpenFile(std::string filename); bool ScrollEventCallback(GdkEventScroll* scroll_event); int Pages(); - Directories::Controller& directories() { return directories_; } Gtk::Paned& view(); void Search(bool forward); - Source::Config& source_config() { return source_config_; } std::string OnSaveFileAs(); - bool LegalExtension(std::string extension); std::string project_path; - protected: - void set_source_handlers(Source::Controller& controller); + Directories::Controller directories; private: void CreateKeybindings(Keybindings::Controller& keybindings); void AskToSaveDialog(); Glib::RefPtr m_refBuilder; Glib::RefPtr refActionGroup; - Source::Config source_config_; - Directories::Controller directories_; + Source::Config& source_config; View view_; Model model_; - bool is_new_file_; + bool is_new_file_; //TODO: Remove this Entry::Controller entry_; std::vector > text_vec_; diff --git a/juci/selectiondialog.h b/juci/selectiondialog.h index 70e16de..f8479ce 100644 --- a/juci/selectiondialog.h +++ b/juci/selectiondialog.h @@ -1,3 +1,6 @@ +#ifndef JUCI_SELECTIONDIALOG_H_ +#define JUCI_SELECTIONDIALOG_H_ + #include "gtkmm.h" #include "logging.h" #include "source.h" @@ -16,4 +19,6 @@ private: Gtk::TextView& text_view; Gtk::ScrolledWindow scrolled_window; Gtk::ListViewText list_view_text; -}; \ No newline at end of file +}; + +#endif // JUCI_SELECTIONDIALOG_H_ \ No newline at end of file diff --git a/juci/source.h b/juci/source.h index 52d754f..dce111d 100644 --- a/juci/source.h +++ b/juci/source.h @@ -11,10 +11,6 @@ #include #include "gtksourceviewmm.h" -namespace Notebook { - class Controller; -} - namespace Source { class Config { public: diff --git a/juci/terminal.cc b/juci/terminal.cc index 83f8205..d6b653d 100644 --- a/juci/terminal.cc +++ b/juci/terminal.cc @@ -87,11 +87,9 @@ void Terminal::Controller::ExecuteCommand(std::string command, std::string mode) FILE* p = NULL; std::cout << command << std::endl; p = popen(command.c_str(), mode.c_str()); - std::cout << "KJØRTE FINT!" << std::endl; if (p == NULL) { PrintMessage("juCi++ ERROR: Failed to run command" + command + "\n"); }else { - std::cout << "SKRIVER UT KOMMANDO RESULAT" << std::endl; char buffer[1028]; while (fgets(buffer, 1028, p) != NULL) { PrintMessage(buffer); diff --git a/juci/window.cc b/juci/window.cc index e3c116a..47ef193 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -73,7 +73,7 @@ Window::Window() : terminal_.SetFolderCommand(path); } terminal_.Compile(); - std::string executable = notebook_.directories(). + std::string executable = notebook_.directories. GetCmakeVarValue(path,"add_executable"); terminal_.Run(executable); running.unlock(); @@ -140,7 +140,7 @@ void Window::OnFileOpenFolder() { { std::string project_path=dialog.get_filename(); notebook_.project_path=project_path; - notebook_.directories().open_folder(project_path); + notebook_.directories.open_folder(project_path); break; } case(Gtk::RESPONSE_CANCEL):