diff --git a/source/ubl-settings-usergroups-settings.c b/source/ubl-settings-usergroups-settings.c index 5a0aada..1479b82 100644 --- a/source/ubl-settings-usergroups-settings.c +++ b/source/ubl-settings-usergroups-settings.c @@ -390,6 +390,8 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ window->GroupMinCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"GroupMinCell")); window->GroupMaxCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"GroupMaxCell")); + yon_gtk_login_block_symbols(GTK_ENTRY(window->DefaultUserNameEntry)); + yon_gtk_revealer_set_from_expander(GTK_REVEALER(window->UserShutdownRevealer),GTK_EXPANDER(window->UsersShutdownExpander)); yon_gtk_revealer_set_from_expander(GTK_REVEALER(window->GroupShutdownRevealer),GTK_EXPANDER(window->GroupsShutdownExpander)); diff --git a/source/ubl-settings-usergroups-user.c b/source/ubl-settings-usergroups-user.c index 1b51851..3378695 100644 --- a/source/ubl-settings-usergroups-user.c +++ b/source/ubl-settings-usergroups-user.c @@ -1,5 +1,33 @@ #include "ubl-settings-usergroups.h" +void on_login_insert_custom_restricted_check(GtkEditable *editable, const gchar *text, gint length, gint *position){ + gchar *new_text = g_new(gchar, length + 1); + memset(new_text,0,length+1); + gint i, j = 0; + + + for (i = 0; i < length; i++) { + if ((text[i]>='a'&&text[i]<='z')||(text[i]>='0'&&text[i]<='9')||strchr("_-",text[i])) { + new_text[j] = text[i]; + j++; + } + } + + if (j < length) { + g_signal_handlers_block_by_func(editable, G_CALLBACK(on_login_insert_custom_restricted_check), NULL); + gtk_editable_insert_text(editable, new_text, j, position); + g_signal_handlers_unblock_by_func(editable, G_CALLBACK(on_login_insert_custom_restricted_check), NULL); + g_signal_stop_emission_by_name(editable, "insert-text"); + } + + g_free(new_text); +} + +void yon_gtk_login_block_symbols(GtkEntry *target){ + g_return_if_fail(GTK_IS_ENTRY(target)); + g_signal_connect(G_OBJECT(target),"insert-text",G_CALLBACK(on_login_insert_custom_restricted_check),NULL); +} + void on_parameter_changed(GtkWidget *,ubl_settings_usergroups_user_window *window){ char *user_shell=NULL; char *user_home=NULL; @@ -130,6 +158,7 @@ ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(){ window->MainNotebook=yon_gtk_builder_get_widget(builder,"MainNotebook"); window->expiration_unix=NULL; window->last_uid=NULL; + yon_gtk_entry_block_symbols(GTK_ENTRY(window->userUserNameEntry),":"); time_t t = time(NULL); struct tm tm = *localtime(&t); diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index 37af024..c2bc9f2 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -562,4 +562,6 @@ void on_additional_settings_cell_toggled(GtkCellRenderer *self, char *path, ubl_ void on_additional_settings_cell_edited(GtkCellRenderer *self, char *path, char *new_text, ubl_settings_usergroups_additional_settings_window *window); void on_adiitional_settings_tree_selection_changed(GtkWidget *self, ubl_settings_usergroups_additional_settings_window *window); void on_useradd_sync_changed(ubl_settings_usergroups_additional_settings_window *window); +void yon_gtk_login_block_symbols(GtkEntry *target); +void on_login_insert_custom_restricted_check(GtkEditable *editable, const gchar *text, gint length, gint *position); #endif \ No newline at end of file diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade index 6772a79..e2a11e8 100644 --- a/ubl-settings-usergroups-additional-settings.glade +++ b/ubl-settings-usergroups-additional-settings.glade @@ -76,8 +76,8 @@ False Group GID range - - + + True True False @@ -90,8 +90,8 @@ False Group GID in system - - + + True True False @@ -176,8 +176,8 @@ False Users UID range - - + + True True False @@ -190,8 +190,8 @@ False User UID in system - - + + True True False @@ -321,6 +321,7 @@ True True + 32 superadmin