From 4bca9c7d7b0f7533e7870dd4e1b4b814ab80f992 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 30 Aug 2024 11:30:06 +0600 Subject: [PATCH] Added warning window before exiting installer --- source/ubinstall-gtk.c | 65 +++++++++++++++++++------------------ source/ubl-strings.h | 6 +++- ubinstall-gtk-warning.glade | 32 ++++++++++-------- ubinstall-gtk.pot | 9 +++++ ubinstall-gtk_ru.po | 9 +++++ 5 files changed, 75 insertions(+), 46 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 36c2173..1533896 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -2185,36 +2185,39 @@ void on_gparted_open(){ yon_launch_app_with_arguments(open_gparted_command,NULL); } -// gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets); -// void on_exit_accepted(GtkWidget *,main_window *widgets); -// void on_exit_accepted(GtkWidget *,main_window *widgets){ -// if (main_config.install_thread){ -// pthread_cancel((pthread_t)main_config.install_thread); -// } -// main_config.exit_accepted=1; -// g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"destroy",widgets->MainWindow,NULL); -// } - -// gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ -// if (!main_config.exit_accepted){ -// if (widgets){}; -// 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->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); -// window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); -// g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_exit_accepted),widgets); -// g_signal_connect(G_OBJECT(window->AcceptButton),"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_widget_show(window->Window); - -// return 1; -// } - -// return 0; -// } +gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets); + +void on_exit_accepted(GtkWidget *,main_window *widgets); +void on_exit_accepted(GtkWidget *,main_window *widgets){ + if (main_config.install_thread){ + pthread_cancel((pthread_t)main_config.install_thread); + } + main_config.exit_accepted=1; + g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event",widgets->MainWindow,NULL); + 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)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_confirmation); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_exit_accepted),widgets); + g_signal_connect(G_OBJECT(window->AcceptButton),"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_widget_show(window->Window); + + + return 1; + } + + return 0; +} /**yon_main_window_complete(main_window *widgets) * [EN] @@ -2389,7 +2392,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"); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 357d8a7..c25745b 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -181,4 +181,8 @@ #define ADD_LAYOUT_LABEL _("Add layouts") #define REMOVE_LAYOUT_LABEL _("Remove layout") -#define CONFIGURATION_LABEL _("System configuration...") \ No newline at end of file +#define CONFIGURATION_LABEL _("System configuration...") + +#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 diff --git a/ubinstall-gtk-warning.glade b/ubinstall-gtk-warning.glade index 704a8d9..cf113d5 100644 --- a/ubinstall-gtk-warning.glade +++ b/ubinstall-gtk-warning.glade @@ -1,13 +1,25 @@ - + + + + True + False + com.ublinux.libublsettingsui-gtk3.cancel-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.accept-symbolic + - 450 - 250 + 350 + 150 False False - 450 + True + 300 dialog-question-symbolic @@ -52,8 +64,10 @@ True False center + 15 Are you sure want to exit and interrupt installation process? + 0 @@ -133,14 +147,4 @@ interrupt installation process? - - True - False - com.ublinux.libublsettingsui-gtk3.cancel-symbolic - - - True - False - com.ublinux.libublsettingsui-gtk3.accept-symbolic - diff --git a/ubinstall-gtk.pot b/ubinstall-gtk.pot index be35c77..98031f6 100644 --- a/ubinstall-gtk.pot +++ b/ubinstall-gtk.pot @@ -628,6 +628,15 @@ msgstr "" msgid "Remove layout" msgstr "" +msgid "Warning" +msgstr "" + +msgid "Accept" +msgstr "" + +msgid "Are you sure want to exit and\ninterrupt installation process?" +msgstr "" + msgid "English, U.S.A.; Russian, Russia" msgstr "" diff --git a/ubinstall-gtk_ru.po b/ubinstall-gtk_ru.po index 85fa027..36ae6c3 100644 --- a/ubinstall-gtk_ru.po +++ b/ubinstall-gtk_ru.po @@ -641,6 +641,15 @@ msgstr "Добавить раскладки" msgid "Remove layout" msgstr "Удалить раскладку" +msgid "Warning" +msgstr "Внимание" + +msgid "Accept" +msgstr "Принять" + +msgid "Are you sure want to exit and\ninterrupt installation process?" +msgstr "Вы уверены, что хотите закрыть программу и\nпрервать процесс установки?" + #: source/ubl-strings.h:140 msgid "Read installation log" msgstr "Открыть лог установки"