Settings menu added; Date format menu added

pull/271/head
parent d4ef71c5b4
commit 098c79a049
No known key found for this signature in database
GPG Key ID: FF1D842BF4DDE92B

@ -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); password_change_interval_maximum = yon_char_from_long(password_change_interval_maximum_active);
} else password_change_interval_maximum = 0; } 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)){ 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)); long warning_days_active = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->userWarningSpin));

@ -1359,12 +1359,12 @@ void yon_system_load(main_window *window){
if (yon_gtk_list_store_find_text(window->liststore1,&iter,2,parsed[0])){ 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); GDateTime *date = g_date_time_new_from_unix_local(atol(parsed[2])*24*60*60);
char *date_string; 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); g_date_time_unref(date);
char *expiration_string=""; char *expiration_string="";
if (parsed_size>7&&!yon_char_is_empty(parsed[7])){ if (parsed_size>7&&!yon_char_is_empty(parsed[7])){
date = g_date_time_new_from_unix_local(atol(parsed[7])*24*60*60); 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); 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){ void on_date_selected(GtkWidget *, ubl_settings_usergroups_user_window *window){
guint year=0, month=0, day=0; guint year=0, month=0, day=0;
gtk_calendar_get_date(GTK_CALENDAR(window->ExpirationCalendar),&year,&month,&day); gtk_calendar_get_date(GTK_CALENDAR(window->ExpirationCalendar),&year,&month,&day);
time_t t = time(NULL); GDateTime *nowdate = g_date_time_new_now_local();
struct tm tm = *localtime(&t); GDateTime *chosendate = g_date_time_new_local(year,month+1,day,23,59,59);
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), ""); if (g_date_time_compare(nowdate,chosendate)>0){
gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry), "");
goto comperr;
return; return;
} }
char *dy = yon_char_from_int(day); char *dy = yon_char_from_int(day);
char *mn = yon_char_from_int(month+1); char *mn = yon_char_from_int(month+1);
char *yr = yon_char_from_int(year); char *yr = yon_char_from_int(year);
if (month+1<10) mn = yon_char_append("0",mn); GDateTime *datetime = g_date_time_new_local(year,month+1,day,0,0,0);
if (day<10) dy = yon_char_append("0",dy); char *date_string = g_date_time_format(datetime,yon_settings_configuration_get(date_format_parameter));
char *date_string = yon_char_unite(yr,"-",mn,"-",dy,NULL);
gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry), date_string); gtk_entry_set_text(GTK_ENTRY(window->userPasswordExpirationEntry), date_string);
window->expiration_unix=date_string; window->expiration_unix=date_string;
free(dy); free(dy);
free(mn); free(mn);
free(yr); free(yr);
comperr:
g_date_time_unref(nowdate);
g_date_time_unref(chosendate);
} }
void on_remove_expired(GtkWidget *, GtkEntryIconPosition icon_pos, GdkEvent *, GtkEntry *target){ 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; return 0;
} }
void on_date_format_changed(GtkWidget *, main_window *widgets){
yon_interface_update(widgets);
}
/**yon_main_window_complete(main_window *widgets) /**yon_main_window_complete(main_window *widgets)
* [EN] * [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->SystemTree),1));
gtk_tree_view_column_clicked(gtk_tree_view_get_column(GTK_TREE_VIEW(widgets->SystemGroupsTree),0)); 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->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->ConfigGroupsFilter),(GtkTreeModelFilterVisibleFunc)on_filter,widgets,NULL);
gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(widgets->SystemUsersFilter),(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_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->UsersTree));
gtk_widget_realize(GTK_WIDGET(widgets->GroupsTree)); 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_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<g_list_length(menu_items);i++){
if (i==0){
gtk_style_context_remove_class(gtk_widget_get_style_context((GtkWidget*)g_list_nth_data(menu_items,i)),"menuitemmiddle");
gtk_style_context_add_class(gtk_widget_get_style_context((GtkWidget*)g_list_nth_data(menu_items,i)),"menuitemtop");
} else if (i==g_list_length(menu_items)-1){
gtk_style_context_remove_class(gtk_widget_get_style_context((GtkWidget*)g_list_nth_data(menu_items,i)),"menuitemmiddle");
gtk_style_context_remove_class(gtk_widget_get_style_context((GtkWidget*)g_list_nth_data(menu_items,i)),"menuitemtop");
gtk_style_context_add_class(gtk_widget_get_style_context((GtkWidget*)g_list_nth_data(menu_items,i)),"menuitembottom");
} else {
gtk_style_context_remove_class(gtk_widget_get_style_context((GtkWidget*)g_list_nth_data(menu_items,i)),"menuitembottom");
gtk_style_context_remove_class(gtk_widget_get_style_context((GtkWidget*)g_list_nth_data(menu_items,i)),"menuitemtop");
gtk_style_context_add_class(gtk_widget_get_style_context((GtkWidget*)g_list_nth_data(menu_items,i)),"menuitemmiddle");
}
}
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);
yon_system_load(widgets);
yon_load_proceed(YON_CONFIG_LOCAL);
yon_interface_update((main_window*)widgets);
yon_save_window_set_postsave_function(on_save_done,widgets); yon_save_window_set_postsave_function(on_save_done,widgets);
yon_save_window_set_postsave_failure_function(on_save_failed,widgets); yon_save_window_set_postsave_failure_function(on_save_failed,widgets);
return (template_main_window*)widgets; return (template_main_window*)widgets;

@ -163,6 +163,8 @@
#define GROUPADD_SEARCH_macro "GROUPADD[" #define GROUPADD_SEARCH_macro "GROUPADD["
#define GROUPADD_parameter_command yon_char_unite("GROUPADD[",target,"]",NULL) #define GROUPADD_parameter_command yon_char_unite("GROUPADD[",target,"]",NULL)
#define date_format_parameter "DateFormat"
typedef char* string; typedef char* string;
__attribute__((unused)) static \ __attribute__((unused)) static \
@ -618,4 +620,5 @@ void on_user_info_save(GtkWidget *,yon_user_info_window *window);
void on_user_info_print(GtkWidget *,yon_user_info_window *window); void on_user_info_print(GtkWidget *,yon_user_info_window *window);
void yon_shutdown_toggled(GtkWidget *self,ubl_settings_usergroups_additional_settings_window *window); void yon_shutdown_toggled(GtkWidget *self,ubl_settings_usergroups_additional_settings_window *window);
void yon_gtk_tree_view_select_first(GtkTreeView *target); void yon_gtk_tree_view_select_first(GtkTreeView *target);
void on_date_format_changed(GtkWidget *, main_window *widgets);
#endif #endif

@ -290,4 +290,13 @@
#define AUTH_ALLOWED_LABEL _("User auth with password is allowed") #define AUTH_ALLOWED_LABEL _("User auth with password is allowed")
#define AUTH_FORBIDDEN_LABEL _("User auth is forbidden") #define AUTH_FORBIDDEN_LABEL _("User auth is forbidden")
#define AUTH_PASSWORD_LOCKED_LABEL _("User auth with password is blocked for user.\nOther access methods are allowed (key auth, user switching etc).") #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 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")

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 <!-- Generated with glade 3.38.2
ubl-settings-usergroups - ubl-settings-usergroups -
Copyright (C) UBGroup Copyright (C) UBGroup
@ -128,33 +128,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</object> </object>
<object class="GtkListStore" id="liststore1"> <object class="GtkListStore" id="liststore1">
<columns> <columns>
<!-- column-name gboolean1 --> <!-- column-name Locked -->
<column type="gboolean"/> <column type="gboolean"/>
<!-- column-name gint1 --> <!-- column-name uid -->
<column type="gint"/> <column type="gint"/>
<!-- column-name gchararray2 --> <!-- column-name Login -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray3 --> <!-- column-name Username -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray4 --> <!-- column-name PrimaryGroup -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray5 --> <!-- column-name AdditionalGroups -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray6 --> <!-- column-name Homedir -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray1 --> <!-- column-name Shell -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray7 --> <!-- column-name PasshordChangeDate -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray8 --> <!-- column-name ExpireDate -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray9 --> <!-- column-name PasswordIntervalMin -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray10 --> <!-- column-name PasswordIntervalMax -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray11 --> <!-- column-name WarningDays -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name gchararray12 --> <!-- column-name ActivityDays -->
<column type="gchararray"/> <column type="gchararray"/>
</columns> </columns>
</object> </object>

Loading…
Cancel
Save