From 3681987abf182e900e4a32d3649a7f21120df20b Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 3 Jun 2025 04:56:50 +0000 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 8/9] 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 9/9] 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