diff --git a/.gitignore b/.gitignore index 4a609ef..e11513c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ source/ubl-cmake.h vgcore* .BUILD.md .updatebuild.sh -.install.sh \ No newline at end of file +.install.sh +ublsettings-ui-debug +.install-debug.sh \ No newline at end of file diff --git a/gresource.xml b/gresource.xml index 7861abe..f24a0e6 100644 --- a/gresource.xml +++ b/gresource.xml @@ -2,6 +2,9 @@ ublsettings-ui.glade + ublsettings-ui-about.glade + ublsettings-ui-documentation.glade + ublsettings-ui-save-confirmation.glade ublsettings-ui.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a4d96b7..2a6b49a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -9,6 +9,11 @@ include_directories(${GTK_INCLUDE_DIRS}) link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) +pkg_check_modules(VTE291 REQUIRED vte-2.91) +include_directories(${VTE291_INCLUDE_DIRS}) +link_directories(${VTE291_LIBRARY_DIRS}) +add_definitions(${VTE291_CFLAGS_OTHER}) + find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) option(WEBKIT_FOUND "No" OFF) @@ -32,6 +37,9 @@ add_custom_target(GLADE ublsettings-ui.glade) set(DEPENDFILES ../ublsettings-ui.glade + ../ublsettings-ui-about.glade + ../ublsettings-ui-documentation.glade + ../ublsettings-ui-save-confirmation.glade ../gresource.xml ../ublsettings-ui-banner.png ../ublsettings-ui.css @@ -62,7 +70,7 @@ add_custom_target( set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ - -fstack-clash-protection -fcf-protection -g") + -fstack-clash-protection -fcf-protection") add_library(${PROJECT_NAME} SHARED ublsettings-ui.c diff --git a/source/ublsettings-ui.c b/source/ublsettings-ui.c index 2f79476..983cd19 100644 --- a/source/ublsettings-ui.c +++ b/source/ublsettings-ui.c @@ -4,48 +4,28 @@ //signal emmit handlers - no header initialization -/**on_close_subwindow(GtkWidget *self) - * [EN] - * Closes window in which [self] is contained. - * [RU] - * Закрывает окно, в котором расположен виджет [self]. -*/ -void on_close_subwindow(GtkWidget *self){ +void on_subwindow_close(GtkWidget *self){ gtk_widget_destroy(gtk_widget_get_toplevel(self)); } -/**yon_open_browser(GtkWidget *self, char *link) - * [EN] - * Opens browser with [link] link. - * [RU] - * Открывает браузер с [link] ссылкой. -*/ void yon_open_browser(GtkWidget *self, char *link){ - yon_ubl_browser_window_open(link,app_information.app_name); + yon_ubl_browser_window_open(link,template_app_information.app_title); } -/**on_open_documentation_confirmation(GtkWidget *self, char *link) - * [EN] - * Opens confirmation window for [link] link. - * [RU] - * Открывает окно подтверждение перехода по ссылке [link]. -*/ void on_open_documentation_confirmation(GtkWidget *self, char *link){ - if (app_information.always_open_documentation==0){ - GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path); - documentation_confirmation_window *widgets = malloc(sizeof(documentation_confirmation_window)); - widgets->Window = yon_gtk_builder_get_widget(builder,"helpConfirmationWindow"); - widgets->AcceptButton = yon_gtk_builder_get_widget(builder,"ReadHelpButton"); - widgets->CloseButton = yon_gtk_builder_get_widget(builder,"CancelHelpButton"); - widgets->HatText = yon_gtk_builder_get_widget(builder,"webHeaderNameLabel"); - widgets->HeaderText = yon_gtk_builder_get_widget(builder,"helpHeader"); - widgets->InfoText = yon_gtk_builder_get_widget(builder,"helpText"); - widgets->AlwaysOpenCheck = yon_gtk_builder_get_widget(builder,"AlwaysOpenDocumentationCheckbox"); - gtk_label_set_text(GTK_LABEL(widgets->HatText),app_information.app_name); - gtk_widget_show_all(widgets->Window); - g_signal_connect(G_OBJECT(widgets->CloseButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(yon_open_browser),yon_char_new(link)); - g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + if (template_app_information.always_open_documentation==0){ + GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_documentation); + template_documentation_confirmation_window *window = malloc(sizeof(template_documentation_confirmation_window)); + window->Window = yon_gtk_builder_get_widget(builder,"helpConfirmationWindow"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"ReadHelpButton"); + window->CloseButton = yon_gtk_builder_get_widget(builder,"CancelHelpButton"); + window->HeaderLabel = yon_gtk_builder_get_widget(builder,"webHeaderNameLabel"); + window->AlwaysOpenCheck = yon_gtk_builder_get_widget(builder,"AlwaysOpenDocumentationCheckbox"); + gtk_label_set_text(GTK_LABEL(window->HeaderLabel),template_app_information.app_title); + gtk_widget_show_all(window->Window); + g_signal_connect(G_OBJECT(window->CloseButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(yon_open_browser),yon_char_new(link)); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); } else { @@ -72,22 +52,14 @@ void on_link(GtkWidget *self, char* uri, gpointer user_data){ on_open_documentation_confirmation(self,uri); } -/**on_about() - * [EN] - * Function for setting up and showing AboutDialog. - * Connect it to "activate" signal of Documentation MenuItem. - * [RU] - * Функиця для настройки и показа окна AboutDialog. - * Присоединять к сигналу "activate" кнопки справки типа MenuItem. -*/ -void on_about(){ - GtkBuilder *builder=gtk_builder_new_from_resource(ui_glade_path); +void on_about(GtkWidget *self, char *version_application){ + GtkBuilder *builder=gtk_builder_new_from_resource(ui_glade_path_about); GtkWidget *window=yon_gtk_builder_get_widget(builder,"AboutWindow"); GtkWidget *title=yon_gtk_builder_get_widget(builder,"headerAboutTopic"); GtkWidget *hideButtonBox=yon_gtk_builder_get_widget(builder,"buttonBoxHide"); gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); - gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),app_information.app_name); - gtk_label_set_text(GTK_LABEL(title),app_information.app_name); + gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),template_app_information.app_title); + gtk_label_set_text(GTK_LABEL(title),template_app_information.app_title); g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),NULL); gtk_widget_set_visible(hideButtonBox,0); gtk_widget_destroy(hideButtonBox); @@ -97,22 +69,28 @@ void on_about(){ //functions void yon_load_proceed(char *command){ - if (yon_config_load_register(command)) - yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - else - yon_ubl_status_box_render(LOAD_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } // standard functions +int yon_ubl_connect_config(_template_config *config){ + int replaces; + if(!template_config) + replaces=0; + else + replaces=1; + template_config = config; + return replaces; +} -main_window *setup_window(){ +template_main_window *setup_window(){ /* Widgets getting | Получение виджетов */ - main_window *widgets = malloc(sizeof(main_window)); + template_main_window *widgets = malloc(sizeof(template_main_window)); GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path); widgets->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); - widgets->HatLabel = yon_gtk_builder_get_widget(builder,"headerTopic"); + widgets->HeadLabel = yon_gtk_builder_get_widget(builder,"headerTopic"); widgets->PlugBox = yon_gtk_builder_get_widget(builder,"plugBox"); widgets->HeadOverlay = yon_gtk_builder_get_widget(builder,"HeadOverlay"); @@ -125,13 +103,11 @@ main_window *setup_window(){ widgets->StatusIcon = yon_gtk_builder_get_widget(builder,"mainStatusIcon"); widgets->StatusLabel = yon_gtk_builder_get_widget(builder,"mainStatusLabel"); - widgets->SaveLabel = yon_gtk_builder_get_widget(builder,"headerSaveConfigLabel"); widgets->SaveMenuItem = yon_gtk_builder_get_widget(builder,"SaveGlobalLocalConfigurationMenuItem"); widgets->SaveGlobalMenuItem = yon_gtk_builder_get_widget(builder,"SaveGlobalConfigurationMenuItem"); widgets->SaveLocalMenuItem = yon_gtk_builder_get_widget(builder,"SaveLocalConfigurationMenuItem"); widgets->RightBox = yon_gtk_builder_get_widget(builder,"HeaderRightBox"); - widgets->LoadLabel = yon_gtk_builder_get_widget(builder,"headerLoadConfigLabel"); widgets->LoadGlobalMenuItem = yon_gtk_builder_get_widget(builder,"LoadGlobalConfigurationMenuItem"); widgets->LoadLocalMenuItem = yon_gtk_builder_get_widget(builder,"LoadLocalConfigurationMenuItem"); widgets->LeftBox = yon_gtk_builder_get_widget(builder,"HeaderLeftBox"); @@ -139,7 +115,10 @@ main_window *setup_window(){ widgets->DocumentationMenuItem = yon_ubl_menu_item_documentation_new(DOCUMENTATION_LABEL); widgets->AboutMenuItem = yon_ubl_menu_item_about_new(ABOUT_LABEL); - gtk_window_set_title(GTK_WINDOW(widgets->Window),app_information.app_name); + gtk_window_set_title(GTK_WINDOW(widgets->Window),template_app_information.app_title); + gtk_label_set_text(GTK_LABEL(widgets->HeadLabel),template_app_information.app_title); + gtk_label_set_text(GTK_LABEL(widgets->HeadTitleLabel),template_app_information.app_title); + gtk_label_set_text(GTK_LABEL(widgets->HeadInfoLabel),template_app_information.app_description); GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2"); gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->DocumentationMenuItem); @@ -150,7 +129,7 @@ main_window *setup_window(){ /* Signal connection | Присоединение сигналов */ g_signal_connect(G_OBJECT(widgets->Window), "destroy", G_CALLBACK(gtk_main_quit), NULL); - g_signal_connect(G_OBJECT(widgets->DocumentationMenuItem),"activate",G_CALLBACK(on_open_documentation_confirmation),app_information.wiki_link); + g_signal_connect(G_OBJECT(widgets->DocumentationMenuItem),"activate",G_CALLBACK(on_open_documentation_confirmation),template_app_information.wiki_link); g_signal_connect(G_OBJECT(widgets->AboutMenuItem),"activate",G_CALLBACK(on_about),NULL); @@ -158,29 +137,36 @@ main_window *setup_window(){ return widgets; } -int yon_ubl_window_setup(GtkWidget *interface, char *app_name, char *app_description, char *locale){ - app_information.interface=interface; - app_information.app_name=app_name; - app_information.app_description=app_description; - app_information.app_locale=locale; +int yon_ubl_window_setup(GtkWidget *interface, char *app_title, char *app_description, char *locale, char *css, char *tech_name, char *version, char *wiki){ + template_app_information.interface=interface; + template_app_information.app_title=app_title; + template_app_information.css_path=css; + template_app_information.app_tech_name=tech_name; + template_app_information.app_version=version; + template_app_information.wiki_link=wiki; + template_app_information.app_description=app_description; + + template_app_information.app_locale=locale; } -main_window *yon_ubl_window_init(int argc, char *argv[]){ - local=setlocale(LC_ALL, ""); - textdomain (app_information.app_locale); +template_main_window *yon_ubl_window_init(int argc, char *argv[]){ + textdomain (template_ui_LocaleName); + setlocale(LC_ALL,""); - gtk_init(&argc,&argv); + // gtk_init(&argc,&argv); - main_window *widgets = setup_window(); + template_main_window *widgets = setup_window(); yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,ui_banner_path); - yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); - if (getuid()!=0) - yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - else - yon_ubl_status_box_render(app_information.app_name,BACKGROUND_IMAGE_SUCCESS_TYPE); - yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,app_information.socket_id,app_information.load_socket_id,app_information.save_socket_id); + if (yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel)){ + if (getuid()!=0) + yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + else + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + } + if(template_config) + yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,template_config->socket_id,template_config->load_socket_id,template_config->save_socket_id); yon_window_config_setup(GTK_WINDOW(widgets->Window)); yon_window_config_load(ui_config_path); GtkCssProvider *css=gtk_css_provider_new(); @@ -190,5 +176,4 @@ main_window *yon_ubl_window_init(int argc, char *argv[]){ -1); return widgets; - gtk_main(); -} \ No newline at end of file +} diff --git a/source/ublsettings-ui.h b/source/ublsettings-ui.h index 394542c..ca189c7 100644 --- a/source/ublsettings-ui.h +++ b/source/ublsettings-ui.h @@ -18,37 +18,85 @@ #define _(String) gettext(String) #define ui_glade_path "/com/ublinux/ui/ublsettings-ui.glade" +#define ui_glade_path_documentation "/com/ublinux/ui/ublsettings-ui-documentation.glade" +#define ui_glade_path_about "/com/ublinux/ui/ublsettings-ui-about.glade" #define ui_banner_path "/com/ublinux/images/ublsettings-ui-banner.png" #define ui_CssPath "/com/ublinux/css/ublsettings-ui.css" -#define ui_config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",app_information.app_locale,"/",app_information.app_locale,".conf",NULL) +#define ui_config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",template_app_information.app_tech_name,"/",template_app_information.app_tech_name,".conf",NULL) -#define ui_LocalePath "/usr/share/locale" -#define ui_LocaleName "ublsettings-ui" -typedef char* string; -string version_application; +#ifndef UBL_UI + #define template_ui_LocalePath "/usr/share/locale" + #define template_ui_LocaleName "ublsettings-ui" -char *local; + #define SUCCESS_LABEL _("Operation succeeded") + #define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked") + #define ABOUT_LABEL _("About") + #define DOCUMENTATION_LABEL _("Documentation") + + #define SAVE_LOCAL_LABEL _("Save to local configuration") + #define SAVE_GLOBAL_LABEL _("Save to global configuration") + #define SAVE_CONFIGURATION_LABEL _("Save configuration") + #define SAVE_LABEL _("Save") + + #define LOAD_LOCAL_LABEL _("Load local configuration") + #define LOAD_GLOBAL_LABEL _("Load global configuration") + #define LOAD_LABEL _("Load") + + #define CANCEL_LABEL _("Cancel") + #define ACCEPT_LABEL _("Accept") + + #define HELP_TITLE_LABEL _("Would you like to read documentation in the Web?") + #define HELP_INFO_LABEL _("You will be redirected to documentation website where documentation is\ntranslated and supported by community.") + #define HELP_ALWAYS_OPEN_LABEL _("Always redirect to online documentation") + #define OPEN_HELP_LABEL _("Open documentation") + #define PROJECT_HOME_LABEL _("Project Home Page") + #define NOTHING_CHOSEN_LABEL _("Nothing were chosen") + + + #define GLOBAL_LOAD_SUCCESS_LABEL _("Global configuration loading succeeded.") + #define LOCAL_LOAD_SUCCESS_LABEL _("Local configuration loading succeeded.") + #define LOAD_FAILED_LABEL _("Config loading failed") + + #define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succeeded.") + #define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succeeded.") + #define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succeeded.") +#endif typedef struct { GtkWidget *interface; - char *app_name; - char *app_description; + char *app_locale; + char *css_path; + char *app_title; + char *app_description; + + char *app_tech_name; + char *app_version; char *wiki_link; + gboolean always_open_documentation; +} template_app_info; +static template_app_info template_app_information; + +typedef struct { int socket_id; int load_socket_id; int save_socket_id; -} app_info; + + int lock_help; + int lock_save_local; + int lock_save_global; + int lock_load_global; -static app_info app_information; + int always_open_documentation; +} _template_config; +static _template_config *template_config; typedef struct { - //Standard GtkWidget *Window; - GtkWidget *HatLabel; + GtkWidget *HeadLabel; GtkWidget *PlugBox; GtkWidget *HeadOverlay; @@ -61,49 +109,90 @@ typedef struct { GtkWidget *StatusIcon; GtkWidget *StatusLabel; - GtkWidget *SaveLabel; GtkWidget *SaveMenuItem; GtkWidget *SaveGlobalMenuItem; GtkWidget *SaveLocalMenuItem; GtkWidget *RightBox; - GtkWidget *LoadLabel; GtkWidget *LoadGlobalMenuItem; GtkWidget *LoadLocalMenuItem; GtkWidget *LeftBox; GtkWidget *DocumentationMenuItem; GtkWidget *AboutMenuItem; - // Custom -} main_window; +} template_main_window; typedef struct { GtkWidget *Window; + GtkWidget *HeaderLabel; - GtkWidget *HatText; - GtkWidget *HeaderText; - GtkWidget *InfoText; GtkWidget *AlwaysOpenCheck; GtkWidget *CloseButton; GtkWidget *AcceptButton; -} documentation_confirmation_window; - - -#define GLOBAL_LOAD_SUCCESS_LABEL _("Global configuration loading succseeded.") -#define LOCAL_LOAD_SUCCESS_LABEL _("Local configuration loading succseeded.") -#define LOAD_FAILED_LABEL _("Config loading failed") - -#define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded.") -#define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded.") -#define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded.") - -#define ABOUT_LABEL _("About") -#define DOCUMENTATION_LABEL _("Documentation") - -#define SUCCESS_LABEL _("Operation succeeded") -#define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked") - -main_window *yon_ubl_window_init(int argc, char *argv[]); -int yon_ubl_window_setup(GtkWidget *interface, char *app_name, char *app_description, char *locale); \ No newline at end of file +} template_documentation_confirmation_window; + +/**yon_open_browser(GtkWidget *self, char *link) + * [EN] + * Opens browser with [link] link. + * [RU] + * Открывает браузер с [link] ссылкой. +*/ +void yon_open_browser(GtkWidget *self, char *link); + +/**yon_ubl_connect_config(_template_config *config) + * [EN] + * + * [RU] + * Присоединяет конфиг основной утилиты (struct config) к стандартному интерфейсу. +*/ +int yon_ubl_connect_config(_template_config *config); + +/**yon_ubl_window_init(int argc, char *argv[]) + * [EN] + * + * [RU] + * Создаёт и настраивает основное окно приложения. +*/ +template_main_window *yon_ubl_window_init(int argc, char *argv[]); + +/**yon_ubl_window_setup(GtkWidget *interface, char *app_title, char *app_description, char *locale, char *css, char *tech_name, char *version, char *wiki) + * [EN] + * + * [RU] + * Установить важные значения для конфига; + * [app_title] - оботражаемое имя утилиты; + * [app_description] - отображаемое описание утилиты; + * [css] - путь к ресурсу css файла; + * [tech_name] - техническое имя утилиты (ubl-settings-) + * [version] - строка с версией приложения; + * [wiki] - ссылка на вики страницу; +*/ +int yon_ubl_window_setup(GtkWidget *interface, char *app_title, char *app_description, char *locale, char *css, char *tech_name, char *version, char *wiki); + +/**on_about() + * [EN] + * Function for setting up and showing AboutDialog. + * Connect it to "activate" signal of Documentation MenuItem. + * [RU] + * Функиця для настройки и показа окна AboutDialog. + * Присоединять к сигналу "activate" кнопки справки типа MenuItem. +*/ +void on_about(GtkWidget *self, char *version_application); + +/**on_open_documentation_confirmation(GtkWidget *self, char *link) + * [EN] + * Opens confirmation window for [link] link. + * [RU] + * Открывает окно подтверждения перехода по ссылке [link]. +*/ +void on_open_documentation_confirmation(GtkWidget *self, char *link); + +/**on_subwindow_close(GtkWidget *self) + * [EN] + * Closes window in which [self] is contained. + * [RU] + * Закрывает окно, в котором расположен виджет [self]. +*/ +void on_subwindow_close(GtkWidget *self); \ No newline at end of file diff --git a/ubl-utils/CMakeLists.txt b/ubl-utils/CMakeLists.txt index 4656047..9286eef 100644 --- a/ubl-utils/CMakeLists.txt +++ b/ubl-utils/CMakeLists.txt @@ -9,6 +9,11 @@ include_directories(${GTK_INCLUDE_DIRS}) link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) +pkg_check_modules(VTE291 REQUIRED vte-2.91) +include_directories(${VTE291_INCLUDE_DIRS}) +link_directories(${VTE291_LIBRARY_DIRS}) +add_definitions(${VTE291_CFLAGS_OTHER}) + find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) option(WEBKIT_FOUND "No" OFF) @@ -37,7 +42,7 @@ add_library(${PROJECT_NAME} SHARED set(LIBRARIES ${GTK_LIBRARIES} ${WEBKIT_LIBRARIES} -# ${VTE291_LIBRARIES} +${VTE291_LIBRARIES} pthread) message(${CMAKE_INSTALL_LIBDIR}) diff --git a/ubl-utils/ubl-utils.c b/ubl-utils/ubl-utils.c index 2403ef2..0e8b853 100644 --- a/ubl-utils/ubl-utils.c +++ b/ubl-utils/ubl-utils.c @@ -455,9 +455,9 @@ char *yon_char_append(char *source, char *append) int size = strlen(source) + strlen(append) + 1; char *final = malloc(size); memset(final, 0, size); - if (strstr(source, "%%")) - sprintf(final, source, append); - else + // if (strstr(source, "%%")) + // sprintf(final, source, append); + // else sprintf(final, "%s%s", source, append); return final; } @@ -522,15 +522,18 @@ char *yon_cut(char *source, int size, int startpos) */ char *yon_char_divide(char *source, int dividepos) { - char *cut = malloc(dividepos + 1); - memset(cut, 0, dividepos + 1); - memcpy(cut, source, dividepos); - char *left = malloc(strlen(source) - strlen(cut)); - memset(left, 0, strlen(source) - strlen(cut)); - memcpy(left, source + dividepos + 1, (strlen(source) - dividepos)); - memset(source, 0, strlen(source)); - memcpy(source, left, strlen(left)); - return cut; + if (source){ + char *cut = malloc(dividepos + 1); + memset(cut, 0, dividepos + 1); + memcpy(cut, source, dividepos); + char *left = malloc(strlen(source) - strlen(cut)); + memset(left, 0, strlen(source) - strlen(cut)); + memcpy(left, source + dividepos + 1, (strlen(source) - dividepos)); + memset(source, 0, strlen(source)); + memcpy(source, left, strlen(left)); + return cut; + } + return NULL; } /**yon_char_find_count(char *source, char *find) @@ -607,6 +610,46 @@ char *yon_char_from_int(int int_to_convert) return ch; } +/**yon_char_from_float(int int_to_convert) + * [EN] + * converts float to char*. + * + * [RU] + * Конвертирует float в char* + */ +char *yon_char_from_float(float int_to_convert) +{ + int i = 1; + float convert_check = (float)int_to_convert; + for (i = 1; convert_check >= 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = g_malloc0((i + 9)* sizeof(char)); + sprintf(ch, "%.2f", int_to_convert); + return ch; +} + +/**yon_char_from_long(int int_to_convert) + * [EN] + * converts long to char*. + * + * [RU] + * Конвертирует long в 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] * @@ -621,11 +664,11 @@ char *yon_char_replace(char *source, char *find, char*replace){ char *temp=NULL; if(!strstr(replace,find)){ while ((final=strstr(source,find))){ - temp=malloc(strlen(source)-strlen(final)); + temp=malloc(strlen(source)-strlen(final)+strlen(replace)); memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); memcpy(temp,source,strlen(source)-strlen(final)); temp=yon_char_append(temp,replace); - source=yon_char_append(temp,final+1); + source=yon_char_append(temp,final+strlen(find)); } } @@ -640,23 +683,22 @@ char *yon_char_replace(char *source, char *find, char*replace){ * size of returned array */ char **yon_char_parse(char *parameters, int *size, char *divider){ - char **string=NULL; - int i=1; - 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||param[0]=='\0') break; - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(param); - i++; - } - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(paramline); - i++; - *size=i-1; - return string; + if (parameters){ + char **string=NULL; + *size=0; + char *paramline=yon_char_new(parameters); + char *param = strstr(paramline,divider); + for (;param;param=strstr(paramline,divider)){ + string = yon_remalloc(string,sizeof(char*)*((*size)+1)); + string[(*size)]=yon_char_divide(paramline,strlen(paramline)-strlen(param)); + *size=(*size)+1; + } + string = yon_remalloc(string,sizeof(char*)*((*size)+1)); + string[(*size)]=paramline; + (*size)+=1; + return string; + } + return NULL; } /**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) @@ -705,6 +747,30 @@ int yon_char_parsed_check_exist(char **parameters, int size, char *param){ return -1; } +/**yon_char_parsed_check_repeats(char **parameters, int size) + * [EN] + * Checks if [parameters] string array of length [size] + * has repeated elements; + * [RU] + * Проверяет есть ли в массиве строк [parameters], размера [size] + * повторения +*/ +int yon_char_parsed_check_repeats(char **parameters, int size, int *first_overlap, int *second_overlap){ + if (parameters){ + *first_overlap=0; + *second_overlap=0; + for ((*first_overlap)=0;(*first_overlap)pw_name,NULL); + else { + user_list = yon_char_parsed_append(user_list,user_size,user->pw_name); + } + } + endpwent(); + return user_list; +} + // parsing functions +/** yon_size_convert_automatic(int bytes, int *size) + * [EN] + * + * [RU] + * +*/ +float yon_size_convert_automatic(int bytes, int *size){ + float byte_float=bytes; + for (*size=-1;byte_float>1024;*size=*size+1){ + byte_float=byte_float/1024; + } + if (*size==-1) { + *size=0; + byte_float=byte_float/1024; + } + return byte_float; +} apps *yon_apps_scan_and_parse_desktops(int *sizef) { @@ -941,8 +1045,73 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size) return NULL; }; + +/** + * yon_dir_get_contents(char *dir_path, int *size) + * [EN] + * + * [RU] + * Проверяет существует ли папка [dir_path] и + * возвращает список всех вложенных файлов и папок, + * передавая в [size] длину списка. +*/ +config_str yon_dir_get_contents(char *dir_path, int *size){ + config_str dir = NULL; + *size=0; + if (!access(dir_path,F_OK)){ + DIR *directory = opendir(dir_path); + struct dirent *de; + while ((de = readdir(directory))){ + if (dir) yon_char_parsed_append(dir,size,de->d_name); + else dir = yon_char_parsed_new(size,de->d_name,NULL); + } + closedir(directory); + } + return dir; +} + //config functions +typedef struct yon_config_parameter +{ + char *key; + void *data; + struct yon_config_parameter *next; + struct yon_config_parameter *prev; + struct yon_config_parameter *first; + DICT_TYPE data_type; + int flag1; + char *section; +} yon_config_parameter; + +yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){ + yon_config_parameter *param = yon_remalloc(NULL,sizeof(yon_config_parameter)); + param->data=data; + param->data_type=DICTIONARY_CHAR_TYPE; + param->first=param; + param->flag1=0; + param->key=yon_char_new(key); + param->next=NULL; + param->prev=NULL; + param->section=NULL; + return param; +} + +yon_config_parameter *yon_config_parameter_append_with_data(yon_config_parameter *dict, char *key, void *data){ + yon_config_parameter *param = yon_config_parameter_new_with_data(key,data); + param->first=dict->first; + (param->prev)=(yon_config_parameter*)yon_dictionary_get_last((dictionary*)dict); + dict->next=param; + return param; +} + + +static yon_config_parameter *__yon__config__strings = NULL; +#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE) +#define for_config dictionary temp = NULL; for_dictionary(temp,(dictionary*)__yon__config__strings) +#define yon_config_parameter_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_config_parameter_new_with_data(key,data); \ + else dict=yon_config_parameter_append_with_data(dict,key,data);} + /**yon_config_load_register(char *command) * [EN] * @@ -950,28 +1119,48 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size) * Выполняет команду [command]. * Полученные данные парсятся и регистрируются в конфиг. */ -int yon_config_load_register(char *command){ +int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...){ if (__yon__config__strings){ - __yon__config__strings = yon_dictionary_free_all(__yon__config__strings,NULL); + __yon__config__strings = yon_dictionary_free_all((dictionary*)__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)) + va_list args; + va_start(args,parameter); + char *arg; + dictionary *sections = NULL; { - if (strcmp(str, "") != 0&& strcmp(str,"(null)\n")!=0) + if (sections&&yon_dictionary_get(§ions,section)) sections->data=(void*)yon_char_unite(yon_dictionary_get_data(sections,char*)," ",parameter,NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections,section,parameter); + } + while (arg=va_arg(args,char*)){ + char *key = va_arg(args,char*); + if (sections&&yon_dictionary_get(§ions,arg)) sections->data=(void*)yon_char_unite(yon_dictionary_get_data(sections,char*)," ",key,NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections,arg,key); + } + char *command=NULL; + dictionary *dict; + for_dictionaries(dict,sections){ + command = yon_char_unite(ubconfig_load_command,config_type==YON_CONFIG_GLOBAL ? " global get " : " system get ", dict->key," ", yon_dictionary_get_data(dict,char*),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)) { - char *key = yon_char_divide_search(str,"=",-1); - yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,str); - __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; + 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_config_parameter_add_or_create_if_exists_with_data(__yon__config__strings,key,yon_char_new(final_str)); + __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; + __yon__config__strings->section=dict->key; + } } } check_config - return 0; - else return 1; + return 1; + else return 0; } /**yon_config_remove_by_key(char *key) @@ -982,35 +1171,15 @@ int yon_config_load_register(char *command){ */ int yon_config_remove_by_key(char *key){ check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + dictionary *dict = yon_dictionary_get((dictionary**)&__yon__config__strings,key); if (dict){ - yon_dictionary_rip(dict); + ((yon_config_parameter*)dict)->flag1=-1; 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] * @@ -1019,7 +1188,7 @@ int yon_config_remove_by_data(void *data){ */ int yon_config_remove_element(char *key, char *deleted){ check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key); char *data = (char*)dict->data; char *found = strstr(data,deleted); int size=strlen(data)-strlen(found)+1; @@ -1033,7 +1202,6 @@ int yon_config_remove_element(char *key, char *deleted){ new_data = yon_char_append(new_data,found+strlen(deleted)); } dict->data=(void*)(new_data); - free(data); dict->flag1=1; return 1; } else return 0; @@ -1048,8 +1216,8 @@ int yon_config_remove_element(char *key, char *deleted){ 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){ + for_dictionaries(dict, (dictionary*)__yon__config__strings){ + if (strcmp(dict->key,key)==0&&((yon_config_parameter*)dict)->flag1!=-1){ return dict->data; } } @@ -1057,6 +1225,21 @@ void *yon_config_get_by_key(char *key){ return NULL; } +void *yon_config_get_all_by_key(char *key, int *size){ + check_config{ + config_str ret_data=NULL; + dictionary *dict = NULL; + for_dictionaries(dict, (dictionary*)__yon__config__strings){ + if (strstr(dict->key,key)&&((yon_config_parameter*)dict)->flag1!=-1) { + char *ret_string = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); + if (ret_data) ret_data = yon_char_parsed_append(ret_data,size,ret_string); + else ret_data = yon_char_parsed_new(size,ret_string,NULL); + } + } + return ret_data; + } +} + /**yon_config_get_key_by_data(char *data) * [EN] * @@ -1067,7 +1250,7 @@ void *yon_config_get_by_key(char *key){ char *yon_config_get_key_by_data(char *data){ check_config{ dictionary *dict = NULL; - for_dictionaries(dict, __yon__config__strings){ + for_dictionaries(dict, (dictionary*)__yon__config__strings){ if (strcmp(((char*)dict->data),data)==0){ return dict->key; } @@ -1084,12 +1267,32 @@ char *yon_config_get_key_by_data(char *data){ */ int yon_config_set(char *key, void *data){ check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key); dict->data=data; + dict->flag1=1; return 1; } else return 0; } + +/**yon_config_append(char *key, void *data) + * [EN] + * + * [RU] + * Производит поиск по конфигу и дополняет значение параметра с ключом [key] значением [data]; +*/ +int yon_config_append(char *key, char *data){ + check_config{ + yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__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; @@ -1098,7 +1301,7 @@ int yon_config_set(char *key, void *data){ */ int yon_config_clean(){ check_config{ - __yon__config__strings = yon_dictionary_free_all(__yon__config__strings, NULL); + __yon__config__strings = (yon_config_parameter*)yon_dictionary_free_all((dictionary*)__yon__config__strings, NULL); return 1; } else return 0; @@ -1112,9 +1315,14 @@ int yon_config_clean(){ * [key] - ключ параметра; * [data] - значение параметра; */ -void yon_config_register(char *key, void *data){ - yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,data); +void yon_config_register(char *key, char *config_section, void *data){ + if (!__yon__config__strings||!yon_dictionary_get((dictionary**)&__yon__config__strings,key)){ + yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__strings,key,data); + } + else if (yon_dictionary_get((dictionary**)&__yon__config__strings,key)) __yon__config__strings->data=data; __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; + __yon__config__strings->flag1=1; + __yon__config__strings->section=yon_char_new(config_section); } /**yon_config_load(char *command, int *str_len) @@ -1136,7 +1344,6 @@ config_str yon_config_load(char *command, int *str_len){ 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, 4096); @@ -1152,22 +1359,93 @@ config_str yon_config_load(char *command, int *str_len){ } } -/**int yon_config_save(char *command) +/**int yon_config_save_registered(char *path) * [EN] - * Saves config with [command] + * Saves config at [path] config. + * [path] can be: + * system + * global * [RU] - * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: - * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" + * Сохраняет конфигурацию в [path] конфиг. + * [path] может быть + * system - локальный конфиг + * global - глобальный конфиг */ -int yon_config_save_registered(char *command){ +int yon_config_save_registered(char *path){ check_config{ - dictionary *dict = NULL; - for_dictionaries(dict,__yon__config__strings){ - command = yon_char_unite(command, " ", yon_dictionary_get_data(dict,char*), NULL); + dictionary *dct; + dictionary *sections_add=NULL; + dictionary *sections_remove=NULL; + for_dictionaries(dct,(dictionary*)__yon__config__strings){ + if (dct->data&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ + if (((yon_config_parameter*)dct)->flag1==1){ + ((yon_config_parameter*)dct)->flag1=0; + if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); + } else if (((yon_config_parameter*)dct)->flag1==-1){ + ((yon_config_parameter*)dct)->flag1=0; + if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); + yon_dictionary_rip(dct); + } + } } - if (popen(command, "r")) return 1; - else return 0; - } else return 0; + if (sections_add) + for_dictionaries(dct,sections_add){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + if (sections_remove) + for_dictionaries(dct,sections_remove){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + return 1; + } else return 1; +} + +/**int yon_config_force_save_registered(char *path, char *section) + * [EN] + * Force config to save at [path] config ignoring parameter save status. + * [path] can be: + * system + * global + * [RU] + * Принудительно сохраняет конфигурацию в [path] конфиг игнорируя статус параметра. + * [path] может быть + * system - локальный конфиг + * global - глобальный конфиг +*/ +int yon_config_force_save_registered(char *path){ + check_config{ + dictionary *dct; + dictionary *sections_add=NULL; + dictionary *sections_remove=NULL; + for_dictionaries(dct,(dictionary*)__yon__config__strings){ + if (dct->data&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ + if (((yon_config_parameter*)dct)->flag1==1||((yon_config_parameter*)dct)->flag1==0){ + if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); + } else if (((yon_config_parameter*)dct)->flag1==-1){ + if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); + else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); + } + } + } + if (sections_add) + for_dictionaries(dct,sections_add){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + if (sections_remove) + for_dictionaries(dct,sections_remove){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + + + return 1; + } else return 1; } /**yon_config_get_all(int *size) @@ -1182,13 +1460,14 @@ config_str yon_config_get_all(int *size){ *size = 1; config_str conf = NULL; dictionary *dict = NULL; - for_dictionaries(dict,__yon__config__strings){ + for_dictionaries(dict,(dictionary*)__yon__config__strings){ conf = yon_remalloc(conf,sizeof(char*)*(*size)); conf[(*size)-1] = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); - size++; + (*size)++; } - conf = yon_remalloc(conf,sizeof(char*)*(*size+1)); - conf[*size] = NULL; + conf = yon_remalloc(conf,sizeof(char*)*(*size)); + conf[*size-1] = NULL; + (*size)=(*size)-1; return conf; } else return NULL; } @@ -1226,7 +1505,71 @@ char *yon_config_get_parameter(config_str parameters, int size, char *param) return NULL; } +config_str yon_file_open(char *file_path, int *size){ + *size=0; + FILE *file = fopen(file_path,"r"); + if (file){ + char str_loaded[4098]; + config_str final_string = NULL; + while (fgets(str_loaded,4098,file)){ + final_string = final_string ? yon_char_parsed_append(final_string,size,str_loaded) : yon_char_parsed_new(size,str_loaded,NULL); + } + return final_string; + } +} + +/**yon_file_create(char *path, char *name, int rules) + * [EN] + * + * [RU] + * Создать файл с названием [name], находящимся по пути [path] + * С правами доступа [rules] (от 0000 до 0777) +*/ +int yon_file_create(char *path, char *name, int rules){ + if (path&&name){ + char *full_path = yon_char_unite(path,"/",name,NULL); + if (access(full_path,F_OK)){ + FILE *fl = fopen(full_path,"w"); + if (fl){ + chmod(full_path,rules); + fclose(fl); + return 1; + } else { + return 0; + } + } else { + return -1; + } + } else { + return 0; + } +} +/**yon_file_create_full_path(char *path, char *name, int rules) + * [EN] + * + * [RU] + * Создать файл по пути [path] + * С правами доступа [rules] (от 0000 до 0777) +*/ +int yon_file_create_full_path(char *path, int rules){ + if (path){ + if (access(path,F_OK)){ + FILE *fl = fopen(path,"w"); + if (fl){ + chmod(path,rules); + fclose(fl); + return 1; + } else { + return 0; + } + } else { + return -1; + } + } else { + return 0; + } +} // terminal-using functions @@ -1297,8 +1640,7 @@ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, voi 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); - printf("%s\n",install_command); + char *install_command=yon_char_unite("clear;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), @@ -1351,7 +1693,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end 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); + char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed; ",command," ; sleep 5; stty -echo; unset PS1","\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), @@ -1377,7 +1719,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end 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(terminal); @@ -1424,6 +1766,11 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end 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.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); + } 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*); @@ -1459,11 +1806,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end 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); } @@ -1525,12 +1868,14 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end 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,'/')); + config_str conf = yon_char_parse(yon_char_new(__yon_window_config_path),&size,"/"); + char *path = yon_char_unite(conf[0],"/",conf[1],"/",conf[2],"/",conf[3],"/",conf[4],"/",NULL); if (stat(path, &st) == -1) { mkdir(path, 0777); } FILE *fp; fp=fopen(__yon_window_config_path,"w"); + chmod(__yon_window_config_path,0777); fclose(fp); g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL); } @@ -1580,7 +1925,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end return key; } - /**yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type) + /**yon_window_config_add_custom_parameter(GtkWidget *widget, char *param_name, char *widget_property) * [EN] * * [RU] @@ -1604,6 +1949,23 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end 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); + dictionary *dict=NULL; + if (__yon_main_window_config.deleted_parameters) + for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ + if (strcmp(dict->key,param->parameter_name)) + yon_dictionary_rip(dict); + } + } + + void yon_window_config_add_instant_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){ + switch (val_type){ + case YON_TYPE_BOOLEAN: g_key_file_set_boolean(__yon_window_config_file,section,param_name,*((gboolean*)tracked_value)); + break; + case YON_TYPE_INT: g_key_file_set_integer(__yon_window_config_file,section,param_name,*((int*)tracked_value)); + break; + case YON_TYPE_STRING: g_key_file_set_string(__yon_window_config_file,section,param_name,(char*)tracked_value); + break; + } } void yon_window_config_erase_custom_parameter(char *param_name, char *section){ @@ -1613,7 +1975,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end 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){ @@ -1639,6 +2001,81 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end } } + void yon_on_window_config_custom_window_destroy(GtkWindow *window, char *window_name){ + if (!gtk_window_is_maximized(window)){ + int height=0; + int width=0; + int X=0; + int Y=0; + gtk_window_get_position(window,&X,&Y); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); + + } + } + + void yon_on_window_config_custom_window_resize(GtkWindow *window, char *window_name){ + if (!gtk_window_is_maximized(window)){ + int height=0; + int width=0; + int X=0; + int Y=0; + gtk_window_get_size(window,&width,&height); + gtk_window_get_position(window,&X,&Y); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Width"),"window",&width,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Height"),"window",&height,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); + } + + } + + void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name){ + int height=0; + int width=0; + int X=0; + int Y=0; + yon_window_config_get_parameter("window",yon_char_append(window_name,"Width"),&width,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"Height"),&height,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosX"),&X,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosY"),&Y,YON_TYPE_INT); + if (width&&height) + gtk_window_resize(window,width,height); + if (X&&Y) + gtk_window_move(window,X,Y); + char *signals_window_name = yon_char_new(window_name); + g_signal_connect(G_OBJECT(window),"check-resize",G_CALLBACK(yon_on_window_config_custom_window_resize),signals_window_name); + g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_window_config_custom_window_destroy),signals_window_name); + } + + void yon_window_config_custom_window_get(GtkWindow *window, char *window_name){ + int height=0; + int width=0; + int X=0; + int Y=0; + yon_window_config_get_parameter("window",yon_char_append(window_name,"Width"),&width,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"Height"),&height,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosX"),&X,YON_TYPE_INT); + yon_window_config_get_parameter("window",yon_char_append(window_name,"PosY"),&Y,YON_TYPE_INT); + if (width&&height) + gtk_window_resize(window,width,height); + if (X&&Y) + gtk_window_move(window,X,Y); + } + + void yon_window_config_custom_window_set(GtkWindow *window, char *window_name){ + int height=0; + int width=0; + int X=0; + int Y=0; + gtk_window_get_size(window,&width,&height); + gtk_window_get_position(window,&X,&Y); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Width"),"window",&width,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"Height"),"window",&height,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosX"),"window",&X,YON_TYPE_INT); + yon_window_config_add_instant_parameter(yon_char_append(window_name,"PosY"),"window",&Y,YON_TYPE_INT); + } + GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ GtkWidget *menu_item = gtk_menu_item_new(); gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom"); @@ -1655,7 +2092,7 @@ GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ 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),"menuitemtop"); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemmiddle"); 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); @@ -1670,13 +2107,13 @@ GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ // other Gtk functions -/**yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size) +/**yon_gtk_combo_box_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){ +int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){ if (combo&¶meters){ for (int i=0;i0 ? 1 : 0); +} + +void yon_gtk_widget_set_sensitive_from_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) { @@ -1799,6 +2257,115 @@ void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type){ _yon_ubl_status_box_render(text,type); } +void _yon_ubl_status_highlight_incorrect(GtkWidget *widget){ + gtk_style_context_add_class(gtk_widget_get_style_context(widget),"errorBox"); + sleep(5); + gtk_style_context_remove_class(gtk_widget_get_style_context(widget),"errorBox"); +} + +void yon_ubl_status_highlight_incorrect(GtkWidget *widget){ + GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_highlight_incorrect,widget); +} + +void _yon_ubl_status_list_store_highlight_incorrect(GtkWidget **widget_pack){ + GtkListStore *list = (GtkListStore*)widget_pack[0]; + GtkTreeIter *iter = (GtkTreeIter*)widget_pack[1]; + GdkRGBA rgba,rgba2; + rgba.alpha=1; + rgba.blue=153.0/255.0; + rgba.green=153.0/255.0; + rgba.red=234.0/255.0; + rgba2.alpha=1; + rgba2.blue=0; + rgba2.green=0; + rgba2.red=0; + gtk_list_store_set(list,iter,1,gdk_rgba_to_string(&rgba2),2,gdk_rgba_to_string(&rgba),-1); + sleep(5); + gtk_list_store_set(list,iter,1,NULL,2,NULL,-1); +} + +void yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter){ + GtkWidget **pack = malloc(sizeof(GtkWidget *)*2); + pack[0]=(GtkWidget*)list; + pack[1]=(GtkWidget*)iter; + GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_list_store_highlight_incorrect,pack); +} + +struct temp_statusbox { + int times; + GtkWidget *revealer; + }; + +void _yon_ubl_status_box_timed_remove(struct temp_statusbox *statusstruct){ + sleep(statusstruct->times); + if (status_thread_busy){ + gtk_revealer_set_reveal_child(GTK_REVEALER(statusstruct->revealer),0); + sleep(1); + gtk_widget_destroy(statusstruct->revealer); + + } + status_thread_busy=0; +} + +void __yon_ubl_status_box_destroyed(){ + status_thread_busy=0; +} + +void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type){ + if (!status_thread_busy){ + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + GtkWidget *revealer = gtk_revealer_new(); + GtkWidget *label = gtk_label_new(""); + GtkWidget *icon = gtk_image_new(); + gtk_container_add(GTK_CONTAINER(revealer),box); + gtk_box_pack_start(GTK_BOX(box),icon,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(container,revealer); + + gtk_widget_show_all(revealer); + gtk_revealer_set_reveal_child(GTK_REVEALER(revealer),1); + g_signal_connect(G_OBJECT(revealer),"destroy", G_CALLBACK(__yon_ubl_status_box_destroyed),NULL); + + gtk_widget_set_margin_bottom(label,9); + gtk_widget_set_margin_top(label,9); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + PangoAttrList *attributes = pango_attr_list_new(); + PangoAttribute *boldAttr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); + pango_attr_list_insert(attributes, boldAttr); + gtk_label_set_attributes(GTK_LABEL(label),attributes); + + GdkRGBA textColor; + gdk_rgba_parse(&textColor, "#4d4d4d4d4d4d"); + PangoAttribute *colorAttr = pango_attr_foreground_new( + (int)(textColor.red * 65535), + (int)(textColor.green * 65535), + (int)(textColor.blue * 65535) + ); + pango_attr_list_insert(attributes, colorAttr); + + GtkIconTheme *ictheme = gtk_icon_theme_get_default(); + if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessError"); + gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); + gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + else if (type == BACKGROUND_IMAGE_FAIL_TYPE) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); + gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessError"); + gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + if (display_text) + gtk_label_set_text(GTK_LABEL(label),display_text); + struct temp_statusbox *statusstruct = malloc(sizeof(struct temp_statusbox)); + statusstruct->revealer = revealer; + statusstruct->times = timeout; + GThread *thread = g_thread_new("StatusThread",(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct); + status_thread_busy=1; + } +} + /**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) * [EN] * Set up plugs for using with GtkSockets insine ubl-settings-manager. diff --git a/ubl-utils/ubl-utils.h b/ubl-utils/ubl-utils.h index 1e845f1..2fef789 100644 --- a/ubl-utils/ubl-utils.h +++ b/ubl-utils/ubl-utils.h @@ -14,8 +14,10 @@ #include #include #include +#include +#include -#include "ubl-cmake.h" +#include "../compile/ubl-cmake.h" #ifdef WEBKIT_FOUND #include #endif @@ -48,9 +50,11 @@ typedef struct dictionary struct dictionary *prev; struct dictionary *first; DICT_TYPE data_type; - int flag1; } dictionary; + + + typedef struct apps { char *Name; @@ -64,13 +68,8 @@ typedef struct 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 @@ -124,6 +123,10 @@ void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(vo // char functions +#define yon_char_divide_search_self(str,find,delete_divider) {char *temp = str; str = yon_char_divide_search(str,find,delete_divider); free(temp);} + +#define yon_char_is_empty(string) !(string&&strcmp(string,"")) + int yon_char_find_last(char *source, char find); char *yon_char_append(char *source, char *append); @@ -140,6 +143,10 @@ 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_float(float 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); @@ -148,12 +155,16 @@ 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); +int yon_char_parsed_check_repeats(char **parameters, int size, int *first_overlap, int *second_overlap); + 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 (int *size, ...); +void yon_char_parsed_free(config_str source, 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); @@ -164,8 +175,12 @@ char *yon_ubl_root_user_get(); char *yon_ubl_user_get_home_directory(); +config_str yon_ubl_get_all_users(int *user_size); + // parsing functions +float yon_size_convert_automatic(int bytes, int *size); + config_str philos_list_user(int* size); apps *yon_apps_scan_and_parse_desktops(int *sizef); @@ -174,13 +189,34 @@ void yon_apps_sort(apps *applist, int size); apps *yon_apps_get_by_name(apps *applist, char *name, int size); +config_str yon_file_open(char *file_path, int *size); + +int yon_file_create(char *path, char *name, int rules); + +int yon_file_create_full_path(char *path, int rules); + +config_str yon_dir_get_contents(char *dir_path, int *size); + +//config functions + +#define ubconfig_save_command "ubconfig" +#define ubconfig_load_command "ubconfig --source" + +typedef enum { + YON_CONFIG_LOCAL=0, + YON_CONFIG_GLOBAL, + YON_CONFIG_BOTH +} YON_CONFIG_TYPE; + config_str yon_config_load(char *command, int *str_len); -int yon_config_save_registered(char *command); +int yon_config_save_registered(char *path); + +int yon_config_force_save_registered(char *path); char *yon_config_get_parameter(config_str parameters, int size, char *param); -int yon_config_load_register(char *command); +int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...); int yon_config_remove_by_key(char *key); @@ -190,13 +226,15 @@ int yon_config_remove_element(char *key, char *deleted); void *yon_config_get_by_key(char *key); +void *yon_config_get_all_by_key(char *key, int *size); + char *yon_config_get_key_by_data(char *data); int yon_config_set(char *key, void *data); int yon_config_clean(); -void yon_config_register(char *key, void *data); +void yon_config_register(char *key, char* config_section, void *data); config_str yon_config_get_all(); @@ -257,10 +295,18 @@ 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); +void yon_window_config_custom_window_setup(GtkWindow *window, char *window_name); + +void yon_window_config_custom_window_get(GtkWindow *window, char *window_name); + +void yon_window_config_custom_window_set(GtkWindow *window, char *window_name); + int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); +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(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); @@ -268,6 +314,10 @@ int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean 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 { @@ -315,6 +365,13 @@ int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label); */ void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); +void yon_ubl_status_highlight_incorrect(GtkWidget *widget); + +void yon_ubl_status_list_store_highlight_incorrect(GtkListStore *list, GtkTreeIter *iter); + +static int status_thread_busy; +void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type); + #ifdef __cplusplus /**yon_ubl_header_setup(overlay, head, image, imag_path) diff --git a/ublsettings-ui-about.glade b/ublsettings-ui-about.glade new file mode 100644 index 0000000..cf83633 --- /dev/null +++ b/ublsettings-ui-about.glade @@ -0,0 +1,64 @@ + + + + + + False + False + True + center + com.ublinux.ublsettings-ui + dialog + True + ublsettings-ui + 1.1 + Copyright © 2022 - 2023, UBSoft LLC + TEMPLATE Manager + https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ublsettings-ui + Project Home Page + Это приложение распространяется без каких-либо гарантий. +Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. + UBGroup + UBGroup + com.ublinux.ublsettings-ui + True + gpl-2-0 + + + False + + + False + + + False + False + 0 + + + + + + + True + False + True + + + True + False + 5 + 5 + 5 + 5 + 2 + TEMPLATE Manager + + + + + + + + + diff --git a/ublsettings-ui-documentation.glade b/ublsettings-ui-documentation.glade new file mode 100644 index 0000000..8629012 --- /dev/null +++ b/ublsettings-ui-documentation.glade @@ -0,0 +1,208 @@ + + + + + + False + False + 450 + dialog-question-symbolic + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + 10 + + + True + False + + + True + False + start + 20 + 20 + dialog-question-symbolic + 6 + + + False + True + 0 + + + + + True + False + vertical + + + True + False + start + 10 + 5 + Would you like to read documentation in the Web? + True + 0 + + + + + + + False + True + 0 + + + + + True + False + start + start + 10 + 10 + You will be redirected to documentation website where documentation is +translated and supported by community. + True + 0 + + + + False + True + 1 + + + + + Always redirect to online documentation + True + True + False + end + True + + + + False + True + end + 2 + + + + + + True + True + 1 + + + + + + True + True + 0 + + + + + True + False + 30 + True + + + Cancel + True + True + True + image8 + + + + True + True + 0 + + + + + Open documentation + True + True + True + image9 + + + + True + True + 1 + + + + + False + True + 1 + + + + + + + True + False + True + + + True + False + TEMPLATE Manager + + + + + + + + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + diff --git a/ublsettings-ui-save-confirmation.glade b/ublsettings-ui-save-confirmation.glade new file mode 100644 index 0000000..168da42 --- /dev/null +++ b/ublsettings-ui-save-confirmation.glade @@ -0,0 +1,145 @@ + + + + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + + + + + + + + + + False + False + 450 + dialog-question-symbolic + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + 10 + + + True + True + liststore1 + + + + + + Parameter + + + + 0 + + + + + + + Save + + + + 1 + + + + + + + True + True + 0 + + + + + True + False + end + 5 + True + + + Cancel + True + True + True + image8 + + + + True + True + 0 + + + + + Accept + True + True + True + image9 + + + + True + True + 1 + + + + + False + True + 1 + + + + + + + True + False + True + + + True + False + ubl-settings-TEMPLATES + + + + + + + + + diff --git a/ublsettings-ui.glade b/ublsettings-ui.glade index fdaf89d..4c0777b 100644 --- a/ublsettings-ui.glade +++ b/ublsettings-ui.glade @@ -25,69 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - False - False - True - center - com.ublinux.ublsettings-ui - dialog - True - ublsettings-ui - 1.1 - Copyright © 2022 - 2023, UBSoft LLC - TEMPLATE Manager - https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ublsettings-ui - Project Home Page - Это приложение распространяется без каких-либо гарантий. -Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. - UBGroup - UBGroup - com.ublinux.ublsettings-ui - True - gpl-2-0 - - - True - False - vertical - 2 - - - False - end - - - False - False - 1 - - - - - - - True - False - True - - - True - False - 5 - 5 - 5 - 5 - 2 - TEMPLATE Manager - - - - - - - - True False @@ -191,207 +128,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - - - False - False - 450 - dialog-question-symbolic - - - True - False - 5 - 5 - 5 - 5 - vertical - 10 - - - True - False - - - True - False - start - 20 - 20 - dialog-question-symbolic - 6 - - - False - True - 0 - - - - - True - False - vertical - - - True - False - start - 10 - 5 - Would you like to read documentation in the Web? - True - 0 - - - - - - - False - True - 0 - - - - - True - False - start - start - 10 - 10 - You will be redirected to documentation website where documentation is -translated and supported by community. - True - 0 - - - - False - True - 1 - - - - - Always redirect to online documentation - True - True - False - end - True - - - - False - True - end - 2 - - - - - - True - True - 1 - - - - - - True - True - 0 - - - - - True - False - 30 - True - - - Cancel - True - True - True - image8 - - - - True - True - 0 - - - - - Open documentation - True - True - True - image9 - - - - True - True - 1 - - - - - False - True - 1 - - - - - - - True - False - True - - - True - False - TEMPLATE Manager - - - - - - - - True False diff --git a/ublsettings-ui.pot b/ublsettings-ui.pot index b516b52..f12d952 100644 --- a/ublsettings-ui.pot +++ b/ublsettings-ui.pot @@ -17,158 +17,106 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: source/ubl-strings.h:1 -msgid "Version:" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "ublsettings-ui version:" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "TEMPLATE settings" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Usage:" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "[OPTIONS]" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Options:" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Show this help" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Show package version" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Lock this help menu" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Lock configuration saving" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Lock local configration saving" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Lock global configration saving" -msgstr "" - -#: source/ubl-strings.h:2 -msgid "Lock global configration loading" -msgstr "" - -#: source/ubl-strings.h:4 -msgid "TEMPLATE Manager" -msgstr "" - -#: source/ubl-strings.h:5 -msgid "TEMPLATE management app" -msgstr "" - -#: source/ubl-strings.h:7 +#: source/ublsettings-ui.h:31 msgid "Operation succeeded" msgstr "" -#: source/ubl-strings.h:8 +#: source/ublsettings-ui.h:32 msgid "" "Warning! Application was launched without root - root-dependent actions are " "locked" msgstr "" -#: source/ubl-strings.h:10 +#: source/ublsettings-ui.h:34 msgid "About" msgstr "" -#: source/ubl-strings.h:11 +#: source/ublsettings-ui.h:35 msgid "Documentation" msgstr "" -#: source/ubl-strings.h:12 +#: source/ublsettings-ui.h:37 msgid "Save to local configuration" msgstr "" -#: source/ubl-strings.h:13 +#: source/ublsettings-ui.h:38 msgid "Save to global configuration" msgstr "" -#: source/ubl-strings.h:14 +#: source/ublsettings-ui.h:39 msgid "Save configuration" msgstr "" -#: source/ubl-strings.h:15 +#: source/ublsettings-ui.h:40 msgid "Save" msgstr "" -#: source/ubl-strings.h:16 +#: source/ublsettings-ui.h:42 msgid "Load local configuration" msgstr "" -#: source/ubl-strings.h:17 +#: source/ublsettings-ui.h:43 msgid "Load global configuration" msgstr "" -#: source/ubl-strings.h:18 +#: source/ublsettings-ui.h:44 msgid "Load" msgstr "" -#: source/ubl-strings.h:20 +#: source/ublsettings-ui.h:46 msgid "Cancel" msgstr "" -#: source/ubl-strings.h:22 +#: source/ublsettings-ui.h:47 +msgid "Accept" +msgstr "" + +#: source/ublsettings-ui.h:49 msgid "Would you like to read documentation in the Web?" msgstr "" -#: source/ubl-strings.h:23 +#: source/ublsettings-ui.h:50 msgid "" "You will be redirected to documentation website where documentation is\n" "translated and supported by community." msgstr "" -#: source/ubl-strings.h:24 +#: source/ublsettings-ui.h:51 msgid "Always redirect to online documentation" msgstr "" -#: source/ubl-strings.h:25 +#: source/ublsettings-ui.h:52 msgid "Open documentation" msgstr "" -#: source/ubl-strings.h:26 +#: source/ublsettings-ui.h:53 msgid "Project Home Page" msgstr "" -#: source/ubl-strings.h:27 +#: source/ublsettings-ui.h:54 msgid "Nothing were chosen" msgstr "" -#: source/ubl-strings.h:30 -msgid "Global configuration loading succseeded." +#: source/ublsettings-ui.h:57 +msgid "Global configuration loading succeeded." +msgstr "" + +#: source/ublsettings-ui.h:58 +msgid "Local configuration loading succeeded." msgstr "" -#: source/ubl-strings.h:31 -msgid "Local configuration loading succseeded." +#: source/ublsettings-ui.h:59 +msgid "Config loading failed" msgstr "" -#: source/ubl-strings.h:33 -msgid "Local and global configuration saving succseeded." +#: source/ublsettings-ui.h:61 +msgid "Local and global configuration saving succeeded." msgstr "" -#: source/ubl-strings.h:34 -msgid "Global configuration saving succseeded." +#: source/ublsettings-ui.h:62 +msgid "Global configuration saving succeeded." msgstr "" -#: source/ubl-strings.h:35 -msgid "Local configuration saving succseeded." +#: source/ublsettings-ui.h:63 +msgid "Local configuration saving succeeded." msgstr "" diff --git a/ublsettings-ui_ru.po b/ublsettings-ui_ru.po index 1ff99b7..a2719cf 100644 --- a/ublsettings-ui_ru.po +++ b/ublsettings-ui_ru.po @@ -17,122 +17,67 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: source/ubl-strings.h:1 -msgid "Version:" -msgstr "Версия:" - -#: source/ubl-strings.h:2 -msgid "ublsettings-ui version:" -msgstr "Версия ublsettings-ui: " - -#: source/ubl-strings.h:2 -msgid "TEMPLATE settings" -msgstr "Настройки TEMPLATE" - -#: source/ubl-strings.h:2 -msgid "Usage:" -msgstr "Использование:" - -#: source/ubl-strings.h:2 -msgid "[OPTIONS]" -msgstr "[АРГУМЕНТЫ]" - -#: source/ubl-strings.h:2 -msgid "Options:" -msgstr "Аргументы:" - -#: source/ubl-strings.h:2 -msgid "Show this help" -msgstr "Показать параметры справки" - -#: source/ubl-strings.h:2 -msgid "Show package version" -msgstr "Показать текущую версию" - -#: source/ubl-strings.h:2 -msgid "Lock this help menu" -msgstr "Блокировка вызова справки" - -#: source/ubl-strings.h:2 -#, fuzzy -msgid "Lock configuration saving" -msgstr "Блокировка сохранения локальной и глобальной конфигурации" - -#: source/ubl-strings.h:2 -msgid "Lock local configration saving" -msgstr "Блокировка сохранения локальной конфигурации" - -#: source/ubl-strings.h:2 -msgid "Lock global configration saving" -msgstr "Блокировка сохранения глобальной конфигурации" - -#: source/ubl-strings.h:2 -msgid "Lock global configration loading" -msgstr "Блокировка загрузки глобальной конфигурации" - -#: source/ubl-strings.h:4 -msgid "TEMPLATE Manager" -msgstr "Настройки TEMPLATE" - -#: source/ubl-strings.h:5 -msgid "TEMPLATE management app" -msgstr "Настройки TEMPLATE" - -#: source/ubl-strings.h:7 +#: source/ublsettings-ui.h:31 msgid "Operation succeeded" msgstr "Операция завершена" -#: source/ubl-strings.h:8 +#: source/ublsettings-ui.h:32 msgid "" "Warning! Application was launched without root - root-dependent actions are " "locked" -msgstr "Внимание! Приложение было запущено без прав суперпользователя - действия, требующие их наличия заблокированы" +msgstr "" +"Внимание! Приложение было запущено без прав суперпользователя - действия, " +"требующие их наличия заблокированы" -#: source/ubl-strings.h:10 +#: source/ublsettings-ui.h:34 msgid "About" msgstr "О программе" -#: source/ubl-strings.h:11 +#: source/ublsettings-ui.h:35 msgid "Documentation" msgstr "Справка" -#: source/ubl-strings.h:12 +#: source/ublsettings-ui.h:37 msgid "Save to local configuration" msgstr "Сохранить в локальную конфигурацию" -#: source/ubl-strings.h:13 +#: source/ublsettings-ui.h:38 msgid "Save to global configuration" msgstr "Сохранить в глобальную конфигурацию" -#: source/ubl-strings.h:14 +#: source/ublsettings-ui.h:39 msgid "Save configuration" msgstr "Сохранить конфигурацию" -#: source/ubl-strings.h:15 +#: source/ublsettings-ui.h:40 msgid "Save" msgstr "Сохранить" -#: source/ubl-strings.h:16 +#: source/ublsettings-ui.h:42 msgid "Load local configuration" msgstr "Загрузить локальную конфигуруцию" -#: source/ubl-strings.h:17 +#: source/ublsettings-ui.h:43 msgid "Load global configuration" msgstr "Загрузить глобальную конфигурацию" -#: source/ubl-strings.h:18 +#: source/ublsettings-ui.h:44 msgid "Load" msgstr "Загрузить" -#: source/ubl-strings.h:20 +#: source/ublsettings-ui.h:46 msgid "Cancel" msgstr "Отмена" -#: source/ubl-strings.h:22 +#: source/ublsettings-ui.h:47 +msgid "Accept" +msgstr "Принять" + +#: source/ublsettings-ui.h:49 msgid "Would you like to read documentation in the Web?" msgstr "Вы хотите прочитать справку в Сети?" -#: source/ubl-strings.h:23 +#: source/ublsettings-ui.h:50 msgid "" "You will be redirected to documentation website where documentation is\n" "translated and supported by community." @@ -140,38 +85,42 @@ msgstr "" "Вы будете перенаправлены на сайт с документацией, где страницы помощи\n" "переводятся и поддерживаются сообществом." -#: source/ubl-strings.h:24 +#: source/ublsettings-ui.h:51 msgid "Always redirect to online documentation" msgstr "Всегда перенаправлять" -#: source/ubl-strings.h:25 +#: source/ublsettings-ui.h:52 msgid "Open documentation" msgstr "Прочитать справку" -#: source/ubl-strings.h:26 +#: source/ublsettings-ui.h:53 msgid "Project Home Page" msgstr "Домашняя страница проекта" -#: source/ubl-strings.h:27 +#: source/ublsettings-ui.h:54 msgid "Nothing were chosen" msgstr "Ничего не было выбрано" -#: source/ubl-strings.h:30 -msgid "Global configuration loading succseeded." +#: source/ublsettings-ui.h:57 +msgid "Global configuration loading succeeded." msgstr "Успешно загружена глобальная конфигурация" -#: source/ubl-strings.h:31 -msgid "Local configuration loading succseeded." +#: source/ublsettings-ui.h:58 +msgid "Local configuration loading succeeded." msgstr "Успешно загружена локальная конфигурация" -#: source/ubl-strings.h:33 -msgid "Local and global configuration saving succseeded." +#: source/ublsettings-ui.h:59 +msgid "Config loading failed" +msgstr "" + +#: source/ublsettings-ui.h:61 +msgid "Local and global configuration saving succeeded." msgstr "Успешно записаны локальная и глобальная конфигурация" -#: source/ubl-strings.h:34 -msgid "Global configuration saving succseeded." +#: source/ublsettings-ui.h:62 +msgid "Global configuration saving succeeded." msgstr "Успешно записана глобальная конфигурация" -#: source/ubl-strings.h:35 -msgid "Local configuration saving succseeded." -msgstr "Успешно записана локальная конфигурация" +#: source/ublsettings-ui.h:63 +msgid "Local configuration saving succeeded." +msgstr "Успешно записана локальная конфигурация" \ No newline at end of file