diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 08670cc..4bf5dd8 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -115,6 +115,7 @@ void config_init(){ main_config.flag_load = 0; main_config.size_array_del_line = 0; main_config.flag_set_data = 0; + main_config.flag_save=0; main_config.i_o_limit_read_size=NULL; main_config.i_o_limit_write_size=NULL; main_config.i_o_limit_write=NULL; @@ -568,7 +569,6 @@ void main_cbx_2_event() { char* cmd = NULL; if (menu_id >= 0) { cmd = yon_char_unite("systemctl status ", cmd_text_param ," --no-pager", NULL); - puts(cmd); yon_terminal_integrated_launch(widgets->vteInformation, cmd, NULL, NULL); } @@ -638,6 +638,7 @@ void tree_view_add(int index) { main_config.cpu_limit_size = philos_int_append(main_config.cpu_limit_size, &main_config.size_tree_view, add_get_limit_cpu_size()); fill_tree_view(main_config.size_tree_view-1, main_config.size_tree_view, 1); main_config.flag_set_data = 1; + main_config.flag_save = 2; } void fill_tree_view(int start, int size, int flag_gui_add) { @@ -722,6 +723,7 @@ int tree_view_edit() { GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->treeViewMain)); if(gtk_tree_selection_get_selected(selection, &model, &iter)) { main_config.flag_set_data = 1; + main_config.flag_save = 2; char* str_iter = gtk_tree_model_get_string_from_iter(model, &iter); index = atoi(str_iter); main_config.soft_raw_limit[index] = edit_get_soft(); @@ -933,11 +935,13 @@ void tree_view_del_line() { gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), model); free(str_iter); main_config.flag_set_data = 1; + main_config.flag_save = 2; } } void wrapper_all_save() { int flag_mess_save = 0; + if (main_config.flag_load == 0) { flag_mess_save = template_format_str_save(CMD_ALL_SAVE, CMD_ALL_REMOVE); } @@ -946,26 +950,31 @@ void wrapper_all_save() { } if (flag_mess_save) { yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); + main_config.flag_save=0; } else { yon_ubl_status_box_render(MESS_NOTHING_SAVE, BACKGROUND_IMAGE_SUCCESS_TYPE); } + } void wrapper_global_save() { if (template_format_str_save(CMD_SAVE_GLOBAL, CMD_REMOVE_GLOBAL)) { yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); + main_config.flag_save-=1; } else { yon_ubl_status_box_render(MESS_NOTHING_SAVE, BACKGROUND_IMAGE_SUCCESS_TYPE); } + } void wrapper_system_save() { if (template_format_str_save(CMD_SAVE_SYSTEM, CMD_REMOVE_SYSTEM)) { yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); + main_config.flag_save-=1; } else { yon_ubl_status_box_render(MESS_NOTHING_SAVE, BACKGROUND_IMAGE_SUCCESS_TYPE); @@ -975,10 +984,7 @@ void wrapper_system_save() { char* save_format_key(int index) { - if (strstr(main_config.quota_volume[index], "-") != NULL) { - return yon_char_unite("CGROUP_QUOTA[", main_config.quota_volume[index] , "]", NULL); - } - return NULL; + return yon_char_unite("CGROUP_QUOTA[", main_config.quota_volume[index] , "]", NULL); } char* save_format_value(int index) { @@ -1070,10 +1076,10 @@ char* add_io_str_format_ubconfig(char* key, int** i_o_limit, int** i_o_limit_s int check_save() { - if (main_config.flag_set_data == 1) { + if (main_config.flag_set_data == 1 || main_config.flag_save>0) { return 0; } - else if (main_config.flag_set_data == 0) { + else if (main_config.flag_set_data == 0 || main_config.flag_save<=0) { return 1; } return 0; @@ -1110,7 +1116,7 @@ char* template_format_str_set_save(char* source_set_cmd) { for (size_t index = 0; index < main_config.size_tree_view; index++) { char* key = save_format_key(index); char* value = save_format_value(index); - if (key != NULL && value != NULL) { + if (strlen(key)>4 && strlen(value) > 4) { cmd = yon_char_unite(cmd, " " , key, "=\"" , value, "\" ", NULL); } if (key != NULL) { @@ -1120,7 +1126,7 @@ char* template_format_str_set_save(char* source_set_cmd) { free(value); } } - if (cmd != NULL && check_save()== 0) { + if (strlen(cmd) > 8 && check_save()== 0) { cmd = yon_char_unite(source_set_cmd, " " ,cmd, NULL); return cmd; } diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h old mode 100644 new mode 100755 index b0485e9..2823e9c --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -44,7 +44,7 @@ #define CMD_GET_GROUP "cut -d: -f1 /etc/group" typedef char *string; -string version_application; +string version_application="1.2"; static char *local; @@ -97,6 +97,7 @@ typedef struct int size_tree_view; int flag_set_data; + int flag_save; int flag_load; // flag_load = 0 -> system // flag_load = 1 -> global } config; diff --git a/ubl-settings-resourcequota.glade b/ubl-settings-resourcequota.glade index f7535b9..5fdca43 100644 --- a/ubl-settings-resourcequota.glade +++ b/ubl-settings-resourcequota.glade @@ -2418,46 +2418,6 @@ - - True - False - dialog-information-symbolic - - - True - False - dialog-question-symbolic - - - True - False - True - combo - - - imagemenuitem - True - False - image2 - False - - - - - - imagemenuitem - True - False - image1 - False - - - - True False @@ -2681,6 +2641,31 @@ translated and supported by community. + + True + False + False + False + + + True + False + + + + + + True + False + + + + True False @@ -2730,7 +2715,6 @@ translated and supported by community. True False - True @@ -3778,7 +3762,7 @@ limit True False - + True True False