Browse Source

Fixes to directory right click methods

merge-requests/365/head
eidheim 10 years ago
parent
commit
ef54c0a52c
  1. 18
      src/directories.cc
  2. 4
      src/notebook.cc
  3. 1
      src/notebook.h

18
src/directories.cc

@ -212,6 +212,8 @@ Directories::Directories() : Gtk::TreeView(), stop_update_thread(false) {
menu_item_rename.set_label("Rename"); menu_item_rename.set_label("Rename");
menu_item_rename.signal_activate().connect([this] { menu_item_rename.signal_activate().connect([this] {
if(menu_popup_row_path.empty())
return;
EntryBox::get().clear(); EntryBox::get().clear();
auto source_path=std::make_shared<boost::filesystem::path>(menu_popup_row_path); auto source_path=std::make_shared<boost::filesystem::path>(menu_popup_row_path);
EntryBox::get().entries.emplace_back(menu_popup_row_path.filename().string(), [this, source_path](const std::string& content){ 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'); Terminal::get().print("Error: could not rename "+source_path->string()+": "+ec.message()+'\n');
else { else {
update(); update();
select(target_path);
for(int c=0;c<Notebook::get().size();c++) { for(int c=0;c<Notebook::get().size();c++) {
auto view=Notebook::get().get_view(c); auto view=Notebook::get().get_view(c);
@ -238,8 +241,19 @@ Directories::Directories() : Gtk::TreeView(), stop_update_thread(false) {
view->file_path=new_file_path; view->file_path=new_file_path;
} }
} }
else if(view->file_path==menu_popup_row_path) else if(view->file_path==*source_path) {
view->get_buffer()->set_modified(); 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(); EntryBox::get().hide();

4
src/notebook.cc

@ -329,6 +329,10 @@ boost::filesystem::path Notebook::get_current_folder() {
return boost::filesystem::path(); 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) { bool Notebook::save_modified_dialog(int page) {
Gtk::MessageDialog dialog((Gtk::Window&)(*get_toplevel()), "Save file!", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); Gtk::MessageDialog dialog((Gtk::Window&)(*get_toplevel()), "Save file!", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO);
dialog.set_default_response(Gtk::RESPONSE_YES); dialog.set_default_response(Gtk::RESPONSE_YES);

1
src/notebook.h

@ -36,6 +36,7 @@ public:
bool save_current(); bool save_current();
void configure(int view_nr); void configure(int view_nr);
boost::filesystem::path get_current_folder(); boost::filesystem::path get_current_folder();
void set_tab_label(int page, const std::string &label);
Gtk::Label info; Gtk::Label info;
Gtk::Label status; Gtk::Label status;

Loading…
Cancel
Save