diff --git a/src/notebook.cc b/src/notebook.cc index 19c2822..bcd1780 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -354,21 +354,6 @@ boost::filesystem::path Notebook::get_current_folder() { return current_path; } -std::unique_ptr Notebook::get_project() { - if(get_current_page()!=-1) { - if(get_current_view()->language->get_id()=="markdown") - return std::unique_ptr(new ProjectMarkdown(*this)); - if(get_current_view()->language->get_id()=="python") - return std::unique_ptr(new ProjectPython(*this)); - if(get_current_view()->language->get_id()=="js") - return std::unique_ptr(new ProjectJavaScript(*this)); - if(get_current_view()->language->get_id()=="html") - return std::unique_ptr(new ProjectHTML(*this)); - } - - return std::unique_ptr(new ProjectClang(*this)); -} - bool Notebook::save_modified_dialog(int page) { Gtk::MessageDialog dialog((Gtk::Window&)(*get_toplevel()), "Save file!", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); dialog.set_default_response(Gtk::RESPONSE_YES); diff --git a/src/notebook.h b/src/notebook.h index 5f58308..1b6f2d8 100644 --- a/src/notebook.h +++ b/src/notebook.h @@ -5,13 +5,10 @@ #include "gtkmm.h" #include "source.h" #include "source_clang.h" -#include "project.h" #include #include #include -class Project; //Avoiding this would lead to bloated code - class Notebook : public Gtk::Notebook { class TabLabel : public Gtk::Box { public: @@ -33,7 +30,6 @@ public: void save_project_files(); void configure(int view_nr); boost::filesystem::path get_current_folder(); - std::unique_ptr get_project(); Gtk::Label info; Gtk::Label status; diff --git a/src/project.h b/src/project.h index a69960b..c6eded8 100644 --- a/src/project.h +++ b/src/project.h @@ -1,7 +1,7 @@ #ifndef JUCI_PROJECT_H_ #define JUCI_PROJECT_H_ -#include "notebook.h" //Avoiding this circular include would lead to bloated code +#include "notebook.h" #include "cmake.h" #include #include "directories.h" @@ -9,8 +9,6 @@ #include #include "tooltips.h" -class Notebook; //Avoiding this circular include would lead to bloated code - class Project { public: Project(Notebook ¬ebook) : notebook(notebook) {} diff --git a/src/window.cc b/src/window.cc index 8495edb..1da6258 100644 --- a/src/window.cc +++ b/src/window.cc @@ -575,7 +575,7 @@ void Window::set_menu_actions() { }); menu.add_action("project_set_run_arguments", [this]() { - project=notebook.get_project(); + project=get_project(); auto run_arguments=std::make_shared >(project->get_run_arguments()); if(run_arguments->second.empty()) return; @@ -605,7 +605,7 @@ void Window::set_menu_actions() { if(Config::get().window.save_on_compile_or_run) notebook.save_project_files(); - project=notebook.get_project(); + project=get_project(); project->compile_and_run(); }); menu.add_action("compile", [this]() { @@ -615,7 +615,7 @@ void Window::set_menu_actions() { if(Config::get().window.save_on_compile_or_run) notebook.save_project_files(); - project=notebook.get_project(); + project=get_project(); project->compile(); }); @@ -656,7 +656,7 @@ void Window::set_menu_actions() { #ifdef JUCI_ENABLE_DEBUG menu.add_action("debug_set_run_arguments", [this]() { - project=notebook.get_project(); + project=get_project(); auto run_arguments=std::make_shared >(project->debug_get_run_arguments()); if(run_arguments->second.empty()) return; @@ -688,7 +688,7 @@ void Window::set_menu_actions() { if(Config::get().window.save_on_compile_or_run) notebook.save_project_files(); - project=notebook.get_project(); + project=get_project(); project->debug_start([this](const std::string &status) { debug_status_mutex.lock(); @@ -1126,3 +1126,19 @@ void Window::rename_token_entry() { } } } + +std::unique_ptr Window::get_project() { + if(notebook.get_current_page()!=-1) { + auto language_id=notebook.get_current_view()->language->get_id(); + if(language_id=="markdown") + return std::unique_ptr(new ProjectMarkdown(notebook)); + if(language_id=="python") + return std::unique_ptr(new ProjectPython(notebook)); + if(language_id=="js") + return std::unique_ptr(new ProjectJavaScript(notebook)); + if(language_id=="html") + return std::unique_ptr(new ProjectHTML(notebook)); + } + + return std::unique_ptr(new ProjectClang(notebook)); +} diff --git a/src/window.h b/src/window.h index b0a5991..4fbfce5 100644 --- a/src/window.h +++ b/src/window.h @@ -60,6 +60,8 @@ private: bool case_sensitive_search=true; bool regex_search=false; bool search_entry_shown=false; + + std::unique_ptr get_project(); }; #endif // JUCI_WINDOW_H