diff --git a/source/main.cc b/source/main.cc index e298fdd..fb22901 100644 --- a/source/main.cc +++ b/source/main.cc @@ -36,10 +36,10 @@ int main(int argc, char* argv[]) { auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug"); auto builder = Gtk::Builder::create_from_file(path_glade + "ubl-settings-datetime.glade"); if (argc>1){ - str_argv_1 = to_string(*argv[1]); + str_argv_1 = argv[1]; } - if ((str_argv_1=="--help" || str_argv_1=="--lock-datetime") || (str_argv_1=="--lock-timezone" || str_argv_1=="--lock-ntp") || (str_argv_1=="--lock-update" || argc==1)){ + cout << 2222 << endl; //setlocale(LC_ALL, "."); //bindtextdomain(app_name.c_str(), "."); //textdomain(app_name.c_str()); @@ -91,6 +91,7 @@ int main(int argc, char* argv[]) { plug.show(); app->run(plug); + return 0; } diff --git a/source/ubl_settings_datetime b/source/ubl_settings_datetime index a3aea90..d8b105b 100755 Binary files a/source/ubl_settings_datetime and b/source/ubl_settings_datetime differ diff --git a/source/ubl_settings_datetime.cc b/source/ubl_settings_datetime.cc index 3337d1f..95ddd01 100644 --- a/source/ubl_settings_datetime.cc +++ b/source/ubl_settings_datetime.cc @@ -33,6 +33,7 @@ bool flag_datetime = false; bool flag_timezone = false; bool flag_ntp = false; bool flag_update = false; + 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} { @@ -72,6 +73,7 @@ void MainWindow::settings(){ this->get_config(); this->flag_block_gui(); this->event(); + this->parse_text_date(); } void MainWindow::flag_block_gui(){ @@ -301,6 +303,17 @@ void MainWindow::enter_zone(){ } } +void MainWindow::parse_text_date(){ + string data = _txtDate->get_text(); + if (data.length()==10){ + string day = data.substr(0,2); + string month1 = data.substr(3,2); + string year = data.substr(6,data.length()); + cout << day << " " << month1 << " " << year << endl; + } + +} + void MainWindow::enter_zone_glob(){ Glib::ustring zone_text = _cbZoneGlob->get_active_text(); Glib::ustring reg_text = _cbRegionGlob->get_active_text(); @@ -449,6 +462,20 @@ void MainWindow::update_time_date(){ system(cmd.c_str()); _txtDate->set_text(str_day+"." + str_month+"." + to_string(year)); } + else{ + string cmd = ""; + string data = _txtDate->get_text(); + if (data.length()==10){ + string str_day = data.substr(0,2); + string str_month = data.substr(3,2); + string str_year = data.substr(6,data.length()); + cmd = "date +%Y%m%d -s \"" + str_year+ + str_month+str_day+"\""; + system(cmd.c_str()); + } + cmd = "hwclock --systohc"; + system(cmd.c_str()); + } } } diff --git a/source/ubl_settings_datetime.h b/source/ubl_settings_datetime.h index bded466..cfbe7aa 100644 --- a/source/ubl_settings_datetime.h +++ b/source/ubl_settings_datetime.h @@ -83,6 +83,7 @@ public: void update_hour_minute(); void update_calendar(); void read_file(); + void parse_text_date(); vector split(const std::string &s, char delim); private: Glib::RefPtr builder;