diff --git a/source/main.cc b/source/main.cc index 6c979b8..f423a3a 100644 --- a/source/main.cc +++ b/source/main.cc @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include "ubl-settings-datetime.h" int main(int argc, char* argv[]) { string str_argv=""; @@ -17,11 +19,31 @@ int main(int argc, char* argv[]) { if (argc>1){ str_argv = argv[1]; } - if (str_argv.find("-")!=std::string::npos){ + + if ((str_argv.find("-s")!=std::string::npos) || (str_argv.find("--socket-id")!=std::string::npos)){ + + auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug"); + auto builder = Gtk::Builder::create_from_file(path_glade + "ubl-settings-datetime.glade"); + Glib::init(); + Glib::OptionContext context; + CmdArgParser parser{ + "Socket ID", + "Command line argument for socket ID communication.", + "No help available, sorry" + }; + context.set_main_group(parser); + context.parse(argc, argv); + ::Window socketID = parser.GetSocketID(); + SettingsPlug plug{socketID, builder}; + plug.show(); + app->run(plug); + return 0; + } + else if (str_argv.find("-")!=std::string::npos || argc==1){ int len_argv = 1; auto app = Gtk::Application::create(len_argv, argv, "org.gtkmm.example.plug"); auto builder = Gtk::Builder::create_from_file(path_glade + "ubl-settings-datetime.glade"); - for (int i=0; irun(plug); + else{ + cout << gettext("Argument not recognized"); return 0; } } \ No newline at end of file diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index ec18f1b..9db3e71 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -53,6 +53,7 @@ CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_descr socketIDArg.set_short_name('s'); socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN); socketIDArg.set_description("Settings manager socket"); + cout << m_socketID << endl; add_entry(socketIDArg, m_socketID); } @@ -102,7 +103,6 @@ void MainWindow::settings(){ 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); @@ -130,6 +130,7 @@ void MainWindow::lacalization(){ cbDhcp->append(_("Default")); cbDhcp->append(_("DHCP")); cbDhcp->append(_("Manual")); + cbDhcp->append(_("Disabled")); lblDateTimeSetting->set_text(_("Local Configuration")); lblHead->set_text(_("Settings the date and time")); lblTime->set_text(_("Time")); @@ -167,7 +168,6 @@ void MainWindow::flag_block_gui(){ btnHardwareTime->set_sensitive(false); lblTime->set_sensitive(false); lblData->set_sensitive(false); - //cbxSynchronizeNtpGlob->set_sensitive(false); } if (flag_timezone==true){ cbRegion->set_sensitive(false); @@ -178,14 +178,12 @@ void MainWindow::flag_block_gui(){ cbDhcp->set_sensitive(false); } if (flag_ntp==true){ - cbxSynchronizeNtpGlob->set_sensitive(false); cbDhcp->set_sensitive(false); txtNtpServer->set_sensitive(false); } if (flag_update==true){ lblDateTimeSettingGlob->set_sensitive(false); //lblSynchronizebChkGLob->set_sensitive(false); - cbxSynchronizeNtpGlob->set_sensitive(false); lblTimeZoneGlob->set_sensitive(false); lblRegGlob->set_sensitive(false); cbRegionGlob->set_sensitive(false); @@ -214,7 +212,6 @@ void MainWindow::get_builder(){ builder->get_widget("btnUpdateDateTime", btnUpdateDateTime); builder->get_widget("btnChooseDate", btnChooseDate); builder->get_widget("btnMessClose", btnMessClose); - builder->get_widget("cbxSynchronizeNtpGlob", cbxSynchronizeNtpGlob); builder->get_widget("popCalendar", popCalendar); builder->get_widget("numTimeHrs", numTimeHrs); builder->get_widget("numTimeMin", numTimeMin); @@ -269,12 +266,10 @@ bool MainWindow::gui_exit_2(GdkEventAny* event){ } void MainWindow::event(){ - //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::wrapper_update_time_date)); btnChooseDate->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::calendar_show)); cbDhcp->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::event_entry_cbDhcp)); @@ -392,6 +387,11 @@ void MainWindow::event_entry_cbDhcp(){ } } } + else if (activ_index==3){ + system("/usr/bin/ubconfig remove network NTPSERVERS"); + txtNtpServer->set_text(""); + txtNtpServer->set_sensitive(false); + } else{ string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; system(cmd.c_str()); @@ -450,9 +450,6 @@ void MainWindow::calendar_show(){ void MainWindow::enry_dhcp_mess(){ string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); if (str_dhcp.find("(null)")==std::string::npos){ - - cbxSynchronizeNtpGlob->set_active(true); - //this->set_ntp_toggle_glob(); 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"){ @@ -482,8 +479,8 @@ void MainWindow::enry_dhcp_mess(){ } } else{ - cbxSynchronizeNtpGlob->set_active(false); - cbDhcp->set_sensitive(false); + cbDhcp->set_active(3); + txtNtpServer->set_text(""); txtNtpServer->set_sensitive(false); } } @@ -597,24 +594,6 @@ void MainWindow::enter_zone_glob(){ } } -void MainWindow::set_ntp_toggle_glob(){ - bool flag = cbxSynchronizeNtpGlob->get_active(); - if (flag==false){ - system("/usr/bin/ubconfig remove network NTPSERVERS"); - cbDhcp->set_sensitive(false); - txtNtpServer->set_text(""); - txtNtpServer->set_sensitive(false); - - } - else{ - cbDhcp->set_sensitive(true); - system("/usr/bin/ubconfig set network NTPSERVERS=dhcp"); - cbDhcp->set_active(1); - txtNtpServer->set_text(""); - txtNtpServer->set_sensitive(false); - } - -} void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxText *tmpCbReg, Gtk::ComboBoxText *tmpCbZone){ str_region=region; @@ -630,7 +609,6 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex } index+=1; } - index = 0; string zone_mixing = ""; string path_reg_zone = ""; @@ -949,18 +927,18 @@ vector MainWindow::split(const std::string &s, char delim){ SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr builder) : Gtk::Plug{p_socketID} { - builder->get_widget("plugBox", plugBox); + builder->get_widget("id_plug", plugBox); plugBox->get_parent()->remove(*plugBox); add(*plugBox); show_all_children(); } void help(){ - g_print("Usage: ubl-settings-datetime [--lock-timezone] [--lock-ntp] [--lock-datetime] [--lock-update]\n"); - g_print("Options:\n"); - g_print(" --lock-timezone Disable timezone field editing\n"); - 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"); + g_print(gettext("Usage: ubl-settings-datetime [--lock-timezone] [--lock-ntp] [--lock-datetime] [--lock-update]\n")); + g_print(gettext("Options:\n")); + g_print(gettext(" --lock-timezone Disable timezone field editing\n")); + g_print(gettext(" --lock-ntp Disable ntp field editing\n")); + g_print(gettext(" --lock-datetime Disable datetime field editing\n")); + g_print(gettext(" --lock-update Disable save changes\n")); } diff --git a/ubl-settings-datetime.desktop b/ubl-settings-datetime.desktop index 87d86f7..8e07f0d 100644 --- a/ubl-settings-datetime.desktop +++ b/ubl-settings-datetime.desktop @@ -10,4 +10,4 @@ Type=Application 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 +Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;X-UBL-SettingsManager;X-UBL-SystemSettings; \ No newline at end of file diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade index 2ddfb98..7370d8c 100644 --- a/ubl-settings-datetime.glade +++ b/ubl-settings-datetime.glade @@ -169,464 +169,229 @@ + + 240 + 185 + False + btnChooseDate + bottom + none + + + True + True + 10 + 10 + 10 + 10 + 10 + 10 + 2023 + 1 + 10 + + + False Настройки даты и времени - + True False vertical - + True False + vertical - - 90 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 69 - ubl-settings-datetime - - - False - True - 0 - - - - + True False - + + 90 True False - - - True - False - vertical - - - 255 - True - False - Date and time settings - - - - - - - - - True - True - 0 - - - - - False - True - 0 - - + 5 + 5 + 5 + 5 + 6 + 6 + 69 + ubl-settings-datetime - True + False True 0 - - - True - False - - - False - True - 1 - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - - - True - False - 6 - 5 - 5 - 5 - 0.019999999552965164 - in True False - 6 - 5 - 5 - vertical True False - - 160 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Time - True - 0 - - - False - True - 0 - - - - - True - True - 5 - 5 - 5 - 5 - 6 - 6 - 2 - 0.099999999776482579 - True - - - False - True - 1 - - - - - True - False - : - - - False - True - 2 - - - - - True - True - 5 - 5 - 5 - 5 - 6 - 6 - 2 - True - - - False - True - 3 - - - - - False - True - 1 - - - - - True - False - - - 160 + True False - 5 - 5 - 5 - 5 - 6 - 6 - Date - True - 0 - - - False - True - 0 - - - - - 191 - True - True - Date -Format: DD.MM.YYYY - 5 - 5 - 5 - 5 - 6 - 6 - - - False - True - 1 - - - - - True - True - True - Интерактивный выбор даты - 5 - 5 - 5 - 5 - 6 - 6 + vertical - + + 255 True False - x-office-calendar + Date and time settings + + + + + + + + True + True + 0 + False True - 2 + 0 - False + True True - 2 + 0 - + 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 - False - - - False - True - 1 - - - - - True - False - - - False - True - 2 - - - - - True - True - True - 5 - 5 - 5 - 10 - 6 - 6 - - - True - False - center - center - Synchronize hardware time - - - - - True - True - 3 - - False True - 3 + 1 + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 0.019999999552965164 + in - + True False 5 - 5 5 - 10 - 6 - 0.019999999552965164 - in + 5 + vertical True False - + + 160 True False + 5 + 5 + 5 + 5 + 6 + 6 + Time + True + 0 False True - 1 + 0 - + True - False + True 5 5 - 8 + 5 5 6 - 13 - Region - 0 + 6 + 2 + 0.099999999776482579 + True False True - 2 + 1 - + True False + : + + + False + True + 2 + + + + + True + True 5 5 5 5 6 - 13 + 6 + 2 + True False @@ -634,52 +399,160 @@ Format: DD.MM.YYYY 3 + + + False + True + 1 + + + + + True + False - + + 160 True False 5 5 - 10 + 5 5 6 - 13 - Area + 6 + Date + True 0 False True - 4 + 0 - + + 191 True - False + True + Date +Format: DD.MM.YYYY + 5 + 5 + 5 + 5 + 6 + 6 + + + False + True + 1 + + + + + True + True + True + Интерактивный выбор даты + 5 + 5 + 5 + 5 + 6 + 6 + + + True + False + x-office-calendar + + + + + False + True + 2 + + + + + False + True + 2 + + + + + True + False + + + True + True + True 5 5 5 5 6 - 13 + 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 - 5 + 0 - 5 True False False True - 6 + 1 @@ -690,87 +563,231 @@ Format: DD.MM.YYYY False True - 7 + 2 + + + + + True + True + True + 5 + 10 + 5 + 10 + 6 + 6 + + + True + False + center + center + Synchronize hardware time + + + + + True + True + 3 + + False + True + 3 + - - + + True False - Time Zone + 5 + 10 + 5 + 10 + 6 + 0.019999999552965164 + in + + + True + False + + + True + False + + + False + True + 1 + + + + + True + False + 8 + 5 + 8 + 5 + 6 + 13 + Region + 0 + + + False + True + 2 + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 13 + + + False + True + 3 + + + + + True + False + 10 + 5 + 10 + 5 + 6 + 13 + Area + 0 + + + False + True + 4 + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 13 + + + False + True + 5 + + + + + 5 + True + False + + + False + True + 6 + + + + + True + False + + + False + True + 7 + + + + + + + True + False + Time Zone + + + + False + True + 5 + - - False - True - 5 - + + + + True + False + Local Configuration + - - - - True - False - Local Configuration - - - - - False - True - 0 - - - - - False - True - 1 - - - - - True - False - vertical + + False + True + 0 + + + + + False + True + 1 + + - + True False - 5 - 5 - 5 - 5 - 0.019999999552965164 - in + vertical - + True False - 6 + 5 + 5 5 - 5 - vertical + 5 + 0.019999999552965164 + in - + True - True - False - Автоматическая синхронизация времени + False 5 - 5 5 - 5 - 6 - True + 5 + vertical True False + start 5 5 5 @@ -779,243 +796,225 @@ Format: DD.MM.YYYY 6 Synchronize via NTP - - - - False - True - 0 - - - - - True - False - - - True - False - 5 - 5 - 5 - 5 - 6 - 5 - False True - 1 - - - - - -1 - True - True - Enter the name of the ntp server or its ip address. When entering multiple addresses, separate them with spaces. - center - 5 - 5 - 5 - 10 - 6 - 5 - - - True - True - 3 + 0 - - - False - True - 1 - - - - - True - False - 5 - 5 - 5 - 10 - 6 - 0.019999999552965164 - in True False - - True - False - - - False - True - 1 - - - - + True False - 8 + 5 5 - 8 + 5 5 6 - 13 - Region - 0 + 5 False True - 2 + 1 - + + -1 True - False + True + Enter the name of the ntp server or its ip address. When entering multiple addresses, separate them with spaces. + center 5 - 5 + 10 5 - 5 + 10 6 - 13 + 5 - False + True True 3 + + + False + True + 1 + + + + + True + False + 5 + 10 + 5 + 10 + 6 + 0.019999999552965164 + in - - True - False - 10 - 5 - 10 - 5 - 5 - 13 - Area - 0 - - - False - True - 4 - - - - + True False - 5 - 5 - 5 - 5 - 6 - 13 + + + True + False + + + False + True + 1 + + + + + True + False + 8 + 5 + 8 + 5 + 6 + 13 + Region + 0 + + + False + True + 2 + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 13 + + + False + True + 3 + + + + + True + False + 10 + 5 + 10 + 5 + 5 + 13 + Area + 0 + + + False + True + 4 + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 13 + + + False + True + 5 + + + + + 5 + True + False + 15 + 5 + 15 + 5 + 5 + 5 + + + False + True + 6 + + - - False - True - 5 - - - - 5 + + True False - 15 - 5 - 15 - 5 - 5 - 5 + Часовой пояс - - False - True - 6 - - - - - True - False - Часовой пояс - + + False + True + 2 + - - False - True - 2 - + + + + True + False + Global customization + - - - - True - False - Global customization - + + False + True + 0 + False True - 0 + 2 False True - 2 + 0 - - 240 - 185 - False - btnChooseDate - bottom - none - - - True - True - 10 - 10 - 10 - 10 - 10 - 10 - 2023 - 1 - 10 - - - False diff --git a/ubl-settings-datetime_ru.po b/ubl-settings-datetime_ru.po index e725dbd..b32e1e6 100644 --- a/ubl-settings-datetime_ru.po +++ b/ubl-settings-datetime_ru.po @@ -1612,3 +1612,27 @@ msgstr "Введите имя ntp-сервера или его ip-адрес.\n msgid "Cape_Verde" msgstr "Кабо-Верде" +msgid "Usage: ubl-settings-datetime [--lock-timezone] [--lock-ntp] [--lock-datetime] [--lock-update]\n" +msgstr "Использование: ubl-settings-datetime [--lock-timezone] [--lock-ntp] [--lock-datetime] [--lock-update]\n" + +msgid " --lock-timezone Disable timezone field editing\n" +msgstr " --lock-timezone Отключить редактирование поля часового пояса\n" + +msgid " --lock-ntp Disable ntp field editing\n" +msgstr " --lock-ntp Отключить редактирование полей ntp\n" + +msgid " --lock-datetime Disable datetime field editing\n" +msgstr " --lock-datetime Отключить редактирование полей даты и времени\n" + +msgid " --lock-update Disable save changes\n" +msgstr " --lock-update Отключить сохранение изменений\n" + +msgid "Options:\n" +msgstr "Опции:\n" + +msgid "Disabled" +msgstr "Отключено" + +msgid "Argument not recognized\n" +msgstr "Не распознанный аргумент\n" +