|
|
|
@ -113,6 +113,8 @@ void config_init(){
|
|
|
|
|
main_config.lock_save_global=0;
|
|
|
|
|
main_config.lock_save_local=0;
|
|
|
|
|
main_config.size_tree_view = 0;
|
|
|
|
|
main_config.flag_load = 0;
|
|
|
|
|
main_config.size_array_del_line = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main_window *setup_window(){
|
|
|
|
@ -254,11 +256,13 @@ void main_update_information() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void load_system_cfg() {
|
|
|
|
|
main_config.flag_load = 0;
|
|
|
|
|
template_cfg(CMD_LOAD_SYSTEM, main_config.load_system_cfg);
|
|
|
|
|
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS, BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void load_global_cfg() {
|
|
|
|
|
main_config.flag_load = 1;
|
|
|
|
|
template_cfg(CMD_LOAD_GLOBAL, main_config.load_global_cfg);
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
@ -273,6 +277,8 @@ void clear_array() {
|
|
|
|
|
philos_free_string_array(&main_config.i_o_limit_read , main_config.size_tree_view);
|
|
|
|
|
philos_free_string_array(&main_config.i_o_limit_write , main_config.size_tree_view);
|
|
|
|
|
philos_free_string_array(&main_config.disk, main_config.size_tree_view);
|
|
|
|
|
philos_free_string_array(&main_config.array_del_line, main_config.size_array_del_line);
|
|
|
|
|
main_config.size_array_del_line = 0;
|
|
|
|
|
|
|
|
|
|
philos_free_int_array(&main_config.type_quota_size, main_config.size_tree_view);
|
|
|
|
|
philos_free_int_array(&main_config.quota_volume_size, main_config.size_tree_view);
|
|
|
|
@ -731,6 +737,11 @@ void tree_view_del_line() {
|
|
|
|
|
g_object_ref(main_config.list);
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), NULL);
|
|
|
|
|
gtk_list_store_clear(main_config.list);
|
|
|
|
|
char* key_del = save_format_key(main_config.size_tree_view-1);
|
|
|
|
|
if (key_del != NULL) {
|
|
|
|
|
main_config.array_del_line = yon_char_parsed_append(main_config.array_del_line, &main_config.size_array_del_line, key_del);
|
|
|
|
|
free(key_del);
|
|
|
|
|
}
|
|
|
|
|
main_config.type_quota = yon_char_parsed_shrink(main_config.type_quota, &main_config.size_tree_view,index);
|
|
|
|
|
main_config.size_tree_view++;
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_shrink(main_config.quota_volume, &main_config.size_tree_view,index);
|
|
|
|
@ -768,15 +779,23 @@ void tree_view_del_line() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void wrapper_all_save() {
|
|
|
|
|
// template_format_str_save(main_config.load_global_cfg, CMD_LOAD_GLOBAL);
|
|
|
|
|
if (main_config.flag_load == 0) {
|
|
|
|
|
template_format_str_save(main_config.load_system_cfg, CMD_ALL_SAVE, CMD_ALL_REMOVE);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
template_format_str_save(main_config.load_global_cfg, CMD_ALL_SAVE, CMD_ALL_REMOVE);
|
|
|
|
|
}
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wrapper_global_save() {
|
|
|
|
|
template_format_str_save(main_config.load_global_cfg, CMD_SAVE_GLOBAL);
|
|
|
|
|
template_format_str_save(main_config.load_global_cfg, CMD_SAVE_GLOBAL, CMD_REMOVE_GLOBAL);
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wrapper_system_save() {
|
|
|
|
|
template_format_str_save(main_config.load_system_cfg, CMD_SAVE_SYSTEM);
|
|
|
|
|
template_format_str_save(main_config.load_system_cfg, CMD_SAVE_SYSTEM, CMD_REMOVE_SYSTEM);
|
|
|
|
|
yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -794,6 +813,8 @@ char* save_format_value(int index) {
|
|
|
|
|
split_simvol[0] = 0;
|
|
|
|
|
split_simvol[1] = 0;
|
|
|
|
|
if (strstr(main_config.soft_raw_limit[index], "-") == NULL) {
|
|
|
|
|
puts(main_config.soft_raw_limit[index]);
|
|
|
|
|
printf("%d\n", main_config.soft_raw_limit_size[index]);
|
|
|
|
|
value = yon_char_unite(philos_format_cfg_str_size_memory("MemoryHigh", main_config.soft_raw_limit[index],main_config.soft_raw_limit_size[index]),NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
@ -824,6 +845,7 @@ char* save_format_value(int index) {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int check_save(dictionary* load_cfg) {
|
|
|
|
|
dictionary* ptr_dict_gui = NULL;
|
|
|
|
|
dictionary* ptr_dict_load = NULL;
|
|
|
|
@ -840,6 +862,7 @@ int check_save(dictionary* load_cfg) {
|
|
|
|
|
}
|
|
|
|
|
for_dictionaries(ptr_dict_gui, main_config.save_cfg_gui) {
|
|
|
|
|
for_dictionaries(ptr_dict_load, load_cfg) {
|
|
|
|
|
|
|
|
|
|
key_gui = ptr_dict_gui->key;
|
|
|
|
|
value_gui = (char*)ptr_dict_gui->data;
|
|
|
|
|
key_load = ptr_dict_load->key;
|
|
|
|
@ -859,12 +882,32 @@ int check_save(dictionary* load_cfg) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int template_format_str_save(dictionary* load_cfg, char* source_set_cmd, char* source_remove_cmd) {
|
|
|
|
|
char* cmd_remove = template_format_str_remove_save(source_remove_cmd);
|
|
|
|
|
char* cmd_set = template_format_str_set_save(load_cfg, source_set_cmd);
|
|
|
|
|
if (cmd_set != NULL && cmd_remove != NULL) {
|
|
|
|
|
yon_config_save(yon_char_unite(cmd_set, "; " , cmd_remove, NULL));
|
|
|
|
|
}
|
|
|
|
|
else if (cmd_remove != NULL) {
|
|
|
|
|
yon_config_save(cmd_remove);
|
|
|
|
|
puts(cmd_remove);
|
|
|
|
|
}
|
|
|
|
|
else if (cmd_set != NULL) {
|
|
|
|
|
yon_config_save(cmd_set);
|
|
|
|
|
puts(cmd_remove);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
void template_format_str_save(dictionary* load_cfg, char* source_cmd) {
|
|
|
|
|
}
|
|
|
|
|
char* template_format_str_set_save(dictionary* load_cfg, char* source_set_cmd) {
|
|
|
|
|
yon_dictionary_free_all(main_config.save_cfg_gui, NULL);
|
|
|
|
|
char* cmd = yon_char_new(source_cmd);
|
|
|
|
|
char* cmd = yon_char_new(source_set_cmd);
|
|
|
|
|
main_config.save_cfg_gui = yon_dictionary_create_empty();
|
|
|
|
|
int flag_save = 0;
|
|
|
|
|
for (size_t index = 0; index < main_config.size_tree_view; index++) {
|
|
|
|
@ -872,23 +915,45 @@ void template_format_str_save(dictionary* load_cfg, char* source_cmd) {
|
|
|
|
|
char* value = NULL;
|
|
|
|
|
key = save_format_key(index);
|
|
|
|
|
value = save_format_value(index);
|
|
|
|
|
puts(value);
|
|
|
|
|
main_config.save_cfg_gui = yon_dictionary_create_with_data_connected(main_config.save_cfg_gui, key, yon_char_new(value));
|
|
|
|
|
check_save(load_cfg);
|
|
|
|
|
if (key != NULL && value != NULL) {
|
|
|
|
|
cmd = yon_char_unite(cmd, " " , key, "=" , value, " ", NULL);
|
|
|
|
|
flag_save = 1;
|
|
|
|
|
if (check_save(load_cfg) == 1) {
|
|
|
|
|
cmd = yon_char_unite(cmd, " " , key, "=" , value, " ", NULL);
|
|
|
|
|
flag_save = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (key != NULL) {
|
|
|
|
|
free(key);
|
|
|
|
|
}
|
|
|
|
|
if (value != NULL) {
|
|
|
|
|
free(value);
|
|
|
|
|
}
|
|
|
|
|
// puts(key);
|
|
|
|
|
free(key);
|
|
|
|
|
free(value);
|
|
|
|
|
}
|
|
|
|
|
if (flag_save) {
|
|
|
|
|
yon_config_save(cmd);
|
|
|
|
|
return cmd;
|
|
|
|
|
}
|
|
|
|
|
free(cmd);
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* template_format_str_remove_save(char* source_remove_cmd) {
|
|
|
|
|
char* cmd = yon_char_new(source_remove_cmd);
|
|
|
|
|
int flag_save = 0;
|
|
|
|
|
for (size_t index = 0; index < main_config.size_array_del_line; index++) {
|
|
|
|
|
char* key = main_config.array_del_line[index];
|
|
|
|
|
if (key != NULL) {
|
|
|
|
|
cmd = yon_char_unite(cmd, " " , key, " ", NULL);
|
|
|
|
|
flag_save = 1;
|
|
|
|
|
free(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag_save) {
|
|
|
|
|
return cmd;
|
|
|
|
|
}
|
|
|
|
|
free(cmd);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void main_fill_tree_view_after_remove() {
|
|
|
|
|
for (int index= 0; index < main_config.size_tree_view; index++) {
|
|
|
|
@ -1005,7 +1070,6 @@ int main(int argc, char *argv[]){
|
|
|
|
|
event_all(widgets);
|
|
|
|
|
main_event(widgets);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yon_ubl_header_setup(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path);
|
|
|
|
|
|
|
|
|
|
if (yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel))
|
|
|
|
@ -1017,6 +1081,8 @@ int main(int argc, char *argv[]){
|
|
|
|
|
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
|
|
|
|
|
GTK_STYLE_PROVIDER(css),
|
|
|
|
|
-1);
|
|
|
|
|
load_global_cfg();
|
|
|
|
|
load_system_cfg();
|
|
|
|
|
gtk_main();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|