|
|
|
@ -23,19 +23,19 @@
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
#include "ubl_settings_datetime.h"
|
|
|
|
#include "ubl-settings-datetime.h"
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
string path_app= "/home/superadmin/Документы/Проект/ubconfig_new/ubl-settings-datetime/source/";
|
|
|
|
|
|
|
|
string path_glade= "/home/superadmin/Документы/Проект/ubconfig_new/ubl-settings-datetime/";
|
|
|
|
string path_app= "/usr/bin/";
|
|
|
|
|
|
|
|
string path_glade= "/usr/share/ubl-settings-datetime/ui/";
|
|
|
|
string app_name = "ubl-settings-datetime";
|
|
|
|
string app_name = "ubl-settings-datetime";
|
|
|
|
string path_locale = "/usr/share/locale/";
|
|
|
|
string path_locale = "/usr/share/locale/";
|
|
|
|
string path_css = "/home/superadmin/Документы/Проект/ubconfig_new/ubl-settings-datetime/style.css";
|
|
|
|
string path_css = "/usr/share/ubl-settings-datetime/css/style.css";
|
|
|
|
bool flag_datetime = false;
|
|
|
|
bool flag_datetime = false;
|
|
|
|
bool flag_timezone = false;
|
|
|
|
bool flag_timezone = false;
|
|
|
|
bool flag_ntp = false;
|
|
|
|
bool flag_ntp = false;
|
|
|
|
bool flag_update = false;
|
|
|
|
bool flag_update = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help)
|
|
|
|
CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help)
|
|
|
|
: Glib::OptionGroup{p_name, p_description, p_help}
|
|
|
|
: Glib::OptionGroup{p_name, p_description, p_help}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -44,21 +44,21 @@ CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_descr
|
|
|
|
socketIDArg.set_short_name('s');
|
|
|
|
socketIDArg.set_short_name('s');
|
|
|
|
socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
|
|
|
|
socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
|
|
|
|
socketIDArg.set_description("Settings manager socket");
|
|
|
|
socketIDArg.set_description("Settings manager socket");
|
|
|
|
|
|
|
|
|
|
|
|
// Register it in the parser. It value will be recorded in m_socketID for later usage.
|
|
|
|
|
|
|
|
add_entry(socketIDArg, m_socketID);
|
|
|
|
add_entry(socketIDArg, m_socketID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
::Window CmdArgParser::GetSocketID() const
|
|
|
|
::Window CmdArgParser::GetSocketID() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return m_socketID;
|
|
|
|
return m_socketID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder)
|
|
|
|
MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder)
|
|
|
|
: Gtk::ApplicationWindow(obj)
|
|
|
|
: Gtk::ApplicationWindow(obj)
|
|
|
|
, builder{builder}
|
|
|
|
, builder{builder}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this->settings();
|
|
|
|
this->settings();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
|
|
|
|
MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
|
|
|
|
this->builder = builder;
|
|
|
|
this->builder = builder;
|
|
|
|
this->settings();
|
|
|
|
this->settings();
|
|
|
|
@ -72,7 +72,6 @@ void MainWindow::settings(){
|
|
|
|
_numTimeHrs->set_increments(1.0,1.0);
|
|
|
|
_numTimeHrs->set_increments(1.0,1.0);
|
|
|
|
_numTimeMin->set_increments(1.0,1.0);
|
|
|
|
_numTimeMin->set_increments(1.0,1.0);
|
|
|
|
this->lacalization();
|
|
|
|
this->lacalization();
|
|
|
|
//_txtDate->set_sensitive(false);
|
|
|
|
|
|
|
|
this->get_config();
|
|
|
|
this->get_config();
|
|
|
|
this->flag_block_gui();
|
|
|
|
this->flag_block_gui();
|
|
|
|
this->event();
|
|
|
|
this->event();
|
|
|
|
@ -81,7 +80,6 @@ void MainWindow::settings(){
|
|
|
|
void MainWindow::lacalization(){
|
|
|
|
void MainWindow::lacalization(){
|
|
|
|
_cbDhcp->append(gettext("DHCP"));
|
|
|
|
_cbDhcp->append(gettext("DHCP"));
|
|
|
|
_cbDhcp->append(gettext("Manually"));
|
|
|
|
_cbDhcp->append(gettext("Manually"));
|
|
|
|
|
|
|
|
|
|
|
|
_lblDateTimeSetting->set_text(gettext("Setting the date and time"));
|
|
|
|
_lblDateTimeSetting->set_text(gettext("Setting the date and time"));
|
|
|
|
_lblNtpServer1->set_text(gettext("Setting the date and time"));
|
|
|
|
_lblNtpServer1->set_text(gettext("Setting the date and time"));
|
|
|
|
_lblTime->set_text(gettext("Time"));
|
|
|
|
_lblTime->set_text(gettext("Time"));
|
|
|
|
@ -98,9 +96,8 @@ void MainWindow::lacalization(){
|
|
|
|
this->set_title(gettext("ubl-settings-datetime"));
|
|
|
|
this->set_title(gettext("ubl-settings-datetime"));
|
|
|
|
_txtDate->set_tooltip_text("Date of\nFormat: DD.MM.YYYY");
|
|
|
|
_txtDate->set_tooltip_text("Date of\nFormat: DD.MM.YYYY");
|
|
|
|
_mess_dchp->set_title("Warning!");
|
|
|
|
_mess_dchp->set_title("Warning!");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::flag_block_gui(){
|
|
|
|
void MainWindow::flag_block_gui(){
|
|
|
|
if (flag_datetime==true){
|
|
|
|
if (flag_datetime==true){
|
|
|
|
_numTimeHrs->set_sensitive(false);
|
|
|
|
_numTimeHrs->set_sensitive(false);
|
|
|
|
@ -125,6 +122,7 @@ void MainWindow::flag_block_gui(){
|
|
|
|
_btnUpdateDateTime->set_sensitive(false);
|
|
|
|
_btnUpdateDateTime->set_sensitive(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::add_CSS(){
|
|
|
|
void MainWindow::add_CSS(){
|
|
|
|
Glib::RefPtr<Gtk::CssProvider> cssProvider = Gtk::CssProvider::create();
|
|
|
|
Glib::RefPtr<Gtk::CssProvider> cssProvider = Gtk::CssProvider::create();
|
|
|
|
cssProvider->load_from_path(path_css);
|
|
|
|
cssProvider->load_from_path(path_css);
|
|
|
|
@ -134,9 +132,8 @@ void MainWindow::add_CSS(){
|
|
|
|
Glib::RefPtr<Gtk::StyleContext> context = _boxColor->get_style_context();
|
|
|
|
Glib::RefPtr<Gtk::StyleContext> context = _boxColor->get_style_context();
|
|
|
|
context->add_class("cssboxColor1");
|
|
|
|
context->add_class("cssboxColor1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void MainWindow::get_builder(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::get_builder(){
|
|
|
|
builder->get_widget("boxColor", _boxColor);
|
|
|
|
builder->get_widget("boxColor", _boxColor);
|
|
|
|
builder->get_widget("btnUpdateDateTime", _btnUpdateDateTime);
|
|
|
|
builder->get_widget("btnUpdateDateTime", _btnUpdateDateTime);
|
|
|
|
builder->get_widget("btnChooseDate", _btnChooseDate);
|
|
|
|
builder->get_widget("btnChooseDate", _btnChooseDate);
|
|
|
|
@ -169,7 +166,8 @@ void MainWindow::get_builder(){
|
|
|
|
builder->get_widget("lblSynchronizeBtn",_lblSynchronizeBtn);
|
|
|
|
builder->get_widget("lblSynchronizeBtn",_lblSynchronizeBtn);
|
|
|
|
builder->get_widget("lblDateTimeSettingGlob",_lblDateTimeSettingGlob);
|
|
|
|
builder->get_widget("lblDateTimeSettingGlob",_lblDateTimeSettingGlob);
|
|
|
|
this->add_CSS();
|
|
|
|
this->add_CSS();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::event(){
|
|
|
|
void MainWindow::event(){
|
|
|
|
_btnMessClose->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_mess_close));
|
|
|
|
_btnMessClose->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_mess_close));
|
|
|
|
_cldrDate->signal_day_selected().connect(sigc::mem_fun(*this, &MainWindow::get_calendar));
|
|
|
|
_cldrDate->signal_day_selected().connect(sigc::mem_fun(*this, &MainWindow::get_calendar));
|
|
|
|
@ -189,7 +187,6 @@ void MainWindow::gui_mess_close(){
|
|
|
|
_mess_dchp->hide();
|
|
|
|
_mess_dchp->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool MainWindow::focus_ntp(GdkEventFocus* event){
|
|
|
|
bool MainWindow::focus_ntp(GdkEventFocus* event){
|
|
|
|
if (event!=NULL){}
|
|
|
|
if (event!=NULL){}
|
|
|
|
if (_txtNtpServer->get_text()=="" || _txtNtpServer->get_text()==" "){
|
|
|
|
if (_txtNtpServer->get_text()=="" || _txtNtpServer->get_text()==" "){
|
|
|
|
@ -205,9 +202,6 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::event_entry_cbDhcp(){
|
|
|
|
void MainWindow::event_entry_cbDhcp(){
|
|
|
|
Glib::ustring str_dhcp = _cbDhcp->get_active_text();
|
|
|
|
Glib::ustring str_dhcp = _cbDhcp->get_active_text();
|
|
|
|
if (str_dhcp.length()!=0){
|
|
|
|
if (str_dhcp.length()!=0){
|
|
|
|
@ -234,7 +228,6 @@ void MainWindow::event_entry_cbDhcp(){
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp";
|
|
|
|
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp";
|
|
|
|
system(cmd.c_str());
|
|
|
|
system(cmd.c_str());
|
|
|
|
//_txtNtpServer->set_sensitive(false);
|
|
|
|
|
|
|
|
_cbDhcp->set_active(0);
|
|
|
|
_cbDhcp->set_active(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -243,7 +236,6 @@ void MainWindow::get_calendar(){
|
|
|
|
string str_month = "";
|
|
|
|
string str_month = "";
|
|
|
|
string str_day = "";
|
|
|
|
string str_day = "";
|
|
|
|
_cldrDate->get_date(year, month, day);
|
|
|
|
_cldrDate->get_date(year, month, day);
|
|
|
|
|
|
|
|
|
|
|
|
if (month <10){
|
|
|
|
if (month <10){
|
|
|
|
str_month = "0"+to_string(month+1);
|
|
|
|
str_month = "0"+to_string(month+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -259,8 +251,7 @@ void MainWindow::get_calendar(){
|
|
|
|
string date = str_day + '.' + str_month + '.' + to_string(year);
|
|
|
|
string date = str_day + '.' + str_month + '.' + to_string(year);
|
|
|
|
_txtDate->set_text(date);
|
|
|
|
_txtDate->set_text(date);
|
|
|
|
_popCalendar->hide();
|
|
|
|
_popCalendar->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::calendar_show(){
|
|
|
|
void MainWindow::calendar_show(){
|
|
|
|
if (year==0){
|
|
|
|
if (year==0){
|
|
|
|
@ -289,7 +280,6 @@ void MainWindow::enry_dhcp_mess(){
|
|
|
|
if (str_dhcp=="dhcp"){
|
|
|
|
if (str_dhcp=="dhcp"){
|
|
|
|
_cbDhcp->set_active(0);
|
|
|
|
_cbDhcp->set_active(0);
|
|
|
|
_txtNtpServer->set_sensitive(false);
|
|
|
|
_txtNtpServer->set_sensitive(false);
|
|
|
|
//_cbxSynchronizeNtp->set_sensitive(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
if (str_dhcp==""){
|
|
|
|
if (str_dhcp==""){
|
|
|
|
@ -298,12 +288,9 @@ void MainWindow::enry_dhcp_mess(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
_cbDhcp->set_active(1);
|
|
|
|
_cbDhcp->set_active(1);
|
|
|
|
//_txtNtpServer->set_sensitive(true);
|
|
|
|
|
|
|
|
//_cbxSynchronizeNtp->set_sensitive(false);
|
|
|
|
|
|
|
|
_txtNtpServer->set_text(str_dhcp);
|
|
|
|
_txtNtpServer->set_text(str_dhcp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//_cbxDhcp->set_active(true);
|
|
|
|
|
|
|
|
this->set_ntp_toggle();
|
|
|
|
this->set_ntp_toggle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
@ -312,11 +299,11 @@ void MainWindow::enry_dhcp_mess(){
|
|
|
|
_txtNtpServer->set_sensitive(0);
|
|
|
|
_txtNtpServer->set_sensitive(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::get_config(){
|
|
|
|
void MainWindow::get_config(){
|
|
|
|
this->read_file();
|
|
|
|
this->read_file();
|
|
|
|
this->update_hour_minute();
|
|
|
|
this->update_hour_minute();
|
|
|
|
this->update_calendar();
|
|
|
|
this->update_calendar();
|
|
|
|
//this->event_entry_cbDhcp();
|
|
|
|
|
|
|
|
this->enry_dhcp_mess();
|
|
|
|
this->enry_dhcp_mess();
|
|
|
|
string str_ntp = this->call("systemctl status ntpd.service systemd-timesyncd.service | grep \"Active: active\"");
|
|
|
|
string str_ntp = this->call("systemctl status ntpd.service systemd-timesyncd.service | grep \"Active: active\"");
|
|
|
|
if (str_ntp.length()<50) {
|
|
|
|
if (str_ntp.length()<50) {
|
|
|
|
@ -325,7 +312,6 @@ void MainWindow::get_config(){
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
_cbxSynchronizeNtp->set_active(true);
|
|
|
|
_cbxSynchronizeNtp->set_active(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string read_reg_zon_cfg = this->call("/usr/bin/ubconfig get clock ZONE");
|
|
|
|
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 != "") && (read_reg_zon_cfg !="(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(read_reg_zon_cfg.find("=")+1,read_reg_zon_cfg.length());
|
|
|
|
@ -334,7 +320,6 @@ void MainWindow::get_config(){
|
|
|
|
string str_filling_zon = read_reg_zon_cfg.substr(read_reg_zon_cfg.find("/")+1,read_reg_zon_cfg.length());
|
|
|
|
string str_filling_zon = read_reg_zon_cfg.substr(read_reg_zon_cfg.find("/")+1,read_reg_zon_cfg.length());
|
|
|
|
str_filling_zon = str_filling_zon.substr(0,str_filling_zon.find("\n"));
|
|
|
|
str_filling_zon = str_filling_zon.substr(0,str_filling_zon.find("\n"));
|
|
|
|
string str_zone_check = "";
|
|
|
|
string str_zone_check = "";
|
|
|
|
cout << str_filling_zon << endl;
|
|
|
|
|
|
|
|
this->append_region_zone(str_filling_reg,str_filling_zon);
|
|
|
|
this->append_region_zone(str_filling_reg,str_filling_zon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
@ -365,9 +350,7 @@ void MainWindow::parse_text_date(){
|
|
|
|
string day = data.substr(0,2);
|
|
|
|
string day = data.substr(0,2);
|
|
|
|
string month1 = data.substr(3,2);
|
|
|
|
string month1 = data.substr(3,2);
|
|
|
|
string year = data.substr(6,data.length());
|
|
|
|
string year = data.substr(6,data.length());
|
|
|
|
cout << day << " " << month1 << " " << year << endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::enter_zone_glob(){
|
|
|
|
void MainWindow::enter_zone_glob(){
|
|
|
|
@ -388,7 +371,6 @@ void MainWindow::enter_zone_glob(){
|
|
|
|
void MainWindow::set_ntp_toggle(){
|
|
|
|
void MainWindow::set_ntp_toggle(){
|
|
|
|
bool flag = _cbxSynchronizeNtp->get_active();
|
|
|
|
bool flag = _cbxSynchronizeNtp->get_active();
|
|
|
|
if (flag_datetime==true){
|
|
|
|
if (flag_datetime==true){
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
_numTimeHrs->set_sensitive(!flag);
|
|
|
|
_numTimeHrs->set_sensitive(!flag);
|
|
|
|
@ -396,8 +378,6 @@ void MainWindow::set_ntp_toggle(){
|
|
|
|
_btnChooseDate->set_sensitive(!flag);
|
|
|
|
_btnChooseDate->set_sensitive(!flag);
|
|
|
|
_txtDate->set_sensitive(!flag);
|
|
|
|
_txtDate->set_sensitive(!flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//_txtDate->set_sensitive(!flag);
|
|
|
|
|
|
|
|
//_btnUpdateDateTime->set_sensitive(!flag);
|
|
|
|
|
|
|
|
string cmd = "";
|
|
|
|
string cmd = "";
|
|
|
|
if (flag==false){
|
|
|
|
if (flag==false){
|
|
|
|
cmd="systemctl --now disable systemd-timesyncd.service ntpd.service";
|
|
|
|
cmd="systemctl --now disable systemd-timesyncd.service ntpd.service";
|
|
|
|
@ -442,18 +422,14 @@ string MainWindow::call(string cmd){
|
|
|
|
char path[PATH_MAX];
|
|
|
|
char path[PATH_MAX];
|
|
|
|
fp = popen(cmd.c_str(), "r");
|
|
|
|
fp = popen(cmd.c_str(), "r");
|
|
|
|
if (fp == NULL){
|
|
|
|
if (fp == NULL){
|
|
|
|
cout << 3 << endl;
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while (fgets(path, PATH_MAX, fp) != NULL){
|
|
|
|
while (fgets(path, PATH_MAX, fp) != NULL){
|
|
|
|
printf("%s", path);
|
|
|
|
printf("%s", path);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status = pclose(fp);
|
|
|
|
status = pclose(fp);
|
|
|
|
if (status == -1) {
|
|
|
|
if (status == -1) {
|
|
|
|
cout << 1 << endl;
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
@ -464,14 +440,12 @@ string MainWindow::call(string cmd){
|
|
|
|
void MainWindow::append_zone(){
|
|
|
|
void MainWindow::append_zone(){
|
|
|
|
Glib::ustring text = _cbRegion->get_active_text();
|
|
|
|
Glib::ustring text = _cbRegion->get_active_text();
|
|
|
|
_cbZone->remove_all();
|
|
|
|
_cbZone->remove_all();
|
|
|
|
|
|
|
|
|
|
|
|
if(!(text.empty())){
|
|
|
|
if(!(text.empty())){
|
|
|
|
str_region = text;
|
|
|
|
str_region = text;
|
|
|
|
for (const auto &_str_zone : time_reg_map.at(str_region)){
|
|
|
|
for (const auto &_str_zone : time_reg_map.at(str_region)){
|
|
|
|
_cbZone->append(_str_zone);
|
|
|
|
_cbZone->append(_str_zone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::append_zone_glob(){
|
|
|
|
void MainWindow::append_zone_glob(){
|
|
|
|
@ -482,8 +456,9 @@ void MainWindow::append_zone_glob(){
|
|
|
|
for (const auto &_str_zone : time_reg_map.at(str_region_glob)){
|
|
|
|
for (const auto &_str_zone : time_reg_map.at(str_region_glob)){
|
|
|
|
_cbZoneGlob->append(_str_zone);
|
|
|
|
_cbZoneGlob->append(_str_zone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::update_time_date(){
|
|
|
|
void MainWindow::update_time_date(){
|
|
|
|
this->enter_zone();
|
|
|
|
this->enter_zone();
|
|
|
|
bool flag = _cbxSynchronizeNtp->get_active();
|
|
|
|
bool flag = _cbxSynchronizeNtp->get_active();
|
|
|
|
@ -526,7 +501,6 @@ void MainWindow::update_time_date(){
|
|
|
|
string str_error_clock = this->call(cmd);
|
|
|
|
string str_error_clock = this->call(cmd);
|
|
|
|
size_t index = str_error_clock.find("date: ");
|
|
|
|
size_t index = str_error_clock.find("date: ");
|
|
|
|
if (index==std::string::npos){
|
|
|
|
if (index==std::string::npos){
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
@ -547,6 +521,7 @@ void MainWindow::update_time_date(){
|
|
|
|
cmd = "hwclock --systohc";
|
|
|
|
cmd = "hwclock --systohc";
|
|
|
|
system(cmd.c_str());
|
|
|
|
system(cmd.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::update_hour_minute(){
|
|
|
|
void MainWindow::update_hour_minute(){
|
|
|
|
time_t now = time(0);
|
|
|
|
time_t now = time(0);
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
@ -581,54 +556,40 @@ void MainWindow::update_calendar(){
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::read_file(){
|
|
|
|
void MainWindow::read_file(){
|
|
|
|
std::string line;
|
|
|
|
std::string line;
|
|
|
|
|
|
|
|
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
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()); // окрываем файл для чтения
|
|
|
|
std::ifstream in(entry.path()); // окрываем файл для чтения
|
|
|
|
if (in.is_open())
|
|
|
|
if (in.is_open()){
|
|
|
|
{
|
|
|
|
string key_reg = entry.path().filename().string();
|
|
|
|
string key_reg = entry.path().filename().string();
|
|
|
|
string path_dir = "/usr/share/zoneinfo/"+key_reg;
|
|
|
|
|
|
|
|
if (fs::is_directory(path_dir)){
|
|
|
|
string path_dir = "/usr/share/zoneinfo/"+key_reg;
|
|
|
|
vector<string> zone;
|
|
|
|
if (fs::is_directory(path_dir)){
|
|
|
|
zone.push_back("");
|
|
|
|
vector<string> zone;
|
|
|
|
for (const auto & entry_zone : fs::directory_iterator(path_dir)){
|
|
|
|
zone.push_back("");
|
|
|
|
std::ifstream in1(entry_zone.path()); // окрываем файл для чтения
|
|
|
|
for (const auto & entry_zone : fs::directory_iterator(path_dir)){
|
|
|
|
if (in1.is_open()){
|
|
|
|
std::ifstream in1(entry_zone.path()); // окрываем файл для чтения
|
|
|
|
string key_zone = entry_zone.path().filename().string();
|
|
|
|
if (in1.is_open())
|
|
|
|
if (key_zone.length()!=0 || key_zone!=" "){
|
|
|
|
{
|
|
|
|
zone.push_back(string(gettext(key_zone.c_str())));
|
|
|
|
|
|
|
|
|
|
|
|
string key_zone = entry_zone.path().filename().string();
|
|
|
|
|
|
|
|
if (key_zone.length()!=0 || key_zone!=" "){
|
|
|
|
|
|
|
|
zone.push_back(string(gettext(key_zone.c_str())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
in1.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
key_reg = string(gettext(key_reg.c_str()));
|
|
|
|
|
|
|
|
time_reg_map.insert({key_reg, zone});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (getline(in, line))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
in1.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
key_reg = string(gettext(key_reg.c_str()));
|
|
|
|
|
|
|
|
time_reg_map.insert({key_reg, zone});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
in.close();
|
|
|
|
in.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vector<std::string> MainWindow::split(const std::string &s, char delim){
|
|
|
|
vector<std::string> MainWindow::split(const std::string &s, char delim){
|
|
|
|
std::stringstream ss(s);
|
|
|
|
std::stringstream ss(s);
|
|
|
|
std::string item;
|
|
|
|
std::string item;
|
|
|
|
std::vector<std::string> elems;
|
|
|
|
std::vector<std::string> elems;
|
|
|
|
while (std::getline(ss, item, delim)) {
|
|
|
|
while (std::getline(ss, item, delim)) {
|
|
|
|
elems.push_back(item);
|
|
|
|
elems.push_back(item);
|
|
|
|
// elems.push_back(std::move(item)); // if C++11 (based on comment from @mchiasson)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return elems;
|
|
|
|
return elems;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -636,8 +597,6 @@ vector<std::string> MainWindow::split(const std::string &s, char delim){
|
|
|
|
SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> builder)
|
|
|
|
SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> builder)
|
|
|
|
: Gtk::Plug{p_socketID}
|
|
|
|
: Gtk::Plug{p_socketID}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//MainWindow* wnd = nullptr;
|
|
|
|
|
|
|
|
//builder->get_widget_derived("window", wnd);
|
|
|
|
|
|
|
|
builder->get_widget("plugBox", plugBox);
|
|
|
|
builder->get_widget("plugBox", plugBox);
|
|
|
|
plugBox->get_parent()->remove(*plugBox);
|
|
|
|
plugBox->get_parent()->remove(*plugBox);
|
|
|
|
add(*plugBox);
|
|
|
|
add(*plugBox);
|