From 88acbfba099cc8bbc484a5802ba81a5dd277a7cb Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 1 Aug 2023 16:41:00 +0600 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BE=D0=B3=D1=80=D0=B0=D0=BD=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=80=D0=B0=D0=B7=D0=BC?= =?UTF-8?q?=D0=B5=D1=80=D0=B0=20=D0=B4=D0=B8=D1=81=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/model/model.h | 1 + source/model/my_device.c | 10 +++++++--- source/model/my_device.h | 1 + source/model/philos_utils.c | 31 +++++++++++++++++++++-------- source/model/philos_utils.h | 1 + source/view_temp_u_g_p.c | 39 ++++++++++++++++++++++++++++++++++++- source/view_temp_u_g_p.h | 3 ++- 7 files changed, 73 insertions(+), 13 deletions(-) diff --git a/source/model/model.h b/source/model/model.h index f96d909..fcc6392 100644 --- a/source/model/model.h +++ b/source/model/model.h @@ -52,6 +52,7 @@ typedef struct{ char* fs; char* mount_point; char* name; + } disk_status; typedef struct{ diff --git a/source/model/my_device.c b/source/model/my_device.c index 10a47f9..8ece330 100644 --- a/source/model/my_device.c +++ b/source/model/my_device.c @@ -8,7 +8,7 @@ vector *get_device_vec() } void device_disk_parsed() { - char *cmd = "findmnt -lo source,target,fstype,label -t ext4"; + char *cmd = "findmnt -lo source,target,fstype,label,size -t ext4"; vector_init(&vec_disk); int size = 0; char **responce = yon_config_load(cmd, &size); @@ -34,7 +34,10 @@ void device_disk_parsed() { obj_device_config->file_system = yon_char_new(name_disk[index_1]); } else if (flag == 3) { - obj_device_config->type_dick = yon_char_new(name_disk[index_1]); + obj_device_config->type_dick = yon_char_new(name_disk[index_1]); + } + else if (flag == 4) { + obj_device_config->size_disk = philos_convert_memory(yon_char_new(name_disk[index_1])); } flag+=1; } @@ -52,7 +55,8 @@ void device_disk_parsed() { } philos_free_string_array(&responce, size); } - + + void device_fill_disk(GtkWidget *combo_box_text, vector* vec_filt) { vector vec; diff --git a/source/model/my_device.h b/source/model/my_device.h index 4fea28b..0c37c15 100644 --- a/source/model/my_device.h +++ b/source/model/my_device.h @@ -12,6 +12,7 @@ typedef struct { char* mounted; char* type_dick; char* description_disk; + size_t size_disk; } device_config; void device_disk_parsed(); diff --git a/source/model/philos_utils.c b/source/model/philos_utils.c index b07d7bd..743f8c2 100644 --- a/source/model/philos_utils.c +++ b/source/model/philos_utils.c @@ -506,14 +506,15 @@ void philos_fill_combo_box_text(GtkWidget *cbt, config_str list_data, int size) void philos_set_spin_adjustment(GtkWidget *check, GtkWidget *spin, GtkWidget *combo, size_t value) { gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check)); - guint value_spin = gtk_spin_button_get_digits(GTK_SPIN_BUTTON(spin)); + //guint value_spin = gtk_spin_button_get_digits(GTK_SPIN_BUTTON(spin)); + guint value_spin = atoi((char*)gtk_entry_get_text(GTK_ENTRY(spin))); if (active != -1) { GtkAdjustment* adjustment = NULL; adjustment = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(spin)); gtk_adjustment_set_lower(adjustment, 0.0); gtk_adjustment_set_page_increment(adjustment, 1.0); if (combo == NULL) { - gtk_adjustment_set_upper(adjustment, (gdouble)(value*100)); + gtk_adjustment_set_upper(adjustment, (value*100)); if ((value*100)quotegroupFilesSoftLimitCheck), "toggled", G_CALLBACK(event_toggled_all), NULL); g_signal_connect(G_OBJECT(temp_widgets->quotegroupFilesHardLimitCheck), "toggled", G_CALLBACK(event_toggled_all), NULL); g_signal_connect(G_OBJECT(temp_widgets->UserDeviceCombo), "changed", G_CALLBACK(temp_select_disk), NULL); + int flag = 3; + g_signal_connect(G_OBJECT(temp_widgets->quotegroupSizeSoftLimitCombo), "changed", G_CALLBACK(update_max_size_spin), &flag); + g_signal_connect(G_OBJECT(temp_widgets->quotegroupSizeHardLimitCombo), "changed", G_CALLBACK(update_max_size_spin), &flag); + g_signal_connect(G_OBJECT(temp_widgets->quotegroupSizeSoftLimitSpin), "changed", G_CALLBACK(update_max_size_spin), NULL); + g_signal_connect(G_OBJECT(temp_widgets->quotegroupSizeHardLimitSpin), "changed", G_CALLBACK(update_max_size_spin), NULL); if (strstr(flag_temp_u_g_p,"prjquota")) { g_signal_connect(G_OBJECT(temp_widgets->btnReviewProject),"clicked",G_CALLBACK(wrapper_show_file_manager),NULL); g_signal_connect(G_OBJECT(temp_widgets->btnGenerateProject),"clicked",G_CALLBACK(generate_id),NULL); @@ -304,6 +309,36 @@ void temp_on_destroy_subwindow(GtkWidget *self) { } } + +void update_max_size_spin(GtkWidget *self, int* flag) { + if (flag) { + gtk_spin_button_set_digits(GTK_SPIN_BUTTON(temp_widgets->quotegroupSizeSoftLimitSpin), 0); + gtk_spin_button_set_digits(GTK_SPIN_BUTTON(temp_widgets->quotegroupSizeHardLimitSpin), 0); + } + char* str_disk = NULL; + if (strcmp(set_add_edit, "add")==0) { + str_disk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(temp_widgets->UserDeviceCombo)); + } + else { + str_disk = (char*)gtk_label_get_label(GTK_LABEL(temp_widgets->lblSetQuotasStatus)); + } + if (!str_disk) { + return; + } + for (int i = 0; i < get_device_vec()->vectorList.total; i++) { + device_config* _config = (device_config*)get_device_vec()->pfVectorGet(get_device_vec(), i); + if (strstr(str_disk, _config->name_disk)) { + philos_set_spin_adjustment(temp_widgets->quotegroupSizeSoftLimitCheck, + temp_widgets->quotegroupSizeSoftLimitSpin, + temp_widgets->quotegroupSizeSoftLimitCombo, _config->size_disk); + philos_set_spin_adjustment(temp_widgets->quotegroupSizeHardLimitCheck, + temp_widgets->quotegroupSizeHardLimitSpin, + temp_widgets->quotegroupSizeHardLimitCombo, _config->size_disk); + } + } + +} + void event_toggled_all() { philos_set_active_widgets(temp_widgets->quotegroupSizeSoftLimitCheck, temp_widgets->quotegroupSizeSoftLimitSpin, @@ -319,6 +354,7 @@ void event_toggled_all() { philos_set_active_widgets(temp_widgets->quotegroupFilesHardLimitCheck, temp_widgets->quotegroupFilesHardLimitSpin, NULL); + update_max_size_spin(NULL, NULL); ; } void block_btn_save() { @@ -621,7 +657,8 @@ void table_u_g_event() { g_signal_connect(G_OBJECT(get_widget_table_u_g()->Window), "destroy", G_CALLBACK(table_u_g_destroy), NULL); } -config_u_g_p* get_temp_gui_data_base(config_u_g_p* _config) { +config_u_g_p* get_temp_gui_data_base(config_u_g_p* _config) { + update_max_size_spin(NULL, NULL); set_widget_config(temp_widgets->quotegroupSizeSoftLimitCheck, temp_widgets->quotegroupSizeSoftLimitSpin, temp_widgets->quotegroupSizeSoftLimitCombo, diff --git a/source/view_temp_u_g_p.h b/source/view_temp_u_g_p.h index a6cbb6e..0ebcf43 100644 --- a/source/view_temp_u_g_p.h +++ b/source/view_temp_u_g_p.h @@ -43,4 +43,5 @@ int wrapper_check_save(); void block_btn_save(); int table_check_save(); void temp_settings(); -void show_warning_no_fill(char* text_mess); \ No newline at end of file +void show_warning_no_fill(char* text_mess); +void update_max_size_spin(GtkWidget *self, int* flag); \ No newline at end of file