Adjust UI
This commit is contained in:
parent
bac367f9ed
commit
ab1c88fc10
|
@ -26,6 +26,7 @@ set(SOURCES src/main.cc src/MyWin.cc src/MyDialog.cc
|
|||
|
||||
#Compile resources with GCR_CMake
|
||||
set(RESOURCE_LIST
|
||||
style.css
|
||||
STRIPBLANKS menubar.xml
|
||||
STRIPBLANKS prefs.ui
|
||||
icons/16x16/actions/open-menu.png
|
||||
|
|
|
@ -2,7 +2,213 @@
|
|||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkDialog" id="prefs">
|
||||
<object class="GtkBox" id="prefs">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">5</property>
|
||||
<property name="margin-end">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_conf">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Release Configs:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<!-- n-columns=2 n-rows=4 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_lts">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="label" translatable="yes">LongTerm:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_stable">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="label" translatable="yes">Stable:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_dev">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="label" translatable="yes">Development:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_lts">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="text" translatable="yes">default_config</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_stable">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="text" translatable="yes">default_config</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_dev">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="text" translatable="yes">default_config</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">Path:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_path">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="text" translatable="yes">./</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="btnpath">
|
||||
<property name="label" translatable="yes">Custom Path</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_ok">
|
||||
<property name="label" translatable="yes">OK</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_cancel">
|
||||
<property name="label" translatable="yes">Cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkDialog" id="prefs1">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-end">10</property>
|
||||
<property name="type-hint">dialog</property>
|
||||
|
@ -16,43 +222,13 @@
|
|||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="btnpath">
|
||||
<property name="label" translatable="yes">Custom Path</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_ok">
|
||||
<property name="label" translatable="yes">OK</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_cancel">
|
||||
<property name="label" translatable="yes">Cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
|
@ -62,156 +238,9 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">5</property>
|
||||
<property name="margin-end">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_conf">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Release Configs:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<!-- n-columns=2 n-rows=4 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_lts">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="label" translatable="yes">LongTerm:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_stable">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="label" translatable="yes">Stable:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_dev">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="label" translatable="yes">Development:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_lts">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="text" translatable="yes">default_config</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_stable">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="text" translatable="yes">default_config</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_dev">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="text" translatable="yes">default_config</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">Path:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_path">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="text" translatable="yes">./</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-5">btn_ok</action-widget>
|
||||
<action-widget response="-6">btn_cancel</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
您可以在这里输入任何 GTK+ 可识别的 CSS 规则。
|
||||
您可以点击上面的“暂停”按钮来暂时停用这个自定义 CSS。
|
||||
|
||||
变更会立即应用到全局,影响整个应用程序。
|
||||
*/
|
||||
|
||||
box{
|
||||
background-color:rgba(255,255,255,0.5);
|
||||
}
|
|
@ -1,17 +1,18 @@
|
|||
#include "MyDialog.hh"
|
||||
|
||||
MyDialog::MyDialog(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_builder)
|
||||
: Gtk::Dialog(cobject),
|
||||
MyPrefs::MyPrefs(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_builder)
|
||||
: Gtk::Box(cobject),
|
||||
ref_Glade(ref_builder)
|
||||
{
|
||||
// Initalize
|
||||
set_icon_name("XeRelease");
|
||||
// // Initalize
|
||||
// set_icon_name("XeRelease");
|
||||
// Get Widgets
|
||||
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);
|
||||
ref_builder->get_widget("btn_ok", btnok);
|
||||
|
||||
// json_file.close();
|
||||
|
||||
|
@ -29,41 +30,40 @@ MyDialog::MyDialog(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &re
|
|||
// readCfgFile("xe_config","Release_Path_Win32",config_win32);
|
||||
|
||||
// Connect Signal
|
||||
btnpath->signal_clicked().connect(sigc::mem_fun(*this, &MyDialog::btnpath_clicked));
|
||||
btnpath->signal_clicked().connect(sigc::mem_fun(*this, &MyPrefs::btnpath_clicked));
|
||||
btnok->signal_clicked().connect(sigc::mem_fun(*this, &MyPrefs::btnok_clicked));
|
||||
}
|
||||
|
||||
void MyDialog::on_response(int response_id)
|
||||
void MyPrefs::btnok_clicked()
|
||||
{
|
||||
// Save Configs to a file
|
||||
if (response_id == Gtk::RESPONSE_OK)
|
||||
Glib::ustring config;
|
||||
std::fstream outfile;
|
||||
|
||||
// Initalize Config for path
|
||||
if (unix_file_system_detected())
|
||||
{
|
||||
config_unix = entry_path->get_text();
|
||||
}
|
||||
else
|
||||
{
|
||||
Glib::ustring config;
|
||||
std::fstream outfile;
|
||||
|
||||
// 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.json", 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())
|
||||
{
|
||||
// Create json object
|
||||
json out_data = json::parse(R"(
|
||||
config_win32 = entry_path->get_text();
|
||||
}
|
||||
// Open the config file
|
||||
outfile.open("xe_config.json", 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())
|
||||
{
|
||||
// Create json object
|
||||
json out_data = json::parse(R"(
|
||||
{
|
||||
"Longterm":"",
|
||||
"Stable":"",
|
||||
|
@ -73,31 +73,29 @@ void MyDialog::on_response(int response_id)
|
|||
}
|
||||
)");
|
||||
|
||||
// Load config to json file
|
||||
out_data["Longterm"] = entry_lts->get_text();
|
||||
out_data["Stable"] = entry_stable->get_text();
|
||||
out_data["Develop"] = entry_dev->get_text();
|
||||
out_data["Release_Path_Unix"] = config_unix;
|
||||
out_data["Release_Path_Win32"] = config_win32;
|
||||
outfile << out_data;
|
||||
// outfile<<"This is the config file of Xe Release"<<std::endl;
|
||||
// outfile<<"See more on github.com/daleclack/Xe-Release"<<std::endl;
|
||||
// outfile<<std::endl;
|
||||
// config=entry_lts->get_text();
|
||||
// outfile<<"Longterm="<<config<<std::endl;
|
||||
// config=entry_stable->get_text();
|
||||
// outfile<<"Stable="<<config<<std::endl;
|
||||
// config=entry_dev->get_text();
|
||||
// outfile<<"Develop="<<config<<std::endl;
|
||||
// outfile<<"Release_Path_Unix="<<config_unix<<std::endl;
|
||||
// outfile<<"Release_Path_Win32="<<config_win32<<std::endl;
|
||||
}
|
||||
outfile.close();
|
||||
// Load config to json file
|
||||
out_data["Longterm"] = entry_lts->get_text();
|
||||
out_data["Stable"] = entry_stable->get_text();
|
||||
out_data["Develop"] = entry_dev->get_text();
|
||||
out_data["Release_Path_Unix"] = config_unix;
|
||||
out_data["Release_Path_Win32"] = config_win32;
|
||||
outfile << out_data;
|
||||
// outfile<<"This is the config file of Xe Release"<<std::endl;
|
||||
// outfile<<"See more on github.com/daleclack/Xe-Release"<<std::endl;
|
||||
// outfile<<std::endl;
|
||||
// config=entry_lts->get_text();
|
||||
// outfile<<"Longterm="<<config<<std::endl;
|
||||
// config=entry_stable->get_text();
|
||||
// outfile<<"Stable="<<config<<std::endl;
|
||||
// config=entry_dev->get_text();
|
||||
// outfile<<"Develop="<<config<<std::endl;
|
||||
// outfile<<"Release_Path_Unix="<<config_unix<<std::endl;
|
||||
// outfile<<"Release_Path_Win32="<<config_win32<<std::endl;
|
||||
}
|
||||
hide();
|
||||
outfile.close();
|
||||
}
|
||||
|
||||
void MyDialog::init_json_data(json &data1)
|
||||
void MyPrefs::init_json_data(json &data1)
|
||||
{
|
||||
// Read Configs
|
||||
std::string config_longterm, config_stable, config_devel;
|
||||
|
@ -129,30 +127,33 @@ void MyDialog::init_json_data(json &data1)
|
|||
}
|
||||
}
|
||||
|
||||
MyDialog *MyDialog::create(Gtk::Window &parent)
|
||||
MyPrefs *MyPrefs::create()
|
||||
{
|
||||
// Create a dialog
|
||||
// Create the config widget
|
||||
auto builder = Gtk::Builder::create_from_resource("/org/gtk/daleclack/prefs.ui");
|
||||
|
||||
MyDialog *dialog = nullptr;
|
||||
builder->get_widget_derived("prefs", dialog);
|
||||
dialog->set_transient_for(parent);
|
||||
MyPrefs *box = nullptr;
|
||||
builder->get_widget_derived("prefs", box);
|
||||
|
||||
return dialog;
|
||||
return box;
|
||||
}
|
||||
|
||||
void MyDialog::btnpath_clicked()
|
||||
void MyPrefs::set_parent_win(Gtk::Window *parent){
|
||||
parent_win = parent;
|
||||
}
|
||||
|
||||
void MyPrefs::btnpath_clicked()
|
||||
{
|
||||
// Create a Dialog
|
||||
dialog = Gtk::FileChooserNative::create("Select a folder", *this,
|
||||
dialog = Gtk::FileChooserNative::create("Select a folder", *parent_win,
|
||||
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER, "OK", "Cancel");
|
||||
|
||||
dialog->signal_response().connect(sigc::mem_fun(*this, &MyDialog::dialog_response));
|
||||
dialog->signal_response().connect(sigc::mem_fun(*this, &MyPrefs::dialog_response));
|
||||
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void MyDialog::dialog_response(int response_id)
|
||||
void MyPrefs::dialog_response(int response_id)
|
||||
{
|
||||
if (response_id == Gtk::RESPONSE_ACCEPT)
|
||||
{
|
||||
|
|
|
@ -6,43 +6,52 @@
|
|||
|
||||
using json = nlohmann::json;
|
||||
|
||||
class MyDialog : public Gtk::Dialog{
|
||||
class MyPrefs : public Gtk::Box
|
||||
{
|
||||
public:
|
||||
MyDialog(BaseObjectType* cobject,const Glib::RefPtr<Gtk::Builder>& ref_builder);
|
||||
static MyDialog * create(Gtk::Window& parent);
|
||||
MyPrefs(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &ref_builder);
|
||||
static MyPrefs *create();
|
||||
void set_parent_win(Gtk::Window *parent);
|
||||
void init_json_data(json &data1);
|
||||
protected:
|
||||
void on_response(int response_id) override;
|
||||
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> ref_Glade;
|
||||
//Child widgets
|
||||
Gtk::Entry * entry_lts,* entry_stable,* entry_dev,* entry_path;
|
||||
Gtk::Button * btnpath;
|
||||
// Parent Window
|
||||
Gtk::Window *parent_win;
|
||||
|
||||
//Strings to store path on Windows and Unix-Like systems
|
||||
std::string config_win32,config_unix;
|
||||
// Child widgets
|
||||
Gtk::Entry *entry_lts, *entry_stable, *entry_dev, *entry_path;
|
||||
Gtk::Button *btnpath, *btnok;
|
||||
|
||||
//Signal Handlers
|
||||
// Strings to store path on Windows and Unix-Like systems
|
||||
std::string config_win32, config_unix;
|
||||
|
||||
// Signal Handlers
|
||||
Glib::RefPtr<Gtk::FileChooserNative> dialog;
|
||||
void btnpath_clicked();
|
||||
void dialog_response(int response_id);
|
||||
void btnok_clicked();
|
||||
};
|
||||
|
||||
class MsgBox : public Gtk::Dialog{
|
||||
class MsgBox : public Gtk::Dialog
|
||||
{
|
||||
public:
|
||||
MsgBox(Gtk::Window &parent);
|
||||
void Init(Glib::ustring msg);
|
||||
|
||||
protected:
|
||||
//Signal Handler
|
||||
// Signal Handler
|
||||
void on_response(int response_id) override;
|
||||
|
||||
private:
|
||||
//Child Widgets
|
||||
// Child Widgets
|
||||
Gtk::Image image;
|
||||
Gtk::Label msg_label;
|
||||
Gtk::Box *vbox,hbox;
|
||||
Gtk::Box *vbox, hbox;
|
||||
};
|
||||
|
||||
static inline bool unix_file_system_detected(){
|
||||
static inline bool unix_file_system_detected()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return false;
|
||||
#else
|
||||
|
|
|
@ -16,6 +16,7 @@ enum Releases
|
|||
MyWin::MyWin()
|
||||
: btn_box(Gtk::ORIENTATION_VERTICAL, 5),
|
||||
btn_ver("Xe-Ver"),
|
||||
cfg_box(Gtk::ORIENTATION_HORIZONTAL, 5),
|
||||
msg_dialog(*this)
|
||||
{
|
||||
// Initalize window
|
||||
|
@ -27,7 +28,7 @@ MyWin::MyWin()
|
|||
auto pixbuf = Gdk::Pixbuf::create_from_xpm_data(fly);
|
||||
auto sized = pixbuf->scale_simple(640, 360, Gdk::INTERP_BILINEAR);
|
||||
gtk_image_set_from_pixbuf(background.gobj(), sized->gobj());
|
||||
overlay.add(background);
|
||||
back_overlay.add(background);
|
||||
|
||||
// Get Local time
|
||||
time_t t;
|
||||
|
@ -55,8 +56,27 @@ MyWin::MyWin()
|
|||
btn_ver.signal_clicked().connect(sigc::mem_fun(*this, &MyWin::main_releases));
|
||||
|
||||
// Show everything
|
||||
add(stack1);
|
||||
add(back_overlay);
|
||||
back_overlay.add_overlay(stack1);
|
||||
stack1.add(overlay, "main_page", "WelCome");
|
||||
|
||||
//Add Config Page
|
||||
prefs = MyPrefs::create();
|
||||
prefs->set_parent_win(this);
|
||||
load_config();
|
||||
prefs->init_json_data(data);
|
||||
cfg_box.pack_start(*prefs, Gtk::PACK_SHRINK);
|
||||
cfg_box.set_opacity(0.7);
|
||||
stack1.add(cfg_box, "config_page", "Config");
|
||||
|
||||
// Create Style for widgets
|
||||
provider = Gtk::CssProvider::create();
|
||||
provider->load_from_resource("/org/gtk/daleclack/style.css");
|
||||
auto style1 = btn_box.get_style_context();
|
||||
style1->add_provider(provider, 1);
|
||||
auto style2 = prefs->get_style_context();
|
||||
style2->add_provider(provider, 1);
|
||||
|
||||
switcher.set_stack(stack1);
|
||||
show_all_children();
|
||||
|
||||
|
@ -135,10 +155,8 @@ void MyWin::background3()
|
|||
void MyWin::config_dialog()
|
||||
{
|
||||
load_config();
|
||||
auto dialog = MyDialog::create(*this);
|
||||
dialog->init_json_data(data);
|
||||
dialog->signal_hide().connect(sigc::bind(sigc::mem_fun(*this, &MyWin::on_window_hide), dialog));
|
||||
dialog->present();
|
||||
prefs->init_json_data(data);
|
||||
stack1.set_visible_child(cfg_box);
|
||||
}
|
||||
|
||||
void MyWin::load_config(){
|
||||
|
|
|
@ -9,34 +9,40 @@ public:
|
|||
MyWin();
|
||||
|
||||
private:
|
||||
//Child Widgets
|
||||
// Child Widgets
|
||||
Glib::RefPtr<Gtk::Builder> menu_builder;
|
||||
|
||||
//Main window
|
||||
// Main window
|
||||
Gtk::Stack stack1;
|
||||
Gtk::StackSwitcher switcher;
|
||||
Gtk::Image background;
|
||||
Gtk::Overlay overlay;
|
||||
Gtk::Box btn_box;
|
||||
Gtk::Overlay back_overlay, overlay;
|
||||
Gtk::Box btn_box, cfg_box;
|
||||
Gtk::Label api_label;
|
||||
Gtk::ComboBoxText combo;
|
||||
Gtk::Button btn_ver;
|
||||
|
||||
//TitleBar and menu
|
||||
// TitleBar and menu
|
||||
Gtk::HeaderBar header;
|
||||
Gtk::MenuButton menubtn;
|
||||
Gtk::PopoverMenu popover;
|
||||
void titlebar_init();
|
||||
|
||||
//Dialogs
|
||||
// Css Style
|
||||
Glib::RefPtr<Gtk::CssProvider> provider;
|
||||
|
||||
// Config Page
|
||||
MyPrefs *prefs;
|
||||
|
||||
// Dialogs
|
||||
MsgBox msg_dialog;
|
||||
|
||||
//Backgrounds
|
||||
// Backgrounds
|
||||
void background1();
|
||||
void background2();
|
||||
void background3();
|
||||
|
||||
//Version Configs
|
||||
// Version Configs
|
||||
struct tm *local;
|
||||
char api_version[57];
|
||||
json data;
|
||||
|
@ -44,8 +50,8 @@ private:
|
|||
void load_config();
|
||||
void config_dialog();
|
||||
|
||||
//Signal Handlers
|
||||
void on_window_hide(Gtk::Window* window);
|
||||
// Signal Handlers
|
||||
void on_window_hide(Gtk::Window *window);
|
||||
void about_dialog();
|
||||
void main_releases();
|
||||
};
|
Loading…
Reference in New Issue