|
|
#include "ublsettings-ui.h"
|
|
|
|
|
|
|
|
|
|
|
|
//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){
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/**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);
|
|
|
|
|
|
|
|
|
} 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);
|
|
|
}
|
|
|
|
|
|
/**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);
|
|
|
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);
|
|
|
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){
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
// standard functions
|
|
|
|
|
|
|
|
|
main_window *setup_window(){
|
|
|
/* Widgets getting | Получение виджетов */
|
|
|
main_window *widgets = malloc(sizeof(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->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->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");
|
|
|
|
|
|
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);
|
|
|
|
|
|
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),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_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;
|
|
|
}
|
|
|
|
|
|
main_window *yon_ubl_window_init(int argc, char *argv[]){
|
|
|
local=setlocale(LC_ALL, "");
|
|
|
textdomain (app_information.app_locale);
|
|
|
|
|
|
|
|
|
gtk_init(&argc,&argv);
|
|
|
|
|
|
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);
|
|
|
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;
|
|
|
gtk_main();
|
|
|
} |