Browse Source

Now opens the last current file tab when starting juci without parameters

merge-requests/365/head
eidheim 10 years ago
parent
commit
43f6e87081
  1. 8
      src/juci.cc
  2. 2
      src/window.cc

8
src/juci.cc

@ -45,6 +45,8 @@ void Application::on_activate() {
add_window(Window::get()); add_window(Window::get());
Window::get().show(); Window::get().show();
std::string last_current_file;
if(directories.empty() && files.empty()) { if(directories.empty() && files.empty()) {
try { try {
boost::property_tree::ptree pt; boost::property_tree::ptree pt;
@ -57,8 +59,9 @@ void Application::on_activate() {
if(!file.empty()) if(!file.empty())
files.emplace_back(file); files.emplace_back(file);
} }
last_current_file=pt.get<std::string>("current_file");
} }
catch(const std::exception &e) {} catch(const std::exception &) {}
} }
bool first_directory=true; bool first_directory=true;
@ -90,6 +93,9 @@ void Application::on_activate() {
for(auto &error: errors) for(auto &error: errors)
Terminal::get().print(error, true); Terminal::get().print(error, true);
if(!last_current_file.empty())
Notebook::get().open(last_current_file);
} }
void Application::on_startup() { void Application::on_startup() {

2
src/window.cc

@ -812,6 +812,8 @@ bool Window::on_delete_event(GdkEventAny *event) {
pt_files.push_back(std::make_pair("", pt_child)); pt_files.push_back(std::make_pair("", pt_child));
} }
pt_root.add_child("files", pt_files); pt_root.add_child("files", pt_files);
if(notebook.get_current_page()!=-1)
pt_root.put("current_file", notebook.get_current_view()->file_path.string());
boost::property_tree::write_json((Config::get().juci_home_path()/"last_session.json").string(), pt_root); boost::property_tree::write_json((Config::get().juci_home_path()/"last_session.json").string(), pt_root);
} }
catch(const std::exception &) {} catch(const std::exception &) {}

Loading…
Cancel
Save