#include "ubinstall-gtk.h" 
#include "pwquality.h"
 
config main_config; 

void yon_license_init(main_window *widgets){
    gtk_widget_set_sensitive(widgets->NextButton,0);
}

yon_window *yon_package_info_window_create(const char *package_str){
    if (yon_char_is_empty(package_str)) return NULL;
    yon_window *window = yon_window_new();
    yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,PACKAGE_INFO_LABEL,icon_path,"info-label");
    int size=0;
    char *package = yon_char_new(package_str);
    if (strstr(package,",")){
        char *temp = yon_char_replace(package,","," ");
        free(package);
        package = temp;
    }
    
    GtkWidget *label = NULL;
    yon_packages_info *info_struct = yon_packages_get_info_struct(YON_PACKAGES_ALL,package);
    if (!info_struct) return NULL;
    char* info_string = yon_packages_get_info_string(info_struct);
    config_str info = yon_char_parse(info_string,&size,"\n");
    if (size>0){
        info_element *element = yon_package_info_element_new();
        gtk_box_pack_start(GTK_BOX(window->MainBox),element->MainBox,1,1,0);
        for (int i=0;i<size;i++){
            yon_char_remove_last_symbol(info[i],'\n');
            GtkTreeIter iter;
            int parsed_size;
            config_str parsed = yon_char_parse(info[i],&parsed_size,":");
            gtk_list_store_append(element->InfoList,&iter);
            gtk_list_store_set(element->InfoList,&iter,0,parsed[0],1,!yon_char_is_empty(parsed[1])?_(parsed[1]):"",-1);
            
        }
    } else {
        label = gtk_label_new(PACKAGE_NOT_FOUND_LABEL);
        yon_gtk_label_set_font(GTK_LABEL(label));
        gtk_widget_show(label);
        gtk_box_pack_start(GTK_BOX(window->MainBox),label,0,0,0);
        gtk_label_set_xalign(GTK_LABEL(label),0);
    }
    gtk_widget_show(window->Window);
    return window;
}

double yon_password_check_func(const char *password_string){
    pwquality_settings_t *settings = pwquality_default_settings();
    int password_strength = pwquality_check(settings,password_string,NULL,NULL,NULL);
    if (password_strength<5){
        password_strength=5;
    }
    return (double)password_strength;
}

char *yon_password_check_error(const char *password_string){
    void *auxerror = NULL;
    pwquality_settings_t *settings = pwquality_default_settings();
    int password_strength = pwquality_check(settings,password_string,NULL,NULL,&auxerror);
    const char *add_info = NULL;
    if (auxerror){
        add_info = pwquality_strerror(NULL,4094,password_strength,auxerror);
    }
    if (password_strength<30){
        return yon_char_new(add_info);
    }
    return NULL;
}

void yon_open_browser(GtkWidget *, char *link){
    GtkWidget *window = yon_ubl_browser_window_open(link,TITLE_LABEL);
    if (window)
    gtk_window_set_icon_name(GTK_WINDOW(window),yon_char_append("com.ublinux.",LocaleName));
}

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),DOCUMENTATION_LABEL);
        gtk_window_set_title(GTK_WINDOW(window->Window),DOCUMENTATION_LABEL);
        gtk_window_set_icon_name(GTK_WINDOW(window->Window),yon_char_append("com.ublinux.",LocaleName));
        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 ){
    gtk_widget_destroy(self);
    on_open_documentation_confirmation(self,uri);
}

void yon_on_about(GtkWidget *, main_window *){
    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),TITLE_LABEL);
    gtk_about_dialog_set_logo_icon_name(GTK_ABOUT_DIALOG(window),yon_char_append("com.ublinux.",LocaleName));
    gtk_window_set_icon_name(GTK_WINDOW(window),yon_char_append("com.ublinux.",LocaleName));
    char *title_str = ABOUT_TITLE_LABEL;
    gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(window),LocaleName);
    gtk_label_set_text(GTK_LABEL(title),ABOUT_TITLE_LABEL);
    g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),NULL);
    gtk_widget_set_visible(hideButtonBox,0);
    gtk_widget_destroy(hideButtonBox);
    gtk_window_set_title(GTK_WINDOW(window),title_str);
    gtk_widget_show(window);
}

//functions

void yon_fs_type_setup(GtkComboBoxText *target){
    int size;
    config_str enc_types = yon_resource_open_file(fs_types_path,&size);
    for (int i=0;i<size;i++){
        yon_char_remove_last_symbol(enc_types[i],'\n');
        int parsed_size;
        config_str parsed = yon_char_parse(enc_types[i],&parsed_size,";");
        if (parsed_size){
            if (parsed[0][0]=='1'){
                gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(target),parsed[1],parsed[1]);
            }
            yon_char_parsed_free(parsed,parsed_size);
        }
    }
}

void on_rdp_toggled(GtkWidget *self, main_window *){
    GList *box = gtk_container_get_children(GTK_CONTAINER(self));
    GList *children = gtk_container_get_children(GTK_CONTAINER(box->data));

    int active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_list_nth_data(children,0)));
    if (!active){
        yon_launch(yon_debug_output("%s\n",enable_rdp_command));
    } else {
        yon_launch(yon_debug_output("%s\n",disable_rdp_command));
    }
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_list_nth_data(children,0)),!active);
    g_list_free(box);
    g_list_free(children);
}

void on_vnc_toggled(GtkWidget *self, main_window *){
    GList *box = gtk_container_get_children(GTK_CONTAINER(self));
    GList *children = gtk_container_get_children(GTK_CONTAINER(box->data));

    int active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_list_nth_data(children,0)));
    if (!active){
        yon_launch_app_with_arguments(enable_vnc_command,NULL);
    } else {
        yon_launch_app_with_arguments(disable_vnc_command,NULL);
    }
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_list_nth_data(children,0)),!active);
    g_list_free(box);
    g_list_free(children);
}

void on_toggle_button_switch_on(GtkWidget *, GtkToggleButton *toggle){
    gtk_toggle_button_set_active(toggle,1);
}

// standard functions 
/**config_init() 
 * [EN] 
 *  
 * [RU] 
 * Функция инициализации всех параметров конфигурации 
*/ 
void config_init(){
    memset(&main_config,0,sizeof(config));
    main_config.socket_id=-1; 
    main_config.save_socket_id=-1; 
    main_config.load_socket_id=-1; 
    main_config.load_mode=YON_CONFIG_GLOBAL;
    yon_packages_init();
    main_config.network_types = g_hash_table_new(g_str_hash,g_str_equal);

    main_config.devices = yon_config_load(get_devices_command,&main_config.devices_size);
    {
        int size;
        config_str ret = yon_config_load(os_name_get_command,&size);
        if (size){
            yon_char_remove_last_symbol(ret[0],'\n');
            main_config.os_name = yon_char_new(ret[0]);
            yon_char_parsed_free(ret,size);
        }
    }
    main_config.languages = g_hash_table_new(g_str_hash,g_str_equal);
    int size;
    config_str languages = yon_config_load(languages_command,&size);
    for (int i=0;i<size;i++){
        yon_char_remove_last_symbol(languages[i],'\n');
        int parsed_size;
        config_str parsed = yon_char_parse(languages[i],&parsed_size,"|");
        g_hash_table_insert(main_config.languages,yon_char_new(parsed[0]),yon_char_new(languages[i]));
        yon_char_parsed_free(parsed,parsed_size);
    }
    yon_char_parsed_free(languages,size);

    main_config.layouts_store = gtk_tree_store_new(5,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_BOOLEAN,G_TYPE_STRING);
    main_config.variants_list = yon_config_load(layouts_variant_command,&main_config.variants_size);
    main_config.layouts_list = yon_config_load(layouts_command,&main_config.layouts_size);
    for (int i=0;i<main_config.variants_size;i++){
        yon_char_remove_last_symbol(main_config.variants_list[i],'\n');
    }
    for (int i=0;i<main_config.layouts_size;i++){
        yon_char_remove_last_symbol(main_config.layouts_list[i],'\n');
    }
    main_config.startup_config=NULL;
}

void on_gparted_open(){
    yon_launch_app_with_arguments(open_gparted_command,NULL);
}

void on_gparted_update(GtkWidget *, main_window *widgets){
    gtk_widget_set_sensitive(widgets->CommonUpdateGpartedButton,0);
    gtk_widget_set_sensitive(widgets->NextInstallationUpdateGPartedButton,0);
    gtk_widget_set_sensitive(widgets->SameUpdateGpartedButton,0);
    gtk_widget_set_sensitive(widgets->GrubInstallUpdateGpartedButton,0);
    gtk_widget_set_sensitive(widgets->GrubUpdateUpdateGpartedButton,0);
    gtk_widget_set_sensitive(widgets->OSUpdateGpartedButton,0);
    gtk_widget_set_sensitive(widgets->UserdataUpdateGpartedButton,0);
    gtk_widget_set_sensitive(widgets->AdvancedUpdateGpartedButton,0);
    gtk_widget_set_sensitive(widgets->AdvancedDeviceTree,0);
    gtk_widget_set_sensitive(widgets->AdvancedPartitionTree,0);
    
    gtk_widget_set_sensitive(widgets->CommonInstallationDevicesTree,0);
    gtk_widget_set_sensitive(widgets->NextInstallationSysDevicesTree,0);
    gtk_widget_set_sensitive(widgets->NextInstallationSysSectionTree,0);
    gtk_widget_set_sensitive(widgets->SamePlaceDeviceTree,0);
    gtk_widget_set_sensitive(widgets->SamePlacePartTree,0);
    gtk_widget_set_sensitive(widgets->GrubInstallDevicesTree,0);
    gtk_widget_set_sensitive(widgets->GrubInstallPartitionTree,0);
    gtk_widget_set_sensitive(widgets->GrubUpdateDevicesTree,0);
    gtk_widget_set_sensitive(widgets->GrubUpdatePartitionTree,0);
    gtk_widget_set_sensitive(widgets->OSDevicesTree,0);
    gtk_widget_set_sensitive(widgets->OSSysSectionTree,0);
    gtk_widget_set_sensitive(widgets->UserdataDevicesTree,0);
    gtk_widget_set_sensitive(widgets->UserdataSysSectionTree,0);

    if (main_config.devices_size) yon_char_parsed_free(main_config.devices,main_config.devices_size);
    g_thread_new("devices_thread",(GThreadFunc)yon_devices_list_load,widgets);

    if (main_config.part_size) yon_char_parsed_free(main_config.partitions,main_config.part_size);
    g_thread_new("Partitions_thread",(GThreadFunc)yon_partitions_list_load,widgets);
    
}

void on_reboot_accepted(main_window *widgets){
    dialog_confirmation_data *data = yon_confirmation_dialog_data_new();
    data->action_text=WARNING_REBOOT_TEXT_LABEL;
    data->title=WARNING_TITLE_LABEL;
    if (yon_confirmation_dialog_call(widgets->MainWindow,data)==GTK_RESPONSE_ACCEPT){
        g_mutex_lock(&main_config.install_mutex);
        if (main_config.install_thread){
            pthread_cancel((pthread_t)main_config.install_thread);
        g_mutex_unlock(&main_config.install_mutex);
        }
        main_config.exit_accepted=1;
        yon_config_restore(widgets);
        while(gtk_events_pending()) gtk_main_iteration();
        if (system("reboot")){};

        gtk_main_quit();
        exit(0);
            }
}

void on_exit_accepted(main_window *widgets){
    g_mutex_lock(&main_config.install_mutex);
    if (main_config.install_thread){
        pthread_cancel((pthread_t)main_config.install_thread);
    g_mutex_unlock(&main_config.install_mutex);
    }
    if (!main_config.configure_mode)
        yon_config_restore(widgets);
    main_config.exit_accepted=1;
    while(gtk_events_pending()) gtk_main_iteration();
}

gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){
    if (!main_config.exit_accepted||(main_config.save_done&&main_config.install_complete)){
        if (!main_config.install_complete||!main_config.save_configured){
            dialog_confirmation_data *data = yon_confirmation_dialog_data_new();
            data->action_text=INTERRUPT_TEXT_LABEL;
            data->title=WARNING_TITLE_LABEL;
            if (yon_confirmation_dialog_call(widgets->MainWindow,data)==GTK_RESPONSE_ACCEPT ){
            yon_window_config_save_instant();
                on_exit_accepted(widgets);
                gtk_main_quit();
                return 1;
            }
        } else {
            on_exit_accepted(widgets);
            gtk_main_quit();
        }
    }

    return 1;
}

void yon_licence_load(main_window *widgets){
    int size;
    config_str parsed = NULL;
    parsed = yon_file_open(licence_path,&size);
    if (size){
        bind_textdomain_codeset("ublinux-init-eula","UTF-8");
        textdomain("ublinux-init-eula");
        char *licence = yon_char_parsed_to_string(parsed,size,"");
        gtk_label_set_text(GTK_LABEL(widgets->LicenceLabel),_(licence));
        free(licence);
        yon_char_parsed_free(parsed,size);
        textdomain(LocaleName);
    }
}

void yon_update_page(main_window *widgets){
    enum YON_PAGES page = gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->Notebook));
    yon_packages_update();
    while(gtk_events_pending()) gtk_main_iteration();
    yon_page_init(widgets,page);
    g_signal_handlers_unblock_by_func(G_OBJECT(widgets->db_lock_monitor),G_CALLBACK(yon_db_unlock_update),widgets);
    if (page == YON_PAGE_PACMAN_SOFTWARE){
        const char *search_string = gtk_entry_get_text(GTK_ENTRY(widgets->PacmanSoftwareSearchEntry));
        if (!yon_char_is_empty(search_string)) on_pacman_search_enter(GTK_ENTRY(widgets->PacmanSoftwareSearchEntry),widgets);
        g_hash_table_remove_all(widgets->pacmanchosen);
    }
    on_status_update(NULL,widgets);
}

void *yon_db_update(main_window *widgets){
    yon_launch("pacsync --updated");
    g_idle_add_once((GSourceOnceFunc)yon_update_page,widgets);
    pthread_exit(NULL);
}

void on_status_button_update(GtkWidget *, main_window *widgets){
    g_signal_handlers_block_by_func(G_OBJECT(widgets->db_lock_monitor),G_CALLBACK(yon_db_unlock_update),widgets);
    pthread_t tid=0;
    pthread_create(&tid,NULL,(void*(*)(void*))yon_db_update,widgets);

}

void yon_status_thread_update_inactive(main_window *widgets){
    gtk_image_set_from_icon_name(GTK_IMAGE(widgets->KernelPacmanStatusImage),inactive_icon_path,GTK_ICON_SIZE_BUTTON);
    gtk_image_set_from_icon_name(GTK_IMAGE(widgets->KernelAddonPacmanStatusImage),inactive_icon_path,GTK_ICON_SIZE_BUTTON);
    gtk_image_set_from_icon_name(GTK_IMAGE(widgets->PacmanSoftwareStatusImage),inactive_icon_path,GTK_ICON_SIZE_BUTTON);
    gtk_image_set_from_icon_name(GTK_IMAGE(widgets->AdditionalComponentsStatusImage),inactive_icon_path,GTK_ICON_SIZE_BUTTON);
    gtk_image_set_from_icon_name(GTK_IMAGE(widgets->PackagesStatusImage),inactive_icon_path,GTK_ICON_SIZE_BUTTON);
    gtk_label_set_text(GTK_LABEL(widgets->KernelPacmanStatusLabel),UNACCESSED_LABEL);
    gtk_label_set_text(GTK_LABEL(widgets->PacmanSoftwareStatusLabel),UNACCESSED_LABEL);
    gtk_label_set_text(GTK_LABEL(widgets->KernelAddonPacmanStatusLabel),UNACCESSED_LABEL);
    gtk_label_set_text(GTK_LABEL(widgets->AdditionalComponentsStatusLabel),UNACCESSED_LABEL);
    gtk_label_set_text(GTK_LABEL(widgets->PackagesStatusLabel),UNACCESSED_LABEL);
}

void yon_status_thread_update_active(main_window *widgets){
    gtk_image_set_from_icon_name(GTK_IMAGE(widgets->KernelPacmanStatusImage),active_icon_path,GTK_ICON_SIZE_BUTTON);
    gtk_image_set_from_icon_name(GTK_IMAGE(widgets->KernelAddonPacmanStatusImage),active_icon_path,GTK_ICON_SIZE_BUTTON);
    gtk_image_set_from_icon_name(GTK_IMAGE(widgets->PacmanSoftwareStatusImage),active_icon_path,GTK_ICON_SIZE_BUTTON);
    gtk_image_set_from_icon_name(GTK_IMAGE(widgets->AdditionalComponentsStatusImage),active_icon_path,GTK_ICON_SIZE_BUTTON);
    gtk_image_set_from_icon_name(GTK_IMAGE(widgets->PackagesStatusImage),active_icon_path,GTK_ICON_SIZE_BUTTON);
    gtk_label_set_text(GTK_LABEL(widgets->KernelPacmanStatusLabel),ACCESSED_LABEL);
    gtk_label_set_text(GTK_LABEL(widgets->PacmanSoftwareStatusLabel),ACCESSED_LABEL);
    gtk_label_set_text(GTK_LABEL(widgets->KernelAddonPacmanStatusLabel),ACCESSED_LABEL);
    gtk_label_set_text(GTK_LABEL(widgets->AdditionalComponentsStatusLabel),ACCESSED_LABEL);
    gtk_label_set_text(GTK_LABEL(widgets->PackagesStatusLabel),ACCESSED_LABEL);
}
void *yon_status_thread_update(main_window *widgets){
    if (system(yon_check_database_command)){
        g_idle_add_once((GSourceOnceFunc)yon_status_thread_update_inactive,widgets);
    } else {
        g_idle_add_once((GSourceOnceFunc)yon_status_thread_update_active,widgets);
    }
    pthread_exit(NULL);
}

void on_status_update(GtkWidget *,main_window *widgets){
    pthread_t tid=0;
    pthread_create(&tid,NULL,(void*(*)(void*))yon_status_thread_update,widgets);

}

void yon_scroll_block_for_builder(GtkBuilder *builder){
    GSList *list = gtk_builder_get_objects(builder);
    GSList *iter;
    for (iter = list; iter; iter=iter->next){
        if (GTK_IS_COMBO_BOX(iter->data)||GTK_IS_SPIN_BUTTON(iter->data)){
            yon_gtk_combo_box_block_scroll((GtkComboBox*)iter->data);
        }
    }
    g_slist_free(list);
}

void yon_db_lock_update(GFileMonitor *,GFile *,GFile *,GFileMonitorEvent ,main_window *widgets){
    if (!access(pacman_lock_path,F_OK)){
        gtk_widget_set_sensitive(widgets->KernelPacmanStatusButton,0);
        gtk_widget_set_sensitive(widgets->PacmanSoftwareStatusButton,0);
        gtk_widget_set_sensitive(widgets->KernelAddonPacmanStatusButton,0);
        gtk_widget_set_sensitive(widgets->PackagesStatusButton,0);
        gtk_widget_set_sensitive(widgets->AdditionalComponentsStatusButton,0);
    }
}

void yon_db_unlock_update(GFileMonitor *,GFile *,GFile *,GFileMonitorEvent ,main_window *widgets){
    if (access(pacman_lock_path,F_OK)){
        gtk_widget_set_sensitive(widgets->KernelPacmanStatusButton,1);
        gtk_widget_set_sensitive(widgets->PacmanSoftwareStatusButton,1);
        gtk_widget_set_sensitive(widgets->KernelAddonPacmanStatusButton,1);
        gtk_widget_set_sensitive(widgets->PackagesStatusButton,1);
        gtk_widget_set_sensitive(widgets->AdditionalComponentsStatusButton,1);
    }
}

void yon_main_window_create(main_window *widgets){
    __attribute__((unused)) char *locale = setlocale(LC_ALL, "en_US.UTF-8");
    GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
    yon_scroll_block_for_builder(builder);
    yon_installer_translation_init(builder);
    gtk_builder_add_callback_symbol(builder,"yon_gtk_widget_set_sensitive_from_toggle_button",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button));
    gtk_builder_add_callback_symbol(builder,"on_toggle_button_switch_on",G_CALLBACK(on_toggle_button_switch_on));
    // Custom widgets configuration 
    widgets->builder = builder;
    gtk_builder_set_translation_domain(builder,template_ui_LocaleName);

    {
        widgets->DevicesList=GTK_LIST_STORE(gtk_builder_get_object(builder,"DevicesList"));
        widgets->LanguagesList=GTK_LIST_STORE(gtk_builder_get_object(builder,"LanguagesList"));

        widgets->PartitionsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"PartitionsList"));

        main_config.kernel_unchosen_radio = yon_gtk_builder_get_widget(builder,"KernelUnchosenRadio");

        widgets->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow");
        widgets->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox");
        widgets->StatusBox2 = yon_gtk_builder_get_widget(builder,"StatusBox2");
        widgets->Notebook = yon_gtk_builder_get_widget(builder,"Notebook");
        widgets->MainSpinner=yon_gtk_builder_get_widget(builder,"MainSpinner");
        widgets->LicenseAgreeRadio = yon_gtk_builder_get_widget(builder,"LicenseAgreeRadio");

        widgets->DocumentationMenuItem = yon_ubl_menu_item_documentation_new(DOCUMENTATION_LABEL);
        widgets->AboutMenuItem = yon_ubl_menu_item_about_new(ABOUT_LABEL);

        widgets->LoadLocalConfigurationMenuItem = yon_gtk_builder_get_widget(builder,"LoadLocalConfigurationMenuItem");
        widgets->LoadExternalConfigurationMenuItem = yon_gtk_builder_get_widget(builder,"LoadExternalConfigurationMenuItem");

        widgets->SlidesImage = yon_gtk_builder_get_widget(builder,"SlidesImage");

        widgets->LicenceLabel = yon_gtk_builder_get_widget(builder,"LicenceLabel");

        widgets->menu1=yon_gtk_builder_get_widget(builder,"menu1");
        widgets->menu2=yon_gtk_builder_get_widget(builder,"menu2");

        widgets->CancelInstallButton=yon_gtk_builder_get_widget(builder,"CancelInstallButton");
        widgets->BackButton=yon_gtk_builder_get_widget(builder,"BackButton");
        widgets->NextButton=yon_gtk_builder_get_widget(builder,"NextButton");

        widgets->WelcomeToggle=yon_gtk_builder_get_widget(builder,"WelcomeToggle");
        widgets->LicenceToggle=yon_gtk_builder_get_widget(builder,"LicenceToggle");
        widgets->PreparationToggle=yon_gtk_builder_get_widget(builder,"PreparationToggle");
        widgets->ConfigurationToggle=yon_gtk_builder_get_widget(builder,"ConfigurationToggle");
        widgets->InstallationToggle=yon_gtk_builder_get_widget(builder,"InstallationToggle");
        widgets->CompletionToggle=yon_gtk_builder_get_widget(builder,"CompletionToggle");

        widgets->StartScenarioButton=yon_gtk_builder_get_widget(builder,"StartScenarioButton");

        widgets->SourceButton=yon_gtk_builder_get_widget(builder,"SourceButton");

        widgets->InstallationRadio=yon_gtk_builder_get_widget(builder,"InstallationRadio");
        widgets->InstallationNearRadio=yon_gtk_builder_get_widget(builder,"InstallationNearRadio");
        widgets->InstallationLinuxRadio=yon_gtk_builder_get_widget(builder,"InstallationLinuxRadio");
        widgets->InstallationWindowsRadio=yon_gtk_builder_get_widget(builder,"InstallationWindowsRadio");
        widgets->InstallationOptionsRadio=yon_gtk_builder_get_widget(builder,"InstallationOptionsRadio");
        widgets->GrubInstallRadio = yon_gtk_builder_get_widget(builder,"GrubInstallRadio");
        widgets->GrubUpdateRadio = yon_gtk_builder_get_widget(builder,"GrubUpdateRadio");
        widgets->SeparateRadio = yon_gtk_builder_get_widget(builder,"SeparateRadio");
        widgets->OSRadio = yon_gtk_builder_get_widget(builder,"OSRadio");
        widgets->UserDataOnlyRadio = yon_gtk_builder_get_widget(builder,"UserDataOnlyRadio");

        widgets->CommonInstallationDevicesTree = yon_gtk_builder_get_widget(builder,"CommonInstallationDevicesTree");
        widgets->CommonInstallationFilesystemTypeCombo = yon_gtk_builder_get_widget(builder,"CommonInstallationFilesystemTypeCombo");
        widgets->CommonInstallationSectionNameEntry = yon_gtk_builder_get_widget(builder,"CommonInstallationSectionNameEntry");
        widgets->CommonFormatSwitch = yon_gtk_builder_get_widget(builder,"CommonFormatSwitch");
        widgets->CommonGpartedButton = yon_gtk_builder_get_widget(builder,"CommonGpartedButton");
        widgets->CommonUpdateGpartedButton = yon_gtk_builder_get_widget(builder,"CommonUpdateGpartedButton");

        widgets->SamePlaceDeviceTree = yon_gtk_builder_get_widget(builder,"SamePlaceDeviceTree");
        widgets->SamePlacePartTree = yon_gtk_builder_get_widget(builder,"SamePlacePartTree");
        widgets->SameInstallationFormatSwitch = yon_gtk_builder_get_widget(builder,"SameInstallationFormatSwitch");
        widgets->SameInstallationFormatRevealer = yon_gtk_builder_get_widget(builder,"SameInstallationFormatRevealer");
        widgets->SameInstallationFilesystemTypeCombo = yon_gtk_builder_get_widget(builder,"SameInstallationFilesystemTypeCombo");
        widgets->SameInstallationSectionNameEntry = yon_gtk_builder_get_widget(builder,"SameInstallationSectionNameEntry");
        widgets->SameGpartedButton = yon_gtk_builder_get_widget(builder,"SameGpartedButton");
        widgets->SameUpdateGpartedButton = yon_gtk_builder_get_widget(builder,"SameUpdateGpartedButton");

        widgets->NextInstallationFilesystemTypeCombo = yon_gtk_builder_get_widget(builder,"NextInstallationFilesystemTypeCombo");
        widgets->NextInstallationFormatSwitch = yon_gtk_builder_get_widget(builder,"NextInstallationFormatSwitch");
        widgets->NextInstallationFormatRevealer = yon_gtk_builder_get_widget(builder,"NextInstallationFormatRevealer");
        widgets->NextInstallationSectionNameEntry = yon_gtk_builder_get_widget(builder,"NextInstallationSectionNameEntry");
        widgets->NextInstallationSizeSpin = yon_gtk_builder_get_widget(builder,"NextInstallationFormatSizeSpin");
        widgets->NextInstallationSizeTypeSpin = yon_gtk_builder_get_widget(builder,"NextInstallationFormatSizeCombo");
        widgets->NextInstallationSysDevicesTree = yon_gtk_builder_get_widget(builder,"NextInstallationSysDevicesTree");
        widgets->NextInstallationSysSectionTree = yon_gtk_builder_get_widget(builder,"NextInstallationSysSectionTree");
        widgets->NextInstallationGPartedButton = yon_gtk_builder_get_widget(builder,"NextInstallationGPartedButton");
        widgets->NextInstallationUpdateGPartedButton = yon_gtk_builder_get_widget(builder,"NextInstallationUpdateGPartedButton");

        widgets->AdvancedDeviceChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"AdvancedDeviceChosenCell"));
        widgets->AdvancedPartChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"AdvancedPartChosenCell"));
        widgets->AdvancedGpartedButton = yon_gtk_builder_get_widget(builder,"AdvancedGpartedButton");
        widgets->AdvancedUpdateGpartedButton = yon_gtk_builder_get_widget(builder,"AdvancedUpdateGpartedButton");
        widgets->AdvancedDeviceTree = yon_gtk_builder_get_widget(builder,"AdvancedDeviceTree");
        widgets->AdvancedVirtualDeviceCombo = yon_gtk_builder_get_widget(builder,"AdvancedVirtualDeviceCombo");
        widgets->AdvancedPartitionTree = yon_gtk_builder_get_widget(builder,"AdvancedPartitionTree");
        widgets->AdvancedPartitionAddBox = yon_gtk_builder_get_widget(builder,"AdvancedPartitionAddBox");
        widgets->AdvancedAddButton = yon_gtk_builder_get_widget(builder,"AdvancedAddButton");
        widgets->AdvancedLoadTypeSwitch = yon_gtk_builder_get_widget(builder,"AdvancedLoadTypeSwitch");
        widgets->AdvancedBiosSectorSwitch = yon_gtk_builder_get_widget(builder,"AdvancedBiosSectorSwitch");
        widgets->AdvancedEFISwitch = yon_gtk_builder_get_widget(builder,"AdvancedEFISwitch");
        widgets->AdvancedSwapSwitch = yon_gtk_builder_get_widget(builder,"AdvancedSwapSwitch");
        widgets->AdvancedSwapAutoSwitch = yon_gtk_builder_get_widget(builder,"AdvancedSwapAutoSwitch");
        widgets->AdvancedSwapRamSwitch = yon_gtk_builder_get_widget(builder,"AdvancedSwapRamSwitch");
        widgets->AdvancedSwapFixedSwitch = yon_gtk_builder_get_widget(builder,"AdvancedSwapFixedSwitch");
        widgets->AdvancedSwapFixedSizeSwitch = yon_gtk_builder_get_widget(builder,"AdvancedSwapFixedSizeSwitch");
        widgets->AdvancedSwapFixedSpin = yon_gtk_builder_get_widget(builder,"AdvancedSwapFixedSpin");
        widgets->AdvancedSwapRevealer = yon_gtk_builder_get_widget(builder,"AdvancedSwapRevealer");
        widgets->AdvancedLoadTypeRevealer = yon_gtk_builder_get_widget(builder,"AdvancedLoadTypeRevealer");
        widgets->advanced_partition_order = g_sequence_new(NULL);

        widgets->GrubInstallDevicesTree = yon_gtk_builder_get_widget(builder,"GrubInstallDevicesTree");
        widgets->GrubInstallPartitionTree = yon_gtk_builder_get_widget(builder,"GrubInstallPartitionTree");
        widgets->GrubInstallGpartedButton = yon_gtk_builder_get_widget(builder,"GrubInstallGpartedButton");
        widgets->GrubInstallUpdateGpartedButton = yon_gtk_builder_get_widget(builder,"GrubInstallUpdateGpartedButton");

        widgets->GrubUpdateDevicesTree = yon_gtk_builder_get_widget(builder,"GrubUpdateDevicesTree");
        widgets->GrubUpdatePartitionTree = yon_gtk_builder_get_widget(builder,"GrubUpdatePartitionTree");
        widgets->GrubUpdateGpartedButton = yon_gtk_builder_get_widget(builder,"GrubUpdateGpartedButton");
        widgets->GrubUpdateUpdateGpartedButton = yon_gtk_builder_get_widget(builder,"GrubUpdateUpdateGpartedButton");

        widgets->OSDevicesTree = yon_gtk_builder_get_widget(builder,"OSDevicesTree");
        widgets->OSSpinner = yon_gtk_builder_get_widget(builder,"OSSpinner");
        widgets->OSOverlay = yon_gtk_builder_get_widget(builder,"OSOverlay");
        widgets->OSSysSectionTree = yon_gtk_builder_get_widget(builder,"OSSysSectionTree");
        widgets->OSGpartedButton = yon_gtk_builder_get_widget(builder,"OSGpartedButton");
        widgets->OSUpdateGpartedButton = yon_gtk_builder_get_widget(builder,"OSUpdateGpartedButton");
        widgets->OSFormatSwitch = yon_gtk_builder_get_widget(builder,"OSFormatSwitch");
        widgets->OSRevealer = yon_gtk_builder_get_widget(builder,"OSRevealer");
        widgets->OSFormatSizeSpin = yon_gtk_builder_get_widget(builder,"OSFormatSizeSpin");
        widgets->OSFormatSizeCombo = yon_gtk_builder_get_widget(builder,"OSFormatSizeCombo");
        widgets->OSFormatPartitionEntry = yon_gtk_builder_get_widget(builder,"OSFormatPartitionEntry");
        widgets->OSFilesystemTypeCombo = yon_gtk_builder_get_widget(builder,"OSFilesystemTypeCombo");
        widgets->OSFormatFSMarkEntry = yon_gtk_builder_get_widget(builder,"OSFormatFSMarkEntry");
        widgets->OSFormatEncryptionCombo = yon_gtk_builder_get_widget(builder,"OSFormatEncryptionCombo");
        widgets->OSFormatEncryptionEntry = yon_gtk_builder_get_widget(builder,"OSFormatEncryptionEntry");
        widgets->OSFormatEncryptionButton = yon_gtk_builder_get_widget(builder,"OSFormatEncryptionButton");
        widgets->OSComponentsOverallSizeLabel = yon_gtk_builder_get_widget(builder,"OSComponentsOverallSizeLabel");
        widgets->OSSoftwareUncheckAllCheck = yon_gtk_builder_get_widget(builder,"OSSoftwareUncheckAllCheck");

        widgets->UserdataDevicesTree = yon_gtk_builder_get_widget(builder,"UserdataDevicesTree");
        widgets->UserdataSysSectionTree = yon_gtk_builder_get_widget(builder,"UserdataSysSectionTree");
        widgets->UserdataGpartedButton = yon_gtk_builder_get_widget(builder,"UserdataGpartedButton");
        widgets->UserdataUpdateGpartedButton = yon_gtk_builder_get_widget(builder,"UserdataUpdateGpartedButton");
        widgets->UserdataFormatSwitch = yon_gtk_builder_get_widget(builder,"UserdataFormatSwitch");
        widgets->UserdataRevealer = yon_gtk_builder_get_widget(builder,"UserdataRevealer");
        widgets->UserdataFormatSizeSpin = yon_gtk_builder_get_widget(builder,"UserdataFormatSizeSpin");
        widgets->UserdataFormatSizeCombo = yon_gtk_builder_get_widget(builder,"UserdataFormatSizeCombo");
        widgets->UserdataFormatPartitionEntry = yon_gtk_builder_get_widget(builder,"UserdataFormatPartitionEntry");
        widgets->UserdataFilesystemTypeCombo = yon_gtk_builder_get_widget(builder,"UserdataFilesystemTypeCombo");
        widgets->UserdataFormatFSMarkEntry = yon_gtk_builder_get_widget(builder,"UserdataFormatFSMarkEntry");
        widgets->UserdataFormatEncryptionCombo = yon_gtk_builder_get_widget(builder,"UserdataFormatEncryptionCombo");
        widgets->UserdataFormatEncryptionEntry = yon_gtk_builder_get_widget(builder,"UserdataFormatEncryptionEntry");
        widgets->UserdataFormatEncryptionButton = yon_gtk_builder_get_widget(builder,"UserdataFormatEncryptionButton");

        widgets->LanguagesFilter = GTK_TREE_MODEL(gtk_builder_get_object(builder,"LanguagesFilter"));
        widgets->LayoutsFilter = GTK_TREE_MODEL(gtk_builder_get_object(builder,"LayoutsFilter"));
        widgets->LayoutsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"LayoutsList"));
        widgets->LanguagesTree=yon_gtk_builder_get_widget(builder,"LanguagesTree");
        widgets->CountryLanguagesTree=yon_gtk_builder_get_widget(builder,"CountryLanguagesTree");
        widgets->InstallerCountryList=GTK_LIST_STORE(gtk_builder_get_object(builder,"InstallerCountryList"));
        widgets->InstallerCountryFilter=GTK_TREE_MODEL(gtk_builder_get_object(builder,"InstallerCountryFilter"));
        widgets->InstallerLanguageList=GTK_LIST_STORE(gtk_builder_get_object(builder,"InstallerLanguageList"));
        widgets->RegionMapBox=yon_gtk_builder_get_widget(builder,"RegionMapBox");
        widgets->RegionMapTarget=NULL;
        widgets->RegionCombo=yon_gtk_builder_get_widget(builder,"RegionCombo");
        widgets->ZoneCombo=yon_gtk_builder_get_widget(builder,"ZoneCombo");
        widgets->RegionSensitiveSwitch = yon_gtk_builder_get_widget(builder,"RegionSensitiveSwitch");
        widgets->RegionEntry = yon_gtk_builder_get_widget(builder,"RegionEntry");
        widgets->RegionTimezoneCompletionList = GTK_LIST_STORE(gtk_builder_get_object(builder,"RegionTimezoneCompletionList"));
        widgets->RegionTimezoneCompletionFilter = GTK_TREE_MODEL_FILTER(gtk_builder_get_object(builder,"RegionTimezoneCompletionFilter"));
        widgets->RegionMapOverlay = yon_gtk_builder_get_widget(builder,"RegionMapOverlay");
        widgets->TimeZoneMapOverlayBox = yon_gtk_builder_get_widget(builder,"TimeZoneMapOverlayBox");
        widgets->TimeZoneMapOverlayImage = yon_gtk_builder_get_widget(builder,"TimeZoneMapOverlayImage");
        widgets->TimeZoneMapOverlayTitleLabel = yon_gtk_builder_get_widget(builder,"TimeZoneMapOverlayTitleLabel");
        widgets->TimeZoneMapOverlayInfoLabel = yon_gtk_builder_get_widget(builder,"TimeZoneMapOverlayInfoLabel");

        widgets->UserRootNameEntry=yon_gtk_builder_get_widget(builder,"UserRootNameEntry");
        widgets->UserRootLoginEntry=yon_gtk_builder_get_widget(builder,"UserRootLoginEntry");
        widgets->UserRootPasswordCombo=yon_gtk_builder_get_widget(builder,"UserRootPasswordCombo");
        widgets->UserRootPasswordEntry=yon_gtk_builder_get_widget(builder,"UserRootPasswordEntry");
        widgets->UserRootPasswordButton=yon_gtk_builder_get_widget(builder,"UserRootPasswordButton");
        widgets->UserAutologinSwitch=yon_gtk_builder_get_widget(builder,"UserAutologinSwitch");
        widgets->UserAddBox=yon_gtk_builder_get_widget(builder,"UserAddBox");
        widgets->UserAddButton=yon_gtk_builder_get_widget(builder,"UserAddButton");

        widgets->LocaleTree = yon_gtk_builder_get_widget(builder,"LocaleTree");
        widgets->LocaleAddButton = yon_gtk_builder_get_widget(builder,"LocaleAddButton");
        widgets->LocaleRemoveButton = yon_gtk_builder_get_widget(builder,"LocaleRemoveButton");
        widgets->LocaleDefaultSwitch = yon_gtk_builder_get_widget(builder,"LocaleDefaultSwitch");
        widgets->LocaleCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"LocaleCell"));
        widgets->LanguageList = GTK_LIST_STORE(gtk_builder_get_object(builder,"LanguageList"));

        widgets->HotnameEntry=yon_gtk_builder_get_widget(builder,"HotnameEntry");
        widgets->mainSettingsButton=yon_gtk_builder_get_widget(builder,"mainSettingsButton");
        
        widgets->KeyboardModelCombo = yon_gtk_builder_get_widget(builder,"KeyboardModelCombo");
        widgets->KeyboardDefaultLayoutsSwitch = yon_gtk_builder_get_widget(builder,"KeyboardDefaultLayoutsSwitch");
        widgets->KeyboardLayoutTree = yon_gtk_builder_get_widget(builder,"KeyboardLayoutTree");
        widgets->KeyboardLayoutMoveUpButton = yon_gtk_builder_get_widget(builder,"KeyboardLayoutMoveUpButton");
        widgets->KeyboardLayoutMoveDownButton = yon_gtk_builder_get_widget(builder,"KeyboardLayoutMoveDownButton");
        widgets->KeyboardLayoutAddButton = yon_gtk_builder_get_widget(builder,"KeyboardLayoutAddButton");
        widgets->KeyboardLayoutRemoveButton = yon_gtk_builder_get_widget(builder,"KeyboardLayoutRemoveButton");
        widgets->KeyboardLayoutChangingCombo = yon_gtk_builder_get_widget(builder,"KeyboardLayoutChangingCombo");
        widgets->KeyboardComposeSwitch = yon_gtk_builder_get_widget(builder,"KeyboardComposeSwitch");
        widgets->KeyboardScrollLockSwitch = yon_gtk_builder_get_widget(builder,"KeyboardScrollLockSwitch");
        widgets->KeyboardNumLockCombo = yon_gtk_builder_get_widget(builder,"KeyboardNumLockCombo");

        widgets->AdditionalComponentsStatusImage = yon_gtk_builder_get_widget(builder,"AdditionalComponentsStatusImage");
        widgets->AdditionalComponentsStatusLabel = yon_gtk_builder_get_widget(builder,"AdditionalComponentsStatusLabel");
        widgets->AdditionalComponentsStatusButton = yon_gtk_builder_get_widget(builder,"AdditionalComponentsStatusButton");
        widgets->AdditionalComponentsList = yon_gtk_builder_get_widget(builder,"AdditionalComponentsList");
        widgets->AdditionalComponentsOverallSizeLabel = yon_gtk_builder_get_widget(builder,"AdditionalComponentsOverallSizeLabel");
        widgets->AdditionalComponentsUncheckAllCheck = yon_gtk_builder_get_widget(builder,"AdditionalComponentsUncheckAllCheck");

        widgets->InstallationProgress = yon_gtk_builder_get_widget(builder,"InstallationProgress");
        widgets->InstallationLabel = yon_gtk_builder_get_widget(builder,"InstallationLabel");
        widgets->ReadShortLogButton = yon_gtk_builder_get_widget(builder,"ReadShortLogButton");
        widgets->PackageInstallationProgress = yon_gtk_builder_get_widget(builder,"PackageInstallationProgress");
        widgets->PackageInstallationLabel = yon_gtk_builder_get_widget(builder,"PackageInstallationLabel");
        widgets->ReadFullLogButton = yon_gtk_builder_get_widget(builder,"ReadFullLogButton");

        widgets->KernelPacmanStatusImage = yon_gtk_builder_get_widget(builder,"KernelPacmanStatusImage");
        widgets->KernelPacmanStatusLabel = yon_gtk_builder_get_widget(builder,"KernelPacmanStatusLabel");
        widgets->KernelPacmanStatusButton = yon_gtk_builder_get_widget(builder,"KernelPacmanStatusButton");
        widgets->KernelListBox = yon_gtk_builder_get_widget(builder,"KernelListBox");
        widgets->KernelInstallLabel = yon_gtk_builder_get_widget(builder,"KernelInstallLabel");
        widgets->KernelEnableLabel = yon_gtk_builder_get_widget(builder,"KernelEnableLabel");
        widgets->KernelNameLabel = yon_gtk_builder_get_widget(builder,"KernelNameLabel");
        widgets->KernelTagsLabel = yon_gtk_builder_get_widget(builder,"KernelTagsLabel");
        widgets->KernelModulesLabel = yon_gtk_builder_get_widget(builder,"KernelModulesLabel");
        widgets->KernelDescriptionLabel = yon_gtk_builder_get_widget(builder,"KernelDescriptionLabel");
        widgets->KernelSizeGroup = GTK_SIZE_GROUP(gtk_builder_get_object(builder,"TagsSizeGroup"));

        widgets->KernelAddonPacmanStatusImage = yon_gtk_builder_get_widget(builder,"KernelAddonPacmanStatusImage");
        widgets->KernelAddonPacmanStatusLabel = yon_gtk_builder_get_widget(builder,"KernelAddonPacmanStatusLabel");
        widgets->KernelAddonPacmanStatusButton = yon_gtk_builder_get_widget(builder,"KernelAddonPacmanStatusButton");
        widgets->KernelAddonListBox = yon_gtk_builder_get_widget(builder,"KernelAddonListBox");
        widgets->KernelAddonInstallLabel = yon_gtk_builder_get_widget(builder,"KernelAddonInstallLabel");
        widgets->KernelAddonNameLabel = yon_gtk_builder_get_widget(builder,"KernelAddonNameLabel");
        widgets->KernelAddonModulesLabel = yon_gtk_builder_get_widget(builder,"KernelAddonModulesLabel");
        widgets->KernelAddonDescriptionLabel = yon_gtk_builder_get_widget(builder,"KernelAddonDescriptionLabel");

        widgets->OSSoftwareListBox = yon_gtk_builder_get_widget(builder,"OSSoftwareListBox");
        widgets->OSSoftwareInstallLabel = yon_gtk_builder_get_widget(builder,"OSSoftwareInstallLabel");
        widgets->OSSoftwareNameLabel = yon_gtk_builder_get_widget(builder,"OSSoftwareNameLabel");
        widgets->OSSoftwareTagsLabel = yon_gtk_builder_get_widget(builder,"OSSoftwareTagsLabel");
        widgets->OSSoftwareDescriptionLabel = yon_gtk_builder_get_widget(builder,"OSSoftwareDescriptionLabel");
        widgets->OSSoftwareEmptyLabel = yon_gtk_builder_get_widget(builder,"OSSoftwareEmptyLabel");

        widgets->PacmanSoftwareSearchEntry = yon_gtk_builder_get_widget(builder,"PacmanSoftwareSearchEntry");
        widgets->PacmanSoftwareStatusImage = yon_gtk_builder_get_widget(builder,"PacmanSoftwareStatusImage");
        widgets->PacmanSoftwareStatusLabel = yon_gtk_builder_get_widget(builder,"PacmanSoftwareStatusLabel");
        widgets->PacmanSoftwareStatusButton = yon_gtk_builder_get_widget(builder,"PacmanSoftwareStatusButton");

        widgets->PacmanLoadingOverlay = yon_gtk_builder_get_widget(builder,"PacmanLoadingOverlay");
        widgets->PacmanSoftwareAllPackagesTree = yon_gtk_builder_get_widget(builder,"PacmanSoftwareAllPackagesTree");
        widgets->PacmanOverallSizeLabel = yon_gtk_builder_get_widget(builder,"PacmanOverallSizeLabel");
        widgets->PacmanChosenLabel = yon_gtk_builder_get_widget(builder,"PacmanChosenLabel");
        widgets->PacmanSoftwareAllList = GTK_LIST_STORE(gtk_builder_get_object(builder,"PacmanSoftwareAllList"));
        widgets->PacmanSoftwareAllCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"PacmanSoftwareAllCell"));
        widgets->PacmanAllInfoImageCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"PacmanAllInfoImageCell"));

        widgets->PacmanSoftwareChosenPackagesTree = yon_gtk_builder_get_widget(builder,"PacmanSoftwareChosenPackagesTree");
        widgets->PacmanSoftwareChosenList = GTK_LIST_STORE(gtk_builder_get_object(builder,"PacmanSoftwareChosenList"));
        widgets->PacmanSoftwareChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"PacmanSoftwareChosenCell"));
        widgets->PacmanChosenInfoImageCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"PacmanChosenInfoImageCell"));

        widgets->StartupServicesTree = yon_gtk_builder_get_widget(builder,"StartupServicesTree");
        widgets->StartupServicesAddButton = yon_gtk_builder_get_widget(builder,"StartupServicesAddButton");
        widgets->StartupServicesEditButton = yon_gtk_builder_get_widget(builder,"StartupServicesEditButton");
        widgets->StartupServicesRemoveButton = yon_gtk_builder_get_widget(builder,"StartupServicesRemoveButton");
        widgets->StartupChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"StartupChosenCell"));
        widgets->StartupList = GTK_LIST_STORE(gtk_builder_get_object(builder,"StartupList"));

        widgets->StartupAppsTree = yon_gtk_builder_get_widget(builder,"StartupAppsTree");
        widgets->StartupAppsAddButton = yon_gtk_builder_get_widget(builder,"StartupAppsAddButton");
        widgets->StartupAppsEditButton = yon_gtk_builder_get_widget(builder,"StartupAppsEditButton");
        widgets->StartupAppsRemoveButton = yon_gtk_builder_get_widget(builder,"StartupAppsRemoveButton");
        widgets->StartupAppsChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"StartupAppsChosenCell"));
        widgets->StartupAppsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"StartupAppsList"));
        
        widgets->BootloadTimerSwitch = yon_gtk_builder_get_widget(builder,"BootloadTimerSwitch");
        widgets->BootloadTimerSpin = yon_gtk_builder_get_widget(builder,"BootloadTimerSpin");
        widgets->BootloadDefaultOSEntry = yon_gtk_builder_get_widget(builder,"BootloadDefaultOSEntry");
        widgets->BootloadDefaulOSButton = yon_gtk_builder_get_widget(builder,"BootloadDefaulOSButton");
        widgets->BootloadUserTree = yon_gtk_builder_get_widget(builder,"BootloadUserTree");
        widgets->BootloadUserAddButton = yon_gtk_builder_get_widget(builder,"BootloadUserAddButton");
        widgets->BootloadUserEditButton = yon_gtk_builder_get_widget(builder,"BootloadUserEditButton");
        widgets->BootloadAdminCheckCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"BootloadAdminCheckCell"));
        widgets->BootloadUserRemoveButton = yon_gtk_builder_get_widget(builder,"BootloadUserRemoveButton");
        widgets->BootloadNoPasswordSwitch = yon_gtk_builder_get_widget(builder,"BootloadNoPasswordSwitch");
        widgets->BootloadUsersList = GTK_LIST_STORE(gtk_builder_get_object(builder,"BootloadUsersList"));

        widgets->NetworkDomainSwitch = yon_gtk_builder_get_widget(builder,"NetworkDomainSwitch");
        widgets->NetworkDomainNameEntry = yon_gtk_builder_get_widget(builder,"NetworkDomainNameEntry");
        widgets->NetworkDomainAdminEntry = yon_gtk_builder_get_widget(builder,"NetworkDomainAdminEntry");
        widgets->NetworkDomainPasswordEntry = yon_gtk_builder_get_widget(builder,"NetworkDomainPasswordEntry");
        widgets->NetworkNTPServerSwitch = yon_gtk_builder_get_widget(builder,"NetworkNTPServerSwitch");
        widgets->NetworkNTPCombo = yon_gtk_builder_get_widget(builder,"NetworkNTPCombo");
        widgets->NetworkNTPEntry = yon_gtk_builder_get_widget(builder,"NetworkNTPEntry");
        widgets->NetworkConnectionsBox = yon_gtk_builder_get_widget(builder,"NetworkConnectionsBox");
        widgets->NetworkConnectionsAddButton = yon_gtk_builder_get_widget(builder,"NetworkConnectionsAddButton");
        widgets->HostnameSensitiveSwitch = yon_gtk_builder_get_widget(builder,"HostnameSensitiveSwitch");
        widgets->AutoHostnameCheck=yon_gtk_builder_get_widget(builder,"AutoHostnameCheck");
        widgets->AdvancedVirtualDeviceLabel = yon_gtk_builder_get_widget(builder,"AdvancedVirtualDeviceLabel");

        widgets->PackagesStatusImage = yon_gtk_builder_get_widget(builder,"PackagesStatusImage");
        widgets->PackagesStatusLabel = yon_gtk_builder_get_widget(builder,"PackagesStatusLabel");
        widgets->PackagesStatusButton = yon_gtk_builder_get_widget(builder,"PackagesStatusButton");
        widgets->PackagesTree = yon_gtk_builder_get_widget(builder,"PackagesTree");
        widgets->PackagesChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"PackagesChosenCell"));
        widgets->PackagesList = GTK_TREE_STORE(gtk_builder_get_object(builder,"Packages"));
        widgets->PackagesInfoIconCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"PackagesInfoIconCell"));

        widgets->ConfigHubRebootCombo = yon_gtk_builder_get_widget(builder,"ConfigHubRebootCombo");
        widgets->HubPersonalListBox = yon_gtk_builder_get_widget(builder,"HubPersonalListBox");
        widgets->HubSystemListBox = yon_gtk_builder_get_widget(builder,"HubSystemListBox");
        widgets->HubPackagesListBox = yon_gtk_builder_get_widget(builder,"HubPackagesListBox");

        widgets->ScrollLeftEventBox = yon_gtk_builder_get_widget(builder,"ScrollLeftEventBox");
        widgets->ScrollRightEventBox = yon_gtk_builder_get_widget(builder,"ScrollRightEventBox");
        widgets->SliderProgressBox = yon_gtk_builder_get_widget(builder,"SliderProgressBox");
        widgets->InstallationSliderArrowsOverlay = yon_gtk_builder_get_widget(builder,"InstallationSliderArrowsOverlay");
        widgets->NextInstallationSliderImage = yon_gtk_builder_get_widget(builder,"NextInstallationSliderImage");
        widgets->PrevInstallationSliderImage = yon_gtk_builder_get_widget(builder,"PrevInstallationSliderImage");


        widgets->network_connections = NULL;
        widgets->pacmanchosen = g_hash_table_new_full(g_str_hash,g_str_equal,free,NULL);

        main_config.status_box = widgets->StatusBox;

        GError *err = NULL;
        GFile *file_desc = g_file_new_for_path(pacman_lock_dir_path);
        widgets->db_lock_monitor = g_file_monitor_directory(file_desc,G_FILE_MONITOR_NONE,NULL,&err);
        if (err){
            printf("%s\n",err->message);
        }
        g_signal_connect(G_OBJECT(widgets->db_lock_monitor),"changed",G_CALLBACK(yon_db_lock_update),widgets);
        g_signal_connect(G_OBJECT(widgets->db_lock_monitor),"changed",G_CALLBACK(yon_db_unlock_update),widgets);
    }

    g_signal_connect(G_OBJECT(widgets->MainWindow),"delete-event",G_CALLBACK(on_yon_exit),widgets);
    GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2");

    g_object_set_data(G_OBJECT(widgets->DocumentationMenuItem),"original_label",yon_char_new(DOCUMENTATION_LABEL));
    g_object_set_data(G_OBJECT(widgets->AboutMenuItem),"original_label",yon_char_new(ABOUT_LABEL));
    gtk_style_context_add_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemmiddle");
    gtk_style_context_remove_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemtop");
    gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->DocumentationMenuItem);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->AboutMenuItem);
    
    {
        g_signal_connect(G_OBJECT(widgets->LicenseAgreeRadio),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->NextButton);

        g_signal_connect(G_OBJECT(widgets->LoadLocalConfigurationMenuItem),"activate",G_CALLBACK(on_config_local_load),widgets);
        g_signal_connect(G_OBJECT(widgets->LoadExternalConfigurationMenuItem),"activate",G_CALLBACK(on_config_custom_load),widgets);

        g_signal_connect(G_OBJECT(widgets->PackagesStatusButton),"clicked",G_CALLBACK(on_status_button_update),widgets);
        g_signal_connect(G_OBJECT(widgets->AdditionalComponentsStatusButton),"clicked",G_CALLBACK(on_status_button_update),widgets);
        g_signal_connect(G_OBJECT(widgets->KernelPacmanStatusButton),"clicked",G_CALLBACK(on_status_button_update),widgets);
        g_signal_connect(G_OBJECT(widgets->KernelAddonPacmanStatusButton),"clicked",G_CALLBACK(on_status_button_update),widgets);
        g_signal_connect(G_OBJECT(widgets->PackagesTree),"button-press-event",G_CALLBACK(on_software_info_event),widgets);
        g_signal_connect(G_OBJECT(widgets->PacmanSoftwareAllPackagesTree),"button-press-event",G_CALLBACK(on_pacman_info),widgets);
        g_signal_connect(G_OBJECT(widgets->PacmanSoftwareChosenPackagesTree),"button-press-event",G_CALLBACK(on_pacman_info),widgets);
        g_signal_connect(G_OBJECT(widgets->PacmanSoftwareStatusButton),"clicked",G_CALLBACK(on_status_button_update),widgets);
        g_signal_connect(G_OBJECT(widgets->ReadFullLogButton),"clicked",G_CALLBACK(on_process_log_view),widgets);
        g_signal_connect(G_OBJECT(widgets->ReadShortLogButton),"clicked",G_CALLBACK(on_summary_log_view),widgets);

        g_signal_connect(G_OBJECT(widgets->CommonGpartedButton),"clicked",G_CALLBACK(on_gparted_open),NULL);
        g_signal_connect(G_OBJECT(widgets->SameGpartedButton),"clicked",G_CALLBACK(on_gparted_open),NULL);
        g_signal_connect(G_OBJECT(widgets->NextInstallationGPartedButton),"clicked",G_CALLBACK(on_gparted_open),NULL);
        g_signal_connect(G_OBJECT(widgets->UserdataGpartedButton),"clicked",G_CALLBACK(on_gparted_open),NULL);
        g_signal_connect(G_OBJECT(widgets->GrubUpdateGpartedButton),"clicked",G_CALLBACK(on_gparted_open),NULL);
        g_signal_connect(G_OBJECT(widgets->GrubInstallGpartedButton),"clicked",G_CALLBACK(on_gparted_open),NULL);
        g_signal_connect(G_OBJECT(widgets->AdvancedGpartedButton),"clicked",G_CALLBACK(on_gparted_open),NULL);

        g_signal_connect(G_OBJECT(widgets->CommonUpdateGpartedButton),"clicked",G_CALLBACK(on_gparted_update),widgets);
        g_signal_connect(G_OBJECT(widgets->SameUpdateGpartedButton),"clicked",G_CALLBACK(on_gparted_update),widgets);
        g_signal_connect(G_OBJECT(widgets->NextInstallationUpdateGPartedButton),"clicked",G_CALLBACK(on_gparted_update),widgets);
        g_signal_connect(G_OBJECT(widgets->UserdataUpdateGpartedButton),"clicked",G_CALLBACK(on_gparted_update),widgets);
        g_signal_connect(G_OBJECT(widgets->GrubUpdateUpdateGpartedButton),"clicked",G_CALLBACK(on_gparted_update),widgets);
        g_signal_connect(G_OBJECT(widgets->GrubInstallUpdateGpartedButton),"clicked",G_CALLBACK(on_gparted_update),widgets);
        g_signal_connect(G_OBJECT(widgets->AdvancedUpdateGpartedButton),"clicked",G_CALLBACK(on_gparted_update),widgets);

        g_signal_connect(G_OBJECT(widgets->NextButton),"clicked",G_CALLBACK(on_page_next_clicked),widgets);
        g_signal_connect(G_OBJECT(widgets->BackButton),"clicked",G_CALLBACK(on_page_prev_clicked),widgets);

        g_signal_connect(G_OBJECT(widgets->LocaleAddButton),"clicked",G_CALLBACK(on_language_open),widgets);
        g_signal_connect(G_OBJECT(widgets->LocaleRemoveButton),"clicked",G_CALLBACK(on_language_remove),widgets);
        g_signal_connect(G_OBJECT(widgets->LocaleDefaultSwitch),"state-set",G_CALLBACK(on_language_default_toggled),widgets);
        g_signal_connect(G_OBJECT(widgets->LocaleCell),"toggled",G_CALLBACK(on_locale_toggled),widgets);
        g_signal_connect(G_OBJECT(widgets->LocaleTree),"cursor-changed",G_CALLBACK(on_locale_selected),widgets);

        g_signal_connect(G_OBJECT(widgets->CancelInstallButton),"clicked",G_CALLBACK(on_page_cancel_clicked),widgets);
        g_signal_connect(G_OBJECT(widgets->RegionCombo),"changed",G_CALLBACK(on_region_changed),widgets);
        #ifdef TIMEZONEMAP_INCLUDE
        g_signal_connect(G_OBJECT(widgets->ZoneCombo),"changed",G_CALLBACK(on_zone_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->TimeZoneMapOverlayBox),"enter-notify-event",G_CALLBACK(on_time_zone_status_hover),widgets);
        g_signal_connect(G_OBJECT(widgets->TimeZoneMapOverlayBox),"leave-notify-event",G_CALLBACK(on_time_zone_status_hover_end),widgets);
        #endif
        g_signal_connect(G_OBJECT(widgets->RegionEntry),"changed",G_CALLBACK(on_region_entry_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->RegionSensitiveSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->RegionCombo);
        g_signal_connect(G_OBJECT(widgets->RegionSensitiveSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->ZoneCombo);
        g_signal_connect(G_OBJECT(widgets->RegionSensitiveSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->RegionMapBox);
        g_signal_connect(G_OBJECT(widgets->RegionSensitiveSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->RegionEntry);
        g_signal_connect(G_OBJECT(widgets->RegionMapBox),"button-press-event",G_CALLBACK(on_map_box_ckicked_skip),NULL);

        g_signal_connect(G_OBJECT(widgets->KeyboardLayoutTree),"cursor-changed",G_CALLBACK(on_layout_selection_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->KeyboardDefaultLayoutsSwitch),"state-set",G_CALLBACK(on_layout_default_toggled),widgets);
        g_signal_connect(G_OBJECT(widgets->KeyboardDefaultLayoutsSwitch),"state-set",G_CALLBACK(on_layout_default_sensitive_toggled),widgets);
        g_signal_connect(G_OBJECT(widgets->KeyboardLayoutMoveUpButton),"clicked",G_CALLBACK(on_layout_move_up),widgets);
        g_signal_connect(G_OBJECT(widgets->KeyboardLayoutMoveDownButton),"clicked",G_CALLBACK(on_layout_move_down),widgets);
        g_signal_connect(G_OBJECT(widgets->KeyboardLayoutAddButton),"clicked",G_CALLBACK(on_system_layouts_add),widgets);
        g_signal_connect(G_OBJECT(widgets->KeyboardLayoutRemoveButton),"clicked",G_CALLBACK(on_system_layouts_remove),widgets);
        g_signal_connect(G_OBJECT(widgets->KeyboardModelCombo),"changed",G_CALLBACK(on_model_changed),widgets);

        g_signal_connect(G_OBJECT(widgets->GrubInstallDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->GrubUpdateDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->NextInstallationSysDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->SamePlaceDeviceTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->UserdataDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets);

        g_signal_connect(G_OBJECT(widgets->OSSoftwareUncheckAllCheck),"toggled",G_CALLBACK(on_os_components_switch_all),widgets);
        g_signal_connect(G_OBJECT(widgets->AdditionalComponentsUncheckAllCheck),"toggled",G_CALLBACK(on_software_switch_all),widgets);
        g_signal_connect(G_OBJECT(widgets->NextInstallationSizeSpin),"value-changed",G_CALLBACK(yon_size_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->UserdataFormatSizeSpin),"value-changed",G_CALLBACK(yon_size_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->OSFormatSizeSpin),"value-changed",G_CALLBACK(yon_size_changed),widgets);

        g_signal_connect(G_OBJECT(widgets->UserRootPasswordCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),widgets->UserRootPasswordEntry);
        g_signal_connect(G_OBJECT(widgets->UserRootPasswordCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),widgets->UserRootPasswordButton);
        g_signal_connect(G_OBJECT(widgets->UserAddButton),"clicked",G_CALLBACK(on_user_add),widgets);
        g_signal_connect(G_OBJECT(widgets->UserRootPasswordButton),"clicked",G_CALLBACK(yon_password_root_new),widgets);
        g_signal_connect(G_OBJECT(widgets->BootloadDefaulOSButton),"clicked",G_CALLBACK(yon_menu_window_open),widgets);

        g_signal_connect(G_OBJECT(widgets->LanguagesTree),"cursor-changed",G_CALLBACK(on_locale_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->CountryLanguagesTree),"row-activated",G_CALLBACK(on_installer_language_changed),widgets);
        
        g_signal_connect(G_OBJECT(widgets->StartupServicesTree),"cursor-changed",G_CALLBACK(on_startup_services_selection_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->StartupServicesAddButton),"clicked",G_CALLBACK(on_startup_service_add),widgets);
        g_signal_connect(G_OBJECT(widgets->StartupServicesEditButton),"clicked",G_CALLBACK(on_startup_service_edit),widgets);
        g_signal_connect(G_OBJECT(widgets->StartupServicesRemoveButton),"clicked",G_CALLBACK(on_startup_services_remove),widgets);
        g_signal_connect(G_OBJECT(widgets->StartupChosenCell),"toggled",G_CALLBACK(on_srartup_services_toggled),widgets);
        
        g_signal_connect(G_OBJECT(widgets->StartupAppsTree),"cursor-changed",G_CALLBACK(on_startup_apps_selection_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->StartupAppsAddButton),"clicked",G_CALLBACK(on_startup_app_add),widgets);
        g_signal_connect(G_OBJECT(widgets->StartupAppsEditButton),"clicked",G_CALLBACK(on_startup_app_edit),widgets);
        g_signal_connect(G_OBJECT(widgets->StartupAppsRemoveButton),"clicked",G_CALLBACK(on_startup_apps_remove),widgets);
        g_signal_connect(G_OBJECT(widgets->StartupAppsChosenCell),"toggled",G_CALLBACK(on_srartup_services_toggled),widgets);
        
        g_signal_connect(G_OBJECT(widgets->AutoHostnameCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),widgets->HotnameEntry);

        yon_gtk_revealer_set_from_switch(GTK_REVEALER(widgets->NextInstallationFormatRevealer),GTK_SWITCH(widgets->NextInstallationFormatSwitch));
        yon_gtk_revealer_set_from_switch(GTK_REVEALER(widgets->SameInstallationFormatRevealer),GTK_SWITCH(widgets->SameInstallationFormatSwitch));
        yon_gtk_revealer_set_from_switch(GTK_REVEALER(widgets->UserdataRevealer),GTK_SWITCH(widgets->UserdataFormatSwitch));
        
        g_signal_connect(G_OBJECT(widgets->OSGpartedButton),"clicked",G_CALLBACK(on_gparted_open),NULL);
        g_signal_connect(G_OBJECT(widgets->OSUpdateGpartedButton),"clicked",G_CALLBACK(on_gparted_update),widgets);
        g_signal_connect(G_OBJECT(widgets->OSDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->OSFormatEncryptionCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),widgets->OSFormatEncryptionEntry);
        g_signal_connect(G_OBJECT(widgets->OSFormatEncryptionCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),widgets->OSFormatEncryptionButton);
        g_signal_connect(G_OBJECT(widgets->OSFormatEncryptionButton),"clicked",G_CALLBACK(yon_os_password_open),widgets);
        yon_gtk_revealer_set_from_switch(GTK_REVEALER(widgets->OSRevealer),GTK_SWITCH(widgets->OSFormatSwitch));

        g_signal_connect(G_OBJECT(widgets->UserAutologinSwitch),"state-set",G_CALLBACK(on_user_autoloin_switch),widgets);

        g_signal_connect(G_OBJECT(widgets->UserdataFormatEncryptionCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),widgets->UserdataFormatEncryptionButton);
        g_signal_connect(G_OBJECT(widgets->UserdataFormatEncryptionButton),"clicked",G_CALLBACK(yon_userdata_password_open),widgets);

        g_signal_connect(G_OBJECT(widgets->PacmanSoftwareAllCell),"toggled",G_CALLBACK(on_pacman_software_all_toggled),widgets);
        g_signal_connect(G_OBJECT(widgets->PacmanSoftwareChosenCell),"toggled",G_CALLBACK(on_pacman_software_chosen_toggled),widgets);
        g_signal_connect(G_OBJECT(widgets->PacmanSoftwareSearchEntry),"icon-press",G_CALLBACK(on_pacman_icon_press),widgets);
        g_signal_connect(G_OBJECT(widgets->PacmanSoftwareSearchEntry),"activate",G_CALLBACK(on_pacman_search_enter),widgets);
        g_signal_connect(G_OBJECT(widgets->BootloadUserAddButton),"clicked",G_CALLBACK(on_bootloader_user_add),widgets);
        g_signal_connect(G_OBJECT(widgets->BootloadUserEditButton),"clicked",G_CALLBACK(on_bootloader_user_edit),widgets);
        g_signal_connect(G_OBJECT(widgets->BootloadAdminCheckCell),"toggled",G_CALLBACK(on_bootloader_admin_toggled),widgets);
        g_signal_connect(G_OBJECT(widgets->BootloadUserRemoveButton),"clicked",G_CALLBACK(on_bootloader_user_remove),widgets);
        g_signal_connect(G_OBJECT(widgets->BootloadUserTree),"cursor-changed",G_CALLBACK(on_bootloader_selected),widgets);
        g_signal_connect(G_OBJECT(widgets->BootloadNoPasswordSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),gtk_widget_get_parent(gtk_widget_get_parent(widgets->BootloadUserAddButton)));

        g_signal_connect(G_OBJECT(widgets->BootloadTimerSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->BootloadTimerSpin);

        g_signal_connect(G_OBJECT(widgets->NetworkDomainSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->NetworkDomainNameEntry);
        g_signal_connect(G_OBJECT(widgets->NetworkDomainSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->NetworkDomainAdminEntry);
        g_signal_connect(G_OBJECT(widgets->NetworkDomainSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->NetworkDomainPasswordEntry);
        g_signal_connect(G_OBJECT(widgets->NetworkNTPServerSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->NetworkNTPCombo);
        g_signal_connect(G_OBJECT(widgets->NetworkNTPServerSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->NetworkNTPEntry);
        g_signal_connect(G_OBJECT(widgets->HostnameSensitiveSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->HotnameEntry);
        g_signal_connect(G_OBJECT(widgets->HostnameSensitiveSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->AutoHostnameCheck);
        g_signal_connect(G_OBJECT(widgets->HostnameSensitiveSwitch),"state-set",G_CALLBACK(on_autohostname_sensitiveness_check),widgets);
        g_signal_connect(G_OBJECT(widgets->AutoHostnameCheck),"toggled",G_CALLBACK(on_autohostname_check),widgets);
        g_signal_connect(G_OBJECT(widgets->HotnameEntry),"changed",G_CALLBACK(on_hostname_entry_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->NetworkConnectionsAddButton),"clicked",G_CALLBACK(on_connection_add),widgets);
        g_signal_connect(G_OBJECT(widgets->NetworkNTPCombo),"changed",G_CALLBACK(on_ntp_sync),widgets);
        yon_gtk_revealer_set_from_switch(GTK_REVEALER(widgets->AdvancedLoadTypeRevealer),GTK_SWITCH(widgets->AdvancedLoadTypeSwitch));
        yon_gtk_revealer_set_from_switch(GTK_REVEALER(widgets->AdvancedSwapRevealer),GTK_SWITCH(widgets->AdvancedSwapSwitch));

        g_signal_connect(G_OBJECT(widgets->AdvancedSwapFixedSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->AdvancedSwapFixedSpin);
        g_signal_connect(G_OBJECT(widgets->AdvancedSwapFixedSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch),widgets->AdvancedSwapFixedSizeSwitch);

        g_signal_connect(G_OBJECT(widgets->AdvancedPartitionAddBox),"add",G_CALLBACK(on_advanced_part_content_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->AdvancedPartitionAddBox),"remove",G_CALLBACK(on_advanced_part_content_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->AdvancedDeviceChosenCell),"toggled",G_CALLBACK(on_install_advanced_device_chosen),widgets);
        g_signal_connect(G_OBJECT(widgets->StartScenarioButton),"clicked",G_CALLBACK(yon_quick_install),widgets);
        g_signal_connect(G_OBJECT(widgets->SourceButton),"clicked",G_CALLBACK(on_source_clicked),widgets);
        g_signal_connect(G_OBJECT(widgets->AdvancedAddButton),"clicked",G_CALLBACK(on_advanced_part_create),widgets);
        g_signal_connect(G_OBJECT(widgets->AdvancedPartChosenCell),"toggled",G_CALLBACK(on_install_advanced_partition_chosen),widgets);
        g_signal_connect(G_OBJECT(widgets->AdvancedVirtualDeviceCombo),"changed",G_CALLBACK(on_advanced_virtual_device_changed),widgets);
        g_signal_connect(G_OBJECT(widgets->PackagesTree),"cursor-changed",G_CALLBACK(yon_on_packages_selected),widgets);
        g_signal_connect(G_OBJECT(widgets->PackagesTree),"row-activated",G_CALLBACK(yon_on_packages_activated),widgets);
        g_signal_connect(G_OBJECT(widgets->PackagesChosenCell),"toggled",G_CALLBACK(yon_on_packages_chosen),widgets);

        g_signal_connect(G_OBJECT(widgets->HubPersonalListBox),"child-activated",G_CALLBACK(on_configuration_hub_open),widgets);
        g_signal_connect(G_OBJECT(widgets->HubSystemListBox),"child-activated",G_CALLBACK(on_configuration_hub_open),widgets);
        g_signal_connect(G_OBJECT(widgets->HubPackagesListBox),"child-activated",G_CALLBACK(on_configuration_hub_open),widgets);
        g_signal_connect(G_OBJECT(widgets->HubPersonalListBox),"selected-children-changed",G_CALLBACK(on_configuration_hub_selected),widgets);
        g_signal_connect(G_OBJECT(widgets->HubSystemListBox),"selected-children-changed",G_CALLBACK(on_configuration_hub_selected),widgets);
        g_signal_connect(G_OBJECT(widgets->HubPackagesListBox),"selected-children-changed",G_CALLBACK(on_configuration_hub_selected),widgets);

        g_signal_connect(G_OBJECT(widgets->ScrollLeftEventBox),"button-release-event",G_CALLBACK(on_install_slider_prev),widgets);
        g_signal_connect(G_OBJECT(widgets->ScrollRightEventBox),"button-release-event",G_CALLBACK(on_install_slider_next),widgets);
        g_signal_connect(G_OBJECT(widgets->ScrollLeftEventBox),"enter-notify-event",G_CALLBACK(on_install_slider_hover_highlight),widgets);
        g_signal_connect(G_OBJECT(widgets->ScrollRightEventBox),"enter-notify-event",G_CALLBACK(on_install_slider_hover_highlight),widgets);
        g_signal_connect(G_OBJECT(widgets->ScrollLeftEventBox),"leave-notify-event",G_CALLBACK(on_install_slider_hover_highlight_end),widgets);
        g_signal_connect(G_OBJECT(widgets->ScrollRightEventBox),"leave-notify-event",G_CALLBACK(on_install_slider_hover_highlight_end),widgets);

        g_signal_connect(G_OBJECT(widgets->AboutMenuItem),"activate",G_CALLBACK(yon_on_about),NULL);
        g_signal_connect(G_OBJECT(widgets->DocumentationMenuItem),"activate",G_CALLBACK(on_open_documentation_confirmation),WIKI_LINK);
    }
    
    yon_gtk_entry_set_password_visibility_icon(GTK_ENTRY(widgets->NetworkDomainPasswordEntry));
    yon_gtk_entry_set_password_visibility_icon(GTK_ENTRY(widgets->UserRootPasswordEntry));

    yon_window_config_setup(GTK_WINDOW(widgets->MainWindow));

    int fullscreen = 0;
    char *path = yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL);
    if (access(path,F_OK)){
        fullscreen = 1;
        g_thread_new("fullscreen",(GThreadFunc)yon_maximize,widgets);

    }
    gtk_widget_show(widgets->MainWindow);
    yon_window_config_load(path);
    yon_window_config_add_instant_parameter("fullscreen","window",&fullscreen,YON_TYPE_BOOLEAN);
    {
        widgets->debug_button = yon_debug_button_new();
        GtkWidget *Label = g_object_get_data(G_OBJECT(widgets->debug_button),"Label");
        yon_installer_widget_set_translation(Label);
        gtk_style_context_add_class(gtk_widget_get_style_context(widgets->debug_button),"menuitemmiddle");
        gtk_style_context_remove_class(gtk_widget_get_style_context(widgets->debug_button),"menuitemtop");
        gtk_menu_shell_prepend(GTK_MENU_SHELL(gtk_widget_get_parent(widgets->AboutMenuItem)),widgets->debug_button);
        
    }
    {
        widgets->EnableRDPMenuItem = gtk_menu_item_new();
        GtkWidget *Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
        GtkWidget *Label = gtk_label_new(ENABLE_RDP_LABEL);
        GtkWidget *Check = gtk_check_button_new();
        yon_installer_widget_set_translation(Label);
        g_object_set_data(G_OBJECT(widgets->EnableRDPMenuItem),"Label",Label);
        gtk_box_pack_start(GTK_BOX(Box),Check,0,0,0);
        gtk_box_pack_start(GTK_BOX(Box),Label,0,0,0);
        gtk_container_add(GTK_CONTAINER(widgets->EnableRDPMenuItem),Box);
        g_signal_connect(G_OBJECT(widgets->EnableRDPMenuItem),"activate",G_CALLBACK(on_rdp_toggled),widgets);
        gtk_style_context_add_class(gtk_widget_get_style_context(widgets->EnableRDPMenuItem),"menuitemmiddle");
        gtk_widget_show_all(widgets->EnableRDPMenuItem);
        gtk_menu_shell_prepend(GTK_MENU_SHELL(widgets->menu2),widgets->EnableRDPMenuItem);
    }
    {
        widgets->EnableVNCMenuItem = gtk_menu_item_new();
        GtkWidget *Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
        GtkWidget *Label = gtk_label_new(ENABLE_VNC_LABEL);
        GtkWidget *Check = gtk_check_button_new();
        yon_installer_widget_set_translation(Label);
        g_object_set_data(G_OBJECT(widgets->EnableVNCMenuItem),"Label",Label);
        gtk_box_pack_start(GTK_BOX(Box),Check,0,0,0);
        gtk_box_pack_start(GTK_BOX(Box),Label,0,0,0);
        gtk_container_add(GTK_CONTAINER(widgets->EnableVNCMenuItem),Box);
        g_signal_connect(G_OBJECT(widgets->EnableVNCMenuItem),"activate",G_CALLBACK(on_vnc_toggled),widgets);
        gtk_style_context_add_class(gtk_widget_get_style_context(widgets->EnableVNCMenuItem),"menuitemmiddle");
        gtk_widget_show_all(widgets->EnableVNCMenuItem);
        gtk_menu_shell_prepend(GTK_MENU_SHELL(widgets->menu2),widgets->EnableVNCMenuItem);
    }
    {
        widgets->ConfigurationModeMenuItem = gtk_menu_item_new();
        GtkWidget *Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
        GtkWidget *Label = gtk_label_new(CONFIGURATION_MODE_LABEL);
        yon_installer_widget_set_translation(Label);
        g_object_set_data(G_OBJECT(widgets->ConfigurationModeMenuItem),"Label",Label);
        widgets->ConfigurationModeCheck = gtk_check_button_new();
        gtk_box_pack_start(GTK_BOX(Box),widgets->ConfigurationModeCheck,0,0,0);
        gtk_box_pack_start(GTK_BOX(Box),Label,0,0,0);
        gtk_container_add(GTK_CONTAINER(widgets->ConfigurationModeMenuItem),Box);
        g_signal_connect(G_OBJECT(widgets->ConfigurationModeMenuItem),"activate",G_CALLBACK(on_configuration_mode_switch),widgets);
        gtk_style_context_add_class(gtk_widget_get_style_context(widgets->ConfigurationModeMenuItem),"menuitemmiddle");
        gtk_widget_show_all(widgets->ConfigurationModeMenuItem);
        gtk_menu_shell_prepend(GTK_MENU_SHELL(widgets->menu2),widgets->ConfigurationModeMenuItem);
        if (getuid()){
            gtk_widget_set_sensitive(widgets->ConfigurationModeMenuItem,0);
        }
    }
    {
        widgets->root_button = yon_root_button_new(main_config.argv,main_config.argc);
        GtkWidget *Label = g_object_get_data(G_OBJECT(widgets->root_button),"Label");
        yon_installer_widget_set_translation(Label);
        gtk_style_context_add_class(gtk_widget_get_style_context(widgets->root_button),"menuitemtop");
        gtk_menu_shell_prepend(GTK_MENU_SHELL(gtk_widget_get_parent(widgets->AboutMenuItem)),widgets->root_button);
        
        yon_root_button_init(widgets->root_button,GTK_WINDOW(widgets->MainWindow));
    }

    widgets->PackagesMenu = yon_rmb_menu_setup(widgets->PackagesTree,NULL,NULL,INFO_LABEL,info_icon_path,G_CALLBACK(on_software_info),widgets,NULL);
    
    dictionary *iter = NULL;
    for_dictionaries (iter,widgets->PackagesMenu->buttons){
        yon_installer_widget_set_translation(g_object_get_data(G_OBJECT(iter->data),"Label"));
    }
    yon_startup_language_init();
    yon_locale_init();
    yon_main_window_update_locale(widgets);

    yon_gtk_window_setup(GTK_WINDOW(widgets->MainWindow),NULL,TITLE_LABEL,icon_path,NULL);

    gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(widgets->InstallerCountryFilter),(GtkTreeModelFilterVisibleFunc)on_country_filter,widgets,NULL);
    
    if (main_config.autoinstall||!yon_char_is_empty(config(finish_parameter))){
        on_autoinstall_start(NULL,widgets);
    }

    gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(widgets->LanguagesTree),(GtkTreeViewSearchEqualFunc)on_languages_search_func,widgets,NULL);
    gtk_overlay_add_overlay(GTK_OVERLAY(widgets->RegionMapOverlay),widgets->TimeZoneMapOverlayBox);
    gtk_overlay_set_overlay_pass_through(GTK_OVERLAY(widgets->RegionMapOverlay),widgets->TimeZoneMapOverlayBox,1);
    gtk_widget_hide(widgets->TimeZoneMapOverlayBox);
    g_thread_new("Partitions_thread",(GThreadFunc)yon_partitions_list_load,widgets);
    {

        gtk_window_set_title(GTK_WINDOW(widgets->MainWindow),TITLE_LABEL);
        gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(builder,"headerTopic")),TITLE_LABEL);
        gtk_window_set_icon_name(GTK_WINDOW(widgets->MainWindow),icon_path);
    }
    gtk_builder_connect_signals(builder,NULL);
    if (getuid()&&!main_config.autoinstall&&yon_char_is_empty(main_config.config_save_path)){
        gtk_menu_item_activate(GTK_MENU_ITEM(widgets->ConfigurationModeMenuItem));
        if (yon_char_is_empty(main_config.config_save_path)){
            exit (1);
        }
    }
    if (main_config.force_ini&&!main_config.autoinstall){
        while(gtk_events_pending()) gtk_main_iteration();
        if (!yon_configuration_path_check(main_config.config_save_path)){
            exit (1);
        }
        yon_config_mode_start(widgets);
    } else {
        yon_config_custom_load_config(&main_config.startup_config,config_get_command("system"),NULL);

    }
    {
        char *command = yon_config_parameter_prepare_command(part_size_parameter_command,"default",NULL,NULL);
        int size;
        config_str default_part_size = yon_config_load(command,&size);
        if (size&&strcmp(default_part_size[0],"(null)\n")){
            free(yon_char_divide_search(default_part_size[0],"=",-1));
            yon_char_remove_last_symbol(default_part_size[0],'\n');
            yon_char_remove_brackets(default_part_size[0]);
            main_config.part_size_default = default_part_size[0];
        }
    }
}

gboolean yon_maximize_start(main_window *widgets){
    gtk_window_maximize(GTK_WINDOW(widgets->MainWindow));
    return G_SOURCE_REMOVE;
}

void *yon_maximize(main_window *widgets){
    g_usleep(G_USEC_PER_SEC/10);
    g_idle_add((GSourceFunc)yon_maximize_start,widgets);
    return NULL;
}
            
/**yon_main_window_complete(main_window *widgets) 
 * [EN] 
 *  
 * [RU] 
 * Функция настройки основного окна приложения. [widgets] - структура со стандартным интерфейсом. 
*/ 
main_window *yon_main_window_complete(){ 
    if (main_config.force_ini){ //Check if config path exists
        if (!yon_char_is_empty(main_config.config_save_path)){
            {
                main_config.configure_mode=1;
            }
        }
    }
    main_window *widgets=NULL;
    widgets = malloc(sizeof(main_window));
    memset(widgets,0,sizeof(main_window));
    yon_main_window_create(widgets);
    return widgets;
}

int main(int argc, char *argv[]){
    main_config.block_restore=1;
	config_str unfound = NULL;
	int size=0;
    yon_ubl_connect_config((_template_config*)&main_config);
    textdomain(LocaleName);
    config_init();
    main_config.argv=yon_char_parsed_copy(argv,argc);
    main_config.argc = argc;
    gtk_init(&argc,&argv);
    yon_ubl_window_init(TITLE_LABEL,"",LocaleName,CssPath,LocaleName,version_application,WIKI_LINK);
    opterr=0; 
	yon_ubl_setup_arguments(argc,argv,&unfound,&size,ADDITIONAL_ARGS);
    if (size) {
        int option_index = 0;
        struct option long_options[] = {
            {"dry-run", 0, 0, 'D'},
            {"autoinstall", 0, 0, 'A'},
            {NULL, 0, NULL, 0}
        };
        optind = 1;
        for (int i = 0; i < size; i++) {
            int argument = getopt_long(argc, argv, "DA", long_options, &option_index);
            switch (argument) {
                case 'D':
                    main_config.dry_run = 1;
                    break;
                case 'A':
                    main_config.autoinstall = 1;
                    break;
                default:
                    break;
            }
        }
    }
    main_window *widgets = NULL;
    GtkCssProvider *css=gtk_css_provider_new();
    gtk_css_provider_load_from_resource(css,CssPath);
    gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
                            GTK_STYLE_PROVIDER(css),
                            -1);
    {
        widgets = yon_main_window_complete();

        on_config_local_load(NULL,widgets);
    }
    
    main_config.launch_arguments=yon_char_parsed_copy(argv,argc);
    main_config.launch_size=argc;
    main_config.block_restore=0;
    gtk_main();
    return 0;
}