From 3681987abf182e900e4a32d3649a7f21120df20b Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 3 Jun 2025 04:56:50 +0000 Subject: [PATCH 01/14] Optimise out fix --- source/ubl-settings-resourcequota.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 0e8be93..e90e622 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -302,25 +302,25 @@ void on_quotas_save(GtkWidget *self, dictionary *windows){ char *hard = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin))),get_size_mod(GTK_COMBO_BOX(window->HardRestrictionCombo))) : NULL; char *paging = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin))),get_size_mod(GTK_COMBO_BOX(window->PagingLimitCombo))) : NULL; char *cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin))),"%") : NULL; - char *read_limit = ""; - char *read_devices = ""; + char *read_limit = NULL; + char *read_devices = NULL; dictionary *dict; for_dictionaries(dict,window->devices){ if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->read) - read_devices = yon_char_unite(read_devices,"",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,"\n",NULL); + read_devices = yon_char_unite(read_devices?read_devices:"","",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,"\n",NULL); } - if (read_devices[strlen(read_devices)-1]=='\n') read_devices[strlen(read_devices)-1]='\0'; - read_limit = yon_char_unite(read_limit,read_devices,NULL); + if (!yon_char_is_empty(read_devices)&&read_devices[strlen(read_devices)-1]=='\n') read_devices[strlen(read_devices)-1]='\0'; + read_limit = yon_char_unite(read_limit?read_limit:"",read_devices,NULL); - char *write_limit = ""; - char *write_devices = ""; + char *write_limit = NULL; + char *write_devices = NULL; for_dictionaries(dict,window->devices){ if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->write) - write_devices = yon_char_unite(write_devices,"",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,"\n",NULL); + write_devices = yon_char_unite(write_devices?write_devices:"","",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,"\n",NULL); } - if (write_devices[strlen(write_devices)-1]=='\n') write_devices[strlen(write_devices)-1]='\0'; - write_limit = yon_char_unite(write_limit,write_devices,NULL); + if (!yon_char_is_empty(write_devices)&&write_devices[strlen(write_devices)-1]=='\n') write_devices[strlen(write_devices)-1]='\0'; + write_limit = yon_char_unite(write_limit?write_limit:"",write_devices,NULL); gtk_list_store_append(main_config.list,&iter); gtk_list_store_set(main_config.list,&iter,0,type,1,target,2,soft,3,hard,4,paging,5,cpu,6,read_limit,7,write_limit,8,string,-1); yon_config_register(CGROUP_QUOTA((char*)target),CGROUP_QUOTA_comd((char*)target),yon_char_new((char*)string)); -- 2.35.1 From 4a2a4fb71dfa537f113df845c052748c61ea0c5e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 3 Jun 2025 09:16:53 +0000 Subject: [PATCH 02/14] Optimise out fix --- source/ubl-settings-resourcequota.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index e90e622..a193b8b 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -875,25 +875,25 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){ char *hard = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin))),get_size_mod(GTK_COMBO_BOX(window->HardRestrictionCombo))) : NULL; char *paging = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin))),get_size_mod(GTK_COMBO_BOX(window->PagingLimitCombo))) : NULL; char *cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin))),"%") : NULL; - char *read_limit = ""; - char *read_devices = ""; + char *read_limit = NULL; + char *read_devices = NULL; dictionary *dict; for_dictionaries(dict,window->devices){ if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->read) - read_devices = yon_char_unite(read_devices,"",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,"\n",NULL); + read_devices = yon_char_unite(read_devices?read_devices:"","",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,"\n",NULL); } if (read_devices[strlen(read_devices)-1]=='\n') read_devices[strlen(read_devices)-1]='\0'; - read_limit = yon_char_unite(read_limit,read_devices,NULL); + read_limit = yon_char_unite(read_limit?read_limit:"",read_devices,NULL); - char *write_limit = ""; - char *write_devices = ""; + char *write_limit = NULL; + char *write_devices = NULL; for_dictionaries(dict,window->devices){ if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->write) - write_devices = yon_char_unite(write_devices,"",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,"\n",NULL); + write_devices = yon_char_unite(write_devices?write_devices:"","",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,"\n",NULL); } if (write_devices[strlen(write_devices)-1]=='\n') write_devices[strlen(write_devices)-1]='\0'; - write_limit = yon_char_unite(write_limit,write_devices,NULL); + write_limit = yon_char_unite(write_limit?write_limit:"",write_devices,NULL); gtk_list_store_set(main_config.list,&iter,1,target,2,soft,3,hard,4,paging,5,cpu,6,read_limit,7,write_limit,8,string,-1); yon_config_register(CGROUP_QUOTA(target),CGROUP_QUOTA_comd(target),(char*)string); on_subwindow_close(self); -- 2.35.1 From d8c30ebf2c770ddc5cbfa5c511549996737ddc8e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 3 Jun 2025 09:33:50 +0000 Subject: [PATCH 03/14] Global and local config save success message fix --- source/ubl-settings-resourcequota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index a193b8b..b716596 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -17,7 +17,7 @@ void on_save_done(main_window *, config_str output, int size){ case 1: yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); break; - case 2: + case 3: yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); break; } -- 2.35.1 From b4585c4041d60511653219e62a9cdf518cffba22 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 3 Jun 2025 09:34:19 +0000 Subject: [PATCH 04/14] ubl-settings-manager start fix --- source/ubl-settings-resourcequota.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index b716596..d6f22f0 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -1308,7 +1308,6 @@ void yon_main_window_complete(main_window *widgets){ main_config.processes = yon_config_load(get_processes_command,&main_config.processes_size); main_config.slices = yon_config_load(get_slices_command,&main_config.slices_size); on_info_target_type_switched(widgets->TargetTypeCombo,widgets); - gtk_widget_show(widgets->Window); } yon_root_button_setup((template_main_window*)widgets,main_config.launch_arguments,main_config.launch_size); -- 2.35.1 From 9f32471ed8fde6df047d034d237ad0436b350407 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 3 Jun 2025 09:39:33 +0000 Subject: [PATCH 05/14] config load fix --- source/ubl-settings-resourcequota.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index d6f22f0..9b0e02a 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -1309,7 +1309,7 @@ void yon_main_window_complete(main_window *widgets){ main_config.slices = yon_config_load(get_slices_command,&main_config.slices_size); on_info_target_type_switched(widgets->TargetTypeCombo,widgets); } - + on_config_local_load(NULL,widgets); yon_root_button_setup((template_main_window*)widgets,main_config.launch_arguments,main_config.launch_size); yon_save_window_set_postsave_function(on_save_done,widgets); } -- 2.35.1 From 849beaa0bc35514f20b65f1cb66e8e48c9bfd5bf Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 3 Jun 2025 10:10:46 +0000 Subject: [PATCH 06/14] Fixed missing funnel icon --- ubl-settings-resourcequota.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-resourcequota.glade b/ubl-settings-resourcequota.glade index f3c35fe..07598a6 100644 --- a/ubl-settings-resourcequota.glade +++ b/ubl-settings-resourcequota.glade @@ -331,7 +331,7 @@ limit True False - com.ublinux.ubl-settings-resourcequota.funnel-symbolic + com.ublinux.libublsettingsui-gtk3.funnel-symbolic False -- 2.35.1 From 99d275edc5843f82d8b32db4fa0392659116e33c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 3 Jun 2025 11:12:06 +0000 Subject: [PATCH 07/14] Fixed spin button buttons --- source/ubl-settings-resourcequota.c | 3 ++- source/ubl-settings-resourcequota.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 9b0e02a..09a64bd 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -1163,7 +1163,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){ } } -void on_dispatcher_update(GtkWidget *,main_window *widgets){ +gboolean on_dispatcher_update(GtkWidget *,main_window *widgets){ int interval = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->DispatcherUpdateSpin)); if (interval>0) { char* str_second = yon_char_from_int(interval); @@ -1177,6 +1177,7 @@ void on_dispatcher_update(GtkWidget *,main_window *widgets){ g_object_set_property(G_OBJECT(widgets->DispatcherUpdateSpin),"has-focus",val); g_free(val); } + return 0; } void on_processes_update(GtkWidget *,main_window *widgets){ diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index 1146aed..1056df7 100644 --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -189,7 +189,7 @@ void config_init(); void on_info_target_type_switched(GtkWidget *self, main_window *widgets); void on_tab_changed(GtkWidget *self, GtkWidget *page, int page_num, main_window *widgets); void on_processes_update(GtkWidget *self,main_window *widgets); -void on_dispatcher_update(GtkWidget *self,main_window *widgets); +gboolean on_dispatcher_update(GtkWidget *self,main_window *widgets); void on_edit_open(GtkWidget *self, main_window *widgets); void on_quotas_edit(GtkWidget *self, dictionary *windows); void on_remove(GtkWidget *self, main_window *widgets); -- 2.35.1 From bcf6239f728e5b2c851a900a872a38d1c6890c77 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 3 Jun 2025 11:44:47 +0000 Subject: [PATCH 08/14] Command changed --- source/ubl-settings-resourcequota.c | 7 ++++--- source/ubl-settings-resourcequota.h | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 09a64bd..b3673ce 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -801,7 +801,7 @@ void on_add_open(GtkWidget *, main_window *widgets){ void on_information_chosen_changed(GtkWidget *self, main_window *widgets){ const char *chosen = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(self)); if (chosen){ - char *command = yon_char_unite(get_information_command, (char*)chosen," --no-pager",NULL); + char *command = get_information_command((char*)chosen); main_config.last_info = yon_char_new((char*)chosen); vte_terminal_reset(VTE_TERMINAL(widgets->InformationTerminal),1,1); yon_terminal_integrated_start(widgets->InformationTerminal, command); @@ -824,7 +824,7 @@ void on_information(GtkWidget *, main_window *widgets){ } gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->TargetCombo),yon_gtk_combo_box_text_find(widgets->TargetCombo,name)); g_signal_handlers_unblock_by_func(G_OBJECT(widgets->TargetCombo),on_information_chosen_changed,widgets); - char *command = yon_char_unite(get_information_command, (char*)name," --no-pager",NULL); + char *command = get_information_command((char*)name); main_config.last_info = yon_char_new((char*)name); vte_terminal_reset(VTE_TERMINAL(widgets->InformationTerminal),1,1); yon_terminal_integrated_start(widgets->InformationTerminal, command); @@ -835,7 +835,7 @@ void on_information(GtkWidget *, main_window *widgets){ } void on_information_update(GtkWidget *, main_window *widgets){ - char *command = yon_char_unite(get_information_command, main_config.last_info," --no-pager",NULL); + char *command = get_information_command(main_config.last_info); vte_terminal_reset(VTE_TERMINAL(widgets->InformationTerminal),1,1); yon_terminal_integrated_start(widgets->InformationTerminal, command); } @@ -1169,6 +1169,7 @@ gboolean on_dispatcher_update(GtkWidget *,main_window *widgets){ char* str_second = yon_char_from_int(interval); char *command = yon_char_unite(get_dispatcher_command," -d ",str_second,NULL); if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->DispatcherUpdateCheck))) command = yon_char_append(command," -n 1"); + vte_terminal_reset(VTE_TERMINAL(widgets->DispatcherTerminal),1,1); yon_terminal_integrated_start_shell(widgets->DispatcherTerminal, command,NULL,NULL); free(str_second); GValue *val = g_malloc0(sizeof(GValue)); diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index 1056df7..dc299b4 100644 --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -39,10 +39,10 @@ // #define remove_command "ubconfig remove security " // #define remove_global_command "ubconfig --target global --noexecute remove security " // #define remove_local_command "ubconfig --target system remove security " -#define get_devices_command "findmnt -lo source,target,fstype,label,size -t ext4 |grep -vE \"zram|\\]|\\[|SOURCE\"" +#define get_devices_command "clear;findmnt -lo source,target,fstype,label,size -t ext4 |grep -vE \"zram|\\]|\\[|SOURCE\"" #define get_processes_tree_command "clear; systemd-cgls --no-page" -#define get_dispatcher_command "clear; systemd-cgtop" -#define get_information_command "systemctl status " +#define get_dispatcher_command "clear; systemd-cgtop -c" +#define get_information_command(target) yon_char_unite("systemctl status ",target,".slice --no-pager",NULL) #define get_processes_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.service\"" #define get_slices_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.slice\"" -- 2.35.1 From 8185dfcbfa7fa99b46fa8d2da1433b6cf6be163d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 3 Jun 2025 12:02:30 +0000 Subject: [PATCH 09/14] Fixed slice --- source/ubl-settings-resourcequota.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index b3673ce..1a92013 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -1309,6 +1309,15 @@ void yon_main_window_complete(main_window *widgets){ main_config.users = yon_ubl_get_all_users(&main_config.users_size); main_config.processes = yon_config_load(get_processes_command,&main_config.processes_size); main_config.slices = yon_config_load(get_slices_command,&main_config.slices_size); + for(int i=0;iTargetTypeCombo,widgets); } on_config_local_load(NULL,widgets); -- 2.35.1 From 367ce507600d12f5290362a9033a24d03f55c7fb Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 4 Jun 2025 09:44:59 +0000 Subject: [PATCH 10/14] Test fix for quota --- source/ubl-settings-resourcequota.c | 20 +++++++++++++++----- source/ubl-settings-resourcequota.h | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 1a92013..cf996b7 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -217,8 +217,10 @@ void yon_get_devices(quota_window *window){ config_str devices_parsed = yon_config_load(get_devices_command,&size); for (int i=0; idevices,devices_parsed[i],NULL); + char *pa = strstr(devices_parsed[i],"/"); + yon_dictionary_add_or_create_if_exists_with_data(window->devices,pa,NULL); } + yon_char_parsed_free(devices_parsed,size); } void on_device_current_changed(GtkWidget *, quota_window *window){ @@ -761,8 +763,8 @@ void on_add_open(GtkWidget *, main_window *widgets){ g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitWriteCombo); g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitWriteSpin); - g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),window->DeviceLimitReadCheck); - g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),window->DeviceLimitWriteCheck); + g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitReadCheck); + g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitWriteCheck); g_signal_connect(G_OBJECT(window->SoftRestrictionSpin),"output",G_CALLBACK(on_quota_configuration_update),window); g_signal_connect(G_OBJECT(window->SoftRestrictionCombo),"changed",G_CALLBACK(on_quota_configuration_update),window); @@ -902,6 +904,14 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){ else yon_ubl_status_box_render(NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } +void yon_widget_set_sensitive(GtkComboBox *toggle, GtkWidget *target){ + if (gtk_combo_box_get_active(toggle)>-1){ + gtk_widget_set_sensitive(target,1); + } else { + gtk_widget_set_sensitive(target,0); + } +} + void on_edit_open(GtkWidget *, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); GtkTreeIter iter; @@ -1024,8 +1034,8 @@ void on_edit_open(GtkWidget *, main_window *widgets){ g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitWriteCombo); g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitWriteSpin); - g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),window->DeviceLimitReadCheck); - g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),window->DeviceLimitWriteCheck); + g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitReadCheck); + g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitWriteCheck); yon_get_devices(window); dictionary *dict; diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index dc299b4..3f6daf2 100644 --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -220,4 +220,5 @@ void on_check_maximum_cpu(GtkWidget *self, GtkWidget *pair); void on_check_maximum(GtkWidget *self, GtkWidget *pair); void on_limit_manual_input(GtkWidget *self, double *new_value, quota_window *window); void on_quota_configuration_update(GtkWidget *self, quota_window *window); -void on_device_limits_update(GtkWidget *, quota_window *window); \ No newline at end of file +void on_device_limits_update(GtkWidget *, quota_window *window); +void yon_widget_set_sensitive(GtkComboBox *toggle, GtkWidget *target); \ No newline at end of file -- 2.35.1 From cca806a303dd7419387976001b143246ab32a2fc Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 5 Jun 2025 04:20:40 +0000 Subject: [PATCH 11/14] Fixed devices saving --- source/ubl-settings-resourcequota.c | 197 +++++++++++++++---------- source/ubl-settings-resourcequota.h | 4 +- source/ubl-strings.h | 2 + ubl-settings-resourcequota-quota.glade | 102 ++++++------- 4 files changed, 179 insertions(+), 126 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index cf996b7..266ae1f 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -53,9 +53,8 @@ void on_device_limits_update(GtkWidget *, quota_window *window){ } } -void on_quota_configuration_update(GtkWidget *self, quota_window *window){ +void on_quota_configuration_update(GtkWidget *, quota_window *window){ char *output_line = NULL; - on_device_limits_update(self,window); long sft = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin)); long hrd = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin)); long pgl = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin)); @@ -218,74 +217,111 @@ void yon_get_devices(quota_window *window){ for (int i=0; idevices,pa,NULL); + char *device_name = yon_char_new(pa); + char *id = yon_char_divide_search(device_name," ",-1); + free(device_name); + device_limits *limits = malloc(sizeof(device_limits)); + limits->device_name = yon_char_new(pa); + limits->read=NULL; + limits->write=NULL; + yon_dictionary_add_or_create_if_exists_with_data(window->devices,id,limits); } yon_char_parsed_free(devices_parsed,size); } -void on_device_current_changed(GtkWidget *, quota_window *window){ - char *chosen = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo)); - if (!window->devices->data){ - printf("%s\n",gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo))); - yon_dictionary_get(&window->devices,chosen); - if (!window->devices->data){ - window->devices->data = g_malloc0(sizeof(device_limits)); - } - ((device_limits*)window->devices->data)->write=NULL; - ((device_limits*)window->devices->data)->read=NULL; - } else { - long read_lim = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin)); - long write_lim = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin)); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck))){ - if (read_lim) yon_dictionary_get_data(window->devices,device_limits*)->read=yon_char_append(yon_char_from_long(read_lim),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitReadCombo))); - } else yon_dictionary_get_data(window->devices,device_limits*)->read = NULL; - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck))){ - if (write_lim) yon_dictionary_get_data(window->devices,device_limits*)->write=yon_char_append(yon_char_from_long(write_lim),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitWriteCombo))); - } else yon_dictionary_get_data(window->devices,device_limits*)->write = NULL; - yon_dictionary_get(&window->devices,chosen); - if (!window->devices->data){ - window->devices->data = g_malloc0(sizeof(device_limits)); - } - ((device_limits*)window->devices->data)->write=NULL; - ((device_limits*)window->devices->data)->read=NULL; - char *read = yon_dictionary_get_data(window->devices,device_limits*)->read; - char *write = yon_dictionary_get_data(window->devices,device_limits*)->write; - if (read) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),atoi(read)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1); - switch (read[strlen(read)-1]){ - case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0); - break; - case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),1); - break; - case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),2); - break; - case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),3); - break; +void on_device_set(GtkWidget *self, quota_window *window){ + char *id = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->DeviceLimitCombo)); + if (!yon_char_is_empty(id)){ + dictionary *current = yon_dictionary_get(&window->devices,id); + if (current){ + device_limits *limits = yon_dictionary_get_data(current,device_limits*); + if (self == window->DeviceLimitReadCheck||self == window->DeviceLimitReadSpin||self == window->DeviceLimitReadCombo){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck))){ + long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin)); + if (!value) { + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->DeviceLimitReadSpin); + return; + } + char *value_str = yon_char_from_long(value); + char *full_str = yon_char_unite(value_str,yon_size_get_mod(gtk_combo_box_get_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo))),NULL); + if (!yon_char_is_empty(limits->read)) free(limits->read); + limits->read=full_str; + } else { + limits->read=NULL; + } + } else if (self == window->DeviceLimitWriteCheck||self == window->DeviceLimitWriteSpin||self == window->DeviceLimitWriteCombo){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck))){ + long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin)); + if (!value) { + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->DeviceLimitWriteSpin); + return; + } + char *value_str = yon_char_from_long(value); + char *full_str = yon_char_unite(value_str,yon_size_get_mod(gtk_combo_box_get_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo))),NULL); + if (!yon_char_is_empty(limits->read)) free(limits->read); + limits->read=full_str; + } else { + limits->read=NULL; + } } - } else { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),0); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),0); - gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0); } - if (write) { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),atoi(write)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1); - switch (write[strlen(write)-1]){ - case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0); - break; - case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),1); - break; - case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),2); - break; - case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),3); - break; + } +} + +void on_device_current_changed(GtkWidget *, quota_window *window){ + char *chosen = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->DeviceLimitCombo)); + if (!yon_char_is_empty(chosen)){ + dictionary *current = yon_dictionary_get(&window->devices,chosen); + if (current){ + device_limits *limits = yon_dictionary_get_data(current,device_limits*); + char *read = limits->read; + char *write = limits->write; + if (!yon_char_is_empty(read)) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),atoi(read)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1); + switch (read[strlen(read)-1]){ + case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0); + break; + case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),1); + break; + case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),2); + break; + case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),3); + break; + } + } else { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0); + } + if (!yon_char_is_empty(write)) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),atoi(write)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1); + switch (write[strlen(write)-1]){ + case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0); + break; + case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),1); + break; + case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),2); + break; + case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),3); + break; + } + } else { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0); } - } else { - gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),0); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),0); - gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0); } + } else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0); } } @@ -314,7 +350,6 @@ void on_quotas_save(GtkWidget *self, dictionary *windows){ if (!yon_char_is_empty(read_devices)&&read_devices[strlen(read_devices)-1]=='\n') read_devices[strlen(read_devices)-1]='\0'; read_limit = yon_char_unite(read_limit?read_limit:"",read_devices,NULL); - char *write_limit = NULL; char *write_devices = NULL; for_dictionaries(dict,window->devices){ @@ -539,7 +574,7 @@ void on_quota_manual_input(GtkWidget *self, quota_window *window){ char *name = yon_char_divide_search(value, " ",-1); dictionary *dict; for_dictionaries(dict,window->devices){ - if (strstr(dict->key,name)){ + if (!strcmp(dict->key,name)){ if (!((device_limits*)dict->data)){ dict->data = g_malloc0(sizeof(device_limits)); ((device_limits*)dict->data)->write=NULL; @@ -553,7 +588,7 @@ void on_quota_manual_input(GtkWidget *self, quota_window *window){ char *name = yon_char_divide_search(value, " ",-1); dictionary *dict; for_dictionaries(dict,window->devices){ - if (strstr(dict->key,name)){ + if (!strcmp(dict->key,name)){ if (!((device_limits*)dict->data)){ dict->data = g_malloc0(sizeof(device_limits)); ((device_limits*)dict->data)->write=NULL; @@ -738,6 +773,12 @@ void on_add_open(GtkWidget *, main_window *widgets){ gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin)),main_config.avaliable_ram); g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(on_device_current_changed),window); + g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(on_device_set),window); + g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"value-changed",G_CALLBACK(on_device_set),window); + g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_device_set),window); + g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(on_device_set),window); + g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"value-changed",G_CALLBACK(on_device_set),window); + g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_device_set),window); g_signal_connect(G_OBJECT(window->TargetCombo),"changed",G_CALLBACK(on_target_check_chosen),window); g_signal_connect(G_OBJECT(window->SoftRestrictionSpin),"change-value",G_CALLBACK(on_check_maximum),window->SoftRestrictionCombo); @@ -789,7 +830,8 @@ void on_add_open(GtkWidget *, main_window *widgets){ yon_get_devices(window); dictionary *dict; for_dictionaries(dict,window->devices){ - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key); + char *temp = yon_char_new(yon_dictionary_get_data(dict,device_limits*)->device_name); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key,temp); } main_config.users = yon_ubl_get_all_users(&main_config.users_size); main_config.processes = yon_config_load(get_processes_command,&main_config.processes_size); @@ -882,7 +924,7 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){ dictionary *dict; for_dictionaries(dict,window->devices){ if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->read) - read_devices = yon_char_unite(read_devices?read_devices:"","",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,"\n",NULL); + read_devices = yon_char_unite(read_devices?read_devices:"","",dict->key," ",yon_dictionary_get_data(dict,device_limits*)->read,"\n",NULL); } if (read_devices[strlen(read_devices)-1]=='\n') read_devices[strlen(read_devices)-1]='\0'; read_limit = yon_char_unite(read_limit?read_limit:"",read_devices,NULL); @@ -892,7 +934,7 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){ char *write_devices = NULL; for_dictionaries(dict,window->devices){ if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->write) - write_devices = yon_char_unite(write_devices?write_devices:"","",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,"\n",NULL); + write_devices = yon_char_unite(write_devices?write_devices:"","",dict->key," ",yon_dictionary_get_data(dict,device_limits*)->write,"\n",NULL); } if (write_devices[strlen(write_devices)-1]=='\n') write_devices[strlen(write_devices)-1]='\0'; write_limit = yon_char_unite(write_limit?write_limit:"",write_devices,NULL); @@ -1040,18 +1082,19 @@ void on_edit_open(GtkWidget *, main_window *widgets){ yon_get_devices(window); dictionary *dict; gtk_widget_set_sensitive(window->BlockUiBox,1); - gtk_label_set_text(GTK_LABEL(window->TargetLabel),target); + gtk_label_set_markup(GTK_LABEL(window->TargetLabel),yon_char_unite(type," ",target,"",NULL)); int read_size=0; config_str read_parsed = yon_char_parse(read,&read_size,"\n"); int write_size=0; config_str write_parsed = yon_char_parse(write,&write_size,"\n"); for_dictionaries(dict,window->devices){ - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key); + char *temp = yon_char_new(yon_dictionary_get_data(dict,device_limits*)->device_name); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key,temp); if (read_parsed) for (int i=0; ikey,read_cur)){ + if (strstr(temp,read_cur)){ if(!dict->data){ dict->data = g_malloc0(sizeof(device_limits)); ((device_limits*)dict->data)->write=NULL; @@ -1063,7 +1106,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){ else{ char *read_limit = yon_char_new(read); char *read_cur = yon_char_divide_search(read_limit," ",-1); - if (strstr(dict->key,read_cur)){ + if (strstr(temp,read_cur)){ if(!dict->data){ dict->data = g_malloc0(sizeof(device_limits)); ((device_limits*)dict->data)->write=NULL; @@ -1076,7 +1119,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){ for (int i=0; ikey,write_cur)){ + if (strstr(temp,write_cur)){ if(!dict->data){ dict->data = g_malloc0(sizeof(device_limits)); ((device_limits*)dict->data)->write=NULL; @@ -1088,7 +1131,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){ else{ char *write_limit = yon_char_new(write); char *write_cur = yon_char_divide_search(write_limit," ",-1); - if (strstr(dict->key,write_cur)){ + if (strstr(temp,write_cur)){ if(!dict->data){ dict->data = g_malloc0(sizeof(device_limits)); ((device_limits*)dict->data)->write=NULL; @@ -1103,6 +1146,12 @@ void on_edit_open(GtkWidget *, main_window *widgets){ window->devices=window->devices->first; gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitCombo),0); g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(on_device_current_changed),window); + g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(on_device_set),window); + g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"value-changed",G_CALLBACK(on_device_set),window); + g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_device_set),window); + g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(on_device_set),window); + g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"value-changed",G_CALLBACK(on_device_set),window); + g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_device_set),window); if (((device_limits*)window->devices->data)->read&&strcmp(((device_limits*)window->devices->data)->read,"")!=0){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1); char *rd = ((device_limits*)window->devices->data)->read; diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index 3f6daf2..b54cf4e 100644 --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -177,6 +177,7 @@ typedef struct { } filters_window; typedef struct { + char *device_name; char *read; char *write; } device_limits; @@ -221,4 +222,5 @@ void on_check_maximum(GtkWidget *self, GtkWidget *pair); void on_limit_manual_input(GtkWidget *self, double *new_value, quota_window *window); void on_quota_configuration_update(GtkWidget *self, quota_window *window); void on_device_limits_update(GtkWidget *, quota_window *window); -void yon_widget_set_sensitive(GtkComboBox *toggle, GtkWidget *target); \ No newline at end of file +void yon_widget_set_sensitive(GtkComboBox *toggle, GtkWidget *target); +void on_device_set(GtkWidget *self, quota_window *window); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 0915a56..8f641a7 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -87,6 +87,8 @@ #define VIEW_PROPERTIES_LABEL _("View properties for") +#define EMPTY_IMPORTANT_LABEL _("Important field is empty") + #define REMOVE_TITLE_LABEL _("Remove quota") #define REMOVE_VALIDATION_LABEL(target) yon_char_unite(_("Are you sure you want to remove quota")," ",target,"?",NULL) #define ADDING_LABEL _("Add quota") diff --git a/ubl-settings-resourcequota-quota.glade b/ubl-settings-resourcequota-quota.glade index 302ac46..5b73aea 100644 --- a/ubl-settings-resourcequota-quota.glade +++ b/ubl-settings-resourcequota-quota.glade @@ -3,6 +3,57 @@ + + 1 + 1 + 1 + 1 + 10 + + + 1 + 1 + 1 + 1 + 10 + + + 1 + 1 + 1 + 1 + 10 + + + 1 + 1 + 1 + 1 + 10 + + + 1 + 1 + 1 + 1 + 10 + + + 1 + 1 + 1 + 10 + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + False start @@ -941,55 +992,4 @@ - - 1 - 1 - 1 - 1 - 10 - - - 1 - 1 - 1 - 1 - 10 - - - 1 - 1 - 1 - 1 - 10 - - - 1 - 1 - 1 - 1 - 10 - - - 1 - 1 - 1 - 1 - 10 - - - 1 - 1 - 1 - 10 - - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - -- 2.35.1 From 8c80927fde8f89183cc161c059725ec8924572e3 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 5 Jun 2025 04:41:51 +0000 Subject: [PATCH 12/14] Quota add processes and slices fix --- source/ubl-settings-resourcequota.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 266ae1f..f21aafe 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -836,6 +836,15 @@ void on_add_open(GtkWidget *, main_window *widgets){ main_config.users = yon_ubl_get_all_users(&main_config.users_size); main_config.processes = yon_config_load(get_processes_command,&main_config.processes_size); main_config.slices = yon_config_load(get_slices_command,&main_config.slices_size); + for(int i=0;iTargetCombo),main_config.users[i]); } -- 2.35.1 From 1fed41b8f01b0fcf4c7646a7cb074926856c38c4 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 5 Jun 2025 04:55:15 +0000 Subject: [PATCH 13/14] paddings fixes --- ubl-settings-resourcequota-quota.glade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ubl-settings-resourcequota-quota.glade b/ubl-settings-resourcequota-quota.glade index 5b73aea..54d72b9 100644 --- a/ubl-settings-resourcequota-quota.glade +++ b/ubl-settings-resourcequota-quota.glade @@ -156,6 +156,8 @@ False + 5 + 5 5 -- 2.35.1 From 574a8d531952a9f64e11567955afe7192d3ab73c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 5 Jun 2025 10:58:15 +0000 Subject: [PATCH 14/14] Fixed editing --- source/ubl-settings-resourcequota.c | 4 +++- source/ubl-settings-resourcequota.h | 1 + ubl-settings-resourcequota-quota.glade | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index f21aafe..ef69879 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -1005,6 +1005,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){ window->EditQuotaTargetBox = yon_gtk_builder_get_widget(builder,"EditQuotaTargetBox"); window->TargetCombo = yon_gtk_builder_get_widget(builder,"TargetCombo"); window->TargetLabel = yon_gtk_builder_get_widget(builder,"TargetLabel"); + window->TypeLabel = yon_gtk_builder_get_widget(builder,"TypeLabel"); window->SoftRestrictionCheck = yon_gtk_builder_get_widget(builder,"SoftRestrictionCheck"); window->SoftRestrictionSpin = yon_gtk_builder_get_widget(builder,"SoftRestrictionSpin"); @@ -1091,7 +1092,8 @@ void on_edit_open(GtkWidget *, main_window *widgets){ yon_get_devices(window); dictionary *dict; gtk_widget_set_sensitive(window->BlockUiBox,1); - gtk_label_set_markup(GTK_LABEL(window->TargetLabel),yon_char_unite(type," ",target,"",NULL)); + gtk_label_set_text(GTK_LABEL(window->TypeLabel),type); + gtk_label_set_text(GTK_LABEL(window->TargetLabel),target); int read_size=0; config_str read_parsed = yon_char_parse(read,&read_size,"\n"); int write_size=0; diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index b54cf4e..ce9d9e0 100644 --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -136,6 +136,7 @@ typedef struct { GtkWidget *TargetTypeCombo; GtkWidget *TargetCombo; GtkWidget *TargetLabel; + GtkWidget *TypeLabel; GtkWidget *SoftRestrictionCheck; GtkWidget *SoftRestrictionSpin; GtkWidget *SoftRestrictionCombo; diff --git a/ubl-settings-resourcequota-quota.glade b/ubl-settings-resourcequota-quota.glade index 54d72b9..3f808c8 100644 --- a/ubl-settings-resourcequota-quota.glade +++ b/ubl-settings-resourcequota-quota.glade @@ -172,9 +172,10 @@ - + True False + label False @@ -182,6 +183,20 @@ 1 + + + True + False + + + + + + False + True + 2 + + False -- 2.35.1