diff --git a/XeRelease_Gtkmm3/.vscode/launch.json b/XeRelease_Gtkmm3/.vscode/launch.json
index 74b5e52..3c090b4 100644
--- a/XeRelease_Gtkmm3/.vscode/launch.json
+++ b/XeRelease_Gtkmm3/.vscode/launch.json
@@ -24,6 +24,27 @@
}
]
},
+ {
+ "name": "(gdb) 启动(win32)",
+ "type": "cppdbg",
+ "request": "launch",
+ "program": "${workspaceFolder}/builddir_win32/XeRelease.exe",
+ "args": [],
+ "stopAtEntry": false,
+ "cwd": "${fileDirname}",
+ "environment": [],
+ "externalConsole": false,
+ "preLaunchTask": "Meson: Build target",
+ "MIMode": "gdb",
+ "setupCommands": [
+ {
+ "description": "为 gdb 启用整齐打印",
+ "text": "-enable-pretty-printing",
+ "ignoreFailures": true
+ }
+ ],
+ "miDebuggerPath": "D:/msys64/mingw64/bin/gdb.exe"
+ },
{
"name": "(lldb) 启动",
"type": "cppdbg",
diff --git a/XeRelease_Gtkmm3/.vscode/tasks.json b/XeRelease_Gtkmm3/.vscode/tasks.json
index 2135630..47ba0cf 100644
--- a/XeRelease_Gtkmm3/.vscode/tasks.json
+++ b/XeRelease_Gtkmm3/.vscode/tasks.json
@@ -2,7 +2,7 @@
"tasks": [
{
"type": "meson",
- "target": "XeRelease",
+ //"target": "XeRelease",
"mode": "build",
"group": "build",
"problemMatcher": [],
diff --git a/XeRelease_Gtkmm3/res/prefs.ui b/XeRelease_Gtkmm3/res/prefs.ui
index 26a767c..fe1c5f9 100644
--- a/XeRelease_Gtkmm3/res/prefs.ui
+++ b/XeRelease_Gtkmm3/res/prefs.ui
@@ -15,6 +15,19 @@
@@ -72,7 +85,7 @@
-
+
True
False
@@ -157,6 +170,29 @@
2
+
+
+ True
+ False
+ end
+ Path:
+
+
+ 0
+ 3
+
+
+
+
+ True
+ True
+ ./
+
+
+ 1
+ 3
+
+
False
diff --git a/XeRelease_Gtkmm3/src/MyDialog.cc b/XeRelease_Gtkmm3/src/MyDialog.cc
index 053e292..080a578 100644
--- a/XeRelease_Gtkmm3/src/MyDialog.cc
+++ b/XeRelease_Gtkmm3/src/MyDialog.cc
@@ -11,6 +11,9 @@ ref_Glade(ref_builder)
ref_builder->get_widget("entry_lts",entry_lts);
ref_builder->get_widget("entry_stable",entry_stable);
ref_builder->get_widget("entry_dev",entry_dev);
+ ref_builder->get_widget("entry_path",entry_path);
+ ref_builder->get_widget("btnpath",btnpath);
+
//Read Configs
std::string config;
if(readCfgFile("xe_config","Longterm",config)){
@@ -22,6 +25,18 @@ ref_Glade(ref_builder)
if(readCfgFile("xe_config","Develop",config)){
entry_dev->set_text(config);
}
+ readCfgFile("xe_config","Release_Path_Unix",config_unix);
+ readCfgFile("xe_config","Release_Path_Win32",config_win32);
+
+ //Use different path for Linux filesystem and Windows
+ if(unix_file_system_detected()){
+ entry_path->set_text(config_unix);
+ }else{
+ entry_path->set_text(config_win32);
+ }
+
+ //Connect Signal
+ btnpath->signal_clicked().connect(sigc::mem_fun(*this,&MyDialog::btnpath_clicked));
}
void MyDialog::on_response(int response_id){
@@ -29,7 +44,22 @@ void MyDialog::on_response(int response_id){
if(response_id == Gtk::RESPONSE_OK){
Glib::ustring config;
std::fstream outfile;
- outfile.open("xe_config",std::ios_base::out);
+ //Initalize Config for path
+ if(unix_file_system_detected()){
+ config_unix = entry_path->get_text();
+ }else{
+ config_win32 = entry_path->get_text();
+ }
+ //Open the config file
+ outfile.open("xe_config",std::ios_base::out);
+ /*OutPut contents to the file
+ Simple Contents of xe_config:
+ Longterm=x.x
+ Stable=x.x
+ Develop=x.x
+ Release_Path_Unix=/xxx/xxx
+ Release_Path_Win32=X:\xxx\xxx
+ */
if(outfile.is_open()){
outfile<<"This is the config file of Xe Release"<get_text();
outfile<<"Develop="<signal_response().connect(sigc::mem_fun(*this,&MyDialog::dialog_response));
+
+ dialog->show();
+}
+
+void MyDialog::dialog_response(int response_id){
+ if(response_id == Gtk::RESPONSE_ACCEPT){
+ Glib::ustring path = dialog->get_filename();
+ entry_path->set_text(path);
+ }
+ dialog.reset();
+}
+
MsgBox::MsgBox(Gtk::Window &parent)
:hbox(Gtk::ORIENTATION_HORIZONTAL,5)
{
diff --git a/XeRelease_Gtkmm3/src/MyDialog.hh b/XeRelease_Gtkmm3/src/MyDialog.hh
index f98dea7..05174de 100644
--- a/XeRelease_Gtkmm3/src/MyDialog.hh
+++ b/XeRelease_Gtkmm3/src/MyDialog.hh
@@ -12,7 +12,17 @@ protected:
void on_response(int response_id) override;
private:
Glib::RefPtr ref_Glade;
- Gtk::Entry * entry_lts,* entry_stable,* entry_dev;
+ //Child widgets
+ Gtk::Entry * entry_lts,* entry_stable,* entry_dev,* entry_path;
+ Gtk::Button * btnpath;
+
+ //Strings to store path on Windows and Unix-Like systems
+ std::string config_win32,config_unix;
+
+ //Signal Handlers
+ Glib::RefPtr dialog;
+ void btnpath_clicked();
+ void dialog_response(int response_id);
};
class MsgBox : public Gtk::Dialog{
@@ -28,3 +38,11 @@ private:
Gtk::Label msg_label;
Gtk::Box *vbox,hbox;
};
+
+static inline bool unix_file_system_detected(){
+#ifdef _WIN32
+ return false;
+#else
+ return true;
+#endif
+}
diff --git a/XeRelease_Gtkmm3/src/MyWin.cc b/XeRelease_Gtkmm3/src/MyWin.cc
index 5894094..f2c5428 100644
--- a/XeRelease_Gtkmm3/src/MyWin.cc
+++ b/XeRelease_Gtkmm3/src/MyWin.cc
@@ -62,7 +62,7 @@ msg_dialog(*this)
void MyWin::titlebar_init(){
//Add HeaderBar
- header.set_title("Xe Release 13");
+ header.set_title("Xe Release 14");
header.set_show_close_button();
header.set_decoration_layout("close,minimize:menu");
set_titlebar(header);
@@ -162,7 +162,7 @@ void MyWin::main_releases(){
void MyWin::about_dialog(){
char *version;
- version=g_strdup_printf("13.0\nRunning Against Gtkmm %d.%d.%d",
+ version=g_strdup_printf("14.0\nRunning Against Gtkmm %d.%d.%d",
GTKMM_MAJOR_VERSION,
GTKMM_MINOR_VERSION,
GTKMM_MICRO_VERSION);
diff --git a/XeRelease_Gtkmm3/src/xerelease.cc b/XeRelease_Gtkmm3/src/xerelease.cc
index 035992e..7bb9127 100644
--- a/XeRelease_Gtkmm3/src/xerelease.cc
+++ b/XeRelease_Gtkmm3/src/xerelease.cc
@@ -1,103 +1,164 @@
-#include
-#include
-#include
-#include
-#include"xeapi.hh"
+#include
+#include
+#include
+#include
+#include "xerelease.hh"
+#include "xeapi.hh"
+#include "cfgfile2/cfgfile.hh"
-//typedef void(*LP)(struct tm *local);//define a pointer function
+// typedef void(*LP)(struct tm *local);//define a pointer function
-int total_day(int year,int month,int day)
+int total_day(int year, int month, int day)
{
- //Calculate day of 1 year
- int sum=0;
- switch(month){
- case 1:
- sum=day;break;
- case 2:
- sum=day+31;break;
- case 3:
- sum=day+59;break;
- case 4:
- sum=day+90;break;
- case 5:
- sum=day+120;break;
- case 6:
- sum=day+151;break;
- case 7:
- sum=day+181;break;
- case 8:
- sum=day+212;break;
- case 9:
- sum=day+243;break;
- case 10:
- sum=day+273;break;
- case 11:
- sum=day+304;break;
- case 12:
- sum=day+334;break;
- default:
- printf("Date Wrong!");
- }
- if(year%4==0&&year%100!=0) sum=sum+1;
- return sum;
+ // Calculate day of 1 year
+ int sum = 0;
+ switch (month)
+ {
+ case 1:
+ sum = day;
+ break;
+ case 2:
+ sum = day + 31;
+ break;
+ case 3:
+ sum = day + 59;
+ break;
+ case 4:
+ sum = day + 90;
+ break;
+ case 5:
+ sum = day + 120;
+ break;
+ case 6:
+ sum = day + 151;
+ break;
+ case 7:
+ sum = day + 181;
+ break;
+ case 8:
+ sum = day + 212;
+ break;
+ case 9:
+ sum = day + 243;
+ break;
+ case 10:
+ sum = day + 273;
+ break;
+ case 11:
+ sum = day + 304;
+ break;
+ case 12:
+ sum = day + 334;
+ break;
+ default:
+ printf("Date Wrong!");
+ }
+ if (year % 4 == 0 && year % 100 != 0)
+ sum = sum + 1;
+ return sum;
}
-int total_year_day(int year1,int year2){//Calculate day of years
- int sum=0;
- sum=(year2-year1)*365;
- for(int i=year1;itm_year+1900,month2=local->tm_mon+1,day2=local->tm_mday;
- lts_ver=total_year_day(year1,year2)-total_day(year1,month1,day1)+total_day(year2,month2,day2);//get release version
- sprintf(str,"Xeinit LTS version:%s.%d\n",lts,lts_ver);
- freopen(filename,"a",stdout);//put all output in xe-release file
- printf("%4d-%02d-%02d ",local->tm_year+1900,local->tm_mon+1,local->tm_mday);//output:release branch time in xe-release
- printf("%s.%d Api:%d\n",lts,lts_ver,xeapi1(local));
+ path_translate(filename,lts);
+ //sprintf(filename, "xe-%c.x", lts[0]);
+ int lts_ver = 0; // default release version
+ int year1 = 2019, month1 = 1, day1 = 11, year2 = local->tm_year + 1900,
+ month2 = local->tm_mon + 1, day2 = local->tm_mday;
+ // get release version
+ lts_ver = total_year_day(year1, year2) - total_day(year1, month1, day1) +
+ total_day(year2, month2, day2);
+ // For show in dialog or console
+ sprintf(str, "Xeinit LTS version:%s.%d\n", lts, lts_ver);
+ freopen(filename, "a", stdout);
+ // put all output in the release file
+ // output:release branch time in xe-release
+ printf("%4d-%02d-%02d ", local->tm_year + 1900, local->tm_mon + 1, local->tm_mday);
+ printf("%s.%d Api:%d\n", lts, lts_ver, xeapi1(local));
fclose(stdout);
- return ;
+ return;
}
-void stable(struct tm *local,const char * rel,char *str)
+void stable(struct tm *local, const char *rel, char *str)
{
+ // Print Version of stable release in the file
char filename[57];
- sprintf(filename,"xe-%c.x",rel[0]);
- int devel1;//stable release version
- int year1=2017,month1=5,day1=19,year2=local->tm_year+1900,month2=local->tm_mon+1,day2=local->tm_mday;
- devel1=total_year_day(year1,year2)-total_day(year1,month1,day1)+total_day(year2,month2,day2);//get release version
- sprintf(str,"Xeinit stable Version:%s.%d\n",rel,devel1);
- freopen(filename,"a",stdout);
- printf("%4d-%02d-%02d ",local->tm_year+1900,local->tm_mon+1,local->tm_mday);//output:development branch time in xe-release
- printf("%s.%d build:%d\n",rel,devel1,xeapi1(local));
+ path_translate(filename,rel);
+ //sprintf(filename, "xe-%c.x", rel[0]);
+ int devel1; // stable release version
+ int year1 = 2017, month1 = 5, day1 = 19, year2 = local->tm_year + 1900,
+ month2 = local->tm_mon + 1, day2 = local->tm_mday;
+ // get release version
+ devel1 = total_year_day(year1, year2) - total_day(year1, month1, day1) +
+ total_day(year2, month2, day2);
+ sprintf(str, "Xeinit stable Version:%s.%d\n", rel, devel1);
+ freopen(filename, "a", stdout);
+ // put all output in the release file
+ // output:development branch time in xe-release
+ printf("%4d-%02d-%02d ", local->tm_year + 1900, local->tm_mon + 1, local->tm_mday);
+ printf("%s.%d build:%d\n", rel, devel1, xeapi1(local));
fclose(stdout);
- return ;
+ return;
}
-void develop(struct tm *local,const char * devel,char *str){
+void develop(struct tm *local, const char *devel, char *str)
+{
+ // Print Version of develop release in the file
char filename[57];
- sprintf(filename,"xe-%c.x",devel[0]);
- int devel1;//development version
- int year1=2017,month1=5,day1=19,year2=local->tm_year+1900,month2=local->tm_mon+1,day2=local->tm_mday;
- devel1=total_year_day(year1,year2)-total_day(year1,month1,day1)+total_day(year2,month2,day2);//get release version
- sprintf(str,"Xeinit devel Version:%s.%d\n",devel,devel1);
- freopen(filename,"a",stdout);
- printf("%4d-%02d-%02d ",local->tm_year+1900,local->tm_mon+1,local->tm_mday);//output:development branch time in xe-release
- printf("%s.%d build:%d\n",devel,devel1,xeapi1(local));
+ path_translate(filename,devel);
+ //sprintf(filename, "xe-%c.x", devel[0]);
+ int devel1; // development version
+ int year1 = 2017, month1 = 5, day1 = 19, year2 = local->tm_year + 1900,
+ month2 = local->tm_mon + 1, day2 = local->tm_mday;
+ // get release version
+ devel1 = total_year_day(year1, year2) - total_day(year1, month1, day1) +
+ total_day(year2, month2, day2);
+ sprintf(str, "Xeinit devel Version:%s.%d\n", devel, devel1);
+ freopen(filename, "a", stdout);
+ // put all output in the release file
+ // output:development branch time in xe-release
+ printf("%4d-%02d-%02d ", local->tm_year + 1900, local->tm_mon + 1, local->tm_mday);
+ printf("%s.%d build:%d\n", devel, devel1, xeapi1(local));
fclose(stdout);
- return ;
+ return;
}
diff --git a/XeRelease_Gtkmm3/src/xerelease.hh b/XeRelease_Gtkmm3/src/xerelease.hh
index 8926e71..5332ad4 100644
--- a/XeRelease_Gtkmm3/src/xerelease.hh
+++ b/XeRelease_Gtkmm3/src/xerelease.hh
@@ -13,4 +13,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
+}
+
#endif
\ No newline at end of file