@ -2,11 +2,11 @@
# include "ubl-settings-datetime.h"
using namespace std ;
string path_app = " /usr/bin/ " ;
string path_glade = " /usr/share/ubl-settings-datetime/ui/ " ;
string app_name = " ubl-settings-datetime " ;
string path_locale = " /usr/share/locale/ " ;
string path_css = " /usr/share/ubl-settings-datetime/css/style.css " ;
const string path_app = " /usr/bin/ " ;
const string path_glade = " /usr/share/ubl-settings-datetime/ui/ " ;
const string app_name = " ubl-settings-datetime " ;
const string path_locale = " /usr/share/locale/ " ;
const string path_css = " /usr/share/ubl-settings-datetime/css/style.css " ;
bool flag_datetime = false ;
bool flag_timezone = false ;
bool flag_ntp_mode = false ;
@ -55,19 +55,12 @@ MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
}
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 ;
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 ) ;
@ -118,13 +111,6 @@ int MainWindow::check_root(){
}
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"));
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 " ) ) ;
@ -206,6 +191,33 @@ void MainWindow::add_CSS(){
Glib : : RefPtr < Gtk : : StyleContext > context_lbl_head = lblHead - > get_style_context ( ) ;
context - > add_class ( " cssboxColor1 " ) ;
context_lbl_head - > add_class ( " textHead " ) ;
/*
Glib : : RefPtr < Gtk : : StyleContext > boxButton_css = boxButton - > get_style_context ( ) ;
Glib : : RefPtr < Gtk : : StyleContext > boxSave_css = boxSave - > get_style_context ( ) ;
Glib : : RefPtr < Gtk : : StyleContext > btnDownload_css = btnDownload - > get_style_context ( ) ;
Glib : : RefPtr < Gtk : : StyleContext > lblDownload_css = lblDownload - > get_style_context ( ) ;
Glib : : RefPtr < Gtk : : StyleContext > imgDonwload_css = imgDonwload - > get_style_context ( ) ;
Glib : : RefPtr < Gtk : : StyleContext > 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 ) ;
*/
}
@ -269,14 +281,25 @@ 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 ( ) {
exit ( 1 ) ;
}
bool MainWindow : : gui_exit_2 ( GdkEventAny * event ) {
if ( event ! = NULL ) { }
if ( event ! = NULL ) {
}
exit ( 1 ) ;
return true ;
}
@ -329,8 +352,8 @@ 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 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 ) ;
@ -338,8 +361,8 @@ void MainWindow::download_globl_cfg(){
}
void MainWindow : : save_local_cfg ( ) {
string cmd = " /usr/bin/ubconfig --target system set clock ZONE= " ;
this - > enter_zone ( cmd ) ;
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= \" " ;
@ -364,6 +387,7 @@ void MainWindow::save_global_cfg(){
this - > hardware_clock_global ( local , hw ) ;
info_warning_error ( 3 ) ;
}
void MainWindow : : save_global_local_cfg ( ) {
string cmd = " " ;
string cmd_default = " " ;
@ -441,8 +465,8 @@ void MainWindow::hardware_clock_global(string &local, string &etc){
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 < string > obj_result_default = this - > wrapper_call ( cmd_default ) ;
if ( obj_result_default . error = = 0 ) {
@ -463,6 +487,7 @@ void MainWindow::entry_hardware_clock_default(string &cmd_default){
}
}
void MainWindow : : entry_hardware_clock ( string & cmd , string & cmd_default ) {
int error = warning_info ;
struct Result < string > obj_result = this - > wrapper_call ( cmd ) ;
@ -537,8 +562,6 @@ bool MainWindow::focus_ntp(string &cmd_set_ntp){
}
}
return true ;
}
@ -581,7 +604,6 @@ bool MainWindow::check_ntp(string &str_ntp){
flag_error = false ;
char_ntp [ 0 ] = str_ntp [ i ] ;
for ( int index = 0 ; index < 11 ; index + + ) {
if ( index = = 10 ) {
simvol = " . " ;
}
@ -590,7 +612,6 @@ bool MainWindow::check_ntp(string &str_ntp){
}
if ( simvol = = char_ntp ) {
flag_error = false ;
break ;
}
else {
@ -643,6 +664,7 @@ struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd){
}
return obj_result ;
}
void MainWindow : : event_entry_cbDhcp ( ) {
string str_dhcp = cbDhcp - > get_active_text ( ) ;
string cmd = " " ;
@ -678,7 +700,6 @@ void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove
int activ_index = cbDhcp - > get_active_row_number ( ) ;
string str_dhcp = cbDhcp - > get_active_text ( ) ;
if ( str_dhcp . length ( ) = = 0 ) {
}
else if ( activ_index = = 0 ) {
wrapper_system ( cmd_default , " & " ) ;
@ -686,11 +707,9 @@ void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove
}
else if ( activ_index = = 1 ) {
wrapper_system ( cmd_dhcp , " & " ) ;
}
else if ( activ_index = = 2 ) {
this - > focus_ntp ( cmd_set_ntp ) ;
}
else if ( activ_index = = 3 ) {
int start_error = error_info ;
@ -703,7 +722,6 @@ void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove
void MainWindow : : entry_dhcp_mess ( string cmd_get_dhcp , string cmd_default_get_dhcp ) {
string cmd = cmd_get_dhcp ;
struct Result < string > obj_result = this - > wrapper_call ( cmd ) ;
if ( obj_result . error = = 0 ) {
string str_dhcp = obj_result . response ;
@ -805,6 +823,7 @@ void MainWindow::calendar_show(){
}
popCalendar - > show ( ) ;
}
void MainWindow : : fill_in_reg_zone ( string & cmd ) {
int error = warning_info ;
struct Result < string > obj_result_1 = this - > wrapper_call ( cmd ) ;
@ -1129,7 +1148,6 @@ void MainWindow::read_file(){
std : : ifstream in1 ( entry_zone . path ( ) ) ;
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 ) ) {