From 97bae361f4298c5432e7f864cc402e29ce550f50 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 7 Oct 2015 10:48:58 +0200 Subject: [PATCH] Added label to Run Command, and some minor cleanup. --- src/notebook.cc | 18 ++++++++++-------- src/source.cc | 2 +- src/source.h | 2 +- src/window.cc | 8 +++++++- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/notebook.cc b/src/notebook.cc index 45d1f2a..2987538 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -89,7 +89,7 @@ void Notebook::open(const boost::filesystem::path &file_path) { source_views.emplace_back(new Source::ClangView(file_path, project_path, language)); } else - source_views.emplace_back(new Source::GenericView(file_path, language)); + source_views.emplace_back(new Source::GenericView(file_path, "", language)); source_views.back()->on_update_status=[this](Source::View* view, const std::string &status) { if(get_current_page()!=-1 && get_current_view()==view) @@ -191,13 +191,15 @@ bool Notebook::save(int page, bool reparse_needed) { project_path=cmake.project_path; } } - for(auto source_view: source_views) { - if(auto source_clang_view=dynamic_cast(source_view)) { - if(project_path==source_clang_view->project_path) { - if(source_clang_view->restart_parse()) - Singleton::terminal()->async_print("Reparsing "+source_clang_view->file_path.string()+"\n"); - else - Singleton::terminal()->async_print("Error: failed to reparse "+source_clang_view->file_path.string()+". Please reopen the file manually.\n"); + if(project_path!="") { + for(auto source_view: source_views) { + if(auto source_clang_view=dynamic_cast(source_view)) { + if(project_path==source_clang_view->project_path) { + if(source_clang_view->restart_parse()) + Singleton::terminal()->async_print("Reparsing "+source_clang_view->file_path.string()+"\n"); + else + Singleton::terminal()->async_print("Error: failed to reparse "+source_clang_view->file_path.string()+". Please reopen the file manually.\n"); + } } } } diff --git a/src/source.cc b/src/source.cc index 1fb536a..34fe021 100644 --- a/src/source.cc +++ b/src/source.cc @@ -1254,7 +1254,7 @@ std::vector Source::View::spellcheck_get_suggestions(const Gtk::Tex ///////////////////// //// GenericView //// ///////////////////// -Source::GenericView::GenericView(const boost::filesystem::path &file_path, Glib::RefPtr language) : View(file_path, "", language) { +Source::GenericView::GenericView(const boost::filesystem::path &file_path, const boost::filesystem::path &project_path, Glib::RefPtr language) : View(file_path, project_path, language) { configure(); spellcheck_all=true; diff --git a/src/source.h b/src/source.h index acb9180..cbaaf45 100644 --- a/src/source.h +++ b/src/source.h @@ -181,7 +181,7 @@ namespace Source { static Glib::RefPtr create() {return Glib::RefPtr(new CompletionBuffer());} }; public: - GenericView(const boost::filesystem::path &file_path, Glib::RefPtr language); + GenericView(const boost::filesystem::path &file_path, const boost::filesystem::path &project_path, Glib::RefPtr language); void parse_language_file(Glib::RefPtr &completion_buffer, bool &has_context_class, const boost::property_tree::ptree &pt); }; diff --git a/src/window.cc b/src/window.cc index 8e4dac9..6663fa7 100644 --- a/src/window.cc +++ b/src/window.cc @@ -365,6 +365,12 @@ void Window::create_menu() { }); menu.action_group->add(Gtk::Action::create("ProjectRunCommand", "Run Command"), Gtk::AccelKey(menu.key_map["run_command"]), [this]() { entry_box.clear(); + entry_box.labels.emplace_back(); + auto label_it=entry_box.labels.begin(); + label_it->update=[label_it](int state, const std::string& message){ + label_it->set_text("Run Command directory order: file project path, file directory, opened directory, current directory"); + }; + label_it->update(0, ""); entry_box.entries.emplace_back(last_run_command, [this](const std::string& content){ if(content!="") { last_run_command=content; @@ -777,7 +783,7 @@ void Window::rename_token_entry() { entry_box.labels.emplace_back(); auto label_it=entry_box.labels.begin(); label_it->update=[label_it](int state, const std::string& message){ - label_it->set_text("Warning: only opened and parsed tabs will have its content renamed, and modified files will be saved."); + label_it->set_text("Warning: only opened and parsed tabs will have its content renamed, and modified files will be saved"); }; label_it->update(0, ""); entry_box.entries.emplace_back(token->spelling, [this, token](const std::string& content){