|
|
|
@ -115,6 +115,7 @@ void config_init(){
|
|
|
|
|
main_config.size_tree_view = 0;
|
|
|
|
|
main_config.flag_load = 0;
|
|
|
|
|
main_config.size_array_del_line = 0;
|
|
|
|
|
main_config.flag_set_data = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main_window *setup_window(){
|
|
|
|
@ -257,13 +258,13 @@ void main_update_information() {
|
|
|
|
|
|
|
|
|
|
void load_system_cfg() {
|
|
|
|
|
main_config.flag_load = 0;
|
|
|
|
|
template_cfg(CMD_LOAD_SYSTEM, main_config.load_system_cfg);
|
|
|
|
|
template_load_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);
|
|
|
|
|
template_load_cfg(CMD_LOAD_GLOBAL, main_config.load_global_cfg);
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -293,7 +294,7 @@ void clear_array() {
|
|
|
|
|
main_config.size_tree_view = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void template_cfg(char* cmd, dictionary* load_cfg) {
|
|
|
|
|
void template_load_cfg(char* cmd, dictionary* load_cfg) {
|
|
|
|
|
clear_array();
|
|
|
|
|
int size = 0;
|
|
|
|
|
char** cfg = yon_config_load(cmd, &size);
|
|
|
|
@ -317,6 +318,7 @@ void template_cfg(char* cmd, dictionary* load_cfg) {
|
|
|
|
|
if (main_config.size_tree_view != 0) {
|
|
|
|
|
fill_tree_view(0, main_config.size_tree_view, 0);
|
|
|
|
|
}
|
|
|
|
|
main_config.flag_set_data = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void init_cfg_array(int index) {
|
|
|
|
@ -573,6 +575,7 @@ void tree_view_add(int index) {
|
|
|
|
|
main_config.size_tree_view--;
|
|
|
|
|
main_config.i_o_limit_write_size = philos_int_append(main_config.i_o_limit_write_size, &main_config.size_tree_view, add_get_write_device_size());
|
|
|
|
|
fill_tree_view(main_config.size_tree_view-1, main_config.size_tree_view, 1);
|
|
|
|
|
main_config.flag_set_data = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fill_tree_view(int start, int size, int flag_gui_add) {
|
|
|
|
@ -605,6 +608,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;
|
|
|
|
|
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();
|
|
|
|
@ -793,6 +797,7 @@ void tree_view_del_line() {
|
|
|
|
|
main_fill_tree_view_after_remove();
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), model);
|
|
|
|
|
free(str_iter);
|
|
|
|
|
main_config.flag_set_data = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void wrapper_all_save() {
|
|
|
|
@ -879,40 +884,12 @@ char* save_format_value(int index) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int check_save(dictionary* load_cfg) {
|
|
|
|
|
dictionary* ptr_dict_gui = NULL;
|
|
|
|
|
dictionary* ptr_dict_load = NULL;
|
|
|
|
|
char* key_gui = NULL;
|
|
|
|
|
char* value_gui = NULL;
|
|
|
|
|
char* key_load = NULL;
|
|
|
|
|
char* value_load = NULL;
|
|
|
|
|
int flag_check_key = 0;
|
|
|
|
|
int flag_check_value = 0;
|
|
|
|
|
size_t size_cfg_gui = yon_dict_len(main_config.save_cfg_gui);
|
|
|
|
|
size_t size_cfg_load = yon_dict_len(load_cfg);
|
|
|
|
|
if (size_cfg_gui!=size_cfg_load) {
|
|
|
|
|
if (main_config.flag_set_data == 1) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
value_load = (char*)ptr_dict_load->data;
|
|
|
|
|
|
|
|
|
|
if (key_gui == key_load) {
|
|
|
|
|
flag_check_key = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if (value_gui == value_load) {
|
|
|
|
|
// TODO: check
|
|
|
|
|
flag_check_value = 1;
|
|
|
|
|
else if (main_config.flag_set_data == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag_check_key == 0 || flag_check_value == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int template_format_str_save(dictionary* load_cfg, char* source_set_cmd, char* source_remove_cmd) {
|
|
|
|
@ -936,20 +913,20 @@ int template_format_str_save(dictionary* load_cfg, char* source_set_cmd, char* s
|
|
|
|
|
if (cmd_set != NULL) {
|
|
|
|
|
free(cmd_set);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main_config.flag_set_data = 0;
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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_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++) {
|
|
|
|
|
char* key = NULL;
|
|
|
|
|
char* value = NULL;
|
|
|
|
|
key = yon_char_new(save_format_key(index));
|
|
|
|
|
value = yon_char_new(save_format_value(index));
|
|
|
|
|
main_config.save_cfg_gui = yon_dictionary_create_with_data_connected(main_config.save_cfg_gui, key, yon_char_new(value));
|
|
|
|
|
if (key != NULL && value != NULL) {
|
|
|
|
|
cmd = yon_char_unite(cmd, " " , key, "=" , value, NULL);
|
|
|
|
|
flag_save = 1;
|
|
|
|
@ -1098,7 +1075,6 @@ int main(int argc, char *argv[]){
|
|
|
|
|
main_window *widgets = setup_window();
|
|
|
|
|
main_config.load_global_cfg = yon_dictionary_create_empty();
|
|
|
|
|
main_config.load_system_cfg = yon_dictionary_create_empty();
|
|
|
|
|
main_config.save_cfg_gui = yon_dictionary_create_empty();
|
|
|
|
|
main_update_information();
|
|
|
|
|
filters_init_flag();
|
|
|
|
|
filters_setup_window(glade_path);
|
|
|
|
|