Browse Source

Remove directories from Notebook

merge-requests/365/head
Jørgen Lien Sellæg 10 years ago
parent
commit
bf92d588c4
  1. 4
      src/notebook.cc
  2. 3
      src/notebook.h
  3. 2
      src/window.cc

4
src/notebook.cc

@ -27,7 +27,7 @@ namespace sigc {
#endif #endif
} }
Notebook::Notebook(Directories &directories) : Gtk::Notebook(), directories(directories) { Notebook::Notebook() : Gtk::Notebook() {
Gsv::init(); Gsv::init();
} }
@ -71,6 +71,7 @@ void Notebook::open(const boost::filesystem::path &file_path) {
auto language=Source::guess_language(file_path); auto language=Source::guess_language(file_path);
if(language && (language->get_id()=="chdr" || language->get_id()=="cpphdr" || language->get_id()=="c" || language->get_id()=="cpp" || language->get_id()=="objc")) { if(language && (language->get_id()=="chdr" || language->get_id()=="cpphdr" || language->get_id()=="c" || language->get_id()=="cpp" || language->get_id()=="objc")) {
boost::filesystem::path project_path; boost::filesystem::path project_path;
auto directories = *Singleton::directories();
if(directories.cmake && directories.cmake->project_path!="" && file_path.generic_string().substr(0, directories.cmake->project_path.generic_string().size()+1)==directories.cmake->project_path.generic_string()+'/') { if(directories.cmake && directories.cmake->project_path!="" && file_path.generic_string().substr(0, directories.cmake->project_path.generic_string().size()+1)==directories.cmake->project_path.generic_string()+'/') {
project_path=directories.cmake->project_path; project_path=directories.cmake->project_path;
if(boost::filesystem::exists(project_path.string()+"/CMakeLists.txt") && !boost::filesystem::exists(project_path.string()+"/compile_commands.json")) if(boost::filesystem::exists(project_path.string()+"/CMakeLists.txt") && !boost::filesystem::exists(project_path.string()+"/compile_commands.json"))
@ -180,6 +181,7 @@ bool Notebook::save(int page, bool reparse_needed) {
//If CMakeLists.txt have been modified: //If CMakeLists.txt have been modified:
//TODO: recreate cmake even without directories open? //TODO: recreate cmake even without directories open?
if(view->file_path.filename()=="CMakeLists.txt") { if(view->file_path.filename()=="CMakeLists.txt") {
auto directories = *Singleton::directories();
if(directories.cmake && directories.cmake->project_path!="" && view->file_path.generic_string().substr(0, directories.cmake->project_path.generic_string().size()+1)==directories.cmake->project_path.generic_string()+'/' && CMake::create_compile_commands(directories.cmake->project_path)) { if(directories.cmake && directories.cmake->project_path!="" && view->file_path.generic_string().substr(0, directories.cmake->project_path.generic_string().size()+1)==directories.cmake->project_path.generic_string()+'/' && CMake::create_compile_commands(directories.cmake->project_path)) {
for(auto source_view: source_views) { for(auto source_view: source_views) {
if(auto source_clang_view=dynamic_cast<Source::ClangView*>(source_view)) { if(auto source_clang_view=dynamic_cast<Source::ClangView*>(source_view)) {

3
src/notebook.h

@ -12,7 +12,7 @@
class Notebook : public Gtk::Notebook { class Notebook : public Gtk::Notebook {
public: public:
Notebook(Directories &directories); Notebook();
Source::View* get_view(int page); Source::View* get_view(int page);
size_t get_index(int page); size_t get_index(int page);
int size(); int size();
@ -25,7 +25,6 @@ public:
private: private:
bool save_modified_dialog(); bool save_modified_dialog();
Directories &directories;
std::vector<Source::View*> source_views; //Is NOT freed in destructor, this is intended for quick program exit. std::vector<Source::View*> source_views; //Is NOT freed in destructor, this is intended for quick program exit.
std::vector<std::unique_ptr<Gtk::Widget> > source_maps; std::vector<std::unique_ptr<Gtk::Widget> > source_maps;
std::vector<std::unique_ptr<Gtk::ScrolledWindow> > scrolled_windows; std::vector<std::unique_ptr<Gtk::ScrolledWindow> > scrolled_windows;

2
src/window.cc

@ -30,7 +30,7 @@ void Window::generate_keybindings() {
} }
} }
Window::Window() : box(Gtk::ORIENTATION_VERTICAL), notebook(*Singleton::directories()), compiling(false) { Window::Window() : box(Gtk::ORIENTATION_VERTICAL), compiling(false) {
JDEBUG("start"); JDEBUG("start");
set_title("juCi++"); set_title("juCi++");
set_events(Gdk::POINTER_MOTION_MASK|Gdk::FOCUS_CHANGE_MASK|Gdk::SCROLL_MASK); set_events(Gdk::POINTER_MOTION_MASK|Gdk::FOCUS_CHANGE_MASK|Gdk::SCROLL_MASK);

Loading…
Cancel
Save