diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2da1c6f..e5e7cdb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,11 +16,15 @@ if(UNIX) #Checking if compiling on Ubuntu that has a buggy menu system execute_process(COMMAND ${LSB_RELEASE_BIN} -is OUTPUT_VARIABLE DISTRIBUTION OUTPUT_STRIP_TRAILING_WHITESPACE) if((DISTRIBUTION STREQUAL Ubuntu) OR (DISTRIBUTION STREQUAL LinuxMint)) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUBUNTU_BUGGED_MENU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJUCI_UBUNTU_BUGGED_MENU") endif() endif() endif() +if(MSYS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJUCI_CMAKE_INSTALL_PREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\"") +endif() + INCLUDE(FindPkgConfig) find_package(LibClang REQUIRED) diff --git a/src/config.cc b/src/config.cc index b39f1e7..ae8a5f7 100644 --- a/src/config.cc +++ b/src/config.cc @@ -9,7 +9,24 @@ using namespace std; //TODO: remove Config::Config() { - init_home_path(); + std::vector locations = {"JUCI_HOME", "HOME", "AppData"}; + char *ptr = nullptr; + for (auto &location : locations) { + ptr=std::getenv(location.c_str()); + if (ptr!=nullptr && boost::filesystem::exists(ptr)) { + home /= ptr; + home /= ".juci"; + break; + } + } + if(home.empty()) { + std::string searched_envs = "["; + for(auto &location : locations) + searched_envs+=location+", "; + searched_envs.erase(searched_envs.end()-2, searched_envs.end()); + searched_envs+="]"; + throw std::runtime_error("One of these environment variables needs to point to a writable directory to save configuration: " + searched_envs); + } } void Config::load() { @@ -169,29 +186,3 @@ void Config::GenerateDirectoryFilter() { for ( auto &i : ignore_json ) directories.ignored.emplace_back(i.second.get_value()); } - -void Config::init_home_path(){ - std::vector locations = JUCI_ENV_SEARCH_LOCATIONS; - char *ptr = nullptr; - for (auto &env : locations) { - ptr=std::getenv(env.c_str()); - if (ptr==nullptr) - continue; - else - if (boost::filesystem::exists(ptr)) { - home /= ptr; - home /= ".juci"; - break; - } - } - - if(home.empty()) { - std::string searched_envs = "["; - for(auto &env : locations) - searched_envs+=env+", "; - searched_envs.erase(searched_envs.end()-2, searched_envs.end()); - searched_envs+="]"; - throw std::runtime_error("One of these environment variables needs to point to a writable directory to save configuration: " + searched_envs); - } - return; -} diff --git a/src/config.h b/src/config.h index 405a98e..84886b4 100644 --- a/src/config.h +++ b/src/config.h @@ -83,7 +83,6 @@ private: void GenerateSource(); void GenerateDirectoryFilter(); - void init_home_path(); boost::property_tree::ptree cfg; boost::filesystem::path home; }; diff --git a/src/dialogs.cc b/src/dialogs.cc index 5604250..d2976bc 100644 --- a/src/dialogs.cc +++ b/src/dialogs.cc @@ -26,31 +26,31 @@ std::string open_dialog(const std::string &title, } std::string Dialog::open_folder() { - return open_dialog("Please choose a folder", + return open_dialog("Open Folder", {std::make_pair("Cancel", Gtk::RESPONSE_CANCEL),std::make_pair("Open", Gtk::RESPONSE_OK)}, Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); } std::string Dialog::new_file() { - return open_dialog("Please create a new file", + return open_dialog("New File", {std::make_pair("Cancel", Gtk::RESPONSE_CANCEL), std::make_pair("Save", Gtk::RESPONSE_OK)}, Gtk::FILE_CHOOSER_ACTION_SAVE); } std::string Dialog::new_folder() { - return open_dialog("Please create a new folder", + return open_dialog("New Folder", {std::make_pair("Cancel", Gtk::RESPONSE_CANCEL),std::make_pair("Create", Gtk::RESPONSE_OK)}, Gtk::FILE_CHOOSER_ACTION_CREATE_FOLDER); } std::string Dialog::open_file() { - return open_dialog("Please choose a file", + return open_dialog("Open File", {std::make_pair("Cancel", Gtk::RESPONSE_CANCEL),std::make_pair("Select", Gtk::RESPONSE_OK)}, Gtk::FILE_CHOOSER_ACTION_OPEN); } std::string Dialog::save_file_as(const boost::filesystem::path &file_path) { - return open_dialog("Please choose a file", + return open_dialog("Save File As", {std::make_pair("Cancel", Gtk::RESPONSE_CANCEL),std::make_pair("Save", Gtk::RESPONSE_OK)}, Gtk::FILE_CHOOSER_ACTION_SAVE, file_path.string()); } diff --git a/src/files.h b/src/files.h index c077227..954e322 100644 --- a/src/files.h +++ b/src/files.h @@ -2,8 +2,6 @@ #define JUCI_VERSION "0.9.4" -#define JUCI_ENV_SEARCH_LOCATIONS {"AppData", "HOME", "JUCI_HOME"} - const std::string configjson = "{\n" " \"version\": \""+std::string(JUCI_VERSION)+"\",\n" @@ -100,7 +98,7 @@ const std::string configjson = " },\n" " \"project\": {\n" #ifdef _WIN32 -" \"cmake_command\": \"cmake -G\\\"MSYS Makefiles\\\"\",\n" +" \"cmake_command\": \"cmake -G\\\"MSYS Makefiles\\\" -DCMAKE_INSTALL_PREFIX="+JUCI_CMAKE_INSTALL_PREFIX+"\",\n" #else " \"cmake_command\": \"cmake\",\n" #endif diff --git a/src/menu.cc b/src/menu.cc index 28669c1..cf3ef98 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -12,7 +12,7 @@ Menu::Menu() { void Menu::init() { auto accels=Singleton::config->menu.keys; for(auto &accel: accels) { -#ifdef UBUNTU_BUGGED_MENU +#ifdef JUCI_UBUNTU_BUGGED_MENU size_t pos=0; std::string second=accel.second; while((pos=second.find('<', pos))!=std::string::npos) { @@ -69,7 +69,7 @@ void Menu::init() { +accels["new_file"]+ //For Ubuntu... " " " " - " _New _Directory" + " _New _Folder" " app.new_folder" +accels["new_folder"]+ //For Ubuntu... " "