From ae90968c303ee20072870eee9dd1616b4b4643e0 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 5 Sep 2023 17:31:51 +0600 Subject: [PATCH 1/6] Russian localisation for packages and modules update --- ubl-settings-video_ru.po | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ubl-settings-video_ru.po b/ubl-settings-video_ru.po index 0ff9114..43922c7 100644 --- a/ubl-settings-video_ru.po +++ b/ubl-settings-video_ru.po @@ -519,29 +519,29 @@ msgid "DPMS off" msgstr "DMPS выключен" msgid "UBLinux module includes NVIDIA 340xx driver and utilities" -msgstr "UBLinux пакет с модулем драйвера и утилиты NVIDIA 340xx" +msgstr "Пакет с модулем драйвера и утилитами NVIDIA 340xx" msgid "UBLinux module includes NVIDIA 390xx driver and utilities" -msgstr "UBLinux пакет с модулем драйвера и утилиты NVIDIA 390xx" +msgstr "Пакет с модулем драйвера и утилитами NVIDIA 390xx" msgid "UBLinux module includes NVIDIA 470xx driver and utilities" -msgstr "UBLinux пакет с модулем драйвера и утилиты NVIDIA 470xx" +msgstr "Пакет с модулем драйвера и утилитами NVIDIA 470xx" msgid "UBLinux module includes NVIDIA 510xx driver and utilities" -msgstr "UBLinux пакет с модулем драйвера и утилиты NVIDIA 510xx" +msgstr "Пакет с модулем драйвера и утилитами NVIDIA 510xx" #: source/ubl-settings-video-strings.h:112 msgid "UBLinux package includes NVIDIA 340xx driver and utilities" -msgstr "UBLinux пакет драйвера и утилиты NVIDIA 340xx" +msgstr "Пакет с драйвером NVIDIA 340xx" #: source/ubl-settings-video-strings.h:112 msgid "UBLinux package includes NVIDIA 390xx driver and utilities" -msgstr "UBLinux пакет драйвера и утилиты NVIDIA 390xx" +msgstr "Пакет с драйвером NVIDIA 390xx" #: source/ubl-settings-video-strings.h:112 msgid "UBLinux package includes NVIDIA 470xx driver and utilities" -msgstr "UBLinux пакет драйвера и утилиты NVIDIA 470xx" +msgstr "Пакет с драйвером NVIDIA 470xx" #: source/ubl-settings-video-strings.h:112 msgid "UBLinux package includes NVIDIA 510xx driver and utilities" -msgstr "UBLinux пакет драйвера и утилиты NVIDIA 510xx" +msgstr "Пакет с драйвером NVIDIA 510xx" -- 2.35.1 From e2ae3d977eb0015e9455ab46aab1fb29d77888a2 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 5 Sep 2023 17:32:41 +0600 Subject: [PATCH 2/6] Header buttons were brought to standard --- ubl-settings-video.glade | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/ubl-settings-video.glade b/ubl-settings-video.glade index 1696556..83ce219 100644 --- a/ubl-settings-video.glade +++ b/ubl-settings-video.glade @@ -2585,10 +2585,6 @@ translated and supported by community. True False - 5 - 5 - 5 - 5 32 com.ublinux.ubl-settings-video @@ -2613,10 +2609,6 @@ translated and supported by community. True False - 5 - 5 - 5 - 5 Load @@ -2673,9 +2665,6 @@ translated and supported by community. True False 5 - 5 - 5 - 5 Save + True False @@ -2419,12 +2428,6 @@ translated and supported by community. False - - - - - - -1 diff --git a/ubl-settings-video.pot b/ubl-settings-video.pot index a7344ef..ff5faf3 100644 --- a/ubl-settings-video.pot +++ b/ubl-settings-video.pot @@ -17,23 +17,23 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: source/ubl-settings-video.h:26 +#: source/ubl-settings-video.h:25 msgid "https://wiki.ublinux.com" msgstr "" -#: source/ubl-settings-video.h:36 +#: source/ubl-settings-video.h:35 msgid "Failed to load global configuration" msgstr "" -#: source/ubl-settings-video.h:37 +#: source/ubl-settings-video.h:36 msgid "Failed to load local configuration" msgstr "" -#: source/ubl-settings-video.h:39 +#: source/ubl-settings-video.h:38 msgid "Saving to global configuration Succeeded" msgstr "" -#: source/ubl-settings-video.h:40 +#: source/ubl-settings-video.h:39 msgid "Saving to local configuration Succeeded" msgstr "" @@ -478,6 +478,10 @@ msgstr "" msgid "Kernel modules" msgstr "" +#: source/ubl-strings.h:121 +msgid "Load drivers from database" +msgstr "" + #: source/ubl-settings-video.c:713 msgid "Project Home Page" msgstr "" diff --git a/ubl-settings-video_ru.po b/ubl-settings-video_ru.po index 43922c7..5705273 100644 --- a/ubl-settings-video_ru.po +++ b/ubl-settings-video_ru.po @@ -17,23 +17,23 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: source/ubl-settings-video.h:26 +#: source/ubl-settings-video.h:25 msgid "https://wiki.ublinux.com" msgstr "https://wiki.ublinux.ru" -#: source/ubl-settings-video.h:36 +#: source/ubl-settings-video.h:35 msgid "Failed to load global configuration" msgstr "Ошибка загрузки глобальной конфигурации" -#: source/ubl-settings-video.h:37 +#: source/ubl-settings-video.h:36 msgid "Failed to load local configuration" msgstr "Ошибка загрузки локальной конфигурации" -#: source/ubl-settings-video.h:39 +#: source/ubl-settings-video.h:38 msgid "Saving to global configuration Succeeded" msgstr "Успешное сохранение глобальной конфигурации" -#: source/ubl-settings-video.h:40 +#: source/ubl-settings-video.h:39 msgid "Saving to local configuration Succeeded" msgstr "Успешно записана локальная конфигурация" @@ -74,22 +74,18 @@ msgid "Lock this help menu" msgstr "Блокировка вызова справки" #: source/ubl-strings.h:2 -#, fuzzy msgid "Lock configration saving" msgstr "Блокировка сохранения локальной и глобальной конфигурации" #: source/ubl-strings.h:2 -#, fuzzy msgid "Lock local configration saving" msgstr "Блокировка сохранения локальной конфигурации" #: source/ubl-strings.h:2 -#, fuzzy msgid "Lock global configration saving" msgstr "Блокировка сохранения глобальной конфигурации" #: source/ubl-strings.h:2 -#, fuzzy msgid "Lock global configration loading" msgstr "Блокировка загрузки глобальной конфигурации" @@ -272,7 +268,7 @@ msgid "Automatically choose and use driver" msgstr "Автоматический выбор и использование драйвера" #: source/ubl-strings.h:49 -msgid "Launch programms through optirun (Nvidia): " +msgid "Launch programs through optirun (Nvidia): " msgstr "Запуск программ через optirun (Nvidia)" #: source/ubl-strings.h:50 @@ -369,24 +365,20 @@ msgstr "" "список установленных драйверов." #: source/ubl-strings.h:73 -#, fuzzy msgid "Configure monitor" -msgstr "Основной" +msgstr "Настроить монитоор" #: source/ubl-strings.h:74 -#, fuzzy msgid "Delete monitor configuration" -msgstr "Настройка экрана" +msgstr "Удалить конфигурацию мониотра" #: source/ubl-strings.h:75 -#, fuzzy msgid "Add monitor configuration" -msgstr "Настройка экрана" +msgstr "Добавить монитор" #: source/ubl-strings.h:76 -#, fuzzy msgid "Switch monitor" -msgstr "Основной" +msgstr "Переключить монтор" #: source/ubl-strings.h:77 msgid "More" @@ -429,7 +421,6 @@ msgid "Driver modules" msgstr "Модули драйвера" #: source/ubl-strings.h:87 -#, fuzzy msgid "Read documentation" msgstr "Справка" @@ -493,55 +484,70 @@ msgstr "Используемый драйвер ядра" msgid "Kernel modules" msgstr "Модули ядра" +#: source/ubl-strings.h:121 +msgid "Load drivers from database" +msgstr "Загрузить список доступных драйверов" + #: source/ubl-settings-video.c:713 msgid "Project Home Page" msgstr "Домашняя страница проекта" + msgid "UBlinux Video Configuration" msgstr "Видеокарта/Экран" + msgid "Videocard and monitor configuration manager" msgstr "Настройка вывода изображения" + msgid "Saving to local and global configuration Succeeded" msgstr "Успешно записаны локальная и глобальная конфигурация" + msgid "VGA compitable controller" msgstr "VGA-совместимый адаптер" + msgid "Configuration has been loaded" msgstr "Конфигурация была загружена" + msgid "Proprietary driver: " msgstr "Проприетарный драйвер: " + msgid "DPMS off" msgstr "DMPS выключен" + msgid "UBLinux module includes NVIDIA 340xx driver and utilities" msgstr "Пакет с модулем драйвера и утилитами NVIDIA 340xx" + msgid "UBLinux module includes NVIDIA 390xx driver and utilities" msgstr "Пакет с модулем драйвера и утилитами NVIDIA 390xx" + msgid "UBLinux module includes NVIDIA 470xx driver and utilities" msgstr "Пакет с модулем драйвера и утилитами NVIDIA 470xx" + msgid "UBLinux module includes NVIDIA 510xx driver and utilities" msgstr "Пакет с модулем драйвера и утилитами NVIDIA 510xx" -#: source/ubl-settings-video-strings.h:112 + msgid "UBLinux package includes NVIDIA 340xx driver and utilities" msgstr "Пакет с драйвером NVIDIA 340xx" -#: source/ubl-settings-video-strings.h:112 + msgid "UBLinux package includes NVIDIA 390xx driver and utilities" msgstr "Пакет с драйвером NVIDIA 390xx" -#: source/ubl-settings-video-strings.h:112 + msgid "UBLinux package includes NVIDIA 470xx driver and utilities" msgstr "Пакет с драйвером NVIDIA 470xx" -#: source/ubl-settings-video-strings.h:112 + msgid "UBLinux package includes NVIDIA 510xx driver and utilities" msgstr "Пакет с драйвером NVIDIA 510xx" -- 2.35.1 From 6d0588ac78a8d4ef43f2547a560b0c1f92a783fa Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 6 Sep 2023 11:56:07 +0600 Subject: [PATCH 4/6] utils update --- source/ubl-settings-video.c | 155 ++-- source/ubl-settings-video.h | 2 +- source/ubl-utils.c | 1669 +++++++++++++++++++++++++++++------ source/ubl-utils.h | 200 +++-- 4 files changed, 1607 insertions(+), 419 deletions(-) diff --git a/source/ubl-settings-video.c b/source/ubl-settings-video.c index ab84496..9d59533 100644 --- a/source/ubl-settings-video.c +++ b/source/ubl-settings-video.c @@ -30,7 +30,7 @@ void on_resized(GtkWidget *window, GdkEventConfigure *event){ void on_monitor_config_save(GtkWidget *self, monitor_edit_window *window){ monitorconfig *config = yon_dictionary_get_data(window->config,monitorconfig*); if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->templateMonitorConfigurationPortCombo))==0){ - yon_ubl_status_box_render(videoconfig.status_render,MONITOR_PORT_ERROR_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_render(MONITOR_PORT_ERROR_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); return; } config->main=0; @@ -44,7 +44,7 @@ void on_monitor_config_save(GtkWidget *self, monitor_edit_window *window){ config->port=NULL; config->resolution=NULL; config->frequency=0; - yon_ubl_status_box_render(videoconfig.status_render,MONITOR_PORT_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(MONITOR_PORT_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); config->port = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->templateMonitorConfigurationPortCombo)); window->config->key = yon_char_new(config->port); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->templateMonitorConfigurationParameterLineCheck))==0){ @@ -97,7 +97,7 @@ void on_terminal_destroy(GtkWidget *self, widgets_dict *widgets){ gtk_widget_destroy(widgets->TerminalRevealer); yon_proprieary_get(); yon_gtk_list_store_fill_with_proprietaries(videoconfig.list); - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_OPETAION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(PROPRIETARY_OPETAION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) @@ -174,44 +174,44 @@ void yon_terminal_start(widgets_dict *widgets, char *usr_command){ } void on_driver_pack_install(GtkWidget *self,widgets_dict *widgets){ - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_INSTALLING_IN_PROGRESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(PROPRIETARY_INSTALLING_IN_PROGRESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); GtkTreeIter iter; char *name; GtkTreeModel *list_s=GTK_TREE_MODEL(videoconfig.list); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->proprietaryTreeView)); if(gtk_tree_selection_get_selected(selection,&list_s,&iter)){ gtk_tree_model_get(list_s,&iter,1,&name,-1); - yon_terminal_start(widgets,yon_char_get_augumented(install_proprietary_command,name)); + yon_terminal_start(widgets,yon_char_append(install_proprietary_command,name)); } else { - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_render(PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } } void on_driver_install(GtkWidget *self,widgets_dict *widgets){ - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_INSTALLING_IN_PROGRESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(PROPRIETARY_INSTALLING_IN_PROGRESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); GtkTreeIter iter; char *name; GtkTreeModel *list_s=GTK_TREE_MODEL(videoconfig.list); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->driversTreeView)); if (gtk_tree_selection_get_selected(selection,&list_s,&iter)){ gtk_tree_model_get(list_s,&iter,2,&name,-1); - yon_terminal_start(widgets,yon_char_get_augumented(install_proprietary_command,name)); + yon_terminal_start(widgets,yon_char_append(install_proprietary_command,name)); } else { - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_render(PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } } void on_driver_pack_delete(GtkWidget *self,widgets_dict *widgets){ - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_DELETING_IN_PROGRESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(PROPRIETARY_DELETING_IN_PROGRESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); GtkTreeIter iter; char *name; GtkTreeModel *list_s=GTK_TREE_MODEL(videoconfig.list); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->proprietaryTreeView)); if(gtk_tree_selection_get_selected(selection,&list_s,&iter)){ gtk_tree_model_get(list_s,&iter,1,&name,-1); - yon_terminal_start(widgets,yon_char_get_augumented(delete_proprietary_command,name)); + yon_terminal_start(widgets,yon_char_append(delete_proprietary_command,name)); } else { - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_render(PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } } @@ -253,16 +253,16 @@ void on_driver_selection_change(GtkWidget *self, widgets_dict *widgets){ } void on_driver_delete(GtkWidget *self,widgets_dict *widgets){ - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_DELETING_IN_PROGRESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(PROPRIETARY_DELETING_IN_PROGRESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); GtkTreeIter iter; char *name; GtkTreeModel *list_s=GTK_TREE_MODEL(videoconfig.list); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->driversTreeView)); if (gtk_tree_selection_get_selected(selection,&list_s,&iter)){ gtk_tree_model_get(list_s,&iter,2,&name,-1); - yon_terminal_start(widgets,yon_char_get_augumented(delete_proprietary_command,name)); + yon_terminal_start(widgets,yon_char_append(delete_proprietary_command,name)); } else { - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_render(PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } } @@ -277,9 +277,9 @@ void on_driver_pack_info(GtkWidget *self, widgets_dict *widgets){ GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->proprietaryTreeView)); if (gtk_tree_selection_get_selected(selection,&list_s,&iter)){ gtk_tree_model_get(list_s,&iter,1,&name,-1); - pthread_create(&tid,&attr,(void*)yon_launch_app,yon_char_get_augumented(get_info_proprietary_command,name)); + pthread_create(&tid,&attr,(void*)yon_launch,yon_char_append(get_info_proprietary_command,name)); } else { - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_render(PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } } @@ -294,9 +294,9 @@ void on_driver_info(GtkWidget *self,widgets_dict *widgets){ GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->driversTreeView)); if (gtk_tree_selection_get_selected(selection,&list_s,&iter)){ gtk_tree_model_get(list_s,&iter,2,&name,-1); - pthread_create(&tid,&attr,(void*)yon_launch_app,yon_char_get_augumented(get_info_proprietary_command,name)); + pthread_create(&tid,&attr,(void*)yon_launch,yon_char_append(get_info_proprietary_command,name)); } else { - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_render(PROPRIETARY_NOTHING_SELECTED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } } @@ -318,7 +318,7 @@ void on_port_chosen_changed(GtkWidget *self, monitor_edit_window *window){ if (window->curport){ gtk_window_set_title(GTK_WINDOW(gtk_widget_get_toplevel(window->mainMonitorConfigurationBox)),window->curport); - dict=yon_dictionary_find(&videoconfig.supported_resolutions,window->curport); + dict=yon_dictionary_get(&videoconfig.supported_resolutions,window->curport); if (dict){ resolution_supported *res = yon_dictionary_get_data(dict,resolution_supported*); int found_size=0; @@ -336,7 +336,7 @@ void on_port_chosen_changed(GtkWidget *self, monitor_edit_window *window){ } } } - yon_gtk_combo_box_fill(window->templateMonitorConfigurationResolutionCombo,config->resolutionCapabilities, config->resolution_size); + yon_gtk_combo_box_text_fill(window->templateMonitorConfigurationResolutionCombo,config->resolutionCapabilities, config->resolution_size); } } } @@ -373,26 +373,26 @@ char *yon_configuration_get_save_command(char *command){ str=yon_char_new(command); if (videoconfig.autoChooseDrivers==0){ if (strcmp(videoconfig.failsafenVidia, dntus)!=0) - str = yon_char_get_augumented(str, yon_char_get_augumented(" FAILSAFENVIDIA=", videoconfig.failsafenVidia)); + str = yon_char_append(str, yon_char_append(" FAILSAFENVIDIA=", videoconfig.failsafenVidia)); else - str = yon_char_get_augumented(str," FAILSAFENVIDIA=\"\""); + str = yon_char_append(str," FAILSAFENVIDIA=\"\""); if (strcmp(videoconfig.failsafeATI, dntus)!=0) - str = yon_char_get_augumented(str, yon_char_get_augumented(" FAILSAFEATI=", videoconfig.failsafeATI)); + str = yon_char_append(str, yon_char_append(" FAILSAFEATI=", videoconfig.failsafeATI)); else - str = yon_char_get_augumented(str," FAILSAFEATI=\"\""); - str=yon_char_get_augumented(str," VGADRV_AUTO=NO"); + str = yon_char_append(str," FAILSAFEATI=\"\""); + str=yon_char_append(str," VGADRV_AUTO=NO"); } else { str = yon_char_unite(str, " FAILSAFENVIDIA=\"\" FAILSAFEATI=\"\" VGADRV_AUTO=YES", NULL); } if (videoconfig.optirun&&strcmp(videoconfig.optirun, dntus)!=0&&strcmp(videoconfig.optirun, "")!=0) - str = yon_char_get_augumented(str, yon_char_unite(" OPTIRUN=","\"",videoconfig.optirun,"\"",NULL)); + str = yon_char_append(str, yon_char_unite(" OPTIRUN=","\"",videoconfig.optirun,"\"",NULL)); else - str = yon_char_get_augumented(str, yon_char_unite(" OPTIRUN=\"\"",NULL)); + str = yon_char_append(str, yon_char_unite(" OPTIRUN=\"\"",NULL)); if (videoconfig.primusrun&&strcmp(videoconfig.primusrun, dntus)!=0&&strcmp(videoconfig.primusrun, "")!=0) - str = yon_char_get_augumented(str, yon_char_unite(" PRIMUSRUN=","\"", videoconfig.primusrun,"\"",NULL)); + str = yon_char_append(str, yon_char_unite(" PRIMUSRUN=","\"", videoconfig.primusrun,"\"",NULL)); else - str = yon_char_get_augumented(str, yon_char_unite(" PRIMUSRUN=\"\"",NULL)); + str = yon_char_append(str, yon_char_unite(" PRIMUSRUN=\"\"",NULL)); dictionary *dict=NULL; for (int i=0;itemplateMonitorConfigurationResolutionCombo),PARAMETER_DEFAULT_LABEL); gtk_combo_box_set_active(GTK_COMBO_BOX(window->templateMonitorConfigurationResolutionCombo),0); if (((monitorconfig*)window->config->data)->show_usupported==1){ - yon_gtk_combo_box_fill(window->templateMonitorConfigurationResolutionCombo,videoconfig.resolutions,videoconfig.resolutionssize); + yon_gtk_combo_box_text_fill(window->templateMonitorConfigurationResolutionCombo,videoconfig.resolutions,videoconfig.resolutionssize); } else { - yon_gtk_combo_box_fill(window->templateMonitorConfigurationResolutionCombo,((monitorconfig*)window->config->data)->resolutionCapabilities,((monitorconfig*)window->config->data)->resolution_size); + yon_gtk_combo_box_text_fill(window->templateMonitorConfigurationResolutionCombo,((monitorconfig*)window->config->data)->resolutionCapabilities,((monitorconfig*)window->config->data)->resolution_size); } } @@ -427,13 +427,13 @@ char *yon_configuration_get_remove_command(char *command){ char *dntus = NULL; dntus=_("Don't use"); str=yon_char_new(command); - str = yon_char_get_augumented(str, " FAILSAFENVIDIA"); - str = yon_char_get_augumented(str, " FAILSAFATI"); - str = yon_char_get_augumented(str, " OPTIRUN"); - str = yon_char_get_augumented(str, " PRIMUSRUN"); + str = yon_char_append(str, " FAILSAFENVIDIA"); + str = yon_char_append(str, " FAILSAFATI"); + str = yon_char_append(str, " OPTIRUN"); + str = yon_char_append(str, " PRIMUSRUN"); dictionary *dict=NULL; for(int i=0;imainMonitorVisualConfigurationBox); - yon_ubl_status_box_render(videoconfig.status_render,LOCAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); } void on_configuration_load_global(GtkWidget *self, widgets_dict *widgets) @@ -509,7 +509,7 @@ void on_configuration_load_global(GtkWidget *self, widgets_dict *widgets) yon_setup_config(load_drivers_global_command); on_config_fill_interface(widgets); yon_monitor_view_setup(widgets->mainMonitorVisualConfigurationBox); - yon_ubl_status_box_render(videoconfig.status_render,GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); } /**void on_monitor_delete(GtkWidget *self,monitor_view windowd) @@ -622,7 +622,7 @@ void on_monitor_configure(GtkWidget *self,monitor_window *window){ monitors->curport=NULL; dictionary *dict=NULL; for (int i=0;istringparameters||check_if_exists==monitors->config) gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(monitors->templateMonitorConfigurationPortCombo),videoconfig.ports[i]); @@ -847,9 +847,9 @@ void yon_monitor_view_update(){ monitor_window *monitor = yon_dictionary_get_data(dict,monitor_window*); monitorconfig *config = yon_dictionary_get_data(monitor->config,monitorconfig*); if (strcmp(monitor->config->key,PARAMETER_DEFAULT_LABEL)!=0) - gtk_label_set_text(GTK_LABEL(monitor->templateMonitorInfoNameLabel),yon_char_get_augumented(MONITOR_LABEL,monitor->config->key)); + gtk_label_set_text(GTK_LABEL(monitor->templateMonitorInfoNameLabel),yon_char_append(MONITOR_LABEL,monitor->config->key)); else - gtk_label_set_text(GTK_LABEL(monitor->templateMonitorInfoNameLabel),yon_char_get_augumented(MONITOR_LABEL,"")); + gtk_label_set_text(GTK_LABEL(monitor->templateMonitorInfoNameLabel),yon_char_append(MONITOR_LABEL,"")); monitorconfig *params=yon_dictionary_get_data(yon_dictionary_get_data(dict,monitor_window*)->config,monitorconfig*); gtk_widget_set_sensitive(yon_dictionary_get_data(dict,monitor_window*)->templateMonitorImage,params->enable); if (config->resolution){ @@ -893,7 +893,7 @@ char *yon_monitor_make_string(monitorconfig* config) resolution=config->resolution; first=0; }else{ - resolution=yon_char_get_augumented(",",config->resolution); + resolution=yon_char_append(",",config->resolution); } char *enable=""; @@ -915,31 +915,31 @@ char *yon_monitor_make_string(monitorconfig* config) char *position=""; if (config->position==1) if (first==1){ - position=yon_char_get_augumented("lo:",config->position_port); + position=yon_char_append("lo:",config->position_port); first=0; }else{ - position=yon_char_get_augumented(",lo:",config->position_port); + position=yon_char_append(",lo:",config->position_port); } else if (config->position==2) if (first==1){ - position=yon_char_get_augumented("ro:",config->position_port); + position=yon_char_append("ro:",config->position_port); first=0; }else{ - position=yon_char_get_augumented(",ro:",config->position_port); + position=yon_char_append(",ro:",config->position_port); } else if (config->position==3) if (first==1){ - position=yon_char_get_augumented("ab:",config->position_port); + position=yon_char_append("ab:",config->position_port); first=0; }else{ - position=yon_char_get_augumented(",ab:",config->position_port); + position=yon_char_append(",ab:",config->position_port); } else if (config->position==4) if (first==1){ - position=yon_char_get_augumented("be:",config->position_port); + position=yon_char_append("be:",config->position_port); first=0; }else{ - position=yon_char_get_augumented(",be:",config->position_port); + position=yon_char_append(",be:",config->position_port); } char *rotation=""; @@ -1015,7 +1015,7 @@ char *yon_monitor_make_string(monitorconfig* config) else if (config->frequency==2) frequency="x75"; } if (strcmp(resolution,"")!=0) - resolution=yon_char_get_augumented(resolution,frequency); + resolution=yon_char_append(resolution,frequency); char *stringparameters=yon_char_unite("",main,resolution,enable,position,rotation,dpms,cvt,reduced,gtf,NULL); @@ -1093,7 +1093,7 @@ void yon_proprietary_local_get(){ if (strcmp(drivers[dr_foun],ubm)==0){ yon_dictionary_add_or_create_if_exists_with_data(videoconfig.proprietary,drivers[dr_foun],rtn[dr_desc]); } - // else if (strcmp(pack,"")!=0&&!(yon_dictionary_find(!videoconfig.proprietary||&videoconfig.proprietary,pack))){ + // else if (strcmp(pack,"")!=0&&!(yon_dictionary_get(!videoconfig.proprietary||&videoconfig.proprietary,pack))){ // yon_dictionary_add_or_create_if_exists_with_data(videoconfig.proprietary,pack,rtn[dr_desc]); // } } @@ -1109,7 +1109,7 @@ void yon_proprietary_local_get(){ * [EN] */ dictionary *yon_proprieary_get(){ - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_LOADING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_render(PROPRIETARY_LOADING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); videoconfig.proprietary=NULL; int drivers_size=0; int size=0; @@ -1130,14 +1130,14 @@ dictionary *yon_proprieary_get(){ if (strcmp(drivers[dr_foun],ubm)==0){ yon_dictionary_add_or_create_if_exists_with_data(videoconfig.proprietary,drivers[dr_foun],rtn[dr_desc]); } - else if (strcmp(pack,"")!=0&&!yon_dictionary_find(&videoconfig.proprietary,pack)){ + else if (strcmp(pack,"")!=0&&!yon_dictionary_get(&videoconfig.proprietary,pack)){ yon_dictionary_add_or_create_if_exists_with_data(videoconfig.proprietary,pack,rtn[dr_desc]); } } } if (videoconfig.proprietary){ yon_gtk_list_store_fill_with_proprietaries(videoconfig.list); - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_OPETAION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(PROPRIETARY_OPETAION_DONE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } else { drivers=yon_config_load(get_proprietary_drivers_local_command,&drivers_size); if (drivers){ @@ -1151,15 +1151,15 @@ dictionary *yon_proprieary_get(){ key = yon_char_divide_search(key,";",-1); char *driver_name=yon_char_divide_search(yon_char_new(drivers[drivers_found])," ",-1); if (strcmp(key,driver_name)==0) - if (i==0) videoconfig.proprietary=yon_dictionary_create_with_data(drivers[drivers_found],rtn[i]); - else videoconfig.proprietary=yon_dictionary_create_with_data_connected(videoconfig.proprietary,drivers[drivers_found],rtn[i]); + if (i==0) videoconfig.proprietary=yon_dictionary_new_with_data(drivers[drivers_found],rtn[i]); + else videoconfig.proprietary=yon_dictionary_append_with_data(videoconfig.proprietary,drivers[drivers_found],rtn[i]); } } yon_gtk_list_store_fill_with_proprietaries(videoconfig.list); - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_USE_LOCAL_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(PROPRIETARY_USE_LOCAL_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } else { - yon_ubl_status_box_render(videoconfig.status_render,PROPRIETARY_LOADING_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_render(PROPRIETARY_LOADING_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } } } @@ -1252,7 +1252,7 @@ void yon_setup_config(char *configcommand) dictionary *dct; for(int i=0; ireduced=0; monitor->gtf=0; if (videoconfig.monitors) - videoconfig.monitors=yon_dictionary_create_with_data_connected(videoconfig.monitors,port,monitor); + videoconfig.monitors=yon_dictionary_append_with_data(videoconfig.monitors,port,monitor); else - videoconfig.monitors=yon_dictionary_create_with_data(port,monitor); + videoconfig.monitors=yon_dictionary_new_with_data(port,monitor); return videoconfig.monitors; } } @@ -1429,8 +1429,8 @@ void yon_monitor_view_new(monitor_config monitor){ window->config=monitor; gtk_widget_hide(window->templateMonitorInfoAddButton); g_signal_connect(G_OBJECT(window->templateMonitorInfoConfigureButton), "clicked", G_CALLBACK(on_monitor_configure), window); - if (videoconfig.monitor_visuals) videoconfig.monitor_visuals = yon_dictionary_create_with_data_connected(videoconfig.monitor_visuals, window->config->key,window); - else videoconfig.monitor_visuals = yon_dictionary_create_with_data(window->config->key,window); + if (videoconfig.monitor_visuals) videoconfig.monitor_visuals = yon_dictionary_append_with_data(videoconfig.monitor_visuals, window->config->key,window); + else videoconfig.monitor_visuals = yon_dictionary_new_with_data(window->config->key,window); g_signal_connect(G_OBJECT(window->templateMonitorDeleteButton), "clicked", G_CALLBACK(on_monitor_delete), videoconfig.monitor_visuals); g_signal_connect(G_OBJECT(window->templateMonitorSwitchButton), "clicked", G_CALLBACK(on_monitor_switch), window); @@ -1440,8 +1440,8 @@ void yon_monitor_view_new(monitor_config monitor){ gtk_widget_hide(window->templateMonitorSwitchButton); gtk_widget_hide(window->templateMonitorInfoConfigureButton); g_signal_connect(G_OBJECT(window->templateMonitorInfoAddButton), "clicked", G_CALLBACK(on_monitor_add), window); - if (videoconfig.monitor_visuals) videoconfig.monitor_visuals = yon_dictionary_create_with_data_connected(videoconfig.monitor_visuals, "GENERIC",window); - else videoconfig.monitor_visuals = yon_dictionary_create_with_data("GENERIC",window); + if (videoconfig.monitor_visuals) videoconfig.monitor_visuals = yon_dictionary_append_with_data(videoconfig.monitor_visuals, "GENERIC",window); + else videoconfig.monitor_visuals = yon_dictionary_new_with_data("GENERIC",window); } } @@ -1479,7 +1479,7 @@ void yon_monitor_set_resolutions(){ port_for_res=yon_char_new(dct->key); } if(port_for_res){ - dct=yon_dictionary_find(&videoconfig.supported_resolutions,port_for_res); + dct=yon_dictionary_get(&videoconfig.supported_resolutions,port_for_res); resolution_supported *sup=yon_dictionary_get_data(dct,resolution_supported*); sup->size++; sup->line=realloc(sup->line,sizeof(char*)*sup->size); @@ -1836,7 +1836,7 @@ int main(int argc, char *argv[]) // char *args=""; // for (int i=0;idata = NULL; @@ -69,34 +20,133 @@ dictionary *yon_dictionary_create_empty() return dict; } +/**yon_dictionary_copy(dictionary *dict) + * [EN] + * + * [RU] + * Создаёт и возвращает копию элемента словаря [dict] +*/ +dictionary *yon_dictinoary_copy(dictionary *dict){ + dictionary *dct = yon_dictionary_new_with_data(dict->key,dict->data); + dct->data_type= dict->data_type; + return dct; +} + +/**yon_dictionary_copy_deep(dictionary *dict) + * [EN] + * + * [RU] + * Создаёт полную копию словаря [dict] и возвращает первый элемент +*/ +dictionary *yon_dictionary_copy_deep(dictionary *dict){ + dictionary *dct = NULL; + dictionary *newone=NULL; + for_dictionaries(dct,dict){ + yon_dictionary_add_or_create_if_exists_with_data(newone,dct->key,dct->data); + newone->data_type=dct->data_type; + } + return newone->first; +} + +/**int yon_dictionary_set_data(dictionary *dict, void *data) + * [EN] + * + * [RU] + * Установить элементу словаря [dict] значение [data] +*/ +int yon_dictionary_set_data(dictionary *dict, void *data){ + dict->data=data; +} + +/**int yon_dictionary_set_key(dictionary *dict, char *key) + * [EN] + * + * [RU] + * Изменяет ключ элемента словаря [dict] на [key] +*/ +int yon_dictionary_set_key(dictionary *dict, char *key){ + dict->key=key; + return 1; +} + +/** int yon_dictionary_set(dictionary *dict, char *key, void *data) + * [EN] + * + * [RU] +* Устанавливает значение ключа элемента словаря [dict] на [key] и его данные на [data] +*/ +int yon_dictionary_set(dictionary *dict, char *key, void *data){ + dict->key=key; + dict->data=data; + return 1; +} + +/**int yon_dictionary_empty(dictionary *dict) + * [EN] + * + * [RU] + * Очищает элемент словаря [dict] от данных +*/ +int yon_dictionary_empty(dictionary *dict){ + dict->data=NULL; + dict->data_type=DICTIONARY_OTHER_TYPE; + return 1; +} + +/**yon_dictionary_switch_to_last(dictionary **dict) + * [EN] + * + * [RU] + * Переключает словарь [dict] на последний элемент. +*/ void yon_dictionary_switch_to_last(dictionary **dict) { - if ((*dict)->next != NULL) - for ((*dict) = (*dict)->first; (*dict)->next != NULL; (*dict) = (*dict)->next) - { - } + dictionary *dct=NULL, *dact=*dict; + for_dictionaries(dct,dact); } -dictionary *yon_dictionary_create_conneced(dictionary *targetdict) +/**yon_dictionary_create_conneced(dictionary *targetdict) + * [EN] + * + * [RU] + * Создаёт новый элемент словаря [targetdict] +*/ +dictionary *yon_dictionary_append(dictionary *targetdict) { targetdict = yon_dictionary_get_last(targetdict); - targetdict->next = yon_dictionary_create_empty(); + targetdict->next = yon_dictionary_new(); targetdict->next->prev = targetdict; targetdict->next->first = targetdict->first; targetdict->next->data_type = DICTIONARY_OTHER_TYPE; return targetdict->next; } +/**yon_dictionary_get_last(dictionary *dict) + * [EN] + * + * [RU] + * Возвращает последний элемент словаря [dict]. + * В отличае от yon_dictionary_switch_to_last() + * словарь [dict] остаётся на прежнем элементе. +*/ dictionary *yon_dictionary_get_last(dictionary *dict) { - dictionary *dct = NULL; - for (dct = dict->first; dct->next != NULL; dct = dct->next) - { - } - return dct; + if (dict->next){ + dictionary *dct = NULL; + for_dictionaries(dct,dict); + return dct; + } else return dict; } -dictionary *yon_dictionary_switch_places(dictionary *dict, int aim) +/**yon_dictionary_switch_places(dictionary *dict, int aim) + * [EN] + * + * [RU] + * Меняет элемент словаря [dict] местами с другим элементом. + * если [aim]<0 элемент меняется местами с левым элементом; + * если [aim]>0 элемент меняется местами с правым элементом; +*/ +dictionary *yon_dictionary_swap(dictionary *dict, int aim) { if (aim < 0) { @@ -197,6 +247,13 @@ dictionary *yon_dictionary_switch_places(dictionary *dict, int aim) } } +/**yon_dictionary_make_first(dictionary *dict) + * [EN] + * + * [RU] + * Устанавливает указатель первого элемента словаря [dict] + * на текущий элемент. Не использовать. +*/ void yon_dictionary_make_first(dictionary *dict) { for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) @@ -205,6 +262,12 @@ void yon_dictionary_make_first(dictionary *dict) } } +/**yon_dictionary_make_nth(dictionary *dict, int nth) + * [EN] + * + * [RU] + * Перемещает элемент словаря [dict] на позицию [nth]. +*/ void yon_dictionary_make_nth(dictionary *dict, int nth) { dictionary *dct = dict->first; @@ -223,9 +286,15 @@ void yon_dictionary_make_nth(dictionary *dict, int nth) dct->prev = dict; } -dictionary *yon_dictionary_create_with_data(char *key, void *data) +/**yon_dictionary_create_with_data(char *key, void *data) + * [EN] + * + * [RU] + * Создаёт новый словарь с ключом [key] и указателем на данные [data] +*/ +dictionary *yon_dictionary_new_with_data(char *key, void *data) { - dictionary *dct = yon_dictionary_create_empty(); + dictionary *dct = yon_dictionary_new(); dct->key = yon_char_new(key); dct->data = data; dct->data_type = DICTIONARY_OTHER_TYPE; @@ -250,15 +319,28 @@ void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipul return NULL; } -dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) +/**yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) + * [EN] + * + * [RU] + * Создаёт новый элемент словаря, присоединяемый в конец словаря [dict] + * с ключом [key] и указателем на данные [data] +*/ +dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data) { - dictionary *dct = yon_dictionary_create_conneced(dict); + dictionary *dct = yon_dictionary_append(dict); dct->key = yon_char_new(key); dct->data = data; dct->data_type = DICTIONARY_OTHER_TYPE; return dct; } +/**yon_dictionary_connect(dictionary *old, dictionary *toconnect) + * [EN] + * + * [RU] + * Присоединяет словарь [toconnect] в конец словаря [old]. +*/ dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect) { dictionary *dict = yon_dictionary_get_last(old); @@ -268,7 +350,14 @@ dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect) return toconnect; } -dictionary *yon_dictionary_find(dictionary **dict, char *key) +/**yon_dictionary_get(dictionary **dict, char *key) + * [EN] + * + * [RU] + * Возвращает элемент словаря [dict] с ключом [key]. + * Если такого элемента не было обнаружено, возвращается NULL +*/ +dictionary *yon_dictionary_get(dictionary **dict, char *key) { dictionary *dct = *dict; for (dictionary *pointer = dct->first; pointer != NULL; pointer = pointer->next) @@ -282,6 +371,12 @@ dictionary *yon_dictionary_find(dictionary **dict, char *key) return NULL; } +/**yon_dictionary_rip(dictionary *dict) + * [EN] + * + * [RU] + * Вырезает элемент из словаря и возвращает вырезанный элемент. +*/ dictionary *yon_dictionary_rip(dictionary *dict) { if (!dict->next&&!dict->prev) return NULL; @@ -317,6 +412,12 @@ dictionary *yon_dictionary_rip(dictionary *dict) } } +/**yon_dictionary_get_nth(dictionary *dict, int place) + * [EN] + * + * [RU] + * Возвращает [place]-й элемент словаря [dict] +*/ dictionary *yon_dictionary_get_nth(dictionary *dict, int place) { if (dict){ @@ -336,11 +437,18 @@ dictionary *yon_dictionary_get_nth(dictionary *dict, int place) // char functions +int yon_char_find_last(char *source, char find){ + int size = strlen(source); + int i=size; + for (;source[i]!=find&&i>0;i--); + return i; +} + /**[EN] * * creates new char string by combining two char strings. */ -char *yon_char_get_augumented(char *source, char *append) +char *yon_char_append(char *source, char *append) { if (source && append) { @@ -372,8 +480,12 @@ char *yon_char_new(char *chr) return NULL; } -// char *yon_char_unite(char *source, ...) - +/**yon_char_unite(char *source, ...) + * [En] + * + * [RU] + * Объединяет строку [source] со всеми строками, написанными в [...] +*/ char *yon_char_unite(char *source, ...){ va_list arglist; char *new_char=NULL; @@ -382,15 +494,15 @@ char *yon_char_unite(char *source, ...){ va_start(arglist,source); unite_char = va_arg(arglist,char*); while(unite_char){ - new_char = yon_char_get_augumented(new_char,unite_char); + new_char = yon_char_append(new_char,unite_char); unite_char = va_arg(arglist,char*); } va_end(arglist); return new_char; } -/**[EN] - * +/**yon_cut(char *source, int size, int startpos) + * [EN] * cuts source string by size length from startpos position. */ char *yon_cut(char *source, int size, int startpos) @@ -401,8 +513,9 @@ char *yon_cut(char *source, int size, int startpos) memcpy(cut, source + startpos, size); return cut; } -/**[EN] - * + +/**yon_char_divide(char *source, int dividepos) + * [EN] * divides source string in dividepos position, * returning left part of divided string and * inserting right part to source string. @@ -420,6 +533,12 @@ char *yon_char_divide(char *source, int dividepos) return cut; } +/**yon_char_find_count(char *source, char *find) + * [EN] + * + * [RU] + * Считает количество символов [find] в строке [source] +*/ int yon_char_find_count(char *source, char *find){ char *working_string=yon_char_new(source); int i=0; @@ -433,7 +552,8 @@ int yon_char_find_count(char *source, char *find){ return i; } -/**[EN] +/**yon_char_divide_search(char *source, char *dividepos, int delete_divider) + * [EN] * char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) * searches string [dividepos] in [source] string and divides it, * returning left part of divided string and @@ -460,49 +580,78 @@ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) cut = yon_char_divide(source, leng); return cut; } - else - return source; } + return source; } -/**[EN] - * char *yon_char_from_int(int int_to_convert) +/**yon_char_from_int(int int_to_convert) + * [EN] * converts int to char*. * * [RU] - * char *yon_char_from_int(int int_to_convert) * Конвертирует int в char* */ char *yon_char_from_int(int int_to_convert) { int i = 1; float convert_check = (float)int_to_convert; - for (i = 1; convert_check > 10; i++) + for (i = 1; convert_check >= 10; i++) { convert_check = convert_check / 10; } - char *ch = malloc(i * sizeof(char) + 1); + char *ch = g_malloc0(i * sizeof(char) + 1); sprintf(ch, "%d", int_to_convert); return ch; } -char *yon_char_replace(char *source, char *find, char*replace){ - char *final=NULL; - char *temp=NULL; - if(!strstr(replace,find)){ - while ((final=strstr(source,find))){ - temp=malloc(strlen(source)-strlen(final)); - memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); - memcpy(temp,source,strlen(source)-strlen(final)); - temp=yon_char_get_augumented(temp,replace); - source=yon_char_get_augumented(temp,final+1); +/**yon_char_from_long(int int_to_convert) + * [EN] + * converts int to char*. + * + * [RU] + * Конвертирует int в char* + */ +char *yon_char_from_long(long int_to_convert) +{ + int i = 1; + double convert_check = (double)int_to_convert; + for (i = 1; convert_check >= 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = g_malloc0(i * sizeof(char) + 1); + sprintf(ch, "%ld", int_to_convert); + return ch; +} + +/**yon_char_replace(char *source, char *find, char*replace) + * [EN] + * + * [RU] + * Заменяет в строке [source] все вхождения строки [find] на [replace] +*/ +char *yon_char_replace(char *source, char *find, char*replace){ + if (!strstr(replace,find)){ + + + char *final=NULL; + char *temp=NULL; + if(!strstr(replace,find)){ + while ((final=strstr(source,find))){ + temp=malloc(strlen(source)-strlen(final))+1; + memset(temp,0,strlen(source)-strlen(final)+strlen(replace)+1); + memcpy(temp,source,strlen(source)-strlen(final)); + temp=yon_char_append(temp,replace); + source=yon_char_append(temp,final+strlen(find)); + } + } - return source; } + return source; } -/**[EN] - * char **yon_char_parse(char *parameters, int *size, char *divider) +/**yon_char_parse(char *parameters, int *size, char *divider) + * [EN] * Parses string [parameters], divided by [divider], * then returns parsed string array and sets [size] to * size of returned array @@ -513,52 +662,73 @@ char **yon_char_parse(char *parameters, int *size, char *divider){ string=malloc(sizeof(char*)); char *paramline=yon_char_new(parameters); char *param; + if (!strstr(parameters,divider)) return NULL; while ((param=yon_char_divide_search(paramline,divider,1))){ + if (strcmp(param,paramline)==0||paramline[0]=='\0') break; string=realloc(string,sizeof(char*)*i); string[i-1]=yon_char_new(param); i++; - if (strcmp(param,paramline)==0) break; } string=realloc(string,sizeof(char*)*i); string[i-1]=yon_char_new(paramline); i++; - // printf("%d\n",i); *size=i-1; return string; - } -char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete){ +/**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) + * [EN] + * + * [RU] + * Удаляет элемент [item_to_delete] из массива строк [char_string], размера [size] + * Возвращает получившийся массив, в [size] загружается размер нового массива. +*/ +char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete){ char **new_char_parsed=NULL; - new_char_parsed=malloc(sizeof(char*)*(*size)-2); - int sz=0; - for (int i=0;i<*size-2;i++){ - if (i!=item_to_delete){ + new_char_parsed=malloc(sizeof(char*)*((*size)-1)); + int flag = 0; + for (int i=0;i < (*size);i++){ + if (i==item_to_delete) { + flag = 1; + } + if (flag == 0) { new_char_parsed[i]=yon_char_new(char_string[i]); - sz++; } - + else if (flag == 1 && i!=item_to_delete) { + new_char_parsed[i-1]=yon_char_new(char_string[i]); + } } - *size=sz; + (*size)=(*size)-1; return new_char_parsed; } -/**[EN] - * +/**yon_char_parsed_check_exist(char **parameters, int size, char *param) + * [EN] * Checks if [parameters] string array of length [size] * has [param] element; + * [RU] + * Проверяет есть ли в массиве строк [parameters], размера [size] + * элемент [param] */ int yon_char_parsed_check_exist(char **parameters, int size, char *param){ for (int i=0;ipw_name,NULL); + else { + user_list = yon_char_parsed_append(user_list,user_size,user->pw_name); + } + } + endpwent(); + return user_list; +} + +config_str yon_ubl_get_all_processes(int *processes_size){ + config_str processes = yon_config_load(get_processes_command,processes_size); + yon_char_parsed_remove_newline_symbols(processes,processes_size); + return processes; +} + +config_str yon_ubl_get_all_slices(int *slices_size){ + config_str slices = yon_config_load(get_slices_command,slices_size); + yon_char_parsed_remove_newline_symbols(slices,slices_size); + return slices; +} // parsing functions +dictionary *yon_scan_desktops(){ + dictionary *apps_dict = NULL; + DIR *directory = opendir(DesktopPath); + struct dirent *de; + while ((de = readdir(directory))) + { + FILE *file; + char *path = yon_char_append(DesktopPath, de->d_name); + file = fopen(path, "r"); + if (strstr(path,".desktop")){ + apps *application = malloc(sizeof(apps)); + GKeyFile *gfile = g_key_file_new(); + GError *err = NULL; + if (!access(path,F_OK)){ + g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL); + application->Type = !strcmp(g_key_file_get_string(gfile, "Desktop Entry", "Type", &err),"Application") ? 1 : 0; + if (application->Type){ + application->Name = g_key_file_get_locale_string(gfile,"Desktop Entry", "Name",setlocale(LC_ALL, NULL),&err); + application->Categories = g_key_file_get_string(gfile,"Desktop Entry", "Categories",&err); + application->Exec = g_key_file_get_string(gfile,"Desktop Entry", "Exec",&err); + application->Icon = g_key_file_get_string(gfile,"Desktop Entry", "Icon",&err); + application->Pluggable = (g_key_file_get_boolean(gfile,"Desktop Entry", "Pluggable",NULL)|| + g_key_file_get_boolean(gfile,"Desktop Entry", "X-XfcePluggable",&err)); + application->DualPluggable = g_key_file_get_boolean(gfile,"Desktop Entry", "X-UBLPluggable",NULL); + application->Hidden = g_key_file_get_boolean(gfile,"Desktop Entry", "X-X-UBL-SettingsManager-Hidden",NULL); + if (application->Name&&application->Exec){ + if (!apps_dict){ + yon_dictionary_add_or_create_if_exists_with_data(apps_dict,application->Name,application); + } else if (!yon_dictionary_get(&apps_dict,application->Name)){ + yon_dictionary_add_or_create_if_exists_with_data(apps_dict,application->Name,application); + } else { + yon_dictionary_set_data(apps_dict,application); + } + } + } + } + } + } + if (apps_dict) return apps_dict; +} + apps *yon_apps_scan_and_parse_desktops(int *sizef) { int size = 0; @@ -609,7 +927,7 @@ apps *yon_apps_scan_and_parse_desktops(int *sizef) while ((de = readdir(directory))) { FILE *file; - char *path = yon_char_get_augumented(DesktopPath, de->d_name); + char *path = yon_char_append(DesktopPath, de->d_name); file = fopen(path, "r"); if (strlen(de->d_name) > 9) { @@ -626,55 +944,59 @@ apps *yon_apps_scan_and_parse_desktops(int *sizef) if (err) { printf("%s\n", err->message); - } - if (strcmp(Type, "Application") == 0) - tempapp.Type = 1; - else if (strcmp(Type, "pyApplication") == 0) - tempapp.Type = 2; - else - continue; - tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); - if (tempapp.Name == NULL) - continue; - tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL); - if (tempapp.Categories == NULL) - continue; - tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); - if (tempapp.Exec == NULL) - continue; - tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); - if (tempapp.Icon == NULL) - continue; - tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL); - if (!tempapp.Pluggable) - tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL); - if (tempapp.Pluggable) - tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL); - if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0) - if (size == 0) - { - applist = (apps *)malloc(size + 1 * sizeof(apps)); - applist[0].Name = yon_char_new(tempapp.Name); - applist[0].Categories = yon_char_new(tempapp.Categories); - applist[0].Exec = yon_char_new(tempapp.Exec); - applist[0].Icon = yon_char_new(tempapp.Icon); - applist[0].Type = tempapp.Type; - applist[0].Pluggable = tempapp.Pluggable; - applist[0].DualPluggable = tempapp.DualPluggable; - size++; - } + } else { + if (strcmp(Type, "Application") == 0) + tempapp.Type = 1; + else if (strcmp(Type, "pyApplication") == 0) + tempapp.Type = 2; else - { - applist = (apps *)realloc(applist, (size + 1) * sizeof(apps)); - applist[size].Name = yon_char_new(tempapp.Name); - applist[size].Categories = yon_char_new(tempapp.Categories); - applist[size].Exec = yon_char_new(tempapp.Exec); - applist[size].Icon = yon_char_new(tempapp.Icon); - applist[size].Pluggable = tempapp.Pluggable; - applist[size].DualPluggable = tempapp.DualPluggable; - applist[size].Type = tempapp.Type; - size++; - } + continue; + tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); + if (tempapp.Name == NULL) + continue; + tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL); + if (tempapp.Categories == NULL) + continue; + tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); + if (tempapp.Exec == NULL) + continue; + tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); + if (tempapp.Icon == NULL) + continue; + tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL); + if (!tempapp.Pluggable) + tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL); + if (tempapp.Pluggable) + tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL); + if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0) + if (size == 0) + { + applist = (apps *)malloc(size + 1 * sizeof(apps)); + applist[0].filename = yon_char_new(path); + applist[0].Name = yon_char_new(tempapp.Name); + applist[0].Categories = yon_char_new(tempapp.Categories); + applist[0].Exec = yon_char_new(tempapp.Exec); + applist[0].Icon = yon_char_new(tempapp.Icon); + applist[0].Type = tempapp.Type; + applist[0].Pluggable = tempapp.Pluggable; + applist[0].DualPluggable = tempapp.DualPluggable; + size++; + } + else + { + applist = (apps *)realloc(applist, (size + 1) * sizeof(apps)); + applist[size].filename = yon_char_new(path); + applist[size].Name = yon_char_new(tempapp.Name); + applist[size].Categories = yon_char_new(tempapp.Categories); + applist[size].Exec = yon_char_new(tempapp.Exec); + applist[size].Icon = yon_char_new(tempapp.Icon); + applist[size].Pluggable = tempapp.Pluggable; + applist[size].DualPluggable = tempapp.DualPluggable; + applist[size].Type = tempapp.Type; + size++; + } + } + g_key_file_free(gfile); } } } @@ -714,51 +1036,399 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size) return NULL; }; -config_str yon_config_load(char *command, int *str_len) -{ - FILE *output = popen(command, "r"); - char **output_strings = NULL; - output_strings = malloc(sizeof(char)); - int i = 0; - char str[1000]; - memset(str, 0, 1000); - while (fgets(str, 1000, output)) - { - if (strcmp(str, "") != 0) - { - output_strings = realloc(output_strings, sizeof(char *) * (i + 1)); - // printf("%s\n", str); - output_strings[i] = NULL; - output_strings[i] = yon_char_new(str); - memset(str, 0, 1000); - i++; +void __yon_on_app_chooser_selection(GtkTreeView *self, GtkTreeStore *store){ + GtkTreeModel *model = GTK_TREE_MODEL(store); + GtkTreeIter iter, parentiter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(self),&model,&iter)){ + if (!gtk_tree_model_iter_parent(model,&parentiter,&iter)){ + gtk_tree_view_expand_row(self,gtk_tree_model_get_path(model,&iter),0); + if (gtk_tree_model_iter_nth_child(model,&parentiter,&iter,0)) + gtk_tree_selection_select_iter(gtk_tree_view_get_selection(self),&parentiter); } - } - if (i>0){ - *str_len = i; - return output_strings; - } else{ - *str_len=-1; - return NULL; + } else { + gtk_tree_model_get_iter_first(model,&iter); + gtk_tree_selection_select_iter(gtk_tree_view_get_selection(self),&iter); } } -/**[EN] - * int yon_config_save(char *command) - * Saves config with [command] +/**yon_app_chooser_open_with_sections(char *section_name, char *section_filter, char *section_icon, ...) + * [EN] + * * [RU] + * Вызывает диалоговое окно выбора приложений с разделом [section_name], разделом [section_filter] и иконкой, полученной по названию [section_icon]. + * после них можно вводить любое количество пар названий раздела и названий иконок для получения дополнительных разделов, + * оканчивающиеся NULL. */ -int yon_config_save(char *command) -{ +char *yon_app_chooser_open_with_sections(char *section_name, char *section_filter, char *section_icon, ...){ + GtkBuilder *builder = gtk_builder_new_from_resource("/com/ublinux/ui/ublexec-application.glade"); + GtkWidget *dialog = gtk_dialog_new(); + gtk_widget_set_size_request(dialog,500,600); + gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ublexec"); + gtk_window_set_title(GTK_WINDOW(dialog),_("Applications")); + gtk_dialog_add_buttons(GTK_DIALOG(dialog),_("Cancel"),0,_("Accept"),1,NULL); + GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"ApplicationsWindow")); + GtkWidget *box = GTK_WIDGET(gtk_builder_get_object(builder,"box")); + GtkWidget *header = GTK_WIDGET(gtk_builder_get_object(builder,"ApplicationsHeaderBar")); + gtk_window_set_title(GTK_WINDOW(dialog),_("Application")); + gtk_window_set_titlebar(GTK_WINDOW(dialog),header); + g_object_ref(box); + gtk_container_remove(GTK_CONTAINER(window),box); + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),box,1,1,5); + gtk_style_context_add_class(gtk_widget_get_style_context(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),"workingbg"); + GtkWidget *main_tree = GTK_WIDGET(gtk_builder_get_object(builder,"MainTree")); + GtkTreeStore *store = GTK_TREE_STORE(gtk_builder_get_object(builder,"treestore1")); + va_list args; + GtkTreeIter iter, childiter; + + g_signal_connect(G_OBJECT(main_tree),"cursor-changed",G_CALLBACK(__yon_on_app_chooser_selection),store); + + gtk_tree_store_append(GTK_TREE_STORE(store),&iter,NULL); + gtk_tree_store_set(GTK_TREE_STORE(store),&iter,0,section_icon,1,section_name,2,section_filter,-1); + va_start(args,section_icon); + char *section; + while ((section = va_arg(args,char*))){ + char *filter = va_arg(args,char*); + char *icon = va_arg(args,char*); + if (icon&&filter){ + gtk_tree_store_append(GTK_TREE_STORE(store),&iter,NULL); + gtk_tree_store_set(GTK_TREE_STORE(store),&iter,0,icon,1,section,2,filter,-1); + } + } + va_end(args); + int size; + apps *app_list = yon_apps_scan_and_parse_desktops(&size); + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store),&iter); + for (; valid; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store),&iter)){ + char *cur_categories; + gtk_tree_model_get(GTK_TREE_MODEL(store),&iter,2,&cur_categories,-1); + for (int i=0; i0&&strcmp(app_list[i].Name,app_list[i-1].Name)){ + if (strstr(app_list[i].Icon,"/")){ + yon_char_divide(app_list[i].Icon,yon_char_find_last(app_list[i].Icon,'/')); + app_list[i].Icon = yon_char_divide(app_list[i].Icon,yon_char_find_last(app_list[i].Icon,'.')); + } + gtk_tree_store_append(store,&childiter,&iter); + gtk_tree_store_set(store,&childiter,0,app_list[i].Icon, 1,app_list[i].Name, 2, app_list[i].filename, -1); + } + } + } + } + gtk_tree_view_set_model(GTK_TREE_VIEW(main_tree),GTK_TREE_MODEL(store)); + int res = gtk_dialog_run(GTK_DIALOG(dialog)); + GtkTreeModel *model = GTK_TREE_MODEL(store); + if (res){ + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(main_tree)),&model,&childiter)){ + if (gtk_tree_model_iter_parent(model,&iter,&childiter)){ + char *path; + gtk_tree_model_get(model,&childiter,2,&path,-1); + gtk_widget_destroy(dialog); + return path; + } + } else { + gtk_widget_destroy(dialog); + return ""; + } + } else { + gtk_widget_destroy(dialog); + } + +} +//config functions + +/**yon_config_load_register(char *command) + * [EN] + * + * [RU] + * Выполняет команду [command]. + * Полученные данные парсятся и регистрируются в конфиг. +*/ +int yon_config_load_register(char *command){ + if (__yon__config__strings){ + __yon__config__strings = yon_dictionary_free_all(__yon__config__strings,NULL); + } FILE *output = popen(command, "r"); + char **output_strings = NULL; + output_strings = malloc(sizeof(char*)); + int i = 0; + char str[4096]; + memset(str, 0, 4096); + while (fgets(str, 4096, output)) + { + if (strcmp(str, "") != 0&& strcmp(str,"(null)\n")!=0) + { + char *key = yon_char_divide_search(str,"=",-1); + char *final_str=yon_char_divide_search(str,"\n",-1); + yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,yon_char_new(final_str)); + __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; + } + } + check_config + return 1; + else return 0; +} + +/**yon_config_remove_by_key(char *key) + * [EN] + * + * [RU] + * Удаляет параметр конфига по ключу [key] +*/ +int yon_config_remove_by_key(char *key){ + check_config{ + dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + if (dict){ + yon_dictionary_rip(dict); + return 1; + }else return 0; + } + return 0; +} + +/**yon_config_remove_by_data(void *data) + * [EN] + * + * [RU] + * Производит поиск по конфигу на наличие параметра со значением [data] и удаляет найденное значение из конфига. +*/ +int yon_config_remove_by_data(void *data){ + check_config{ + dictionary *dict = NULL; + for_dictionaries(dict,__yon__config__strings){ + if (dict->data==data){ + yon_dictionary_rip(dict); + return 1; + } + } + return 0; + } + return 0; +} + +/**yon_config_remove_element(char *key, char *deleted) + * [EN] + * + * [RU] + * Удаляет элемент [deleted] из массива параметров с ключом [key] +*/ +int yon_config_remove_element(char *key, char *deleted){ + check_config{ + dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + char *data = (char*)dict->data; + char *found = strstr(data,deleted); + int size=strlen(data)-strlen(found)+1; + char *new_data = malloc(size); + memset(new_data,0,size); + if (strlen(found)!=strlen(deleted)){ + memcpy(new_data,data,size-1); + new_data = yon_char_append(new_data,found+strlen(deleted)+1); + } else { + memcpy(new_data,data,size-2); + new_data = yon_char_append(new_data,found+strlen(deleted)); + } + dict->data=(void*)(new_data); + dict->flag1=1; + return 1; + } else return 0; +} + +/**yon_config_get_by_key(char *key) + * [EN] + * + * [RU] + * Возвращает значение параметра конфига с ключом [key] +*/ +void *yon_config_get_by_key(char *key){ + check_config{ + dictionary *dict = NULL; + for_dictionaries(dict, __yon__config__strings){ + if (strcmp(dict->key,key)==0){ + return dict->data; + } + } + } + return NULL; +} + +/**yon_config_get_key_by_data(char *data) + * [EN] + * + * [RU] + * Возвращает ключ параметра конфига со значением [data]. + * Если параметр с таким значением не найден, возвращается NULL +*/ +char *yon_config_get_key_by_data(char *data){ + check_config{ + dictionary *dict = NULL; + for_dictionaries(dict, __yon__config__strings){ + if (strcmp(((char*)dict->data),data)==0){ + return dict->key; + } + } + } + return NULL; +} + +/**yon_config_set(char *key, void *data) + * [EN] + * + * [RU] + * Производит поиск по конфигу и заменяет значение параметра с ключом [key] на новое значение [data]; +*/ +int yon_config_set(char *key, void *data){ + check_config{ + dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + dict->data=data; + dict->flag1=1; return 1; + } else return 0; } -/**[EN] - * char *yon_config_get_parameter(config parameters, int size, char *param) - * Gets parameter from parameter list; + +/**yon_config_append(char *key, void *data) + * [EN] * + * [RU] + * Производит поиск по конфигу и дополняет значение параметра с ключом [key] значением [data]; +*/ +int yon_config_append(char *key, char *data){ + check_config{ + dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + if (strcmp(((char*)dict->data),"")!=0) + dict->data=(void*)(yon_char_unite((char*)dict->data," ",data,NULL)); + else dict->data=(void*)data; + dict->flag1=1; + return 1; + } else return 0; +} + + +/**yon_config_clean() + * [EN] + * Erase all parameters from config; + * [RU] + * Удаляет все параметры из конфига; +*/ +int yon_config_clean(){ + check_config{ + __yon__config__strings = yon_dictionary_free_all(__yon__config__strings, NULL); + return 1; + } + else return 0; +} + +/**yon_config_register(char *key, void *data) + * [EN] + * + * [RU] + * Регистрирует новый параметр конфига. + * [key] - ключ параметра; + * [data] - значение параметра; +*/ +void yon_config_register(char *key, void *data){ + if (!__yon__config__strings||!yon_dictionary_get(&__yon__config__strings,key)){ + yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,data); + } + else if (yon_dictionary_get(&__yon__config__strings,key)) __yon__config__strings->data=data; + __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; + __yon__config__strings->flag1=1; +} + +/**yon_config_load(char *command, int *str_len) + * [EN] + * + * [RU] + * Выполняет команду [command] и возвращает распаршеный результат выполнения команды. + * В [str_len] возвращается длина возвращаемого массива +*/ +config_str yon_config_load(char *command, int *str_len){ + FILE *output = popen(command, "r"); + char **output_strings = NULL; + output_strings = malloc(sizeof(char)); + int i = 0; + char str[4096]; + memset(str, 0, 4096); + while (fgets(str, 4096, output)) + { + if (strcmp(str, "") != 0) + { + output_strings = realloc(output_strings, sizeof(char *) * (i + 1)); + output_strings[i] = NULL; + output_strings[i] = yon_char_new(str); + memset(str, 0, 4096); + i++; + } + } + if (i>0){ + *str_len = i; + return output_strings; + } else{ + *str_len=-1; + return NULL; + } +} + +/**int yon_config_save_registered(char *path, char *section) + * [EN] + * Saves config with [command] + * [RU] + * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: + * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" +*/ +int yon_config_save_registered(char *path, char *section){ + check_config{ + char *command = yon_char_unite("/usr/bin/ubconfig",path ? yon_char_append(" --target ",path):"", " set ", section,NULL); + char *remove_command = yon_char_unite("/usr/bin/ubconfig", path ? yon_char_append(" --target ",path):"", " remove ", section,NULL); + dictionary *dict = NULL; + int any_add = 0; + int any_remove = 0; + for_dictionaries(dict,__yon__config__strings){ + char *data = yon_dictionary_get_data(dict,char*); + if (dict->flag1==1&&strcmp(data,"")!=0){ + command = yon_char_unite(command, " ", dict->key,"=\"", yon_dictionary_get_data(dict,char*),"\"", NULL); + any_add=1; + } + if (strcmp(data,"")==0){ + remove_command = yon_char_unite(remove_command, " ", dict->key, NULL); + any_remove=1; + } + } + if (any_add) yon_launch(command); + if (any_remove) yon_launch(remove_command); + return 1; + } else return 1; +} + +/**yon_config_get_all(int *size) + * [EN] + * + * [RU] + * Возвращает массив со всеми параметрами конфига, оканчивающаяся NULL + * [size] - указатель, в который выгружается длина массива +*/ +config_str yon_config_get_all(int *size){ + check_config{ + *size = 1; + config_str conf = NULL; + dictionary *dict = NULL; + for_dictionaries(dict,__yon__config__strings){ + conf = yon_remalloc(conf,sizeof(char*)*(*size)); + conf[(*size)-1] = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); + (*size)++; + } + conf = yon_remalloc(conf,sizeof(char*)*(*size)); + conf[*size-1] = NULL; + return conf; + } else return NULL; +} + +/**char *yon_config_get_parameter(config parameters, int size, char *param) + * [EN] + * Gets parameter [param] from parameter list [parameters] of size [size]; + * or NULL if nothing were found * [RU] + * Возвращает параметр [param] из массива строк [parameters] размером [size] + * или NULL если такой не был найден */ char *yon_config_get_parameter(config_str parameters, int size, char *param) { @@ -785,66 +1455,47 @@ char *yon_config_get_parameter(config_str parameters, int size, char *param) return NULL; } -/**[EN] - * Parses, modifies and connects string to use it as one of arguments, - * sended to ubconfig. - * - * [RU] - */ -char *yon_config_make_save_parameter_with_multiple_arguments(char *parameter_string, char *config_parameter, char *divider){ - char *final=""; - int done=0; - char *cur=yon_char_new(parameter_string); - yon_char_divide_search(cur,"=",1); - char *cur_param=NULL; - while (cur_param=yon_char_divide_search(cur,",",1)){ - if (done==0){ - final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"="), yon_char_get_augumented(cur_param,", "))); - done=1; - } else { - final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"+="), yon_char_get_augumented(cur_param,", "))); - } - } - if (cur&&strcmp(cur,"")!=0) - if (done==0) - final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"="), yon_char_get_augumented(cur,", "))); - else - final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"+="), yon_char_get_augumented(cur,", "))); - return final; -} + // terminal-using functions -int yon_launch_app(char *name) +/**yon_launch_app_with_arguments(char *name, char *args) + * [EN] + * Execute [command] in separate thread; + * [RU] + * Выполнить команду [command] в отдельном потоке; +*/ +int yon_launch_app_with_arguments(char *name, char *args) { - char *path = name; - thread_output *thread = malloc(sizeof(thread_output)); - thread->command = path; - thread->exitcode = malloc(sizeof(int)); + char *path = yon_char_unite(name, " ", args,NULL); pthread_t thread_id; - pthread_create(&thread_id, NULL, (void *)yon_launch, thread); - return *thread->exitcode; + char *command = NULL; + command = path; + pthread_create(&thread_id, NULL, (void *)yon_launch, command); }; -int yon_launch_app_with_arguments(char *name, char *args) +/**yon_launch(char *command) + * [EN] + * Execute command [command] + * [RU] + * Выполнить команду [command] +*/ +void yon_launch(char *command) { - char *path = yon_char_get_augumented("/usr/bin/", name); - path = yon_char_get_augumented(path, " "); - path = yon_char_get_augumented(path, args); - pthread_t thread_id; - thread_output *thread = malloc(sizeof(thread_output)); - thread->command = path; - thread->exitcode = malloc(sizeof(int)); - pthread_create(&thread_id, NULL, (void *)yon_launch, thread); - return *thread->exitcode; -}; + system(command); +} + -int yon_launch(thread_output *thread) +/**yon_launch(char *command) + * [EN] + * Execute command [command] + * [RU] + * Выполнить команду [command] +*/ +void yon_launch_thread(char *command) { - int a = 0; - a = system(thread->command); - *thread->exitcode = a; - return *thread->exitcode; + pthread_t thread_id; + pthread_create(&thread_id, NULL, (void *)yon_launch, command); } // Gtk functions @@ -852,8 +1503,18 @@ int yon_launch(thread_output *thread) #ifdef __GTK_H__ + +static render_data render; + #ifdef VTE_TERMINAL +static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) +{ + if (!terminal) return; + if (pid == -1) printf("Error\n\n\n"); + else vte_terminal_feed_child(VTE_TERMINAL(terminal),(char*)user_data,strlen((char*)user_data)); +} + /** * void yon_terminal_integrated_launch(GtkWidget *place_to_show, void *endwork_function, void* endwork_function_argument) * [EN] @@ -866,27 +1527,36 @@ int yon_launch(thread_output *thread) * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. */ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument){ + char **commands=new_arr(char*,2); + gchar **envp = g_get_environ(); + commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); + commands[1]=NULL; + char **env=new_arr(char*,2); + env[0]=""; + env[1]=NULL; GtkWidget *terminal = vte_terminal_new(); vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); + gtk_container_add(GTK_CONTAINER(place_to_show),terminal); char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); - g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(on_terminal_done), widgets); + if(endwork_function) + g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); vte_terminal_spawn_async(VTE_TERMINAL(terminal), VTE_PTY_DEFAULT, NULL, - install_command, + commands, NULL, 0, NULL, NULL, NULL, -1, NULL, - NULL, - NULL); + child_ready, + install_command); vte_pty_spawn_async(pty, NULL, - install_command, + commands, NULL, 0, NULL, NULL, @@ -895,15 +1565,372 @@ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, voi NULL, NULL, NULL); - vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), 100); + vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); - gtk_widget_show_all(widgets->TerminalRevealer); + gtk_widget_show_all(terminal); } +/**yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument) + * [EN] + * launches terminal with specific [command], + * terminal is shown in [place_to_show] container, + * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. + * [RU] + * Запускает терминал с командой [command], + * терминал добавляется в контейнер [place_to_show] виджета, + * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. +*/ +void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument){ + char **commands=new_arr(char*,2); + gchar **envp = g_get_environ(); + commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); + commands[1]=NULL; + char **env=new_arr(char*,2); + env[0]=""; + env[1]=NULL; + vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); + VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); + vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); + char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); + if(endwork_function) + g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); + vte_terminal_spawn_async(VTE_TERMINAL(terminal), + VTE_PTY_DEFAULT, + NULL, + commands, + NULL, + 0, + NULL, NULL, + NULL, + -1, + NULL, + child_ready, + install_command); + vte_pty_spawn_async(pty, + NULL, + commands, + NULL, + 0, + NULL, NULL, + NULL, + -1, + NULL, + NULL, + NULL); + vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); + vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); + vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); + gtk_widget_show_all(terminal); + } #endif -int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){ + // Window config functions + + #define check_window_config_setup if(__yon_window_config_target_window) + + typedef struct { + char *parameter_name; + enum YON_TYPE containing_type; + GtkWidget *track_widget; + char *property_name; + } __yon_listener_parameter; + + typedef struct { + char *parameter_name; + char *section; + enum YON_TYPE containing_type; + void *property; + } __yon_custom_parameter; + + struct { + int x; + int y; + int width; + int height; + int fullscreen; + dictionary *custom_listeners; + dictionary *custom_parameters; + dictionary *deleted_parameters; + } __yon_main_window_config; + + static GtkWindow *__yon_window_config_target_window = NULL; + static GKeyFile *__yon_window_config_file = NULL; + static char *__yon_window_config_path = NULL; + + void yon_window_config_save(){ + g_key_file_set_integer(__yon_window_config_file,"window","WindowPosX",__yon_main_window_config.x); + g_key_file_set_integer(__yon_window_config_file,"window","WindowPosY",__yon_main_window_config.y); + g_key_file_set_integer(__yon_window_config_file,"window","WindowWidth",__yon_main_window_config.width); + g_key_file_set_integer(__yon_window_config_file,"window","WindowHeight",__yon_main_window_config.height); + g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen); + dictionary *dict=NULL; + if (__yon_main_window_config.custom_listeners) + for_dictionaries(dict,__yon_main_window_config.custom_listeners){ + __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); + GValue *val = g_malloc0(sizeof(GValue)); + g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); + switch(param->containing_type){ + case YON_TYPE_STRING: + g_key_file_set_string(__yon_window_config_file,"window",param->parameter_name, g_value_get_string(val)); + break; + case YON_TYPE_INT: + g_key_file_set_integer(__yon_window_config_file,"window",param->parameter_name, g_value_get_int(val)); + break; + case YON_TYPE_DOUBLE: + g_key_file_set_double(__yon_window_config_file,"window",param->parameter_name, g_value_get_double(val)); + break; + case YON_TYPE_BOOLEAN: + g_key_file_set_boolean(__yon_window_config_file,"window",param->parameter_name, g_value_get_boolean(val)); + break; + case YON_TYPE_OTHER:printf("\033[0;31mCannot save %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; + } + } + if (__yon_main_window_config.custom_parameters) + for_dictionaries(dict,__yon_main_window_config.custom_parameters){ + __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); + switch (param->containing_type){ + case YON_TYPE_STRING: + g_key_file_set_string(__yon_window_config_file,param->section,param->parameter_name, (char*)param->property); + break; + case YON_TYPE_INT: + g_key_file_set_integer(__yon_window_config_file,param->section,param->parameter_name, *(int*)param->property); + break; + case YON_TYPE_DOUBLE: + g_key_file_set_double(__yon_window_config_file,param->section,param->parameter_name, *(double*)param->property); + break; + case YON_TYPE_BOOLEAN: + g_key_file_set_boolean(__yon_window_config_file,param->section,param->parameter_name, *(gboolean*)param->property); + break; + default: + break; + } + } + if (__yon_main_window_config.deleted_parameters) + for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ + __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); + g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL); + } + g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL); + } + + void yon_get_is_fullscreen(){ + gtk_window_is_maximized(__yon_window_config_target_window); + __yon_main_window_config.fullscreen = gtk_window_is_maximized(__yon_window_config_target_window); + if (!__yon_main_window_config.fullscreen) gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); + } + + /**yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event) + * [EN] + * + * [RU] + * Сохраняет настройки основного окна. Вызывается когда основное окно уничтожается. + */ + void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event){ + check_window_config_setup{ + yon_get_is_fullscreen(); + yon_window_config_save(); + } + gtk_main_quit(); + } + + void __yon_window_config_on_resize(){ + int max=0; + max=gtk_window_is_maximized(__yon_window_config_target_window); + if(max==0){ + gtk_window_get_size(__yon_window_config_target_window,&__yon_main_window_config.width,&__yon_main_window_config.height); + gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); + } + } + + /**yon_window_config_setup(GtkWindow *window) + * [EN] + * + * [RU] + * Устанавливает указатель на окно для отслеживания его положения и размера + */ + void yon_window_config_setup(GtkWindow *window){ + __yon_window_config_target_window = window; + g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL); + g_signal_connect(G_OBJECT(window),"check-resize"/*"configure-event"*/,G_CALLBACK(__yon_window_config_on_resize),NULL); + } + + void _yon_maximize(void *data){ + g_usleep(G_USEC_PER_SEC/10); + if(__yon_main_window_config.fullscreen ==1) gtk_window_maximize(__yon_window_config_target_window); + } + + /**yon_window_config_load(char *path) + * [EN] + * + * [RU] + * Загружает конфиг окна и инициализирует отслеживание его параметров + */ + int yon_window_config_load(char *path){ + __yon_window_config_file = g_key_file_new(); + __yon_window_config_path=yon_char_new(path); + if (!g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL)){ + struct stat st; + int size; + char *path = yon_char_divide(yon_char_new(__yon_window_config_path),yon_char_find_last(__yon_window_config_path,'/')); + if (stat(path, &st) == -1) { + mkdir(path, 0777); + } + FILE *fp; + fp=fopen(__yon_window_config_path,"w"); + fclose(fp); + g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL); + } + __yon_main_window_config.x = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosX",NULL); + __yon_main_window_config.y = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosY",NULL); + __yon_main_window_config.width = g_key_file_get_integer(__yon_window_config_file,"window","WindowWidth",NULL); + __yon_main_window_config.height = g_key_file_get_integer(__yon_window_config_file,"window","WindowHeight",NULL); + __yon_main_window_config.fullscreen = g_key_file_get_integer(__yon_window_config_file,"window","fullscreen",NULL); + dictionary *dict=NULL; + if (__yon_main_window_config.custom_listeners) + for_dictionaries(dict,__yon_main_window_config.custom_listeners){ + __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); + GValue *val = g_malloc0(sizeof(GValue)); + g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); + switch(param->containing_type){ + case YON_TYPE_STRING: + g_value_set_string(val,g_key_file_get_string(__yon_window_config_file,"window",param->parameter_name, NULL)); + break; + case YON_TYPE_INT: + g_value_set_int(val,g_key_file_get_integer(__yon_window_config_file,"window",param->parameter_name, NULL)); + break; + case YON_TYPE_DOUBLE: + g_value_set_double(val,g_key_file_get_double(__yon_window_config_file,"window",param->parameter_name, NULL)); + break; + case YON_TYPE_BOOLEAN: + gboolean res = g_key_file_get_boolean(__yon_window_config_file,"window",param->parameter_name, NULL); + g_value_set_boolean(val,res); + break; + default:printf("\033[0;31mCannot load %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; + } + g_object_set_property(G_OBJECT(param->track_widget),param->property_name,val); + } + if (__yon_main_window_config.width!=0&&__yon_main_window_config.height!=0) gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); + if (__yon_main_window_config.x!=0&&__yon_main_window_config.y!=0) gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); + + + pthread_t tid; + pthread_create(&tid,NULL,(void *)_yon_maximize,NULL); + return 1; + } + + void yon_window_config_apply(){ + dictionary *dict=NULL; + gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); + gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); + } + + config_str yon_window_config_get_section(char *section, gsize *size){ + config_str key = g_key_file_get_keys(__yon_window_config_file,section,size,NULL); + return key; + } + + /**yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type) + * [EN] + * + * [RU] + * Добавляет параметр виджета [widget] по названию [widget_property] для отслеживания и сохраняет его в конфиг под ключом [param_name]. + */ + void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type){ + __yon_listener_parameter *param = NULL; + param = yon_remalloc(param,sizeof(__yon_listener_parameter)); + param->parameter_name = yon_char_new(param_name); + param->track_widget = widget; + param->property_name = yon_char_new(widget_property); + param->containing_type = val_type; + yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_listeners,param->parameter_name,param); + } + + void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){ + __yon_custom_parameter *param = NULL; + param = yon_remalloc(param,sizeof(__yon_custom_parameter)); + param->parameter_name = yon_char_new(param_name); + param->section=section; + param->property = tracked_value; + param->containing_type = val_type; + yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_parameters,param->parameter_name,param); + } + + void yon_window_config_erase_custom_parameter(char *param_name, char *section){ + __yon_custom_parameter *param = NULL; + param = yon_remalloc(param,sizeof(__yon_custom_parameter)); + param->parameter_name=param_name; + param->section=section; + 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_DOUBLE: + *((int*)return_value) = g_key_file_get_double(__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),"aaa"); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + GtkWidget *label = gtk_label_new(buttonname); + GtkWidget *image = gtk_image_new_from_icon_name("dialog-information-symbolic",GTK_ICON_SIZE_BUTTON); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + gtk_box_pack_start(GTK_BOX(box),image,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(GTK_CONTAINER(menu_item),box); + gtk_widget_show_all(menu_item); + return menu_item; +} + +GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ + GtkWidget *menu_item = gtk_menu_item_new(); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"aaa"); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + GtkWidget *label = gtk_label_new(buttonname); + GtkWidget *image = gtk_image_new_from_icon_name("dialog-question-symbolic",GTK_ICON_SIZE_BUTTON); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + gtk_box_pack_start(GTK_BOX(box),image,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(GTK_CONTAINER(menu_item),box); + gtk_widget_show_all(menu_item); + return menu_item; +} + + +// other Gtk functions + +/**yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size) + * [EN] + * + * [RU] + * Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size] +*/ +int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size){ if (combo&¶meters){ for (int i=0;ifirst; dct != NULL; dct = dct->next) - { - gtk_box_pack_start(GTK_BOX(destination), (GtkWidget *)dct->data, expand, fill, padding); +void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column){ + GdkRectangle rect; + int x,y; + int width,height; + gtk_tree_view_column_cell_get_size(column, &rect,&x,&y,&width,&height); + gtk_tree_view_column_set_min_width(column,width); +} + +void yon_subwindow_close(GtkWidget *self){ + gtk_widget_destroy(gtk_widget_get_toplevel(self)); +} + +/**yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...) + * [EN] + * + * [RU] + * Добвляет [destination] все виджеты, прописанные после [padding]. Добавление происходит с начала контейнера. + * [expand] - расширяемость выделенного для виджетов места + * [fill] - заполнять ли виджетом всё ему выделенное место + * [padding] - отступ од других элементов +*/ +int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...){ + va_list args; + va_start(args,padding); + GtkWidget *widget = va_arg(args,GtkWidget*); + while (widget){ + gtk_box_pack_start(GTK_BOX(destination), widget, expand, fill, padding); } + va_end(args); return 1; - }else return 0; } -int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding) -{ - for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) - { - gtk_box_pack_end(GTK_BOX(destination), (GtkWidget *)dct->data, expand, fill, padding); - } +/**yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...) + * [EN] + * + * [RU] + * Добвляет в [destination] все виджеты, прописанные после [padding]. Добавление происходит с конца контейнера. + * [expand] - расширяемость выделенного для виджетов места + * [fill] - заполнять ли виджетом всё ему выделенное место + * [padding] - отступ од других элементов +*/ +int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...){ + va_list args; + va_start(args,padding); + GtkWidget *widget = va_arg(args,GtkWidget*); + while (widget){ + gtk_box_pack_end(GTK_BOX(destination), widget, expand, fill, padding); + } + va_end(args); return 1; } + +void yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target){ + gtk_widget_set_sensitive(target,gtk_toggle_button_get_active(toggle)); +} + +void yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target){ + gtk_widget_set_sensitive(target,!gtk_toggle_button_get_active(toggle)); + +} + +void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target){ + gtk_widget_set_sensitive(target,gtk_combo_box_get_active(toggle)>=0 ? 1 : 0); +} + +void yon_gtk_widget_set_sensitive_from_toggle_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ + gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>=0 ? 0 : 1); +} + void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) { gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); @@ -958,12 +2042,19 @@ void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidg gtk_image_set_from_resource(GTK_IMAGE(Image), image_path); } -/** - * -*/ -void _yon_ubl_status_box_render(render_data *datav) +int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label) { - render_data data = *(render_data*)datav; + if(icon&&box&&label){ + render.icon=icon; + render.box=box; + render.label=label; + return 1; + } else return 0; +} + +void _yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type) +{ + render_data data = render; GtkIconTheme *ictheme = gtk_icon_theme_get_default(); GError *err = NULL; if (err) @@ -971,20 +2062,24 @@ void _yon_ubl_status_box_render(render_data *datav) printf("%s\n", err->message); g_error_free(err); } - if (data.type == BACKGROUND_IMAGE_SUCCESS_TYPE||! data.type) + if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) { gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); } - else if (data.type == BACKGROUND_IMAGE_FAIL_TYPE) + else if (type == BACKGROUND_IMAGE_FAIL_TYPE) { gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); } - if (data.text_to_render) - gtk_label_set_text(GTK_LABEL(data.label), data.text_to_render); + if (text) + gtk_label_set_text(GTK_LABEL(data.label), text); +} + +void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type){ + _yon_ubl_status_box_render(text,type); } /**yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id) diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 963fa63..d11ee49 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -7,44 +7,63 @@ #include #include #include +#include +#include +#include +#include #include +#include #include #include +#include +#include #include "ubl-cmake.h" #ifdef WEBKIT_FOUND #include #endif -#define DesktopPath "/usr/share/applications/" +#define _(String) gettext(String) + +#define DesktopPath "/usr/share/applications/" +#define try bool __HadError=false; +#define catch(x) ExitJmp:if(__HadError) +#define throw(x) {__HadError=true;goto ExitJmp;} +static char** array_size_pow; #define for_dictionaries(obj, obj1) for (obj = obj1->first; obj != NULL; obj = obj->next) #define new(type) malloc(sizeof(type)) #define new_arr(type,size) malloc(sizeof(type)*size) +#define get_home_dir_command yon_char_unite("getent passwd \"",yon_ubl_root_user_get(),"\" | cut -d: -f6",NULL) + +#define get_processes_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.service\"" +#define get_slices_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.slice\"" + #define yon_ubl_set_config_save_data_pointer(command) config_commands.config_save_data = command #define yon_ubl_load_global_config(command, size_pointer) yon_config_load(command, size_pointer) #define yon_ubl_load_local_config(command, size_pointer) yon_config_load(command, size_pointer) #define yon_ubl_save_global_config(command) yon_config_save(command) #define yon_ubl_save_local_config(command) yon_config_save(command) - typedef enum { #ifdef __GTK_H__ DICTIONARY_GTK_WIDGETS_TYPE, #endif - DICTIONARY_OTHER_TYPE + DICTIONARY_OTHER_TYPE=0, + DICTIONARY_CHAR_TYPE, + DICTIONARY_INT_TYPE, + DICTIONARY_BOOL_TYPE, } DICT_TYPE; + typedef struct { char *command; int *exitcode; } thread_output; - - typedef struct dictionary { char *key; @@ -53,10 +72,12 @@ typedef struct dictionary struct dictionary *prev; struct dictionary *first; DICT_TYPE data_type; + int flag1; } dictionary; typedef struct apps { + char *filename; char *Name; int Type; char *Categories; @@ -64,9 +85,19 @@ typedef struct apps char *Icon; int Pluggable; int DualPluggable; + int Hidden; } apps; typedef char** config_str; + +static dictionary *__yon__config__strings = NULL; +#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE) + +#define config(key) yon_config_get_by_key(key) + +#define for_config dictionary temp = NULL; for_dictionary(temp,__yon__config__strings) + +#define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size) // dictionary functions /**yon_dictionary_get_data(dictionary, type) @@ -80,28 +111,36 @@ typedef char** config_str; * [type] - тип данных, хранящихся в словаре [dictionary]. */ #define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data) -#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_create_with_data(key,data); \ - else dict=yon_dictionary_create_with_data_connected(dict,key,data);} -dictionary *yon_dictionary_create_empty(); +/**yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) + * [EN] + * + * [RU] + * Добавляет элемент словаря в конец словаря [dict] c ключом [key] и данными [data]. + * Если словарь не существует, создаёт его +*/ +#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_new_with_data(key,data); \ + else dict=yon_dictionary_append_with_data(dict,key,data);} -dictionary *yon_dictionary_create_conneced(dictionary *targetdict); +dictionary *yon_dictionary_new(); + +dictionary *yon_dictionary_append(dictionary *targetdict); dictionary *yon_dictionary_get_last(dictionary *dict); -dictionary *yon_dictionary_switch_places(dictionary *dict, int aim); +dictionary *yon_dictionary_swap(dictionary *dict, int aim); void yon_dictionary_make_first(dictionary *dict); void yon_dictionary_make_nth(dictionary *dict, int nth); -dictionary *yon_dictionary_create_with_data(char *key, void *data); +dictionary *yon_dictionary_new_with_data(char *key, void *data); -dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data); +dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data); dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); -dictionary *yon_dictionary_find(dictionary **dict, char *key); +dictionary *yon_dictionary_get(dictionary **dict, char *key); dictionary *yon_dictionary_rip(dictionary *dict); @@ -111,7 +150,9 @@ void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(vo // char functions -char *yon_char_get_augumented(char *source, char *append); +int yon_char_find_last(char *source, char find); + +char *yon_char_append(char *source, char *append); char *yon_char_new(char *chr); @@ -124,12 +165,13 @@ char *yon_char_divide(char *source, int dividepos); char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); char *yon_char_from_int(int int_to_convert); +char *yon_char_from_long(long int_to_convert); char *yon_char_replace(char *source, char *find, char*replace); char **yon_char_parse(char *parameters, int *size, char *divider); -char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete); +char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete); int yon_char_parsed_check_exist(char **parameters, int size, char *param); @@ -137,43 +179,94 @@ int yon_char_find_count(char *source, char *find); int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size); -config_str yon_char_parsed_new (config_str old, int *old_size, ...); +config_str yon_char_parsed_new (int *size, ...); + +void yon_char_parsed_copy(config_str *source, config_str *to_copy); + +config_str yon_char_parsed_append(config_str parsed, int *size, char *string); + +int yon_char_parsed_remove_newline_symbols(config_str parsed, int *size); + +int yon_ubl_check_root(); + +char *yon_ubl_root_user_get(); + +char *yon_ubl_user_get_home_directory(); + +config_str yon_ubl_get_all_users(int *user_size); +config_str yon_ubl_get_all_processes(int *processes_size); +config_str yon_ubl_get_all_slices(int *slices_size); // parsing functions +config_str philos_list_user(int* size); + +dictionary *yon_scan_desktops(); + apps *yon_apps_scan_and_parse_desktops(int *sizef); void yon_apps_sort(apps *applist, int size); apps *yon_apps_get_by_name(apps *applist, char *name, int size); +char *yon_app_chooser_open_with_sections(char *section_name, char *section_filter, char *section_icon, ...); + config_str yon_config_load(char *command, int *str_len); -int yon_config_save(char *command); +int yon_config_save_registered(char *path, char *section); char *yon_config_get_parameter(config_str parameters, int size, char *param); -char *yon_config_make_save_parameter_with_multiple_arguments(char *parameter_string, char *config_parameter, char *divider); +int yon_config_load_register(char *command); -// terminal-using functions +int yon_config_remove_by_key(char *key); + +int yon_config_remove_by_data(void *data); + +int yon_config_remove_element(char *key, char *deleted); + +void *yon_config_get_by_key(char *key); + +char *yon_config_get_key_by_data(char *data); -int yon_launch_app(char *name); +int yon_config_set(char *key, void *data); + +int yon_config_clean(); + +void yon_config_register(char *key, void *data); + +config_str yon_config_get_all(); + +// terminal-using functions int yon_launch_app_with_arguments(char *name, char *args); -int yon_launch(thread_output *thread); +void yon_launch(char *command); + +void yon_launch_thread(char *command); // Gtk functions #ifdef __GTK_H__ #ifdef VTE_TERMINAL - -/** - * -*/ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument); + +void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument); + #endif +enum YON_TYPE{ + YON_TYPE_STRING, + YON_TYPE_STRING_LIST, + YON_TYPE_INT, + YON_TYPE_DOUBLE, + YON_TYPE_BOOLEAN, + YON_TYPE_OTHER +}; + +GtkWidget *yon_ubl_menu_item_about_new(char *buttonname); +GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname); + /**yon_gtk_builder_get_widget(builder, widget_name) * [EN] * Returns GtkWidget from GtkBuilder *[builder]. @@ -190,22 +283,39 @@ typedef struct GtkListStore *List; } expander_icon_view; -// GtkWidget *yon_gtk_app_chooser_apps_create(); +void yon_window_config_setup(GtkWindow *window); + +int yon_window_config_load(char *path); -// dictionary *yon_gtk_app_chooser_create(); +config_str yon_window_config_get_section(char *section, gsize *size); -// expander_icon_view yon_gtk_icon_view_expander_create(GtkWidget *pack, ...); +void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type); -int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); +void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type); + +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_text_fill(GtkWidget *combo, char **parameters,int size); int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); +void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column); + int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); -int yon_dictionary_gtk_pack_start_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding); -int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding); +void yon_subwindow_close(GtkWidget *self); + +int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); +int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); + +void yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target); +void yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target); +void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target); +void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target); typedef enum { @@ -221,6 +331,7 @@ typedef struct { char* text_to_render; } render_data; + /**yon_ubl_status_box_setup(render,icon,box,label) * [EN] * Sets up [render] structure of type render_data. @@ -233,7 +344,7 @@ typedef struct { * [box] - виджет типа GtkBox в котором будет отображаться цвет статуса; * [label] - виджет типа GtkLabel в котором будет отображаться текст статусного сообщения; */ -#define yon_ubl_status_box_setup(render,icon,box,label) {render.icon=GTK_WIDGET(icon); render.box=GTK_WIDGET(box); render.label=GTK_WIDGET(label);} +int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label); /**yon_ubl_status_box_render(render,text,type) * [EN] @@ -250,26 +361,7 @@ typedef struct { * или * BACKGROUND_IMAGE_SUCCESS_TYPE (Жёлтный фон, иконка - галка) */ -#define yon_ubl_status_box_render(render,text,m_type) {render.text_to_render=text; render.type=m_type; pthread_attr_t attr; pthread_attr_init(&attr); pthread_t tid; pthread_create(&tid,&attr,(void*)_yon_ubl_status_box_render,((void*)&render)); } - -#ifdef __cplusplus - -/**yon_ubl_header_setup(overlay, head, image, imag_path) - * [EN] - * Sets up header of app. - * [overlay] is overlay for app header; - * [head] is box of header, which connects to [overlay] - * [image] is header background image; - * [imag_path] is path of image, shown in [image] - * [RU] - * Настраивает заголовок приложения. - * [overlay] - оверлей заголовка приложения; - * [head] - шапка заголовка, присоединяемая к [overlay] - * [image] - виджет картинки для заднего фона; - * [imag_path] - путь до картинки, загружаемой в [image] -*/ -#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay.gobj()), GTK_WIDGET(head.gobj()), GTK_WIDGET(image.gobj()), (char *)imag_path) -#else +void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); /**yon_ubl_header_setup(overlay, head, image, imag_path) * [EN] @@ -290,8 +382,9 @@ typedef struct { #endif void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); + void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); -void _yon_ubl_status_box_render(render_data *datav); + void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id); #ifdef WEBKIT_FOUND @@ -299,5 +392,4 @@ void yon_ubl_browser_window_open(char *link, char *browser_window_name); #else void yon_ubl_browser_window_open(char *link, char *browser_window_name); #endif -#endif #endif \ No newline at end of file -- 2.35.1 From 6974d8db912939eaba5409bb4d6a221c0849a9b5 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 6 Sep 2023 16:34:39 +0600 Subject: [PATCH 5/6] Finished utils updating; Project updating --- gresource.xml | 2 + source/CMakeLists.txt | 2 + source/ubl-settings-video.c | 14 +- source/ubl-settings-video.h | 3 + source/ubl-utils.c | 4 +- ubl-settings-video-configuration.glade | 500 ++++++++++++++++++ ubl-settings-video-monitor.glade | 192 +++++++ ubl-settings-video.glade | 676 ------------------------- 8 files changed, 704 insertions(+), 689 deletions(-) create mode 100644 ubl-settings-video-configuration.glade create mode 100644 ubl-settings-video-monitor.glade diff --git a/gresource.xml b/gresource.xml index e089af7..ad86631 100644 --- a/gresource.xml +++ b/gresource.xml @@ -2,6 +2,8 @@ ubl-settings-video.glade + ubl-settings-video-monitor.glade + ubl-settings-video-configuration.glade ubl-settings-video.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 2340635..eaf0053 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -36,6 +36,8 @@ add_custom_target(GLADE ubl-settings-video.glade) set(DEPENDFILES ../ubl-settings-video.glade + ../ubl-settings-video-monitor.glade + ../ubl-settings-video-configuration.glade ../gresource.xml ../ubl-settings-video-banner.png ../ubl-settings-video.css diff --git a/source/ubl-settings-video.c b/source/ubl-settings-video.c index 9d59533..5708d88 100644 --- a/source/ubl-settings-video.c +++ b/source/ubl-settings-video.c @@ -672,7 +672,7 @@ void on_link(GtkWidget *self, char* link, gpointer user_data){ if (!link) link=UBLINUX_WIKI_LINK; if (videoconfig.alwaysredirect==0){ - GtkBuilder *builder=gtk_builder_new_from_resource(glade_path); + GtkBuilder *builder=gtk_builder_new_from_resource(glade_path_configuration); GtkWidget *sureWindow=yon_gtk_builder_get_widget(builder,"HelpSureWindow"); GtkWidget *readButton=yon_gtk_builder_get_widget(builder,"ReadHelpButton"); GtkWidget *cancelButton=yon_gtk_builder_get_widget(builder,"CancelHelpButton"); @@ -1408,7 +1408,7 @@ char *yon_char_parsed_get_resolution(config_str parsed_string, int size){ } void yon_monitor_view_new(monitor_config monitor){ - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_monitor); monitor_window *window = new(monitor_window); window->templateMonitorscreenOverlay=yon_gtk_builder_get_widget(builder,"templateMonitorscreenOverlay"); window->templateMonitorImage=yon_gtk_builder_get_widget(builder,"templateMonitorImage"); @@ -1833,20 +1833,12 @@ int main(int argc, char *argv[]) } if (getuid()!=0){ - // char *args=""; - // for (int i=0;i + + + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + + False + True + com.ublinux.ubl-settings-video + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + + + True + False + 5 + + + Enabled + True + True + False + True + + + False + True + 0 + + + + + False + True + 1 + + + + + True + False + vertical + + + True + False + end + 5 + True + + + Save + True + True + True + image5 + + + False + True + end + 0 + + + + + Cancel + True + True + True + image4 + + + False + True + end + 1 + + + + + False + True + 0 + + + + + False + True + end + 2 + + + + + True + False + vertical + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Port + + + False + True + 0 + + + + + True + False + 0 + + + True + True + 1 + + + + + Main display + True + True + False + True + + + False + True + 2 + + + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Resolution (px): + + + False + True + 0 + + + + + True + False + 0 + + + True + True + 1 + + + + + Show unsupported + True + True + False + True + + + False + True + 2 + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Frequency (Hz): + + + False + True + 0 + + + + + True + False + 0 + + 60 + 75 + + + + True + True + 1 + + + + + False + True + 3 + + + + + True + False + 5 + + + True + False + Rotation: + + + False + True + 0 + + + + + True + False + 0 + + + True + True + 1 + + + + + False + True + 4 + + + + + True + False + 5 + + + True + False + Position: + + + False + True + 0 + + + + + True + False + 5 + True + + + True + False + 0 + + + True + True + 0 + + + + + True + False + 0 + + + True + True + 1 + + + + + True + True + 1 + + + + + False + True + 5 + + + + + Do not switch off display + True + True + False + True + + + False + True + 6 + + + + + Create modeline for current resolution with CVT + True + True + False + True + + + False + True + 7 + + + + + Use "CVT Reduced Blanking"gshgrbehr + True + True + False + True + + + False + True + 8 + + + + + Create modeline for current resolution with GTF + True + True + False + True + + + False + True + 9 + + + + + True + False + + + False + True + 10 + + + + + False + True + 0 + + + + + True + False + 5 + 5 + vertical + 5 + + + Configure manually through parameter line: + True + True + False + True + + + False + True + 0 + + + + + True + False + True + center + 1920x1080 + + + True + True + 1 + + + + + False + True + 1 + + + + + False + True + 3 + + + + + True + True + 0 + + + + + + diff --git a/ubl-settings-video-monitor.glade b/ubl-settings-video-monitor.glade new file mode 100644 index 0000000..155909f --- /dev/null +++ b/ubl-settings-video-monitor.glade @@ -0,0 +1,192 @@ + + + + + + True + False + True + Switch + system-shutdown-symbolic + + + True + False + True + Delete + user-trash-symbolic + + + False + True + value-increase-symbolic + + + True + False + Configure + open-menu-symbolic + + + + True + False + start + 3 + 3 + 3 + 3 + 10 + 20 + vertical + + + True + False + True + + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + True + + + + + + + False + True + 1 + + + + + True + False + 15 + + + True + True + True + image14 + + + + False + True + 0 + + + + + True + True + True + image13 + + + + False + True + 1 + + + + + True + True + True + True + end + image3 + + + + False + True + end + 2 + + + + + True + True + True + Add + image15 + + + + False + True + 3 + + + + + False + True + 2 + + + + + True + False + + + True + False + False + 128 + com.ublinux.ubl-settings-video.display + 6 + + + -1 + + + + diff --git a/ubl-settings-video.glade b/ubl-settings-video.glade index f9dfd06..c72f264 100644 --- a/ubl-settings-video.glade +++ b/ubl-settings-video.glade @@ -741,670 +741,11 @@ translated and supported by community. False dialog-information-symbolic - - True - False - True - Switch - system-shutdown-symbolic - - - True - False - True - Delete - user-trash-symbolic - - - False - True - value-increase-symbolic - True False document-edit-symbolic - - True - False - Configure - open-menu-symbolic - - - - True - False - start - 3 - 3 - 10 - 20 - vertical - - - True - False - True - - - - - - - False - True - 0 - - - - - True - False - 5 - 5 - True - - - - - - - False - True - 1 - - - - - True - False - 15 - - - True - True - True - image14 - - - - False - True - 0 - - - - - True - True - True - image13 - - - - False - True - 1 - - - - - True - True - True - True - end - image3 - - - - False - True - end - 2 - - - - - True - True - True - Add - image15 - - - - False - True - 3 - - - - - False - True - 2 - - - - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - - - False - True - com.ublinux.ubl-settings-video - - - True - False - vertical - - - True - False - 5 - 5 - 5 - 5 - vertical - - - True - False - 5 - - - Enabled - True - True - False - True - - - False - True - 0 - - - - - False - True - 1 - - - - - True - False - vertical - - - True - False - end - 5 - True - - - Save - True - True - True - image5 - - - False - True - end - 0 - - - - - Cancel - True - True - True - image4 - - - False - True - end - 1 - - - - - False - True - 0 - - - - - False - True - end - 2 - - - - - True - False - vertical - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - Port - - - False - True - 0 - - - - - True - False - 0 - - - True - True - 1 - - - - - Main display - True - True - False - True - - - False - True - 2 - - - - - False - True - 1 - - - - - True - False - 5 - - - True - False - Resolution (px): - - - False - True - 0 - - - - - True - False - 0 - - - True - True - 1 - - - - - Show unsupported - True - True - False - True - - - False - True - 2 - - - - - False - True - 2 - - - - - True - False - 5 - - - True - False - Frequency (Hz): - - - False - True - 0 - - - - - True - False - 0 - - 60 - 75 - - - - True - True - 1 - - - - - False - True - 3 - - - - - True - False - 5 - - - True - False - Rotation: - - - False - True - 0 - - - - - True - False - 0 - - - True - True - 1 - - - - - False - True - 4 - - - - - True - False - 5 - - - True - False - Position: - - - False - True - 0 - - - - - True - False - 5 - True - - - True - False - 0 - - - True - True - 0 - - - - - True - False - 0 - - - True - True - 1 - - - - - True - True - 1 - - - - - False - True - 5 - - - - - Do not switch off display - True - True - False - True - - - False - True - 6 - - - - - Create modeline for current resolution with CVT - True - True - False - True - - - False - True - 7 - - - - - Use "CVT Reduced Blanking"gshgrbehr - True - True - False - True - - - False - True - 8 - - - - - Create modeline for current resolution with GTF - True - True - False - True - - - False - True - 9 - - - - - True - False - - - False - True - 10 - - - - - False - True - 0 - - - - - True - False - 5 - 5 - vertical - 5 - - - Configure manually through parameter line: - True - True - False - True - - - False - True - 0 - - - - - True - False - True - center - 1920x1080 - - - True - True - 1 - - - - - False - True - 1 - - - - - False - True - 3 - - - - - True - True - 0 - - - - - True False @@ -2753,21 +2094,4 @@ translated and supported by community. both - - True - False - - - True - False - False - 128 - com.ublinux.ubl-settings-video.display - 6 - - - -1 - - - -- 2.35.1 From 255d00e98567e1e69236920311b6a2c0e851c824 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 7 Sep 2023 09:25:56 +0600 Subject: [PATCH 6/6] Memory leak fixes --- source/ubl-settings-video.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/ubl-settings-video.c b/source/ubl-settings-video.c index 5708d88..f456e90 100644 --- a/source/ubl-settings-video.c +++ b/source/ubl-settings-video.c @@ -1502,7 +1502,6 @@ void yon_adapter_window_setup(widgets_dict *widgets){ char *driver_use = yon_config_get_parameter(rtn,size,"Kernel-driver-in-use"); yon_char_divide_search(driver_use,"=",-1); char *driver_all = yon_config_get_parameter(rtn,size,"Kernel-modules"); - driver_all = yon_char_replace(driver_all,"-"," "); yon_char_divide_search(driver_all,"=",-1); char *final_text = yon_char_unite("",DESCRIPTION_LABEL,": ",_(desc), "\n",VENDOR_LABEL,": ",vendor, -- 2.35.1