From 554f78cfa353a46d10fc3217e8dd4f4a64e14754 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 18 Nov 2025 14:30:26 +0600 Subject: [PATCH] Fixed loading function --- source/ubl-settings-video.c | 66 ++++++++++++++++++++----------------- source/ubl-settings-video.h | 2 +- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/source/ubl-settings-video.c b/source/ubl-settings-video.c index 37aa805..61e5249 100644 --- a/source/ubl-settings-video.c +++ b/source/ubl-settings-video.c @@ -231,40 +231,44 @@ void yon_interface_update(){ yon_monitor_view_update(); } -void yon_load_proceed(YON_CONFIG_TYPE type){ +void yon_load_proceed(YON_CONFIG_TYPE type){ if (type!=YON_CONFIG_CUSTOM){ yon_config_clean(); + if (!yon_char_is_empty(config_get_default_command)) + yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); + } + if (type==YON_CONFIG_GLOBAL){ + yon_config_load_config(type,config_get_command("global"),NULL); + } else if (type==YON_CONFIG_LOCAL){ + yon_config_load_config(type,config_get_command("system"),NULL); + } else if (type==YON_CONFIG_CUSTOM){ + char *path=""; + textdomain(template_ui_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_LABEL,GTK_RESPONSE_ACCEPT,NULL); + textdomain(LocaleName); + gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ubl-settings-services"); + gtk_window_set_title(GTK_WINDOW(dialog),TITLE_LABEL); + GtkFileFilter *filter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(filter,"*.ini"); + gtk_file_filter_set_name(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(); + if (!yon_char_is_empty(config_get_default_command)) + yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); + char *command = config_get_command(path); + yon_config_load_config(type,command,NULL); + gtk_widget_destroy(dialog); + } else { + gtk_widget_destroy(dialog); + } } - if (!yon_char_is_empty(config_get_default_command)) - yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); - switch (type){ - case YON_CONFIG_GLOBAL: - yon_config_load_config(type,config_get_command("global"),NULL); - yon_ubl_status_box_render(yon_char_get_localised_from_lib(GLOBAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); - break; - case YON_CONFIG_LOCAL: - yon_config_load_config(type,config_get_command("system"),NULL); - yon_ubl_status_box_render(yon_char_get_localised_from_lib(LOCAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); - break; - case YON_CONFIG_CUSTOM: - char *path = NULL; - path=yon_custom_config_init(GTK_FILE_CHOOSER_ACTION_OPEN); - yon_char_remove_brackets(path); - if (!yon_char_is_empty(path)){ - if ((access(path,0)==F_OK&&access(path,4)!=F_OK)){ - if (yon_status_box_is_set()){ - yon_ubl_status_box_render(ACCESS_DENIED_LABEL(path),BACKGROUND_IMAGE_FAIL_TYPE); - return; - } - } - yon_config_clean(); - yon_config_load_config(type,config_get_command(path),NULL); - yon_ubl_status_box_render(yon_char_get_localised_from_lib(LOCAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); - } - break; - default: - break; - } } void on_config_local_load(GtkWidget *self,main_window *){ diff --git a/source/ubl-settings-video.h b/source/ubl-settings-video.h index 816053f..8f91920 100644 --- a/source/ubl-settings-video.h +++ b/source/ubl-settings-video.h @@ -146,7 +146,7 @@ typedef struct{ typedef char* string; __attribute__((unused)) static \ -string version_application; +string version_application = "2.22"; #define _(String) gettext(String)