From 6fd36488983c6ea8868e9faf641da386c06a4d29 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Mon, 31 Jul 2023 11:10:45 +0600 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=83=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=B9=20=D0=B8=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/model/philos_utils.c | 21 +++++++++++++++++---- source/model/philos_utils.h | 4 ++-- source/view_check_user_table.c | 30 +++++++++++++++++++++--------- source/view_check_user_table.h | 1 + ubl-settings-diskquota.glade | 25 +++++++++++++++++++++---- ubl-settings-diskquota.pot | 6 ++++++ ubl-settings-diskquota_ru.po | 8 +++++++- 7 files changed, 75 insertions(+), 20 deletions(-) diff --git a/source/model/philos_utils.c b/source/model/philos_utils.c index 868e8ad..78e67b1 100644 --- a/source/model/philos_utils.c +++ b/source/model/philos_utils.c @@ -132,7 +132,7 @@ void philos_free_int_array_n2(int ***array, int size) { } } -config_str philos_list_user(int* size) { +config_str philos_list_user(int* size, int flag_lim) { char* str_uid_min = "UID_MIN"; char* str_uid_max = "UID_MAX"; unsigned short uid_min = philos_read_uid_min_max(file_source_login_min_max, str_uid_min); @@ -147,9 +147,15 @@ config_str philos_list_user(int* size) { } break; } - if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) { + if (flag_lim == 1) { + if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) { + str_users = yon_char_parsed_append(str_users, size, entry->pw_name); + } + } + else { str_users = yon_char_parsed_append(str_users, size, entry->pw_name); } + } endpwent(); return str_users; @@ -200,7 +206,7 @@ unsigned short philos_read_uid_min_max(char* filename, char* search) { } -config_str philos_list_group(int* size) { +config_str philos_list_group(int* size, int flag_lim) { char* str_uid_min = "UID_MIN"; char* str_uid_max = "UID_MAX"; unsigned short uid_min = philos_read_uid_min_max(file_source_login_min_max, str_uid_min); @@ -215,7 +221,14 @@ config_str philos_list_group(int* size) { } break; } - str_users = yon_char_parsed_append(str_users, size, entry->pw_name); + if (flag_lim == 1) { + if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) { + str_users = yon_char_parsed_append(str_users, size, entry->pw_name); + } + } + else { + str_users = yon_char_parsed_append(str_users, size, entry->pw_name); + } } endpwent(); return str_users; diff --git a/source/model/philos_utils.h b/source/model/philos_utils.h index 43a8926..5a0001d 100644 --- a/source/model/philos_utils.h +++ b/source/model/philos_utils.h @@ -106,8 +106,8 @@ void philos_free_string_array_n3(char ****array, int size); void philos_free_int_array(int **array, int size); void philos_free_int_array_n2(int ***array, int size); unsigned short philos_read_uid_min_max(char* filename, char* search); -config_str philos_list_user(int* size); -config_str philos_list_group(int* size); +config_str philos_list_user(int* size, int flag_lim); +config_str philos_list_group(int* size, int flag_lim); char* philos_str_size_pow_byte(GtkWidget *combo_box_text); char* philos_str_remove(char *str, const char *sub); void philos_split_size_memory(char* str_value, int* size, char* pow_memory); diff --git a/source/view_check_user_table.c b/source/view_check_user_table.c index 1c83605..60c5601 100644 --- a/source/view_check_user_table.c +++ b/source/view_check_user_table.c @@ -14,30 +14,42 @@ table_u_g* get_widget_table_u_g() { return table_widgets; } +void table_u_g_set_fill_user_group() { + int size = 0; + g_object_ref(table_widgets->liststoreUsersGroups); + gtk_list_store_clear(table_widgets->liststoreUsersGroups); + gboolean active1 = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(table_widgets->chkActivUsersGroup)); + if (strcmp(flag_u_g, "grpquota")==0) { + gtk_button_set_label(GTK_BUTTON(table_widgets->chkActivUsersGroup), _("Withdraw all groups")); + char** array_groups = philos_list_group(&size,active1); + table_u_g_fill_tree_view(array_groups, size); + } + else if (strcmp(flag_u_g, "usrquota") == 0) { + gtk_button_set_label(GTK_BUTTON(table_widgets->chkActivUsersGroup), _("Withdraw all users")); + char** array_user = philos_list_user(&size, active1); + table_u_g_fill_tree_view(array_user, size); + } +} + table_u_g *setup_table_u_g(){ /* Widgets getting | Получение виджетов */ table_widgets = malloc(sizeof(table_u_g)); device_disk_parsed(); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); table_widgets->Window = yon_gtk_builder_get_widget(builder,"tableUserGroupWindow"); + table_widgets->chkActivUsersGroup = yon_gtk_builder_get_widget(builder,"chkActivUsersGroup"); table_widgets->btnCancel = yon_gtk_builder_get_widget(builder,"quotegroupCancelButton1"); table_widgets->btnSave = yon_gtk_builder_get_widget(builder,"quotegroupSaveButton1"); table_widgets->treeViewCheckUsersGroups = yon_gtk_builder_get_widget(builder,"treeViewCheckUsersGroups"); table_widgets->checkColUserGroup = GTK_CELL_RENDERER_TOGGLE(gtk_builder_get_object(builder,"checkColUserGroup")); table_widgets->liststoreUsersGroups = GTK_LIST_STORE(gtk_builder_get_object(builder, "liststoreUsersGroups")); - int size = 0; - if (strcmp(flag_u_g, "grpquota")==0) { - char** array_groups = philos_list_group(&size); - table_u_g_fill_tree_view(array_groups, size); - } - else if (strcmp(flag_u_g, "usrquota") == 0) { - char** array_user = philos_list_user(&size); - table_u_g_fill_tree_view(array_user, size); - } + table_u_g_set_fill_user_group(); set_actors(_actors); table_u_g_event(); + g_signal_connect(G_OBJECT(table_widgets->chkActivUsersGroup), "toggled", G_CALLBACK(table_u_g_set_fill_user_group), NULL); } + void table_u_g_set_glade_path(char* _glade_path) { glade_path = _glade_path; } diff --git a/source/view_check_user_table.h b/source/view_check_user_table.h index 0fb656e..485f959 100644 --- a/source/view_check_user_table.h +++ b/source/view_check_user_table.h @@ -21,6 +21,7 @@ typedef struct { GtkWidget* treeViewCheckUsersGroups; GtkListStore* liststoreUsersGroups; GtkCellRendererToggle* checkColUserGroup; + GtkWidget* chkActivUsersGroup; } table_u_g; void table_u_g_table_u_g_event(table_u_g *widgets); diff --git a/ubl-settings-diskquota.glade b/ubl-settings-diskquota.glade index 37d0736..98aabef 100644 --- a/ubl-settings-diskquota.glade +++ b/ubl-settings-diskquota.glade @@ -2674,6 +2674,26 @@ translated and supported by community. True False vertical + + + Withdraw all users + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + False + True + 0 + + True @@ -2691,9 +2711,6 @@ translated and supported by community. True liststoreUsersGroups 0 - - - @@ -2723,7 +2740,7 @@ translated and supported by community. True True - 0 + 1 diff --git a/ubl-settings-diskquota.pot b/ubl-settings-diskquota.pot index d64074e..2892d58 100644 --- a/ubl-settings-diskquota.pot +++ b/ubl-settings-diskquota.pot @@ -410,3 +410,9 @@ msgstr "" msgid "The selected directory is not located on the target device" msgstr "" +msgid "Withdraw all users" +msgstr "" + +msgid "Withdraw all groups" +msgstr "" + diff --git a/ubl-settings-diskquota_ru.po b/ubl-settings-diskquota_ru.po index f2ab9db..b55bb95 100644 --- a/ubl-settings-diskquota_ru.po +++ b/ubl-settings-diskquota_ru.po @@ -410,4 +410,10 @@ msgid "Warning" msgstr "Внимание" msgid "The selected directory is not located on the target device" -msgstr "Выбранный каталог не расположен на целевом устройстве" \ No newline at end of file +msgstr "Выбранный каталог не расположен на целевом устройстве" + +msgid "Withdraw all users" +msgstr "Вывести всех пользователей" + +msgid "Withdraw all groups" +msgstr "Вывести всех группы" \ No newline at end of file