From 61f283df5d271f39af761bc116e1b1979465ab1c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 30 Sep 2024 15:30:29 +0600 Subject: [PATCH] If GID is written in user's main group, groups list will be scanned for replacing GID with group name --- source/ubl-settings-usergroups.c | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index bbbba4c..c6fafa0 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -876,6 +876,39 @@ void on_groups_clicked(GtkWidget *self, GtkEntry *output_target){ } gtk_tree_view_column_set_visible(gtk_tree_view_get_column(GTK_TREE_VIEW(window->GroupsTree),0),0); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->GroupsTree)),GTK_SELECTION_SINGLE); + const char *current_group=gtk_entry_get_text(output_target); + int digits=0; + for (int k=0;k2&&!strcmp(groups_parsed[2],current_group)){ + final_group_name=yon_char_new(groups_parsed[0]); + if (group_size) yon_char_parsed_free(groups_parsed,group_size); + break; + } + if (group_size) yon_char_parsed_free(groups_parsed,group_size); + } + } else { + final_group_name=yon_char_new(current_group); + } + for_iter(window->list,&iter){ + char *group; + gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,1,&group,-1); + if (!strcmp(group,final_group_name)){ + gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->GroupsTree)),&iter); + gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(window->GroupsTree),gtk_tree_model_get_path(GTK_TREE_MODEL(window->list),&iter),gtk_tree_view_get_column(GTK_TREE_VIEW(window->GroupsTree),1),0,0,0); + break; + } + } dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); yon_dictionary_add_or_create_if_exists_with_data(dict,"output",output_target); @@ -1924,6 +1957,8 @@ void on_user_save(GtkWidget *self, dictionary *dict){ } else { uid_string = (char*)gtk_entry_get_text(GTK_ENTRY(window->userUIDEntry)); if (yon_char_is_empty(uid_string)){ + + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->userUIDEntry); return; @@ -2531,6 +2566,7 @@ void on_main_edit(GtkWidget *self, main_window *widgets){ if (!strcmp(parameters[2],"x")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->userGroupsCheck),1); else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->userGroupsCheck),0); gtk_entry_set_text(GTK_ENTRY(window->userGroupsEntry), parsed_size>2?parameters[2]:""); if (!yon_char_is_empty(parameters[2])) window->last_uid=yon_char_new(parameters[2]);