diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 7ab3609..faac6c5 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -226,6 +226,7 @@ void config_init(){ main_config.install_thread=NULL; main_config.progress_thread=0; main_config.install_complete=0; + main_config.save_done=0; } int yon_image_resize_from_container(GtkImage *target, GdkPixbuf *pixbuf_unscaled); @@ -311,22 +312,6 @@ gboolean on_image_slide(void *data){ return 1; } -void *on_config_save(void *); -void *on_config_save(void *){ - int size=0; - config_str parameters = yon_config_get_all(&size); - main_config.install_thread=(GThread*)0x1; - FILE *file = fopen(progress_path,"w"); - if (file) - fclose(file); - char *command = save_config_command(yon_char_parsed_to_string(parameters,size," ")); - if (system(command)){}; - main_config.install_thread=(GThread*)0x0; - main_config.config_save_thread=NULL; - return NULL; -} - - char* yon_debug_output(char *pattern,char*text); char* yon_debug_output(char *pattern,char*text){ if (main_config.debug_mode){ @@ -335,15 +320,41 @@ char* yon_debug_output(char *pattern,char*text){ return text; } +void *on_config_save(void *data); +void *on_config_save(void *data){ + main_window *widgets = (main_window*)data; + if (!main_config.install_complete){ + int size=0; + config_str parameters = yon_config_get_all(&size); + main_config.install_thread=(GThread*)0x1; + FILE *file = fopen(progress_path,"w"); + if (file) + fclose(file); + char *command = save_config_command(yon_char_parsed_to_string(parameters,size," ")); + if (!system(command)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),INSTALLATION_ERROR,5,BACKGROUND_IMAGE_FAIL_TYPE); + }; + yon_debug_output("%s\n","SUCCESS"); + main_config.install_thread=NULL; + main_config.install_complete=1; + if (gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->Notebook))){ + if (main_config.save_done){ + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETION); + } + } + main_config.install_thread=(GThread*)0x0; + main_config.config_save_thread=NULL; + } + return NULL; +} + + + void *yon_installation_start(main_window *widgets); void *yon_installation_start(main_window *widgets){ if (!main_config.install_complete){ if (system(start_fast_install_command)){ - yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),INSTALLATION_ERROR,5,BACKGROUND_IMAGE_FAIL_TYPE); } - yon_debug_output("%s\n","SUCCESS"); - main_config.install_thread=NULL; - main_config.install_complete=1; gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETION); } g_thread_exit(NULL); @@ -460,7 +471,7 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->CancelInstallButton))),"com.ublinux.libublsettingsui-gtk3.reset-symbolic",GTK_ICON_SIZE_BUTTON); pthread_t tid; - pthread_create(&tid,NULL,on_config_save,NULL); + pthread_create(&tid,NULL,on_config_save,widgets); } break; case YON_PAGE_INSTALL_COMMON: @@ -471,8 +482,9 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ } } -void *on_setup_system_configuration(void *); -void *on_setup_system_configuration(void *){ +void *on_setup_system_configuration(void *data); +void *on_setup_system_configuration(void * data){ + main_window *widgets = (main_window*)data; int size; config_str all_parameters = yon_config_get_selection_by_key(&size, user_gecos_parameter, @@ -496,6 +508,9 @@ void *on_setup_system_configuration(void *){ free(command); if (parameter_string) free(parameter_string); } + main_config.save_done=1; + if (main_config.install_complete) + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETION); return NULL; } @@ -807,7 +822,7 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ } if (gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress))>0.9){ pthread_t tid; - pthread_create(&tid,NULL,on_setup_system_configuration,NULL); + pthread_create(&tid,NULL,on_setup_system_configuration,widgets); } gtk_widget_set_sensitive(widgets->CancelInstallButton,0); gtk_widget_set_sensitive(widgets->NextButton,0); @@ -815,7 +830,7 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ }break; case YON_PAGE_INSTALLATION_BEGIN:{ pthread_t tid; - pthread_create(&tid,NULL,on_config_save,NULL); + pthread_create(&tid,NULL,on_config_save,widgets); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); } break; case YON_PAGE_COMPLETION: diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 6bb64a4..b81f2c3 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -166,6 +166,8 @@ typedef struct { int always_open_documentation; int password_min_length; + + int save_done; int install_complete; int debug_mode;