diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index d32d385..3a80a14 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -487,25 +487,25 @@ void yon_interface_update(main_window *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); + 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); @@ -864,7 +864,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 +883,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 +941,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_slidePackageInstallationLabel), ""); - 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 +1127,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 +1148,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 +1170,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); @@ -1243,37 +1261,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 +1280,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 +1292,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 +1384,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 @@ -1759,7 +1747,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 +1762,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 +1776,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,6 +1784,7 @@ 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; @@ -2231,8 +2224,10 @@ 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); @@ -2441,7 +2436,7 @@ main_window *yon_main_window_complete(){ widgets->SameFSTypeSensitiveCheck = yon_gtk_builder_get_widget(builder,"SameFSTypeSensitiveCheck"); widgets->SameLabelSensitiveCheck = yon_gtk_builder_get_widget(builder,"SameLabelSensitiveCheck"); - g_signal_connect(G_OBJECT(widgets->MainWindow),"delete-event",G_CALLBACK(on_yon_exit),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"); 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"); @@ -2740,10 +2735,10 @@ int main(int argc, char *argv[]){ gtk_init(&argc,&argv); main_window *widgets = NULL; widgets = yon_main_window_complete(); - 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); + // 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); 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..4d4b003 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -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 {