diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index d32d385..a00a755 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -4,6 +4,29 @@ config main_config; //functions +void on_layout_toggle_button_switch(GtkWidget *self, main_window *widgets){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self))){ + gtk_widget_set_sensitive(widgets->DefaultLayoutRadio,1); + gtk_widget_set_sensitive(widgets->ManualLayoutRadio,1); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->ManualLayoutRadio))){ + gtk_widget_set_sensitive(widgets->LayoutTree,1); + gtk_widget_set_sensitive(widgets->AddButton,1); + gtk_widget_set_sensitive(widgets->RemoveButton,1); + } else { + gtk_widget_set_sensitive(widgets->LayoutTree,0); + gtk_widget_set_sensitive(widgets->AddButton,0); + gtk_widget_set_sensitive(widgets->RemoveButton,0); + } + } else { + gtk_widget_set_sensitive(widgets->DefaultLayoutRadio,0); + gtk_widget_set_sensitive(widgets->ManualLayoutRadio,0); + gtk_widget_set_sensitive(widgets->LayoutTree,0); + gtk_widget_set_sensitive(widgets->AddButton,0); + gtk_widget_set_sensitive(widgets->RemoveButton,0); + + } +} + void on_toggle_button_switch_on(GtkWidget *, GtkToggleButton *toggle){ gtk_toggle_button_set_active(toggle,1); } @@ -191,17 +214,14 @@ void yon_interface_update(main_window *widgets){ page = YON_PAGE_OPTIONS_SEPARATE; } } - char *device = config(AUTOINSTALL_DEVICE); char *part = NULL; if (page!=YON_PAGE_INSTALL_COMMON) part = config(part_parameter); - char *fs_type = config(part_type_parameter); char *device_label = config(device_label_parameter); char *format = config(device_format_parameter); char *part_size = config(part_size_parameter); - GtkListStore *device_list = widgets->DevicesList; GtkListStore *part_list=widgets->PartitionsList; GtkWidget *device_tree=NULL; @@ -210,6 +230,7 @@ void yon_interface_update(main_window *widgets){ case YON_PAGE_INSTALL_COMMON:{ device_tree = widgets->CommonInstallationDevicesTree; } break; + case YON_PAGE_INSTALL_SEPARATE:{ device_tree = widgets->InstallationNearSysDevicesTree; part_tree = widgets->InstallationNearSysSectionTree; @@ -229,6 +250,7 @@ void yon_interface_update(main_window *widgets){ gtk_entry_set_text(GTK_ENTRY(widgets->NextInstallationSectionNameEntry),""); } break; + case YON_PAGE_INSTALL_SAME_PARTITION:{ device_tree = widgets->SamePlaceDeviceTree; part_tree = widgets->SamePlacePartTree; @@ -245,9 +267,11 @@ void yon_interface_update(main_window *widgets){ case YON_PAGE_OPTIONS_GRUB_INSTALL:{ device_tree = widgets->GrubInstallDevicesTree; } break; + case YON_PAGE_OPTIONS_GRUB_UPDATE:{ device_tree = widgets->GrubUpdateDevicesTree; } break; + case YON_PAGE_OPTIONS_SEPARATE:{ GtkTreeIter iter; device_tree = widgets->SeparateDevicesTree; @@ -269,21 +293,19 @@ void yon_interface_update(main_window *widgets){ } } } break; + case YON_PAGE_OPTIONS_OS_ONLY:{ device_tree = widgets->OSDevicesTree; part_tree = widgets->OSSysSectionTree; } break; + case YON_PAGE_OPTIONS_USRDATA_ONLY:{ device_tree = widgets->UserdataDevicesTree; part_tree = widgets->UserdataSysSectionTree; } break; + default:{}break; } - - - - - GtkTreeIter iter; char *cur_device=""; if (page!=YON_PAGE_OPTIONS_SEPARATE && !yon_char_is_empty(device)){ @@ -305,8 +327,6 @@ void yon_interface_update(main_window *widgets){ } } } - - char *system_locale = config(locale_parameter); if (!yon_char_is_empty(system_locale)){ char *chosen_langs = ""; @@ -328,7 +348,6 @@ void yon_interface_update(main_window *widgets){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),""); } - // gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter)); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),""); @@ -346,14 +365,10 @@ void yon_interface_update(main_window *widgets){ if (cur) free(cur); } if (langsize) yon_char_parsed_free(lang,langsize); - // gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter)); } - - - char *zone = config(zone_parameter); char *region = NULL; - + if (!yon_char_is_empty(zone)) region = yon_char_divide_search(zone,"/",-1); else {gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RegionSensitiveCheck),0);} if (!yon_char_is_empty(region)){ gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->RegionCombo),region); @@ -361,13 +376,11 @@ void yon_interface_update(main_window *widgets){ gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->RegionCombo),"Europe"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RegionSensitiveCheck),0); } - if (!yon_char_is_empty(zone)){ gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->ZoneCombo),zone); } else { gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->ZoneCombo),"Moscow"); } - char *language = config(lang_parameter); if (!yon_char_is_empty(language)){ gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->LanguageCombo),language); @@ -375,12 +388,9 @@ void yon_interface_update(main_window *widgets){ gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LanguageCombo),0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->MainLanguageSensitiveCheck),0); } - - char *kbmodel = config (xkbmodel_parameter); char *optinos = config(xkboptions_parameter); char *layout = config(xkblayout_parameter); - if (!yon_char_is_empty(kbmodel)){ gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->KeyboardModelCombo),kbmodel); } else { @@ -388,25 +398,23 @@ void yon_interface_update(main_window *widgets){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->KeyboardModelSensitiveCheck),0); } - if (!yon_char_is_empty(optinos)){ gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->LayoutBindingCombo),optinos); } else { gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LayoutBindingCombo),0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->OptionsSensitiveCheck),0); } - if (!yon_char_is_empty(layout)){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->ManualLayoutRadio),1); - for_iter(widgets->LayoutList,&iter){ - char *cur=NULL; - gtk_tree_model_get(GTK_TREE_MODEL(widgets->LayoutList),&iter,0,&cur,-1); - if (strstr(layout,cur)){ - gtk_tree_store_set(widgets->LayoutList,&iter,3,1,-1); - } else { - gtk_tree_store_set(widgets->LayoutList,&iter,3,0,-1); + for_iter(widgets->LayoutList,&iter){ + char *cur=NULL; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->LayoutList),&iter,0,&cur,-1); + if (strstr(layout,cur)){ + gtk_tree_store_set(widgets->LayoutList,&iter,3,1,-1); + } else { + gtk_tree_store_set(widgets->LayoutList,&iter,3,0,-1); + } } - } } else { for_iter(widgets->LayoutList,&iter){ char *id; @@ -419,28 +427,24 @@ void yon_interface_update(main_window *widgets){ } gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LayoutSensitiveCheck),0); } - char *user_name = config(user_name_parameter); char *user_gecos = config(user_gecos_parameter); char *user_password = config(user_password_parameter); char *root_password = config(root_password_parameter); char *autologin = config(autologin_parameter); char *hostname = config(hostname_parameter); - if (!yon_char_is_empty(user_name)){ gtk_entry_set_text(GTK_ENTRY(widgets->LoginEntry),user_name); } else { gtk_entry_set_text(GTK_ENTRY(widgets->LoginEntry),""); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LoginSensitiveCheck),0); } - if (!yon_char_is_empty(user_gecos)){ gtk_entry_set_text(GTK_ENTRY(widgets->UserNameEntry),_(user_gecos)); } else { gtk_entry_set_text(GTK_ENTRY(widgets->UserNameEntry),""); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->UsernameSensitiveCheck),0); } - if (!yon_char_is_empty(user_password)){ gtk_entry_set_text(GTK_ENTRY(widgets->PasswordEntry),user_password); gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->PasswordCombo),1); @@ -448,9 +452,7 @@ void yon_interface_update(main_window *widgets){ gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->PasswordCombo),0); gtk_entry_set_text(GTK_ENTRY(widgets->PasswordEntry),""); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->PasswordSensitiveCheck),0); - } - if (!yon_char_is_empty(root_password)){ gtk_entry_set_text(GTK_ENTRY(widgets->AdminPasswordEntry),root_password); gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->AdminPasswordCombo),1); @@ -459,7 +461,6 @@ void yon_interface_update(main_window *widgets){ gtk_entry_set_text(GTK_ENTRY(widgets->AdminPasswordEntry),""); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RootPasswordSensitiveCheck),0); } - if (!yon_char_is_empty(autologin)){ if (!strcmp(autologin,"yes")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinCheck),1); @@ -469,7 +470,6 @@ void yon_interface_update(main_window *widgets){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinCheck),main_config.autologin_default); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinSensitiveCheck),0); } - if (!yon_char_is_empty(hostname)){ if (strcmp(hostname,"auto")){ gtk_entry_set_text(GTK_ENTRY(widgets->HotnameEntry),hostname); @@ -486,46 +486,26 @@ void yon_interface_update(main_window *widgets){ g_signal_handlers_unblock_by_func(G_OBJECT(widgets->AutoHostnameCheck),on_autohostname_check,widgets); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),0); } - - // if (fs_type) free(fs_type); - // if (device_label) free(device_label); - // if (format) free(format); - // if (part_size) free(part_size); - // if (user_name) free(user_name); - // if (user_gecos) free(user_gecos); - // if (user_password) free(user_password); - // if (root_password) free(root_password); - // if (autologin) free(autologin); - // if (hostname) free(hostname); - // if (kbmodel) free(kbmodel); - // if (optinos) free(optinos); - // if (layout) free(layout); - // if (language) free(language); - // if (zone) free(zone); - // if (system_locale) free(system_locale); - // if (region) free(region); - // if (device) free(device); - // if (part) free(part); } void on_config_local_load(GtkWidget *,main_window *widgets); void on_config_local_load(GtkWidget *,main_window *widgets){ - yon_load_proceed(YON_CONFIG_LOCAL); - yon_interface_update(widgets); - main_config.load_mode=1; + yon_load_proceed(YON_CONFIG_LOCAL); + yon_interface_update(widgets); + main_config.load_mode=1; } void on_config_global_load(GtkWidget *,main_window *); void on_config_global_load(GtkWidget *,main_window *widgets){ - yon_load_proceed(YON_CONFIG_GLOBAL); - yon_interface_update(widgets); - main_config.load_mode=0; + yon_load_proceed(YON_CONFIG_GLOBAL); + yon_interface_update(widgets); + main_config.load_mode=0; } void on_config_custom_load(GtkWidget *,main_window *); void on_config_custom_load(GtkWidget *,main_window *widgets){ yon_load_proceed(YON_CONFIG_CUSTOM); - yon_interface_update(widgets); + yon_interface_update(widgets); main_config.load_mode=3; } @@ -552,7 +532,6 @@ void on_config_global_save(GtkWidget *,main_window *widgets){ void on_config_custom_save(GtkWidget *, main_window *widgets); void on_config_custom_save(GtkWidget *, main_window *widgets){ char *path = NULL; - // YON_CONFIG_TYPE type = YON_CONFIG_CUSTOM; GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,SAVE_LABEL,GTK_RESPONSE_ACCEPT,NULL); textdomain(TITLE_LABEL); GtkFileFilter *filter = gtk_file_filter_new(); @@ -563,7 +542,6 @@ void on_config_custom_save(GtkWidget *, main_window *widgets){ int response = gtk_dialog_run(GTK_DIALOG(dialog)); if (response == GTK_RESPONSE_ACCEPT){ char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - // char *directory = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog)); if (!yon_char_is_empty(file)){ if (!strstr(file,".ini")) file = yon_char_append(file,".ini"); if (access(file,0)!=F_OK){ @@ -864,7 +842,6 @@ void config_init(){ main_config.lock_save_local=0; main_config.debug_mode=0; main_config.slider_thread=0; - main_config.config_save_thread=NULL; main_config.install_thread=0; main_config.progress_thread=0; main_config.install_complete=0; @@ -884,7 +861,7 @@ void on_configuration_mode_switch(GtkWidget *self){ int cur_slide=0; int yon_image_resize_from_container(GtkImage *target, GdkPixbuf *pixbuf_unscaled); -int yon_image_resize_from_container(GtkImage *target, GdkPixbuf *pixbuf_unscaled) { +int yon_image_resize_from_container(GtkImage *target, GdkPixbuf *pixbuf_unscaled){ int width = gtk_widget_get_allocated_width((gtk_widget_get_parent(GTK_WIDGET(target)))); int height = gtk_widget_get_allocated_height((gtk_widget_get_parent(GTK_WIDGET(target)))); @@ -942,7 +919,14 @@ gboolean on_image_slide(void *data){ gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->SlidesImage),(GdkPixbuf*)g_list_nth_data(widgets->slides_original,cur_slide)); // gtk_widget_queue_draw(widgets->SlidesImage); if (cur_slidePackageInstallationProgress), fraction); gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel), yon_char_parsed_to_string(parsed, size, " ")); } - yon_char_parsed_free(parsed, size); } - free(current_copy); - free(percentage); } yon_char_parsed_free(text, size); } + g_mutex_lock(&main_config.install_mutex); if (main_config.install_thread) { + g_mutex_unlock(&main_config.install_mutex); return 1; } else { + g_mutex_unlock(&main_config.install_mutex); gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel), ""); - return 0; + return 0; } } void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets); void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ + if (widgets){}; switch(page){ case YON_PAGE_WELCOME: { gtk_widget_hide(widgets->SaveButton); @@ -1115,7 +1100,9 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ gtk_widget_hide(widgets->PackageInstallationLabel); gtk_widget_set_sensitive(widgets->NextButton,1); gtk_widget_set_sensitive(widgets->CancelInstallButton,1); + g_mutex_lock(&main_config.install_mutex); main_config.install_complete=0; + g_mutex_unlock(&main_config.install_mutex); main_config.save_done=0; textdomain(LocaleName); gtk_button_set_label(GTK_BUTTON(widgets->NextButton),RESTART_LABEL); @@ -1134,7 +1121,9 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ gtk_widget_set_sensitive(widgets->NextButton,1); gtk_widget_set_sensitive(widgets->CancelInstallButton,1); yon_debug_output("%s\n","Done widgets"); + g_mutex_lock(&main_config.install_mutex); main_config.install_complete=0; + g_mutex_unlock(&main_config.install_mutex); main_config.save_done=0; yon_debug_output("%s\n","Done variables"); textdomain(LocaleName); @@ -1154,7 +1143,9 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ gtk_widget_hide(widgets->PackageInstallationLabel); gtk_widget_set_sensitive(widgets->NextButton,0); gtk_widget_set_sensitive(widgets->CancelInstallButton,1); + g_mutex_lock(&main_config.install_mutex); main_config.install_complete=0; + g_mutex_unlock(&main_config.install_mutex); main_config.save_done=0; textdomain(LocaleName); gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),EXIT_LABEL); @@ -1185,18 +1176,17 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ } } -void *on_install_success(main_window *widgets){ +gboolean on_install_success(main_window *widgets){ gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),""); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETION); - return NULL; + return 0; } -void *on_install_error(main_window *widgets){ +gboolean on_install_error(main_window *widgets){ gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),""); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALL_ERROR); - - return NULL; + return 0; } void *on_setup_system_configuration(void * data){ @@ -1204,20 +1194,20 @@ void *on_setup_system_configuration(void * data){ main_window *widgets = (main_window*)data; if (widgets){}; int size; - config_str all_parameters = yon_config_get_selection_by_key(&size, - user_name_parameter, - user_gecos_parameter, - user_password_parameter, - root_password_parameter, - autologin_parameter, - xkbmodel_parameter, - xkblayout_parameter, - xkbvariant_parameter, - xkboptions_parameter, - hostname_parameter, - zone_parameter, - lang_parameter, - locale_parameter, + config_str all_parameters = yon_char_parsed_new(&size, + config(user_name_parameter), + config(user_gecos_parameter), + config(user_password_parameter), + config(root_password_parameter), + config(autologin_parameter), + config(xkbmodel_parameter), + config(xkblayout_parameter), + config(xkbvariant_parameter), + config(xkboptions_parameter), + config(hostname_parameter), + config(zone_parameter), + config(lang_parameter), + config(locale_parameter), NULL); if (all_parameters){ char *parameter_string = yon_char_parsed_to_string(all_parameters,size," "); @@ -1227,7 +1217,7 @@ void *on_setup_system_configuration(void * data){ free(command); if (parameter_string) free(parameter_string); } - g_thread_new("success func",(GThreadFunc)on_install_success,widgets); + g_idle_add((GSourceFunc)on_install_success,widgets); return NULL; } @@ -1243,37 +1233,6 @@ void on_log_closed(GtkWidget *, dictionary *dict){ window->Window=NULL; } -void *on_save_system_configuration(void *data); -void *on_save_system_configuration(void * data){ - main_window *widgets = (main_window*)data; - if (widgets){}; - int size; - config_str all_parameters = yon_config_get_selection_by_key(&size, - user_name_parameter, - user_gecos_parameter, - user_password_parameter, - root_password_parameter, - autologin_parameter, - xkbmodel_parameter, - xkblayout_parameter, - xkbvariant_parameter, - xkboptions_parameter, - hostname_parameter, - zone_parameter, - lang_parameter, - locale_parameter, - NULL); - if (all_parameters){ - char *parameter_string = yon_char_parsed_to_string(all_parameters,size," "); - char *command = save_additional_config_command(parameter_string); - if (system(yon_debug_output("%s\n",command))){}; - yon_char_parsed_free(all_parameters,size); - free(command); - if (parameter_string) free(parameter_string); - } - return NULL; -} - log_window *yon_log_window_new(); log_window *yon_log_window_new(){ log_window *window = malloc(sizeof(log_window)); @@ -1293,10 +1252,9 @@ gboolean yon_read_log(void *data){ log_window *window = (log_window*)data; if (window->Window){ int size; - while (!main_config.install_complete&&main_config.log_progress_buzy){}; - main_config.log_progress_buzy=1; + g_mutex_lock(&main_config.progress_mutex); config_str parsed = yon_file_open(window->command,&size); - main_config.log_progress_buzy=0; + g_mutex_unlock(&main_config.progress_mutex); if (size){ char *final = yon_char_parsed_to_string(parsed,size,""); gtk_label_set_text(GTK_LABEL(window->LogLabel),final); @@ -1306,10 +1264,12 @@ gboolean yon_read_log(void *data){ free(final); yon_char_parsed_free(parsed,size); } - yon_debug_output("%s\n","Log read"); + g_mutex_lock(&main_config.install_mutex); if (!main_config.install_complete){ + g_mutex_unlock(&main_config.install_mutex); return 1; } else { + g_mutex_unlock(&main_config.install_mutex); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->ScrollToEndCheck),0); gtk_widget_set_sensitive(window->ScrollToEndCheck,0); } @@ -1396,8 +1356,8 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ active_id=2; else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio))) active_id=3; - // else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->InstallationRadio))) - // active_id=4; + else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->InstallationRadio))) + active_id=4; main_config.install_mode=active_id; switch (active_id){ case 0:{ // normal installation @@ -1512,6 +1472,7 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ char *file_system_type = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->CommonInstallationFilesystemTypeCombo)); char *device_name = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->CommonInstallationSectionNameEntry)); char *device; + yon_config_remove_by_key(part_size_parameter); yon_config_remove_by_key(part_parameter); gtk_tree_model_get(model,&iter,0,&device,-1); yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"fast"); @@ -1759,7 +1720,9 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ } if (!main_config.configure_mode){ + g_mutex_lock(&main_config.install_mutex); if (main_config.install_complete){ + g_mutex_unlock(&main_config.install_mutex); yon_debug_output("%s\n","Entered saving before installation done"); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),CONFIGURATION_LABEL); @@ -1772,7 +1735,8 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ gtk_widget_set_sensitive(widgets->BackButton,0); main_config.save_done=1; } - if (!main_config.install_complete){ + else if (!main_config.install_complete){ + g_mutex_unlock(&main_config.install_mutex); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); gtk_widget_set_sensitive(widgets->CancelInstallButton,0); @@ -1785,6 +1749,7 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ }break; case YON_PAGE_INSTALLATION_BEGIN:{ + g_mutex_lock(&main_config.install_mutex); if (!main_config.install_thread){ pthread_attr_t attr; pthread_attr_init(&attr); @@ -1792,14 +1757,24 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ pthread_create(&tid,&attr,on_config_save,widgets); memcpy(&main_config.install_thread,&tid,sizeof(pthread_t)); + g_mutex_unlock(&main_config.install_mutex); } gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); } break; case YON_PAGE_INSTALL_ERROR: case YON_PAGE_COMPLETION: - if (!system("reboot")) - return; + confirmation_window *window = yon_confirmation_window_new(); + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_reboot_accepted),dict); + gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->MainWindow)); + gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); + gtk_window_set_icon_name(GTK_WINDOW(window->Window),icon_path); + gtk_label_set_text(GTK_LABEL(window->TextLabel),WARNING_REBOOT_TEXT_LABEL); + gtk_label_set_text(GTK_LABEL(window->TitleLabel),WARNING_TITLE_LABEL); + gtk_widget_show(window->Window); break; case YON_PAGE_INSTALL_OPTIONS: { @@ -2131,7 +2106,7 @@ void on_near_installation_device_changed(GtkWidget *self, main_window *widgets){ json_object_object_get_ex(root, "blockdevices", &blockdevices); for (long unsigned int i = 0; i < json_object_array_length(blockdevices); i++) { struct json_object *device = json_object_array_get_idx(blockdevices, i); - struct json_object *type, *path, *size, *model, *fstype, *fsused; + struct json_object *type, *path, *size, *model, *fstype, *fsused, *label; json_object_object_get_ex(device, "type", &type); if (strcmp("part",json_object_get_string(type))) @@ -2142,6 +2117,7 @@ void on_near_installation_device_changed(GtkWidget *self, main_window *widgets){ } json_object_object_get_ex(device, "size", &size); json_object_object_get_ex(device, "model", &model); + json_object_object_get_ex(device, "label", &label); json_object_object_get_ex(device, "fstype", &fstype); json_object_object_get_ex(device, "fsused", &fsused); @@ -2175,7 +2151,7 @@ void on_near_installation_device_changed(GtkWidget *self, main_window *widgets){ // gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),0.0); gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin)),0.0); gtk_list_store_append(widgets->PartitionsList,&iter); - gtk_list_store_set(widgets->PartitionsList,&iter,0,json_object_get_string(path),1,json_object_get_string(size),2,free_space_string,3,json_object_get_string(fstype),-1); + gtk_list_store_set(widgets->PartitionsList,&iter,0,json_object_get_string(path),1,json_object_get_string(size),2,free_space_string,3,json_object_get_string(fstype),4,json_object_get_string(label),-1); } yon_char_parsed_free(parsed,size); } @@ -2227,38 +2203,64 @@ void on_gparted_open(){ gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets); +void on_reboot_accepted(GtkWidget *,dictionary *dict){ + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + confirmation_window *window = yon_dictionary_get_data(dict->first->next,confirmation_window*); + 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; + g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event"); + free(window); + yon_dictionary_free_all(dict,NULL); + free(dict); + if (system("reboot")){}; +} + void on_exit_accepted(GtkWidget *,dictionary *dict); void on_exit_accepted(GtkWidget *,dictionary *dict){ main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); confirmation_window *window = yon_dictionary_get_data(dict->first->next,confirmation_window*); + 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; - g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event",widgets->MainWindow,NULL); + g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event"); free(window); yon_dictionary_free_all(dict,NULL); free(dict); gtk_widget_destroy(widgets->MainWindow); } -gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ - if (!main_config.exit_accepted){ - if (widgets){}; - confirmation_window *window = malloc(sizeof(confirmation_window)); +confirmation_window *yon_confirmation_window_new(){ + confirmation_window *window = malloc(sizeof(confirmation_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_confirmation); window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->TitleLabel = yon_gtk_builder_get_widget(builder,"TitleLabel"); + window->TextLabel = yon_gtk_builder_get_widget(builder,"TextLabel"); window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + return window; +} + +gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ + if (!main_config.exit_accepted||(main_config.save_done&&main_config.install_complete)){ + if (widgets){}; + confirmation_window *window = yon_confirmation_window_new(); dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_exit_accepted),dict); - g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->MainWindow)); gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); gtk_window_set_icon_name(GTK_WINDOW(window->Window),icon_path); + gtk_label_set_text(GTK_LABEL(window->TextLabel),WARNING_TEXT_LABEL); + gtk_label_set_text(GTK_LABEL(window->TitleLabel),WARNING_TITLE_LABEL); gtk_widget_show(window->Window); @@ -2471,6 +2473,7 @@ main_window *yon_main_window_complete(){ g_signal_connect(G_OBJECT(widgets->CancelInstallButton),"clicked",G_CALLBACK(on_page_navigation_clicked),widgets); g_signal_connect(G_OBJECT(widgets->AvailableLanguagesButton),"clicked",G_CALLBACK(on_language_clicked),widgets); g_signal_connect(G_OBJECT(widgets->RegionCombo),"changed",G_CALLBACK(on_region_changed),widgets); + g_signal_connect(G_OBJECT(widgets->LayoutSensitiveCheck),"toggled",G_CALLBACK(on_layout_toggle_button_switch),widgets); g_signal_connect(G_OBJECT(widgets->AddButton),"clicked",G_CALLBACK(on_keyboard_clicked),widgets); g_signal_connect(G_OBJECT(widgets->RemoveButton),"clicked",G_CALLBACK(on_keyboard_removed),widgets); @@ -2506,6 +2509,18 @@ main_window *yon_main_window_complete(){ g_signal_connect(G_OBJECT(widgets->RootPasswordSensitiveCheck),"toggled",G_CALLBACK(yon_password_set_sensitive_from_toggle),widgets); g_signal_connect(G_OBJECT(widgets->PasswordSensitiveCheck),"toggled",G_CALLBACK(yon_password_set_sensitive_from_toggle),widgets); + if (main_config.lock_load_global == 1){ + gtk_widget_set_sensitive(widgets->LoadGlobalConfigurationMenuItem,0); + } + if (main_config.lock_save_global == 1){ + gtk_widget_set_sensitive(widgets->SaveGlobalConfigurationMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveGlobalLocalConfigurationMenuItem,0); + } + if (main_config.lock_save_local == 1){ + gtk_widget_set_sensitive(widgets->SaveLocalConfigurationMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveGlobalLocalConfigurationMenuItem,0); + } + gtk_tree_model_filter_set_visible_column(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter),0); gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter)); @@ -2743,7 +2758,7 @@ int main(int argc, char *argv[]){ yon_window_config_setup(GTK_WINDOW(widgets->MainWindow)); char *window_config_path = config_path; yon_window_config_load(window_config_path); - free(window_config_path); + free(window_config_path); 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(), diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index f989488..67706dd 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -35,9 +35,9 @@ #define LocalePath "/usr/share/locale" #define LocaleName "ubinstall-gtk" -#define clear_config_both_command "ubconfig remove TEMP_SECTION TEMP_PATAMETER" -#define clear_config_global_command "ubconfig --target global remove TEMP_SECTION TEMP_PATAMETER" -#define clear_config_local_command "ubconfig --target system remove TEMP_SECTION TEMP_PATAMETER" +#define clear_config_both_command "pkexec bash -c 'ubconfig remove TEMP_SECTION TEMP_PATAMETER '" +#define clear_config_global_command "pkexec bash -c 'ubconfig --target global remove TEMP_SECTION TEMP_PATAMETER '" +#define clear_config_local_command "pkexec bash -c 'ubconfig --target system remove TEMP_SECTION TEMP_PATAMETER '" #define regions_path "/com/ublinux/images/map-time-zone.png" #define keyboard_path "/com/ublinux/images/keyboard.png" @@ -202,7 +202,6 @@ typedef struct { int debug_mode; guint slider_thread; int install_mode; - GThread *config_save_thread; unsigned long install_thread; guint progress_thread; int configure_mode; @@ -211,6 +210,8 @@ typedef struct { int format_default; int log_end; int exit_accepted; + GMutex progress_mutex; + GMutex install_mutex; } config; typedef struct { @@ -440,6 +441,8 @@ typedef struct { typedef struct { GtkWidget *Window; + GtkWidget *TitleLabel; + GtkWidget *TextLabel; GtkWidget *AcceptButton; GtkWidget *CancelButton; } confirmation_window; @@ -467,6 +470,12 @@ void on_autohostname_sensitiveness_check(GtkWidget *, main_window *widgets); void on_autohostname_check(GtkWidget *, main_window *widgets); void on_hostname_entry_changed (GtkWidget *, main_window *widgets); -void *on_install_success(main_window *widgets); +gboolean on_install_success(main_window *widgets); -void *on_install_error(main_window *widgets); \ No newline at end of file +gboolean on_install_error(main_window *widgets); + +confirmation_window *yon_confirmation_window_new(); + +void on_reboot_accepted(GtkWidget *,dictionary *dict); + +void on_layout_toggle_button_switch(GtkWidget *self, main_window *widgets); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index c25745b..abdc0be 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -9,7 +9,7 @@ #define OPEN_LABEL _("Open") #define KEYBOARD_TITLE_LABEL _("Keyboard layout") - #define CUSTOM_CONFIG_CREATION_ERROR_LABEL _("New configuration file creation failed") +#define CUSTOM_CONFIG_CREATION_ERROR_LABEL _("New configuration file creation failed") #define CANCEL_LABEL _("Cancel") #define BACK_LABEL _("Back") @@ -59,7 +59,7 @@ #define CHOOSE_SECTION_LABEL _("Choose a section:") #define ATTENSION_LABEL _("Attention! The selected partition will be modified: the size will be reduced. In the resulting free space, a partition will be created into which the UBLinux OS will be\ninstalled.") #define DEVICE_LABEL _("Device") -#define MARK_LABEL _("Mark") +#define MARK_LABEL _("Label") #define SIZE_LABEL _("Size") #define FREE_LABEL _("Free") #define SPECIFY_LABEL _("Specify the size of the new partition for UBLinux OS:") @@ -173,8 +173,6 @@ #define ACCEPT_LABEL _("Accept") #define GPARTED_LABEL _("Start GParted") -#define EXIT_WARNING_LABEL _("Are you sure want to exit and interrupt installation process?") - #define PROGRESS_LOG_LABEL _("Progress log") #define INSTALL_LOG_LABEL _("Installation log") @@ -185,4 +183,5 @@ #define WARNING_TITLE_LABEL _("Warning") -#define WARNING_TEXT_LABEL _("Are you sure want to exit and\ninterrupt installation process?") \ No newline at end of file +#define WARNING_TEXT_LABEL _("Are you sure want to exit and\ninterrupt installation process?") +#define WARNING_REBOOT_TEXT_LABEL _("Are you sure want to reboot system?") \ No newline at end of file diff --git a/ubinstall-gtk-warning.glade b/ubinstall-gtk-warning.glade index cf113d5..6dfe131 100644 --- a/ubinstall-gtk-warning.glade +++ b/ubinstall-gtk-warning.glade @@ -60,7 +60,7 @@ vertical 5 - + True False center @@ -105,7 +105,7 @@ interrupt installation process? True False - + True False Warning diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index 0edbb2c..d0ed9eb 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -2059,11 +2059,6 @@ and help you install UBLinux on your computer True False True - - - - - @@ -2112,6 +2107,9 @@ and help you install UBLinux on your computer True DefaultLayoutRadio + + + False @@ -3049,7 +3047,7 @@ or continue working in the UBLinux Live environment. - Mark + Label @@ -3071,7 +3069,7 @@ or continue working in the UBLinux Live environment. - Free + Serial @@ -3456,7 +3454,7 @@ installed. - Mark + Label @@ -3582,7 +3580,7 @@ installed. - Mark + Label @@ -4046,7 +4044,7 @@ installed. - Mark + Description @@ -4057,7 +4055,7 @@ installed. - Capacity + Label @@ -4068,7 +4066,7 @@ installed. - Location + Size @@ -4077,6 +4075,17 @@ installed. + + + Serial + + + + 4 + + + + @@ -4172,7 +4181,7 @@ installed. - Mark + Label diff --git a/ubinstall-gtk.pot b/ubinstall-gtk.pot index 98031f6..64ee4dd 100644 --- a/ubinstall-gtk.pot +++ b/ubinstall-gtk.pot @@ -272,7 +272,7 @@ msgid "Device" msgstr "" #: source/ubl-strings.h:58 -msgid "Mark" +msgid "Label" msgstr "" #: source/ubl-strings.h:59 @@ -565,6 +565,10 @@ msgstr "" msgid "Start GParted" msgstr "" +#: source/ubl-strings.h:187 +msgid "Are you sure want to reboot system?" +msgstr "" + msgid "Load global configuration" msgstr "" diff --git a/ubinstall-gtk_ru.po b/ubinstall-gtk_ru.po index e687ffe..7dc9da8 100644 --- a/ubinstall-gtk_ru.po +++ b/ubinstall-gtk_ru.po @@ -286,7 +286,7 @@ msgid "Device" msgstr "Устройство" #: source/ubl-strings.h:58 -msgid "Mark" +msgid "Label" msgstr "Метка" #: source/ubl-strings.h:59 @@ -665,6 +665,10 @@ msgstr "Запустить GParted" msgid "English, U.S.A.; Russian, Russia" msgstr "Английский, США; Русский, Россия" +#: source/ubl-strings.h:187 +msgid "Are you sure want to reboot system?" +msgstr "Вы уверены что хотите перезагрузить систему?" + msgid "Afrikaans" msgstr "Африканский"