From 5960598354ea7bca9a0f77a66f1b0dba13be8936 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Thu, 9 Mar 2023 12:07:38 +0600 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B4=D0=B8=D0=B7=D0=B0=D0=B9=D0=BD,=20=D1=87?= =?UTF-8?q?=D0=B0=D1=81=D1=82=D0=B8=D1=87=D0=BD=D0=BE=20=D0=BA=D0=BE=D0=B4?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=D0=B2=D0=B5=D0=B4=D1=91=D0=BD=20=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=B4=D0=B0=D1=80=D1=82=D1=83=20=D0=A1=D1=82?= =?UTF-8?q?=D1=8D=D0=BD=D1=84=D0=BE=D1=80=D0=B4=D1=81=D0=BA=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D1=83=D0=BD=D0=B8=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=82?= =?UTF-8?q?=D0=B5=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/main.cc | 14 +- source/ubl-settings-datetime.cc | 740 ++++++++++++++++---------------- source/ubl-settings-datetime.h | 31 +- style.css | 9 + ubl-settings-datetime.glade | 60 ++- 5 files changed, 462 insertions(+), 392 deletions(-) diff --git a/source/main.cc b/source/main.cc index 42b4f43..0052a16 100644 --- a/source/main.cc +++ b/source/main.cc @@ -3,7 +3,7 @@ void pars_flag(int index_start, int argc, char* argv[]); int main(int argc, char* argv[]) { - string str_argv=""; + string str_argv= ""; string str_cmd_argv = ""; for (int i=1; i1){ + if (argc > 1){ str_argv = argv[1]; } - if (str_argv.find("--socket-id")!=std::string::npos){ + if (str_argv.find("--socket-id") != std::string::npos){ pars_flag(3, argc, argv); auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug"); @@ -44,7 +44,7 @@ int main(int argc, char* argv[]) { app->run(plug); return 0; } - else if (str_argv.find("-")!=std::string::npos || argc==1){ + else if (str_argv.find("-") != std::string::npos || argc == 1){ int len_argv = 1; auto app = Gtk::Application::create(len_argv, argv, "org.gtkmm.example.plug"); auto builder = Gtk::Builder::create_from_file(path_glade + "ubl-settings-datetime.glade"); @@ -62,10 +62,10 @@ int main(int argc, char* argv[]) { } void pars_flag(int index_start, int argc, char* argv[]){ - string str_argv=""; - for (int i=index_start; i const& builder) { this->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; +void MainWindow::settings() { 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(); - if (this->check_root()==0){ - numTimeHrs->set_range(0,23); - numTimeMin->set_range(0,59); - numTimeHrs->set_increments(1.0,1.0); - numTimeMin->set_increments(1.0,1.0); + if (this->check_root() == 0) { + numTimeHrs->set_range(0, 23); + numTimeMin->set_range(0, 59); + numTimeHrs->set_increments(1.0, 1.0); + numTimeMin->set_increments(1.0, 1.0); this->get_config(); this->flag_block_gui(); btnBoxAboutDialog->set_visible(false); @@ -81,7 +74,7 @@ void MainWindow::settings(){ this->parse_text_date(); this->download_local_cfg(); } - else{ + else { btnDownload->set_sensitive(false); numTimeHrs->set_sensitive(false); numTimeMin->set_sensitive(false); @@ -108,8 +101,8 @@ void MainWindow::settings(){ } -int MainWindow::check_root(){ - if (geteuid()!=0){ +int MainWindow::check_root() { + if (geteuid() != 0) { lblMessageSudo->set_text(_("The program must be run with \nsuperuser privileges!")); mess_sudo->show(); return 1; @@ -117,14 +110,7 @@ int MainWindow::check_root(){ return 0; } -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")); +void MainWindow::lacalization() { aboutWindows->set_comments(_("Setting the date and time")); aboutWindows->set_website(_("https://wiki.ublinux.com")); aboutWindows->set_version(_(version_application.c_str())); @@ -138,7 +124,6 @@ void MainWindow::lacalization(){ cbDhcp->append(_("DHCP")); cbDhcp->append(_("Manual")); cbDhcp->append(_("Disabled")); - lblDateTimeSetting->set_text(_("Current date and time")); lblHead->set_text(_("Setting the date and time")); lblTime->set_text(_("Time")); @@ -157,8 +142,8 @@ void MainWindow::lacalization(){ } -void MainWindow::flag_block_gui(){ - if (flag_datetime==true){ +void MainWindow::flag_block_gui() { + if (flag_datetime == true) { btnUpdateDateTime->set_sensitive(false); numTimeHrs->set_sensitive(false); numTimeMin->set_sensitive(false); @@ -169,34 +154,34 @@ void MainWindow::flag_block_gui(){ lblTime->set_sensitive(false); lblData->set_sensitive(false); } - if (flag_timezone==true){ + if (flag_timezone == true) { cbRegion->set_sensitive(false); cbZone->set_sensitive(false); } - if (flag_ntp_mode==true){ + if (flag_ntp_mode == true) { cbDhcp->set_sensitive(false); txtNtpServer->set_sensitive(false); flag_ntp_edit = true; } - if (flag_ntp_edit==true){ + if (flag_ntp_edit == true) { txtNtpServer->set_sensitive(false); } - if (flag_load_global==true){ + if (flag_load_global == true) { btnDonwlolGlob->set_sensitive(false); } - if (flag_save==true){ + if (flag_save == true) { btnSave->set_sensitive(false); } - if (flag_save_local==true){ + if (flag_save_local == true) { btnSaveLocal->set_sensitive(false); } - if (flag_save_global==true){ + if (flag_save_global == true) { btnSaveGlob->set_sensitive(false); } } -void MainWindow::add_CSS(){ +void MainWindow::add_CSS() { Glib::RefPtr cssProvider = Gtk::CssProvider::create(); cssProvider->load_from_path(path_css); Glib::RefPtr styleContext = Gtk::StyleContext::create(); @@ -206,17 +191,44 @@ void MainWindow::add_CSS(){ Glib::RefPtr context_lbl_head = lblHead->get_style_context(); context->add_class("cssboxColor1"); context_lbl_head->add_class("textHead"); + /* + Glib::RefPtr boxButton_css = boxButton->get_style_context(); + Glib::RefPtr boxSave_css = boxSave->get_style_context(); + Glib::RefPtr btnDownload_css = btnDownload->get_style_context(); + Glib::RefPtr lblDownload_css = lblDownload->get_style_context(); + Glib::RefPtr imgDonwload_css = imgDonwload->get_style_context(); + Glib::RefPtr 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); + */ + } -void MainWindow::info_status_app(string stule){ +void MainWindow::info_status_app(string stule) { Glib::RefPtr boxInfo = boxInfoError->get_style_context(); boxInfo->remove_class("boxInfoMessOK"); boxInfo->remove_class("boxInfoMessError"); boxInfo->add_class(stule); } -void MainWindow::get_builder(){ +void MainWindow::get_builder() { builder->set_translation_domain(path_app); builder->get_widget("boxColor", boxColor); builder->get_widget("btnUpdateDateTime", btnUpdateDateTime); @@ -269,19 +281,30 @@ void MainWindow::get_builder(){ builder->get_widget("cbHw", cbHw); builder->get_widget("popCalendar", popCalendar); 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); } -bool MainWindow::gui_exit_2(GdkEventAny* event){ - if (event!=NULL){} +bool MainWindow::gui_exit_2(GdkEventAny* event) { + if (event != NULL) { + } exit(1); return true; } -void MainWindow::event(){ +void MainWindow::event() { btnHardwareTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::hardware_clock)); btnMessClose->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_mess_close)); btnMessCloseSudo->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_exit)); @@ -292,26 +315,26 @@ void MainWindow::event(){ cbRegion->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::append_zone)); cldrDate->signal_day_selected_double_click().connect(sigc::mem_fun(*this, &MainWindow::get_calendar)); mess_sudo->signal_delete_event().connect(sigc::mem_fun(*this, &MainWindow::gui_exit_2)); - btnAbout->signal_activate().connect([&](){aboutWindows->show();}); + btnAbout->signal_activate().connect([&]() {aboutWindows->show();}); btnSynopsis->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::synopsis_show)); btnDonwlodLocal->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::download_local_cfg)); btnDonwlolGlob->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::download_globl_cfg)); - btnSaveLocalGlob->signal_activate().connect([&](){save_global_local_cfg();}); - btnSaveLocal->signal_activate().connect([&](){save_local_cfg();}); - btnSaveGlob->signal_activate().connect([&](){save_global_cfg();}); + btnSaveLocalGlob->signal_activate().connect([&]() {save_global_local_cfg();}); + btnSaveLocal->signal_activate().connect([&]() {save_local_cfg();}); + btnSaveGlob->signal_activate().connect([&]() {save_global_cfg();}); } -void MainWindow::synopsis_show(){ +void MainWindow::synopsis_show() { int start_error = error_info; wrapper_system("xdg-open https://wiki.ublinux.ru/ru/home", "&"); //gtk_show_uri_on_window(NULL, "https://wiki.ublinux.ru/ru/home", 0, 0); - if (start_error!=error_info){ - error_info=start_error; + if (start_error != error_info) { + error_info = start_error; } } -void MainWindow::download_local_cfg(){ +void MainWindow::download_local_cfg() { string cmd = "/usr/bin/ubconfig --default --source system get clock ZONE"; this->fill_in_reg_zone(cmd); this->update_hour_minute(); @@ -325,21 +348,21 @@ void MainWindow::download_local_cfg(){ info_warning_error(0); } -void MainWindow::download_globl_cfg(){ +void MainWindow::download_globl_cfg() { 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"; this->entry_dhcp_mess(cmd_get_dhcp, cmd_default_get_dhcp); - string cmd = "/usr/bin/ubconfig --default --source global get clock ZONE"; - this->fill_in_reg_zone(cmd); - string hw = "/usr/bin/ubconfig --default --source global get clock HWCLOCK_SYNC"; + string cmd_zone = "/usr/bin/ubconfig --default --source global get clock ZONE"; + this->fill_in_reg_zone(cmd_zone); + 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"; this->entry_hardware_clock(hw, hw_default); info_warning_error(1); } -void MainWindow::save_local_cfg(){ - string cmd = "/usr/bin/ubconfig --target system set clock ZONE="; - this->enter_zone(cmd); +void MainWindow::save_local_cfg() { + string cmd_zone = "/usr/bin/ubconfig --target system set clock ZONE="; + this->enter_zone(cmd_zone); 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_set_ntp = "/usr/bin/ubconfig --target system set network NTPSERVERS=\""; @@ -351,7 +374,7 @@ void MainWindow::save_local_cfg(){ info_warning_error(2); } -void MainWindow::save_global_cfg(){ +void MainWindow::save_global_cfg() { string cmd = "/usr/bin/ubconfig --target global set clock ZONE="; this->enter_zone(cmd); string cmd_default = "/usr/bin/ubconfig --target global set network NTPSERVERS=default"; @@ -360,189 +383,189 @@ void MainWindow::save_global_cfg(){ string remove = "/usr/bin/ubconfig --target global remove network NTPSERVERS"; this->save_Dhcp(cmd_default, cmd_dhcp, remove, cmd_set_ntp); string local = "/usr/bin/ubconfig --target global set clock HWCLOCK_SYNC=localtime"; - string hw = "/usr/bin/ubconfig --target global set clock HWCLOCK_SYNC=utc"; + string hw = "/usr/bin/ubconfig --target global set clock HWCLOCK_SYNC=utc"; this->hardware_clock_global(local, hw); info_warning_error(3); } -void MainWindow::save_global_local_cfg(){ + +void MainWindow::save_global_local_cfg() { string cmd = ""; string cmd_default = ""; string cmd_dhcp = ""; string cmd_set_ntp = ""; string remove = ""; - if (flag_save_global==false){ + if (flag_save_global == false) { this->save_local_cfg(); } - if (flag_save_local==false){ + if (flag_save_local == false) { this->save_global_cfg(); } info_warning_error(4); } -void MainWindow::info_warning_error(int mess){ - if (error_info>0 || warning_info>0){ +void MainWindow::info_warning_error(int mess) { + if (error_info > 0 || warning_info > 0) { info_status_app("boxInfoMessError"); imgInfo->set("/usr/share/ubl-settings-datetime/images/warning.svg"); - error_info=0; - warning_info=0; - if (mess == 0){ + error_info = 0; + warning_info = 0; + if (mess == 0) { lblWarning->set_text(_("Local configuration reading error")); } - else if (mess == 1){ + else if (mess == 1) { lblWarning->set_text(_("Global configuration read error")); } - else if (mess == 2){ + else if (mess == 2) { lblWarning->set_text(_("Local configuration write error")); } - else if (mess == 3){ + else if (mess == 3) { lblWarning->set_text(_("Global configuration write error")); } - else if (mess == 4){ + else if (mess == 4) { lblWarning->set_text(_("Error saved local and global configuration")); } } - else{ + else { info_status_app("boxInfoMessOK"); imgInfo->set("/usr/share/ubl-settings-datetime/images/checked.svg"); - if (mess == 0){ + if (mess == 0) { lblWarning->set_text(_("Local configuration downloaded successfully")); } - else if (mess == 1){ + else if (mess == 1) { lblWarning->set_text(_("Global configuration downloaded successfully")); } - else if (mess == 2){ + else if (mess == 2) { lblWarning->set_text(_("Local configuration successfully written")); } - else if (mess == 3){ + else if (mess == 3) { lblWarning->set_text(_("Global configuration successfully written")); } - else if (mess == 4){ + else if (mess == 4) { lblWarning->set_text(_("Successfully saved local and global configuration")); } } } -void MainWindow::wrapper_system(string cmd, string thread_str=""){ +void MainWindow::wrapper_system(string cmd, string thread_str = "") { cmd=cmd + " " + thread_str; int response_cmd = system(cmd.c_str()); - if (response_cmd!=0){ - error_info+=1; + if (response_cmd!= 0) { + error_info+= 1; } } -void MainWindow::hardware_clock_global(string &local, string &etc){ +void MainWindow::hardware_clock_global(string &local, string &etc) { int index = cbHw->get_active_row_number(); - if (index == 0){ + if (index == 0) { wrapper_system(local, "&"); } - else if (index == 1){ + else if (index == 1) { 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; struct Result obj_result_default = this->wrapper_call(cmd_default); - if (obj_result_default.error == 0){ - if (obj_result_default.response.find("localtime")!=string::npos){ + if (obj_result_default.error == 0) { + if (obj_result_default.response.find("localtime") !=string::npos) { cbHw->set_active(0); } - else if (obj_result_default.response.find("utc")!=string::npos){ + else if (obj_result_default.response.find("utc") !=string::npos) { cbHw->set_active(1); } } - else if (obj_result_default.error == 3){ - if (error!=warning_info){ - warning_info=error; + else if (obj_result_default.error == 3) { + if (error != warning_info) { + warning_info = error; } cbHw->set_active(-1); } } -void MainWindow::entry_hardware_clock(string &cmd, string &cmd_default){ + +void MainWindow::entry_hardware_clock(string &cmd, string &cmd_default) { int error = warning_info; struct Result obj_result = this->wrapper_call(cmd); - if (obj_result.error == 0){ - if (obj_result.response.find("localtime")!=string::npos){ + if (obj_result.error == 0) { + if (obj_result.response.find("localtime") !=string::npos) { cbHw->set_active(0); } - else if (obj_result.response.find("utc")!=string::npos){ + else if (obj_result.response.find("utc") !=string::npos) { cbHw->set_active(1); } - else{ + else { this->entry_hardware_clock_default(cmd_default); } } - else if (obj_result.error == 3){ - if (error!=warning_info){ - warning_info=error; + else if (obj_result.error == 3) { + if (error != warning_info) { + warning_info = error; } cbHw->set_active(-1); this->entry_hardware_clock_default(cmd_default); } - else{ + else { this->entry_hardware_clock_default(cmd_default); } } -void MainWindow::hardware_clock(){ +void MainWindow::hardware_clock() { string cmd = "hwclock --systohc"; wrapper_system(cmd); } -void MainWindow::gui_mess_close(){ +void MainWindow::gui_mess_close() { mess_dchp->hide(); } -bool MainWindow::focus_ntp(string &cmd_set_ntp){ - if (txtNtpServer->get_text()=="" || txtNtpServer->get_text()==" "){ +bool MainWindow::focus_ntp(string &cmd_set_ntp) { + if (txtNtpServer->get_text() == "" || txtNtpServer->get_text() == " ") { lblMessage->set_text(_("Enter DHCP!")); mess_dchp->show(); } - else{ + else { string cmd = ""; - string array_simvol[]={ - "!","\"","#","$","%","^","'","*","(",")","+",":",";","=","<",">","?", - "@","[","]","\\","{","}","|","~", " " + string array_simvol[] = { + "!", "\"", "#", "$", "%", "^", "'", "*", "(", ")", "+", ":", ";", "=", "<", ">", "?", + "@", "[", "]", "\\", "{", "}", "|", "~", " " }; bool flag_error = false; bool flag_error_check_ntp = false; string str_ntp = txtNtpServer->get_text(); flag_error_check_ntp = this->check_ntp(str_ntp); - for (const auto &simvol: array_simvol){ - if (str_ntp.find(simvol)!=std::string::npos){ - flag_error=true; + for (const auto &simvol: array_simvol) { + if (str_ntp.find(simvol) != std::string::npos) { + flag_error= true; break; } } - if ((flag_error==false) && (flag_error_check_ntp==false)){ + if ((flag_error == false) && (flag_error_check_ntp == false)) { cmd = cmd_set_ntp + str_ntp + "\""; wrapper_system(cmd, "&"); } - else{ - if (flag_error==true){ + else { + if (flag_error == true) { lblMessage->set_text(_("An invalid character is entered")); mess_dchp->show(); } - else if (flag_error_check_ntp==true){ + else if (flag_error_check_ntp == true) { lblMessage->set_text(_("Error in the ntp name")); mess_dchp->show(); } } } - - return true; } -vector MainWindow::find_all(string &str_ntp, string substr){ +vector MainWindow::find_all(string &str_ntp, string substr) { size_t index = 0; vector sub_index; while ((index = str_ntp.find(substr, index)) != std::string::npos) { @@ -552,19 +575,19 @@ vector MainWindow::find_all(string &str_ntp, string substr){ return sub_index; } -bool MainWindow::check_ntp(string &str_ntp){ - vector sub_index = this->find_all(str_ntp,"."); - if (sub_index.size()==1){ +bool MainWindow::check_ntp(string &str_ntp) { + vector sub_index = this->find_all(str_ntp, "."); + if (sub_index.size() == 1) { int index_point = sub_index[0]; int len_str_ntp = str_ntp.length(); - if (((len_str_ntp-index_point)>=2) && (index_point>2)){ + if (((len_str_ntp-index_point) >= 2) && (index_point > 2)) { return false; } - else{ + else { return true; } } - else if (sub_index.size()==3){ + else if (sub_index.size() == 3) { int index_str_ntp = sub_index[0]; int index_str_ntp_1 = sub_index[1]; int index_str_ntp_2 = sub_index[2]; @@ -573,214 +596,209 @@ bool MainWindow::check_ntp(string &str_ntp){ ((index_str_ntp_1-index_str_ntp)<=4) && (index_str_ntp_2>(index_str_ntp_1+1)) && ((index_str_ntp_2-index_str_ntp_1)<=4) && - ((str_ntp.length()-index_str_ntp_2)<=3)) { - string simvol; - bool flag_error=false; - char char_ntp[1]={0}; - for (size_t i = 0; i < str_ntp.size(); i++){ - flag_error=false; - char_ntp[0] = str_ntp[i]; - for (int index=0;index<11;index++){ - - if (index==10){ - simvol="."; - } - else{ - simvol = to_string(index); - } - if (simvol==char_ntp){ - flag_error=false; - - break; - } - else{ - flag_error=true; - } + ((str_ntp.length()-index_str_ntp_2)<= 3)) { + string simvol; + bool flag_error = false; + char char_ntp[1] = {0}; + for (size_t i = 0; i < str_ntp.size(); i++) { + flag_error = false; + char_ntp[0] = str_ntp[i]; + for (int index = 0; index < 11; index++) { + if (index == 10) { + simvol = "."; + } + else { + simvol = to_string(index); } - if (flag_error==true){ - return true; + if (simvol == char_ntp) { + flag_error=false; + break; } + else { + flag_error = true; + } + } + if (flag_error == true) { + return true; } - } - else{ + } + } + else { return true; } } - else{ + else { return true; } return false; } -struct MainWindow::Result MainWindow::wrapper_call(string cmd){ +struct MainWindow::Result MainWindow::wrapper_call(string cmd) { struct Result obj_result; string response=this->call(cmd); - if ((response.find("(null)")==std::string::npos) && (response.length()!=0)){ - if (response.find("=")!=std::string::npos){ - if (response.find("\n")!=std::string::npos){ + if ((response.find("(null)") == std::string::npos) && (response.length() != 0 )) { + if (response.find("=") != std::string::npos) { + if (response.find("\n") != std::string::npos) { response = response.substr(response.find("=")+1,response.length()); response = response.substr(0,response.find("\n")); obj_result.response = response; obj_result.error = 0; } - else{ + else { obj_result.response = response; obj_result.error = 1; - warning_info+=1; + warning_info+= 1; } } - else{ + else { obj_result.response = response; obj_result.error = 2; - warning_info+=1; + warning_info+= 1; } } - else{ + else { obj_result.response = response; obj_result.error = 3; - warning_info+=1; + warning_info+= 1; } return obj_result; } -void MainWindow::event_entry_cbDhcp(){ + +void MainWindow::event_entry_cbDhcp() { string str_dhcp = cbDhcp->get_active_text(); string cmd = ""; - int activ_index = cbDhcp->get_active_row_number(); - if (str_dhcp.length()==0){ + int activ_index = cbDhcp->get_active_row_number(); + if (str_dhcp.length() == 0) { cbDhcp->set_active(0); } - else if (activ_index==0){ + else if (activ_index == 0) { txtNtpServer->set_text(""); btnUpdateDateTime->set_sensitive(false); txtNtpServer->set_sensitive(false); } - else if (activ_index==1){ + else if (activ_index == 1) { btnUpdateDateTime->set_sensitive(false); txtNtpServer->set_sensitive(false); txtNtpServer->set_text(""); } - else if (activ_index==2){ - if (flag_ntp_edit==false){ + else if (activ_index == 2) { + if (flag_ntp_edit==false) { txtNtpServer->set_sensitive(true); } } - else if (activ_index==3){ + else if (activ_index == 3) { txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); btnUpdateDateTime->set_sensitive(true); } } -void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove, string &cmd_set_ntp){ +void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove, string &cmd_set_ntp) { int activ_index = cbDhcp->get_active_row_number(); 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, "&"); } - else if (activ_index==1){ + else if (activ_index == 1) { wrapper_system(cmd_dhcp, "&"); - } - else if (activ_index==2){ + else if (activ_index == 2) { this->focus_ntp(cmd_set_ntp); - } - else if (activ_index==3){ + else if (activ_index== 3) { int start_error = error_info; wrapper_system(remove, "&"); - if (start_error != error_info){ + if (start_error != error_info) { error_info=start_error; } } } -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; - struct Result obj_result = this->wrapper_call(cmd); - if (obj_result.error==0){ + if (obj_result.error== 0) { string str_dhcp = obj_result.response; btnUpdateDateTime->set_sensitive(false); str_dhcp = str_dhcp.substr(str_dhcp.find("=")+1,str_dhcp.length()); str_dhcp = str_dhcp.substr(0,str_dhcp.find("\n")); - if (str_dhcp=="dhcp"){ + if (str_dhcp == "dhcp") { cbDhcp->set_active(1); txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); } - else if (str_dhcp=="default"){ + else if (str_dhcp == "default") { btnUpdateDateTime->set_sensitive(false); cbDhcp->set_active(0); cmd = cmd_default_get_dhcp; struct Result obj_result = this->wrapper_call(cmd); txtNtpServer->set_sensitive(false); - if (obj_result.error==0){ + if (obj_result.error== 0) { txtNtpServer->set_text(obj_result.response); } - else{ - if (obj_result.error==2){ - warning_info-=1; + else { + if (obj_result.error== 2) { + warning_info-= 1; } } } - else{ + else { btnUpdateDateTime->set_sensitive(false); - if (str_dhcp==""){ + if (str_dhcp == "") { lblMessage->set_text(_("Enter DHCP!")); mess_dchp->show(); } - else if (str_dhcp=="(null)"){ + else if (str_dhcp == "(null)") { cbDhcp->set_active(0); txtNtpServer->set_text(""); } - else{ + else { cbDhcp->set_active(2); txtNtpServer->set_text(str_dhcp); - if (flag_ntp_edit==false){ + if (flag_ntp_edit==false) { txtNtpServer->set_sensitive(true); } } } - } - else{ + } + else { cbDhcp->set_active(3); txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); btnUpdateDateTime->set_sensitive(true); - warning_info-=1; + warning_info-= 1; } } -string MainWindow::str_remove(std::string& source, const std::string to_remove){ +string MainWindow::str_remove(std::string& source, const std::string to_remove) { auto begin = source.find(to_remove); - if (begin!=std::string::npos){ + if (begin!=std::string::npos) { int len_to_remove = to_remove.length(); source.erase(begin, begin+len_to_remove); } return source; } -void MainWindow::get_calendar(){ +void MainWindow::get_calendar() { string str_month = ""; string str_day = ""; cldrDate->get_date(year, month, day); - if (month <10){ - str_month = "0"+to_string(month+1); + if (month < 10) { + str_month = "0"+ to_string(month+1); } - else{ + else { str_month = to_string(month+1); } - if (day <10){ + if (day < 10) { str_day = "0"+to_string(day); } - else{ + else { str_day = to_string(day); } string date = str_day + '.' + str_month + '.' + to_string(year); @@ -788,67 +806,68 @@ void MainWindow::get_calendar(){ popCalendar->hide(); } -void MainWindow::calendar_show(){ - if (year==0){ +void MainWindow::calendar_show() { + if (year== 0) { time_t now = time(0); tm *ltm = localtime(&now); - unsigned int y=1900+ ltm->tm_year; + unsigned int y= 1900+ ltm->tm_year; unsigned int m=ltm->tm_mon; unsigned int d=ltm->tm_mday; cldrDate->select_month(m,y); cldrDate->select_day(d); } - else{ + else { cldrDate->select_month(month,year); cldrDate->select_day(day); } popCalendar->show(); } -void MainWindow::fill_in_reg_zone(string &cmd){ + +void MainWindow::fill_in_reg_zone(string &cmd) { int error = warning_info; struct Result obj_result_1 = this->wrapper_call(cmd); - if (obj_result_1.error==0){ + if (obj_result_1.error== 0) { auto arr_reg_zone = this->split_region_zone(obj_result_1.response); - if (arr_reg_zone[0].length()!=0){ - this->append_region_zone(arr_reg_zone[0],arr_reg_zone[1], cbRegion, cbZone); + if (arr_reg_zone[0].length() != 0) { + this->append_region_zone(arr_reg_zone[0], arr_reg_zone[1], cbRegion, cbZone); } - else{ - this->append_region_zone("","",cbRegion,cbZone); + else { + this->append_region_zone("", "" ,cbRegion,cbZone); } } else { - this->append_region_zone("","",cbRegion,cbZone); + this->append_region_zone("", "", cbRegion, cbZone); } - if (obj_result_1.error==3){ - if (error!=warning_info){ - warning_info=error; + if (obj_result_1.error == 3) { + if (error != warning_info) { + warning_info = error; } } } -void MainWindow::get_config(){ +void MainWindow::get_config() { this->read_file(); this->update_hour_minute(); this->update_calendar(); } -array MainWindow::split_region_zone(string &read_reg_zon_cfg){ +array MainWindow::split_region_zone(string &read_reg_zon_cfg) { array arr; - if (read_reg_zon_cfg.find("/")!=std::string::npos){ + if (read_reg_zon_cfg.find("/") !=std::string::npos) { string str_filling_reg = read_reg_zon_cfg.substr(0,read_reg_zon_cfg.find("/")); string str_filling_zon = read_reg_zon_cfg.substr(read_reg_zon_cfg.find("/")+1,read_reg_zon_cfg.length()); arr[0] = str_filling_reg; arr[1] = str_filling_zon; } - else if (read_reg_zon_cfg.length()!=0){ + else if (read_reg_zon_cfg.length() != 0) { arr[0] = read_reg_zon_cfg; arr[1] = ""; } - else{ + else { arr[0] = ""; arr[1] = ""; } @@ -857,59 +876,59 @@ array MainWindow::split_region_zone(string &read_reg_zon_cfg){ } -void MainWindow::enter_zone(string &cmd){ +void MainWindow::enter_zone(string &cmd) { int activ_index_reg = cbRegion->get_active_row_number(); string reg_text=array_region[activ_index_reg]; int activ_index = cbZone->get_active_row_number(); string zone_text = ""; - if(!(reg_text.empty())){ - int index=0; - for (const auto &zone :time_reg_map.at(reg_text)){ - if (index==activ_index){ + if(!(reg_text.empty())) { + int index= 0; + for (const auto &zone: time_reg_map.at(reg_text)) { + if (index==activ_index) { zone_text=zone; } - index+=1; + index+= 1; } - if (!(zone_text.empty())){ + if (!(zone_text.empty())) { str_zone=zone_text; str_region=reg_text; - cmd = cmd + str_region + "/" + str_zone; + cmd = cmd + str_region + "/" + str_zone; wrapper_system(cmd, "&"); } - else{ - str_zone=""; - str_region=""; + else { + str_zone = ""; + str_region = ""; } } - else{ - str_zone=""; - str_region=""; + else { + str_zone = ""; + str_region = ""; } } -void MainWindow::parse_text_date(){ +void MainWindow::parse_text_date() { string data = txtDate->get_text(); - if (data.length()==10){ - string day = data.substr(0,2); - string month1 = data.substr(3,2); + if (data.length() == 10) { + string day = data.substr(0, 2); + string month1 = data.substr(3, 2); string year = data.substr(6,data.length()); } } -void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxText *tmpCbReg, Gtk::ComboBoxText *tmpCbZone){ - str_region=region; +void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxText *tmpCbReg, Gtk::ComboBoxText *tmpCbZone) { + str_region = region; int index = 0; Glib::ustring reg_local = ""; int size_vec = array_region_local.size(); - if (size_vec==0){ - for (auto& [key, value]: time_reg_map){ + if (size_vec== 0) { + for (auto& [key, value]: time_reg_map) { array_region_local.push_back(string(_(key.c_str()))); array_region.push_back(key); - index+=1; + index += 1; } } // Cортировка пузырьком - if (size_vec==0){ + if (size_vec == 0) { int size_vec_sort = array_region_local.size(); for (int i = 0; i < size_vec_sort; i++) { for (int j = 0; j < size_vec_sort-1; j++) { @@ -925,11 +944,11 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex } } - for (string ® : array_region_local){ - if (size_vec==0){ + for (string ® : array_region_local) { + if (size_vec == 0) { tmpCbReg->append(Glib::ustring(reg)); } - if (reg == string(_(region.c_str()))){ + if (reg == string(_(region.c_str()))) { tmpCbReg->set_active_text(reg); } } @@ -938,52 +957,52 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex string zone_mixing = ""; string path_reg_zone = ""; string zone_offest = ""; - path_reg_zone=region+"/"+zone; + path_reg_zone=region + "/" + zone; zone_offest = this->zone_file_read(path_reg_zone) + _(zone.c_str()); - if (region==""){ + if (region == "") { tmpCbZone->append(" "); tmpCbZone->set_active(0); tmpCbReg->set_active(-1); return; } - if (time_reg_map_local.find(region) == time_reg_map_local.end()){ + if (time_reg_map_local.find(region) == time_reg_map_local.end()) { tmpCbZone->append(" "); tmpCbZone->set_active(0); tmpCbReg->set_active(-1); } - else{ - for (string &_str_zone : time_reg_map_local.at(region)){ + else { + for (string &_str_zone: time_reg_map_local.at(region)) { tmpCbZone->append(_str_zone); - if (_str_zone!=""){ - if (zone_offest == _str_zone){ + if (_str_zone != "") { + if (zone_offest == _str_zone) { tmpCbZone->set_active(index); } } - index+=1; + index+= 1; } } - if (region=="Etc" && zone==""){ - warning_info-=1; + if (region == "Etc" && zone == "") { + warning_info -= 1; tmpCbZone->set_active(index); } - else if (region=="" && zone==""){ - warning_info+=1; + else if (region == "" && zone== "") { + warning_info += 1; int error = warning_info; - if (warning_info!=error){ - warning_info=error; + if (warning_info != error) { + warning_info = error; } } } -string MainWindow::call(string cmd){ +string MainWindow::call(string cmd) { FILE *fp; int status; - char path[PATH_MAX]={0}; + char path[PATH_MAX] = {0}; fp = popen(cmd.c_str(), "r"); - if (fp == NULL){ + if (fp == NULL) { exit(1); } - while (fgets(path, PATH_MAX, fp) != NULL){ + while (fgets(path, PATH_MAX, fp) != NULL) { break; } status = pclose(fp); @@ -994,15 +1013,15 @@ string MainWindow::call(string cmd){ return path; } -void MainWindow::append_zone(){ +void MainWindow::append_zone() { cbZone->remove_all(); int index = cbRegion->get_active_row_number(); - if (index!=-1){ + if (index!=-1) { string str_region = array_region[index]; - string zone_mixing=""; - string path_dir=""; - if(str_region.length()!=0){ - for (const auto &_str_zone : time_reg_map_local.at(str_region)){ + string zone_mixing= ""; + string path_dir= ""; + if(str_region.length() != 0) { + for (const auto &_str_zone : time_reg_map_local.at(str_region)) { cbZone->append(Glib::ustring(_str_zone)); } } @@ -1010,57 +1029,57 @@ void MainWindow::append_zone(){ } } -void MainWindow::update_time_date(){ +void MainWindow::update_time_date() { string cmd = ""; - if ((year!=0) && (month !=0) && (day !=0)){ + if ((year != 0) && (month != 0) && (day != 0)) { string str_month = ""; string str_day = ""; - month+=2; - if (month <10){ + month+= 2; + if (month < 10) { str_month = "0"+to_string(month); } - else{ + else { str_month = to_string(month); } - if (day <10){ - str_day = "0"+to_string(day); + if (day < 10) { + str_day = "0" + to_string(day); } - else{ + else { str_day = to_string(day); } string str_data = ""; - str_data = str_day+"." + str_month+"." + to_string(year); + str_data = str_day + "." + str_month + "." + to_string(year); string str_data_entry = txtDate->get_text(); - if (str_data==str_data_entry){ + if (str_data == str_data_entry) { cmd = "date +%Y%m%d -s \"" + to_string(year)+ - str_month+str_day+"\""; + str_month+str_day + "\""; wrapper_system(cmd); txtDate->set_text(str_data); - year=0; - month=0; - day=0; + year = 0; + month = 0; + day = 0; } - else{ + else { this->post_entry_data(); } } - else{ + else { this->post_entry_data(); } hour = numTimeHrs->get_value_as_int(); minute = numTimeMin->get_value_as_int(); time_t now = time(0); tm *ltm = localtime(&now); - cmd = "date +%T -s \""+ + cmd = "date +%T -s \"" + to_string(hour) + ":" + to_string(minute) + ":" + to_string(ltm->tm_sec) +"\""; wrapper_system(cmd); } -void MainWindow::post_entry_data(){ +void MainWindow::post_entry_data() { string cmd = ""; string data = txtDate->get_text(); - if (data.length()==10){ + if (data.length() == 10) { string str_day = data.substr(0,2); string str_month = data.substr(3,2); string str_year = data.substr(6,data.length()); @@ -1068,23 +1087,23 @@ void MainWindow::post_entry_data(){ str_month+str_day+"\""; string str_error_clock = this->call(cmd); size_t index = str_error_clock.find("date: "); - if (index==std::string::npos){ + if (index == std::string::npos) { } } - else{ + else { lblMessage->set_text(_("Incorrect date format")); mess_dchp->show(); } } -void MainWindow::update_hour_minute(){ +void MainWindow::update_hour_minute() { time_t now = time(0); tm *ltm = localtime(&now); numTimeHrs->set_value(ltm->tm_hour); numTimeMin->set_value(ltm->tm_min); } -void MainWindow::update_calendar(){ +void MainWindow::update_calendar() { time_t now = time(0); tm *ltm = localtime(&now); int year1 = 1900 + (int)ltm->tm_year; @@ -1093,58 +1112,57 @@ void MainWindow::update_calendar(){ unsigned int month, day; month=ltm->tm_mon+1; day=ltm->tm_mday; - if (month <=10){ - str_month = "0"+to_string(month); + if (month <= 10) { + str_month = "0" + to_string(month); } - else{ + else { str_month = to_string(month); } - if (day <10){ - str_day = "0"+to_string(day); + if (day < 10) { + str_day = "0" + to_string(day); } - else{ + else { str_day = to_string(day); } string date = str_day + '.' + str_month + '.' + to_string(year1); txtDate->set_text(date); } -void MainWindow::read_file(){ +void MainWindow::read_file() { std::string line; string key_zone_local = ""; string path_reg_zone = ""; namespace fs = std::filesystem; - for (const auto & entry : fs::directory_iterator("/usr/share/zoneinfo/")){ + for (const auto & entry : fs::directory_iterator("/usr/share/zoneinfo/")) { std::ifstream in(entry.path()); - if (in.is_open()){ - string key_reg = entry.path().filename().string(); - string path_dir = "/usr/share/zoneinfo/"+key_reg; - if (fs::is_directory(path_dir)){ - if (key_reg!="Pacific"){ - if (key_reg!="posix"){ - if (key_reg!="right"){ + if (in.is_open()) { + string key_reg = entry.path().filename().string(); + string path_dir = "/usr/share/zoneinfo/" + key_reg; + if (fs::is_directory(path_dir)) { + if (key_reg != "Pacific") { + if (key_reg != "posix") { + if (key_reg != "right") { vector zone; vector zone_local; - for (const auto & entry_zone : fs::directory_iterator(path_dir)){ + for (const auto & entry_zone : fs::directory_iterator(path_dir)) { std::ifstream in1(entry_zone.path()); - if (in1.is_open()){ + if (in1.is_open()) { string key_zone = entry_zone.path().filename().string(); - - if (fs::is_directory(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)){ + if (fs::is_directory(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)) { std::ifstream in2(entry_zone.path()); - if (in2.is_open()){ + if (in2.is_open()) { string reg_reg_zone = entry_reg_reg_zone.path().filename().string(); zone.push_back(reg_reg_zone); path_reg_zone=key_reg + "/" + reg_reg_zone; - key_zone_local = this->zone_file_read(path_reg_zone) +_(reg_reg_zone.c_str()); + key_zone_local = this->zone_file_read(path_reg_zone) + _(reg_reg_zone.c_str()); zone_local.push_back(key_zone_local); } in2.close(); } } - else if (key_zone.length()!=0 || key_zone!=" "){ + else if (key_zone.length() != 0 || key_zone != " ") { zone.push_back(key_zone); path_reg_zone = key_reg + "/" + key_zone; key_zone_local = this->zone_file_read(path_reg_zone) + _(key_zone.c_str()); @@ -1163,7 +1181,7 @@ void MainWindow::read_file(){ } } -void MainWindow::sort_zone(vector *time_reg_map_local,vector *time_reg_map){ +void MainWindow::sort_zone(vector *time_reg_map_local,vector *time_reg_map) { string str_j = ""; int j_i; string str_j_1 = ""; @@ -1172,32 +1190,32 @@ void MainWindow::sort_zone(vector *time_reg_map_local,vector *ti for (int i = 1; i < size_vec; i++) { for (int j = 1; j < size_vec-1; j++) { str_j=(*time_reg_map_local)[j]; - if (str_j!=" "){ + if (str_j != " ") { str_j = str_j.substr(5,str_j.find(")")-5); - if (str_j[1]=='0'){ - str_j.replace(1,1,"0"); + if (str_j[1] == '0') { + str_j.replace(1,1, "0"); } - if (str_j.find("+") != std::string::npos){ - str_j.replace(0,1,"+"); + if (str_j.find("+") != std::string::npos) { + str_j.replace(0,1, "+"); j_i = stoi(str_j); } - else{ - str_j.replace(0,1,"-"); + else { + str_j.replace(0,1, "-"); j_i = stoi(str_j); j_i=-j_i; } str_j_1=(*time_reg_map_local)[j+1]; str_j_1 = str_j_1.substr(5,str_j_1.find(")")-5); - if (str_j_1[1]=='0'){ - str_j_1.replace(1,1,"0"); + if (str_j_1[1]=='0') { + str_j_1.replace(1,1, "0"); } - if (str_j_1.find("+") != std::string::npos){ - str_j_1.replace(0,1,"+"); + if (str_j_1.find("+") != std::string::npos) { + str_j_1.replace(0,1, "+"); j_i_1 = stoi(str_j_1); } - else{ - str_j_1.replace(0,1,"-"); + else { + str_j_1.replace(0, 1, "-"); j_i_1 = stoi(str_j_1); j_i_1 = -j_i_1; } @@ -1214,8 +1232,8 @@ void MainWindow::sort_zone(vector *time_reg_map_local,vector *ti } } -string MainWindow::zone_file_read(string zone){ - if (zone.length()==1){ +string MainWindow::zone_file_read(string zone) { + if (zone.length() == 1) { return ""; } UErrorCode success = U_ZERO_ERROR; @@ -1225,23 +1243,23 @@ string MainWindow::zone_file_read(string zone){ U_ICU_NAMESPACE::Calendar* calendar = U_ICU_NAMESPACE::Calendar::createInstance(success); curDate = calendar->getNow(); tzWest->getOffset(curDate,true,stdOffset,dstOffset,success); - int offset = stdOffset/(1000*60*60); + int offset = stdOffset/(1000 * 60 * 60); string str_utc = ""; - if (offset>=0){ - if (offset<=9){ + if (offset >= 0) { + if (offset <=9) { str_utc = "(UTC +0" + to_string(offset) + ") "; } - else{ + else { str_utc = "(UTC +" + to_string(offset) + ") "; } } - else{ - if (offset>=-9){ - offset*=-1; + else { + if (offset >= -9) { + offset *= -1; str_utc = "(UTC -0" + to_string(offset) + ") "; } - else{ + else { str_utc = "(UTC " + to_string(offset) + ") "; } } @@ -1250,7 +1268,7 @@ string MainWindow::zone_file_read(string zone){ return str_utc; } -vector MainWindow::split(const std::string &s, char delim){ +vector MainWindow::split(const std::string &s, char delim) { std::stringstream ss(s); std::string item; std::vector elems; @@ -1261,7 +1279,7 @@ vector MainWindow::split(const std::string &s, char delim){ } SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr builder) - : Gtk::Plug{p_socketID} { + :Gtk::Plug{p_socketID} { MainWindow* wnd = nullptr; builder->get_widget_derived("window", wnd); builder->get_widget("plugBox", plugBox); @@ -1270,7 +1288,7 @@ SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr build show_all_children(); } -void help(){ +void help() { g_print(gettext("Usage: ubl-settings-datetime [--lock-timezone] [--lock-ntp] [--lock-datetime] [--lock-update]\n")); g_print(gettext("Options:\n")); g_print(gettext(" --lock-timezone Disable timezone field editing\n")); diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index 9bf6c34..ce4b60e 100755 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -20,11 +20,11 @@ using namespace std; -extern string path_app; -extern string path_glade; -extern string app_name; -extern string path_locale; -extern string path_css; +extern const string path_app; +extern const string path_glade; +extern const string app_name; +extern const string path_locale; +extern const string path_css; extern bool flag_datetime; extern bool flag_timezone; extern bool flag_ntp_mode; @@ -105,17 +105,26 @@ class MainWindow : public Gtk::ApplicationWindow { Gtk::Label *lblHW; Gtk::ComboBoxText *cbHw; Gtk::Box *boxDateTime; - unsigned int year=0; - unsigned int month=0; - unsigned int day=0; + 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 month = 0; + unsigned int day = 0; string version_application = "1.3"; int error_info = 0; int warning_info = 0; int hour; int minute; - string str_region=""; - string str_zone=""; - bool bool_close_banner_info=true; + string str_region = ""; + string str_zone = ""; + bool bool_close_banner_info = true; template struct Result{ Type response; diff --git a/style.css b/style.css index ada0e2a..fadccb5 100644 --- a/style.css +++ b/style.css @@ -69,4 +69,13 @@ .menuitemtop{ 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)); } \ No newline at end of file diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade index ab4b270..6fdf5c9 100644 --- a/ubl-settings-datetime.glade +++ b/ubl-settings-datetime.glade @@ -457,7 +457,7 @@ Format: DD.MM.YYYY 6 - True + False True 5 @@ -550,7 +550,7 @@ Format: DD.MM.YYYY - False + True True 0 @@ -680,7 +680,6 @@ Format: DD.MM.YYYY - -1 True True Enter the name of the ntp server or its ip address. When entering multiple addresses, separate them with spaces. @@ -754,19 +753,31 @@ Format: DD.MM.YYYY False start 8 - 31 + 5 8 - 31 + 5 6 13 Synchronize hardware time: - False + True True 0 + + + True + False + 55 + + + False + True + 1 + + True @@ -783,7 +794,7 @@ Format: DD.MM.YYYY True True - 1 + 2 @@ -829,7 +840,6 @@ Format: DD.MM.YYYY - 172 True False 5 @@ -842,7 +852,7 @@ Format: DD.MM.YYYY False - False + True True 3 @@ -956,11 +966,11 @@ Format: DD.MM.YYYY True False + start 5 5 5 5 - 2 False ubl-settings-datetime @@ -1014,7 +1024,7 @@ Format: DD.MM.YYYY - + True False pan-down-symbolic @@ -1079,7 +1089,7 @@ Format: DD.MM.YYYY - + True False pan-down-symbolic @@ -1109,7 +1119,7 @@ Format: DD.MM.YYYY menu1 none - + True False open-menu-symbolic @@ -1134,6 +1144,30 @@ Format: DD.MM.YYYY + + both + True + + + + + + + both + True + + + + + + + both + True + + + + + 240 185