From e5630f85c3f2e2619aa831f4323f07b614f032d6 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 26 Jan 2024 11:00:35 +0600 Subject: [PATCH] Changed date format --- source/ubl-settings-usergroups.c | 31 +++++++++++++++++++++++++------ source/ubl-settings-usergroups.h | 2 +- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index cf33de2..238d739 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -947,7 +947,7 @@ void yon_system_load(ubl_settings_usergroups_system_window *window){ if (yon_gtk_list_store_find_text(window->liststore1,&iter,3,parsed[0])){ GDateTime *date = g_date_time_new_from_unix_local(atol(parsed[2])); char *date_string; - date_string = g_date_time_format(date,"%c"); + date_string = g_date_time_format(date,"%Y-%m-%d"); gtk_list_store_set(window->liststore1,&iter,8,parsed_size>2?date_string:"",9,parsed_size>7?parsed[7]:"",10,parsed_size>3?parsed[3]:"",11,parsed_size>4?parsed[4]:"",12,parsed_size>5?parsed[5]:"",13,parsed_size>2?parsed[6]:"",-1); } @@ -1182,7 +1182,7 @@ void on_user_save(GtkWidget *self, dictionary *dict){ password_expiration_date = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordExpirationEntry)); if (!yon_char_is_empty(password_expiration_date)){ - password_expiration_date = yon_char_from_long(window->expiration_unix); + password_expiration_date = window->expiration_unix; } warning_days = yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->userWarningSpin))); @@ -1317,12 +1317,26 @@ void on_user_save(GtkWidget *self, dictionary *dict){ on_subwindow_close(self); } +void on_toggle_button_set_active_from_combo_box(GtkComboBox *self,GtkToggleButton *target){ + if (gtk_combo_box_get_active(self)<=1){ + gtk_toggle_button_set_active(target,0); + gtk_widget_set_sensitive(GTK_WIDGET(target),0); + } +} + +void on_toggle_button_set_active_from_toggle_button_inversed(GtkToggleButton *self, GtkToggleButton *target){ + if (gtk_toggle_button_get_active(self)){ + gtk_toggle_button_set_active(target,0); + } +} + void on_date_selected(GtkWidget *self, ubl_settings_usergroups_user_window *window){ int year=0, month=0, day=0; gtk_calendar_get_date(GTK_CALENDAR(window->ExpirationCalendar),&year,&month,&day); GDateTime *date = g_date_time_new_local(year,month,day,23,59,59); - gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry), g_date_time_format(date,"%c")); - window->expiration_unix=g_date_time_to_unix(date); + char *date_string = g_date_time_format(date,"%Y-%m-%d"); + gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry), date_string); + window->expiration_unix=date_string; } ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(){ @@ -1415,6 +1429,12 @@ ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(){ g_signal_connect(G_OBJECT(window->userUIDAutoCheck),"toggled",G_CALLBACK(yon_gtk_toggle_button_set_inactive_from_toggle_button),window->userCreateSystemCheck); g_signal_connect(G_OBJECT(window->userUIDAutoCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->userCreateUnuniqueCheck); g_signal_connect(G_OBJECT(window->userUIDAutoCheck),"toggled",G_CALLBACK(yon_gtk_toggle_button_set_inactive_from_toggle_button_inversed),window->userCreateUnuniqueCheck); + g_signal_connect(G_OBJECT(window->userSyncSAMBACheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->userSyncSAMBAPasswordCheck); + g_signal_connect(G_OBJECT(window->userSyncSAMBAPasswordCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->userSyncSAMBACheck); + g_signal_connect(G_OBJECT(window->userSyncSAMBACheck),"toggled",G_CALLBACK(on_toggle_button_set_active_from_toggle_button_inversed),window->userSyncSAMBAPasswordCheck); + g_signal_connect(G_OBJECT(window->userSyncSAMBAPasswordCheck),"toggled",G_CALLBACK(on_toggle_button_set_active_from_toggle_button_inversed),window->userSyncSAMBACheck); + g_signal_connect(G_OBJECT(window->userPasswordCombo),"changed",G_CALLBACK(on_toggle_button_set_active_from_combo_box),window->userSyncSAMBAPasswordCheck); + g_signal_connect(G_OBJECT(window->userPasswordCombo),"changed",G_CALLBACK(on_toggle_button_set_active_from_combo_box),window->userSyncSAMBACheck); return window; } @@ -1548,8 +1568,7 @@ void on_main_edit(GtkWidget *self, main_window *widgets){ gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->userWarningSpin),atol(parsed_size>3?parameters[3]:"0")); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->userActivitySpin),atol(parsed_size>4?parameters[4]:"0")); if (parsed_size>5&&!yon_char_is_empty(parameters[5])){ - GDateTime *date = g_date_time_new_from_unix_local(atol(parameters[5])); - gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry),g_date_time_format(date,"%c")); + gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry),parameters[5]); } gtk_window_set_transient_for(GTK_WINDOW(window->CreateUserWindow),GTK_WINDOW(widgets->Window)); gtk_widget_show(window->CreateUserWindow); diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index a6f6563..f010b4c 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -277,7 +277,7 @@ typedef struct{ GtkWidget *userTitleNameLabel; GtkWidget *userSyncSAMBAPasswordCheck; - long expiration_unix; + char *expiration_unix; char *old_password; } ubl_settings_usergroups_user_window;