diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 0e8be93..1a92013 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; } @@ -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)); @@ -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); } @@ -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); @@ -1163,12 +1163,13 @@ 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); 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)); @@ -1177,6 +1178,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){ @@ -1307,10 +1309,18 @@ 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); - gtk_widget_show(widgets->Window); } - + 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); } diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index 1146aed..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\"" @@ -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); 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