Change config file to json
This commit is contained in:
parent
241211c4e9
commit
07aa1278a5
|
@ -6,6 +6,79 @@
|
||||||
"array": "cpp",
|
"array": "cpp",
|
||||||
"string": "cpp",
|
"string": "cpp",
|
||||||
"string_view": "cpp",
|
"string_view": "cpp",
|
||||||
"*.inc": "cpp"
|
"*.inc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"any": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"hash_map": "cpp",
|
||||||
|
"strstream": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"bitset": "cpp",
|
||||||
|
"cfenv": "cpp",
|
||||||
|
"charconv": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"codecvt": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"complex": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"condition_variable": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"forward_list": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"set": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"unordered_set": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"source_location": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"future": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"semaphore": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"stop_token": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"typeindex": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"valarray": "cpp",
|
||||||
|
"variant": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,6 +33,7 @@ MyDialog::MyDialog(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &re
|
||||||
entry_stable->set_text(config_stable);
|
entry_stable->set_text(config_stable);
|
||||||
entry_dev->set_text(config_devel);
|
entry_dev->set_text(config_devel);
|
||||||
}
|
}
|
||||||
|
json_file.close();
|
||||||
|
|
||||||
// std::string config;
|
// std::string config;
|
||||||
// if(readCfgFile("xe_config","Longterm",config)){
|
// if(readCfgFile("xe_config","Longterm",config)){
|
||||||
|
|
|
@ -56,7 +56,7 @@ MyWin::MyWin()
|
||||||
|
|
||||||
// Show everything
|
// Show everything
|
||||||
add(stack1);
|
add(stack1);
|
||||||
stack1.add(overlay,"main_page","WelCome");
|
stack1.add(overlay, "main_page", "WelCome");
|
||||||
switcher.set_stack(stack1);
|
switcher.set_stack(stack1);
|
||||||
show_all_children();
|
show_all_children();
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ MyWin::MyWin()
|
||||||
void MyWin::titlebar_init()
|
void MyWin::titlebar_init()
|
||||||
{
|
{
|
||||||
// Add HeaderBar
|
// Add HeaderBar
|
||||||
//header.set_title("Xe Release 15");
|
// header.set_title("Xe Release 15");
|
||||||
|
|
||||||
// Add stack widget
|
// Add stack widget
|
||||||
header.set_custom_title(switcher);
|
header.set_custom_title(switcher);
|
||||||
|
@ -86,7 +86,7 @@ void MyWin::titlebar_init()
|
||||||
add_action("configs", sigc::mem_fun(*this, &MyWin::config_dialog));
|
add_action("configs", sigc::mem_fun(*this, &MyWin::config_dialog));
|
||||||
add_action("back1", sigc::mem_fun(*this, &MyWin::background1));
|
add_action("back1", sigc::mem_fun(*this, &MyWin::background1));
|
||||||
add_action("back2", sigc::mem_fun(*this, &MyWin::background2));
|
add_action("back2", sigc::mem_fun(*this, &MyWin::background2));
|
||||||
add_action("back3",sigc::mem_fun(*this,&MyWin::background3));
|
add_action("back3", sigc::mem_fun(*this, &MyWin::background3));
|
||||||
add_action("about", sigc::mem_fun(*this, &MyWin::about_dialog));
|
add_action("about", sigc::mem_fun(*this, &MyWin::about_dialog));
|
||||||
add_action("quit", sigc::mem_fun(*this, &MyWin::hide));
|
add_action("quit", sigc::mem_fun(*this, &MyWin::hide));
|
||||||
|
|
||||||
|
@ -120,7 +120,8 @@ void MyWin::background2()
|
||||||
sized.reset();
|
sized.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyWin::background3(){
|
void MyWin::background3()
|
||||||
|
{
|
||||||
// Set Background Image
|
// Set Background Image
|
||||||
auto pixbuf = Gdk::Pixbuf::create_from_xpm_data(fly);
|
auto pixbuf = Gdk::Pixbuf::create_from_xpm_data(fly);
|
||||||
auto sized = pixbuf->scale_simple(640, 360, Gdk::INTERP_BILINEAR);
|
auto sized = pixbuf->scale_simple(640, 360, Gdk::INTERP_BILINEAR);
|
||||||
|
@ -147,50 +148,44 @@ void MyWin::main_releases()
|
||||||
{
|
{
|
||||||
// Get Selection
|
// Get Selection
|
||||||
int version = combo.get_active_row_number();
|
int version = combo.get_active_row_number();
|
||||||
std::string ver; // Version and Full Version
|
|
||||||
char str[57];
|
char str[57];
|
||||||
// Get Configs
|
// Get Configs
|
||||||
|
std::string config_longterm, config_stable, config_devel;
|
||||||
|
// Open json file
|
||||||
|
std::ifstream json_file("xe_config.json");
|
||||||
|
json data;
|
||||||
|
if (json_file.is_open())
|
||||||
|
{
|
||||||
|
// Read data from json file
|
||||||
|
data = json::parse(json_file);
|
||||||
|
config_longterm = data["Longterm"];
|
||||||
|
config_stable = data["Stable"];
|
||||||
|
config_devel = data["Develop"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg_dialog.Init("The config doesn't exist!\nPlease use \"Config\" menu to set releases");
|
||||||
|
msg_dialog.show_all();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
json_file.close();
|
||||||
|
|
||||||
switch (version) // Use Selection to Perform
|
switch (version) // Use Selection to Perform
|
||||||
{
|
{
|
||||||
case Releases::LTS:
|
case Releases::LTS:
|
||||||
if (readCfgFile("xe_config", "Longterm", ver))
|
longterm(local, config_longterm.c_str(), str);
|
||||||
{
|
msg_dialog.Init(str);
|
||||||
longterm(local, ver.c_str(), str);
|
msg_dialog.show_all();
|
||||||
msg_dialog.Init(str);
|
|
||||||
msg_dialog.show_all();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg_dialog.Init("The config doesn't exist!\nPlease use \"Config\" menu to set releases");
|
|
||||||
msg_dialog.show_all();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Releases::Stable:
|
case Releases::Stable:
|
||||||
if (readCfgFile("xe_config", "Stable", ver))
|
stable(local, config_stable.c_str(), str);
|
||||||
{
|
msg_dialog.Init(str);
|
||||||
stable(local, ver.c_str(), str);
|
msg_dialog.show_all();
|
||||||
msg_dialog.Init(str);
|
|
||||||
msg_dialog.show_all();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg_dialog.Init("The config doesn't exist!\nPlease use \"Config\" menu to set releases");
|
|
||||||
msg_dialog.show_all();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Releases::Dev:
|
case Releases::Dev:
|
||||||
if (readCfgFile("xe_config", "Develop", ver))
|
develop(local, config_devel.c_str(), str);
|
||||||
{
|
msg_dialog.Init(str);
|
||||||
develop(local, ver.c_str(), str);
|
msg_dialog.show_all();
|
||||||
msg_dialog.Init(str);
|
|
||||||
msg_dialog.show_all();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg_dialog.Init("The config doesn't exist!\nPlease use \"Config\" menu to set releases");
|
|
||||||
msg_dialog.show_all();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
#include "MyDialog.hh"
|
#include "MyDialog.hh"
|
||||||
#include "../cfgfile2/cfgfile.hh"
|
|
||||||
|
|
||||||
class MyWin : public Gtk::ApplicationWindow
|
class MyWin : public Gtk::ApplicationWindow
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#include "xerelease.hh"
|
#include "xerelease.hh"
|
||||||
#include "xeapi.hh"
|
#include "xeapi.hh"
|
||||||
#include "cfgfile2/cfgfile.hh"
|
#include "cfgfile2/cfgfile.hh"
|
||||||
|
#include "../json_nlohmann/json.hpp"
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
// typedef void(*LP)(struct tm *local);//define a pointer function
|
// typedef void(*LP)(struct tm *local);//define a pointer function
|
||||||
|
|
||||||
|
@ -75,20 +78,30 @@ int total_year_day(int year1, int year2)
|
||||||
|
|
||||||
static void path_translate(char *result, const char *version)
|
static void path_translate(char *result, const char *version)
|
||||||
{
|
{
|
||||||
// Just combine the release file path and filename
|
// Get Config from json file
|
||||||
std::string path;
|
std::ifstream json_file("xe_config.json");
|
||||||
if (rel_unix_file_system_detected())
|
if (json_file.is_open())
|
||||||
{
|
{
|
||||||
if(readCfgFile("xe_config","Release_Path_Unix",path)){
|
// Read data from json file
|
||||||
|
json data = json::parse(json_file);
|
||||||
|
// Just combine the release file path and filename
|
||||||
|
std::string path;
|
||||||
|
if (rel_unix_file_system_detected())
|
||||||
|
{
|
||||||
|
path = data["Release_Path_Unix"];
|
||||||
sprintf(result, "%s/xe-%c.x", path.c_str(), version[0]);
|
sprintf(result, "%s/xe-%c.x", path.c_str(), version[0]);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path = data["Release_Path_Win32"];
|
||||||
|
sprintf(result, "%s\\xe-%c.x", path.c_str(), version[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(readCfgFile("xe_config","Release_Path_Win32",path)){
|
sprintf(result, "./xe-%c.x", version[0]);
|
||||||
sprintf(result, "%s\\xe-%c.x", path.c_str(), version[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
json_file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dale(struct tm *local)
|
void dale(struct tm *local)
|
||||||
|
@ -100,8 +113,8 @@ void longterm(struct tm *local, const char *lts, char *str)
|
||||||
{
|
{
|
||||||
// Print Version of longterm release in the file
|
// Print Version of longterm release in the file
|
||||||
char filename[57];
|
char filename[57];
|
||||||
path_translate(filename,lts);
|
path_translate(filename, lts);
|
||||||
//sprintf(filename, "xe-%c.x", lts[0]);
|
// sprintf(filename, "xe-%c.x", lts[0]);
|
||||||
int lts_ver = 0; // default release version
|
int lts_ver = 0; // default release version
|
||||||
int year1 = 2019, month1 = 1, day1 = 11, year2 = local->tm_year + 1900,
|
int year1 = 2019, month1 = 1, day1 = 11, year2 = local->tm_year + 1900,
|
||||||
month2 = local->tm_mon + 1, day2 = local->tm_mday;
|
month2 = local->tm_mon + 1, day2 = local->tm_mday;
|
||||||
|
@ -123,8 +136,8 @@ void stable(struct tm *local, const char *rel, char *str)
|
||||||
{
|
{
|
||||||
// Print Version of stable release in the file
|
// Print Version of stable release in the file
|
||||||
char filename[57];
|
char filename[57];
|
||||||
path_translate(filename,rel);
|
path_translate(filename, rel);
|
||||||
//sprintf(filename, "xe-%c.x", rel[0]);
|
// sprintf(filename, "xe-%c.x", rel[0]);
|
||||||
int devel1; // stable release version
|
int devel1; // stable release version
|
||||||
int year1 = 2017, month1 = 5, day1 = 19, year2 = local->tm_year + 1900,
|
int year1 = 2017, month1 = 5, day1 = 19, year2 = local->tm_year + 1900,
|
||||||
month2 = local->tm_mon + 1, day2 = local->tm_mday;
|
month2 = local->tm_mon + 1, day2 = local->tm_mday;
|
||||||
|
@ -145,8 +158,8 @@ void develop(struct tm *local, const char *devel, char *str)
|
||||||
{
|
{
|
||||||
// Print Version of develop release in the file
|
// Print Version of develop release in the file
|
||||||
char filename[57];
|
char filename[57];
|
||||||
path_translate(filename,devel);
|
path_translate(filename, devel);
|
||||||
//sprintf(filename, "xe-%c.x", devel[0]);
|
// sprintf(filename, "xe-%c.x", devel[0]);
|
||||||
int devel1; // development version
|
int devel1; // development version
|
||||||
int year1 = 2017, month1 = 5, day1 = 19, year2 = local->tm_year + 1900,
|
int year1 = 2017, month1 = 5, day1 = 19, year2 = local->tm_year + 1900,
|
||||||
month2 = local->tm_mon + 1, day2 = local->tm_mday;
|
month2 = local->tm_mon + 1, day2 = local->tm_mday;
|
||||||
|
|
Loading…
Reference in New Issue