From a9c53c044cf215c546f5dc978126f41dbe1e4d09 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 2 May 2024 12:32:55 +0600 Subject: [PATCH] Fixed loading of custom config --- source/ubl-settings-system.c | 14 ++++++++++---- source/ubl-settings-system.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 884dd89..cec5a4b 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -4,7 +4,7 @@ config main_config; //functions -void yon_load_proceed(YON_CONFIG_TYPE type){ +int yon_load_proceed(YON_CONFIG_TYPE type){ yon_config_clean(); if (!yon_char_is_empty(config_get_default_command)) yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); @@ -15,8 +15,12 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ 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); - GtkFileFilter *filter = gtk_file_filter_new(); + textdomain(LocaleName); + yon_gtk_window_setup(GTK_WINDOW(dialog),NULL,TITLE_LABEL,main_icon,"LoadWindow"); + GtkFileFilter *filter = gtk_file_filter_new(); + gtk_file_filter_set_name(filter,"*.ini"); gtk_file_filter_add_pattern(filter,"*.ini"); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter); gtk_widget_show(dialog); @@ -30,10 +34,11 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ gtk_widget_destroy(dialog); } else { gtk_widget_destroy(dialog); - return; + return 0; } yon_config_load_config(type,config_get_command(path),NULL); } + return 1; } @@ -197,6 +202,8 @@ void yon_config_global_local_save(){ } void yon_config_custom_load(GtkWidget *self, main_window *widgets){ + if (!yon_load_proceed(YON_CONFIG_CUSTOM)) + return; g_signal_handlers_block_by_func(G_OBJECT(widgets->IDEntry),G_CALLBACK(on_id_changed),widgets); gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),""); gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),""); @@ -208,7 +215,6 @@ void yon_config_custom_load(GtkWidget *self, main_window *widgets){ gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),*rtn); gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ConsoleFontCombo),0); gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LanguageCombo),0); - yon_load_proceed(YON_CONFIG_CUSTOM); char *hostname = yon_config_get_by_key(hostname_parameter); if (!yon_char_is_empty(hostname)){ gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),hostname); diff --git a/source/ubl-settings-system.h b/source/ubl-settings-system.h index 089f7eb..469223f 100644 --- a/source/ubl-settings-system.h +++ b/source/ubl-settings-system.h @@ -20,6 +20,7 @@ #define _(String) gettext(String) +#define main_icon "com.ublinux.ubl-settings-system" #define glade_path "/com/ublinux/ui/ubl-settings-system.glade" #define glade_domain_path "/com/ublinux/ui/ubl-settings-system-domain.glade" #define glade_connection_path "/com/ublinux/ui/ubl-settings-system-connection.glade"