#include "ublsettings-ui.h" //signal emmit handlers - no header initialization void on_subwindow_close(GtkWidget *self){ gtk_widget_destroy(gtk_widget_get_toplevel(self)); } void yon_open_browser(GtkWidget *self, char *link){ yon_ubl_browser_window_open(link,template_app_information.app_title); } void on_open_documentation_confirmation(GtkWidget *self, char *link){ 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 { yon_open_browser(self,link); } } /**on_link(GtkWidget *self, char* uri, gpointer user_data) * [EN] * Signal for hadnling AboutDialog links. * Connect to "activate-link" signal. * [self] is AboutDialog window; * [uri] is activated link; * [user_data] is pointer for user data, hasn't used in standard handler; * [RU] * Функция для обработки сигнала нажатия на ссылку окна AboutDialog. * Присоединять к сигналу "activate-link". * [self] - окно AboutDialog; * [uri] - ссылка, по которой совершается переход; * [user_data] - указатель на любые другие данные, не используется в стандартном обработчике; */ void on_link(GtkWidget *self, char* uri, gpointer user_data){ gtk_widget_destroy(self); on_open_documentation_confirmation(self,uri); } 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),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); gtk_widget_show(window); } //functions void yon_load_proceed(char *command){ 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; } template_main_window *setup_window(){ /* Widgets getting | Получение виджетов */ 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->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"); widgets->HeadImage = yon_gtk_builder_get_widget(builder,"HeadBackgroundImage"); widgets->HeadBox = yon_gtk_builder_get_widget(builder,"HeaderBox"); widgets->HeadTitleLabel = yon_gtk_builder_get_widget(builder,"HeaderTitleLabel"); widgets->HeadInfoLabel = yon_gtk_builder_get_widget(builder,"HeaderInfoLabel"); widgets->StatusBox = yon_gtk_builder_get_widget(builder,"mainStatusBox"); widgets->StatusIcon = yon_gtk_builder_get_widget(builder,"mainStatusIcon"); widgets->StatusLabel = yon_gtk_builder_get_widget(builder,"mainStatusLabel"); 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->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"); 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),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); gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->AboutMenuItem); /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ // yon_window_config_add_listener(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING); /* 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),template_app_information.wiki_link); g_signal_connect(G_OBJECT(widgets->AboutMenuItem),"activate",G_CALLBACK(on_about),NULL); gtk_widget_show(widgets->Window); return widgets; } 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; } template_main_window *yon_ubl_window_init(int argc, char *argv[]){ textdomain (template_ui_LocaleName); setlocale(LC_ALL,""); // gtk_init(&argc,&argv); template_main_window *widgets = setup_window(); yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,ui_banner_path); 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(); gtk_css_provider_load_from_resource(css,ui_CssPath); gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), -1); return widgets; }