diff --git a/gresource.xml b/gresource.xml index 5a3a1a3..9af9d5d 100644 --- a/gresource.xml +++ b/gresource.xml @@ -6,6 +6,8 @@ libublsettingsui-gtk3-documentation.glade libublsettingsui-gtk3-saving.glade libublsettingsui-gtk3-debugger.glade + libublsettingsui-gtk3-filechooser.glade + libublsettingsui-gtk3-config-window.glade libublsettingsui-gtk3.css diff --git a/icons/status/com.ublinux.libublsettingsui-gtk3.checked.svg b/icons/status/com.ublinux.libublsettingsui-gtk3.checked.svg index e3cab42..1ab3d35 100644 --- a/icons/status/com.ublinux.libublsettingsui-gtk3.checked.svg +++ b/icons/status/com.ublinux.libublsettingsui-gtk3.checked.svg @@ -5,8 +5,8 @@ version="1.1" viewBox="0 0 24 24" id="svg25" - sodipodi:docname="checked.svg" - inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)" + sodipodi:docname="com.ublinux.libublsettingsui-gtk3.checked.svg" + inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" @@ -21,14 +21,16 @@ inkscape:pagecheckerboard="0" showgrid="false" inkscape:zoom="14.8125" - inkscape:cx="-4.6919831" + inkscape:cx="-4.6582278" inkscape:cy="9.9578059" - inkscape:window-width="1920" - inkscape:window-height="1027" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="1" - inkscape:current-layer="svg25" /> + inkscape:window-width="1631" + inkscape:window-height="1047" + inkscape:window-x="1966" + inkscape:window-y="17" + inkscape:window-maximized="0" + inkscape:current-layer="svg25" + inkscape:showpageshadow="2" + inkscape:deskcolor="#d1d1d1" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libublsettingsui-gtk3-filechooser.glade b/libublsettingsui-gtk3-filechooser.glade index c1ebeea..c5d317b 100644 --- a/libublsettingsui-gtk3-filechooser.glade +++ b/libublsettingsui-gtk3-filechooser.glade @@ -2,6 +2,22 @@ + + True + False + com.ublinux.libublsettingsui-gtk3.cancel-symbolic + + + + True + False + com.ublinux.libublsettingsui-gtk3.accept-symbolic + + 450 500 @@ -14,7 +30,6 @@ True False vertical - 5 True @@ -34,15 +49,10 @@ True False - 5 - 5 - 5 - 5 - 5 vertical 5 - + True False False @@ -54,6 +64,22 @@ 0 + + + Choose directory instead of file + True + True + False + end + True + + + False + True + end + 1 + + True @@ -67,7 +93,6 @@ True False - True True @@ -103,7 +128,7 @@ - Save + Load True True True @@ -123,20 +148,4 @@ - - True - False - com.ublinux.libublsettingsui-gtk3.cancel-symbolic - - - - True - False - com.ublinux.libublsettingsui-gtk3.accept-symbolic - - diff --git a/libublsettingsui-gtk3.glade b/libublsettingsui-gtk3.glade index 2e204d8..a70d977 100644 --- a/libublsettingsui-gtk3.glade +++ b/libublsettingsui-gtk3.glade @@ -228,10 +228,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 640 - 440 False - 1024 - 720 + 800 + 500 com.ublinux.libublsettingsui-gtk3 diff --git a/libublsettingsui-gtk3.pot b/libublsettingsui-gtk3.pot index 9bad71f..191d72a 100644 --- a/libublsettingsui-gtk3.pot +++ b/libublsettingsui-gtk3.pot @@ -17,248 +17,280 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: source/libublsettingsui-gtk3.h:34 +#: source/libublsettingsui-gtk3.h:299 msgid "Version:" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid " version:" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Usage:" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "[OPTIONS]" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Options:" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Show this help" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Show package version" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Lock this help menu" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Lock configuration saving" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Lock local configration saving" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Lock global configration saving" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Lock global configration loading" msgstr "" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Reset application settings" msgstr "" -#: source/libublsettingsui-gtk3.h:40 +#: source/libublsettingsui-gtk3.h:305 msgid "Operation succeeded" msgstr "" -#: source/libublsettingsui-gtk3.h:41 +#: source/libublsettingsui-gtk3.h:306 msgid "" "Warning! Application was launched without root - root-dependent actions are " "locked" msgstr "" -#: source/libublsettingsui-gtk3.h:43 +#: source/libublsettingsui-gtk3.h:308 +msgid "Default" +msgstr "" + +#: source/libublsettingsui-gtk3.h:309 msgid "About" msgstr "" -#: source/libublsettingsui-gtk3.h:44 +#: source/libublsettingsui-gtk3.h:310 msgid "Documentation" msgstr "" -#: source/libublsettingsui-gtk3.h:46 +#: source/libublsettingsui-gtk3.h:312 msgid "Save to specific file" msgstr "" -#: source/libublsettingsui-gtk3.h:47 +#: source/libublsettingsui-gtk3.h:313 msgid "Save to local configuration" msgstr "" -#: source/libublsettingsui-gtk3.h:48 +#: source/libublsettingsui-gtk3.h:314 msgid "Save to global configuration" msgstr "" -#: source/libublsettingsui-gtk3.h:49 +#: source/libublsettingsui-gtk3.h:315 msgid "Save configuration" msgstr "" -#: source/libublsettingsui-gtk3.h:50 +#: source/libublsettingsui-gtk3.h:316 msgid "Save" msgstr "" -#: source/libublsettingsui-gtk3.h:51 +#: source/libublsettingsui-gtk3.h:317 msgid "Saving..." msgstr "" -#: source/libublsettingsui-gtk3.h:53 +#: source/libublsettingsui-gtk3.h:319 msgid "Load from specific file" msgstr "" -#: source/libublsettingsui-gtk3.h:54 +#: source/libublsettingsui-gtk3.h:320 msgid "Load local configuration" msgstr "" -#: source/libublsettingsui-gtk3.h:55 +#: source/libublsettingsui-gtk3.h:321 msgid "Load global configuration" msgstr "" -#: source/libublsettingsui-gtk3.h:56 +#: source/libublsettingsui-gtk3.h:322 msgid "Load" msgstr "" -#: source/libublsettingsui-gtk3.h:58 +#: source/libublsettingsui-gtk3.h:324 msgid "Cancel" msgstr "" -#: source/libublsettingsui-gtk3.h:59 +#: source/libublsettingsui-gtk3.h:325 msgid "Accept" msgstr "" -#: source/libublsettingsui-gtk3.h:60 +#: source/libublsettingsui-gtk3.h:326 msgid "Open" msgstr "" -#: source/libublsettingsui-gtk3.h:62 +#: source/libublsettingsui-gtk3.h:328 msgid "Would you like to read documentation in the Web?" msgstr "" -#: source/libublsettingsui-gtk3.h:63 +#: source/libublsettingsui-gtk3.h:329 msgid "" "You will be redirected to documentation website where documentation is\n" "translated and supported by community." msgstr "" -#: source/libublsettingsui-gtk3.h:64 +#: source/libublsettingsui-gtk3.h:330 msgid "Always redirect to online documentation" msgstr "" -#: source/libublsettingsui-gtk3.h:65 +#: source/libublsettingsui-gtk3.h:331 msgid "Open documentation" msgstr "" -#: source/libublsettingsui-gtk3.h:66 +#: source/libublsettingsui-gtk3.h:332 msgid "Project Home Page" msgstr "" -#: source/libublsettingsui-gtk3.h:67 +#: source/libublsettingsui-gtk3.h:333 msgid "Nothing were chosen" msgstr "" -#: source/libublsettingsui-gtk3.h:68 +#: source/libublsettingsui-gtk3.h:334 msgid "Copyright © 2022 - 2023, UBSoft LLC" msgstr "" -#: source/libublsettingsui-gtk3.h:71 +#: source/libublsettingsui-gtk3.h:337 msgid "Global configuration loading succeeded." msgstr "" -#: source/libublsettingsui-gtk3.h:72 +#: source/libublsettingsui-gtk3.h:338 msgid "Local configuration loading succeeded." msgstr "" -#: source/libublsettingsui-gtk3.h:73 +#: source/libublsettingsui-gtk3.h:339 msgid "Config loading failed" msgstr "" -#: source/libublsettingsui-gtk3.h:75 +#: source/libublsettingsui-gtk3.h:341 msgid "Local and global configuration saving succeeded." msgstr "" -#: source/libublsettingsui-gtk3.h:76 +#: source/libublsettingsui-gtk3.h:342 msgid "Global configuration saving succeeded." msgstr "" -#: source/libublsettingsui-gtk3.h:77 +#: source/libublsettingsui-gtk3.h:343 msgid "Local configuration saving succeeded." msgstr "" -#: source/libublsettingsui-gtk3.h:79 +#: source/libublsettingsui-gtk3.h:344 +msgid "Configuration saving succeeded." +msgstr "" + +#: source/libublsettingsui-gtk3.h:346 msgid "Parameter" msgstr "" -#: source/libublsettingsui-gtk3.h:80 +#: source/libublsettingsui-gtk3.h:347 msgid "Old value" msgstr "" -#: source/libublsettingsui-gtk3.h:81 +#: source/libublsettingsui-gtk3.h:348 msgid "New value" msgstr "" -#: source/libublsettingsui-gtk3.h:82 +#: source/libublsettingsui-gtk3.h:349 msgid "" "Value\n" "(Old/New)" msgstr "" -#: source/libublsettingsui-gtk3.h:84 +#: source/libublsettingsui-gtk3.h:351 msgid "Nothing to save" msgstr "" -#: source/libublsettingsui-gtk3.h:85 +#: source/libublsettingsui-gtk3.h:352 msgid "Saving into local configuration" msgstr "" -#: source/libublsettingsui-gtk3.h:86 +#: source/libublsettingsui-gtk3.h:353 msgid "Saving into global configuration" msgstr "" -#: source/libublsettingsui-gtk3.h:87 +#: source/libublsettingsui-gtk3.h:354 msgid "Saving into global and local configuration" msgstr "" -#: source/libublsettingsui-gtk3.h:88 +#: source/libublsettingsui-gtk3.h:355 msgid "Saving into custom configuration at" msgstr "" -#: source/libublsettingsui-gtk3.h:93 +#: source/libublsettingsui-gtk3.h:360 msgid "Full saving mode" msgstr "" -#: source/libublsettingsui-gtk3.h:94 +#: source/libublsettingsui-gtk3.h:361 msgid "Saving into module" msgstr "" -#: source/libublsettingsui-gtk3.h:95 +#: source/libublsettingsui-gtk3.h:362 msgid "Sandbox mode" msgstr "" -#: source/libublsettingsui-gtk3.h:96 +#: source/libublsettingsui-gtk3.h:363 msgid "Sandbox with profile saving" msgstr "" -#: source/libublsettingsui-gtk3.h:97 +#: source/libublsettingsui-gtk3.h:364 msgid "HDD sandbox" msgstr "" -#: source/libublsettingsui-gtk3.h:98 +#: source/libublsettingsui-gtk3.h:365 msgid "HDD sandbox with profile saving" msgstr "" -#: source/libublsettingsui-gtk3.h:99 +#: source/libublsettingsui-gtk3.h:366 msgid "New configuration file creation failed" msgstr "" -#: source/libublsettingsui-gtk3.h:100 +#: source/libublsettingsui-gtk3.h:367 msgid "Upgrade to root" msgstr "" + +#: source/libublsettingsui-gtk3.h:368 +msgid "Settings" +msgstr "" + +#: source/libublsettingsui-gtk3.h:370 +msgid "Application settigs" +msgstr "" + +#: source/libublsettingsui-gtk3.h:372 +msgid "Invalid email adress" +msgstr "" + +#: source/libublsettingsui-gtk3.h:373 +msgid "Invalid path" +msgstr "" + +#: source/libublsettingsui-gtk3.h:375 +msgid "Choose path" +msgstr "" + +#: source/libublsettingsui-gtk3.h:377 +msgid "Choose directory instead of file" +msgstr "" diff --git a/libublsettingsui-gtk3_ru.po b/libublsettingsui-gtk3_ru.po index 59ce55b..fb3e7c7 100644 --- a/libublsettingsui-gtk3_ru.po +++ b/libublsettingsui-gtk3_ru.po @@ -17,63 +17,63 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: source/libublsettingsui-gtk3.h:34 +#: source/libublsettingsui-gtk3.h:299 msgid "Version:" msgstr "Версия:" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid " version:" msgstr " версия:" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Usage:" msgstr "Использование:" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "[OPTIONS]" msgstr "[АРГУМЕНТЫ]" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Options:" msgstr "Аргументы:" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Show this help" msgstr "Показать эту подсказку" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Show package version" msgstr "Показать версию пакета" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Lock this help menu" msgstr "Заблокировать это меню помощи" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Lock configuration saving" msgstr "Успешно записана локальная конфигурация" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Lock local configration saving" msgstr "Заблокировать сохранение локальной конфигурации" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Lock global configration saving" msgstr "Заблокировать сохранение глобальной конфигурации" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Lock global configration loading" msgstr "Заблокировать загрузку глобальную конфигурацию" -#: source/libublsettingsui-gtk3.h:35 +#: source/libublsettingsui-gtk3.h:300 msgid "Reset application settings" msgstr "Сбросить настройки программы" -#: source/libublsettingsui-gtk3.h:40 +#: source/libublsettingsui-gtk3.h:305 msgid "Operation succeeded" msgstr "Операция завершена" -#: source/libublsettingsui-gtk3.h:41 +#: source/libublsettingsui-gtk3.h:306 msgid "" "Warning! Application was launched without root - root-dependent actions are " "locked" @@ -81,71 +81,75 @@ msgstr "" "Внимание! Приложение было запущено без прав суперпользователя - действия, " "требующие их наличия заблокированы" -#: source/libublsettingsui-gtk3.h:43 +#: source/libublsettingsui-gtk3.h:308 +msgid "Default" +msgstr "По умолчанию" + +#: source/libublsettingsui-gtk3.h:309 msgid "About" msgstr "О программе" -#: source/libublsettingsui-gtk3.h:44 +#: source/libublsettingsui-gtk3.h:310 msgid "Documentation" msgstr "Справка" -#: source/libublsettingsui-gtk3.h:46 +#: source/libublsettingsui-gtk3.h:312 msgid "Save to specific file" msgstr "Сохранить в файл" -#: source/libublsettingsui-gtk3.h:47 +#: source/libublsettingsui-gtk3.h:313 msgid "Save to local configuration" msgstr "Сохранить в локальную конфигурацию" -#: source/libublsettingsui-gtk3.h:48 +#: source/libublsettingsui-gtk3.h:314 msgid "Save to global configuration" msgstr "Сохранить в глобальную конфигурацию" -#: source/libublsettingsui-gtk3.h:49 +#: source/libublsettingsui-gtk3.h:315 msgid "Save configuration" msgstr "Сохранить конфигурацию" -#: source/libublsettingsui-gtk3.h:50 +#: source/libublsettingsui-gtk3.h:316 msgid "Save" msgstr "Сохранить" -#: source/libublsettingsui-gtk3.h:51 +#: source/libublsettingsui-gtk3.h:317 msgid "Saving..." msgstr "Сохранение..." -#: source/libublsettingsui-gtk3.h:53 +#: source/libublsettingsui-gtk3.h:319 msgid "Load from specific file" msgstr "Загрузить из файла" -#: source/libublsettingsui-gtk3.h:54 +#: source/libublsettingsui-gtk3.h:320 msgid "Load local configuration" msgstr "Загрузить локальную конфигурацию" -#: source/libublsettingsui-gtk3.h:55 +#: source/libublsettingsui-gtk3.h:321 msgid "Load global configuration" msgstr "Загрузить глобальную конфигурацию" -#: source/libublsettingsui-gtk3.h:56 +#: source/libublsettingsui-gtk3.h:322 msgid "Load" msgstr "Загрузить" -#: source/libublsettingsui-gtk3.h:58 +#: source/libublsettingsui-gtk3.h:324 msgid "Cancel" msgstr "Отмена" -#: source/libublsettingsui-gtk3.h:59 +#: source/libublsettingsui-gtk3.h:325 msgid "Accept" msgstr "Принять" -#: source/libublsettingsui-gtk3.h:60 +#: source/libublsettingsui-gtk3.h:326 msgid "Open" msgstr "Открыть" -#: source/libublsettingsui-gtk3.h:62 +#: source/libublsettingsui-gtk3.h:328 msgid "Would you like to read documentation in the Web?" msgstr "Вы хотите прочитать справку в Сети?" -#: source/libublsettingsui-gtk3.h:63 +#: source/libublsettingsui-gtk3.h:329 msgid "" "You will be redirected to documentation website where documentation is\n" "translated and supported by community." @@ -153,63 +157,67 @@ msgstr "" "Вы будете перенаправлены на сайт с документацией, где страницы помощи\n" "переводятся и поддерживаются сообществом." -#: source/libublsettingsui-gtk3.h:64 +#: source/libublsettingsui-gtk3.h:330 msgid "Always redirect to online documentation" msgstr "Всегда перенаправлять" -#: source/libublsettingsui-gtk3.h:65 +#: source/libublsettingsui-gtk3.h:331 msgid "Open documentation" msgstr "Прочитать справку" -#: source/libublsettingsui-gtk3.h:66 +#: source/libublsettingsui-gtk3.h:332 msgid "Project Home Page" msgstr "Домашняя страница проекта" -#: source/libublsettingsui-gtk3.h:67 +#: source/libublsettingsui-gtk3.h:333 msgid "Nothing were chosen" msgstr "Ничего не было выбрано" -#: source/libublsettingsui-gtk3.h:68 +#: source/libublsettingsui-gtk3.h:334 msgid "Copyright © 2022 - 2023, UBSoft LLC" msgstr "Copyright © 2022 - 2023, ООО «Юбисофт»" -#: source/libublsettingsui-gtk3.h:71 +#: source/libublsettingsui-gtk3.h:337 msgid "Global configuration loading succeeded." msgstr "Успешно загружена глобальная конфигурация" -#: source/libublsettingsui-gtk3.h:72 +#: source/libublsettingsui-gtk3.h:338 msgid "Local configuration loading succeeded." msgstr "Успешно загружена локальная конфигурация" -#: source/libublsettingsui-gtk3.h:73 +#: source/libublsettingsui-gtk3.h:339 msgid "Config loading failed" msgstr "Ошибка загрузки конфига" -#: source/libublsettingsui-gtk3.h:75 +#: source/libublsettingsui-gtk3.h:341 msgid "Local and global configuration saving succeeded." msgstr "Успешно записаны локальная и глобальная конфигурация" -#: source/libublsettingsui-gtk3.h:76 +#: source/libublsettingsui-gtk3.h:342 msgid "Global configuration saving succeeded." msgstr "Успешно записана глобальная конфигурация" -#: source/libublsettingsui-gtk3.h:77 +#: source/libublsettingsui-gtk3.h:343 msgid "Local configuration saving succeeded." msgstr "Успешно записана локальная конфигурация" -#: source/libublsettingsui-gtk3.h:79 +#: source/libublsettingsui-gtk3.h:344 +msgid "Configuration saving succeeded." +msgstr "Успешно записана конфигурация" + +#: source/libublsettingsui-gtk3.h:346 msgid "Parameter" msgstr "Параметр" -#: source/libublsettingsui-gtk3.h:80 +#: source/libublsettingsui-gtk3.h:347 msgid "Old value" msgstr "Старое значение" -#: source/libublsettingsui-gtk3.h:81 +#: source/libublsettingsui-gtk3.h:348 msgid "New value" msgstr "Новое значение" -#: source/libublsettingsui-gtk3.h:82 +#: source/libublsettingsui-gtk3.h:349 msgid "" "Value\n" "(Old/New)" @@ -217,54 +225,78 @@ msgstr "" "Значение\n" "(Старое/Новое)" -#: source/libublsettingsui-gtk3.h:84 +#: source/libublsettingsui-gtk3.h:351 msgid "Nothing to save" msgstr "Нечего сохранять" -#: source/libublsettingsui-gtk3.h:85 +#: source/libublsettingsui-gtk3.h:352 msgid "Saving into local configuration" msgstr "Сохранение в локальный конфигурационный файл" -#: source/libublsettingsui-gtk3.h:86 +#: source/libublsettingsui-gtk3.h:353 msgid "Saving into global configuration" msgstr "Сохранение в глобальный конфигурационный файл" -#: source/libublsettingsui-gtk3.h:87 +#: source/libublsettingsui-gtk3.h:354 msgid "Saving into global and local configuration" msgstr "Сохранение в глобальный и локальный конфигурационный файл" -#: source/libublsettingsui-gtk3.h:88 +#: source/libublsettingsui-gtk3.h:355 msgid "Saving into custom configuration at" msgstr "Сохранение в конфигурационный файл по пути" -#: source/libublsettingsui-gtk3.h:93 +#: source/libublsettingsui-gtk3.h:360 msgid "Full saving mode" msgstr "Полное сохранение" -#: source/libublsettingsui-gtk3.h:94 +#: source/libublsettingsui-gtk3.h:361 msgid "Saving into module" msgstr "Сохранение в модуль" -#: source/libublsettingsui-gtk3.h:95 +#: source/libublsettingsui-gtk3.h:362 msgid "Sandbox mode" msgstr "Полная песочница в ОЗУ" -#: source/libublsettingsui-gtk3.h:96 +#: source/libublsettingsui-gtk3.h:363 msgid "Sandbox with profile saving" msgstr "Песочница с сохранением профиля пользователя" -#: source/libublsettingsui-gtk3.h:97 +#: source/libublsettingsui-gtk3.h:364 msgid "HDD sandbox" msgstr "Полная песочница на HDD" -#: source/libublsettingsui-gtk3.h:98 +#: source/libublsettingsui-gtk3.h:365 msgid "HDD sandbox with profile saving" msgstr "Полная песочница на HDD с сохранением профиля пользователя" -#: source/libublsettingsui-gtk3.h:99 +#: source/libublsettingsui-gtk3.h:366 msgid "New configuration file creation failed" msgstr "Ошибка создания нового файла конфигурации" -#: source/libublsettingsui-gtk3.h:100 +#: source/libublsettingsui-gtk3.h:367 msgid "Upgrade to root" msgstr "Повысить права до root" + +#: source/libublsettingsui-gtk3.h:368 +msgid "Settings" +msgstr "" + +#: source/libublsettingsui-gtk3.h:370 +msgid "Application settigs" +msgstr "Настройки" + +#: source/libublsettingsui-gtk3.h:372 +msgid "Invalid email adress" +msgstr "Неверный email-адрес" + +#: source/libublsettingsui-gtk3.h:373 +msgid "Invalid path" +msgstr "Неправильный путь" + +#: source/libublsettingsui-gtk3.h:375 +msgid "Choose path" +msgstr "Выбор пути" + +#: source/libublsettingsui-gtk3.h:377 +msgid "Choose directory instead of file" +msgstr "Выбрать папку вместо вайла" diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index d87dbcd..5bce0e2 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -41,7 +41,9 @@ set(DEPENDFILES ../libublsettingsui-gtk3-about.glade ../libublsettingsui-gtk3-documentation.glade ../libublsettingsui-gtk3-saving.glade + ../libublsettingsui-gtk3-filechooser.glade ../libublsettingsui-gtk3-debugger.glade + ../libublsettingsui-gtk3-config-window.glade ../gresource.xml ../libublsettingsui-gtk3-banner.png ../libublsettingsui-gtk3.css @@ -77,6 +79,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin add_library(${PROJECT_NAME} SHARED libublsettingsui-gtk3.c libublsettingsui-gtk3-save.c + libublsettingsui-gtk3-config-window.c + libublsettingsui-gtk3-filechooser.c libublsettingsui-gtk3.h ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}) diff --git a/source/libublsettingsui-gtk3-config-window.c b/source/libublsettingsui-gtk3-config-window.c new file mode 100644 index 0000000..72a8501 --- /dev/null +++ b/source/libublsettingsui-gtk3-config-window.c @@ -0,0 +1,266 @@ +#include "libublsettingsui-gtk3.h" + +void on_confuguration_combo_box_changed(GtkComboBox *self, char *id); +void __yon_on_boolean_parameter_toggled(GtkToggleButton *self ,char *id); + +typedef struct { + char *id; + GtkWidget *Box; + GtkWidget *CheckButton; +} yon_configuration_boolean_parameter; + +typedef struct { + char *id; + GtkWidget *Box; + GtkWidget *Label; + GtkWidget *Entry; +} yon_configuration_entry_parameter; + +typedef struct { + char *id; + GtkWidget *Box; + GtkWidget *Label; + GtkWidget *ComboBox; +} yon_configuration_combo_parameter; + +// typedef struct { +// char *id; +// GtkWidget *Label; +// GtkWidget *GtkTreeView; +// GtkListStore *list; +// } yon_configuration_list_parameter; + + + +typedef struct yon_configuration_parameters { + dictionary_fields(yon_configuration_parameters); + char *label; + char *value; + GCallback func; + enum CONFIGURATION_PARAMETER_TYPE type; +} yon_configuration_parameters; + +yon_configuration_entry_parameter *yon_configuration_entry_parameter_new(char *id, char *label_text){ + yon_configuration_entry_parameter *parameter = malloc(sizeof(yon_configuration_entry_parameter)); + parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + parameter->Label = gtk_label_new(label_text); + parameter->Entry = gtk_entry_new(); + parameter->id = yon_char_new(id); + gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Label,1,1,0); + gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Entry,1,1,0); + gtk_widget_show_all(parameter->Box); + return parameter; +} + +yon_configuration_parameters *__yon_settings_parameters = NULL; + +yon_configuration_combo_parameter *yon_configuration_combo_box_parameter_new(char *id, char *label_text, config_str parameters){ + yon_configuration_combo_parameter *parameter = malloc(sizeof(yon_configuration_combo_parameter)); + parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + parameter->Label = gtk_label_new(label_text); + parameter->ComboBox = gtk_combo_box_text_new(); + parameter->id = yon_char_new(id); + gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Label,0,0,0); + gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->ComboBox,0,0,0); + for (int i=0;parameters[i]&¶meters[i+1];i+=2){ + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(parameter->ComboBox),parameters[i],parameters[i+1]); + } + char *value = NULL; + yon_window_config_get_parameter("settings",id,&value,YON_TYPE_STRING); + if (!yon_char_is_empty(value)){ + gtk_combo_box_set_active_id(GTK_COMBO_BOX(parameter->ComboBox),value); + } else { + gtk_combo_box_set_active(GTK_COMBO_BOX(parameter->ComboBox),0); + } + g_signal_connect(G_OBJECT(parameter->ComboBox),"changed",G_CALLBACK(on_confuguration_combo_box_changed),id); + yon_configuration_parameters *target = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id); + if (target){ + if (target->func){ + g_signal_connect(G_OBJECT(parameter->ComboBox),"changed",G_CALLBACK(target->func),target->value); + } + } + gtk_widget_show_all(parameter->Box); + return parameter; +} + +ubl_settings_window *yon_ubl_settings_window_new(){ + ubl_settings_window *window = malloc(sizeof(ubl_settings_window)); + GtkBuilder *builder = gtk_builder_new_from_resource("/com/ublinux/ui/libublsettingsui-gtk3-config-window.glade"); + window->window = yon_gtk_builder_get_widget(builder,"Window"); + window->WorkZoneBox = yon_gtk_builder_get_widget(builder,"WorkZoneBox"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + return window; +} + + +yon_configuration_boolean_parameter *__yon_configuration_boolean_parameter_new(char *id, char *label_text){ + yon_configuration_boolean_parameter *parameter = malloc(sizeof(yon_configuration_boolean_parameter)); + parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + parameter->CheckButton = gtk_check_button_new_with_label(label_text); + parameter->id = yon_char_new(id); + + g_signal_connect(G_OBJECT(parameter->CheckButton),"toggled",G_CALLBACK(__yon_on_boolean_parameter_toggled),parameter->id); + gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->CheckButton,0,0,0); + return parameter; +} + +//parameter section + +yon_configuration_parameters *yon_configuration_parameter_new() +{ + yon_configuration_parameters *dict = malloc(sizeof(yon_configuration_parameters)); + dict->data = NULL; + dict->key = NULL; + dict->next = NULL; + dict->prev = NULL; + dict->data = NULL; + dict->value = NULL; + dict->func = NULL; + dict->first = (struct yon_configuration_parameters*)dict; + dict->data_type = DICTIONARY_OTHER_TYPE; + return dict; +} + +yon_configuration_parameters *yon_configuration_parameter_append(yon_configuration_parameters *targetdict) +{ + targetdict = (yon_configuration_parameters*)yon_dictionary_get_last((dictionary*)targetdict); + targetdict->next = (struct yon_configuration_parameters*)yon_configuration_parameter_new(); + targetdict->next->prev = (struct yon_configuration_parameters*)targetdict; + targetdict->next->first = targetdict->first; + targetdict->next->data_type = DICTIONARY_OTHER_TYPE; + targetdict->next->data = NULL; + targetdict->next->value = NULL; + targetdict->next->func = NULL; + return targetdict->next; +} + +yon_configuration_parameters *yon_configuration_parameter_new_with_label(char *key, void *data) +{ + yon_configuration_parameters *dct = yon_configuration_parameter_new(); + dct->key = yon_char_new(key); + dct->label = data; + dct->data_type = DICTIONARY_OTHER_TYPE; + return dct; +} + +yon_configuration_parameters *yon_configuration_parameter_append_with_label(yon_configuration_parameters *dict, char *key, void *data) +{ + yon_configuration_parameters *dct = yon_configuration_parameter_append(dict); + dct->key = yon_char_new(key); + dct->label = data; + dct->data_type = DICTIONARY_OTHER_TYPE; + return dct; +} + +#define yon_configuration_parameter_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_configuration_parameter_new_with_label(key,data); \ + else dict=yon_configuration_parameter_append_with_label(dict,key,data);} + +void yon_configuration_window_add_boolean_parameter(enum CONFIGURATION_PARAMETER_TYPE type, char *id, char *label){ + yon_configuration_parameter_add_or_create_if_exists_with_data(__yon_settings_parameters,id,label); + yon_configuration_parameters *parameter = (yon_configuration_parameters*)yon_dictionary_get_last((dictionary*)__yon_settings_parameters); + if (parameter){ + parameter->type = CONFIGURATION_PARAMETER_BOOL; + } +} + +char *yon_settings_configuration_get(char *id){ + char *return_val = NULL; + yon_window_config_get_parameter("settings",id,&return_val,YON_TYPE_STRING); + return return_val; +} + +//signnals section + +void __yon_on_ubl_settings_window_open(){ + if (!__yon_settings_parameters) return; + ubl_settings_window *window = yon_ubl_settings_window_new(); + dictionary *current = NULL; + for_dictionaries(current,(dictionary*)__yon_settings_parameters){ + switch(((yon_configuration_parameters*)current)->type){ + case CONFIGURATION_PARAMETER_BOOL:{ + yon_configuration_boolean_parameter *cur = __yon_configuration_boolean_parameter_new(((yon_configuration_parameters*)current)->key,((yon_configuration_parameters*)current)->label); + gtk_box_pack_start(GTK_BOX(window->WorkZoneBox),cur->Box,0,0,0); + gtk_widget_show_all(window->WorkZoneBox); + + } break; + case CONFIGURATION_PARAMETER_ENTRY:{ + // yon_configuration_entry_parameter *cur = __yon_configuration_entry_parameter_new(current->key,current->label); + // gtk_box_pack_start(GTK_BOX(window->WorkZoneBox),cur->Box,0,0,0); + + } break; + case CONFIGURATION_PARAMETER_COMBO_BOX:{ + yon_configuration_combo_parameter *cur = yon_configuration_combo_box_parameter_new(((yon_configuration_parameters*)current)->key,((yon_configuration_parameters*)current)->label,(config_str)((yon_configuration_parameters*)current)->data); + gtk_box_pack_start(GTK_BOX(window->WorkZoneBox),cur->Box,0,0,0); + gtk_widget_show_all(window->WorkZoneBox); + } break; + case CONFIGURATION_PARAMETER_LIST_MULTIPLE:{ + } break; + } + } + gtk_widget_show(window->window); +} + +void __yon_on_boolean_parameter_toggled(GtkToggleButton *self ,char *id){ + yon_configuration_parameters *current = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id); + if (current){ + current->data= gtk_toggle_button_get_active(self)?(void*)1:(void*)0; + } +} + +void on_confuguration_combo_box_changed(GtkComboBox *self, char *id){ + yon_configuration_parameters *cur = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id); + if (cur){ + char *cur_value = yon_char_new((char*)gtk_combo_box_get_active_id(self)); + if (yon_window_config_check_init()){ + yon_window_config_add_instant_parameter(id,"settings",cur_value,YON_TYPE_STRING); + } + } +} + +//init section + +void yon_configuration_window_add_combo_box_parameter(enum CONFIGURATION_PARAMETER_TYPE type, char *id, char *label, GCallback func, gpointer data,...){ + yon_configuration_parameter_add_or_create_if_exists_with_data(__yon_settings_parameters,id,label); + va_list args; + va_start(args,data); + char *cur=NULL; + int size=0; + config_str variants = NULL; + while ((cur=va_arg(args,char*))){ + yon_char_parsed_add_or_create_if_exists(variants,&size,cur); + } + { + char *target=NULL; + yon_window_config_get_parameter("settings",id,&target,YON_TYPE_STRING); + if (yon_char_is_empty(target)){ + yon_window_config_add_instant_parameter(id,"settings",variants[0],YON_TYPE_STRING); + } + } + yon_char_parsed_add_or_create_if_exists(variants,&size,NULL); + yon_configuration_parameters *parameter = (yon_configuration_parameters*)yon_dictionary_get_last((dictionary*)__yon_settings_parameters); + if (parameter){ + + parameter->data = (void*)variants; + parameter->type = CONFIGURATION_PARAMETER_COMBO_BOX; + parameter->func = func; + parameter->value = data; + } + +} + +void yon_ubl_settings_window_init(GtkMenu *menu){ + GtkWidget *menu_item = gtk_menu_item_new(); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + textdomain(template_ui_LocaleName); + GtkWidget *label = gtk_label_new(CONFIG_WINDOW_MENU_LABEL); + textdomain(template_app_information.app_locale); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemtop"); + GtkWidget *image = gtk_image_new_from_icon_name("com.ublinux.libublsettingsui-gtk3.settings-symbolic",GTK_ICON_SIZE_BUTTON); + gtk_menu_shell_prepend(GTK_MENU_SHELL(menu),menu_item); + gtk_container_add(GTK_CONTAINER(menu_item),box); + gtk_box_pack_start(GTK_BOX(box),image,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_widget_show_all(menu_item); + g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(__yon_on_ubl_settings_window_open),NULL); +} \ No newline at end of file diff --git a/source/libublsettingsui-gtk3-filechooser.c b/source/libublsettingsui-gtk3-filechooser.c new file mode 100644 index 0000000..1fc9d36 --- /dev/null +++ b/source/libublsettingsui-gtk3-filechooser.c @@ -0,0 +1,120 @@ +#include "libublsettingsui-gtk3.h" + +void on_file_chooser_accept(GtkWidget *, filechooser_window *window){ + switch (gtk_file_chooser_get_action(GTK_FILE_CHOOSER(window->MainFileChooser))){ + case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER: + case GTK_FILE_CHOOSER_ACTION_SAVE: + window->responce=GTK_RESPONSE_APPLY; + break; + + case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER: + case GTK_FILE_CHOOSER_ACTION_OPEN: + window->responce = GTK_RESPONSE_ACCEPT; + break; + } + gtk_widget_destroy(window->Window); + gtk_main_quit(); +} + +void on_file_chooser_cancel(GtkWidget *, filechooser_window *window){ + window->responce=GTK_RESPONSE_CANCEL; + gtk_widget_destroy(window->Window); + gtk_main_quit(); + +} + +void on_file_chooser_selected(GtkWidget *self, filechooser_window *window){ + if (window->last_any_selection) free(window->last_any_selection); + if (window->last_success_selection) free(window->last_success_selection); + + GSList *list = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(window->MainFileChooser)); + config_str paths_all = NULL; + config_str paths_success = NULL; + int all_size=0; + int success_size=0; + GtkFileChooserAction action = gtk_file_chooser_get_action(GTK_FILE_CHOOSER(window->MainFileChooser)); + for (int i=0;iChooseFolderCheck))&&yon_file_is_directory(data)) || + (action == GTK_FILE_CHOOSER_ACTION_OPEN&&!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->ChooseFolderCheck))&&!yon_file_is_directory(data)) || + (action == GTK_FILE_CHOOSER_ACTION_SAVE&&!yon_file_is_directory(data)) || + (action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER&&yon_file_is_directory(data)) + ){ + yon_char_parsed_add_or_create_if_exists(paths_success,&success_size,data); + } + + yon_char_parsed_add_or_create_if_exists(paths_all,&all_size,data); + } + char *full_success = yon_char_parsed_to_string(paths_success,success_size,","); + char *full_all = yon_char_parsed_to_string(paths_all,all_size,","); + window->last_any_selection = yon_char_is_empty(full_all)?NULL:full_all; + window->last_success_selection = yon_char_is_empty(full_success)?NULL:full_success; + if (all_size) yon_char_parsed_free(paths_all,all_size); + if (success_size) yon_char_parsed_free(paths_success,success_size); +} + +filechooser_window *__yon_filechooser_window = NULL; + +void yon_file_chooser_set_button_label(char *label){ + if (__yon_filechooser_window){ + gtk_button_set_label(GTK_BUTTON(__yon_filechooser_window->SaveButton),label); + } +} + +void on_file_chooser_exit(GtkWidget *, filechooser_window *){ + __yon_filechooser_window = NULL; +} + +filechooser_window *yon_file_chooser_window_new(GtkFileChooserAction action){ + if (!__yon_filechooser_window){ + filechooser_window *window = malloc(sizeof(filechooser_window)); + __yon_filechooser_window = window; + GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_filechooser); + window->Window = yon_gtk_builder_get_widget(builder,"Window"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->HeaderTopic = yon_gtk_builder_get_widget(builder,"HeaderTopic"); + window->MainFileChooser = yon_gtk_builder_get_widget(builder,"MainFileChooser"); + window->SaveButton = yon_gtk_builder_get_widget(builder,"SaveButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->ChooseFolderCheck = yon_gtk_builder_get_widget(builder,"ChooseFolderCheck"); + window->last_any_selection=NULL; + window->last_success_selection=NULL; + g_signal_connect(G_OBJECT(window->MainFileChooser),"selection-changed",G_CALLBACK(on_file_chooser_selected),window); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_file_chooser_cancel),window); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_file_chooser_accept),window); + g_signal_connect(G_OBJECT(window->Window),"destroy",G_CALLBACK(on_file_chooser_exit),window); + + gtk_file_chooser_set_action(GTK_FILE_CHOOSER(window->MainFileChooser),action); + switch(action){ + case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER: + gtk_widget_hide(window->ChooseFolderCheck); + gtk_button_set_label(GTK_BUTTON(window->SaveButton),yon_char_get_localised_from_lib(CREATE_FOLDER_LABEL)); + break; + case GTK_FILE_CHOOSER_ACTION_OPEN: + + break; + case GTK_FILE_CHOOSER_ACTION_SAVE: + gtk_widget_hide(window->ChooseFolderCheck); + gtk_button_set_label(GTK_BUTTON(window->SaveButton),yon_char_get_localised_from_lib(SAVE_LABEL)); + break; + case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER: + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->ChooseFolderCheck),1); + gtk_widget_hide(window->ChooseFolderCheck); + gtk_button_set_label(GTK_BUTTON(window->SaveButton),yon_char_get_localised_from_lib(SELECT_FOLDER_LABEL)); + break; + } + + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + return window; + } else { + return __yon_filechooser_window; + } +} + +GtkResponseType yon_file_chooser_start(filechooser_window *window){ + gtk_widget_show(window->Window); + gtk_main(); + + return window->responce; +} \ No newline at end of file diff --git a/source/libublsettingsui-gtk3-save.c b/source/libublsettingsui-gtk3-save.c index f187763..6f55daa 100644 --- a/source/libublsettingsui-gtk3-save.c +++ b/source/libublsettingsui-gtk3-save.c @@ -1,79 +1,11 @@ #include "libublsettingsui-gtk3.h" +#include "libublsettingsui-gtk3-save.h" -struct loaded_config { - dictionary_fields(loaded_config); - char *section; -}; - -template_saving_window *yon_saving_window_new(); - -struct loaded_config *yon_config_convert_parameter(config_str parsed, int size); - -/**function and argument, which called after successful config saving. - * Example: - * void on_save_done(main_window *widgets, config_str output, int size) +/* + ============== + saving section + ============== */ -void (*save_success_function)(void*,config_str,int)=NULL; -void *save_success_argument=NULL; -void (*save_failure_function)(void*,config_str,int)=NULL; -void *save_failure_argument=NULL; - -void yon_save_window_set_postsave_function(void *function, void *data){ - save_success_function=function; - save_success_argument=data; -} - -void yon_save_window_set_postsave_failure_function(void *function, void *data){ - save_failure_function=function; - save_failure_argument=data; -} - -void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path, template_saving_window *window){ - GtkTreeIter iter,itar; - if (path){ - if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),&itar,path)){ - gboolean is_active; - gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&is_active,-1); - gtk_list_store_set(window->list,&itar,0,!is_active,-1); - } - } - int once_active=0; - int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter); - for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){ - int is_active; - gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&is_active,-1); - if (is_active){ - once_active=1; - break; - } - } - if (!once_active) gtk_widget_set_sensitive(window->SaveButton,0); - else gtk_widget_set_sensitive(window->SaveButton,1); - -} - -template_debug_window *template_debugger_window_new(){ - template_debug_window *window = malloc(sizeof(template_debug_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_debug); - window->Window=yon_gtk_builder_get_widget(builder,"Window"); - window->HeaderTopic=yon_gtk_builder_get_widget(builder,"HeaderTopic"); - window->HeaderImage=yon_gtk_builder_get_widget(builder,"HeaderImage"); - window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); - window->Vte=yon_gtk_builder_get_widget(builder,"DebuggerTerminal"); - gtk_window_set_title(GTK_WINDOW(window->Window),template_app_information.app_title); - gtk_label_set_text(GTK_LABEL(window->HeaderTopic),template_app_information.app_title); - gtk_window_set_icon_name(GTK_WINDOW(window->Window),yon_char_append("com.ublinux.",template_app_information.app_tech_name)); - gtk_image_set_from_pixbuf(GTK_IMAGE(window->HeaderImage),gtk_icon_theme_load_icon_for_scale(gtk_icon_theme_get_default(),yon_char_append("com.ublinux.",template_app_information.app_tech_name),32,1,GTK_ICON_LOOKUP_FORCE_SIZE,NULL)); - - yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"DebugWindow"); - return window; -} - -struct save_return { - void *save_success_argument; - config_str file_return; - int file_save; -}; gboolean _yon_postsave_function_start(struct save_return *data){ save_success_function(data->save_success_argument,data->file_return,data->file_save); @@ -134,70 +66,276 @@ struct loaded_config *yon_save_window_get_saved_parameters(template_saving_windo config_str yon_loaded_config_convert_to_save_command(struct loaded_config *target, int *size,char *path){ (*size)=0; - dictionary *sections = NULL; + + config_str final_commands = NULL; + { + struct yon_temp_command_sections { + dictionary_fields(yon_temp_command_sections); + int status; + }; + + struct yon_temp_command_sections *sections = NULL; struct loaded_config *current; for_dictionaries(current,target){ - dictionary *cur_section=NULL; - if (sections&&(cur_section=yon_dictionary_get(§ions,current->section))){ - char *temp = yon_char_unite((char*)cur_section->data," ", current->key,"=\'",(char*)current->data,"\'",NULL); + struct yon_temp_command_sections *cur_section=NULL, *found = NULL; + if (sections){ + for_dictionaries(cur_section,sections){ + if (!strcmp(current->section,cur_section->key)){ + int status = yon_config_get_status(current->key); + if ((status==-1&&cur_section->status==-1)||(status>-1)&&cur_section->status>-1){ + found = cur_section; + } + } + } + cur_section = found; + } + if (cur_section){ + char *parameters_for_current_command = NULL; + if (yon_config_get_status(current->key)==-1){ + parameters_for_current_command = yon_char_unite((char*)cur_section->data," ", current->key,NULL); + } else { + parameters_for_current_command = yon_char_unite((char*)cur_section->data," ", current->key,"=\'",(char*)current->data,"\'",NULL); + } free(current->data); - cur_section->data = temp; + cur_section->data = parameters_for_current_command; } else { - char *parameters = yon_char_unite(current->key,"=\'",(char*)current->data,"\'",NULL); - yon_dictionary_add_or_create_if_exists_with_data(sections,current->section,parameters); + char *parameters_for_current_command = NULL; + if (yon_config_get_status(current->key)==-1){ + parameters_for_current_command = current->key; + } else { + parameters_for_current_command = yon_char_unite(current->key,"=\'",(char*)current->data,"\'",NULL); + } + dictionary *sections_dict = (dictionary*)sections; + yon_dictionary_add_or_create_if_exists_with_data(sections_dict,current->section,parameters_for_current_command); + sections = realloc(sections_dict,sizeof(struct yon_temp_command_sections)); + sections->status=yon_config_get_status(current->key); + } + + } + config_str commands = NULL; + { + struct yon_temp_command_sections *current; + for_dictionaries(current,sections){ + char *dull_command = NULL; + if (current->status>=0){ + dull_command = ubconfig_set_command_full(path,current->key,(char*)current->data); + } else { + dull_command = ubconfig_remove_command_full(path,current->key,(char*)current->data); + } + yon_char_parsed_add_or_create_if_exists(commands,size,dull_command); + free(dull_command); } } + return commands; } - config_str commands = NULL; - { - dictionary *current; - for_dictionaries(current,sections){ - char *dull_command = ubconfig_set_command_full(path,current->key,(char*)current->data); - char *command = yon_config_parameter_prepare_command(dull_command,NULL,current->key,NULL); - yon_char_parsed_add_or_create_if_exists(commands,size,command); - free(command); +} + +void yon_save_window_set_postsave_function(void *function, void *data){ + save_success_function=function; + save_success_argument=data; +} + +void yon_save_window_set_postsave_failure_function(void *function, void *data){ + save_failure_function=function; + save_failure_argument=data; +} + + +/* + ============== + window section + ============== +*/ +void yon_save_window_set_status(template_saving_window *window,char *path,YON_CONFIG_TYPE type){ + textdomain(template_ui_LocaleName); + window->type=type; + window->custom_save_path=path; + if (type==YON_CONFIG_BOTH){ + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_GLOBAL_LOCAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); + } else if (type==YON_CONFIG_GLOBAL){ + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_GLOBAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); + + } else if (type==YON_CONFIG_LOCAL){ + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_LOCAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); + } else if (type==YON_CONFIG_CUSTOM){ + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_CUSTOM_STATE_LABEL(path),BACKGROUND_IMAGE_INFO_TYPE); + } + textdomain(template_app_information.app_locale); +} + +gboolean yon_save_window_destroy_if_empty(template_saving_window *window){ + GtkTreeIter iter; + if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter)){ + gtk_widget_destroy(window->Window); + textdomain(template_ui_LocaleName); + yon_ubl_status_box_render(NOTHING_TO_SAVE_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + textdomain(template_app_information.app_locale); + if (save_failure_function){ + + struct save_return *data = malloc(sizeof(struct save_return)); + data->save_success_argument = save_failure_argument; + data->file_return = NULL; + data->file_save = 0; + gdk_threads_add_idle((GSourceFunc)_yon_postsave_failure_function_start,data); } + return 0; } - return commands; + return 1; } -int yon_config_parameter_prepare_elements(struct loaded_config *target){ - int success = 0; - struct loaded_config *current = NULL; - for_dictionaries(current,target){ - char *parameter = current->key; - if (strstr(parameter,"[")){ - char *param = yon_char_divide_search(parameter,"[",-1); - char *param_key = yon_char_divide_search(parameter,"]",-1); - free(parameter); - parameter = yon_char_unite(param,"[\"",param_key,"\"]",NULL); - current->key = parameter; - success=1; +void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path, template_saving_window *window){ + GtkTreeIter iter,itar; + if (path){ + if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),&itar,path)){ + gboolean is_active; + gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&is_active,-1); + gtk_list_store_set(window->list,&itar,0,!is_active,-1); } } - return success; + int once_active=0; + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){ + int is_active; + gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&is_active,-1); + if (is_active){ + once_active=1; + break; + } + } + if (!once_active) gtk_widget_set_sensitive(window->SaveButton,0); + else gtk_widget_set_sensitive(window->SaveButton,1); + } -void on_save_parameters(GtkWidget *self, template_saving_window *window){ - textdomain(template_ui_LocaleName); - yon_ubl_status_box_render(SAVE_PROCESS_LABEL,BACKGROUND_IMAGE_INFO_TYPE); - textdomain(template_app_information.app_locale); +template_saving_window *yon_saving_window_new(){ + GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_saving); + template_saving_window *window = malloc(sizeof(template_saving_window)); + window->Window = yon_gtk_builder_get_widget(builder,"Window"); + window->HeaderImage = yon_gtk_builder_get_widget(builder,"HeaderImage"); + window->HeaderTopic = yon_gtk_builder_get_widget(builder,"HeaderTopic"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->ParametersTree = yon_gtk_builder_get_widget(builder,"ParametersTree"); + window->SaveButton = yon_gtk_builder_get_widget(builder,"SaveButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->ToggleCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"ToggleCell")); + window->list = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); + window->OldValueColumn = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"OldValueColumn")); + window->OldValueCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"OldValueCell")); + window->NewValueColumn = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"NewValueColumn")); + window->NewValueCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"NewValueCell")); + window->filteredModel = GTK_TREE_MODEL(gtk_builder_get_object(builder,"listfilter1")); + yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"SaveWindow"); + char *icon_name = yon_char_append("com.ublinux.",template_app_information.app_tech_name); + gtk_window_set_icon_name(GTK_WINDOW(window->Window),icon_name); + gtk_window_set_title(GTK_WINDOW(window->Window),template_app_information.app_title); + gtk_label_set_text(GTK_LABEL(window->HeaderTopic),template_app_information.app_title); + gtk_image_set_from_pixbuf(GTK_IMAGE(window->HeaderImage),gtk_icon_theme_load_icon_for_scale(gtk_icon_theme_get_default(),yon_char_append("com.ublinux.",template_app_information.app_tech_name),32,1,GTK_ICON_LOOKUP_FORCE_SIZE,NULL)); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_save_parameters),window); + g_signal_connect(G_OBJECT(window->ToggleCell),"toggled", G_CALLBACK(on_save_window_parameter_switched),window); + return window; +} - int saved_size; - struct loaded_config *saved_parameters = yon_save_window_get_saved_parameters(window); - yon_config_parameter_prepare_elements(saved_parameters); - - int size=0; - config_str commands = yon_loaded_config_convert_to_save_command(saved_parameters,&size,window->type!=YON_CONFIG_CUSTOM? yon_config_get_type_path(window->type):window->custom_save_path); - - char *final_command = yon_char_parsed_to_string(commands,size,";"); - pthread_t thread_id; - pthread_create(&thread_id, NULL, (void *)_yon_saving_threaded,final_command); +/* + ====================== + config getting section + ====================== +*/ +char *yon_get_compare_config_command(va_list args,char *path,YON_CONFIG_TYPE type){ + char *cur_command; + char *compare_command=""; + while ((cur_command=va_arg(args,char*))){ + char *temp=cur_command; + cur_command = yon_config_parameter_prepare_command(cur_command,type!=YON_CONFIG_CUSTOM?yon_config_get_type_path(type):path,NULL,NULL); + char *temp_command = yon_char_unite(compare_command,!yon_char_is_empty(compare_command)?";":"",cur_command,NULL); + if (!yon_char_is_empty(compare_command)) free(compare_command); + compare_command = temp_command; + } + return yon_char_is_empty(compare_command)?NULL:compare_command; +} - yon_window_config_custom_window_set(GTK_WINDOW(window->Window),"SaveWindow"); - on_subwindow_close(self); +void yon_save_window_loaded_config_init(template_saving_window *window, struct loaded_config *current_loaded, struct loaded_config *config_compare){ + if (current_loaded){ + struct loaded_config *current = NULL; + for_dictionaries(current,current_loaded){ + if (!yon_config_check_ignore(current->key)){ + dictionary *dict = NULL; + if (!yon_config_compare_ignore_get(current->key)){ + dict = yon_dictionary_get((dictionary**)&config_compare,current->key); // get old parameter value + } + gboolean status=0; + status = yon_config_get_status(current->key); + if (dict&&!yon_char_is_empty((char*)dict->data)&&status!=-2){ + if (strcmp((char*)dict->data,(char*)current->data)){ + GtkTreeIter iter; + if (status==0||status==-2) status = 0; + else status=1; + char *old_val = yon_char_new(current->data); + char *new_val = yon_char_new(dict->data); + if (strstr(old_val,"&")) {old_val = yon_char_replace(old_val,"&","\003");old_val = yon_char_replace(old_val,"\003","&");} + if (strstr(old_val,">")) old_val = yon_char_replace(old_val,">","<"); + if (strstr(old_val,"<")) old_val = yon_char_replace(old_val,"<",">"); + if (strstr(new_val,"&")) {int sz = 0; config_str new_val_parsed = yon_char_parse(new_val,&sz,"&");new_val = yon_char_parsed_to_string(new_val_parsed,sz,"&"); yon_char_parsed_free(new_val_parsed,sz);} + if (strstr(new_val,">")) new_val = yon_char_replace(new_val,">","<"); + if (strstr(new_val,"<")) new_val = yon_char_replace(new_val,"<",">"); + char *compare_string = yon_char_unite("",(char*)new_val,"\n",(char*)old_val,NULL); + gtk_list_store_append(window->list,&iter); + gtk_list_store_set(window->list,&iter,0,status,1,current->key,2,(char*)dict->data,3,(char*)current->data,4,compare_string,6,1,7,yon_config_get_section_for_key(current->key),-1); + free(compare_string); + } + } else if ((strcmp((char*)current->data,""))&&status!=-2){ + GtkTreeIter iter; + if (status==0||status==-2) status = 0; + else status=1; + char *old_val = yon_char_new(current->data); + if (strstr(old_val,"&")) {int sz = 0; config_str old_val_parsed = yon_char_parse(old_val,&sz,"&");old_val = yon_char_parsed_to_string(old_val_parsed,sz,"&"); yon_char_parsed_free(old_val_parsed,sz);} + if (strstr(old_val,">")) old_val = yon_char_replace(old_val,">","<"); + if (strstr(old_val,"<")) old_val = yon_char_replace(old_val,"<",">"); + char *compare_string = yon_char_unite("\n",(char*)old_val,NULL); + gtk_list_store_append(window->list,&iter); + gtk_list_store_set(window->list,&iter,0,status,1,current->key,3,(char*)current->data,4,compare_string,6,1,7,yon_config_get_section_for_key(current->key),-1); + free(compare_string); + } + } + } + } +} + +void yon_save_window_compared_config_init_unfound(template_saving_window *window, struct loaded_config *current_loaded, struct loaded_config *config_compare){ + if (config_compare){ + struct loaded_config *current = NULL; + for_dictionaries(current,config_compare){ + if (!yon_config_check_ignore(current->key)){ + GtkTreeIter iter; + dictionary *dict = yon_dictionary_get((dictionary**)¤t_loaded,current->key); + if (!dict){ + GdkRGBA rgba; + rgba.alpha=0.8; + rgba.red=1; + rgba.blue=0.3; + rgba.green=0.65; + char *rgba_string = gdk_rgba_to_string(&rgba); + int status=0; + char *compare_string = yon_char_unite((char*)current->data,"\n",NULL); + gtk_list_store_append(window->list,&iter); + gtk_list_store_set(window->list,&iter,0,0,1,current->key,2,(char*)current->data,4,compare_string,5,rgba_string,6,1,7,current->section,-1); + free(compare_string); + } + } + } + } +} + +int yon_config_parameter_prepare_elements(config_str target, int *size){ + int success = 0; + for (int i=0;i<(*size);i++){ + char *start_bracket_replaced_string = yon_char_replace(target[i],"[","[\""); + char *end_bracket_replaced_string = yon_char_replace(start_bracket_replaced_string,"]","\"]"); + target[i] = end_bracket_replaced_string; + } + return success; } struct loaded_config *yon_config_convert_parameter(config_str parsed, int size){ @@ -316,20 +454,23 @@ struct loaded_config *yon_config_get_compared(char *command){ } -char *yon_custom_config_init(){ - 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,SAVE_LABEL,GTK_RESPONSE_ACCEPT,NULL); - textdomain(template_app_information.app_locale); +char *yon_custom_config_init(GtkFileChooserAction type){ + filechooser_window *dialog = yon_file_chooser_window_new(type); + gtk_widget_hide(dialog->ChooseFolderCheck); + yon_gtk_window_setup(GTK_WINDOW(dialog->Window),NULL,template_app_information.app_title,yon_char_unite("com.ublinux.",template_app_information.app_tech_name,NULL),"ConfigFilechooserWindow"); + gtk_label_set_text(GTK_LABEL(dialog->HeaderTopic),template_app_information.app_title); GtkFileFilter *filter = gtk_file_filter_new(); - gtk_window_set_icon_name(GTK_WINDOW(dialog),yon_char_append("com.ublinux.",template_app_information.app_tech_name)); 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_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog->MainFileChooser),filter); + if (type==GTK_FILE_CHOOSER_ACTION_SAVE){ + yon_file_chooser_set_button_label(yon_char_get_localised_from_lib(LOAD_CONFIG_LABEL)); - 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_file_chooser_start(dialog)==GTK_RESPONSE_ACCEPT){ + + char *file = dialog->last_success_selection; if (!yon_char_is_empty(file)){ if (!strstr(file,".ini")) file = yon_char_append(file,".ini"); if (access(file,0)!=F_OK){ @@ -342,123 +483,56 @@ char *yon_custom_config_init(){ } } } - char *path = yon_char_unite("'",file,"'",NULL); free(file); - gtk_widget_destroy(dialog); + gtk_widget_destroy(dialog->Window); return path; - - } else { - gtk_widget_destroy(dialog); } - return NULL; -} -char *yon_get_compare_config_command(va_list args,char *path,YON_CONFIG_TYPE type){ - char *cur_command; - char *compare_command=""; - while ((cur_command=va_arg(args,char*))){ - char *temp=cur_command; - cur_command = yon_config_parameter_prepare_command(cur_command,type!=YON_CONFIG_CUSTOM?yon_config_get_type_path(type):path,NULL,NULL); - char *temp_command = yon_char_unite(compare_command,!yon_char_is_empty(compare_command)?";":"",cur_command,NULL); - if (!yon_char_is_empty(compare_command)) free(compare_command); - compare_command = temp_command; - } - return yon_char_is_empty(compare_command)?NULL:compare_command; + return NULL; } -void yon_save_window_loaded_config_init(template_saving_window *window, struct loaded_config *current_loaded, struct loaded_config *config_compare){ - if (current_loaded){ - struct loaded_config *current = NULL; - for_dictionaries(current,current_loaded){ - if (!yon_config_check_ignore(current->key)){ - dictionary *dict = yon_dictionary_get((dictionary**)&config_compare,current->key); // get old parameter value - gboolean status=0; - status = yon_config_get_status(current->key); - if (dict&&!yon_char_is_empty((char*)dict->data)&&status!=-2){ - if (strcmp((char*)dict->data,(char*)current->data)){ - GtkTreeIter iter; - if (status==0||status==-2) status = 0; - else status=1; - char *compare_string = yon_char_unite("",(char*)dict->data,"\n",(char*)current->data,NULL); - gtk_list_store_append(window->list,&iter); - gtk_list_store_set(window->list,&iter,0,status,1,current->key,2,(char*)dict->data,3,(char*)current->data,4,compare_string,6,1,7,yon_config_get_section_for_key(current->key),-1); - free(compare_string); - } - } else if ((strcmp((char*)current->data,""))&&status!=-2){ - GtkTreeIter iter; - if (status==0||status==-2) status = 0; - else status=1; - char *compare_string = yon_char_unite("\n",(char*)current->data,NULL); - gtk_list_store_append(window->list,&iter); - gtk_list_store_set(window->list,&iter,0,status,1,current->key,3,(char*)current->data,4,compare_string,6,1,7,yon_config_get_section_for_key(current->key),-1); - free(compare_string); - } - } - } - } -} +/* + ============ + init section + ============ +*/ -void yon_save_window_compared_config_init_unfound(template_saving_window *window, struct loaded_config *current_loaded, struct loaded_config *config_compare){ - if (config_compare){ - struct loaded_config *current = NULL; - for_dictionaries(current,config_compare){ - if (!yon_config_check_ignore(current->key)){ - GtkTreeIter iter; - dictionary *dict = yon_dictionary_get((dictionary**)¤t_loaded,current->key); - if (!dict){ - GdkRGBA rgba; - rgba.alpha=0.8; - rgba.red=1; - rgba.blue=0.3; - rgba.green=0.65; - char *rgba_string = gdk_rgba_to_string(&rgba); - int status=0; - char *compare_string = yon_char_unite((char*)current->data,"\n",NULL); - gtk_list_store_append(window->list,&iter); - gtk_list_store_set(window->list,&iter,0,0,1,current->key,2,(char*)current->data,4,compare_string,5,rgba_string,6,1,7,current->section,-1); - free(compare_string); - } - } - } - } -} +void on_save_parameters(GtkWidget *self, template_saving_window *window){ + textdomain(template_ui_LocaleName); + yon_ubl_status_box_render(SAVE_PROCESS_LABEL,BACKGROUND_IMAGE_INFO_TYPE); + textdomain(template_app_information.app_locale); -gboolean yon_save_window_destroy_if_empty(template_saving_window *window){ - GtkTreeIter iter; - if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter)){ - gtk_widget_destroy(window->Window); - textdomain(template_ui_LocaleName); - yon_ubl_status_box_render(NOTHING_TO_SAVE_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - textdomain(template_app_information.app_locale); - if (save_failure_function){ + int saved_size; + struct loaded_config *saved_parameters = yon_save_window_get_saved_parameters(window); + + int size=0; + config_str commands = yon_loaded_config_convert_to_save_command(saved_parameters,&size,window->type!=YON_CONFIG_CUSTOM? yon_config_get_type_path(window->type):window->custom_save_path); + yon_config_parameter_prepare_elements(commands,&size); + + char *final_command = yon_char_parsed_to_string(commands,size,";"); + pthread_t thread_id; + pthread_create(&thread_id, NULL, (void *)_yon_saving_threaded,final_command); - struct save_return *data = malloc(sizeof(struct save_return)); - data->save_success_argument = save_failure_argument; - data->file_return = NULL; - data->file_save = 0; - gdk_threads_add_idle((GSourceFunc)_yon_postsave_failure_function_start,data); - } - return 0; - } - return 1; + yon_window_config_custom_window_set(GTK_WINDOW(window->Window),"SaveWindow"); + on_subwindow_close(self); } -void yon_save_window_set_status(template_saving_window *window,char *path,YON_CONFIG_TYPE type){ - textdomain(template_ui_LocaleName); - window->type=type; - window->custom_save_path=path; - if (type==YON_CONFIG_BOTH){ - yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_GLOBAL_LOCAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); - } else if (type==YON_CONFIG_GLOBAL){ - yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_GLOBAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); - - } else if (type==YON_CONFIG_LOCAL){ - yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_LOCAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); - } else if (type==YON_CONFIG_CUSTOM){ - yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_CUSTOM_STATE_LABEL(path),BACKGROUND_IMAGE_INFO_TYPE); - } - textdomain(template_app_information.app_locale); +template_debug_window *template_debugger_window_new(){ + template_debug_window *window = malloc(sizeof(template_debug_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_debug); + window->Window=yon_gtk_builder_get_widget(builder,"Window"); + window->HeaderTopic=yon_gtk_builder_get_widget(builder,"HeaderTopic"); + window->HeaderImage=yon_gtk_builder_get_widget(builder,"HeaderImage"); + window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); + window->Vte=yon_gtk_builder_get_widget(builder,"DebuggerTerminal"); + gtk_window_set_title(GTK_WINDOW(window->Window),template_app_information.app_title); + gtk_label_set_text(GTK_LABEL(window->HeaderTopic),template_app_information.app_title); + gtk_window_set_icon_name(GTK_WINDOW(window->Window),yon_char_append("com.ublinux.",template_app_information.app_tech_name)); + gtk_image_set_from_pixbuf(GTK_IMAGE(window->HeaderImage),gtk_icon_theme_load_icon_for_scale(gtk_icon_theme_get_default(),yon_char_append("com.ublinux.",template_app_information.app_tech_name),32,1,GTK_ICON_LOOKUP_FORCE_SIZE,NULL)); + + yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"DebugWindow"); + return window; } template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ @@ -467,7 +541,8 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ config_to_save = yon_config_get_type_path(type); if (!path&&type == YON_CONFIG_CUSTOM){ - path = yon_custom_config_init(); + path = yon_custom_config_init(GTK_FILE_CHOOSER_ACTION_SAVE); + if (!path) return NULL; } va_list args; @@ -496,32 +571,3 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ on_save_window_parameter_switched(NULL,NULL,window); return window; } - -template_saving_window *yon_saving_window_new(){ - GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_saving); - template_saving_window *window = malloc(sizeof(template_saving_window)); - window->Window = yon_gtk_builder_get_widget(builder,"Window"); - window->HeaderImage = yon_gtk_builder_get_widget(builder,"HeaderImage"); - window->HeaderTopic = yon_gtk_builder_get_widget(builder,"HeaderTopic"); - window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); - window->ParametersTree = yon_gtk_builder_get_widget(builder,"ParametersTree"); - window->SaveButton = yon_gtk_builder_get_widget(builder,"SaveButton"); - window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); - window->ToggleCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"ToggleCell")); - window->list = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); - window->OldValueColumn = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"OldValueColumn")); - window->OldValueCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"OldValueCell")); - window->NewValueColumn = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"NewValueColumn")); - window->NewValueCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"NewValueCell")); - window->filteredModel = GTK_TREE_MODEL(gtk_builder_get_object(builder,"listfilter1")); - yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"SaveWindow"); - char *icon_name = yon_char_append("com.ublinux.",template_app_information.app_tech_name); - gtk_window_set_icon_name(GTK_WINDOW(window->Window),icon_name); - gtk_window_set_title(GTK_WINDOW(window->Window),template_app_information.app_title); - gtk_label_set_text(GTK_LABEL(window->HeaderTopic),template_app_information.app_title); - gtk_image_set_from_pixbuf(GTK_IMAGE(window->HeaderImage),gtk_icon_theme_load_icon_for_scale(gtk_icon_theme_get_default(),yon_char_append("com.ublinux.",template_app_information.app_tech_name),32,1,GTK_ICON_LOOKUP_FORCE_SIZE,NULL)); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_save_parameters),window); - g_signal_connect(G_OBJECT(window->ToggleCell),"toggled", G_CALLBACK(on_save_window_parameter_switched),window); - return window; -} \ No newline at end of file diff --git a/source/libublsettingsui-gtk3-save.h b/source/libublsettingsui-gtk3-save.h new file mode 100644 index 0000000..c380028 --- /dev/null +++ b/source/libublsettingsui-gtk3-save.h @@ -0,0 +1,27 @@ + +struct loaded_config { + dictionary_fields(loaded_config); + char *section; +}; + +template_saving_window *yon_saving_window_new(); + +struct loaded_config *yon_config_convert_parameter(config_str parsed, int size); + +struct save_return { + void *save_success_argument; + config_str file_return; + int file_save; +}; + +/**function and argument, which called after successful config saving. + * Example: + * void on_save_done(main_window *widgets, config_str output, int size) +*/ +void (*save_success_function)(void*,config_str,int)=NULL; +void *save_success_argument=NULL; +void (*save_failure_function)(void*,config_str,int)=NULL; +void *save_failure_argument=NULL; + +#define default_config_command(target, data) yon_char_unite("ubconfig --source default --raw get ",target," ",data,NULL) +void on_save_parameters(GtkWidget *self, template_saving_window *window); \ No newline at end of file diff --git a/source/libublsettingsui-gtk3.c b/source/libublsettingsui-gtk3.c index 90dcbc4..67a81d5 100644 --- a/source/libublsettingsui-gtk3.c +++ b/source/libublsettingsui-gtk3.c @@ -1,7 +1,17 @@ #include "libublsettingsui-gtk3.h" +_template_config *template_config = NULL; +template_app_info template_app_information; + static char *__yon_config_mode=NULL; +char *yon_char_get_localised_from_lib(char *string){ + textdomain(template_ui_LocaleName); + char *ret = _(string); + textdomain(template_app_information.app_locale); + return ret; +} + char *yon_ubl_save_mode_get_icon_name(SAVE_MODE_TYPE type){ switch (type){ case SAVE_MODE_FULL: @@ -64,6 +74,8 @@ void on_open_documentation_confirmation(GtkWidget *self, char *link){ window->HeaderLabel = yon_gtk_builder_get_widget(builder,"webHeaderNameLabel"); window->AlwaysOpenCheck = yon_gtk_builder_get_widget(builder,"AlwaysOpenDocumentationCheckbox"); gtk_label_set_text(GTK_LABEL(window->HeaderLabel),template_app_information.app_title); + gtk_window_set_title(GTK_WINDOW(window->Window),template_app_information.app_title); + gtk_window_set_icon_name(GTK_WINDOW(window->Window),yon_char_append("com.ublinux.",template_app_information.app_tech_name)); gtk_widget_show_all(window->Window); g_signal_connect(G_OBJECT(window->CloseButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(yon_open_browser),yon_char_new(link)); @@ -103,6 +115,7 @@ void on_about(GtkWidget *self, char *version_application){ gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),template_app_information.app_title); gtk_about_dialog_set_logo_icon_name(GTK_ABOUT_DIALOG(window),yon_char_append("com.ublinux.",template_app_information.app_tech_name)); gtk_window_set_icon_name(GTK_WINDOW(window),yon_char_append("com.ublinux.",template_app_information.app_tech_name)); + gtk_window_set_title(GTK_WINDOW(window),template_app_information.app_title); gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(window),template_app_information.app_tech_name); gtk_label_set_text(GTK_LABEL(title),template_app_information.app_title); g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),NULL); @@ -184,6 +197,19 @@ char* yon_debug_output(char *pattern,char*text){ // standard functions +char *yon_get_default_label_with_parameter(char *command){ + int size; + config_str parsed = yon_config_load(command,&size); + if (strcmp(parsed[0],"(null)\n")){ + if (parsed){ + yon_char_remove_last_symbol(parsed[0],'\n'); + char *default_string = yon_char_unite(DEFAULT_LABEL," ","(",parsed[0],")",NULL); + return default_string; + } + } + return DEFAULT_LABEL; +} + int yon_ubl_connect_config(_template_config *config){ int replaces; if(!template_config) @@ -505,3 +531,117 @@ template_main_window *yon_ubl_window_setup(){ return widgets; } + +void yon_on_email_check(GtkEntry *self,GdkEventFocus *event,GtkContainer *status){ + char *text = (char*)gtk_entry_get_text(self); + if (!strstr(text,"@")){ + yon_ubl_status_box_spawn_infinite(status,"invalid_email",EMAIL_INVALID_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + } else { + yon_ubl_status_box_despawn_infinite(status); + } +} + +void yon_on_space_first_changed(GtkEntry *editable){ + const char *text = gtk_entry_get_text(editable); + gchar *new_text = yon_char_new(text); + if (new_text[0]==' ') free(yon_char_divide(new_text,0)); + + if (strlen(new_text) < strlen(text)) { + g_signal_handlers_block_by_func(editable, G_CALLBACK(yon_on_space_first_changed), NULL); + gtk_entry_set_text(editable, new_text); + g_signal_handlers_unblock_by_func(editable, G_CALLBACK(yon_on_space_first_changed), NULL); + g_signal_stop_emission_by_name(editable, "changed"); + } + + g_free(new_text); +} + +void yon_on_digit_only_changed(GtkEditable *editable, const gchar *text, gint length, gint *position){ + gchar *new_text = g_new(gchar, length + 1); + gint i, j = 0; + + for (i = 0; i < length; i++) { + if (text[i]>'0'&&text[i]<'9') { + new_text[j] = text[i]; + j++; + } + } + if (j < length) { + g_signal_handlers_block_by_func(editable, G_CALLBACK(yon_on_digit_only_changed), NULL); + gtk_editable_insert_text(editable, new_text, j, position); + g_signal_handlers_unblock_by_func(editable, G_CALLBACK(yon_on_digit_only_changed), NULL); + g_signal_stop_emission_by_name(editable, "insert-text"); + } + + g_free(new_text); +} + +void yon_on_path_check(GtkEntry *self,GdkEventFocus *event,GtkContainer *status){ + char *text = (char*)gtk_entry_get_text(self); + if (text[0]=='~'){ + text = yon_char_new(text); + free(yon_char_divide(text,0)); + char *new_text = yon_char_unite(yon_ubl_user_get_home_directory(),"/",text,NULL); + free(text); + gtk_entry_set_text(GTK_ENTRY(self),new_text); + text = new_text; + } + if (!strstr(text,"/")){ + yon_ubl_status_box_spawn_infinite(status,"invalid_path",PATH_INVALID_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + } else { + yon_ubl_status_box_despawn_infinite(status); + } + +} + +char *yon_gtk_entry_check_restricted(GtkEntry *target){ + GtkInputPurpose purpose = gtk_entry_get_input_purpose(target); + const char *text = gtk_entry_get_text(target); + char *error=NULL; + if (!yon_char_is_empty(text)){ + switch(purpose){ + case GTK_INPUT_PURPOSE_EMAIL:{ + char *temp = NULL; + if (!((temp = strstr(text,"@"))&& + strstr(temp,".")&& + strlen(temp)!=strlen(text)&& + temp[1]!='.'&& + strstr(temp,".")[1]!='\0')){ + error = yon_char_get_localised_from_lib(EMAIL_INVALID_LABEL); + } + } + break; + case GTK_INPUT_PURPOSE_URL:{ + if (!strstr(text,"/")){ + error = yon_char_get_localised_from_lib(PATH_INVALID_LABEL); + } + } + break; + default: break; + } + } + return error; + +} + +void yon_entry_set_entry_type(GtkEntry *target,GtkBox *status){ + GtkInputPurpose purpose = gtk_entry_get_input_purpose(target); + g_signal_connect(G_OBJECT(target),"changed",G_CALLBACK(yon_on_space_first_changed),NULL); + switch(purpose){ + + case GTK_INPUT_PURPOSE_DIGITS: + g_signal_connect(G_OBJECT(target),"insert-text",G_CALLBACK(yon_on_digit_only_changed),NULL); + + break; + case GTK_INPUT_PURPOSE_EMAIL: + yon_gtk_entry_block_symbols(target,"/'\"\\+=)(*&>?<^%$#!:;?,)"); + yon_gtk_entry_block_languages(target); + break; + case GTK_INPUT_PURPOSE_NAME: + case GTK_INPUT_PURPOSE_URL: + yon_gtk_entry_block_restricted_symbols(target); + + break; + default: break; + } +} \ No newline at end of file diff --git a/source/libublsettingsui-gtk3.h b/source/libublsettingsui-gtk3.h index 65acbd2..ff83b0e 100644 --- a/source/libublsettingsui-gtk3.h +++ b/source/libublsettingsui-gtk3.h @@ -23,6 +23,7 @@ #define ui_glade_path_documentation "/com/ublinux/ui/libublsettingsui-gtk3-documentation.glade" #define ui_glade_path_about "/com/ublinux/ui/libublsettingsui-gtk3-about.glade" #define ui_glade_path_saving "/com/ublinux/ui/libublsettingsui-gtk3-saving.glade" +#define ui_glade_path_filechooser "/com/ublinux/ui/libublsettingsui-gtk3-filechooser.glade" #define ui_glade_path_debug "/com/ublinux/ui/libublsettingsui-gtk3-debugger.glade" #define ui_banner_path "/com/ublinux/images/libublsettingsui-gtk3-banner.png" #define ui_CssPath "/com/ublinux/css/libublsettingsui-gtk3.css" @@ -46,6 +47,8 @@ typedef enum SAVE_MODE_TYPE { SAVE_MODE_HDD_HOME, } SAVE_MODE_TYPE; +char *yon_char_get_localised_from_lib(char *string); + char *yon_ubl_save_mode_get_icon_name(SAVE_MODE_TYPE type); SAVE_MODE_TYPE yon_ubl_save_mode_get_type(char *type); @@ -66,7 +69,7 @@ typedef struct { gboolean always_open_documentation; } template_app_info; -static template_app_info template_app_information; +extern template_app_info template_app_information; #define template_config_fields\ @@ -89,8 +92,9 @@ static template_app_info template_app_information; typedef struct { template_config_fields } _template_config; + [[maybe_unused]] -static _template_config *template_config; +extern _template_config *template_config; #define template_window_fields\ GtkWidget *Window;\ @@ -152,6 +156,22 @@ typedef struct { char *action_text; } dialog_confirmation_data; +typedef struct { + GtkWidget *Window; + GtkWidget *StatusBox; + GtkWidget *HeaderTopic; + GtkWidget *MainFileChooser; + GtkWidget *SaveButton; + GtkWidget *CancelButton; + GtkWidget *ChooseFolderCheck; + char *last_success_selection; + char *last_any_selection; + GtkResponseType responce; +} filechooser_window; +filechooser_window *yon_file_chooser_window_new(GtkFileChooserAction action); +GtkResponseType yon_file_chooser_start(filechooser_window *window); +void yon_file_chooser_set_button_label(char *label); + int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data); /**yon_open_browser(GtkWidget *self, char *link) @@ -214,6 +234,8 @@ void on_about(GtkWidget *self, char *version_application); */ void on_open_documentation_confirmation(GtkWidget *self, char *link); +void yon_entry_set_entry_type(GtkEntry *target,GtkBox *status); + int yon_ubl_setup_arguments(int argc, char *argv[],config_str *unfound_arguments, int *arguments_size, char *additional_options_output); void yon_gtk_scrolled_window_set_horizontal_at_desired_size(GtkWidget *window, GtkScrolledWindow *target); @@ -245,11 +267,50 @@ void yon_save_window_set_postsave_function(void *function, void *data); void yon_save_window_set_postsave_failure_function(void *function, void *data); +char *yon_get_default_label_with_parameter(char *command); + template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...); +void yon_on_space_first_changed(GtkEntry *editable); + + +enum CONFIGURATION_PARAMETER_TYPE{ + CONFIGURATION_PARAMETER_BOOL, + CONFIGURATION_PARAMETER_ENTRY, + CONFIGURATION_PARAMETER_COMBO_BOX, + CONFIGURATION_PARAMETER_LIST_MULTIPLE +}; + +void yon_ubl_settings_window_init(GtkMenu *menu); +void *yon_ubl_settings_window_get(char *id); +void yon_configuration_window_add_boolean_parameter(enum CONFIGURATION_PARAMETER_TYPE type, char *id, char *label); +void yon_configuration_window_add_combo_box_parameter(enum CONFIGURATION_PARAMETER_TYPE type, char *id, char *label, GCallback func, gpointer data, ...); + +char *yon_gtk_entry_check_restricted(GtkEntry *target); + +typedef struct { + GtkWidget *window; + GtkWidget *WorkZoneBox; + GtkWidget *AcceptButton; + GtkWidget *CancelButton; +} ubl_settings_window; + +char *yon_settings_configuration_get(char *id); +char *yon_custom_config_init(); #define VERSION_LABEL yon_char_unite(_("Version:")," ",!yon_char_is_empty(template_app_information.app_version)?template_app_information.app_version:"","\n",NULL) - #define HELP_LABEL(rest) yon_char_unite(template_app_information.app_tech_name,_(" version:")," ", !yon_char_is_empty(template_app_information.app_version)?template_app_information.app_version:"","\n",template_app_information.app_title,"\n",_("Usage:"), " ",template_app_information.app_tech_name," ",_("[OPTIONS]"),"\n",_("Options:"),"\n\t--help, -h\t\t\t",_("Show this help"),"\n\t--version, -V\t\t\t",_("Show package version"),"\n\t--lock-help\t\t\t",_("Lock this help menu"),"\n\t--lock-save\t\t\t",_("Lock configuration saving"),"\n\t--lock-save-local\t\t",_("Lock local configration saving"),"\n\t--lock-save-global\t\t",_("Lock global configration saving"),"\n\t--lock-load-global\t\t",_("Lock global configration loading"),"\n\t--clear-config\t\t\t",_("Reset application settings"),"\n",!yon_char_is_empty(rest)?rest:NULL,NULL) + #define HELP_LABEL(rest) yon_char_unite(template_app_information.app_tech_name,_(" version:")," ", !yon_char_is_empty(template_app_information.app_version)?template_app_information.app_version:"","\n",\ + template_app_information.app_title,"\n",_("Usage:"), " ",template_app_information.app_tech_name," ",_("[OPTIONS]"),"\n",\ + _("Options:"),"\n",\ + " --help, -h ",_("Show this help"),"\n",\ + " --version, -V ",_("Show package version"),"\n",\ + " --lock-help ",_("Lock this help menu"),"\n",\ + " --lock-save ",_("Lock configuration saving"),"\n",\ + " --lock-save-local ",_("Lock local configration saving"),"\n",\ + " --lock-save-global ",_("Lock global configration saving"),"\n",\ + " --lock-load-global ",_("Lock global configration loading"),"\n",\ + " --clear-config, -c ",_("Reset application settings"),"\n",\ + !yon_char_is_empty(rest)?rest:NULL,NULL) #define template_ui_LocalePath "/usr/share/locale" #define template_ui_LocaleName "libublsettingsui-gtk3" @@ -257,6 +318,8 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...); #define SUCCESS_LABEL _("Operation succeeded") #define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked") + #define DEFAULT_LABEL _("Default") + #define DEFAULT_CUSTOM_LABEL(target) yon_char_unite(_("Default")," (",target,")",NULL) #define ABOUT_LABEL _("About") #define DOCUMENTATION_LABEL _("Documentation") @@ -271,10 +334,13 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...); #define LOAD_LOCAL_LABEL _("Load local configuration") #define LOAD_GLOBAL_LABEL _("Load global configuration") #define LOAD_LABEL _("Load") + #define LOAD_CONFIG_LABEL _("Load file") #define CANCEL_LABEL _("Cancel") #define ACCEPT_LABEL _("Accept") #define OPEN_LABEL _("Open") + #define CREATE_FOLDER_LABEL _("Create directory") + #define SELECT_FOLDER_LABEL _("Select directory") #define HELP_TITLE_LABEL _("Would you like to read documentation in the Web?") #define HELP_INFO_LABEL _("You will be redirected to documentation website where documentation is\ntranslated and supported by community.") @@ -292,6 +358,7 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...); #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_SUCCESS_LABEL _("Configuration saving succeeded.") #define PARAMETER_LABEL _("Parameter") #define OLD_VALUE_LABEL _("Old value") @@ -316,4 +383,15 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...); #define CUSTOM_CONFIG_CREATION_ERROR_LABEL _("New configuration file creation failed") #define ROOT_CHECK_LABEL _("Upgrade to root") #define SETTINGS_TITLE_LABEL _("Settings") + + #define CONFIG_WINDOW_MENU_LABEL _("Application settigs") + + #define EMAIL_INVALID_LABEL _("Invalid email adress") + #define PATH_INVALID_LABEL _("Invalid path") + + #define CHOOSE_FILE_LABEL _("Choose path") + + + #define FILE_CHOOSER_CHOOSE_FILDER_LABEL _("Choose directory instead of file") + #endif \ No newline at end of file