Browse Source

Slight cleanup of project

merge-requests/365/head
eidheim 10 years ago
parent
commit
da0dde1d6f
  1. 15
      src/notebook.cc
  2. 4
      src/notebook.h
  3. 4
      src/project.h
  4. 26
      src/window.cc
  5. 2
      src/window.h

15
src/notebook.cc

@ -354,21 +354,6 @@ boost::filesystem::path Notebook::get_current_folder() {
return current_path;
}
std::unique_ptr<Project> Notebook::get_project() {
if(get_current_page()!=-1) {
if(get_current_view()->language->get_id()=="markdown")
return std::unique_ptr<Project>(new ProjectMarkdown(*this));
if(get_current_view()->language->get_id()=="python")
return std::unique_ptr<Project>(new ProjectPython(*this));
if(get_current_view()->language->get_id()=="js")
return std::unique_ptr<Project>(new ProjectJavaScript(*this));
if(get_current_view()->language->get_id()=="html")
return std::unique_ptr<Project>(new ProjectHTML(*this));
}
return std::unique_ptr<Project>(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);

4
src/notebook.h

@ -5,13 +5,10 @@
#include "gtkmm.h"
#include "source.h"
#include "source_clang.h"
#include "project.h"
#include <type_traits>
#include <map>
#include <sigc++/sigc++.h>
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<Project> get_project();
Gtk::Label info;
Gtk::Label status;

4
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 <boost/filesystem.hpp>
#include "directories.h"
@ -9,8 +9,6 @@
#include <mutex>
#include "tooltips.h"
class Notebook; //Avoiding this circular include would lead to bloated code
class Project {
public:
Project(Notebook &notebook) : notebook(notebook) {}

26
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<std::pair<std::string, std::string> >(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<std::pair<std::string, std::string> >(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<Project> 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<Project>(new ProjectMarkdown(notebook));
if(language_id=="python")
return std::unique_ptr<Project>(new ProjectPython(notebook));
if(language_id=="js")
return std::unique_ptr<Project>(new ProjectJavaScript(notebook));
if(language_id=="html")
return std::unique_ptr<Project>(new ProjectHTML(notebook));
}
return std::unique_ptr<Project>(new ProjectClang(notebook));
}

2
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<Project> get_project();
};
#endif // JUCI_WINDOW_H

Loading…
Cancel
Save