Добавлен новый функционал по выборе синхронизации аппаратного времени

pull/55/head
Igor Belitskiy 3 years ago
parent bb45aa7aae
commit b7a33c66c6

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 57 KiB

@ -152,6 +152,10 @@ void MainWindow::lacalization(){
mess_sudo->set_title(_("Warning!"));
mess_dchp->set_title(_("Warning!"));
lblTimeBios->set_text(_("Synchronize hardware time"));
lblHW->set_text(_("Synchronize hardware time:"));
cbHw->append(_("Local time"));
cbHw->append(_("UTC time"));
}
void MainWindow::flag_block_gui(){
@ -266,6 +270,8 @@ void MainWindow::get_builder(){
builder->get_widget("btnSaveGlob", btnSaveGlob);
builder->get_widget("headerBar", headerBar);
builder->get_widget("lblHeader", lblHeader);
builder->get_widget("lblHW", lblHW);
builder->get_widget("cbHw", cbHw);
this->add_CSS();
}
void MainWindow::gui_exit(){
@ -299,11 +305,13 @@ void MainWindow::event(){
btnSaveLocalGlob->signal_clicked().connect([&](){save_global_local_cfg();});
btnSaveLocal->signal_clicked().connect([&](){save_local_cfg();});
btnSaveGlob->signal_clicked().connect([&](){save_global_cfg();});
}
void MainWindow::synopsis_show(){
int start_error = error_info;
//wrapper_system("xdg-open https://wiki.ublinux.ru/ru/home");
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;
}
@ -317,6 +325,8 @@ void MainWindow::download_local_cfg(){
string cmd_get_dhcp = "/usr/bin/ubconfig --source system 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 hw = "/usr/bin/ubconfig --default --source system get clock HWCLOCK_SYNC";
this->entry_hardware_clock(hw);
info_warning_error(0);
}
@ -326,17 +336,22 @@ void MainWindow::download_globl_cfg(){
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";
this->entry_hardware_clock(hw);
info_warning_error(1);
}
void MainWindow::save_local_cfg(){
string cmd = "ubconfig --target system set clock ZONE=";
string cmd = "/usr/bin/ubconfig --target system set clock ZONE=";
this->enter_zone(cmd);
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=\"";
string remove = "/usr/bin/ubconfig --target system remove network NTPSERVERS";
this->save_Dhcp(cmd_default, cmd_dhcp, remove, cmd_set_ntp);
string local = "/usr/bin/ubconfig --target system set clock HWCLOCK_SYNC=localtime";
string hw = "/usr/bin/ubconfig --target system set clock HWCLOCK_SYNC=utc";
this->hardware_clock_global(local, hw);
info_warning_error(2);
}
@ -348,6 +363,9 @@ void MainWindow::save_global_cfg(){
string cmd_set_ntp = "/usr/bin/ubconfig --target global set network NTPSERVERS=\"";
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";
this->hardware_clock_global(local, hw);
info_warning_error(3);
}
void MainWindow::save_global_local_cfg(){
@ -357,22 +375,11 @@ void MainWindow::save_global_local_cfg(){
string cmd_set_ntp = "";
string remove = "";
if (flag_save_global==false){
cmd = "/usr/bin/ubconfig --target global set clock ZONE=";
this->enter_zone(cmd);
cmd_default = "/usr/bin/ubconfig --target global set network NTPSERVERS=default";
cmd_dhcp = "/usr/bin/ubconfig --target global set network NTPSERVERS=dhcp";
cmd_set_ntp = "/usr/bin/ubconfig --target global set network NTPSERVERS=\"";
remove = "/usr/bin/ubconfig --target global remove network NTPSERVERS";
this->save_Dhcp(cmd_default, cmd_dhcp, remove, cmd_set_ntp);
this->save_local_cfg();
}
if (flag_save_local==false){
cmd = "ubconfig --target system set clock ZONE=";
this->enter_zone(cmd);
cmd_default = "/usr/bin/ubconfig --target system set network NTPSERVERS=default";
cmd_dhcp = "/usr/bin/ubconfig --target system set network NTPSERVERS=dhcp";
cmd_set_ntp = "/usr/bin/ubconfig --target system set network NTPSERVERS=\"";
remove = "/usr/bin/ubconfig --target system remove network NTPSERVERS";
this->save_Dhcp(cmd_default, cmd_dhcp, remove, cmd_set_ntp);
this->save_global_cfg();
}
info_warning_error(4);
}
@ -429,6 +436,31 @@ void MainWindow::wrapper_system(string cmd){
}
void MainWindow::hardware_clock_global(string &local, string &utc){
int index = cbHw->get_active_row_number();
cout << index << endl;
if (index == 0){
cout << local << endl;
wrapper_system(local);
}
else if (index == 1){
cout << utc << endl;
wrapper_system(utc);
}
}
void MainWindow::entry_hardware_clock(string &cmd){
struct Result<string> obj_result = this->wrapper_call(cmd);
if (obj_result.error == 0){
if (obj_result.response == "localtime"){
cbHw->set_active(0);
}
else{
cbHw->set_active(1);
}
}
}
void MainWindow::hardware_clock(){
string cmd = "hwclock --systohc";
wrapper_system(cmd);

@ -106,6 +106,8 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::ModelButton *btnSynopsis;
Gtk::HeaderBar *headerBar;
Gtk::Label *lblHeader;
Gtk::Label *lblHW;
Gtk::ComboBoxText *cbHw;
unsigned int year=0;
unsigned int month=0;
unsigned int day=0;
@ -128,8 +130,10 @@ class MainWindow : public Gtk::ApplicationWindow {
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder);
MainWindow(Glib::RefPtr<Gtk::Builder> const& builder);
virtual ~MainWindow() = default;
void hardware_clock_global(string &local, string &utc);
void info_warning_error(int mess);
void synopsis_show();
void entry_hardware_clock(string &cmd);
void save_global_local_cfg();
void fill_in_reg_zone(string &cmd);
void download_globl_cfg();

@ -65,6 +65,5 @@ inline void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, in
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
}
return;
}
#endif

@ -1,5 +1,3 @@
#define STANDARD_PATH "/usr/share/ubl-util-standard/ubl-util-standard.glade"
#define CSS_PATH "/usr/share/ubl-util-standard/ubl-util-standard.css"
#ifndef __cplusplus
#include <gtk/gtk.h>
#include <gtk/gtkx.h>

@ -996,114 +996,175 @@ Format: DD.MM.YYYY</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lblReg">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">8</property>
<property name="margin-right">5</property>
<property name="margin-start">8</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">13</property>
<property name="label" translatable="yes" context="Region" comments="Region">Region</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="cbRegion">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">10</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lblZone">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">10</property>
<property name="margin-right">5</property>
<property name="margin-start">10</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">13</property>
<property name="label" translatable="yes" context="Zone" comments="Zone">Area</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="cbZone">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">10</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="width-request">5</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel" id="lblHW">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="margin-left">8</property>
<property name="margin-right">31</property>
<property name="margin-start">8</property>
<property name="margin-end">31</property>
<property name="margin-top">6</property>
<property name="margin-bottom">13</property>
<property name="label" translatable="yes">Synchronize hardware time:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="cbHw">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">10</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lblReg">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">8</property>
<property name="margin-right">5</property>
<property name="margin-start">8</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="label" translatable="yes" context="Region" comments="Region">Region</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="cbRegion">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">10</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lblZone">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">10</property>
<property name="margin-right">5</property>
<property name="margin-start">10</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">13</property>
<property name="label" translatable="yes" context="Zone" comments="Zone">Area</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="cbZone">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">10</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="width-request">5</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
<property name="position">1</property>
</packing>
</child>
</object>
@ -1152,6 +1213,7 @@ Format: DD.MM.YYYY</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-bottom">2</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">ubl-settings-datetime</property>
<attributes>
<attribute name="weight" value="bold"/>
@ -1166,8 +1228,6 @@ Format: DD.MM.YYYY</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="pixel-size">32</property>
<property name="icon-name">ubl-settings-datetime</property>
</object>
@ -1197,8 +1257,6 @@ Format: DD.MM.YYYY</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="label" translatable="yes">Download</property>
</object>
<packing>
@ -1267,8 +1325,6 @@ Format: DD.MM.YYYY</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="label" translatable="yes">Save</property>
<style>
<class name="toolbar"/>

@ -16,6 +16,18 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Select the method of hardware time synchronization"
msgstr "Выберите способ синхронизации аппаратного времени"
msgid "Local time"
msgstr "Локальное время"
msgid "UTC time"
msgstr "Время по UTC"
msgid "Synchronize hardware time:"
msgstr "Синхронизировать аппаратное время:"
msgid "An invalid character is entered"
msgstr "Введён недопустимый символ"

Loading…
Cancel
Save