From 25bc2c8b0acf1f9d79911b5b00176e694c9cc761 Mon Sep 17 00:00:00 2001 From: Ivan Dmitrievich Yartsev Date: Thu, 27 Nov 2025 14:05:18 +0600 Subject: [PATCH] Updated configuration window initiation --- source/ubl-settings-usergroups.c | 14 ++++++++++---- source/ubl-settings-usergroups.h | 1 + source/ubl-strings.h | 8 -------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 1902ef0..571af6c 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -1407,12 +1407,13 @@ void yon_system_load(main_window *window){ if (yon_gtk_list_store_find_text(window->liststore1,&iter,2,parsed[0])){ GDateTime *date = g_date_time_new_from_unix_local(atol(parsed[2])*24*60*60); char *date_string; - date_string = g_date_time_format(date,yon_settings_configuration_get(date_format_parameter)); + char *format = yon_settings_configuration_get(date_format_parameter); + date_string = g_date_time_format(date,format?format:"%d.%m.%Y"); g_date_time_unref(date); char *expiration_string=""; if (parsed_size>7&&!yon_char_is_empty(parsed[7])){ date = g_date_time_new_from_unix_local(atol(parsed[7])*24*60*60); - expiration_string = g_date_time_format(date,yon_settings_configuration_get(date_format_parameter)); + expiration_string = g_date_time_format(date,format?format:"%d.%m.%Y"); g_date_time_unref(date); } @@ -1525,7 +1526,8 @@ void on_date_selected(GtkWidget *, ubl_settings_usergroups_user_window *window){ char *mn = yon_char_from_int(month+1); char *yr = yon_char_from_int(year); GDateTime *datetime = g_date_time_new_local(year,month+1,day,0,0,0); - char *date_string = g_date_time_format(datetime,yon_settings_configuration_get(date_format_parameter)); + char *format = yon_settings_configuration_get(date_format_parameter); + char *date_string = g_date_time_format(datetime,format?format:"%d.%m.%Y"); gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry), date_string); window->expiration_unix=date_string; free(dy); @@ -2468,7 +2470,11 @@ template_main_window *yon_main_window_complete(main_window *widgets){ } } g_list_free(menu_items); - yon_configuration_window_add_combo_box_parameter(CONFIGURATION_PARAMETER_BOOL,date_format_parameter,DATE_FORMAT_SETTINGS_LABEL,G_CALLBACK(on_date_format_changed),widgets,"%d.%m.%Y",DMY_FORMAT_LABEL,"%d-%m-%Y",DMY_MINUS_FORMAT_LABEL,"%d/%m/%Y",DMY_SLASH_FORMAT_LABEL,"%m-%d-%Y",MDY_FORMAT_LABEL,NULL); + struct yon_configuration_window_custom_parameter *parameter = malloc(sizeof(struct yon_configuration_window_custom_parameter)); + parameter->custom_parameter_create_func = yon_date_chooser_new; + parameter->custom_parameter_save_value_func = yon_date_chooser_save; + parameter->custom_parameter_update_func = yon_date_chooser_update; + yon_configuration_window_add_custom_parameter(date_format_parameter,parameter); yon_system_load(widgets); diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index d3f3476..c7e0a4e 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -487,6 +487,7 @@ typedef struct{ GtkToggleButton *defaut_toggle; }; + ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_additional_settings_new(); void on_ubl_settings_usergroups_additional_settings_open(GtkWidget *self, main_window *widgets); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 08b2fc9..ee2fbfe 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -292,14 +292,6 @@ #define AUTH_PASSWORD_LOCKED_LABEL _("User auth with password is blocked for user.\nOther access methods are allowed (key auth, user switching etc).") #define USER_INFORMATION_TOOLTIP_LABEL _("User information") -#define DATE_FORMAT_SETTINGS_LABEL _("Date format:") -#define YEAR_FORMAT_LABEL _("YYYY") -#define MONTH_FORMAT_LABEL _("MM") -#define DAY_FORMAT_LABEL _("DD") -#define DMY_FORMAT_LABEL _("DD.MM.YYYY") -#define DMY_MINUS_FORMAT_LABEL _("DD-MM-YYYY") -#define DMY_SLASH_FORMAT_LABEL _("DD/MM/YYYY") -#define MDY_FORMAT_LABEL _("MM-DD-YYYY") #define HOMEDIR_USED_LABEL _("The selected home directory is used by another user") #define SYSTEM_LANGUAGE_LABEL _("System language:") -- 2.35.1