Browse Source

Now reopens folder and files from last session if starting juci without parameters. Related to issue mentioned in #170

merge-requests/365/head
eidheim 10 years ago
parent
commit
033f5e76de
  1. 17
      src/juci.cc
  2. 13
      src/window.cc

17
src/juci.cc

@ -44,6 +44,23 @@ int Application::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>
void Application::on_activate() {
add_window(Window::get());
Window::get().show();
if(directories.empty() && files.empty()) {
try {
boost::property_tree::ptree pt;
boost::property_tree::read_json((Config::get().juci_home_path()/"last_session.json").string(), pt);
auto folder=pt.get<std::string>("folder");
if(!folder.empty())
directories.emplace_back(folder);
for(auto &v: pt.get_child("files")) {
std::string file=v.second.data();
if(!file.empty())
files.emplace_back(file);
}
}
catch(const std::exception &e) {}
}
bool first_directory=true;
for(auto &directory: directories) {
if(first_directory) {

13
src/window.cc

@ -803,6 +803,19 @@ bool Window::on_key_press_event(GdkEventKey *event) {
}
bool Window::on_delete_event(GdkEventAny *event) {
try {
boost::property_tree::ptree pt_root, pt_files;
pt_root.put("folder", Directories::get().path.string());
for(int c=0;c<notebook.size();c++) {
boost::property_tree::ptree pt_child;
pt_child.put("", notebook.get_view(c)->file_path.string());
pt_files.push_back(std::make_pair("", pt_child));
}
pt_root.add_child("files", pt_files);
boost::property_tree::write_json((Config::get().juci_home_path()/"last_session.json").string(), pt_root);
}
catch(const std::exception &) {}
auto size=notebook.size();
for(int c=0;c<size;c++) {
if(!notebook.close_current_page())

Loading…
Cancel
Save