From 98e8c15386527254d031d657a79467880f3f2d6a Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 19 Sep 2023 17:43:01 +0600 Subject: [PATCH 01/25] ID is shown; added warning at saving --- source/ubl-settings-system.c | 23 +++++++++++----------- source/ubl-settings-system.h | 8 ++++++++ source/ubl-strings.h | 1 + source/ubl-utils.h | 8 -------- ubl-settings-system.desktop | 8 ++++---- ubl-settings-system.glade | 1 + ubl-settings-system.pot | 28 ++++++++++++++------------ ubl-settings-system_ru.po | 38 ++++++++++++++++++++---------------- 8 files changed, 63 insertions(+), 52 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 86422f3..2fcdde1 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -113,7 +113,10 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ void yon_config_local_load(GtkWidget *self, main_window *widgets){ gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),""); gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),""); - gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),""); + int size; + config_str rtn = yon_config_load(get_id_command,&size); + rtn[0]=yon_char_divide_search(rtn[0],"\n",-1); + 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_LOCAL); @@ -150,7 +153,10 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ void yon_config_global_load(GtkWidget *self, main_window *widgets){ gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),""); gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),""); - gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),""); + int size; + config_str rtn = yon_config_load(get_id_command,&size); + rtn[0]=yon_char_divide_search(rtn[0],"\n",-1); + 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_GLOBAL); @@ -160,9 +166,6 @@ void yon_config_global_load(GtkWidget *self, main_window *widgets){ gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),1); else if (!strcmp(id,"hardware")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),2); - else - gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),id); - GtkTreeIter iter; char *code; char *cons_font = yon_config_get_by_key(console_font_parameter); @@ -188,15 +191,18 @@ void yon_config_global_load(GtkWidget *self, main_window *widgets){ void yon_config_global_local_save(){ yon_config_save_registered(NULL,""); + yon_ubl_status_box_render(yon_char_unite(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL," ", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); } void yon_config_local_save(){ yon_config_save_registered("system","config"); + yon_ubl_status_box_render(yon_char_unite(LOCAL_SAVE_SUCCESS_LABEL," ", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); } void yon_config_global_save(){ yon_config_save_registered("global",""); + yon_ubl_status_box_render(yon_char_unite(GLOBAL_SAVE_SUCCESS_LABEL," ", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); } @@ -219,12 +225,9 @@ void on_id_combo_toggled(GtkComboBox *self, main_window *widgets){ } } if (id<3){ - gtk_widget_set_sensitive(widgets->IDEntry,0); - gtk_widget_set_sensitive(widgets->IDCopyButton,0); } else { - gtk_widget_set_sensitive(widgets->IDCopyButton,1); gtk_widget_set_sensitive(widgets->IDEntry,1); } } @@ -358,7 +361,6 @@ main_window *setup_window(){ gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,0); gtk_widget_set_sensitive(widgets->SaveMenuItem,0); } - /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ // yon_window_config_add_custom_parameter(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING); @@ -379,8 +381,7 @@ main_window *setup_window(){ g_signal_connect(G_OBJECT(widgets->IDCopyButton),"clicked",G_CALLBACK(on_id_copy),widgets); g_signal_connect(G_OBJECT(widgets->ConsoleFontCombo),"changed",G_CALLBACK(on_console_font_changed),widgets); g_signal_connect(G_OBJECT(widgets->LanguageCombo),"changed",G_CALLBACK(on_language_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->IDRandomCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),widgets->IDCopyButton); - // g_signal_connect(G_OBJECT(widgets->IDRandomCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),widgets->IDEntry); + int size; config_str locales = yon_config_load(get_locales_command,&size); GtkTreeIter iter; diff --git a/source/ubl-settings-system.h b/source/ubl-settings-system.h index 02f4723..ca328b5 100644 --- a/source/ubl-settings-system.h +++ b/source/ubl-settings-system.h @@ -32,8 +32,16 @@ #define get_locales_command "grep '' /usr/share/ubl-settings-system/csv/locales.csv" #define get_fonts_command "grep '' /usr/share/ubl-settings-system/csv/fonts.csv" +#define get_id_command "grep '' /etc/machine-id" // #define get_fonts_command "ls /usr/share/kbd/consolefonts/ |grep -v \"README\"|grep -oE \"^[-a-zA-Z0-9_]{3,}.psf\"|sed -e 's/\\.psf//g'" +#define hostname_parameter "HOSTNAME" +#define id_parameter "MACHINEID" +#define keyboard_layout_parameter "XkbLayout" +#define console_font_parameter "CONSOLE_FONT" +#define num_lock_boot_parameter "NUMLOCK" +#define language_parameter "LANG" + typedef char* string; string version_application; diff --git a/source/ubl-strings.h b/source/ubl-strings.h index e8136b9..1649cda 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -36,6 +36,7 @@ #define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded.") #define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded.") #define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded.") +#define SAVE_WARNING_LABEL _("Warning! New machine ID will apply after system reboot") #define HOSTNAME_LABEL _("Hostname:") #define ID_LABEL _("Work station ID:") diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 88222c1..ab19767 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -28,14 +28,6 @@ #define get_home_dir_command yon_char_unite("getent passwd \"",yon_ubl_root_user_get(),"\" | cut -d: -f6",NULL) - -#define hostname_parameter "HOSTNAME" -#define id_parameter "MACHINEID" -#define keyboard_layout_parameter "XkbLayout" -#define console_font_parameter "CONSOLE_FONT" -#define num_lock_boot_parameter "NUMLOCK" -#define language_parameter "LANG" - typedef enum { #ifdef __GTK_H__ diff --git a/ubl-settings-system.desktop b/ubl-settings-system.desktop index 941293e..89644e7 100644 --- a/ubl-settings-system.desktop +++ b/ubl-settings-system.desktop @@ -1,15 +1,15 @@ [Desktop Entry] Encoding=UTF-8 Name=System configuration -Name[ru]=TEMPLATE +Name[ru]=Системные настройки GenericName=ubl-settings-system -GenericName[ru]=TEMPLATE +GenericName[ru]=ubl-settings-system Comment=System basic parameters configuration -Comment[ru]=Приложение для TEMPLATE +Comment[ru]=Настройка основных параметров системы Type=Application Exec=pkexec ubl-settings-system Icon=com.ublinux.ubl-settings-system Terminal=false X-XfcePluggable=true X-UBLPluggable=true -Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;X-UBL-SettingsManager;X-UBL-Personal-Settings; +Categories=XFCE;GTK;Settings;X-UBL-SettingsManager;X-UBL-System-Settings; diff --git a/ubl-settings-system.glade b/ubl-settings-system.glade index 85456f4..9b011b2 100644 --- a/ubl-settings-system.glade +++ b/ubl-settings-system.glade @@ -711,6 +711,7 @@ translated and supported by community. True True + True True diff --git a/ubl-settings-system.pot b/ubl-settings-system.pot index c0517de..34c45e1 100644 --- a/ubl-settings-system.pot +++ b/ubl-settings-system.pot @@ -173,51 +173,55 @@ msgstr "" msgid "Local configuration saving succseeded." msgstr "" -#: source/ubl-strings.h:40 -msgid "Hostname:" +#: source/ubl-strings.h:39 +msgid "Warning! New machine ID will apply after reboot" msgstr "" #: source/ubl-strings.h:41 -msgid "Work station ID:" +msgid "Hostname:" msgstr "" #: source/ubl-strings.h:42 -msgid "System" +msgid "Work station ID:" msgstr "" #: source/ubl-strings.h:43 -msgid "Random" +msgid "System" msgstr "" #: source/ubl-strings.h:44 -msgid "Hardware" +msgid "Random" msgstr "" #: source/ubl-strings.h:45 -msgid "Manual" +msgid "Hardware" msgstr "" #: source/ubl-strings.h:46 -msgid "Console" +msgid "Manual" msgstr "" #: source/ubl-strings.h:47 -msgid "Console font:" +msgid "Console" msgstr "" #: source/ubl-strings.h:48 -msgid "Locale" +msgid "Console font:" msgstr "" #: source/ubl-strings.h:49 +msgid "Locale" +msgstr "" + +#: source/ubl-strings.h:50 msgid "Language:" msgstr "" -#: source/ubl-strings.h:51 +#: source/ubl-strings.h:52 msgid "Default" msgstr "" -#: source/ubl-strings.h:53 +#: source/ubl-strings.h:54 msgid "Machine ID has been copied" msgstr "" diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index a47ba90..b4b6e19 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -155,11 +155,11 @@ msgstr "Ничего не было выбрано" #: source/ubl-strings.h:32 msgid "Global configuration loading succseeded." -msgstr "Успешно загружена глобальная конфигурация" +msgstr "Успешно загружена глобальная конфигурация." #: source/ubl-strings.h:33 msgid "Local configuration loading succseeded." -msgstr "Успешно загружена локальная конфигурация" +msgstr "Успешно загружена локальная конфигурация." #: source/ubl-strings.h:34 msgid "Config loading failed" @@ -167,61 +167,65 @@ msgstr "Ошибка загрузки конфигурации" #: source/ubl-strings.h:36 msgid "Local and global configuration saving succseeded." -msgstr "Успешно записаны локальная и глобальная конфигурация" +msgstr "Успешно записаны локальная и глобальная конфигурация." #: source/ubl-strings.h:37 msgid "Global configuration saving succseeded." -msgstr "Успешно записана глобальная конфигурация" +msgstr "Успешно записана глобальная конфигурация." #: source/ubl-strings.h:38 msgid "Local configuration saving succseeded." -msgstr "Успешно записана локальная конфигурация" +msgstr "Успешно записана локальная конфигурация." -#: source/ubl-strings.h:40 +#: source/ubl-strings.h:39 +msgid "Warning! New machine ID will apply after reboot" +msgstr "Внимание! Новый ID рабочей станции будет применён после перезагрузки системы." + +#: source/ubl-strings.h:41 msgid "Hostname:" msgstr "Имя хоста:" -#: source/ubl-strings.h:41 +#: source/ubl-strings.h:42 msgid "Work station ID:" msgstr "ID рабочей станции:" -#: source/ubl-strings.h:42 +#: source/ubl-strings.h:43 msgid "System" msgstr "Система" -#: source/ubl-strings.h:43 +#: source/ubl-strings.h:44 msgid "Random" msgstr "Случайный" -#: source/ubl-strings.h:44 +#: source/ubl-strings.h:45 msgid "Hardware" msgstr "Системный" -#: source/ubl-strings.h:45 +#: source/ubl-strings.h:46 msgid "Manual" msgstr "Вручную" -#: source/ubl-strings.h:46 +#: source/ubl-strings.h:47 msgid "Console" msgstr "Консоль" -#: source/ubl-strings.h:47 +#: source/ubl-strings.h:48 msgid "Console font:" msgstr "Шрифт в консоли" -#: source/ubl-strings.h:48 +#: source/ubl-strings.h:49 msgid "Locale" msgstr "Локаль" -#: source/ubl-strings.h:49 +#: source/ubl-strings.h:50 msgid "Language:" msgstr "Язык" -#: source/ubl-strings.h:51 +#: source/ubl-strings.h:52 msgid "Default" msgstr "По умолчанию" -#: source/ubl-strings.h:53 +#: source/ubl-strings.h:54 msgid "Machine ID has been copied" msgstr "ID рабочей станции скопирован" -- 2.35.1 From c7ac167950013bcad56da40627e9ba36ab137705 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 19 Sep 2023 17:49:23 +0600 Subject: [PATCH 02/25] Empty id check added --- source/ubl-settings-system.c | 12 +++++++----- source/ubl-strings.h | 4 +++- ubl-settings-system.pot | 4 ++++ ubl-settings-system_ru.po | 7 ++++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 2fcdde1..e228026 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -234,11 +234,13 @@ void on_id_combo_toggled(GtkComboBox *self, main_window *widgets){ void on_id_changed(GtkEntry *self, main_window *widgets){ char *text = (char*)gtk_entry_get_text(self); - if (yon_config_get_by_key(id_parameter)){ - yon_config_set(id_parameter,text); - } else { - yon_config_register(id_parameter,"config",text); - } + if (strcmp(text,"")){ + if (yon_config_get_by_key(id_parameter)){ + yon_config_set(id_parameter,text); + } else { + yon_config_register(id_parameter,"config",text); + } + } else yon_ubl_status_box_render(ID_EMPTY_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 1649cda..29520a7 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -51,4 +51,6 @@ #define DEFAULT_LABEL _("Default") -#define COPY_SUCCESS_LABEL _("Machine ID has been copied") \ No newline at end of file +#define COPY_SUCCESS_LABEL _("Machine ID has been copied") + +#define ID_EMPTY_LABEL _("ID field can't be empty!"); \ No newline at end of file diff --git a/ubl-settings-system.pot b/ubl-settings-system.pot index 34c45e1..882bc57 100644 --- a/ubl-settings-system.pot +++ b/ubl-settings-system.pot @@ -225,6 +225,10 @@ msgstr "" msgid "Machine ID has been copied" msgstr "" +#: source/ubl-strings.h:56 +msgid "ID string can't be empty!" +msgstr "" + msgid "Afrikaans, South Africa" msgstr "" diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index b4b6e19..3ed1e65 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -178,7 +178,7 @@ msgid "Local configuration saving succseeded." msgstr "Успешно записана локальная конфигурация." #: source/ubl-strings.h:39 -msgid "Warning! New machine ID will apply after reboot" +msgid "Warning! New machine ID will apply after system reboot" msgstr "Внимание! Новый ID рабочей станции будет применён после перезагрузки системы." #: source/ubl-strings.h:41 @@ -229,6 +229,11 @@ msgstr "По умолчанию" msgid "Machine ID has been copied" msgstr "ID рабочей станции скопирован" +#: source/ubl-strings.h:56 +msgid "ID field can't be empty!" +msgstr "Поле ID не может быть пустым!" + + msgid "Afrikaans, South Africa" msgstr "Африканский, Южная Африка" -- 2.35.1 From b77109f7c6cbce94870fbdc53b877cfc0314f84f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 19 Sep 2023 17:50:26 +0600 Subject: [PATCH 03/25] Empty id check added --- source/ubl-strings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 29520a7..49c9de2 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -53,4 +53,4 @@ #define COPY_SUCCESS_LABEL _("Machine ID has been copied") -#define ID_EMPTY_LABEL _("ID field can't be empty!"); \ No newline at end of file +#define ID_EMPTY_LABEL _("ID field can't be empty!") \ No newline at end of file -- 2.35.1 From beb9cf38708e75747c23f9a60c844382535f30d7 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 19 Sep 2023 17:56:30 +0600 Subject: [PATCH 04/25] Save blocking when id is not inserted --- source/ubl-settings-system.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index e228026..2456b10 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -240,7 +240,17 @@ void on_id_changed(GtkEntry *self, main_window *widgets){ } else { yon_config_register(id_parameter,"config",text); } - } else yon_ubl_status_box_render(ID_EMPTY_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,1); + gtk_widget_set_sensitive(widgets->SaveMenuItem,1); + gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,1); + gtk_widget_set_sensitive(widgets->IDCopyButton,1); + } else { + gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,0); + gtk_widget_set_sensitive(widgets->IDCopyButton,0); + yon_ubl_status_box_render(ID_EMPTY_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + } } -- 2.35.1 From d147b25a19684a17d5ad0ad6bd3045f914f4558f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 19 Sep 2023 18:07:43 +0600 Subject: [PATCH 05/25] Added new label for data inserting --- source/ubl-settings-system.c | 7 ++++--- source/ubl-strings.h | 4 +++- ubl-settings-system.pot | 4 ++++ ubl-settings-system_ru.po | 3 +++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 2456b10..9b022c8 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -191,18 +191,18 @@ void yon_config_global_load(GtkWidget *self, main_window *widgets){ void yon_config_global_local_save(){ yon_config_save_registered(NULL,""); - yon_ubl_status_box_render(yon_char_unite(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL," ", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(yon_char_unite(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,"\n", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); } void yon_config_local_save(){ yon_config_save_registered("system","config"); - yon_ubl_status_box_render(yon_char_unite(LOCAL_SAVE_SUCCESS_LABEL," ", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(yon_char_unite(LOCAL_SAVE_SUCCESS_LABEL,"\n", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); } void yon_config_global_save(){ yon_config_save_registered("global",""); - yon_ubl_status_box_render(yon_char_unite(GLOBAL_SAVE_SUCCESS_LABEL," ", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(yon_char_unite(GLOBAL_SAVE_SUCCESS_LABEL,"\n", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); } @@ -244,6 +244,7 @@ void on_id_changed(GtkEntry *self, main_window *widgets){ gtk_widget_set_sensitive(widgets->SaveMenuItem,1); gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,1); gtk_widget_set_sensitive(widgets->IDCopyButton,1); + yon_ubl_status_box_render(INSERT_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } else { gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,0); gtk_widget_set_sensitive(widgets->SaveMenuItem,0); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 49c9de2..b316a0f 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -53,4 +53,6 @@ #define COPY_SUCCESS_LABEL _("Machine ID has been copied") -#define ID_EMPTY_LABEL _("ID field can't be empty!") \ No newline at end of file +#define ID_EMPTY_LABEL _("ID field can't be empty!") + +#define INSERT_LABEL _("Insert data") \ No newline at end of file diff --git a/ubl-settings-system.pot b/ubl-settings-system.pot index 882bc57..2f04f28 100644 --- a/ubl-settings-system.pot +++ b/ubl-settings-system.pot @@ -229,6 +229,10 @@ msgstr "" msgid "ID string can't be empty!" msgstr "" +#: source/ubl-strings.h:56 +msgid "Insert data" +msgstr "" + msgid "Afrikaans, South Africa" msgstr "" diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index 3ed1e65..9258722 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -233,6 +233,9 @@ msgstr "ID рабочей станции скопирован" msgid "ID field can't be empty!" msgstr "Поле ID не может быть пустым!" +#: source/ubl-strings.h:56 +msgid "Insert data" +msgstr "Введите данные" msgid "Afrikaans, South Africa" msgstr "Африканский, Южная Африка" -- 2.35.1 From 8150f1ab9b0164c80fb3ce68aaee87a82b9d7652 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 20 Sep 2023 09:45:25 +0600 Subject: [PATCH 06/25] Fixed global configuration status message --- source/ubl-settings-system.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 9b022c8..fdd95b3 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -104,7 +104,6 @@ void on_about(){ void yon_load_proceed(YON_CONFIG_TYPE type){ if (yon_config_load_register(type,"config",hostname_parameter,"config",id_parameter,"locale",console_font_parameter,"locale",language_parameter,NULL)) - yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); else yon_ubl_status_box_render(LOAD_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); @@ -147,7 +146,7 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ if (code&&!strcmp(code,lang)) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->LanguageCombo),&iter); } } - + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } void yon_config_global_load(GtkWidget *self, main_window *widgets){ @@ -186,7 +185,7 @@ void yon_config_global_load(GtkWidget *self, main_window *widgets){ else { gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LanguageCombo),0); } } } - + yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } void yon_config_global_local_save(){ -- 2.35.1 From 876f803dc9ac0ec56d3ff7d176bf0fc99394d9cf Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 20 Sep 2023 09:46:47 +0600 Subject: [PATCH 07/25] Fixed global configuration status message --- source/ubl-settings-system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index fdd95b3..c9a7813 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -103,7 +103,7 @@ void on_about(){ //functions void yon_load_proceed(YON_CONFIG_TYPE type){ - if (yon_config_load_register(type,"config",hostname_parameter,"config",id_parameter,"locale",console_font_parameter,"locale",language_parameter,NULL)) + if (yon_config_load_register(type,"config",hostname_parameter,"config",id_parameter,"locale",console_font_parameter,"locale",language_parameter,NULL)){} else yon_ubl_status_box_render(LOAD_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); -- 2.35.1 From a608b0ad0025e25eed169e62b56d9f0ea47c67be Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 22 Sep 2023 12:31:10 +0600 Subject: [PATCH 08/25] Localisation update --- ubl-settings-system.pot | 4 ++++ ubl-settings-system_ru.po | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ubl-settings-system.pot b/ubl-settings-system.pot index 2f04f28..fc5830d 100644 --- a/ubl-settings-system.pot +++ b/ubl-settings-system.pot @@ -233,6 +233,10 @@ msgstr "" msgid "Insert data" msgstr "" +#: source/ubl-strings.h:60 +msgid "Accept" +msgstr "" + msgid "Afrikaans, South Africa" msgstr "" diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index 9258722..c07aef6 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -237,6 +237,10 @@ msgstr "Поле ID не может быть пустым!" msgid "Insert data" msgstr "Введите данные" +#: source/ubl-strings.h:60 +msgid "Accept" +msgstr "Принять" + msgid "Afrikaans, South Africa" msgstr "Африканский, Южная Африка" @@ -250,7 +254,7 @@ msgid "Arabic, Algeria" msgstr "Арабский, Алжир" msgid "Arabic, Egypt" -msgstr "Арабский, Египт" +msgstr "Арабский, Египет" msgid "Arabic, Iraq" msgstr "Арабский, Ирак" @@ -496,7 +500,7 @@ msgid "Kannada, India" msgstr "Каннада, Индия" msgid "Korean, Korea" -msgstr "орейский, Корея" +msgstr "Корейский, Корея" msgid "Kashmiri, India" msgstr "Кашмирский, Индия" @@ -547,7 +551,7 @@ msgid "Oriya, India" msgstr "Ория, Индия" msgid "Punjabi, India" -msgstr "Панджаби" +msgstr "Панджаби, Индия" msgid "Polish, Poland" msgstr "Польский, Польша" -- 2.35.1 From d817004b1faeff8a494d5925a0f161d2f5036a84 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 22 Sep 2023 12:32:53 +0600 Subject: [PATCH 09/25] Added new entry and menu for LOCALE parameter --- gresource.xml | 1 + source/CMakeLists.txt | 1 + source/ubl-settings-system.c | 126 ++++++++++++++++++++++---- source/ubl-settings-system.h | 16 ++++ source/ubl-strings.h | 4 +- source/ubl-utils.c | 43 ++++++++- source/ubl-utils.h | 8 +- ubl-settings-system-layouts.glade | 141 +++++++++++++++++------------- ubl-settings-system.glade | 104 ++++++++++++++++++---- 9 files changed, 341 insertions(+), 103 deletions(-) diff --git a/gresource.xml b/gresource.xml index 02e88c1..a172326 100644 --- a/gresource.xml +++ b/gresource.xml @@ -2,6 +2,7 @@ ubl-settings-system.glade + ubl-settings-system-layouts.glade ubl-settings-system.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 865fcbb..f2d6ea4 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -36,6 +36,7 @@ add_custom_target(GLADE ubl-settings-system.glade) set(DEPENDFILES ../ubl-settings-system.glade + ../ubl-settings-system-layouts.glade ../gresource.xml ../ubl-settings-system-banner.png ../ubl-settings-system.css diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index c9a7813..924a147 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -103,7 +103,7 @@ void on_about(){ //functions void yon_load_proceed(YON_CONFIG_TYPE type){ - if (yon_config_load_register(type,"config",hostname_parameter,"config",id_parameter,"locale",console_font_parameter,"locale",language_parameter,NULL)){} + if (yon_config_load_register(type,"config",hostname_parameter,"config",id_parameter,"locale",console_font_parameter,"locale",locale_parameter,"locale",language_parameter,NULL)){} else yon_ubl_status_box_render(LOAD_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); @@ -112,7 +112,9 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ void yon_config_local_load(GtkWidget *self, main_window *widgets){ gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),""); gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),""); + gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),""); int size; + GtkTreeIter iter; config_str rtn = yon_config_load(get_id_command,&size); rtn[0]=yon_char_divide_search(rtn[0],"\n",-1); gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),*rtn); @@ -120,6 +122,9 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LanguageCombo),0); yon_load_proceed(YON_CONFIG_LOCAL); gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),yon_config_get_by_key(hostname_parameter)); + for_iter(GTK_TREE_MODEL(widgets->languagelist),&iter){ + gtk_list_store_set(widgets->languagelist,&iter,2,0,-1); + } char *id = yon_config_get_by_key(id_parameter); if (!strcmp(id,"Random")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),1); @@ -128,7 +133,6 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ else gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),id); - GtkTreeIter iter; char *code; char *cons_font = yon_config_get_by_key(console_font_parameter); if (cons_font){ @@ -139,12 +143,26 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ } } char *lang = yon_config_get_by_key(language_parameter); + char *avlocale = yon_config_get_by_key(locale_parameter); + int locsize; + if (avlocale); + config_str locale_parsed = yon_char_parse(avlocale,&locsize,","); + gboolean is_active; + char *locale_string=""; + char *loc_name; if (lang){ int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->languagelist),&iter); for(;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->languagelist),&iter)){ - gtk_tree_model_get(GTK_TREE_MODEL(widgets->languagelist),&iter,1,&code,-1); + gtk_tree_model_get(GTK_TREE_MODEL(widgets->languagelist),&iter,0,&loc_name,1,&code,2,&is_active,-1); if (code&&!strcmp(code,lang)) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->LanguageCombo),&iter); + if (avlocale) + for (int i=0;ilanguagelist,&iter,2,1,-1); + locale_string = yon_char_unite(strcmp(locale_string,"") ? yon_char_append(locale_string,"; ") : locale_string, loc_name,NULL); + } } + gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),locale_string); } yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } @@ -152,7 +170,9 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ void yon_config_global_load(GtkWidget *self, main_window *widgets){ gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),""); gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),""); + gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),""); int size; + GtkTreeIter iter; config_str rtn = yon_config_load(get_id_command,&size); rtn[0]=yon_char_divide_search(rtn[0],"\n",-1); gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),*rtn); @@ -160,51 +180,120 @@ void yon_config_global_load(GtkWidget *self, main_window *widgets){ gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LanguageCombo),0); yon_load_proceed(YON_CONFIG_GLOBAL); gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),yon_config_get_by_key(hostname_parameter)); + for_iter(GTK_TREE_MODEL(widgets->languagelist),&iter){ + gtk_list_store_set(widgets->languagelist,&iter,2,0,-1); + } char *id = yon_config_get_by_key(id_parameter); if (!strcmp(id,"Random")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),1); else if (!strcmp(id,"hardware")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),2); - GtkTreeIter iter; + else + gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),id); + char *code; char *cons_font = yon_config_get_by_key(console_font_parameter); if (cons_font){ int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->fontlist),&iter); - for(;valid;gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->fontlist),&iter)){ - gtk_tree_model_get(GTK_TREE_MODEL(widgets->fontlist),&iter,1,&code,-1); - if (code&&!strcmp(code,cons_font)){ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->ConsoleFontCombo),&iter); break; } - else { gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ConsoleFontCombo),0); } + for(;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->fontlist),&iter)){ + gtk_tree_model_get(GTK_TREE_MODEL(widgets->fontlist),&iter,0,&code,-1); + if (code&&!strcmp(code,cons_font)) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->ConsoleFontCombo),&iter); } } char *lang = yon_config_get_by_key(language_parameter); + char *avlocale = yon_config_get_by_key(locale_parameter); + int locsize; + if (avlocale); + config_str locale_parsed = yon_char_parse(avlocale,&locsize,","); + gboolean is_active; + char *locale_string=""; + char *loc_name; if (lang){ int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->languagelist),&iter); for(;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->languagelist),&iter)){ - gtk_tree_model_get(GTK_TREE_MODEL(widgets->languagelist),&iter,1,&code,-1); - if (!strcmp(code,lang)){ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->LanguageCombo),&iter); break; } - else { gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LanguageCombo),0); } + gtk_tree_model_get(GTK_TREE_MODEL(widgets->languagelist),&iter,0,&loc_name,1,&code,2,&is_active,-1); + if (code&&!strcmp(code,lang)) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->LanguageCombo),&iter); + if (avlocale) + for (int i=0;ilanguagelist,&iter,2,1,-1); + locale_string = yon_char_unite(strcmp(locale_string,"") ? yon_char_append(locale_string,"; ") : locale_string, loc_name,NULL); + } } + gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),locale_string); } yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } void yon_config_global_local_save(){ - yon_config_save_registered(NULL,""); + yon_config_save_registered(NULL); yon_ubl_status_box_render(yon_char_unite(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,"\n", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); } void yon_config_local_save(){ - yon_config_save_registered("system","config"); + yon_config_save_registered("system"); yon_ubl_status_box_render(yon_char_unite(LOCAL_SAVE_SUCCESS_LABEL,"\n", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); } void yon_config_global_save(){ - yon_config_save_registered("global",""); + yon_config_save_registered("global"); yon_ubl_status_box_render(yon_char_unite(GLOBAL_SAVE_SUCCESS_LABEL,"\n", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE); } +void on_locale_toggle(GtkCellRendererToggle *self,GtkTreePath* path,GtkTreeViewColumn* column,locals_window *window){ + GtkTreeIter iter; + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(window->MainTree)); + gtk_tree_model_get_iter(model,&iter,path); + gboolean is_active; + gtk_tree_model_get(model,&iter,2,&is_active,-1); + gtk_list_store_set(GTK_LIST_STORE(model),&iter,2,!is_active,-1); +} + +void on_locale_accept(GtkWidget *self, dictionary *dict){ + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + locals_window *window = yon_dictionary_get_data(dict->first->next,locals_window*); + GtkTreeIter iter; + gboolean is_active; + char *final_string = ""; + char *final_ids = ""; + char *name, *id; + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->languagelist),&iter); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->languagelist),&iter)){ + gtk_tree_model_get(GTK_TREE_MODEL(widgets->languagelist),&iter,0,&name,1,&id,2,&is_active,-1); + if (is_active){ + final_string = yon_char_unite(strcmp(final_string,"") ? yon_char_append(final_string,"; ") : final_string,name,NULL); + final_ids = yon_char_unite(strcmp(final_ids,"") ? yon_char_append(final_ids,",") : final_ids,id,NULL); + } + } + gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),final_string); + if (yon_config_get_by_key("LOCALE")) yon_config_set("LOCALE",final_ids); + else yon_config_register("LOCALE","locale",final_ids); + on_close_subwindow(self); +} + +void on_locale_open(GtkWidget *self, main_window *widgets){ + locals_window *window = malloc(sizeof(locals_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_locales_path); + window->Window = yon_gtk_builder_get_widget(builder,"localesLayoutsWindow"); + window->MainTree = yon_gtk_builder_get_widget(builder,"localesTree"); + window->CloseButton = yon_gtk_builder_get_widget(builder,"localesCancelButton"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"localesAcceptButton"); + window->ToggleCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"toggleCell")); + gtk_tree_view_set_model(GTK_TREE_VIEW(window->MainTree), GTK_TREE_MODEL(widgets->languagelist)); + + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + + g_signal_connect(G_OBJECT(window->CloseButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_locale_accept),dict); + g_signal_connect(G_OBJECT(window->MainTree),"row-activated",G_CALLBACK(on_locale_toggle),window); + gtk_dialog_run(GTK_DIALOG(window->Window)); + +} + void on_hostname_changed(GtkEntry *self, main_window *widgets){ char *text = (char*)gtk_entry_get_text(self); if (yon_config_get_by_key(hostname_parameter)){ @@ -349,6 +438,9 @@ main_window *setup_window(){ widgets->ConsoleFontCombo = yon_gtk_builder_get_widget(builder,"ConsoleFontCombo"); widgets->LanguageCombo = yon_gtk_builder_get_widget(builder,"LanguageCombo"); + widgets->LocaleButton = yon_gtk_builder_get_widget(builder,"getLocalesButton"); + widgets->LocaleEntry = yon_gtk_builder_get_widget(builder,"localeEntry"); + widgets->fontlist = GTK_LIST_STORE(gtk_builder_get_object(builder,"fontlist")); widgets->languagelist = GTK_LIST_STORE(gtk_builder_get_object(builder,"languagelist")); @@ -391,9 +483,11 @@ main_window *setup_window(){ g_signal_connect(G_OBJECT(widgets->IDCombo),"changed",G_CALLBACK(on_id_combo_toggled),widgets); g_signal_connect(G_OBJECT(widgets->IDEntry),"changed",G_CALLBACK(on_id_changed),widgets); g_signal_connect(G_OBJECT(widgets->IDCopyButton),"clicked",G_CALLBACK(on_id_copy),widgets); + g_signal_connect(G_OBJECT(widgets->LocaleButton),"clicked",G_CALLBACK(on_locale_open),widgets); g_signal_connect(G_OBJECT(widgets->ConsoleFontCombo),"changed",G_CALLBACK(on_console_font_changed),widgets); g_signal_connect(G_OBJECT(widgets->LanguageCombo),"changed",G_CALLBACK(on_language_changed),widgets); - + + main_config.localeslist = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_BOOLEAN); int size; config_str locales = yon_config_load(get_locales_command,&size); GtkTreeIter iter; @@ -402,7 +496,7 @@ main_window *setup_window(){ locales[i]=yon_char_divide_search(locales[i],"\n",-1); config_str loc_parsed = yon_char_parse(locales[i],&locsize,";"); gtk_list_store_append(widgets->languagelist,&iter); - gtk_list_store_set(widgets->languagelist,&iter,0,_(loc_parsed[1]),1,loc_parsed[0],-1); + gtk_list_store_set(widgets->languagelist,&iter,0,_(loc_parsed[1]),1,loc_parsed[0],2,0,-1); } config_str fonts = yon_config_load(get_fonts_command,&size); for (int i=0;idata&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ if (((yon_config_parameter*)dct)->flag1==1){ ((yon_config_parameter*)dct)->flag1=0; - if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=",yon_dictionary_get_data(dct,char*),NULL); - else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=",yon_dictionary_get_data(dct,char*),NULL)); + if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section," ", dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); } else if (((yon_config_parameter*)dct)->flag1==-1){ ((yon_config_parameter*)dct)->flag1=0; if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); @@ -1740,6 +1750,31 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.deleted_parameters,param->parameter_name,param); } + int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type){ + GError *err=NULL; + switch (type){ + case YON_TYPE_BOOLEAN: + *((int*)return_value) = g_key_file_get_boolean(__yon_window_config_file,section,config_parameter,&err); + if (err) return 0; else return 1; + break; + case YON_TYPE_INT: + *((int*)return_value) = g_key_file_get_integer(__yon_window_config_file,section,config_parameter,&err); + if (err) return 0; else return 1; + break; + case YON_TYPE_STRING: + *((char**)return_value) = g_key_file_get_string(__yon_window_config_file,section,config_parameter,&err); + if (err) return 0; else return 1; + break; + case YON_TYPE_STRING_LIST: + gsize size=0; + *((char***)return_value) = g_key_file_get_string_list(__yon_window_config_file,section,config_parameter,&size,&err); + *((char***)return_value)=yon_remalloc(return_value,size+1); + *((char***)return_value)[size]=NULL; + if (err) return 0; else return 1; + break; + } + } + GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ GtkWidget *menu_item = gtk_menu_item_new(); gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom"); diff --git a/source/ubl-utils.h b/source/ubl-utils.h index ab19767..396ccd4 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -22,6 +22,7 @@ #define DesktopPath "/usr/share/applications/" #define for_dictionaries(obj, obj1) for (obj = obj1->first; obj != NULL; obj = obj->next) +#define for_iter(model,iter) for (int valid = gtk_tree_model_get_iter_first(model,iter);valid;valid=gtk_tree_model_iter_next(model,iter)) #define new(type) malloc(sizeof(type)) #define new_arr(type,size) malloc(sizeof(type)*size) @@ -171,6 +172,8 @@ void yon_apps_sort(apps *applist, int size); apps *yon_apps_get_by_name(apps *applist, char *name, int size); +config_str yon_file_open(char *file_path, int *size); + //config functions #define ubconfig_save_command "ubconfig" @@ -184,7 +187,7 @@ typedef enum { config_str yon_config_load(char *command, int *str_len); -int yon_config_save_registered(char *path, char *section); +int yon_config_save_registered(char *path); char *yon_config_get_parameter(config_str parameters, int size, char *param); @@ -226,6 +229,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end enum YON_TYPE{ YON_TYPE_STRING, + YON_TYPE_STRING_LIST, YON_TYPE_INT, YON_TYPE_BOOLEAN, YON_TYPE_OTHER @@ -262,6 +266,8 @@ void yon_window_config_add_custom_parameter(char *param_name, char *section, voi void yon_window_config_erase_custom_parameter(char *param_name, char *section); +int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type); + int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); diff --git a/ubl-settings-system-layouts.glade b/ubl-settings-system-layouts.glade index 6853c3b..2dfb5fc 100644 --- a/ubl-settings-system-layouts.glade +++ b/ubl-settings-system-layouts.glade @@ -12,77 +12,27 @@ False emblem-ok-symbolic - - - - - - - + 450 550 False - False - 450 - dialog-question-symbolic - + dialog + - True False - 5 - 5 - 5 - 5 - 5 - 5 vertical - 10 - - - True - True - in - - - True - True - keyboardList - False - - - - - - column - - - - 0 - - - - - - - - - True - True - 0 - - - - - True + 2 + + False - 5 + end - - Ok + + Cancel True True True - image9 + image8 @@ -95,12 +45,12 @@ - - Cancel + + Accept True True True - image8 + image9 @@ -115,6 +65,70 @@ False + False + 0 + + + + + True + False + 2 + 2 + 2 + 2 + vertical + 10 + + + True + True + in + + + True + True + False + True + + + none + + + + + column + + + + 2 + + + + + + + column + + + + 0 + + + + + + + + + True + True + 0 + + + + + True True 1 @@ -125,6 +139,7 @@ True False + True True diff --git a/ubl-settings-system.glade b/ubl-settings-system.glade index 9b011b2..37b2560 100644 --- a/ubl-settings-system.glade +++ b/ubl-settings-system.glade @@ -211,6 +211,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False edit-copy-symbolic + + True + False + document-edit-symbolic + True False @@ -419,13 +424,9 @@ translated and supported by community. + + - - - Default - - - True @@ -866,14 +867,53 @@ translated and supported by community. True False + vertical 5 - + True False - Language: - True - 0 + 5 + + + True + False + Locale: + 0 + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + True + True + True + image2 + + + + False + True + 2 + + False @@ -882,20 +922,46 @@ translated and supported by community. - + True False - languagelist - 0 + 5 + + + True + False + Language: + True + 0 + + + False + True + 0 + + - - - 0 - + + True + False + languagelist + 0 + + + + 0 + + + + + True + True + 1 + - True + False True 1 @@ -1110,6 +1176,8 @@ translated and supported by community. + + -- 2.35.1 From e52475dddb876277c0a96f549964909bac849c5e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 22 Sep 2023 12:35:48 +0600 Subject: [PATCH 10/25] Fixed unswitched work station id combo after loading --- source/ubl-settings-system.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 924a147..78685fd 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -130,8 +130,10 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),1); else if (!strcmp(id,"hardware")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),2); - else + else { gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),id); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),3); + } char *code; char *cons_font = yon_config_get_by_key(console_font_parameter); @@ -188,8 +190,10 @@ void yon_config_global_load(GtkWidget *self, main_window *widgets){ gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),1); else if (!strcmp(id,"hardware")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),2); - else + else{ gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),id); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),3); + } char *code; char *cons_font = yon_config_get_by_key(console_font_parameter); -- 2.35.1 From a0d0ba57341176227841e11f86f7773e805c6a7e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 22 Sep 2023 12:36:10 +0600 Subject: [PATCH 11/25] Added semicolumn --- ubl-settings-system_ru.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index c07aef6..b8490d9 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -211,7 +211,7 @@ msgstr "Консоль" #: source/ubl-strings.h:48 msgid "Console font:" -msgstr "Шрифт в консоли" +msgstr "Шрифт в консоли:" #: source/ubl-strings.h:49 msgid "Locale" -- 2.35.1 From e1df7ab7b4bd518c8328242c5d6cf2bf5204df77 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 22 Sep 2023 13:40:45 +0600 Subject: [PATCH 12/25] Added semicolumn --- ubl-settings-system_ru.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index b8490d9..245f9fc 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -219,7 +219,7 @@ msgstr "Локаль" #: source/ubl-strings.h:50 msgid "Language:" -msgstr "Язык" +msgstr "Язык:" #: source/ubl-strings.h:52 msgid "Default" -- 2.35.1 From d1982872be55d02ecd033f96650c4209e4dd2f5b Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 22 Sep 2023 13:43:28 +0600 Subject: [PATCH 13/25] Removed unwanted dots --- source/ubl-strings.h | 10 +++++----- ubl-settings-system.pot | 10 +++++----- ubl-settings-system_ru.po | 22 +++++++++++----------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 23fa3e3..6703f05 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -29,13 +29,13 @@ #define NOTHING_CHOSEN_LABEL _("Nothing were chosen") -#define GLOBAL_LOAD_SUCCESS_LABEL _("Global configuration loading succseeded.") -#define LOCAL_LOAD_SUCCESS_LABEL _("Local configuration loading succseeded.") +#define GLOBAL_LOAD_SUCCESS_LABEL _("Global configuration loading succseeded") +#define LOCAL_LOAD_SUCCESS_LABEL _("Local configuration loading succseeded") #define LOAD_FAILED_LABEL _("Config loading failed") -#define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded.") -#define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded.") -#define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded.") +#define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded") +#define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded") +#define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded") #define SAVE_WARNING_LABEL _("Warning! New machine ID will apply after system reboot") #define HOSTNAME_LABEL _("Hostname:") diff --git a/ubl-settings-system.pot b/ubl-settings-system.pot index fc5830d..7c33049 100644 --- a/ubl-settings-system.pot +++ b/ubl-settings-system.pot @@ -150,11 +150,11 @@ msgid "Nothing were chosen" msgstr "" #: source/ubl-strings.h:32 -msgid "Global configuration loading succseeded." +msgid "Global configuration loading succseeded" msgstr "" #: source/ubl-strings.h:33 -msgid "Local configuration loading succseeded." +msgid "Local configuration loading succseeded" msgstr "" #: source/ubl-strings.h:34 @@ -162,15 +162,15 @@ msgid "Config loading failed" msgstr "" #: source/ubl-strings.h:36 -msgid "Local and global configuration saving succseeded." +msgid "Local and global configuration saving succseeded" msgstr "" #: source/ubl-strings.h:37 -msgid "Global configuration saving succseeded." +msgid "Global configuration saving succseeded" msgstr "" #: source/ubl-strings.h:38 -msgid "Local configuration saving succseeded." +msgid "Local configuration saving succseeded" msgstr "" #: source/ubl-strings.h:39 diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index 245f9fc..4b1e79c 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -154,32 +154,32 @@ msgid "Nothing were chosen" msgstr "Ничего не было выбрано" #: source/ubl-strings.h:32 -msgid "Global configuration loading succseeded." -msgstr "Успешно загружена глобальная конфигурация." +msgid "Global configuration loading succseeded" +msgstr "Успешно загружена глобальная конфигурация" #: source/ubl-strings.h:33 -msgid "Local configuration loading succseeded." -msgstr "Успешно загружена локальная конфигурация." +msgid "Local configuration loading succseeded" +msgstr "Успешно загружена локальная конфигурация" #: source/ubl-strings.h:34 msgid "Config loading failed" msgstr "Ошибка загрузки конфигурации" #: source/ubl-strings.h:36 -msgid "Local and global configuration saving succseeded." -msgstr "Успешно записаны локальная и глобальная конфигурация." +msgid "Local and global configuration saving succseeded" +msgstr "Успешно записаны локальная и глобальная конфигурация" #: source/ubl-strings.h:37 -msgid "Global configuration saving succseeded." -msgstr "Успешно записана глобальная конфигурация." +msgid "Global configuration saving succseeded" +msgstr "Успешно записана глобальная конфигурация" #: source/ubl-strings.h:38 -msgid "Local configuration saving succseeded." -msgstr "Успешно записана локальная конфигурация." +msgid "Local configuration saving succseeded" +msgstr "Успешно записана локальная конфигурация" #: source/ubl-strings.h:39 msgid "Warning! New machine ID will apply after system reboot" -msgstr "Внимание! Новый ID рабочей станции будет применён после перезагрузки системы." +msgstr "Внимание! Новый ID рабочей станции будет применён после перезагрузки системы" #: source/ubl-strings.h:41 msgid "Hostname:" -- 2.35.1 From 00c65db73aed1025e76d4edb4e6e59828f970bf6 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 22 Sep 2023 16:03:45 +0600 Subject: [PATCH 14/25] Localisation error fixes --- source/ubl-settings-system.c | 8 ++++---- source/ubl-strings.h | 10 +++++----- ubl-settings-system.pot | 10 +++++----- ubl-settings-system_ru.po | 10 +++++----- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 78685fd..fb20852 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -126,7 +126,7 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ gtk_list_store_set(widgets->languagelist,&iter,2,0,-1); } char *id = yon_config_get_by_key(id_parameter); - if (!strcmp(id,"Random")) + if (!strcmp(id,"random")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),1); else if (!strcmp(id,"hardware")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),2); @@ -186,7 +186,7 @@ void yon_config_global_load(GtkWidget *self, main_window *widgets){ gtk_list_store_set(widgets->languagelist,&iter,2,0,-1); } char *id = yon_config_get_by_key(id_parameter); - if (!strcmp(id,"Random")) + if (!strcmp(id,"random")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),1); else if (!strcmp(id,"hardware")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),2); @@ -311,9 +311,9 @@ void on_id_combo_toggled(GtkComboBox *self, main_window *widgets){ int id = gtk_combo_box_get_active(self); if (id==2||id==1){ if (yon_config_get_by_key(id_parameter)){ - yon_config_set(id_parameter, id == 1 ? "Random" : "hardware"); + yon_config_set(id_parameter, id == 1 ? "random" : "hardware"); } else { - yon_config_register(id_parameter,"config", id == 1 ? "Random":"hardware"); + yon_config_register(id_parameter,"config", id == 1 ? "random":"hardware"); } } if (id<3){ diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 6703f05..6b98513 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -29,13 +29,13 @@ #define NOTHING_CHOSEN_LABEL _("Nothing were chosen") -#define GLOBAL_LOAD_SUCCESS_LABEL _("Global configuration loading succseeded") -#define LOCAL_LOAD_SUCCESS_LABEL _("Local configuration loading succseeded") +#define GLOBAL_LOAD_SUCCESS_LABEL _("Global configuration loading succeeded") +#define LOCAL_LOAD_SUCCESS_LABEL _("Local configuration loading succeeded") #define LOAD_FAILED_LABEL _("Config loading failed") -#define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded") -#define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded") -#define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded") +#define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succeeded") +#define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succeeded") +#define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succeeded") #define SAVE_WARNING_LABEL _("Warning! New machine ID will apply after system reboot") #define HOSTNAME_LABEL _("Hostname:") diff --git a/ubl-settings-system.pot b/ubl-settings-system.pot index 7c33049..87f9db9 100644 --- a/ubl-settings-system.pot +++ b/ubl-settings-system.pot @@ -150,11 +150,11 @@ msgid "Nothing were chosen" msgstr "" #: source/ubl-strings.h:32 -msgid "Global configuration loading succseeded" +msgid "Global configuration loading succeeded" msgstr "" #: source/ubl-strings.h:33 -msgid "Local configuration loading succseeded" +msgid "Local configuration loading succeeded" msgstr "" #: source/ubl-strings.h:34 @@ -162,15 +162,15 @@ msgid "Config loading failed" msgstr "" #: source/ubl-strings.h:36 -msgid "Local and global configuration saving succseeded" +msgid "Local and global configuration saving succeeded" msgstr "" #: source/ubl-strings.h:37 -msgid "Global configuration saving succseeded" +msgid "Global configuration saving succeeded" msgstr "" #: source/ubl-strings.h:38 -msgid "Local configuration saving succseeded" +msgid "Local configuration saving succeeded" msgstr "" #: source/ubl-strings.h:39 diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index 4b1e79c..0e5cec3 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -154,11 +154,11 @@ msgid "Nothing were chosen" msgstr "Ничего не было выбрано" #: source/ubl-strings.h:32 -msgid "Global configuration loading succseeded" +msgid "Global configuration loading succeeded" msgstr "Успешно загружена глобальная конфигурация" #: source/ubl-strings.h:33 -msgid "Local configuration loading succseeded" +msgid "Local configuration loading succeeded" msgstr "Успешно загружена локальная конфигурация" #: source/ubl-strings.h:34 @@ -166,15 +166,15 @@ msgid "Config loading failed" msgstr "Ошибка загрузки конфигурации" #: source/ubl-strings.h:36 -msgid "Local and global configuration saving succseeded" +msgid "Local and global configuration saving succeeded" msgstr "Успешно записаны локальная и глобальная конфигурация" #: source/ubl-strings.h:37 -msgid "Global configuration saving succseeded" +msgid "Global configuration saving succeeded" msgstr "Успешно записана глобальная конфигурация" #: source/ubl-strings.h:38 -msgid "Local configuration saving succseeded" +msgid "Local configuration saving succeeded" msgstr "Успешно записана локальная конфигурация" #: source/ubl-strings.h:39 -- 2.35.1 From 179cdffb700c02ccca51291c43e9498bab372026 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 22 Sep 2023 16:13:47 +0600 Subject: [PATCH 15/25] Localisation updates --- source/ubl-strings.h | 2 +- ubl-settings-system.pot | 2 +- ubl-settings-system_ru.po | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 6b98513..42ea7b2 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -46,7 +46,7 @@ #define MANUAL_LABEL _("Manual") #define CONSOLE_LABEL _("Console") #define FONT_LABEL _("Console font:") -#define LOCALE_LABEL _("Locale") +#define LOCALE_LABEL _("Locale:") #define LANGUAGE_LABEL _("Language:") #define DEFAULT_LABEL _("Default") diff --git a/ubl-settings-system.pot b/ubl-settings-system.pot index 87f9db9..1fa8d52 100644 --- a/ubl-settings-system.pot +++ b/ubl-settings-system.pot @@ -210,7 +210,7 @@ msgid "Console font:" msgstr "" #: source/ubl-strings.h:49 -msgid "Locale" +msgid "Locale:" msgstr "" #: source/ubl-strings.h:50 diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index 0e5cec3..7dfded3 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -111,7 +111,7 @@ msgstr "Сохранить" #: source/ubl-strings.h:18 msgid "Load local configuration" -msgstr "Загрузить локальную конфигуруцию" +msgstr "Загрузить локальную конфигурацию" #: source/ubl-strings.h:19 msgid "Load global configuration" @@ -214,8 +214,8 @@ msgid "Console font:" msgstr "Шрифт в консоли:" #: source/ubl-strings.h:49 -msgid "Locale" -msgstr "Локаль" +msgid "Locale:" +msgstr "Локаль:" #: source/ubl-strings.h:50 msgid "Language:" -- 2.35.1 From dd22cb38f4516d31220b1cdf29f62637472822ab Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 22 Sep 2023 16:20:01 +0600 Subject: [PATCH 16/25] Translation changes --- ubl-settings-system_ru.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index 7dfded3..e407101 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -215,7 +215,7 @@ msgstr "Шрифт в консоли:" #: source/ubl-strings.h:49 msgid "Locale:" -msgstr "Локаль:" +msgstr "Доступные языки в системе:" #: source/ubl-strings.h:50 msgid "Language:" -- 2.35.1 From 59a0b3cbc601abd4a1292aceaee313d3046aadbc Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 25 Sep 2023 09:16:52 +0600 Subject: [PATCH 17/25] added 'Default' option on locale string if absent in config file --- source/ubl-settings-system.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index fb20852..39a76b1 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -112,7 +112,7 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ void yon_config_local_load(GtkWidget *self, main_window *widgets){ gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),""); gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),""); - gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),""); + gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),DEFAULT_LABEL); int size; GtkTreeIter iter; config_str rtn = yon_config_load(get_id_command,&size); @@ -164,7 +164,7 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ locale_string = yon_char_unite(strcmp(locale_string,"") ? yon_char_append(locale_string,"; ") : locale_string, loc_name,NULL); } } - gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),locale_string); + if (strcmp(locale_string,"")) gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),locale_string); } yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } @@ -172,7 +172,7 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ void yon_config_global_load(GtkWidget *self, main_window *widgets){ gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),""); gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),""); - gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),""); + gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),DEFAULT_LABEL); int size; GtkTreeIter iter; config_str rtn = yon_config_load(get_id_command,&size); @@ -224,7 +224,7 @@ void yon_config_global_load(GtkWidget *self, main_window *widgets){ locale_string = yon_char_unite(strcmp(locale_string,"") ? yon_char_append(locale_string,"; ") : locale_string, loc_name,NULL); } } - gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),locale_string); + if (strcmp(locale_string,"")) gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),locale_string); } yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } -- 2.35.1 From bfe50acf7fe5407b46974b5870a5794ee2a23657 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 25 Sep 2023 09:17:13 +0600 Subject: [PATCH 18/25] translation fixes --- source/ubl-strings.h | 1 + ubl-settings-system.pot | 4 ++++ ubl-settings-system_ru.po | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 42ea7b2..784063c 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -46,6 +46,7 @@ #define MANUAL_LABEL _("Manual") #define CONSOLE_LABEL _("Console") #define FONT_LABEL _("Console font:") +#define LOCALE_SECTION_LABEL _("Locale") #define LOCALE_LABEL _("Locale:") #define LANGUAGE_LABEL _("Language:") diff --git a/ubl-settings-system.pot b/ubl-settings-system.pot index 1fa8d52..1250dfa 100644 --- a/ubl-settings-system.pot +++ b/ubl-settings-system.pot @@ -209,6 +209,10 @@ msgstr "" msgid "Console font:" msgstr "" +#: source/ubl-strings.h:49 +msgid "Locale" +msgstr "" + #: source/ubl-strings.h:49 msgid "Locale:" msgstr "" diff --git a/ubl-settings-system_ru.po b/ubl-settings-system_ru.po index e407101..89c9dd4 100644 --- a/ubl-settings-system_ru.po +++ b/ubl-settings-system_ru.po @@ -213,6 +213,10 @@ msgstr "Консоль" msgid "Console font:" msgstr "Шрифт в консоли:" +#: source/ubl-strings.h:49 +msgid "Locale" +msgstr "Локаль" + #: source/ubl-strings.h:49 msgid "Locale:" msgstr "Доступные языки в системе:" -- 2.35.1 From 5cd386805df5d777868f14244bb68eec670c1f8f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 25 Sep 2023 09:25:36 +0600 Subject: [PATCH 19/25] language combobox state saving fix --- source/ubl-settings-system.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 39a76b1..23de598 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -373,18 +373,14 @@ void on_console_font_changed(GtkComboBox *self, main_window *widgets){ void on_language_changed(GtkComboBox *self, main_window *widgets){ GtkTreeIter iter; - if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->LanguageCombo))==0){ - yon_config_remove_by_key(language_parameter); + gtk_combo_box_get_active_iter(self,&iter); + char *code; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->languagelist),&iter,1,&code,-1); + if (code) + if (yon_config_get_by_key(language_parameter)){ + yon_config_set(language_parameter,code); } else { - gtk_combo_box_get_active_iter(self,&iter); - char *code; - gtk_tree_model_get(GTK_TREE_MODEL(widgets->languagelist),&iter,1,&code,-1); - if (code) - if (yon_config_get_by_key(language_parameter)){ - yon_config_set(language_parameter,code); - } else { - yon_config_register(language_parameter,"locale",code); - } + yon_config_register(language_parameter,"locale",code); } } -- 2.35.1 From acb0336ec2acbbf39156d67d9386792a8c3caf00 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 26 Sep 2023 11:24:49 +0600 Subject: [PATCH 20/25] Removed 800x600 sized window setting when window can be smaller --- ubl-settings-system.glade | 2 -- 1 file changed, 2 deletions(-) diff --git a/ubl-settings-system.glade b/ubl-settings-system.glade index 37b2560..00b3a02 100644 --- a/ubl-settings-system.glade +++ b/ubl-settings-system.glade @@ -497,8 +497,6 @@ translated and supported by community. 800 False - 800 - 600 com.ublinux.ubl-settings-system -- 2.35.1 From a53798635c50428856c0f6b50522647bc4d3d42c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 26 Sep 2023 11:28:37 +0600 Subject: [PATCH 21/25] Config cleaning argument added --- source/ubl-settings-system.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 23de598..9a8f663 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -528,6 +528,7 @@ int main(int argc, char *argv[]){ {"socket-ext-id", 1,0, 'e'}, {"socket-trd-id", 1,0, 't'}, {"debug", 0,0, 'd'}, + {"clean-config", 0,0, 'c'}, { NULL, 0, NULL, 0 } }; for (int i=0;i Date: Tue, 26 Sep 2023 12:44:33 +0600 Subject: [PATCH 22/25] Fixed unblocking of save buttons without root --- source/ubl-settings-system.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 9a8f663..71ce381 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -332,9 +332,12 @@ void on_id_changed(GtkEntry *self, main_window *widgets){ } else { yon_config_register(id_parameter,"config",text); } - gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,1); - gtk_widget_set_sensitive(widgets->SaveMenuItem,1); - gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,1); + if (!main_config.lock_save_global) + gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,1); + if (!main_config.lock_save_global&&!main_config.lock_save_global) + gtk_widget_set_sensitive(widgets->SaveMenuItem,1); + if (!main_config.lock_save_local) + gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,1); gtk_widget_set_sensitive(widgets->IDCopyButton,1); yon_ubl_status_box_render(INSERT_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } else { @@ -454,17 +457,6 @@ main_window *setup_window(){ gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->DocumentationMenuItem); gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->AboutMenuItem); - if (main_config.lock_load_global == 1){ - gtk_widget_set_sensitive(widgets->LoadGlobalMenuItem,0); - } - if (main_config.lock_save_global == 1){ - gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,0); - gtk_widget_set_sensitive(widgets->SaveMenuItem,0); - } - if (main_config.lock_save_local == 1){ - gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,0); - gtk_widget_set_sensitive(widgets->SaveMenuItem,0); - } /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ // yon_window_config_add_custom_parameter(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING); @@ -504,6 +496,17 @@ main_window *setup_window(){ gtk_list_store_append(widgets->fontlist,&iter); gtk_list_store_set(widgets->fontlist,&iter,0,fonts[i],-1); } + if (main_config.lock_load_global == 1){ + gtk_widget_set_sensitive(widgets->LoadGlobalMenuItem,0); + } + if (main_config.lock_save_global == 1){ + gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveMenuItem,0); + } + if (main_config.lock_save_local == 1){ + gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveMenuItem,0); + } gtk_widget_show(widgets->Window); return widgets; } -- 2.35.1 From f3a04ee479ca8ae946b564548692d69ca23f4d80 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 26 Sep 2023 13:55:36 +0600 Subject: [PATCH 23/25] Added block for 'id changed' function --- source/ubl-settings-system.c | 8 ++++++-- source/ubl-settings-system.h | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index 71ce381..be77a12 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -110,6 +110,7 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ } void yon_config_local_load(GtkWidget *self, main_window *widgets){ + 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),""); gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),DEFAULT_LABEL); @@ -166,10 +167,13 @@ void yon_config_local_load(GtkWidget *self, main_window *widgets){ } if (strcmp(locale_string,"")) gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),locale_string); } + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->IDEntry),G_CALLBACK(on_id_changed),widgets); + if (getuid()==0) yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } void yon_config_global_load(GtkWidget *self, main_window *widgets){ + 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),""); gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),DEFAULT_LABEL); @@ -226,6 +230,8 @@ void yon_config_global_load(GtkWidget *self, main_window *widgets){ } if (strcmp(locale_string,"")) gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),locale_string); } + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->IDEntry),G_CALLBACK(on_id_changed),widgets); + if (getuid()==0) yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } @@ -597,8 +603,6 @@ int main(int argc, char *argv[]){ yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); if (getuid()!=0) yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - else - yon_ubl_status_box_render(TITLE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); yon_window_config_setup(GTK_WINDOW(widgets->Window)); yon_window_config_load(config_path); diff --git a/source/ubl-settings-system.h b/source/ubl-settings-system.h index 152a713..e05ebbd 100644 --- a/source/ubl-settings-system.h +++ b/source/ubl-settings-system.h @@ -135,4 +135,5 @@ typedef struct { GtkCellRenderer *ToggleCell; } locals_window; -main_window *setup_window(); \ No newline at end of file +main_window *setup_window(); +void on_id_changed(GtkEntry *self, main_window *widgets); \ No newline at end of file -- 2.35.1 From 232f559124fb6ee5ae101a775df49dfa6db17d4d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 28 Sep 2023 10:20:12 +0600 Subject: [PATCH 24/25] Variable rename --- source/ubl-settings-system.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubl-settings-system.h b/source/ubl-settings-system.h index e05ebbd..61ba0af 100644 --- a/source/ubl-settings-system.h +++ b/source/ubl-settings-system.h @@ -38,7 +38,7 @@ #define hostname_parameter "HOSTNAME" #define id_parameter "MACHINEID" -#define keyboard_layout_parameter "XkbLayout" +#define keyboard_layout_parameter "XKBLAYOUT" #define console_font_parameter "CONSOLE_FONT" #define num_lock_boot_parameter "NUMLOCK" #define language_parameter "LANG" -- 2.35.1 From 98d0bd7431b334f1fec8e9439e9bac4bf443e4c3 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 28 Sep 2023 10:32:01 +0600 Subject: [PATCH 25/25] strings of sections were replaced with macros --- source/ubl-settings-system.c | 14 +++++++------- source/ubl-settings-system.h | 7 +++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index be77a12..ca41b3c 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -103,7 +103,7 @@ void on_about(){ //functions void yon_load_proceed(YON_CONFIG_TYPE type){ - if (yon_config_load_register(type,"config",hostname_parameter,"config",id_parameter,"locale",console_font_parameter,"locale",locale_parameter,"locale",language_parameter,NULL)){} + if (yon_config_load_register(type,hostname_section,hostname_parameter,id_section,id_parameter,console_font_section,console_font_parameter,locale_section,locale_parameter,language_section,language_parameter,NULL)){} else yon_ubl_status_box_render(LOAD_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); @@ -279,7 +279,7 @@ void on_locale_accept(GtkWidget *self, dictionary *dict){ } gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),final_string); if (yon_config_get_by_key("LOCALE")) yon_config_set("LOCALE",final_ids); - else yon_config_register("LOCALE","locale",final_ids); + else yon_config_register("LOCALE",locale_section,final_ids); on_close_subwindow(self); } @@ -309,7 +309,7 @@ void on_hostname_changed(GtkEntry *self, main_window *widgets){ if (yon_config_get_by_key(hostname_parameter)){ yon_config_set(hostname_parameter,text); } else { - yon_config_register(hostname_parameter,"config",text); + yon_config_register(hostname_parameter,hostname_section,text); } } @@ -319,7 +319,7 @@ void on_id_combo_toggled(GtkComboBox *self, main_window *widgets){ if (yon_config_get_by_key(id_parameter)){ yon_config_set(id_parameter, id == 1 ? "random" : "hardware"); } else { - yon_config_register(id_parameter,"config", id == 1 ? "random":"hardware"); + yon_config_register(id_parameter,id_section, id == 1 ? "random":"hardware"); } } if (id<3){ @@ -336,7 +336,7 @@ void on_id_changed(GtkEntry *self, main_window *widgets){ if (yon_config_get_by_key(id_parameter)){ yon_config_set(id_parameter,text); } else { - yon_config_register(id_parameter,"config",text); + yon_config_register(id_parameter,id_section,text); } if (!main_config.lock_save_global) gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,1); @@ -375,7 +375,7 @@ void on_console_font_changed(GtkComboBox *self, main_window *widgets){ if (yon_config_get_by_key(console_font_parameter)){ yon_config_set(console_font_parameter,code); } else { - yon_config_register(console_font_parameter,"locale",code); + yon_config_register(console_font_parameter,console_font_section,code); } } } @@ -389,7 +389,7 @@ void on_language_changed(GtkComboBox *self, main_window *widgets){ if (yon_config_get_by_key(language_parameter)){ yon_config_set(language_parameter,code); } else { - yon_config_register(language_parameter,"locale",code); + yon_config_register(language_parameter,language_section,code); } } diff --git a/source/ubl-settings-system.h b/source/ubl-settings-system.h index 61ba0af..7ba558f 100644 --- a/source/ubl-settings-system.h +++ b/source/ubl-settings-system.h @@ -37,12 +37,19 @@ // #define get_fonts_command "ls /usr/share/kbd/consolefonts/ |grep -v \"README\"|grep -oE \"^[-a-zA-Z0-9_]{3,}.psf\"|sed -e 's/\\.psf//g'" #define hostname_parameter "HOSTNAME" +#define hostname_section "config" #define id_parameter "MACHINEID" +#define id_section "config" #define keyboard_layout_parameter "XKBLAYOUT" +#define keyboard_section "keyboard" #define console_font_parameter "CONSOLE_FONT" +#define console_font_section "locale" #define num_lock_boot_parameter "NUMLOCK" +#define num_lock_boot_section "config" #define language_parameter "LANG" +#define language_section "locale" #define locale_parameter "LOCALE" +#define locale_section "locale" typedef char* string; string version_application; -- 2.35.1