From 71ae5f187ea3a723e101bd2400a54a61e1a24087 Mon Sep 17 00:00:00 2001 From: YanTheKaller Date: Tue, 24 Sep 2024 09:56:57 +0000 Subject: [PATCH 01/10] Test fix for crash --- source/ubinstall-gtk.c | 153 ++++++++++++++++++++--------------------- source/ubinstall-gtk.h | 3 +- 2 files changed, 76 insertions(+), 80 deletions(-) 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 { -- 2.35.1 From 4cebccbd31e513c8fd227735310f0baeec46ac11 Mon Sep 17 00:00:00 2001 From: YanTheKaller Date: Wed, 25 Sep 2024 06:29:06 +0000 Subject: [PATCH 02/10] Test fix for crash --- source/ubinstall-gtk.c | 47 ++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 3a80a14..b5778ee 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); @@ -1037,11 +1037,8 @@ gboolean yon_installation_progress_update(void *data) { gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->PackageInstallationProgress), 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); } @@ -1103,8 +1100,8 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ gtk_widget_set_sensitive(widgets->BackButton,0); if ((!main_config.configure_mode)) gtk_widget_set_sensitive(widgets->CancelInstallButton,0); - if (!main_config.progress_thread&&!main_config.configure_mode) - main_config.progress_thread = gdk_threads_add_timeout(500,(GSourceFunc)yon_installation_progress_update,widgets); + // if (!main_config.progress_thread&&!main_config.configure_mode) + // main_config.progress_thread = gdk_threads_add_timeout(500,(GSourceFunc)yon_installation_progress_update,widgets); if (!main_config.slider_thread&&!main_config.configure_mode) main_config.slider_thread = g_timeout_add(5000,(GSourceFunc)on_image_slide,widgets); @@ -2459,7 +2456,7 @@ main_window *yon_main_window_complete(){ g_signal_connect(G_OBJECT(widgets->GpartedSameButton),"clicked",G_CALLBACK(on_gparted_open),NULL); g_signal_connect(G_OBJECT(widgets->GpartedNearButton),"clicked",G_CALLBACK(on_gparted_open),NULL); - g_signal_connect(G_OBJECT(widgets->Notebook),"switch-page",G_CALLBACK(on_page_changed),widgets); + // g_signal_connect(G_OBJECT(widgets->Notebook),"switch-page",G_CALLBACK(on_page_changed),widgets); g_signal_connect(G_OBJECT(widgets->MainWindow),"check-resize",G_CALLBACK(on_region_resized),widgets); g_signal_connect(G_OBJECT(widgets->BackButton),"clicked",G_CALLBACK(on_page_navigation_clicked),widgets); g_signal_connect(G_OBJECT(widgets->NextButton),"clicked",G_CALLBACK(on_page_navigation_clicked),widgets); -- 2.35.1 From eae6f6892974bf406e7b0edc1f802bccc2db257b Mon Sep 17 00:00:00 2001 From: YanTheKaller Date: Wed, 25 Sep 2024 06:41:39 +0000 Subject: [PATCH 03/10] Return of functions --- source/ubinstall-gtk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index b5778ee..2453540 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -2433,7 +2433,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"); @@ -2456,7 +2456,7 @@ main_window *yon_main_window_complete(){ g_signal_connect(G_OBJECT(widgets->GpartedSameButton),"clicked",G_CALLBACK(on_gparted_open),NULL); g_signal_connect(G_OBJECT(widgets->GpartedNearButton),"clicked",G_CALLBACK(on_gparted_open),NULL); - // g_signal_connect(G_OBJECT(widgets->Notebook),"switch-page",G_CALLBACK(on_page_changed),widgets); + g_signal_connect(G_OBJECT(widgets->Notebook),"switch-page",G_CALLBACK(on_page_changed),widgets); g_signal_connect(G_OBJECT(widgets->MainWindow),"check-resize",G_CALLBACK(on_region_resized),widgets); g_signal_connect(G_OBJECT(widgets->BackButton),"clicked",G_CALLBACK(on_page_navigation_clicked),widgets); g_signal_connect(G_OBJECT(widgets->NextButton),"clicked",G_CALLBACK(on_page_navigation_clicked),widgets); -- 2.35.1 From b21ec46fdced82539d5750a754bb998de75eb679 Mon Sep 17 00:00:00 2001 From: YanTheKaller Date: Wed, 25 Sep 2024 06:42:36 +0000 Subject: [PATCH 04/10] Return of functions --- source/ubinstall-gtk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 2453540..dde5eea 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -1000,7 +1000,7 @@ void *on_config_save(void *data){ if (!main_config.save_done){ yon_debug_output("%s\n","Entered installation page change"); on_setup_system_configuration(widgets); - // g_thread_new("success func",(GThreadFunc)on_install_success,widgets); + g_thread_new("success func",(GThreadFunc)on_install_success,widgets); } yon_debug_output("%s\n","Exit installation"); @@ -1100,8 +1100,8 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ gtk_widget_set_sensitive(widgets->BackButton,0); if ((!main_config.configure_mode)) gtk_widget_set_sensitive(widgets->CancelInstallButton,0); - // if (!main_config.progress_thread&&!main_config.configure_mode) - // main_config.progress_thread = gdk_threads_add_timeout(500,(GSourceFunc)yon_installation_progress_update,widgets); + if (!main_config.progress_thread&&!main_config.configure_mode) + main_config.progress_thread = gdk_threads_add_timeout(500,(GSourceFunc)yon_installation_progress_update,widgets); if (!main_config.slider_thread&&!main_config.configure_mode) main_config.slider_thread = g_timeout_add(5000,(GSourceFunc)on_image_slide,widgets); -- 2.35.1 From 02d65722d22e934fc6cd8fd016d62e9b4ba020c1 Mon Sep 17 00:00:00 2001 From: YanTheKaller Date: Wed, 25 Sep 2024 09:56:13 +0000 Subject: [PATCH 05/10] Test fix for crash --- source/ubinstall-gtk.c | 42 +++++++++++++++++++++--------------------- source/ubinstall-gtk.h | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index dde5eea..132de74 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -1000,7 +1000,7 @@ void *on_config_save(void *data){ if (!main_config.save_done){ yon_debug_output("%s\n","Entered installation page change"); on_setup_system_configuration(widgets); - g_thread_new("success func",(GThreadFunc)on_install_success,widgets); + // g_thread_new("success func",(GThreadFunc)on_install_success,widgets); } yon_debug_output("%s\n","Exit installation"); @@ -1200,11 +1200,11 @@ 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){ @@ -1219,30 +1219,30 @@ 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," "); char *command = set_user_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); + // yon_char_parsed_free(all_parameters,size); + // 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; } diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 4d4b003..454face 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -468,6 +468,6 @@ 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 -- 2.35.1 From 653adbd1987cb4af6444a4bc5d4fd27cf05a918b Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Sep 2024 10:09:41 +0600 Subject: [PATCH 06/10] Fixed exiting --- source/ubinstall-gtk.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 132de74..c8d05a7 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -2227,7 +2227,7 @@ void on_exit_accepted(GtkWidget *,dictionary *dict){ 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); @@ -2732,10 +2732,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(), -- 2.35.1 From 03857aa110521fd5bb8dc3cbee70988675fb586c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Sep 2024 11:07:49 +0600 Subject: [PATCH 07/10] Fixed device and partitions lables --- source/ubinstall-gtk.c | 66 +++++++++++++++++++++++++++++++------ source/ubinstall-gtk.h | 14 +++++--- source/ubl-strings.h | 6 ++-- ubinstall-gtk-warning.glade | 4 +-- ubinstall-gtk.glade | 23 +++++++++---- ubinstall-gtk.pot | 2 +- ubinstall-gtk_ru.po | 2 +- 7 files changed, 89 insertions(+), 28 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index c8d05a7..640df44 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -1788,8 +1788,17 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ 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_TEXT_LABEL); + gtk_label_set_text(GTK_LABEL(window->TitleLabel),WARNING_TITLE_LABEL); + gtk_widget_show(window->Window); break; case YON_PAGE_INSTALL_OPTIONS: { @@ -2121,7 +2130,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))) @@ -2132,6 +2141,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); @@ -2165,7 +2175,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); } @@ -2217,6 +2227,22 @@ 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*); @@ -2234,23 +2260,31 @@ void on_exit_accepted(GtkWidget *,dictionary *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){ + 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); @@ -2498,6 +2532,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)); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 454face..519c4cd 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" @@ -441,6 +441,8 @@ typedef struct { typedef struct { GtkWidget *Window; + GtkWidget *TitleLabel; + GtkWidget *TextLabel; GtkWidget *AcceptButton; GtkWidget *CancelButton; } confirmation_window; @@ -470,4 +472,8 @@ void on_hostname_entry_changed (GtkWidget *, main_window *widgets); gboolean on_install_success(main_window *widgets); -void *on_install_error(main_window *widgets); \ No newline at end of file +void *on_install_error(main_window *widgets); + +confirmation_window *yon_confirmation_window_new(); + +void on_reboot_accepted(GtkWidget *,dictionary *dict); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index c25745b..c43b7bd 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") 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..52126c7 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -3049,7 +3049,7 @@ or continue working in the UBLinux Live environment. - Mark + Label @@ -3071,7 +3071,7 @@ or continue working in the UBLinux Live environment. - Free + Serial @@ -3456,7 +3456,7 @@ installed. - Mark + Label @@ -4046,7 +4046,7 @@ installed. - Mark + Description @@ -4057,7 +4057,7 @@ installed. - Capacity + Label @@ -4068,7 +4068,7 @@ installed. - Location + Size @@ -4077,6 +4077,17 @@ installed. + + + Serial + + + + 4 + + + + diff --git a/ubinstall-gtk.pot b/ubinstall-gtk.pot index 98031f6..e3ef875 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 diff --git a/ubinstall-gtk_ru.po b/ubinstall-gtk_ru.po index e687ffe..83736f7 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 -- 2.35.1 From b778f34d78d99efa529cfd8c7c8b3082ecd64088 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Sep 2024 16:09:18 +0600 Subject: [PATCH 08/10] Label fixes, sensetiveness edit for keyboard layouts widgets, removal of debug messages --- source/ubinstall-gtk.c | 139 ++++++++++++++++------------------------- source/ubinstall-gtk.h | 6 +- ubinstall-gtk.glade | 12 ++-- 3 files changed, 62 insertions(+), 95 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 640df44..c65660a 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){ @@ -973,9 +951,8 @@ void *on_config_save(void *data){ yon_char_parsed_free(parameters,size); yon_debug_output("%s\n","Entered installation"); if (system(yon_debug_output("%s\n",command))){ - yon_debug_output("%s\n","Entered installation failed"); - g_thread_new("error func",(GThreadFunc)on_install_error,widgets); + gdk_threads_add_idle((GSourceFunc)on_install_error,widgets); free(command); g_mutex_lock(&main_config.install_mutex); main_config.install_thread=0; @@ -983,28 +960,18 @@ void *on_config_save(void *data){ g_mutex_lock(&main_config.install_mutex); main_config.install_complete=1; g_mutex_unlock(&main_config.install_mutex); - yon_debug_output("%s\n","Exit installation"); - // // pthread_exit(NULL); return 0; }; - yon_debug_output("%s\n","Entered installation success"); free(command); g_mutex_lock(&main_config.install_mutex); main_config.install_thread=0; g_mutex_unlock(&main_config.install_mutex); g_mutex_lock(&main_config.install_mutex); main_config.install_complete=1; - yon_debug_output("Install set to: %s\n",yon_char_from_int(main_config.install_complete)); g_mutex_unlock(&main_config.install_mutex); - yon_debug_output("Save state: %s\n",yon_char_from_int(main_config.save_done)); if (!main_config.save_done){ - yon_debug_output("%s\n","Entered installation page change"); on_setup_system_configuration(widgets); - // g_thread_new("success func",(GThreadFunc)on_install_success,widgets); } - - yon_debug_output("%s\n","Exit installation"); - // pthread_exit(NULL); return 0; } @@ -1207,11 +1174,10 @@ gboolean on_install_success(main_window *widgets){ 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){ @@ -1238,9 +1204,9 @@ void *on_setup_system_configuration(void * data){ char *parameter_string = yon_char_parsed_to_string(all_parameters,size," "); char *command = set_user_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); + yon_char_parsed_free(all_parameters,size); + free(command); + if (parameter_string) free(parameter_string); } g_idle_add((GSourceFunc)on_install_success,widgets); return NULL; @@ -2497,6 +2463,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); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 519c4cd..67706dd 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -472,8 +472,10 @@ void on_hostname_entry_changed (GtkWidget *, main_window *widgets); gboolean on_install_success(main_window *widgets); -void *on_install_error(main_window *widgets); +gboolean on_install_error(main_window *widgets); confirmation_window *yon_confirmation_window_new(); -void on_reboot_accepted(GtkWidget *,dictionary *dict); \ No newline at end of file +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/ubinstall-gtk.glade b/ubinstall-gtk.glade index 52126c7..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 @@ -3582,7 +3580,7 @@ installed. - Mark + Label @@ -4183,7 +4181,7 @@ installed. - Mark + Label -- 2.35.1 From aabc607cc78c8856aaf8487f139615810f02e1e0 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Sep 2024 16:58:56 +0600 Subject: [PATCH 09/10] If installation succeeded, no warning will be shown at exiting --- source/ubinstall-gtk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index c65660a..0a92563 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -2239,7 +2239,7 @@ confirmation_window *yon_confirmation_window_new(){ } gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ - if (!main_config.exit_accepted){ + 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; -- 2.35.1 From 5416f14a70b4c8c90e943ec811090efc673c4593 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 27 Sep 2024 10:01:18 +0600 Subject: [PATCH 10/10] Slight changes to saving mechanism, reboot warning text change --- source/ubinstall-gtk.c | 14 ++++++++++++-- source/ubl-strings.h | 3 ++- ubinstall-gtk.pot | 4 ++++ ubinstall-gtk_ru.po | 4 ++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 0a92563..a00a755 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -943,7 +943,16 @@ void *on_config_save(void *data){ main_window *widgets = (main_window*)data; int size=0; - config_str parameters = yon_config_get_all(&size); + config_str parameters = yon_config_get_selection_by_key(&size, + AUTOINSTALL_TYPE_INSTALL, + AUTOINSTALL_DEVICE, + device_format_parameter, + device_label_parameter, + main_config.install_mode!=1||main_config.install_mode!=2?NULL:part_parameter, + part_type_parameter, + device_format_parameter, + main_config.install_mode!=1?NULL:part_size_parameter, + NULL); FILE *file = fopen(progress_path,"w"); if (file) fclose(file); @@ -1463,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"); @@ -1762,7 +1772,7 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ 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->TextLabel),WARNING_REBOOT_TEXT_LABEL); gtk_label_set_text(GTK_LABEL(window->TitleLabel),WARNING_TITLE_LABEL); gtk_widget_show(window->Window); break; diff --git a/source/ubl-strings.h b/source/ubl-strings.h index c43b7bd..abdc0be 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -183,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.pot b/ubinstall-gtk.pot index e3ef875..64ee4dd 100644 --- a/ubinstall-gtk.pot +++ b/ubinstall-gtk.pot @@ -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 83736f7..7dc9da8 100644 --- a/ubinstall-gtk_ru.po +++ b/ubinstall-gtk_ru.po @@ -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 "Африканский" -- 2.35.1