Add config for darwin
This commit is contained in:
parent
9b9df72744
commit
d0cdfe02d7
|
@ -26,15 +26,27 @@ void MyPrefs::btnok_clicked()
|
|||
std::fstream outfile;
|
||||
|
||||
// Initalize Config for path
|
||||
if (unix_file_system_detected())
|
||||
switch (get_os_type())
|
||||
{
|
||||
case OS_Type::Linux:
|
||||
config_unix = entry_path->get_text();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
break;
|
||||
case OS_Type::Windows:
|
||||
config_win32 = entry_path->get_text();
|
||||
break;
|
||||
case OS_Type::Darwin:
|
||||
config_darwin = entry_path->get_text();
|
||||
break;
|
||||
}
|
||||
// if (get_os_type() == OS_Type::Linux)
|
||||
// {
|
||||
// config_unix = entry_path->get_text();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// config_win32 = entry_path->get_text();
|
||||
// }
|
||||
// Open the config file
|
||||
outfile.open("xe_config.json", std::ios_base::out);
|
||||
/*OutPut contents to the file
|
||||
|
@ -43,8 +55,10 @@ void MyPrefs::btnok_clicked()
|
|||
"Longterm":"x.x",
|
||||
"Stable":"x.x",
|
||||
"Develop":"x.x",
|
||||
"dark_mode":false,
|
||||
"Release_Path_Unix":"",
|
||||
"Release_Path_Win32":""
|
||||
"Release_Path_Win32":"",
|
||||
"Release_Path_Darwin":""
|
||||
}
|
||||
*/
|
||||
if (outfile.is_open())
|
||||
|
@ -59,7 +73,9 @@ void MyPrefs::btnok_clicked()
|
|||
"Stable":"",
|
||||
"Develop":"",
|
||||
"Release_Path_Unix":"",
|
||||
"Release_Path_Win32":""
|
||||
"Release_Path_Win32":"",
|
||||
"Release_Path_Darwin":"",
|
||||
"dark_mode":false
|
||||
}
|
||||
)");
|
||||
|
||||
|
@ -69,6 +85,8 @@ void MyPrefs::btnok_clicked()
|
|||
out_data["Develop"] = entry_dev->get_text();
|
||||
out_data["Release_Path_Unix"] = config_unix;
|
||||
out_data["Release_Path_Win32"] = config_win32;
|
||||
out_data["Release_Path_Darwin"] = config_darwin;
|
||||
out_data["dark_mode"] = dark_mode;
|
||||
outfile << out_data;
|
||||
|
||||
// Set Current json data
|
||||
|
@ -115,6 +133,8 @@ void MyPrefs::reset_entries()
|
|||
config_devel = data["Develop"];
|
||||
config_unix = data["Release_Path_Unix"];
|
||||
config_win32 = data["Release_Path_Win32"];
|
||||
config_darwin = data["Release_Path_Darwin"];
|
||||
dark_mode = data["dark_mode"];
|
||||
|
||||
// Set text from json file data
|
||||
entry_lts->set_text(config_longterm);
|
||||
|
@ -122,14 +142,26 @@ void MyPrefs::reset_entries()
|
|||
entry_dev->set_text(config_devel);
|
||||
|
||||
// Use different path for Linux filesystem and Windows
|
||||
if (unix_file_system_detected())
|
||||
switch (get_os_type())
|
||||
{
|
||||
case OS_Type::Linux:
|
||||
entry_path->set_text(config_unix);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
case OS_Type::Windows:
|
||||
entry_path->set_text(config_win32);
|
||||
break;
|
||||
case OS_Type::Darwin:
|
||||
entry_path->set_text(config_darwin);
|
||||
break;
|
||||
}
|
||||
// if (get_os_type() == OS_Type::Linux)
|
||||
// {
|
||||
// entry_path->set_text(config_unix);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// entry_path->set_text(config_win32);
|
||||
// }
|
||||
}
|
||||
|
||||
MyPrefs *MyPrefs::create()
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <gtkmm.h>
|
||||
#include <fstream>
|
||||
#include "../json_nlohmann/json.hpp"
|
||||
#include "os_detector.hh"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -40,9 +41,10 @@ private:
|
|||
// Child widgets
|
||||
Gtk::Entry *entry_lts, *entry_stable, *entry_dev, *entry_path;
|
||||
Gtk::Button *btnpath, *btnok, *btncancel;
|
||||
bool dark_mode;
|
||||
|
||||
// Strings to store path on Windows and Unix-Like systems
|
||||
std::string config_win32, config_unix;
|
||||
std::string config_win32, config_unix, config_darwin;
|
||||
json data, data_backup;
|
||||
|
||||
// Messagebox
|
||||
|
@ -57,11 +59,11 @@ private:
|
|||
void reset_entries();
|
||||
};
|
||||
|
||||
static inline bool unix_file_system_detected()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
// static inline bool unix_file_system_detected()
|
||||
// {
|
||||
// #ifdef _WIN32
|
||||
// return false;
|
||||
// #else
|
||||
// return true;
|
||||
// #endif
|
||||
// }
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
#pragma once
|
||||
// Defining the OS
|
||||
enum class OS_Type{
|
||||
Linux,
|
||||
macOS,
|
||||
Darwin,
|
||||
Windows
|
||||
};
|
||||
|
||||
static inline OS_Type os_detector(){
|
||||
static inline OS_Type get_os_type(){
|
||||
#if defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
|
||||
// #define COMPILED_IN_LINUX
|
||||
return OS_Type::Linux;
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
// #define COMPILED_IN_MACOS
|
||||
return OS_Type::macOS;
|
||||
// #define COMPILED_IN_Darwin
|
||||
return OS_Type::Darwin;
|
||||
#elif defined(_WIN32) || defined(_WIN64)
|
||||
// #define COMPILED_IN_WINDOWS
|
||||
return OS_Type::Windows;
|
||||
|
|
|
@ -81,16 +81,31 @@ static void path_translate(char *result, const char *version)
|
|||
{
|
||||
// Just combine the release file path and filename
|
||||
std::string path;
|
||||
if (rel_unix_file_system_detected())
|
||||
switch (get_os_type())
|
||||
{
|
||||
case OS_Type::Linux:
|
||||
path = data1["Release_Path_Unix"];
|
||||
sprintf(result, "%s/xe-%c.x", path.c_str(), version[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
case OS_Type::Darwin:
|
||||
path = data1["Release_Path_Darwin"];
|
||||
sprintf(result, "%s/xe-%c.x", path.c_str(), version[0]);
|
||||
break;
|
||||
case OS_Type::Windows:
|
||||
path = data1["Release_Path_Win32"];
|
||||
sprintf(result, "%s\\xe-%c.x", path.c_str(), version[0]);
|
||||
break;
|
||||
}
|
||||
// if (rel_unix_file_system_detected())
|
||||
// {
|
||||
// path = data1["Release_Path_Unix"];
|
||||
// sprintf(result, "%s/xe-%c.x", path.c_str(), version[0]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// path = data1["Release_Path_Win32"];
|
||||
// sprintf(result, "%s\\xe-%c.x", path.c_str(), version[0]);
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -170,6 +185,7 @@ void develop(struct tm *local, const char *devel, char *str)
|
|||
return;
|
||||
}
|
||||
|
||||
void json_config_init(json &user_data){
|
||||
void json_config_init(json &user_data)
|
||||
{
|
||||
data1 = user_data;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __XE_RELEASE_
|
||||
|
||||
#include "../json_nlohmann/json.hpp"
|
||||
#include "os_detector.hh"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
@ -19,12 +20,12 @@ void stable(struct tm *local,const char * rel,char *str);
|
|||
|
||||
void develop(struct tm *local,const char * devel,char *str);
|
||||
|
||||
static inline bool rel_unix_file_system_detected(){
|
||||
#ifdef _WIN32
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
// static inline bool rel_unix_file_system_detected(){
|
||||
// #ifdef _WIN32
|
||||
// return false;
|
||||
// #else
|
||||
// return true;
|
||||
// #endif
|
||||
// }
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue