Browse Source

use new filesystem functions for home path

xdg
Jørgen Lien Sellæg 5 years ago
parent
commit
beea90b28f
  1. 10
      src/config.cpp
  2. 2
      src/config.hpp
  3. 2
      src/project.cpp
  4. 2
      src/snippets.cpp
  5. 2
      src/source.cpp
  6. 6
      src/window.cpp

10
src/config.cpp

@ -11,8 +11,8 @@ Config::Config() {
if(home_path.empty())
throw std::runtime_error("Could not find home path");
home_juci_path = filesystem::get_config_path() / "juci";
juci_config_file = home_juci_path / "config.json";
juci_config_path = filesystem::get_config_path() / "juci";
juci_config_file = juci_config_path / "config.json";
}
void Config::load() {
@ -30,12 +30,12 @@ void Config::load() {
}
}
boost::filesystem::create_directories(home_juci_path);
boost::filesystem::create_directories(juci_config_path);
if(!boost::filesystem::exists(juci_config_file))
filesystem::write(juci_config_file, default_config_file);
auto juci_style_path = home_juci_path / "styles";
auto juci_style_path = juci_config_path / "styles";
boost::filesystem::create_directories(juci_style_path);
juci_style_path /= "juci-light.xml";
@ -81,7 +81,7 @@ void Config::update(boost::property_tree::ptree &cfg) {
it_version->second.data() = JUCI_VERSION;
}
auto style_path = home_juci_path / "styles";
auto style_path = juci_config_path / "styles";
filesystem::write(style_path / "juci-light.xml", juci_light_style);
filesystem::write(style_path / "juci-dark.xml", juci_dark_style);
filesystem::write(style_path / "juci-dark-blue.xml", juci_dark_blue_style);

2
src/config.hpp

@ -133,7 +133,7 @@ public:
Source source;
Log log;
boost::filesystem::path home_juci_path;
boost::filesystem::path juci_config_path;
boost::filesystem::path juci_config_file;
private:

2
src/project.cpp

@ -73,7 +73,7 @@ void Project::on_save(size_t index) {
if(!view)
return;
if(view->file_path == Config::get().home_juci_path / "snippets.json") {
if(view->file_path == Config::get().juci_config_path / "snippets.json") {
Snippets::get().load();
for(auto view : Notebook::get().get_views())
view->set_snippets();

2
src/snippets.cpp

@ -5,7 +5,7 @@
#include <boost/property_tree/json_parser.hpp>
void Snippets::load() {
auto snippets_file = Config::get().home_juci_path / "snippets.json";
auto snippets_file = Config::get().juci_config_path / "snippets.json";
boost::system::error_code ec;
if(!boost::filesystem::exists(snippets_file, ec))

2
src/source.cpp

@ -41,7 +41,7 @@ Glib::RefPtr<Gsv::StyleSchemeManager> Source::StyleSchemeManager::get_default()
static auto instance = Gsv::StyleSchemeManager::create();
static bool first = true;
if(first) {
instance->prepend_search_path((Config::get().home_juci_path / "styles").string());
instance->prepend_search_path((Config::get().juci_config_path / "styles").string());
first = false;
}
return instance;

6
src/window.cpp

@ -282,7 +282,7 @@ void Window::set_menu_actions() {
Notebook::get().open(Config::get().juci_config_file);
});
menu.add_action("snippets", []() {
Notebook::get().open(Config::get().home_juci_path / "snippets.json");
Notebook::get().open(Config::get().juci_config_path / "snippets.json");
});
menu.add_action("quit", [this]() {
close();
@ -2210,7 +2210,7 @@ void Window::save_session() {
window_pt.put("height", height);
root_pt.add_child("window", window_pt);
boost::property_tree::write_json((Config::get().home_juci_path / "last_session.json").string(), root_pt);
boost::property_tree::write_json((Config::get().juci_config_path / "last_session.json").string(), root_pt);
}
catch(...) {
}
@ -2219,7 +2219,7 @@ void Window::save_session() {
void Window::load_session(std::vector<boost::filesystem::path> &directories, std::vector<std::pair<boost::filesystem::path, size_t>> &files, std::vector<std::pair<int, int>> &file_offsets, std::string &current_file, bool read_directories_and_files) {
try {
boost::property_tree::ptree root_pt;
boost::property_tree::read_json((Config::get().home_juci_path / "last_session.json").string(), root_pt);
boost::property_tree::read_json((Config::get().juci_config_path / "last_session.json").string(), root_pt);
if(read_directories_and_files) {
auto folder = root_pt.get<std::string>("folder");
if(!folder.empty() && boost::filesystem::exists(folder) && boost::filesystem::is_directory(folder))

Loading…
Cancel
Save