Исправлен дизайн, частично код приведён стандарту Стэнфордского университета

pull/71/head
Igor Belitskiy 3 years ago
parent a223848947
commit 5960598354

@ -2,11 +2,11 @@
#include "ubl-settings-datetime.h" #include "ubl-settings-datetime.h"
using namespace std; using namespace std;
string path_app= "/usr/bin/"; const string path_app = "/usr/bin/";
string path_glade= "/usr/share/ubl-settings-datetime/ui/"; const string path_glade = "/usr/share/ubl-settings-datetime/ui/";
string app_name = "ubl-settings-datetime"; const string app_name = "ubl-settings-datetime";
string path_locale = "/usr/share/locale/"; const string path_locale = "/usr/share/locale/";
string path_css = "/usr/share/ubl-settings-datetime/css/style.css"; const string path_css = "/usr/share/ubl-settings-datetime/css/style.css";
bool flag_datetime = false; bool flag_datetime = false;
bool flag_timezone = false; bool flag_timezone = false;
bool flag_ntp_mode = false; bool flag_ntp_mode = false;
@ -55,19 +55,12 @@ MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
} }
void MainWindow::settings() { void MainWindow::settings() {
Gtk::Widget *standartHead;
Gtk::Widget *plugBox;
Gtk::Window *window;
Gtk::Widget *boxButton;
Gtk::Widget *boxSave;
builder->get_widget("standartHead",standartHead);
builder->get_widget("plugBox",plugBox);
builder->get_widget("window",window);
builder->get_widget("boxButton",boxButton);
builder->get_widget("boxSave",boxSave);
ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I);
year=0, month=0, day=0;
this->get_builder(); this->get_builder();
this->add_CSS();
ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I);
year = 0;
month = 0;
day = 0;
this->lacalization(); this->lacalization();
if (this->check_root() == 0) { if (this->check_root() == 0) {
numTimeHrs->set_range(0, 23); numTimeHrs->set_range(0, 23);
@ -118,13 +111,6 @@ int MainWindow::check_root(){
} }
void MainWindow::lacalization() { void MainWindow::lacalization() {
//btnSynopsis->set_label(_("Synopsis"));
//btnAbout->set_label(_("About the program"));
//btnDonwlodLocal->set_label(_("Download local"));
//btnDonwlolGlob->set_label(_("Download global"));
//btnSaveGlob->set_label(_("Save to Global configuration"));
//btnSaveLocal->set_label(_("Save to local configuration"));
//btnSaveLocalGlob->set_label(_("Save to global and local configuration"));
aboutWindows->set_comments(_("Setting the date and time")); aboutWindows->set_comments(_("Setting the date and time"));
aboutWindows->set_website(_("https://wiki.ublinux.com")); aboutWindows->set_website(_("https://wiki.ublinux.com"));
aboutWindows->set_version(_(version_application.c_str())); aboutWindows->set_version(_(version_application.c_str()));
@ -138,7 +124,6 @@ void MainWindow::lacalization(){
cbDhcp->append(_("DHCP")); cbDhcp->append(_("DHCP"));
cbDhcp->append(_("Manual")); cbDhcp->append(_("Manual"));
cbDhcp->append(_("Disabled")); cbDhcp->append(_("Disabled"));
lblDateTimeSetting->set_text(_("Current date and time")); lblDateTimeSetting->set_text(_("Current date and time"));
lblHead->set_text(_("Setting the date and time")); lblHead->set_text(_("Setting the date and time"));
lblTime->set_text(_("Time")); lblTime->set_text(_("Time"));
@ -206,6 +191,33 @@ void MainWindow::add_CSS(){
Glib::RefPtr<Gtk::StyleContext> context_lbl_head = lblHead->get_style_context(); Glib::RefPtr<Gtk::StyleContext> context_lbl_head = lblHead->get_style_context();
context->add_class("cssboxColor1"); context->add_class("cssboxColor1");
context_lbl_head->add_class("textHead"); context_lbl_head->add_class("textHead");
/*
Glib::RefPtr<Gtk::StyleContext> boxButton_css = boxButton->get_style_context();
Glib::RefPtr<Gtk::StyleContext> boxSave_css = boxSave->get_style_context();
Glib::RefPtr<Gtk::StyleContext> btnDownload_css = btnDownload->get_style_context();
Glib::RefPtr<Gtk::StyleContext> lblDownload_css = lblDownload->get_style_context();
Glib::RefPtr<Gtk::StyleContext> imgDonwload_css = imgDonwload->get_style_context();
Glib::RefPtr<Gtk::StyleContext> headerBar_css = headerBar->get_style_context();
headerBar_css->add_class("bkim");
imgDonwload_css->add_class("bkim");
lblDownload_css->add_class("bkim");
btnDownload_css->add_class("bkim");
boxButton_css->add_class("bkim");
boxSave_css->add_class("bkim");
double opacity= 1.0;
headerBar->set_opacity(opacity);
boxButton->set_opacity(opacity);
boxSave->set_opacity(opacity);
btnDownload->set_opacity(opacity);
lblDownload->set_opacity(opacity);
imgDonwload->set_opacity(opacity);
btnSave->set_opacity(opacity);
lblSave->set_opacity(opacity);
btnSettings->set_opacity(opacity);
imgSave->set_opacity(opacity);
imgSettings->set_opacity(opacity);
*/
} }
@ -269,14 +281,25 @@ void MainWindow::get_builder(){
builder->get_widget("cbHw", cbHw); builder->get_widget("cbHw", cbHw);
builder->get_widget("popCalendar", popCalendar); builder->get_widget("popCalendar", popCalendar);
builder->get_widget("boxDateTime", boxDateTime); builder->get_widget("boxDateTime", boxDateTime);
this->add_CSS(); builder->get_widget("boxButton", boxButton);
builder->get_widget("boxSave", boxSave);
builder->get_widget("standartHead", standartHead);
builder->get_widget("plugBox", plugBox);
builder->get_widget("window" ,window);
builder->get_widget("imgDonwload", imgDonwload);
builder->get_widget("imgDonwload", imgDonwload);
builder->get_widget("imgSettings", imgSettings);
builder->get_widget("imgSave", imgSave);
} }
void MainWindow::gui_exit() { void MainWindow::gui_exit() {
exit(1); exit(1);
} }
bool MainWindow::gui_exit_2(GdkEventAny* event) { bool MainWindow::gui_exit_2(GdkEventAny* event) {
if (event!=NULL){} if (event != NULL) {
}
exit(1); exit(1);
return true; return true;
} }
@ -329,8 +352,8 @@ void MainWindow::download_globl_cfg(){
string cmd_get_dhcp = "/usr/bin/ubconfig --default --source global get network NTPSERVERS"; string cmd_get_dhcp = "/usr/bin/ubconfig --default --source global get network NTPSERVERS";
string cmd_default_get_dhcp = "/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT"; string cmd_default_get_dhcp = "/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT";
this->entry_dhcp_mess(cmd_get_dhcp, cmd_default_get_dhcp); this->entry_dhcp_mess(cmd_get_dhcp, cmd_default_get_dhcp);
string cmd = "/usr/bin/ubconfig --default --source global get clock ZONE"; string cmd_zone = "/usr/bin/ubconfig --default --source global get clock ZONE";
this->fill_in_reg_zone(cmd); this->fill_in_reg_zone(cmd_zone);
string hw = "/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC"; string hw = "/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC";
string hw_default = "/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC"; string hw_default = "/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC";
this->entry_hardware_clock(hw, hw_default); this->entry_hardware_clock(hw, hw_default);
@ -338,8 +361,8 @@ void MainWindow::download_globl_cfg(){
} }
void MainWindow::save_local_cfg() { void MainWindow::save_local_cfg() {
string cmd = "/usr/bin/ubconfig --target system set clock ZONE="; string cmd_zone = "/usr/bin/ubconfig --target system set clock ZONE=";
this->enter_zone(cmd); this->enter_zone(cmd_zone);
string cmd_default = "/usr/bin/ubconfig --target system set network NTPSERVERS=default"; string cmd_default = "/usr/bin/ubconfig --target system set network NTPSERVERS=default";
string cmd_dhcp = "/usr/bin/ubconfig --target system set network NTPSERVERS=dhcp"; string cmd_dhcp = "/usr/bin/ubconfig --target system set network NTPSERVERS=dhcp";
string cmd_set_ntp = "/usr/bin/ubconfig --target system set network NTPSERVERS=\""; string cmd_set_ntp = "/usr/bin/ubconfig --target system set network NTPSERVERS=\"";
@ -364,6 +387,7 @@ void MainWindow::save_global_cfg(){
this->hardware_clock_global(local, hw); this->hardware_clock_global(local, hw);
info_warning_error(3); info_warning_error(3);
} }
void MainWindow::save_global_local_cfg() { void MainWindow::save_global_local_cfg() {
string cmd = ""; string cmd = "";
string cmd_default = ""; string cmd_default = "";
@ -441,8 +465,8 @@ void MainWindow::hardware_clock_global(string &local, string &etc){
wrapper_system(etc, "&"); wrapper_system(etc, "&");
} }
} }
void MainWindow::entry_hardware_clock_default(string &cmd_default){
void MainWindow::entry_hardware_clock_default(string &cmd_default) {
int error = warning_info; int error = warning_info;
struct Result<string> obj_result_default = this->wrapper_call(cmd_default); struct Result<string> obj_result_default = this->wrapper_call(cmd_default);
if (obj_result_default.error == 0) { if (obj_result_default.error == 0) {
@ -463,6 +487,7 @@ void MainWindow::entry_hardware_clock_default(string &cmd_default){
} }
} }
void MainWindow::entry_hardware_clock(string &cmd, string &cmd_default) { void MainWindow::entry_hardware_clock(string &cmd, string &cmd_default) {
int error = warning_info; int error = warning_info;
struct Result<string> obj_result = this->wrapper_call(cmd); struct Result<string> obj_result = this->wrapper_call(cmd);
@ -537,8 +562,6 @@ bool MainWindow::focus_ntp(string &cmd_set_ntp){
} }
} }
return true; return true;
} }
@ -581,7 +604,6 @@ bool MainWindow::check_ntp(string &str_ntp){
flag_error = false; flag_error = false;
char_ntp[0] = str_ntp[i]; char_ntp[0] = str_ntp[i];
for (int index = 0; index < 11; index++) { for (int index = 0; index < 11; index++) {
if (index == 10) { if (index == 10) {
simvol = "."; simvol = ".";
} }
@ -590,7 +612,6 @@ bool MainWindow::check_ntp(string &str_ntp){
} }
if (simvol == char_ntp) { if (simvol == char_ntp) {
flag_error=false; flag_error=false;
break; break;
} }
else { else {
@ -643,6 +664,7 @@ struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd){
} }
return obj_result; return obj_result;
} }
void MainWindow::event_entry_cbDhcp() { void MainWindow::event_entry_cbDhcp() {
string str_dhcp = cbDhcp->get_active_text(); string str_dhcp = cbDhcp->get_active_text();
string cmd = ""; string cmd = "";
@ -678,7 +700,6 @@ void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove
int activ_index = cbDhcp->get_active_row_number(); int activ_index = cbDhcp->get_active_row_number();
string str_dhcp = cbDhcp->get_active_text(); string str_dhcp = cbDhcp->get_active_text();
if (str_dhcp.length() == 0) { if (str_dhcp.length() == 0) {
} }
else if (activ_index == 0) { else if (activ_index == 0) {
wrapper_system(cmd_default, "&"); wrapper_system(cmd_default, "&");
@ -686,11 +707,9 @@ void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove
} }
else if (activ_index == 1) { else if (activ_index == 1) {
wrapper_system(cmd_dhcp, "&"); wrapper_system(cmd_dhcp, "&");
} }
else if (activ_index == 2) { else if (activ_index == 2) {
this->focus_ntp(cmd_set_ntp); this->focus_ntp(cmd_set_ntp);
} }
else if (activ_index== 3) { else if (activ_index== 3) {
int start_error = error_info; int start_error = error_info;
@ -703,7 +722,6 @@ void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove
void MainWindow::entry_dhcp_mess(string cmd_get_dhcp, string cmd_default_get_dhcp) { void MainWindow::entry_dhcp_mess(string cmd_get_dhcp, string cmd_default_get_dhcp) {
string cmd = cmd_get_dhcp; string cmd = cmd_get_dhcp;
struct Result<string> obj_result = this->wrapper_call(cmd); struct Result<string> obj_result = this->wrapper_call(cmd);
if (obj_result.error== 0) { if (obj_result.error== 0) {
string str_dhcp = obj_result.response; string str_dhcp = obj_result.response;
@ -805,6 +823,7 @@ void MainWindow::calendar_show(){
} }
popCalendar->show(); popCalendar->show();
} }
void MainWindow::fill_in_reg_zone(string &cmd) { void MainWindow::fill_in_reg_zone(string &cmd) {
int error = warning_info; int error = warning_info;
struct Result<string> obj_result_1 = this->wrapper_call(cmd); struct Result<string> obj_result_1 = this->wrapper_call(cmd);
@ -1129,7 +1148,6 @@ void MainWindow::read_file(){
std::ifstream in1(entry_zone.path()); std::ifstream in1(entry_zone.path());
if (in1.is_open()) { if (in1.is_open()) {
string key_zone = entry_zone.path().filename().string(); string key_zone = entry_zone.path().filename().string();
if (fs::is_directory(path_dir + "/" + key_zone)) { if (fs::is_directory(path_dir + "/" + key_zone)) {
string reg_reg_zone = path_dir + "/" + key_zone; string reg_reg_zone = path_dir + "/" + key_zone;
for (const auto & entry_reg_reg_zone : fs::directory_iterator(reg_reg_zone)) { for (const auto & entry_reg_reg_zone : fs::directory_iterator(reg_reg_zone)) {

@ -20,11 +20,11 @@
using namespace std; using namespace std;
extern string path_app; extern const string path_app;
extern string path_glade; extern const string path_glade;
extern string app_name; extern const string app_name;
extern string path_locale; extern const string path_locale;
extern string path_css; extern const string path_css;
extern bool flag_datetime; extern bool flag_datetime;
extern bool flag_timezone; extern bool flag_timezone;
extern bool flag_ntp_mode; extern bool flag_ntp_mode;
@ -105,6 +105,15 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::Label *lblHW; Gtk::Label *lblHW;
Gtk::ComboBoxText *cbHw; Gtk::ComboBoxText *cbHw;
Gtk::Box *boxDateTime; Gtk::Box *boxDateTime;
Gtk::Widget *boxButton;
Gtk::Widget *boxSave;
Gtk::Widget *standartHead;
Gtk::Widget *plugBox;
Gtk::Window *window;
Gtk::Image *imgDonwload;
Gtk::Image *imgSave;
Gtk::Image *imgSettings;
unsigned int year = 0; unsigned int year = 0;
unsigned int month = 0; unsigned int month = 0;
unsigned int day = 0; unsigned int day = 0;

@ -70,3 +70,12 @@
.menuitemtop{ .menuitemtop{
margin-bottom:0px; margin-bottom:0px;
} }
.bkim{
background-image: -gtk-gradient(linear,
left top, left bottom,
from(@entry_background_a),
color-stop(0.20, @entry_background_b),
color-stop(0.85, @entry_background_c),
to(@entry_background_d));
}

@ -457,7 +457,7 @@ Format: DD.MM.YYYY</property>
<property name="margin-bottom">6</property> <property name="margin-bottom">6</property>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">5</property> <property name="position">5</property>
</packing> </packing>
@ -550,7 +550,7 @@ Format: DD.MM.YYYY</property>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
@ -680,7 +680,6 @@ Format: DD.MM.YYYY</property>
</child> </child>
<child> <child>
<object class="GtkEntry" id="txtNtpServer"> <object class="GtkEntry" id="txtNtpServer">
<property name="width-request">-1</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="tooltip-text" translatable="yes">Enter the name of the ntp server or its ip address. When entering multiple addresses, separate them with spaces.</property> <property name="tooltip-text" translatable="yes">Enter the name of the ntp server or its ip address. When entering multiple addresses, separate them with spaces.</property>
@ -754,19 +753,31 @@ Format: DD.MM.YYYY</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="margin-left">8</property> <property name="margin-left">8</property>
<property name="margin-right">31</property> <property name="margin-right">5</property>
<property name="margin-start">8</property> <property name="margin-start">8</property>
<property name="margin-end">31</property> <property name="margin-end">5</property>
<property name="margin-top">6</property> <property name="margin-top">6</property>
<property name="margin-bottom">13</property> <property name="margin-bottom">13</property>
<property name="label" translatable="yes">Synchronize hardware time:</property> <property name="label" translatable="yes">Synchronize hardware time:</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-end">55</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<object class="GtkComboBoxText" id="cbHw"> <object class="GtkComboBoxText" id="cbHw">
<property name="visible">True</property> <property name="visible">True</property>
@ -783,7 +794,7 @@ Format: DD.MM.YYYY</property>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>
@ -829,7 +840,6 @@ Format: DD.MM.YYYY</property>
</child> </child>
<child> <child>
<object class="GtkComboBoxText" id="cbRegion"> <object class="GtkComboBoxText" id="cbRegion">
<property name="width-request">172</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="margin-left">5</property> <property name="margin-left">5</property>
@ -842,7 +852,7 @@ Format: DD.MM.YYYY</property>
<property name="vexpand">False</property> <property name="vexpand">False</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">3</property> <property name="position">3</property>
</packing> </packing>
@ -956,11 +966,11 @@ Format: DD.MM.YYYY</property>
<object class="GtkLabel" id="lblHeader"> <object class="GtkLabel" id="lblHeader">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="halign">start</property>
<property name="margin-left">5</property> <property name="margin-left">5</property>
<property name="margin-right">5</property> <property name="margin-right">5</property>
<property name="margin-start">5</property> <property name="margin-start">5</property>
<property name="margin-end">5</property> <property name="margin-end">5</property>
<property name="margin-bottom">2</property>
<property name="hexpand">False</property> <property name="hexpand">False</property>
<property name="label" translatable="yes">ubl-settings-datetime</property> <property name="label" translatable="yes">ubl-settings-datetime</property>
<attributes> <attributes>
@ -1014,7 +1024,7 @@ Format: DD.MM.YYYY</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkImage"> <object class="GtkImage" id="imgDonwload">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="icon-name">pan-down-symbolic</property> <property name="icon-name">pan-down-symbolic</property>
@ -1079,7 +1089,7 @@ Format: DD.MM.YYYY</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkImage"> <object class="GtkImage" id="imgSave">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="icon-name">pan-down-symbolic</property> <property name="icon-name">pan-down-symbolic</property>
@ -1109,7 +1119,7 @@ Format: DD.MM.YYYY</property>
<property name="popup">menu1</property> <property name="popup">menu1</property>
<property name="direction">none</property> <property name="direction">none</property>
<child> <child>
<object class="GtkImage"> <object class="GtkImage" id="imgSettings">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="icon-name">open-menu-symbolic</property> <property name="icon-name">open-menu-symbolic</property>
@ -1134,6 +1144,30 @@ Format: DD.MM.YYYY</property>
</object> </object>
</child> </child>
</object> </object>
<object class="GtkSizeGroup">
<property name="mode">both</property>
<property name="ignore-hidden">True</property>
<widgets>
<widget name="cbRegion"/>
<widget name="cbZone"/>
</widgets>
</object>
<object class="GtkSizeGroup">
<property name="mode">both</property>
<property name="ignore-hidden">True</property>
<widgets>
<widget name="btnUpdateDateTime"/>
<widget name="lblHW"/>
</widgets>
</object>
<object class="GtkSizeGroup">
<property name="mode">both</property>
<property name="ignore-hidden">True</property>
<widgets>
<widget name="cbHw"/>
<widget name="cbZone"/>
</widgets>
</object>
<object class="GtkPopover" id="popCalendar"> <object class="GtkPopover" id="popCalendar">
<property name="width-request">240</property> <property name="width-request">240</property>
<property name="height-request">185</property> <property name="height-request">185</property>

Loading…
Cancel
Save