Browse Source

Cleanup of directory view right click menus. Also now checks if target path exists on rename

merge-requests/365/head
eidheim 10 years ago
parent
commit
7d10fa491b
  1. 22
      src/directories.cc

22
src/directories.cc

@ -216,12 +216,19 @@ Directories::Directories() : Gtk::TreeView(), stop_update_thread(false) {
EntryBox::get().entries.emplace_back(menu_popup_row_path.filename().string(), [this, source_path](const std::string &content){
bool is_directory=boost::filesystem::is_directory(*source_path);
boost::system::error_code ec;
auto target_path=source_path->parent_path()/content;
if(boost::filesystem::exists(target_path)) {
Terminal::get().print("Error: could not rename to "+target_path.string()+": already exists\n", true);
return;
}
boost::system::error_code ec;
boost::filesystem::rename(*source_path, target_path, ec);
if(ec)
if(ec) {
Terminal::get().print("Error: could not rename "+source_path->string()+": "+ec.message()+'\n', true);
else {
return;
}
update();
select(target_path);
@ -252,7 +259,6 @@ Directories::Directories() : Gtk::TreeView(), stop_update_thread(false) {
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();
}
@ -313,11 +319,15 @@ Directories::Directories() : Gtk::TreeView(), stop_update_thread(false) {
update();
Notebook::get().open(target_path);
}
else
else {
Terminal::get().print("Error: could not create "+target_path.string()+'\n', true);
return;
}
else
}
else {
Terminal::get().print("Error: could not create "+target_path.string()+": file already exists\n", true);
return;
}
EntryBox::get().hide();
});

Loading…
Cancel
Save