diff --git a/Makefile b/Makefile index 376e6da..e1f25a0 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,7 @@ install: check uninstall @install -Dm644 -t /usr/share/${PKGNAME}/css/ style.css @install -Dm644 -t /usr/share/${PKGNAME}/images/ ${PKGNAME}.svg @install -Dm644 -t /usr/share/${PKGNAME}/images/ ${PKGNAME}.png + @install -Dm644 -t /usr/share/${PKGNAME}/images/ bg_top.png @gtk-update-icon-cache -fiq /usr/share/icons/hicolor/ @update-desktop-database --quiet 2>/dev/null @touch /usr/share/applications diff --git a/bg_top.png b/bg_top.png new file mode 100644 index 0000000..7feeb92 Binary files /dev/null and b/bg_top.png differ diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index cf7db5e..3051153 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -77,11 +77,11 @@ void MainWindow::settings(){ void MainWindow::lacalization(){ _txtDate->set_tooltip_text(gettext("Date of\nFormat: DD.MM.YYYY")); - _lblSynchronizebChk->set_text(gettext("Synchronize via NTP")); + _lblSynchronizebChkGLob->set_text(gettext("Synchronize via NTP")); _cbDhcp->append(gettext("DHCP")); _cbDhcp->append(gettext("Manually")); _lblDateTimeSetting->set_text(gettext("Settings the date and time")); - _lblNtpServer1->set_text(gettext("Settings the date and time")); + //_lblNtpServer1->set_text(gettext("Settings the date and time")); _lblTime->set_text(gettext("Time")); _lblData->set_text(gettext("Date")); _lblTimeZone->set_text(gettext("Time zone")); @@ -90,12 +90,12 @@ void MainWindow::lacalization(){ _lblRegGlob->set_text(gettext("Region")); _lblZone1Glob->set_text(gettext("Zone")); _lblTimeZoneGlob->set_text(gettext("Time zone")); - _lblSynchronizeBtn->set_text(gettext("Sync by")); + _lblSynchronizeBtn->set_text(gettext("Apply local date and time settings")); _lblDateTimeSettingGlob->set_text(gettext("Setting date and time in global configuration")); this->set_title(gettext("ubl-settings-datetime")); _mess_dchp->set_title(gettext("Warning!")); _lblTimeBios->set_text(gettext("Synchronize hardware time")); - _lblTimeBiosGlob->set_text(gettext("Synchronize hardware time")); + _lblSynchronizebChk->set_text(gettext("Synchronize via NTP")); } void MainWindow::flag_block_gui(){ @@ -114,14 +114,15 @@ void MainWindow::flag_block_gui(){ _cbDhcp->set_sensitive(false); } if (flag_ntp==true){ - _cbxSynchronizeNtp->set_sensitive(false); + _cbxSynchronizeNtpGlob->set_sensitive(false); _cbDhcp->set_sensitive(false); _txtNtpServer->set_sensitive(false); + _cbxSynchronizeNtp->set_sensitive(false); } if (flag_update==true){ _lblDateTimeSettingGlob->set_sensitive(false); - _lblSynchronizebChk->set_sensitive(false); - _cbxSynchronizeNtp->set_sensitive(false); + _lblSynchronizebChkGLob->set_sensitive(false); + _cbxSynchronizeNtpGlob->set_sensitive(false); _lblTimeZoneGlob->set_sensitive(false); _lblRegGlob->set_sensitive(false); _cbRegionGlob->set_sensitive(false); @@ -146,7 +147,7 @@ void MainWindow::get_builder(){ builder->get_widget("btnUpdateDateTime", _btnUpdateDateTime); builder->get_widget("btnChooseDate", _btnChooseDate); builder->get_widget("btnMessClose", _btnMessClose); - builder->get_widget("cbxSynchronizeNtp", _cbxSynchronizeNtp); + builder->get_widget("cbxSynchronizeNtpGlob", _cbxSynchronizeNtpGlob); builder->get_widget("popCalendar", _popCalendar); builder->get_widget("numTimeHrs", _numTimeHrs); builder->get_widget("numTimeMin", _numTimeMin); @@ -171,20 +172,22 @@ void MainWindow::get_builder(){ builder->get_widget("lblZone1Glob",_lblZone1Glob); builder->get_widget("lblTimeZoneGlob",_lblTimeZoneGlob); builder->get_widget("lblSynchronizebChk",_lblSynchronizebChk); + builder->get_widget("lblSynchronizebChkGLob",_lblSynchronizebChkGLob); builder->get_widget("lblSynchronizeBtn",_lblSynchronizeBtn); builder->get_widget("lblDateTimeSettingGlob",_lblDateTimeSettingGlob); builder->get_widget("lblTimeBios",_lblTimeBios); - builder->get_widget("lblTimeBiosGlob",_lblTimeBiosGlob); - - + builder->get_widget("btnHardwareTime",_btnHardwareTime); + builder->get_widget("cbxSynchronizeNtp",_cbxSynchronizeNtp); this->add_CSS(); } void MainWindow::event(){ + _cbxSynchronizeNtp->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::set_ntp_toggle)); + _btnHardwareTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::hardware_clock)); _btnMessClose->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_mess_close)); //_cldrDate->signal_day_selected().connect(sigc::mem_fun(*this, &MainWindow::get_calendar)); - _cbxSynchronizeNtp->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::set_ntp_toggle)); + _cbxSynchronizeNtpGlob->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::set_ntp_toggle_glob)); _btnUpdateDateTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::update_time_date)); _btnChooseDate->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::calendar_show)); _cbDhcp->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::event_entry_cbDhcp)); @@ -196,6 +199,33 @@ void MainWindow::event(){ _cldrDate->signal_day_selected_double_click().connect(sigc::mem_fun(*this, &MainWindow::get_calendar)); } +void MainWindow::set_ntp_toggle(){ + bool flag = _cbxSynchronizeNtp->get_active(); + if (flag_ntp==true){ + } + else { + _numTimeHrs->set_sensitive(!flag); + _numTimeMin->set_sensitive(!flag); + _btnChooseDate->set_sensitive(!flag); + _txtDate->set_sensitive(!flag); + _lblTimeBios->set_sensitive(!flag); + } + string cmd = ""; + if (flag==false){ + cmd="systemctl --now disable systemd-timesyncd.service ntpd.service"; + system(cmd.c_str()); + } + else { + cmd = "systemctl --now enable systemd-timesyncd.service"; + system(cmd.c_str()); + } +} + + +void MainWindow::hardware_clock(){ + string cmd = "hwclock --systohc"; + system(cmd.c_str()); +} void MainWindow::gui_mess_close(){ _mess_dchp->hide(); @@ -288,7 +318,7 @@ void MainWindow::calendar_show(){ void MainWindow::enry_dhcp_mess(){ string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); if ((str_dhcp!="") && (str_dhcp!="(null)")){ - _cbxSynchronizeNtp->set_active(1); + _cbxSynchronizeNtpGlob->set_active(1); 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"){ @@ -305,10 +335,10 @@ void MainWindow::enry_dhcp_mess(){ _txtNtpServer->set_text(str_dhcp); } } - this->set_ntp_toggle(); + this->set_ntp_toggle_glob(); } else{ - _cbxSynchronizeNtp->set_active(0); + _cbxSynchronizeNtpGlob->set_active(0); _cbDhcp->set_sensitive(0); _txtNtpServer->set_sensitive(0); } @@ -322,9 +352,19 @@ void MainWindow::get_config(){ string str_ntp = this->call("systemctl status ntpd.service systemd-timesyncd.service | grep \"Active: active\""); if (str_ntp.length()<50) { _cbxSynchronizeNtp->set_active(false); + _numTimeHrs->set_sensitive(true); + _numTimeMin->set_sensitive(true); + _btnChooseDate->set_sensitive(true); + _txtDate->set_sensitive(true); + _lblTimeBios->set_sensitive(true); } else{ _cbxSynchronizeNtp->set_active(true); + _numTimeHrs->set_sensitive(false); + _numTimeMin->set_sensitive(false); + _btnChooseDate->set_sensitive(false); + _txtDate->set_sensitive(false); + _lblTimeBios->set_sensitive(false); } string read_reg_zon_cfg = this->call("/usr/bin/ubconfig get clock ZONE"); if ((read_reg_zon_cfg != "") && (read_reg_zon_cfg !="(null)")){ @@ -382,25 +422,15 @@ void MainWindow::enter_zone_glob(){ } } -void MainWindow::set_ntp_toggle(){ +void MainWindow::set_ntp_toggle_glob(){ bool flag = _cbxSynchronizeNtp->get_active(); - if (flag_datetime==true){ - } - else { - _numTimeHrs->set_sensitive(!flag); - _numTimeMin->set_sensitive(!flag); - _btnChooseDate->set_sensitive(!flag); - _txtDate->set_sensitive(!flag); - } - string cmd = ""; - if (flag==false){ - cmd="systemctl --now disable systemd-timesyncd.service ntpd.service"; - system(cmd.c_str()); + if (flag==true){ + } - else { - cmd = "systemctl --now enable systemd-timesyncd.service"; - system(cmd.c_str()); + else{ + } + } void MainWindow::append_region_zone(string region, string zone){ @@ -475,7 +505,7 @@ void MainWindow::append_zone_glob(){ void MainWindow::update_time_date(){ //this->enter_zone(); - bool flag = _cbxSynchronizeNtp->get_active(); + bool flag = _cbxSynchronizeNtpGlob->get_active(); string cmd = ""; if ((year!=0) && (month !=0) && (day !=0)){ string str_month = ""; @@ -500,8 +530,7 @@ void MainWindow::update_time_date(){ cmd = "date +%Y%m%d -s \"" + to_string(year)+ str_month+str_day+"\""; system(cmd.c_str()); - //cmd = "hwclock --systohc"; - //system(cmd.c_str()); + _txtDate->set_text(str_data); year=0; month=0; diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index 7d34d73..de8fc92 100644 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -73,6 +73,8 @@ class MainWindow : public Gtk::ApplicationWindow { void update_calendar(); void read_file(); void parse_text_date(); + void hardware_clock(); + void set_ntp_toggle_glob(); vector split(const std::string &s, char delim); private: Glib::RefPtr builder; @@ -82,7 +84,7 @@ class MainWindow : public Gtk::ApplicationWindow { Gtk::ComboBoxText *_cbDhcp; Gtk::SpinButton *_numTimeHrs; Gtk::SpinButton *_numTimeMin; - Gtk::CheckButton *_cbxSynchronizeNtp; + Gtk::CheckButton *_cbxSynchronizeNtpGlob; Gtk::Box *_boxColor; Gtk::Entry *_txtDate; Gtk::ComboBoxText *_cbRegion; @@ -105,10 +107,12 @@ class MainWindow : public Gtk::ApplicationWindow { Gtk::Label *_lblZone1Glob; Gtk::Label *_lblTimeZoneGlob; Gtk::Label *_lblSynchronizebChk; + Gtk::Label *_lblSynchronizebChkGLob; Gtk::Label *_lblSynchronizeBtn; Gtk::Label *_lblDateTimeSettingGlob; Gtk::Label *_lblTimeBios; - Gtk::Label *_lblTimeBiosGlob; + Gtk::Button *_btnHardwareTime; + Gtk::CheckButton *_cbxSynchronizeNtp; std::map > time_reg_map; unsigned int year=0; unsigned int month=0; diff --git a/style.css b/style.css index f3bdf4e..12dcd25 100644 --- a/style.css +++ b/style.css @@ -1,4 +1,3 @@ .cssboxColor1{ - background-color: rgb(255, 255, 255); - background-size: 100% auto; + background-image: url("/usr/share/ubl-settings-datetime/images/bg_top.png"); } \ No newline at end of file diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade index e7ac7c2..1c55ddb 100644 --- a/ubl-settings-datetime.glade +++ b/ubl-settings-datetime.glade @@ -79,29 +79,6 @@ - - 240 - 185 - False - btnChooseDate - bottom - none - - - True - True - 10 - 10 - 10 - 10 - 10 - 10 - 2023 - 1 - 10 - - - False Настройки даты и времени @@ -111,7 +88,7 @@ False vertical - + True False @@ -135,50 +112,62 @@ - - 145 + True False - 5 - 5 - 5 - 5 - 3 - 6 - Настройка даты и времени - True - 28 - 0 - - - - + + + True + False + + + True + False + vertical + + + 255 + True + False + + + False + True + 0 + + + + + False + True + 0 + + + + + True + True + 0 + + + + + True + False + + + False + True + 1 + + - False + True True 1 - - - 100 - True - False - 15 - 5 - 15 - 5 - - - - - - False - True - 2 - - False @@ -209,6 +198,38 @@ 6 5 vertical + + + True + True + False + 5 + 5 + 5 + 6 + 6 + True + + + 145 + True + False + 5 + 5 + 5 + 5 + 6 + 6 + Синхронизировать через NTP + + + + + False + True + 0 + + True @@ -218,7 +239,6 @@ 145 True False - 5 5 5 5 @@ -289,7 +309,7 @@ False True - 0 + 1 @@ -301,7 +321,6 @@ 145 True False - 5 5 5 5 @@ -319,7 +338,7 @@ - 221 + 191 True True Дата @@ -367,34 +386,13 @@ False True - 1 + 2 True False - - - 145 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Часовой пояс - True - 0 - - - False - True - 0 - - True @@ -407,18 +405,9 @@ - + True False - Регион - 5 - 5 - 5 - 5 - 6 - 6 - Регион - 0 False @@ -427,140 +416,27 @@ - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - - - False - True - 3 - - - - - True - False - Зона - 5 - 5 - 5 - 5 - 6 - 6 - Зона - 0 - - - False - True - 4 - - - - + True - False - 5 + True + True 5 5 5 - 6 - 6 - - - False - True - 5 - - - - - 5 - True - False - - - False - True - 6 - - - - - True - False - - - False - True - 7 - - - - - True - True - 2 - - - - - True - False - - - True - True - False - True - 145 True False - 5 - 5 - 5 - 5 - 6 - 5 + center + center Синхронизировать аппаратное время - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - True - False - - - False + True True - 2 + 3 @@ -571,39 +447,178 @@ - + True - True - True + False 5 + 5 5 6 6 + 0.019999999552965164 + in True False - center - center - + True False - media-playlist-repeat False True - 0 + 1 - + True False - center + Регион + 5 + 5 + 5 + 5 + 8 + Регион + 0 + + + False + True + 2 + + + + + True + False + 5 + 5 + 5 + 5 + 8 + + + False + True + 3 + + + + + True + False + Зона + 5 + 5 + 5 + 5 + 8 + Зона + 0 + + + False + True + 4 + + + + + True + False + 5 + 5 + 5 + 5 + 8 + + + False + True + 5 + + + + + 5 + True + False + + + False + True + 6 + + + + + True + False + + + False + True + 7 + + + + + + + True + False + Часовой пояс + + + + + False + True + 5 + + + + + True + True + True + 5 + 5 + 5 + 6 + + + True + False + center + center + + + True + False + 5 + 5 + 5 + 5 + media-playlist-repeat + + + False + True + 0 + + + + + True + False + center center - Синхронизировать + Применить локальную настройку даты и времени False @@ -617,7 +632,7 @@ False True - 4 + 6 @@ -657,7 +672,7 @@ 5 5 5 - 0.019999999552965164 + 0.05999999865889549 in @@ -671,7 +686,7 @@ True False - + True True False @@ -680,10 +695,9 @@ 5 5 6 - 6 True - + True False Синхронизировать через NTP @@ -701,7 +715,6 @@ True False 6 - 6 False @@ -720,7 +733,6 @@ 5 5 6 - 6 True @@ -736,193 +748,128 @@ - + True False + 5 + 5 + 5 + 6 + 0.019999999552965164 + in - - 145 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Часовой пояс - True - 28 - 0 - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Регион - 0 - - - False - True - 2 - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - - - False - True - 3 - - - - - True - False - 5 - 5 - 5 - 5 - Зона - 0 - - - False - True - 4 - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - - - False - True - 5 - - - - - 5 + True False - 15 - 5 - 15 - 5 - - - False - True - 6 - - - - - True - True - 1 - - - - - True - False - - - True - True - False - True - - 145 + + True + False + + + False + True + 1 + + + + True False 5 5 5 5 - 6 - 5 - Синхронизировать аппаратное время + 8 + Регион + 0 + + False + True + 2 + + + + + True + False + 5 + 5 + 5 + 5 + 8 + + + False + True + 3 + + + + + True + False + 5 + 5 + 5 + 5 + 8 + Зона + 0 + + + False + True + 4 + + + + + True + False + 5 + 5 + 5 + 5 + 8 + + + False + True + 5 + + + + + 5 + True + False + 15 + 5 + 15 + 5 + + + False + True + 6 + - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - + + True False + Часовой пояс - - False - True - 2 - False True - 2 + 1 @@ -951,4 +898,27 @@ + + 240 + 185 + False + btnChooseDate + bottom + none + + + True + True + 10 + 10 + 10 + 10 + 10 + 10 + 2023 + 1 + 10 + + + diff --git a/ubl-settings-datetime_ru.po b/ubl-settings-datetime_ru.po index a9bbf62..b4bd9a1 100644 --- a/ubl-settings-datetime_ru.po +++ b/ubl-settings-datetime_ru.po @@ -9,8 +9,8 @@ msgstr "" msgid "Manually" msgstr "Вручную" -msgid "Enter DHCP !" -msgstr "Введите DHCP !" +msgid "Enter DHCP!" +msgstr "Введите DHCP!" msgid "OK" msgstr "OK" @@ -54,8 +54,8 @@ msgstr "Регион" msgid "Zone" msgstr "Зона" -msgid "Sync by" -msgstr "Синхронизировать" +msgid "Apply local date and time settings" +msgstr "Применить локальную настройку даты и времени" msgid "Automatic time synchronization" msgstr "Автоматическая синхронизация времени"