parent
831e0ad131
commit
c1fb310f56
@ -0,0 +1,6 @@
|
||||
UBTime
|
||||
main.cpp
|
||||
ubl-settings-datetime.glade~
|
||||
test.cpp
|
||||
ubl-settings-datetime
|
||||
a.out
|
||||
@ -1,61 +1,71 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
pkgname="ubconfig"
|
||||
pkgname=ubl-settings-datetime
|
||||
|
||||
all: uninstall build check install clean
|
||||
all: uninstall init build check install clean
|
||||
|
||||
init:
|
||||
mkdir -p /usr/share/${pkgname}/{images,ui,reg}/;
|
||||
|
||||
uninstall:
|
||||
pkgname="ubconfig"
|
||||
for size in 16 32 48; do
|
||||
rm -f "/usr/share/icons/hicolor/${size}x${size}/apps/ublinux-${pkgname}.svg"
|
||||
rm -f "/usr/share/icons/hicolor/${size}x${size}/apps/hide_pass_icon.svg"
|
||||
rm -f "/usr/share/icons/hicolor/${size}x${size}/apps/show_pass_icon.svg"
|
||||
done
|
||||
for file_po in *.po; do
|
||||
lang=${file_po##*_};lang=${lang%.*}
|
||||
file_mo=${file_po##*/}; file_mo="${file_mo%_*.po}.mo"
|
||||
path_file_mo="/usr/share/locale/${lang}/LC_MESSAGES/${file_mo}"
|
||||
rm -f "/usr/share/locale/${lang}/LC_MESSAGES/${file_mo}"
|
||||
done
|
||||
rm -f /usr/bin/"${pkgname}"
|
||||
rm -f /usr/bin/"${pkgname}".gtk
|
||||
rm -f /usr/share/"${pkgname}"/ui/"${pkgname}".glade
|
||||
rm -f /usr/share/applications/"${pkgname}".desktop
|
||||
rm -f /usr/share/"${pkgname}"/css/style.css
|
||||
rm -f /usr/share/"${pkgname}"/images/side_img_ubc_v_dark.png
|
||||
rm -f /usr/share/"${pkgname}"/images/side_img_ubc_v_light.png
|
||||
rm -f /usr/share/polkit-1/actions/org.freedesktop.policykit."${pkgname}".pkexec.policy
|
||||
@for size in 16 32 48; do \
|
||||
rm -f "/usr/share/icons/hicolor/$${size}x$${size}/apps/ublinux-datetime-settings.svg"; \
|
||||
rm -f "/usr/share/icons/hicolor/$${size}x$${size}/apps/ublinux-datetime-settings.png"; \
|
||||
done;
|
||||
@for file_po in *.po; do \
|
||||
lang=$${file_po##*_};lang=$${lang%.*}; \
|
||||
file_mo=$${file_po##*/}; file_mo="$${file_mo%_*.po}.mo"; \
|
||||
path_file_mo="/usr/share/locale/$${lang}/LC_MESSAGES/$${file_mo}"; \
|
||||
rm -f "/usr/share/locale/$${lang}/LC_MESSAGES/$${file_mo}"; \
|
||||
done;
|
||||
rm -f /usr/bin/${pkgname}; \
|
||||
rm -rf /usr/bin/${pkgname}/reg; \
|
||||
rm -f /usr/share/${pkgname}/ui/${pkgname}.glade; \
|
||||
rm -f /usr/share/applications/${pkgname}.desktop; \
|
||||
rm -f /usr/share/${pkgname}/images/ublinux-datetime-settings.svg; \
|
||||
rm -f /usr/share/${pkgname}/images/ublinux-datetime-settings.png; \
|
||||
rm -f /usr/share/polkit-1/actions/org.freedesktop.policykit.${pkgname}.pkexec.policy; \
|
||||
|
||||
build:
|
||||
echo "Build"
|
||||
echo "Build"; \
|
||||
g++ -O2 -std=c++20 -lstdc++ -o ubl-settings-datetime ubl-settings-datetime.cpp `pkg-config --cflags --libs gtkmm-3.0` -Wl,-export-dynamic -g; \
|
||||
|
||||
check:
|
||||
echo "Check"
|
||||
echo "Check"; \
|
||||
|
||||
install:
|
||||
for size in 16 32 48; do
|
||||
install -dm755 /usr/share/icons/hicolor/${size}x${size}/apps
|
||||
rsvg-convert -w ${size} -h ${size} -f svg --keep-image-data "ublinux-${pkgname}.svg" -o "/usr/share/icons/hicolor/${size}x${size}/apps/ublinux-${pkgname}.svg"
|
||||
rsvg-convert -w ${size} -h ${size} -f svg --keep-image-data "hide_pass_icon.svg" -o "/usr/share/icons/hicolor/${size}x${size}/apps/hide_pass_icon.svg"
|
||||
rsvg-convert -w ${size} -h ${size} -f svg --keep-image-data "show_pass_icon.svg" -o "/usr/share/icons/hicolor/${size}x${size}/apps/show_pass_icon.svg"
|
||||
done
|
||||
for file_po in *.po; do
|
||||
lang=${file_po##*_};lang=${lang%.*}
|
||||
install -dm755 /usr/share/locale/${lang}/LC_MESSAGES
|
||||
file_mo=${file_po##*/}; file_mo="${file_mo%_*.po}.mo"
|
||||
path_file_mo="/usr/share/locale/${lang}/LC_MESSAGES/${file_mo}"
|
||||
msgfmt "${file_po}" -v -f -o "${path_file_mo}"
|
||||
done
|
||||
install -vDm0755 "${pkgname}" -t /usr/bin/
|
||||
install -vDm0755 "${pkgname}".gtk -t /usr/bin/
|
||||
install -vDm0644 "${pkgname}".glade -t /usr/share/"${pkgname}"/ui/
|
||||
install -vDm0644 "${pkgname}".desktop -t /usr/share/applications/
|
||||
install -vDm0644 style.css -t /usr/share/"${pkgname}"/css/
|
||||
install -vDm0644 side_img_ubc_v_dark.png -t /usr/share/"${pkgname}"/images/
|
||||
install -vDm0644 side_img_ubc_v_light.png -t /usr/share/"${pkgname}"/images/
|
||||
install -vDm0644 org.freedesktop.policykit."${pkgname}".pkexec.policy -t /usr/share/polkit-1/actions/
|
||||
|
||||
|
||||
@for size in 16 32 48; do \
|
||||
install -dm755 /usr/share/icons/hicolor/$${size}x$${size}/apps; \
|
||||
rsvg-convert -w $$size -h $$size -f svg --keep-image-data ${pkgname}.svg -o "/usr/share/icons/hicolor/$${size}x$${size}/apps/$${pkgname}.svg"; \
|
||||
done;
|
||||
@for file_po in *.po; do \
|
||||
lang=$${file_po##*_};lang=$${lang%.*}; \
|
||||
install -dm755 /usr/share/locale/$${lang}/LC_MESSAGES; \
|
||||
file_mo=$${file_po##*/}; file_mo="$${file_mo%_*.po}.mo"; \
|
||||
path_file_mo="/usr/share/locale/$${lang}/LC_MESSAGES/$${file_mo}"; \
|
||||
echo $$file_po; \
|
||||
msgfmt "$${file_po}" -v -f -o "$${path_file_mo}"; \
|
||||
done;
|
||||
install -vDm0755 ${pkgname} -t /usr/bin/; \
|
||||
install -vDm0644 ${pkgname}.glade -t /usr/share/${pkgname}/ui/; \
|
||||
install -vDm0644 ${pkgname}.desktop -t /usr/share/applications/; \
|
||||
install -vDm0644 ubl-settings-datetime.svg -t /usr/share/icons/hicolor/scalable/apps/
|
||||
install -vDm0644 ubl-settings-datetime.svg -t /usr/share/${pkgname}/images/; \
|
||||
install -vDm0644 ubl-settings-datetime.png -t /usr/share/${pkgname}/images/; \
|
||||
install -vDm0644 org.freedesktop.policykit.${pkgname}.pkexec.policy -t /usr/share/polkit-1/actions/;
|
||||
install -vDm0644 reg/Africa -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/America -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/Antarctica -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/Arctic -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/Asia -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/Atlantic -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/Australia -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/Brazil -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/Chile -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/Europe -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/Indian -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/Mexico -t /usr/share/${pkgname}/reg/; \
|
||||
install -vDm0644 reg/US -t /usr/share/${pkgname}/reg/;
|
||||
clean:
|
||||
echo "Clean"
|
||||
echo "Clean";
|
||||
|
||||
@ -1,2 +1,8 @@
|
||||
# ubl-settings-datetime
|
||||
|
||||

|
||||
|
||||
- [ ] Локализация
|
||||
- [x] Makefile
|
||||
- [ ] Парсинг TimeZone C++
|
||||
|
||||
|
||||
@ -1,477 +0,0 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <gtkmm.h>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <gtkmm/plug.h>
|
||||
|
||||
using namespace std;
|
||||
class MainWindow;
|
||||
|
||||
class MainWindow {
|
||||
public:
|
||||
MainWindow(Glib::RefPtr<Gtk::Builder> const& builder)
|
||||
{
|
||||
this->builder = builder;
|
||||
this->get_builder();
|
||||
_numTimeHrs->set_range(0,23);
|
||||
_numTimeMin->set_range(0,59);
|
||||
_numTimeHrs->set_increments(1.0,1.0);
|
||||
_numTimeMin->set_increments(1.0,1.0);
|
||||
_txtDate->set_sensitive(false);
|
||||
this->get_config();
|
||||
this->event();
|
||||
|
||||
|
||||
}
|
||||
|
||||
virtual ~MainWindow() = default;
|
||||
// Функция вызывается btnUpdateDate для обновления времени
|
||||
void get_builder(){
|
||||
builder->get_widget("btnUpdateDateTime", _btnUpdateDateTime);
|
||||
builder->get_widget("btnChooseDate", _btnChooseDate);
|
||||
builder->get_widget("cbxSynchronizeNtp", _cbxSynchronizeNtp);
|
||||
builder->get_widget("popCalendar", _popCalendar);
|
||||
builder->get_widget("numTimeHrs", _numTimeHrs);
|
||||
builder->get_widget("numTimeMin", _numTimeMin);
|
||||
builder->get_widget("cbDhcp", _cbDhcp);
|
||||
builder->get_widget("txtDate", _txtDate);
|
||||
builder->get_widget("cbRegion", _cbRegion);
|
||||
builder->get_widget("cbRegionGlob", _cbRegionGlob);
|
||||
builder->get_widget("cbZone", _cbZone);
|
||||
builder->get_widget("cbZoneGlob", _cbZoneGlob);
|
||||
builder->get_widget("txtNtpServer", _txtNtpServer);
|
||||
builder->get_widget("cldrDate", _cldrDate);
|
||||
builder->get_widget("mess_dchp", _mess_dchp);
|
||||
|
||||
}
|
||||
void event(){
|
||||
_cldrDate->signal_day_selected().connect(sigc::mem_fun(*this, &MainWindow::get_calendar));
|
||||
_cbxSynchronizeNtp->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::set_ntp_toggle));
|
||||
_btnUpdateDateTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::update_time_date));
|
||||
_btnChooseDate->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::calendar_show));
|
||||
_cbDhcp->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::get_ghcp));
|
||||
_cbRegion->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::append_zone));
|
||||
_cbRegionGlob->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::append_zone_glob));
|
||||
_cbZone->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::enter_zone));
|
||||
_cbZoneGlob->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::enter_zone_glob));
|
||||
_txtNtpServer->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::A));;
|
||||
}
|
||||
|
||||
void focus_ntp(){
|
||||
|
||||
}
|
||||
void A(){
|
||||
cout << "A" << endl;
|
||||
//_txtNtpServer->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_ntp));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void enry_dhcp_mess(){}
|
||||
|
||||
void get_ghcp(){
|
||||
Glib::ustring str_dhcp = _cbDhcp->get_active_text();
|
||||
if (str_dhcp.length()!=0){
|
||||
if (str_dhcp=="DHCP"){
|
||||
string cmd = "sudo /usr/bin/ubconfig set network NTPSERVERS=dhcp";
|
||||
system(cmd.c_str());
|
||||
//_txtNtpServer->set_active(false);
|
||||
_cbDhcp->set_active(0);
|
||||
}
|
||||
else{
|
||||
string cmd = "sudo /usr/bin/ubconfig set network NTPSERVERS=" + _txtNtpServer->get_text();
|
||||
//_txtNtpServer->set_active(true);
|
||||
system(cmd.c_str());
|
||||
_cbDhcp->set_active(1);
|
||||
}
|
||||
}
|
||||
else{
|
||||
string cmd = "sudo /usr/bin/ubconfig set network NTPSERVERS=dhcp";
|
||||
system(cmd.c_str());
|
||||
//_txtNtpServer->set_sensitive(false);
|
||||
_cbDhcp->set_active(0);
|
||||
}
|
||||
}
|
||||
|
||||
void get_calendar(){
|
||||
_cldrDate->get_date(year, month, day);
|
||||
string date = to_string(day) + ':' + to_string(month+1) + ':' + to_string(year);
|
||||
_txtDate->set_text(date);
|
||||
}
|
||||
|
||||
|
||||
void calendar_show(){
|
||||
time_t now = time(0);
|
||||
tm *ltm = localtime(&now);
|
||||
unsigned int y=1900+ ltm->tm_year;
|
||||
unsigned int m=ltm->tm_mon;
|
||||
unsigned int d=ltm->tm_mday;
|
||||
|
||||
|
||||
_cldrDate->select_month(m,y);
|
||||
_cldrDate->select_day(d);
|
||||
_popCalendar->show();
|
||||
}
|
||||
|
||||
void get_config(){
|
||||
this->read_file();
|
||||
this->update_hour_minute();
|
||||
this->update_calendar();
|
||||
this->get_ghcp();
|
||||
string str_dhcp = this->call("sudo /usr/bin/ubconfig get network NTPSERVERS");
|
||||
cout << str_dhcp << endl;
|
||||
if ((str_dhcp!="") && (str_dhcp!="(null)")){
|
||||
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"){
|
||||
_cbDhcp->set_active(0);
|
||||
//_txtNtpServer->set_sensitive(false);
|
||||
//_cbxSynchronizeNtp->set_sensitive(true);
|
||||
}
|
||||
else{
|
||||
if (str_dhcp==""){
|
||||
_mess_dchp->show();
|
||||
}
|
||||
else{
|
||||
_cbDhcp->set_active(1);
|
||||
//_txtNtpServer->set_sensitive(true);
|
||||
//_cbxSynchronizeNtp->set_sensitive(false);
|
||||
_txtNtpServer->set_text(str_dhcp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//_cbxDhcp->set_active(true);
|
||||
this->set_ntp_toggle();
|
||||
}
|
||||
string str_ntp = this->call("sudo systemctl status ntpd.service systemd-timesyncd.service | grep \"Active: active\"");
|
||||
if (str_ntp.length()<50) {
|
||||
_cbxSynchronizeNtp->set_active(false);
|
||||
}
|
||||
else{
|
||||
_cbxSynchronizeNtp->set_active(true);
|
||||
}
|
||||
|
||||
string read_reg_zon_cfg = this->call("sudo /usr/bin/ubconfig get clock ZONE");
|
||||
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(0,read_reg_zon_cfg.find("\n"));
|
||||
string str_filling_reg = read_reg_zon_cfg.substr(0,read_reg_zon_cfg.find("/"));
|
||||
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"));
|
||||
string str_zone_check = "";
|
||||
this->append_region_zone(str_filling_reg,str_filling_zon);
|
||||
}
|
||||
else {
|
||||
this->append_region_zone("Asia","Omsk");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void enter_zone(){
|
||||
Glib::ustring zone_text = _cbZone->get_active_text();
|
||||
Glib::ustring reg_text = _cbRegion->get_active_text();
|
||||
if(!(zone_text.empty()) && !(reg_text.empty())){
|
||||
str_zone=zone_text.substr(zone_text.find(") ")+2,zone_text.length());
|
||||
str_region=reg_text;
|
||||
string cmd = "sudo timedatectl set-timezone '" + str_region +"/" + str_zone+"'";
|
||||
system(cmd.c_str());
|
||||
}
|
||||
else{
|
||||
str_zone="";
|
||||
str_region="";
|
||||
}
|
||||
}
|
||||
|
||||
void enter_zone_glob(){
|
||||
Glib::ustring zone_text = _cbZoneGlob->get_active_text();
|
||||
Glib::ustring reg_text = _cbRegionGlob->get_active_text();
|
||||
if(!(zone_text.empty()) && !(reg_text.empty())){
|
||||
str_zoneGlob = zone_text.substr(zone_text.find(") ")+2,zone_text.length());
|
||||
str_region_glob = reg_text;
|
||||
string cmd = "sudo /usr/bin/ubconfig set clock ZONE=" +str_region_glob +"/" + str_zoneGlob;
|
||||
system(cmd.c_str());
|
||||
}
|
||||
else{
|
||||
str_zoneGlob="";
|
||||
str_region_glob="";
|
||||
}
|
||||
}
|
||||
|
||||
void set_ntp_toggle(){
|
||||
bool flag = _cbxSynchronizeNtp->get_active();
|
||||
_numTimeHrs->set_sensitive(!flag);
|
||||
_numTimeMin->set_sensitive(!flag);
|
||||
//_txtDate->set_sensitive(!flag);
|
||||
_btnChooseDate->set_sensitive(!flag);
|
||||
//_btnUpdateDateTime->set_sensitive(!flag);
|
||||
if (flag==false){
|
||||
system("sudo systemctl --now disable systemd-timesyncd.service ntpd.service");
|
||||
}
|
||||
else {
|
||||
system("sudo systemctl --now enable systemd-timesyncd.service");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void append_region_zone(string region, string zone){
|
||||
int index = 0;
|
||||
for ( const auto &text : time_reg_map ) {
|
||||
_cbRegion->append(text.first);
|
||||
_cbRegionGlob->append(text.first);
|
||||
if (text.first == region){
|
||||
_cbRegionGlob->set_active(index);
|
||||
_cbRegion->set_active(index);
|
||||
|
||||
}
|
||||
index+=1;
|
||||
}
|
||||
index = 0;
|
||||
string cheek_zone = "";
|
||||
for (const auto &_str_zone : time_reg_map.at(region)){
|
||||
_cbZone->append(_str_zone);
|
||||
_cbZoneGlob->append(_str_zone);
|
||||
if (_str_zone!=""){
|
||||
cheek_zone = _str_zone.substr(_str_zone.find(") ")+2,_str_zone.length());
|
||||
if (cheek_zone == zone){
|
||||
_cbZone->set_active(index);
|
||||
_cbZoneGlob->set_active(index);
|
||||
}
|
||||
}
|
||||
index+=1;
|
||||
}
|
||||
}
|
||||
string call(string cmd){
|
||||
FILE *fp;
|
||||
int status;
|
||||
char path[PATH_MAX];
|
||||
fp = popen(cmd.c_str(), "r");
|
||||
if (fp == NULL){
|
||||
//return "";
|
||||
}
|
||||
|
||||
while (fgets(path, PATH_MAX, fp) != NULL){
|
||||
printf("%s", path);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
status = pclose(fp);
|
||||
if (status == -1) {
|
||||
//return "";
|
||||
}
|
||||
else {
|
||||
//return "";
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
void append_zone(){
|
||||
Glib::ustring text = _cbRegion->get_active_text();
|
||||
_cbZone->remove_all();
|
||||
|
||||
if(!(text.empty())){
|
||||
str_region = text;
|
||||
for (const auto &_str_zone : time_reg_map.at(str_region)){
|
||||
_cbZone->append(_str_zone);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void append_zone_glob(){
|
||||
Glib::ustring text = _cbRegionGlob->get_active_text();
|
||||
_cbZoneGlob->remove_all();
|
||||
if(!(text.empty())){
|
||||
str_region_glob = text;
|
||||
for (const auto &_str_zone : time_reg_map.at(str_region_glob)){
|
||||
_cbZoneGlob->append(_str_zone);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void update_time_date(){
|
||||
this->enter_zone();
|
||||
bool flag = _cbxSynchronizeNtp->get_active();
|
||||
if (flag==false){
|
||||
hour = _numTimeHrs->get_value_as_int();
|
||||
minute = _numTimeMin->get_value_as_int();
|
||||
time_t now = time(0);
|
||||
tm *ltm = localtime(&now);
|
||||
string cmd = "sudo timedatectl set-time \""+
|
||||
to_string(hour) + ":" + to_string(minute)
|
||||
+ ":" + to_string(ltm->tm_sec) +"\"";
|
||||
system(cmd.c_str());
|
||||
if ((year==0) && (month == 0) && (day == 0)){
|
||||
time_t now = time(0);
|
||||
tm *ltm = localtime(&now);
|
||||
year=1900+ ltm->tm_year;
|
||||
month=ltm->tm_mon+1;
|
||||
day=ltm->tm_mday;
|
||||
}
|
||||
string str_mount = "";
|
||||
string str_day = "";
|
||||
if (month <10){
|
||||
str_mount = "0"+to_string(month+1);
|
||||
}
|
||||
else{
|
||||
str_mount = to_string(month+1);
|
||||
}
|
||||
if (day <10){
|
||||
str_day = "0"+to_string(day);
|
||||
}
|
||||
else{
|
||||
str_day = to_string(day);
|
||||
}
|
||||
string cmd1 = "sudo date --set=\"" +to_string(year)+
|
||||
str_mount+str_day + " " +to_string(hour) + ":" +
|
||||
to_string(minute)+"\"";
|
||||
system(cmd1.c_str());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void update_hour_minute(){
|
||||
time_t now = time(0);
|
||||
tm *ltm = localtime(&now);
|
||||
_numTimeHrs->set_value(ltm->tm_hour);
|
||||
_numTimeMin->set_value(ltm->tm_min);
|
||||
}
|
||||
|
||||
void update_calendar(){
|
||||
time_t now = time(0);
|
||||
tm *ltm = localtime(&now);
|
||||
int year = 1900 + (int)ltm->tm_year;
|
||||
string date = to_string(ltm->tm_mday) + ':' + to_string(ltm->tm_mon+1) + ':' + to_string(year);
|
||||
_txtDate->set_text(date);
|
||||
}
|
||||
void read_file(){
|
||||
std::string line;
|
||||
namespace fs = std::filesystem;
|
||||
for (const auto & entry : fs::directory_iterator(path_file)){
|
||||
std::ifstream in(entry.path()); // окрываем файл для чтения
|
||||
if (in.is_open())
|
||||
{
|
||||
vector<string> zone;
|
||||
zone.push_back("");
|
||||
while (getline(in, line))
|
||||
{
|
||||
zone.push_back(string(gettext(line.c_str())));
|
||||
}
|
||||
string key_reg = entry.path().filename().string();
|
||||
key_reg = string(gettext(key_reg.c_str()));
|
||||
time_reg_map.insert({key_reg, zone});
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
string path_file="reg/";
|
||||
Glib::RefPtr<Gtk::Builder> builder;
|
||||
Gtk::Button *_btnUpdateDateTime;
|
||||
Gtk::Button *_btnChooseDate;
|
||||
Gtk::ComboBoxText *_cbDhcp;
|
||||
Gtk::SpinButton *_numTimeHrs;
|
||||
Gtk::SpinButton *_numTimeMin;
|
||||
Gtk::CheckButton *_cbxSynchronizeNtp;
|
||||
|
||||
Gtk::Entry *_txtDate;
|
||||
Gtk::ComboBoxText *_cbRegion;
|
||||
Gtk::ComboBoxText *_cbRegionGlob;
|
||||
Gtk::ComboBoxText *_cbZone;
|
||||
Gtk::ComboBoxText *_cbZoneGlob;
|
||||
Gtk::Entry *_txtNtpServer;
|
||||
Gtk::MessageDialog *_mess_dchp;
|
||||
Gtk::Popover *_popCalendar;
|
||||
Gtk::Calendar *_cldrDate;
|
||||
unsigned int year, month, day;
|
||||
int hour;
|
||||
int minute;
|
||||
string str_region="";
|
||||
string str_region_glob="";
|
||||
string str_txtDate;
|
||||
string str_txtNtpServer;
|
||||
string str_zone="";
|
||||
string str_zoneGlob;
|
||||
std::map <string, vector<string>> time_reg_map;
|
||||
|
||||
};
|
||||
|
||||
class WrapperMainWindow : public Gtk::ApplicationWindow {
|
||||
public:
|
||||
WrapperMainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder)
|
||||
: Gtk::ApplicationWindow(obj)
|
||||
, builder{builder}
|
||||
{
|
||||
MainWindow MainWindow(builder);
|
||||
}
|
||||
virtual ~WrapperMainWindow() = default;
|
||||
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> builder;
|
||||
};
|
||||
/*
|
||||
class PlugMainWindow : public Gtk::Plug
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
SettingsPlug(::Window p_socketID)
|
||||
: Gtk::Plug{p_socketID}
|
||||
{
|
||||
|
||||
}
|
||||
void get_builder(Glib::RefPtr<Gtk::Builder> const& builder)
|
||||
{
|
||||
this->builder = builder;
|
||||
}
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> builder;
|
||||
}
|
||||
*/
|
||||
int main(int argc, char* argv[]) {
|
||||
string app_name = "main";
|
||||
//setlocale(LC_ALL, "");
|
||||
//bindtextdomain(app_name, "/usr/share/locale");
|
||||
//textdomain(app_name);
|
||||
auto app = Gtk::Application::create(argc, argv, "de.engelmarkus.example");
|
||||
auto builder = Gtk::Builder::create_from_file("ubconfig_date_time.glade");
|
||||
|
||||
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};
|
||||
//plug.show();
|
||||
|
||||
WrapperMainWindow * wnd = nullptr;
|
||||
|
||||
builder->get_widget_derived("window", wnd);
|
||||
|
||||
auto r = app->run(*wnd);
|
||||
|
||||
delete wnd;
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
msgid "Ok"
|
||||
msgstr "Oк"
|
||||
|
||||
msgid "Enter DHCP"
|
||||
msgstr "Введите DHCP"
|
||||
|
||||
msgid "UBconfig - Дата и время"
|
||||
msgstr "UBconfig - Дата и время"
|
||||
|
||||
msgid "Setting the date and time"
|
||||
msgstr "Настройка даты и времени"
|
||||
|
||||
msgid "Time"
|
||||
msgstr "Время"
|
||||
|
||||
msgid "Clock"
|
||||
msgstr "Часы"
|
||||
|
||||
msgid "Minutes"
|
||||
msgstr "Минуты"
|
||||
|
||||
msgid "Date"
|
||||
msgstr "Дата"
|
||||
|
||||
msgid ""
|
||||
msgstr ""
|
||||
|
||||
msgid "Interactive date picker"
|
||||
msgstr "Интерактивный выбор даты"
|
||||
|
||||
msgid "Change zone setting"
|
||||
msgstr "Изменить параметр зоны"
|
||||
|
||||
msgid "time zone"
|
||||
msgstr "Временная зона"
|
||||
|
||||
msgid "Region"
|
||||
msgstr "Регион"
|
||||
|
||||
msgid "Zone"
|
||||
msgstr "Зона"
|
||||
|
||||
msgid "Update date and time"
|
||||
msgstr "Обновить дату и время"
|
||||
|
||||
msgid "Synchronize via NTP"
|
||||
msgstr "Синхронизировать через NTP"
|
||||
|
||||
msgid "Automatic time synchronization"
|
||||
msgstr "Автоматическая синхронизация времени"
|
||||
|
||||
msgid "Synchronization method"
|
||||
msgstr "Способ синхронизации"
|
||||
|
||||
msgid "DHCP"
|
||||
msgstr "DHCP"
|
||||
|
||||
msgid "Manually"
|
||||
msgstr "Вручную"
|
||||
|
||||
msgid ""
|
||||
msgstr ""
|
||||
|
||||
msgid "Time zone"
|
||||
msgstr "Временная зона"
|
||||
|
||||
msgid "Setting date and time in global configuration"
|
||||
msgstr "Настройка даты и времени в глобальной конфигурации"
|
||||
|
||||
|
After Width: | Height: | Size: 35 KiB |
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Exec=ubl-settings-datetime
|
||||
Icon=ubl-settings-datetime
|
||||
Comment=Time setting app
|
||||
Comment[ru]=Приложение для настройки времени
|
||||
Terminal=false
|
||||
Name=Time setting
|
||||
Name[ru]=Настройка времени
|
||||
GenericName=Time setting app
|
||||
GenericName[ru]=Настройка времени
|
||||
Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;
|
||||
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 210 KiB After Width: | Height: | Size: 210 KiB |
Loading…
Reference in new issue