Исправил баг с сохранением

pull/4/head
Igor Belitskiy 2 years ago
parent 042511ef93
commit 1ec9283278

@ -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;
}

@ -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;

@ -2418,46 +2418,6 @@
</object>
</child>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">dialog-information-symbolic</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">dialog-question-symbolic</property>
</object>
<object class="GtkMenu" id="menuAbout">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="tearoff-state">True</property>
<property name="menu-type-hint">combo</property>
<child>
<object class="GtkImageMenuItem" id="DocumentationMenuItem">
<property name="label" translatable="yes">imagemenuitem</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="image">image2</property>
<property name="use-stock">False</property>
<style>
<class name="menuitemtop"/>
</style>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="AboutMenuItem">
<property name="label" translatable="yes">imagemenuitem</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="image">image1</property>
<property name="use-stock">False</property>
<style>
<class name="menuitembottom"/>
</style>
</object>
</child>
</object>
<object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -2681,6 +2641,31 @@ translated and supported by community.</property>
<column type="gchararray"/>
</columns>
</object>
<object class="GtkMenu" id="menuAbout">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="take-focus">False</property>
<property name="reserve-toggle-size">False</property>
<child>
<object class="GtkMenuItem" id="DocumentationMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<style>
<class name="menuitemtop"/>
</style>
</object>
</child>
<child>
<object class="GtkMenuItem" id="AboutMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<style>
<class name="menuitemsolo"/>
<class name="menuitembottom"/>
</style>
</object>
</child>
</object>
<object class="GtkMenu" id="menuLoad">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -2730,7 +2715,6 @@ translated and supported by community.</property>
<object class="GtkMenuItem" id="SaveLocalConfigurationMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<style>
<class name="menuitembottom"/>
</style>
@ -3778,7 +3762,7 @@ limit
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkMenuButton" id="btnSaveCfg">
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="focus-on-click">False</property>

Loading…
Cancel
Save