diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index c9f07e6..8d44392 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -9,19 +9,14 @@ link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) find_package(ICU REQUIRED COMPONENTS uc dt in io) -find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) - -option(WEBKIT_FOUND "No" OFF) - -find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) -if(WEBKIT_LIBRARIES_FOUND) - option(WEBKIT_FOUND "Yes" ON) +option(WEBKIT_FOUND "" ON) +if(WEBKIT_FOUND) PKG_CHECK_MODULES(WEBKIT REQUIRED webkit2gtk-4.0 webkit2gtk-web-extension-4.0) include_directories(${WEBKIT_INCLUDE_DIRS}) link_directories(${WEBKIT_LIBRARY_DIRS}) add_definitions(${WEBKIT_CFLAGS_OTHER}) endif() -configure_file(ubl-settings-datetime.h.in ubl-settings-datetime-cm.h) + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ @@ -30,11 +25,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin -fstack-clash-protection -fcf-protection") set(SOURCE_FILES - my_localization.h - ubl-settings-datetime-cm.h ubl-util-standard.h ubl-util-standard.c - my_cmd_and_path.h main.cc ubl-settings-datetime.cc ubl-settings-datetime.h) diff --git a/source/my_cmd_and_path.h b/source/my_cmd_and_path.h deleted file mode 100644 index 2dd328f..0000000 --- a/source/my_cmd_and_path.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef MY_CMD_H -#define MY_CMD_H - -#define link_doc "https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-datetime" -#define cmd_xdg "xdg-open " -#define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \"" -#define get_NTPSERVERS_DEFAULT "ubconfig --source default get [] NTPSERVERS_DEFAULT" -#define get_global_NTPSERVERS "ubconfig --default --source global get network NTPSERVERS" -#define get_system_ZONE "ubconfig --default --source system get clock ZONE" -#define get_system_NTPSERVERS "ubconfig --default --source system get network NTPSERVERS" -#define get_system_HWCLOCK_SYNC "ubconfig --default --source system get clock HWCLOCK_SYNC" -#define get_global_ZONE "ubconfig --default --source global get clock ZONE" -#define get_global_HWCLOCK_SYNC "ubconfig --source global get clock HWCLOCK_SYNC" -#define set_system_ZONE "ubconfig --target system set clock ZONE=" -#define set_global_HWCLOCK_SYNC_utc "ubconfig --target global set clock HWCLOCK_SYNC=utc" -#define set_global_HWCLOCK_SYNC_localtime "ubconfig --target global set clock HWCLOCK_SYNC=localtime" -#define set_system_HWCLOCK_SYNC_localtime "ubconfig --target system set clock HWCLOCK_SYNC=localtime" -#define set_system_HWCLOCK_SYNC_utc "ubconfig --target system set clock HWCLOCK_SYNC=utc" -#define remove_global_NTPSERVERS "ubconfig --target global remove network NTPSERVERS" -#define set_system_NTPSERVERS_default "ubconfig --target system set network NTPSERVERS=default" -#define set_system_NTPSERVERS_dhcp "ubconfig --target system set network NTPSERVERS=dhcp" -#define set_system_NTPSERVERS "ubconfig --target system set network NTPSERVERS=\"" -#define remove_system_NTPSERVERS "ubconfig --target system remove network NTPSERVERS" -#define set_global_ZONE "ubconfig --target global set clock ZONE=" -#define set_global_NTPSERVERS_default "ubconfig --target global set network NTPSERVERS=default" -#define set_global_NTPSERVERS_dhcp "ubconfig --target global set network NTPSERVERS=dhcp" -#define set_global_NTPSERVERS "ubconfig --target global set network NTPSERVERS=\"" -#define set_hwclock "hwclock --systohc" -#define icon_checked "com.ublinux.ubl-settings-datetime.checked" -#define icon_warning "com.ublinux.ubl-settings-datetime.warning" -#define get_global_defalult_HWCLOCK_SYNC "ubconfig --default --source global get clock HWCLOCK_SYNC" -#define path_app "/usr/bin/" -#define path_glade "/usr/share/ubl-settings-datetime/ui/ubl-settings-datetime.glade" -#define app_name "ubl-settings-datetime" -#define path_locale "/usr/share/locale/" -#define path_css "/usr/share/ubl-settings-datetime/css/ubl-settings-datetime.css" -#define path_img_head_background "/usr/share/ubl-settings-datetime/images/logo-background.png" -#endif - - diff --git a/source/my_localization.h b/source/my_localization.h deleted file mode 100644 index 4d2c4bd..0000000 --- a/source/my_localization.h +++ /dev/null @@ -1,74 +0,0 @@ - -#ifndef MY_LOCALIZATION -#define MY_LOCALIZATION -#include -#define copyright _("Copyright © UBSoft LLC, 2022 - ") -#define name_app _("ubl-settings-datetime") -#define website _("https://wiki.ublinux.com") -#define home_page _("Project Home Page") -#define str_about_1 _("About") -#define str_about _("About ubl-settings-datetime") -#define str_help _("Help") -#define str_save _("Save") -#define str_load _("Load") -#define save_all _("Save to global and local configuration") -#define save_local _("Save local configuration") -#define save_global _("Save global configuration") -#define load_global _("Load global configuration") -#define load_local _("Load local configuration") -#define read_online _("Read online") -#define cancel _("Cancel") -#define always_redirect _("Always redirect") -#define nothing_save _("Nothing to save!") -#define read_documentation_web _("Would you like to read documentation in the Web?") -#define redirected_documentation _("You will be redirected to documentation site, where user help pages are ""translated and supported by community.") -#define str_help_h _("GTK settings datetime for UBLinux\n\n""Usage: ubl-settings-datetime [OPTIONS...]\n""Options:\n"" -h, --help Show this help\n"" -V, --version Show package version\n"" --lock-datetime Lock date and time changes\n"" --lock-timezone Lock time zone changes\n"" --lock-ntp-mode Lock NTP mode selection\n"" --lock-ntp-edit Lock editing NTP servers\n"" --lock-sync-hwclock Lock sync hwclock mode selection\n"" --lock-save Lock saving local and global configuration\n"" --lock-save-local Lock save global configuration\n"" --lock-save-global Lock load global configuration\n"" --lock-load-global Lock load global configuration\n") -#define str_version _("ubl-settings-datetime version: ") -#define local_read_error _("Local configuration reading error") -#define global_read_error _("Global configuration read error") -#define local_write_error _("Local configuration write error") -#define global_write_error _("Global configuration write error") -#define error_save_all _("Error saved local and global configuration") -#define local_load_ok _("Local configuration downloaded successfully") -#define global_load_ok _("Global configuration downloaded successfully") -#define local_ok_written _("Local configuration successfully written") -#define global_ok_written _("Global configuration successfully written") -#define successfully_save_all _("Successfully saved local and global configuration") - -#define incorrect_date_f _("Incorrect date format") -#define date_time_ok_synchronized _("Date and time are successfully synchronized") -#define entry_list_ntp _("Enter a list of NTP servers") -#define error_ntp_name _("Error in the NTP server name") -#define invalid_character_entry _("An invalid character is entered") -#define ntp_server_ok _("NTP server name is correct") -#define hardware_clock_ok _("Hardware clock successfully synchronized") -#define hardware_clock_error _("Hardware clock synchronization error") - -#define no_recognized _("Argument not recognized\n") -#define program_as_root _("The program must be run as root") -#define str_date_flag _(": \"Date\"") -#define str_time_zone_flag _(": \"Time Zone\"") -#define str_hardware_time_flag _(": \"Hardware time\"") -#define str_NTP_flag _(": \"NTP\"") -#define str_default _("Default") -#define str_DHCP _("DHCP") -#define str_manual _("Manual") -#define str_disabled _("Disabled") -#define str_time _("Time:") -#define str_date_time _("Date and Time") -#define utc_time _("UTC time") -#define str_local_time _("Local time") -#define str_attention _("Attention") -#define str_sync_by _("Sync by") -#define str_zone _("Zone:") -#define str_region _("Region:") -#define str_time_zone _("Time zone") -#define str_date _("Date:") -#define synchronize_hw _("Synchronize hardware time") -#define setting_date_time _("Setting the date and time") -#define current_date_time _("Current date and time") -#define data_format_d_m_y _("Date of\nFormat: DD.MM.YYYY") -#define synchronize_ntp _("Synchronize via NTP") -#define enter_name_ntp_tooltip _("Enter the name of the ntp-server or its ip-address.\nWhen entering multiple addresses, separate them with commas.") - -#endif \ No newline at end of file diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 19e62f3..be97591 100755 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -116,7 +116,7 @@ void MainWindow::settings() { btnSave->set_sensitive(false); this->event(); imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU); - info_status_app("boxInfoMessError"); + info_status_app(info_box_error_css); lblWarning->set_text(program_as_root); } } @@ -255,8 +255,8 @@ void MainWindow::add_CSS() { void MainWindow::info_status_app(string stule) { Glib::RefPtr boxInfo = boxInfoError->get_style_context(); - boxInfo->remove_class("boxInfoMessOK"); - boxInfo->remove_class("boxInfoMessError"); + boxInfo->remove_class(info_box_ok_css); + boxInfo->remove_class(info_box_error_css); boxInfo->add_class(stule); } @@ -481,7 +481,7 @@ void MainWindow::load_globl_cfg() { void MainWindow::save_local_cfg() { if ((this->check_config("region", 0) && this->check_config("zone", 0) && this->check_config("dhcp", 0) && this->check_config("hw", 0))) { - info_status_app("boxInfoMessOK"); + info_status_app(info_box_ok_css); lblWarning->set_text(nothing_save); } else { @@ -510,7 +510,7 @@ void MainWindow::save_local_cfg() { void MainWindow::save_global_cfg() { if ((this->check_config("region", 1) && this->check_config("zone", 1) && this->check_config("dhcp", 1) && this->check_config("hw", 1))) { - info_status_app("boxInfoMessOK"); + info_status_app(info_box_ok_css); lblWarning->set_text(nothing_save); } else { @@ -541,7 +541,7 @@ void MainWindow::save_global_local_cfg() { this->check_config("dhcp", 0) && this->check_config("hw", 0)) && (this->check_config("region", 1) && this->check_config("zone", 1) && this->check_config("dhcp", 1) && this->check_config("hw", 1))) { - info_status_app("boxInfoMessOK"); + info_status_app(info_box_ok_css); lblWarning->set_text(nothing_save); } else { @@ -732,7 +732,7 @@ string MainWindow::get_ubconfig_value(string cmd){ void MainWindow::info_warning_error(int mess) { if (error_info > 0 || warning_info > 0) { - info_status_app("boxInfoMessError"); + info_status_app(info_box_error_css); imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU); error_info = 0; warning_info = 0; @@ -760,7 +760,7 @@ void MainWindow::info_warning_error(int mess) { cmd_error = ""; } else { - info_status_app("boxInfoMessOK"); + info_status_app(info_box_ok_css); imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU);//Gtk::IconSize::INHERIT); if (mess == 0) { lblWarning->set_text(local_load_ok); @@ -862,11 +862,11 @@ void MainWindow::hardware_clock() { wrapper_system(cmd); if (error_hw != error_info){ lblWarning->set_text(hardware_clock_error); - info_status_app("boxInfoMessError"); + info_status_app(info_box_error_css); } else { lblWarning->set_text(hardware_clock_ok); - info_status_app("boxInfoMessOK"); + info_status_app(info_box_ok_css); } } @@ -877,7 +877,7 @@ void MainWindow::gui_mess_close() { bool MainWindow::focus_ntp_text() { if (txtNtpServer->get_text() == "" || txtNtpServer->get_text() == " ") { lblWarning->set_text(entry_list_ntp); - info_status_app("boxInfoMessError"); + info_status_app(info_box_error_css); btnSave->set_sensitive(false); return false; } @@ -901,19 +901,19 @@ bool MainWindow::focus_ntp_text() { if ((flag_error == false) && (flag_error_check_ntp == false)) { this->write_config(str_ntp, "dhcp"); lblWarning->set_text(ntp_server_ok); - info_status_app("boxInfoMessOK"); + info_status_app(info_box_ok_css); btnSave->set_sensitive(true); return true; } else { if (flag_error == true) { lblWarning->set_text(invalid_character_entry); - info_status_app("boxInfoMessError"); + info_status_app(info_box_error_css); btnSave->set_sensitive(false); } else if (flag_error_check_ntp == true) { lblWarning->set_text(error_ntp_name); - info_status_app("boxInfoMessError"); + info_status_app(info_box_error_css); btnSave->set_sensitive(false); } return false; @@ -1149,7 +1149,7 @@ void MainWindow::entry_dhcp_mess(string cmd_get_dhcp, string cmd_default_get_dhc if (str_dhcp == "") { this->write_config("", "dhcp"); lblWarning->set_text(entry_list_ntp); - info_status_app("boxInfoMessError"); + info_status_app(info_box_error_css); btnSave->set_sensitive(false); } else if (str_dhcp == "(null)") { @@ -1469,7 +1469,7 @@ void MainWindow::update_time_date() { month = 0; day = 0; lblWarning->set_text(date_time_ok_synchronized); - info_status_app("boxInfoMessOK"); + info_status_app(info_box_ok_css); flag_error_time = false; } else { @@ -1487,7 +1487,7 @@ void MainWindow::update_time_date() { } if (flag_error_time == false) { lblWarning->set_text(date_time_ok_synchronized); - info_status_app("boxInfoMessOK"); + info_status_app(info_box_ok_css); hour = numTimeHrs->get_value_as_int(); minute = numTimeMin->get_value_as_int(); time_t now = time(0); @@ -1513,18 +1513,18 @@ bool MainWindow::post_entry_data() { size_t index = str_error_clock.find("date:"); if (index != std::string::npos) { lblWarning->set_text(incorrect_date_f); - info_status_app("boxInfoMessError"); + info_status_app(info_box_error_css); return true; } else { lblWarning->set_text(date_time_ok_synchronized); - info_status_app("boxInfoMessOK"); + info_status_app(info_box_ok_css); return false; } } else { lblWarning->set_text(incorrect_date_f); - info_status_app("boxInfoMessError"); + info_status_app(info_box_error_css); return true; } } diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index fe03a64..4dccb5c 100644 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -17,15 +17,122 @@ #include #include #include +#include #include "ubl-util-standard.c" -#include "my_cmd_and_path.h" -#include "ubl-settings-datetime-cm.h" -#include "my_localization.h" #ifdef WEBKIT_FOUND -#include + #include #endif + +#define link_doc "https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-datetime" +#define cmd_xdg "xdg-open " +#define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \"" +#define get_NTPSERVERS_DEFAULT "ubconfig --source default get [] NTPSERVERS_DEFAULT" +#define get_global_NTPSERVERS "ubconfig --default --source global get network NTPSERVERS" +#define get_system_ZONE "ubconfig --default --source system get clock ZONE" +#define get_system_NTPSERVERS "ubconfig --default --source system get network NTPSERVERS" +#define get_system_HWCLOCK_SYNC "ubconfig --default --source system get clock HWCLOCK_SYNC" +#define get_global_ZONE "ubconfig --default --source global get clock ZONE" +#define get_global_HWCLOCK_SYNC "ubconfig --source global get clock HWCLOCK_SYNC" +#define set_system_ZONE "ubconfig --target system set clock ZONE=" +#define set_global_HWCLOCK_SYNC_utc "ubconfig --target global set clock HWCLOCK_SYNC=utc" +#define set_global_HWCLOCK_SYNC_localtime "ubconfig --target global set clock HWCLOCK_SYNC=localtime" +#define set_system_HWCLOCK_SYNC_localtime "ubconfig --target system set clock HWCLOCK_SYNC=localtime" +#define set_system_HWCLOCK_SYNC_utc "ubconfig --target system set clock HWCLOCK_SYNC=utc" +#define remove_global_NTPSERVERS "ubconfig --target global remove network NTPSERVERS" +#define set_system_NTPSERVERS_default "ubconfig --target system set network NTPSERVERS=default" +#define set_system_NTPSERVERS_dhcp "ubconfig --target system set network NTPSERVERS=dhcp" +#define set_system_NTPSERVERS "ubconfig --target system set network NTPSERVERS=\"" +#define remove_system_NTPSERVERS "ubconfig --target system remove network NTPSERVERS" +#define set_global_ZONE "ubconfig --target global set clock ZONE=" +#define set_global_NTPSERVERS_default "ubconfig --target global set network NTPSERVERS=default" +#define set_global_NTPSERVERS_dhcp "ubconfig --target global set network NTPSERVERS=dhcp" +#define set_global_NTPSERVERS "ubconfig --target global set network NTPSERVERS=\"" +#define set_hwclock "hwclock --systohc" +#define icon_checked "com.ublinux.ubl-settings-datetime.checked" +#define icon_warning "com.ublinux.ubl-settings-datetime.warning" +#define get_global_defalult_HWCLOCK_SYNC "ubconfig --default --source global get clock HWCLOCK_SYNC" +#define path_app "/usr/bin/" +#define path_glade "/usr/share/ubl-settings-datetime/ui/ubl-settings-datetime.glade" +#define app_name "ubl-settings-datetime" +#define path_locale "/usr/share/locale/" +#define path_css "/usr/share/ubl-settings-datetime/css/ubl-settings-datetime.css" +#define path_img_head_background "/usr/share/ubl-settings-datetime/images/logo-background.png" + + +#include +#define copyright _("Copyright © UBSoft LLC, 2022 - ") +#define name_app _("ubl-settings-datetime") +#define website _("https://wiki.ublinux.com") +#define home_page _("Project Home Page") +#define str_about_1 _("About") +#define str_about _("About ubl-settings-datetime") +#define str_help _("Help") +#define str_save _("Save") +#define str_load _("Load") +#define save_all _("Save to global and local configuration") +#define save_local _("Save local configuration") +#define save_global _("Save global configuration") +#define load_global _("Load global configuration") +#define load_local _("Load local configuration") +#define read_online _("Read online") +#define cancel _("Cancel") +#define always_redirect _("Always redirect") +#define nothing_save _("Nothing to save!") +#define read_documentation_web _("Would you like to read documentation in the Web?") +#define redirected_documentation _("You will be redirected to documentation site, where user help pages are ""translated and supported by community.") +#define str_help_h _("GTK settings datetime for UBLinux\n\n""Usage: ubl-settings-datetime [OPTIONS...]\n""Options:\n"" -h, --help Show this help\n"" -V, --version Show package version\n"" --lock-datetime Lock date and time changes\n"" --lock-timezone Lock time zone changes\n"" --lock-ntp-mode Lock NTP mode selection\n"" --lock-ntp-edit Lock editing NTP servers\n"" --lock-sync-hwclock Lock sync hwclock mode selection\n"" --lock-save Lock saving local and global configuration\n"" --lock-save-local Lock save global configuration\n"" --lock-save-global Lock load global configuration\n"" --lock-load-global Lock load global configuration\n") +#define str_version _("ubl-settings-datetime version: ") +#define local_read_error _("Local configuration reading error") +#define global_read_error _("Global configuration read error") +#define local_write_error _("Local configuration write error") +#define global_write_error _("Global configuration write error") +#define error_save_all _("Error saved local and global configuration") +#define local_load_ok _("Local configuration downloaded successfully") +#define global_load_ok _("Global configuration downloaded successfully") +#define local_ok_written _("Local configuration successfully written") +#define global_ok_written _("Global configuration successfully written") +#define successfully_save_all _("Successfully saved local and global configuration") + +#define incorrect_date_f _("Incorrect date format") +#define date_time_ok_synchronized _("Date and time are successfully synchronized") +#define entry_list_ntp _("Enter a list of NTP servers") +#define error_ntp_name _("Error in the NTP server name") +#define invalid_character_entry _("An invalid character is entered") +#define ntp_server_ok _("NTP server name is correct") +#define hardware_clock_ok _("Hardware clock successfully synchronized") +#define hardware_clock_error _("Hardware clock synchronization error") + +#define no_recognized _("Argument not recognized\n") +#define program_as_root _("The program must be run as root") +#define str_date_flag _(": \"Date\"") +#define str_time_zone_flag _(": \"Time Zone\"") +#define str_hardware_time_flag _(": \"Hardware time\"") +#define str_NTP_flag _(": \"NTP\"") +#define str_default _("Default") +#define str_DHCP _("DHCP") +#define str_manual _("Manual") +#define str_disabled _("Disabled") +#define str_time _("Time:") +#define str_date_time _("Date and Time") +#define utc_time _("UTC time") +#define str_local_time _("Local time") +#define str_attention _("Attention") +#define str_sync_by _("Sync by") +#define str_zone _("Zone:") +#define str_region _("Region:") +#define str_time_zone _("Time zone") +#define str_date _("Date:") +#define synchronize_hw _("Synchronize hardware time") +#define setting_date_time _("Setting the date and time") +#define current_date_time _("Current date and time") +#define data_format_d_m_y _("Date of\nFormat: DD.MM.YYYY") +#define synchronize_ntp _("Synchronize via NTP") +#define enter_name_ntp_tooltip _("Enter the name of the ntp-server or its ip-address.\nWhen entering multiple addresses, separate them with commas.") +#define info_box_ok_css "boxInfoMessOK" +#define info_box_error_css "boxInfoMessError" + using namespace std; extern bool flag_datetime; extern bool flag_timezone; diff --git a/source/ubl-settings-datetime.h.in b/source/ubl-settings-datetime.h.in deleted file mode 100644 index 17ba454..0000000 --- a/source/ubl-settings-datetime.h.in +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine WEBKIT_FOUND \ No newline at end of file