diff --git a/locale/ubl-settings-system.pot b/locale/ubl-settings-system.pot index 87e250b..7a131fe 100644 --- a/locale/ubl-settings-system.pot +++ b/locale/ubl-settings-system.pot @@ -252,8 +252,12 @@ msgstr "" msgid "Language" msgstr "" +#: source/ubl-strings.h:70 +msgid "Regional settings" +msgstr "" + #: source/ubl-strings.h:71 -msgid "Available languages ​​in the system:" +msgid "Available locales in the system:" msgstr "" #: source/ubl-strings.h:72 @@ -277,7 +281,11 @@ msgid "Languages" msgstr "" #: source/ubl-strings.h:77 -msgid "Add anguages" +msgid "Add locales" +msgstr "" + +#: source/ubl-strings.h:77 +msgid "Add locale" msgstr "" #: source/ubl-strings.h:78 diff --git a/locale/ubl-settings-system_ru.po b/locale/ubl-settings-system_ru.po index 82576b3..2d07c63 100644 --- a/locale/ubl-settings-system_ru.po +++ b/locale/ubl-settings-system_ru.po @@ -256,9 +256,13 @@ msgstr "" msgid "Language" msgstr "Язык" +#: source/ubl-strings.h:70 +msgid "Regional settings" +msgstr "Региональные настройки" + #: source/ubl-strings.h:71 -msgid "Available languages ​​in the system:" -msgstr "Доступные языки для системы:" +msgid "Available locales in the system:" +msgstr "Доступные языки в системе:" #: source/ubl-strings.h:72 msgid "System locale" @@ -281,7 +285,11 @@ msgid "Languages" msgstr "Языки" #: source/ubl-strings.h:77 -msgid "Add anguages" +msgid "Add locales" +msgstr "Добавление языков" + +#: source/ubl-strings.h:77 +msgid "Add locale" msgstr "Добавить язык" #: source/ubl-strings.h:78 diff --git a/source/ubl-settings-system-language.c b/source/ubl-settings-system-language.c index 116c291..40c3359 100644 --- a/source/ubl-settings-system-language.c +++ b/source/ubl-settings-system-language.c @@ -36,22 +36,23 @@ void on_locale_accept(GtkWidget *self, language_window *window){ yon_interface_update(widgets); } -language_window *yon_language_window_new(){ - language_window *window = malloc(sizeof(language_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(glade_locales_path); - window->Window = yon_gtk_builder_get_widget(builder,"Window"); - window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); - window->LanguagesTree = yon_gtk_builder_get_widget(builder,"LanguagesTree"); - window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); - window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); - window->ManualEntry = yon_gtk_builder_get_widget(builder,"ManualEntry"); - window->ToggleCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"ToggleCell")); - window->LanguagesList = GTK_LIST_STORE(gtk_builder_get_object(builder,"LanguagesList")); +gboolean yon_locale_window_set_locales(struct locales_struct *data){ + GtkTreeIter iter; + gtk_list_store_append(GTK_LIST_STORE(data->list),&iter); + gtk_list_store_set(GTK_LIST_STORE(data->list),&iter,1,data->locale,2,data->lang,3,data->territory,0,data->chosen,-1); + if(!yon_char_is_empty(data->lang)) free(data->lang); + if(!yon_char_is_empty(data->locale)) free(data->locale); + if(!yon_char_is_empty(data->territory)) free(data->territory); + if(!yon_char_is_empty(data->lang)) free(data); + return G_SOURCE_REMOVE; +} - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); - g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_locale_accept),window); - g_signal_connect(G_OBJECT(window->ToggleCell),"toggled",G_CALLBACK(on_locale_toggle),window); +gboolean yon_locale_window_unlock(GtkWidget *spinner){ + gtk_widget_hide(spinner); + return G_SOURCE_REMOVE; +} +void *yon_locales_load_func(language_window *window){ char *config_value = config(locale_parameter); int config_parsed_size; config_str config_parsed = NULL; @@ -61,19 +62,51 @@ language_window *yon_language_window_new(){ } int size; - GtkTreeIter iter; config_str languages = yon_config_load(languages_command,&size); for (int i=0;ilist=window->LanguagesList; yon_char_remove_last_symbol(languages[i],'\n'); int parsed_size; config_str parsed = yon_char_parse(languages[i],&parsed_size,"|"); - gtk_list_store_append(window->LanguagesList,&iter); - gtk_list_store_set(window->LanguagesList,&iter,1,parsed[0],2,parsed[1],3,parsed[2],-1); + data_struct->locale = yon_char_new(parsed[0]); + data_struct->lang = yon_char_new(parsed[1]); + data_struct->territory = yon_char_new(parsed[2]); + if (config_parsed_size&&yon_char_parsed_check_exist(config_parsed,config_parsed_size,parsed[2])>-1){ - gtk_list_store_set(window->LanguagesList,&iter,0,1,-1); + data_struct->chosen=1; + } else { + data_struct->chosen=0; } + g_idle_add((GSourceFunc)yon_locale_window_set_locales,data_struct); + yon_char_parsed_free(parsed,parsed_size); } + g_idle_add((GSourceFunc)yon_locale_window_unlock,window->LoadingSpinner); yon_char_parsed_free(config_parsed,config_parsed_size); + g_thread_exit(NULL); +} + +language_window *yon_language_window_new(){ + language_window *window = malloc(sizeof(language_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_locales_path); + window->Window = yon_gtk_builder_get_widget(builder,"Window"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->LanguagesTree = yon_gtk_builder_get_widget(builder,"LanguagesTree"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + window->ManualEntry = yon_gtk_builder_get_widget(builder,"ManualEntry"); + window->LoadingOverlay = yon_gtk_builder_get_widget(builder,"LoadingOverlay"); + window->LoadingSpinner = yon_gtk_builder_get_widget(builder,"LoadingSpinner"); + window->ToggleCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"ToggleCell")); + window->LanguagesList = GTK_LIST_STORE(gtk_builder_get_object(builder,"LanguagesList")); + + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_locale_accept),window); + g_signal_connect(G_OBJECT(window->ToggleCell),"toggled",G_CALLBACK(on_locale_toggle),window); + yon_gtk_tree_view_minimal_fixed_size_set_full(GTK_TREE_VIEW(window->LanguagesTree)); + + gtk_overlay_add_overlay(GTK_OVERLAY(window->LoadingOverlay),window->LoadingSpinner); + g_thread_new("locales-thread",(GThreadFunc)yon_locales_load_func,window); return window; } @@ -82,7 +115,7 @@ void on_language_open(GtkWidget *, main_window *widgets){ g_object_set_data(G_OBJECT(window->Window),"widgets",widgets); - yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),TITLE_LABEL,main_icon,"LocalesWindow"); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),ADD_LANGUAGE_TITLE_LABEL,main_icon,"LocalesWindow"); gtk_widget_show(window->Window); diff --git a/source/ubl-settings-system.h b/source/ubl-settings-system.h index e7e99d2..55d5f71 100644 --- a/source/ubl-settings-system.h +++ b/source/ubl-settings-system.h @@ -148,6 +148,8 @@ typedef struct { GtkWidget *CancelButton; GtkWidget *AcceptButton; GtkWidget *ManualEntry; + GtkWidget *LoadingOverlay; + GtkWidget *LoadingSpinner; GtkCellRenderer *ToggleCell; GtkListStore *LanguagesList; @@ -202,6 +204,14 @@ typedef struct { GtkWidget *TerminalScroll; } domain_info_window; +struct locales_struct { + char *locale; + char *lang; + char *territory; + int chosen; + GtkListStore *list; +}; + void on_save_done(main_window *widgets, config_str output, int size); void on_config_reload(GtkWidget *,main_window *widgets); void yon_config_local_load(GtkWidget *self, main_window *widgets); @@ -259,4 +269,7 @@ language_window *yon_language_window_new(); void yon_config_init(); void on_locale_toggled(GtkCellRenderer *, gchar *path, main_window *widgets); void on_language_default_toggled(GtkWidget *, int status, main_window *widgets); -void on_language_remove(GtkWidget *, main_window *widgets); \ No newline at end of file +void on_language_remove(GtkWidget *, main_window *widgets); +gboolean yon_locale_window_set_locales(struct locales_struct *data); +void *yon_locales_load_func(language_window *window); +gboolean yon_locale_window_unlock(GtkWidget *spinner); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 82dfcd4..5258ea7 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -68,12 +68,14 @@ #define OU_LABEL _("OU, Organizational Unit:") #define OU_TOOLTIP_LABEL _("The name of the OU in which we want to create the computer account in the domain. If the account already exists, it will be updated. Example: \"ubhosts\" or \"OU=UBL Servers,OU=KOM,DC=ad,DC=holding,DC=com\"") #define LANGUAGE__LABEL _("Language") -#define AVALIABLE_LANGUAGES_LABEL _("Available languages ​​in the system:") +#define REGIONAL_SETTINGS_LABEL _("Regional settings") +#define AVALIABLE_LANGUAGES_LABEL _("Available locales in the system:") #define SYSTEM_LOCALE_LABEL _("System locale") #define TERRITORY_LABEL _("Territory") #define VALUE_LABEL _("Value") #define MANUAL_INPUT_LABEL _("Manual input:") #define LANGUAGES_LABEL _("Languages") -#define ADD_LANGIAGE_TOOLTIP_LABEL _("Add anguages") +#define ADD_LANGUAGE_TITLE_LABEL _("Add locales") +#define ADD_LANGUAGE_TOOLTIP_LABEL _("Add locale") #define REMOVE_LANGUAGE_LABEL _("Remove language") #define RESTRICTED_SYMBOLS_LABEL _("OU, Organizational Unit restricted symbols: ! \" # $ % & \' ( ) * + , - . / : ; < = > ? @ [ \\ ] ^ _ ` { | } ~.") \ No newline at end of file diff --git a/ubl-settings-system-layouts.glade b/ubl-settings-system-layouts.glade index 24890d6..149f001 100644 --- a/ubl-settings-system-layouts.glade +++ b/ubl-settings-system-layouts.glade @@ -14,6 +14,11 @@ + + True + False + True + True False @@ -53,75 +58,89 @@ - + True - True - 5 - 5 - never - in + False - + True True - LanguagesList - both - True - - - none - - + 5 + 5 + never + in - + + True + True + LanguagesList + 1 + both + True - - - 0 - + + + + + 0 + + + - - - - - Locale - - - 1 - + + autosize + Locale + + + word + 150 + + + 1 + + + - - - - - Language - - word - 100 + + True + fixed + 35 + Language + + + word + 100 + + + 2 + + - - 2 - - - - - - Territory - - word - 125 + + True + fixed + Territory + + + word + 125 + + + 3 + + - - 3 - + + -1 + diff --git a/ubl-settings-system.glade b/ubl-settings-system.glade index 2ce37bd..aa5c0fb 100644 --- a/ubl-settings-system.glade +++ b/ubl-settings-system.glade @@ -1,5 +1,5 @@ -