diff --git a/src/directories.cc b/src/directories.cc index 152828d..eba9370 100644 --- a/src/directories.cc +++ b/src/directories.cc @@ -212,6 +212,8 @@ Directories::Directories() : Gtk::TreeView(), stop_update_thread(false) { menu_item_rename.set_label("Rename"); menu_item_rename.signal_activate().connect([this] { + if(menu_popup_row_path.empty()) + return; EntryBox::get().clear(); auto source_path=std::make_shared(menu_popup_row_path); EntryBox::get().entries.emplace_back(menu_popup_row_path.filename().string(), [this, source_path](const std::string& content){ @@ -224,6 +226,7 @@ Directories::Directories() : Gtk::TreeView(), stop_update_thread(false) { Terminal::get().print("Error: could not rename "+source_path->string()+": "+ec.message()+'\n'); else { update(); + select(target_path); for(int c=0;cfile_path=new_file_path; } } - else if(view->file_path==menu_popup_row_path) - view->get_buffer()->set_modified(); + else if(view->file_path==*source_path) { + view->file_path=target_path; + Notebook::get().set_tab_label(c, target_path.filename().string()); + std::string old_language_id; + if(view->language) + old_language_id=view->language->get_id(); + view->language=Source::guess_language(target_path); + std::string new_language_id; + if(view->language) + new_language_id=view->language->get_id(); + if(new_language_id!=old_language_id) + Terminal::get().print("Warning: language for "+target_path.string()+" has changed. Please reopen the file\n"); + } } EntryBox::get().hide(); diff --git a/src/notebook.cc b/src/notebook.cc index ea9124b..df4f9c2 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -329,6 +329,10 @@ boost::filesystem::path Notebook::get_current_folder() { return boost::filesystem::path(); } +void Notebook::set_tab_label(int page, const std::string &label) { + tab_labels.at(get_index(page))->label.set_text(label); +} + 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 6bb3127..0654165 100644 --- a/src/notebook.h +++ b/src/notebook.h @@ -36,6 +36,7 @@ public: bool save_current(); void configure(int view_nr); boost::filesystem::path get_current_folder(); + void set_tab_label(int page, const std::string &label); Gtk::Label info; Gtk::Label status;