diff --git a/Makefile b/Makefile
index e1f25a0..af79dbe 100644
--- a/Makefile
+++ b/Makefile
@@ -12,8 +12,8 @@ CMAKE_COMMAND = cmake
CMAKE_SOURCE_DIR = ./source
CMAKE_BUILD_DIR = ./compile
DEPENDS = cmake
-#PKGNAME = $(MAKEFILE_DIR)
-PKGNAME = ubl-settings-datetime
+PKGNAME = $(MAKEFILE_DIR)
+#PKGNAME = ubl-settings-datetime
default_target: all
all: init build
diff --git a/README.md b/README.md
index b5c8c4d..aa70440 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,41 @@
# ubl-settings-datetime
# Настройки даты и времени
+[RU] Утилита для настройки даты и времени
+
+Utility for setting the date and time
+

+# Build
+In order to build ubl-settings-datetime you will need:
+
+- CMake
+- C compiler
+- GTK+ 3 & dependencies
+
+Once you have all the necessary dependencies, you can use:
+```sh
+$ make
+```
+
+# Installation
+After a successful build, just use:
+```sh
+$ sudo make install clean
+```
+
+# Uninstallation
+After a successful build, just use:
+```sh
+$ sudo make uninstall
+```
+# Usage
+```sh
+$ ubl-settings-datetime --help
+Usage: ubl-settings-datetime [--lock-timezone] [--lock-ntp] [--lock-datetime] [--lock-update]
+Options:
+ --lock-timezone Disable timezone field editing
+ --lock-ntp Disable ntp field editing
+ --lock-datetime Disable datetime field editing
+ --lock-update Disable save changes
+```
diff --git a/bg_top.png b/bg_top.png
index d673a36..8eb67cb 100644
Binary files a/bg_top.png and b/bg_top.png differ
diff --git a/ru.ublinux.pkexec.ubl-settings-datetime.exec.policy b/ru.ublinux.pkexec.ubl-settings-datetime.exec.policy
index bd85ed6..3aa3714 100644
--- a/ru.ublinux.pkexec.ubl-settings-datetime.exec.policy
+++ b/ru.ublinux.pkexec.ubl-settings-datetime.exec.policy
@@ -7,7 +7,7 @@
UBLinux
https://ublinux.ru
-
+
Run "Time date settings" as root
Запуск настройки даты и времени" с правами root
Authentication is required to run the time date settings
@@ -21,4 +21,4 @@
true
-
+
\ No newline at end of file
diff --git a/source/main.cc b/source/main.cc
index 46295a7..2363a00 100644
--- a/source/main.cc
+++ b/source/main.cc
@@ -25,11 +25,7 @@ int main(int argc, char* argv[]) {
for (int i=1; iset_translation_domain(app_name);
for (int i=0; iset_translation_domain(app_name);
Glib::init();
Glib::OptionContext context;
CmdArgParser parser{
diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc
index 884751e..9ea6713 100644
--- a/source/ubl-settings-datetime.cc
+++ b/source/ubl-settings-datetime.cc
@@ -64,15 +64,51 @@ MainWindow::MainWindow(Glib::RefPtr const& builder) {
void MainWindow::settings(){
year=0, month=0, day=0;
this->get_builder();
- this->lacalization();
- _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();
this->event();
- this->parse_text_date();
+ if (this->check_root()==0){
+ this->lacalization();
+ _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();
+ this->parse_text_date();
+ }
+ else{
+ _numTimeHrs->set_sensitive(false);
+ _numTimeMin->set_sensitive(false);
+ _lblTime->set_sensitive(false);
+ _lblData->set_sensitive(false);
+ _txtDate->set_sensitive(false);
+ _btnChooseDate->set_sensitive(false);
+ _btnUpdateDateTime->set_sensitive(false);
+ _btnHardwareTime->set_sensitive(false);
+ _cbRegion->set_sensitive(false);
+ _cbZone->set_sensitive(false);
+ _lblReg->set_sensitive(false);
+ _lblZone->set_sensitive(false);
+ _lblTimeZone->set_sensitive(false);
+ _lblDateTimeSettingGlob->set_sensitive(false);
+ _cbxSynchronizeNtpGlob->set_sensitive(false);
+ _lblSynchronizebChkGLob->set_sensitive(false);
+ _cbDhcp->set_sensitive(false);
+ _txtNtpServer->set_sensitive(false);
+ _lblTimeZoneGlob->set_sensitive(false);
+ _lblRegGlob->set_sensitive(false);
+ _lblZone1Glob->set_sensitive(false);
+ _lblDateTimeSetting->set_sensitive(false);
+
+ }
+}
+
+int MainWindow::check_root(){
+ if (geteuid()!=0){
+ _lblMessageSudo->set_text(gettext("The program must be run with \nsuperuser privileges!"));
+ _mess_sudo->show();
+ return 1;
+ }
+ return 0;
}
void MainWindow::lacalization(){
@@ -90,12 +126,12 @@ void MainWindow::lacalization(){
_lblRegGlob->set_text(gettext("Region"));
_lblZone1Glob->set_text(gettext("Zone"));
_lblTimeZoneGlob->set_text(gettext("Time zone"));
- _lblSynchronizeBtn->set_text(gettext("Apply local date and time settings"));
+ _lblSynchronizeBtn->set_text(gettext("Sync by"));
_lblDateTimeSettingGlob->set_text(gettext("Global customization"));
this->set_title(gettext("ubl-settings-datetime"));
_mess_dchp->set_title(gettext("Warning!"));
_lblTimeBios->set_text(gettext("Synchronize hardware time"));
- _lblSynchronizebChk->set_text(gettext("Synchronize via NTP"));
+ //_lblSynchronizebChk->set_text(gettext("Synchronize via NTP"));
}
void MainWindow::flag_block_gui(){
@@ -104,6 +140,15 @@ void MainWindow::flag_block_gui(){
//_numTimeMin->set_sensitive(false);
//_txtDate->set_sensitive(false);
_btnUpdateDateTime->set_sensitive(false);
+ _numTimeHrs->set_sensitive(false);
+ _numTimeMin->set_sensitive(false);
+ _btnChooseDate->set_sensitive(false);
+ _txtDate->set_sensitive(false);
+ _lblTimeBios->set_sensitive(false);
+ _btnHardwareTime->set_sensitive(false);
+ _lblTime->set_sensitive(false);
+ _lblData->set_sensitive(false);
+ //_cbxSynchronizeNtpGlob->set_sensitive(false);
}
if (flag_timezone==true){
_cbRegion->set_sensitive(false);
@@ -117,11 +162,10 @@ void MainWindow::flag_block_gui(){
_cbxSynchronizeNtpGlob->set_sensitive(false);
_cbDhcp->set_sensitive(false);
_txtNtpServer->set_sensitive(false);
- _cbxSynchronizeNtp->set_sensitive(false);
}
if (flag_update==true){
_lblDateTimeSettingGlob->set_sensitive(false);
- _lblSynchronizebChkGLob->set_sensitive(false);
+ //_lblSynchronizebChkGLob->set_sensitive(false);
_cbxSynchronizeNtpGlob->set_sensitive(false);
_lblTimeZoneGlob->set_sensitive(false);
_lblRegGlob->set_sensitive(false);
@@ -146,6 +190,7 @@ void MainWindow::add_CSS(){
}
void MainWindow::get_builder(){
+ builder->set_translation_domain(path_app);
builder->get_widget("boxColor", _boxColor);
builder->get_widget("btnUpdateDateTime", _btnUpdateDateTime);
builder->get_widget("btnChooseDate", _btnChooseDate);
@@ -174,21 +219,36 @@ void MainWindow::get_builder(){
builder->get_widget("lblRegGlob",_lblRegGlob);
builder->get_widget("lblZone1Glob",_lblZone1Glob);
builder->get_widget("lblTimeZoneGlob",_lblTimeZoneGlob);
- builder->get_widget("lblSynchronizebChk",_lblSynchronizebChk);
+ //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("btnHardwareTime",_btnHardwareTime);
- builder->get_widget("cbxSynchronizeNtp",_cbxSynchronizeNtp);
+ builder->get_widget("mess_sudo",_mess_sudo);
+ builder->get_widget("lblMessageSudo",_lblMessageSudo);
+ builder->get_widget("btnMessCloseSudo",_btnMessCloseSudo);
+
+
+ //builder->get_widget("cbxSynchronizeNtp",_cbxSynchronizeNtp);
this->add_CSS();
}
+void MainWindow::gui_exit(){
+ exit(1);
+}
+
+bool MainWindow::gui_exit_2(GdkEventAny* event){
+ if (event!=NULL){}
+ exit(1);
+ return true;
+}
void MainWindow::event(){
- _cbxSynchronizeNtp->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::set_ntp_toggle));
+ //_cbxSynchronizeNtpGlob->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));
+ _btnMessCloseSudo->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_exit));
//_cldrDate->signal_day_selected().connect(sigc::mem_fun(*this, &MainWindow::get_calendar));
_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));
@@ -200,11 +260,12 @@ void MainWindow::event(){
_cbZoneGlob->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::enter_zone_glob));
_txtNtpServer->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_ntp));
_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));
}
void MainWindow::set_ntp_toggle(){
- bool flag = _cbxSynchronizeNtp->get_active();
- if (flag_ntp==true){
+ bool flag = _cbxSynchronizeNtpGlob->get_active();
+ if (flag_ntp==true || flag_datetime==true){
}
else {
_numTimeHrs->set_sensitive(!flag);
@@ -212,6 +273,9 @@ void MainWindow::set_ntp_toggle(){
_btnChooseDate->set_sensitive(!flag);
_txtDate->set_sensitive(!flag);
_lblTimeBios->set_sensitive(!flag);
+ _btnUpdateDateTime->set_sensitive(!flag);
+ _lblTime->set_sensitive(!flag);
+ _lblData->set_sensitive(!flag);
}
string cmd = "";
if (flag==false){
@@ -264,7 +328,7 @@ void MainWindow::event_entry_cbDhcp(){
if ((str_dhcp!="") && (str_dhcp!="(null)") ){
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" && str_dhcp!="(null)"){
_txtNtpServer->set_text(str_dhcp);
}
_txtNtpServer->set_sensitive(true);
@@ -333,6 +397,10 @@ void MainWindow::enry_dhcp_mess(){
_lblMessage->set_text(gettext("Enter DHCP !"));
_mess_dchp->show();
}
+ else if (str_dhcp=="(null)"){
+ _cbDhcp->set_active(0);
+ _txtNtpServer->set_text("");
+ }
else{
_cbDhcp->set_active(1);
_txtNtpServer->set_text(str_dhcp);
@@ -354,7 +422,7 @@ void MainWindow::get_config(){
this->enry_dhcp_mess();
string str_ntp = this->call("systemctl status ntpd.service systemd-timesyncd.service | grep \"Active: active\"");
if (str_ntp.length()<50) {
- _cbxSynchronizeNtp->set_active(false);
+ _cbxSynchronizeNtpGlob->set_active(false);
_numTimeHrs->set_sensitive(true);
_numTimeMin->set_sensitive(true);
_btnChooseDate->set_sensitive(true);
@@ -362,7 +430,7 @@ void MainWindow::get_config(){
_lblTimeBios->set_sensitive(true);
}
else{
- _cbxSynchronizeNtp->set_active(true);
+ _cbxSynchronizeNtpGlob->set_active(true);
_numTimeHrs->set_sensitive(false);
_numTimeMin->set_sensitive(false);
_btnChooseDate->set_sensitive(false);
@@ -370,7 +438,7 @@ void MainWindow::get_config(){
_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)")){
+ if ((read_reg_zon_cfg != "") && (strstr(read_reg_zon_cfg.c_str() ,"(null)")==NULL)){
read_reg_zon_cfg = read_reg_zon_cfg.substr(read_reg_zon_cfg.find("=")+1,read_reg_zon_cfg.length());
read_reg_zon_cfg = read_reg_zon_cfg.substr(0,read_reg_zon_cfg.find("\n"));
string str_filling_reg = read_reg_zon_cfg.substr(0,read_reg_zon_cfg.find("/"));
@@ -380,7 +448,7 @@ void MainWindow::get_config(){
this->append_region_zone(str_filling_reg,str_filling_zon);
}
else {
- this->append_region_zone("Asia","Omsk");
+ this->append_region_zone("Africa","Abidjan");
}
}
@@ -414,9 +482,8 @@ void MainWindow::enter_zone_glob(){
Glib::ustring zone_text = _cbZoneGlob->get_active_text();
Glib::ustring reg_text = _cbRegionGlob->get_active_text();
if(!(zone_text.empty()) && !(reg_text.empty())){
- str_zoneGlob = zone_text.substr(zone_text.find(") ")+2,zone_text.length());
- str_region_glob = reg_text;
- string cmd = "/usr/bin/ubconfig set clock ZONE=" +str_region_glob +"/" + str_zoneGlob;
+ //str_zoneGlob = zone_text.substr(zone_text.find(") ")+2,zone_text.length());
+ string cmd = "/usr/bin/ubconfig set clock ZONE=" +reg_text +"/" + zone_text;
system(cmd.c_str());
}
else{
@@ -426,12 +493,16 @@ void MainWindow::enter_zone_glob(){
}
void MainWindow::set_ntp_toggle_glob(){
- bool flag = _cbxSynchronizeNtp->get_active();
- if (flag==true){
- system("/usr/bin/ubconfig remove network NTPSERVERS")
+ this->set_ntp_toggle();
+ bool flag = _cbxSynchronizeNtpGlob->get_active();
+ if (flag==false){
+ system("/usr/bin/ubconfig remove network NTPSERVERS");
+ _cbDhcp->set_sensitive(false);
+ _txtNtpServer->set_sensitive(false);
}
else{
-
+ _cbDhcp->set_sensitive(true);
+ _txtNtpServer->set_sensitive(true);
}
}
@@ -448,13 +519,12 @@ void MainWindow::append_region_zone(string region, string zone){
index+=1;
}
index = 0;
- string cheek_zone = "";
+ cout << zone;
for (const auto &_str_zone : time_reg_map.at(region)){
_cbZone->append(_str_zone);
_cbZoneGlob->append(_str_zone);
if (_str_zone!=""){
- cheek_zone = _str_zone.substr(_str_zone.find(") ")+2,_str_zone.length());
- if (cheek_zone == zone){
+ if (_str_zone == zone){
_cbZone->set_active(index);
_cbZoneGlob->set_active(index);
}
@@ -556,8 +626,6 @@ void MainWindow::update_time_date(){
+ ":" + to_string(ltm->tm_sec) +"\"";
system(cmd.c_str());
}
- cmd = "hwclock --systohc";
- system(cmd.c_str());
}
void MainWindow::post_entry_data(){
@@ -673,5 +741,4 @@ void help(){
g_print(" --lock-ntp Disable ntp field editing\n");
g_print(" --lock-datetime Disable datetime field editing\n");
g_print(" --lock-update Disable save changes\n");
- cout << "Параметры командной строки --lock-datetime\n --lock-timezone\n --lock-ntp\n --lock-update\n" << endl;
}
\ No newline at end of file
diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h
index 4dd0cc9..20ff007 100644
--- a/source/ubl-settings-datetime.h
+++ b/source/ubl-settings-datetime.h
@@ -75,11 +75,15 @@ class MainWindow : public Gtk::ApplicationWindow {
void parse_text_date();
void hardware_clock();
void set_ntp_toggle_glob();
+ int check_root();
+ void gui_exit();
+ bool gui_exit_2(GdkEventAny* event);
vector split(const std::string &s, char delim);
private:
Glib::RefPtr builder;
Gtk::Button *_btnUpdateDateTime;
Gtk::Button *_btnChooseDate;
+ Gtk::Button *_btnMessCloseSudo;
Gtk::Button *_btnMessClose;
Gtk::ComboBoxText *_cbDhcp;
Gtk::SpinButton *_numTimeHrs;
@@ -93,9 +97,11 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::ComboBoxText *_cbZoneGlob;
Gtk::Entry *_txtNtpServer;
Gtk::Window *_mess_dchp;
+ Gtk::Window *_mess_sudo;
Gtk::Popover *_popCalendar;
Gtk::Calendar *_cldrDate;
Gtk::Label *_lblMessage;
+ Gtk::Label *_lblMessageSudo;
Gtk::Label *_lblDateTimeSetting;
Gtk::Label *_lblHead;
Gtk::Label *_lblTime;
diff --git a/ubl-settings-datetime.desktop b/ubl-settings-datetime.desktop
index 2225ea4..87d86f7 100644
--- a/ubl-settings-datetime.desktop
+++ b/ubl-settings-datetime.desktop
@@ -7,7 +7,7 @@ GenericName[ru]=Настройка даты и времени
Comment=Date time settings
Comment[ru]=Приложение для настройки даты и времени
Type=Application
-Exec=ubl-settings-datetime
+Exec=pkexec ubl-settings-datetime
Icon=ubl-settings-datetime
Terminal=false
Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;
\ No newline at end of file
diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade
index ff8fc94..a919ff1 100644
--- a/ubl-settings-datetime.glade
+++ b/ubl-settings-datetime.glade
@@ -5,6 +5,7 @@
+
+ False
+ Внимание!
+ center
+ dialog
+
+
+ True
+ False
+ vertical
+
+
+ True
+ False
+
+
+ True
+ False
+ 5
+ 5
+ 5
+ 5
+ 6
+ 6
+ 50
+ gtk-dialog-warning
+
+
+ True
+ True
+ 0
+
+
+
+
+ 160
+ True
+ False
+ start
+ center
+ 5
+ 5
+ 5
+ 5
+ 6
+ 6
+ Enter DHCP !
+
+
+ True
+ True
+ 1
+
+
+
+
+ False
+ True
+ 1
+
+
+
+
+ OK
+ True
+ True
+ True
+ 5
+ 5
+ 5
+ 5
+ 3
+ 3
+
+
+ False
+ True
+ 1
+
+
+
+
+
False
Настройки даты и времени
@@ -129,11 +213,12 @@
255
True
False
- Настройки даты и времени
+ Date and time settings
+
-
+
@@ -204,45 +289,13 @@
5
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
False
- 145
+ 160
True
False
5
@@ -250,7 +303,7 @@
5
6
6
- Время
+ Time
True
0
@@ -324,7 +377,7 @@
False
- 145
+ 160
True
False
5
@@ -332,7 +385,7 @@
5
6
6
- Дата
+ Date
True
0
@@ -347,8 +400,8 @@
191
True
True
- Дата
-Формат: ДД.ММ.ГГГГ
+ Date
+Format: DD.MM.YYYY
5
5
5
@@ -399,6 +452,62 @@
True
False
+
+
+ True
+ True
+ True
+ 5
+ 5
+ 5
+ 5
+ 6
+ 6
+
+
+ True
+ False
+ center
+ center
+
+
+ True
+ False
+ 5
+ 5
+ 5
+ 5
+ media-playlist-repeat
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ center
+ center
+ Sync by
+
+
+ False
+ True
+ 1
+
+
+
+
+
+
+ False
+ True
+ 0
+
+
True
@@ -426,16 +535,19 @@
True
True
True
+ 5
5
5
5
+ 6
+ 6
True
False
center
center
- Синхронизировать аппаратное время
+ Synchronize hardware time
@@ -467,8 +579,6 @@
True
False
- 6
- 5
True
@@ -484,13 +594,12 @@
True
False
- Регион
5
5
5
5
8
- Регион
+ Region
0
@@ -519,13 +628,12 @@
True
False
- Зона
5
5
- 5
+ 10
5
8
- Зона
+ Area
0
@@ -579,7 +687,7 @@
True
False
- Часовой пояс
+ Time Zone
@@ -589,67 +697,13 @@
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
- True
- 1
-
-
-
-
-
-
- False
- True
- 6
-
-
True
False
- Локальная настройка
+ Local Configuration
@@ -708,7 +762,7 @@
True
False
- Синхронизировать через NTP
+ Synchronize via NTP
@@ -790,7 +844,7 @@
5
5
8
- Регион
+ Region
0
@@ -821,10 +875,10 @@
False
5
5
- 5
+ 10
5
8
- Зона
+ Area
0
@@ -887,7 +941,7 @@
True
False
- Глобальная настройка
+ Global customization
diff --git a/ubl-settings-datetime_ru.po b/ubl-settings-datetime_ru.po
index 8f78b7a..7f7f769 100644
--- a/ubl-settings-datetime_ru.po
+++ b/ubl-settings-datetime_ru.po
@@ -6,6 +6,9 @@
msgid ""
msgstr ""
+msgid "The program must be run with \nsuperuser privileges!"
+msgstr "Программа должна быть запущена с правами \nсуперпользователя!"
+
msgid "Manually"
msgstr "Вручную"
@@ -60,8 +63,8 @@ msgstr "Регион"
msgid "Zone"
msgstr "Зона"
-msgid "Apply local date and time settings"
-msgstr "Применить локальную настройку даты и времени"
+msgid "Sync by"
+msgstr "Синхронизировать"
msgid "Automatic time synchronization"
msgstr "Автоматическая синхронизация времени"