Custom config loading minor rework

pull/129/head
Ivan Yartsev 6 months ago
parent 219a2782b3
commit b0553794a4

@ -102,53 +102,29 @@ int yon_load_proceed(YON_CONFIG_TYPE type){
if(!yon_char_is_empty(config_get_default_command)){ if(!yon_char_is_empty(config_get_default_command)){
yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL);
} }
if (type==YON_CONFIG_GLOBAL){ switch (type){
yon_debug_output("%s\n",yon_char_unite(config_get_command("global"),NULL)); case YON_CONFIG_GLOBAL:
yon_config_load_config(type,config_get_command("global"),NULL); yon_debug_output("%s\n",yon_char_unite(config_get_command("global"),NULL));
textdomain(template_ui_LocaleName); yon_config_load_config(type,config_get_command("global"),NULL);
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); update_loaded_logrotate();
textdomain(LocaleName); return 1;
update_loaded_logrotate(); break;
return 1; case YON_CONFIG_LOCAL:
} yon_config_load_config(type,config_get_command("system"),NULL);
if (type==YON_CONFIG_LOCAL){ yon_config_load_config(YON_CONFIG_GLOBAL,config_get_global_only_parameters,NULL);
yon_config_load_config(type,config_get_command("system"),NULL); update_loaded_logrotate();
yon_config_load_config(YON_CONFIG_GLOBAL,config_get_global_only_parameters,NULL); return 1;
// int size; break;
textdomain(template_ui_LocaleName); case YON_CONFIG_CUSTOM:
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); char *path = NULL;
textdomain(LocaleName); path=yon_custom_config_init();
update_loaded_logrotate(); if (!yon_char_is_empty(path)){
return 1; yon_config_clean();
} yon_config_load_config(type,config_get_command(path),NULL);
else if (type==YON_CONFIG_CUSTOM){ yon_ubl_status_box_render(yon_char_get_localised_from_lib(LOCAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE);
char *path=NULL; }
textdomain(template_ui_LocaleName); break;
char *open_string = OPEN_LABEL; default:
textdomain(LocaleName);
GtkWidget *dialog = gtk_file_chooser_dialog_new(template_app_information.app_title,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,open_string,GTK_RESPONSE_ACCEPT,NULL);
yon_gtk_window_setup(GTK_WINDOW(dialog),NULL,CHOOSE_CUSTOM_CONFIG_LABEL,icon_path,"config-open-window");
GtkFileFilter *filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter,FILTER_NAME_CONFIG_LABEL);
gtk_file_filter_add_pattern(filter,"*.ini");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
gtk_widget_show(dialog);
int response = gtk_dialog_run(GTK_DIALOG(dialog));
if (response == GTK_RESPONSE_ACCEPT){
char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
if (!yon_char_is_empty(file)){
path=file;
}
yon_config_clean();
yon_config_load_config(type,config_get_command(path),NULL);
textdomain(template_ui_LocaleName);
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
textdomain(LocaleName);
gtk_widget_destroy(dialog);
} else {
gtk_widget_destroy(dialog);
return 0;
}
} }
update_loaded_logrotate(); update_loaded_logrotate();
return 1; return 1;

Loading…
Cancel
Save