#include #include #include #include #include #include #include #include #include #include #include #include #define ui_WIKI_LINK "https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ublsettingsui-gtk3" #define _(String) gettext(String) #define ui_glade_path "/com/ublinux/ui/libublsettingsui-gtk3.glade" #define ui_glade_path_documentation "/com/ublinux/ui/libublsettingsui-gtk3-documentation.glade" #define ui_glade_path_about "/com/ublinux/ui/libublsettingsui-gtk3-about.glade" #define ui_glade_path_saving "/com/ublinux/ui/libublsettingsui-gtk3-saving.glade" #define ui_banner_path "/com/ublinux/images/libublsettingsui-gtk3-banner.png" #define ui_CssPath "/com/ublinux/css/libublsettingsui-gtk3.css" #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) #ifndef UBL_UI #define template_ui_LocalePath "/usr/share/locale" #define template_ui_LocaleName "libublsettingsui-gtk3" #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.") #define PARAMETER_LABEL _("Parameter") #define OLD_VALUE_LABEL _("Old value") #define NEW_VALUE_LABEL _("New value") #endif typedef struct { GtkWidget *interface; 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; int lock_help; int lock_save_local; int lock_save_global; int lock_load_global; int load_mode; int always_open_documentation; } _template_config; static _template_config *template_config; typedef struct { GtkWidget *Window; GtkWidget *HeadLabel; GtkWidget *PlugBox; GtkWidget *HeadOverlay; GtkWidget *HeadImage; GtkWidget *HeadBox; GtkWidget *HeadTitleLabel; GtkWidget *HeadInfoLabel; GtkWidget *StatusBox; GtkWidget *StatusIcon; GtkWidget *StatusLabel; GtkWidget *SaveMenuItem; GtkWidget *SaveGlobalMenuItem; GtkWidget *SaveLocalMenuItem; GtkWidget *RightBox; GtkWidget *LoadGlobalMenuItem; GtkWidget *LoadLocalMenuItem; GtkWidget *LeftBox; GtkWidget *DocumentationMenuItem; GtkWidget *AboutMenuItem; GtkWidget *InterfaceBox; } template_main_window; typedef struct { GtkWidget *Window; GtkWidget *HeaderLabel; GtkWidget *AlwaysOpenCheck; GtkWidget *CloseButton; GtkWidget *AcceptButton; } template_documentation_confirmation_window; typedef struct { GtkWidget *Window; GtkWidget *HeaderTopic; GtkWidget *HeaderImage; GtkWidget *StatusBox; GtkWidget *ParametersTree; GtkCellRenderer *ToggleCell; GtkWidget *CancelButton; GtkWidget *SaveButton; GtkListStore *list; GtkTreeModel *filteredModel; YON_CONFIG_TYPE type; } template_saving_window; typedef struct { void (*function)(void*,void*); void *data; char *action_text; } dialog_confirmation_data; int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data); template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...); /**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_setup(); /**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_init(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);