diff --git a/source/ubl-settings-usergroups-user.c b/source/ubl-settings-usergroups-user.c index f2548b3..c1cf7dc 100644 --- a/source/ubl-settings-usergroups-user.c +++ b/source/ubl-settings-usergroups-user.c @@ -487,9 +487,17 @@ void on_user_save(GtkWidget *self, dictionary *dict){ password_change_interval_maximum = yon_char_from_long(password_change_interval_maximum_active); } else password_change_interval_maximum = 0; - password_expiration_date = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordExpirationEntry)); + guint year, month, day; + gtk_calendar_get_date(GTK_CALENDAR(window->ExpirationCalendar),&year,&month,&day); + char *dy = yon_char_from_int(day); + char *mn = yon_char_from_int(month+1); + char *yr = yon_char_from_int(year); + if (month+1<10) mn = yon_char_append("0",mn); + if (day<10) dy = yon_char_append("0",dy); + password_expiration_date = yon_char_unite(yr,"-",mn,"-",dy,NULL); + // password_expiration_date = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordExpirationEntry)); if (yon_char_is_empty(password_expiration_date)){ - password_expiration_date="-1"; + password_expiration_date="-1"; } long warning_days_active = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->userWarningSpin)); diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index d9efef4..03faec5 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -1359,12 +1359,12 @@ 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,"%Y-%m-%d"); + date_string = g_date_time_format(date,yon_settings_configuration_get(date_format_parameter)); 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,"%Y-%m-%d"); + expiration_string = g_date_time_format(date,yon_settings_configuration_get(date_format_parameter)); g_date_time_unref(date); } @@ -1465,23 +1465,27 @@ void on_toggle_button_set_active_from_toggle_button_inversed(GtkToggleButton *, void on_date_selected(GtkWidget *, ubl_settings_usergroups_user_window *window){ guint year=0, month=0, day=0; gtk_calendar_get_date(GTK_CALENDAR(window->ExpirationCalendar),&year,&month,&day); - time_t t = time(NULL); - struct tm tm = *localtime(&t); - if ((1900+tm.tm_year)>(int)year||((1900+tm.tm_year)==(int)year&&tm.tm_mon>(int)month)||((1900+tm.tm_year)==(int)year&&tm.tm_mon==(int)month&&tm.tm_mday>(int)day)) { - gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry), ""); + GDateTime *nowdate = g_date_time_new_now_local(); + GDateTime *chosendate = g_date_time_new_local(year,month+1,day,23,59,59); + + if (g_date_time_compare(nowdate,chosendate)>0){ + gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry), ""); + goto comperr; return; } char *dy = yon_char_from_int(day); char *mn = yon_char_from_int(month+1); char *yr = yon_char_from_int(year); - if (month+1<10) mn = yon_char_append("0",mn); - if (day<10) dy = yon_char_append("0",dy); - char *date_string = yon_char_unite(yr,"-",mn,"-",dy,NULL); + 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)); gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry), date_string); window->expiration_unix=date_string; free(dy); free(mn); free(yr); + comperr: + g_date_time_unref(nowdate); + g_date_time_unref(chosendate); } void on_remove_expired(GtkWidget *, GtkEntryIconPosition icon_pos, GdkEvent *, GtkEntry *target){ @@ -2269,6 +2273,10 @@ gboolean on_system_menu_open(GtkWidget *self,GdkEventButton *event, rmb_menu_win return 0; } +void on_date_format_changed(GtkWidget *, main_window *widgets){ + yon_interface_update(widgets); +} + /**yon_main_window_complete(main_window *widgets) * [EN] * @@ -2368,7 +2376,6 @@ template_main_window *yon_main_window_complete(main_window *widgets){ gtk_tree_view_column_clicked(gtk_tree_view_get_column(GTK_TREE_VIEW(widgets->SystemTree),1)); gtk_tree_view_column_clicked(gtk_tree_view_get_column(GTK_TREE_VIEW(widgets->SystemGroupsTree),0)); - yon_system_load(widgets); gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(widgets->ConfigUsersFilter),(GtkTreeModelFilterVisibleFunc)on_filter,widgets,NULL); gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(widgets->ConfigGroupsFilter),(GtkTreeModelFilterVisibleFunc)on_filter,widgets,NULL); gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(widgets->SystemUsersFilter),(GtkTreeModelFilterVisibleFunc)on_filter,widgets,NULL); @@ -2377,8 +2384,6 @@ template_main_window *yon_main_window_complete(main_window *widgets){ yon_root_button_setup((template_main_window*)widgets,main_config.launch_arguments,main_config.launch_size); - yon_load_proceed(YON_CONFIG_LOCAL); - yon_interface_update((main_window*)widgets); gtk_widget_realize(GTK_WIDGET(widgets->UsersTree)); gtk_widget_realize(GTK_WIDGET(widgets->GroupsTree)); @@ -2409,6 +2414,29 @@ template_main_window *yon_main_window_complete(main_window *widgets){ yon_window_config_load(config_path); + yon_ubl_settings_window_init(GTK_MENU(gtk_widget_get_parent(widgets->DocumentationMenuItem))); + GList *menu_items = gtk_container_get_children(GTK_CONTAINER(gtk_widget_get_parent(widgets->DocumentationMenuItem))); + for (guint i=0;i - + - + - + - + - + - + - + - + - + - + - + - + - + - +