From dd3981085f877e5d4078d44c0c7502266f6c4536 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 9 Aug 2024 16:27:36 +0600 Subject: [PATCH] Fixes --- source/ubinstall-gtk.c | 27 ++++++++++++++++++++++++--- source/ubinstall-gtk.h | 8 +++++++- source/ubl-strings.h | 7 ++++++- ubinstall-gtk-log-view.glade | 1 + ubinstall-gtk.glade | 9 +++++++++ ubinstall-gtk.pot | 4 ++++ ubinstall-gtk_ru.po | 4 ++++ 7 files changed, 55 insertions(+), 5 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index dc46dd5..3d61a77 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -915,7 +915,7 @@ void *on_config_save(void *data){ if (!main_config.install_complete){ int size=0; config_str parameters = yon_config_get_all(&size); - main_config.install_thread=(GThread*)0x1; + // main_config.install_thread=(GThread*)0x1; FILE *file = fopen(progress_path,"w"); if (file) fclose(file); @@ -1694,8 +1694,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,widgets); + pthread_create(main_config.install_thread,NULL,on_config_save,widgets); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); } break; @@ -2087,6 +2086,27 @@ void on_gparted_open(){ yon_launch_app_with_arguments(open_gparted_command,NULL); } +gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets); +gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ + GtkWidget *dialog = gtk_dialog_new_with_buttons(TITLE_LABEL,GTK_WINDOW(widgets->MainWindow),0,CANCEL_LABEL,GTK_RESPONSE_CANCEL,ACCEPT_LABEL,GTK_RESPONSE_ACCEPT,NULL); + + GtkWidget *box = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + GtkWidget *HeadLabel = gtk_label_new(EXIT_WARNING_LABEL); + gtk_widget_show(HeadLabel); + gtk_box_pack_start(GTK_BOX(box),HeadLabel,0,0,5); + + int resp = gtk_dialog_run(GTK_DIALOG(dialog)); + if (resp == GTK_RESPONSE_ACCEPT){ + if (main_config.install_thread) + pthread_cancel(*main_config.install_thread); + return 0; + + } else { + gtk_widget_destroy(dialog); + } + return 1; +} + /**yon_main_window_complete(main_window *widgets) * [EN] * @@ -2260,6 +2280,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); 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"); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index dbd9c74..07319ea 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -200,7 +200,7 @@ typedef struct { guint slider_thread; int install_mode; GThread *config_save_thread; - GThread *install_thread; + pthread_t *install_thread; guint progress_thread; int configure_mode; int log_progress_buzy; @@ -434,6 +434,12 @@ typedef struct { char *command; } log_window; +typedef struct { + GtkWidget *Window; + GtkWidget *AcceptButton; + GtkWidget *CancelButton; +} confirmation_window; + void config_init(); main_window *yon_main_window_complete(); ubinstall_language_window *yon_ubinstall_language_new(); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 5a1e5ea..90b8067 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -168,4 +168,9 @@ #define DEFAULT_LOCALES_LABEL _("English, U.S.A.; Russian, Russia") #define READ_INSTALL_LOG_LABEL _("Read installation log") -#define READ_PROGRESS_LOG_LABEL _("Read progress log") \ No newline at end of file +#define READ_PROGRESS_LOG_LABEL _("Read progress log") + +#define ACCEPT_LABEL _("Accept") +#define ACCEPT_LABEL _("Start GParted") + +#define EXIT_WARNING_LABEL _("Are you sure want to exit and interrupt installation process?") \ No newline at end of file diff --git a/ubinstall-gtk-log-view.glade b/ubinstall-gtk-log-view.glade index 6bd7dbc..3c9904e 100644 --- a/ubinstall-gtk-log-view.glade +++ b/ubinstall-gtk-log-view.glade @@ -69,6 +69,7 @@ True False + True 0 0 diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index 723e56d..2988de9 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -2855,6 +2855,8 @@ or continue working in the UBLinux Live environment. True False + 10 + 5 True @@ -2956,6 +2958,7 @@ or continue working in the UBLinux Live environment. True True True + Start GParted image5