diff --git a/gresource.xml b/gresource.xml index fab2075..7c8474c 100644 --- a/gresource.xml +++ b/gresource.xml @@ -7,6 +7,7 @@ ubinstall-gtk-about.glade ubinstall-gtk-documentation.glade ubinstall-gtk-log-view.glade + ubinstall-gtk-warning.glade ubinstall-gtk.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 6442a1f..a3e0cae 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -64,6 +64,7 @@ set(DEPENDFILES ../ubinstall-gtk-about.glade ../ubinstall-gtk-documentation.glade ../ubinstall-gtk-log-view.glade + ../ubinstall-gtk-warning.glade ../gresource.xml ../ubinstall-gtk.css ../modules.csv diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 5c105c6..4b27e00 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -812,7 +812,7 @@ void config_init(){ main_config.debug_mode=0; main_config.slider_thread=0; main_config.config_save_thread=NULL; - main_config.install_thread=NULL; + main_config.install_thread=0; main_config.progress_thread=0; main_config.install_complete=0; main_config.save_done=0; @@ -820,6 +820,7 @@ void config_init(){ main_config.load_mode=-1; main_config.log_progress_buzy=0; main_config.log_end=0; + main_config.exit_accepted=0; } void on_configuration_mode_switch(GtkWidget *self); @@ -912,10 +913,10 @@ char* yon_debug_output(char *pattern,char*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; + // main_config.install_thread=(GThread*)0x1; FILE *file = fopen(progress_path,"w"); if (file) fclose(file); @@ -925,7 +926,7 @@ void *on_config_save(void *data){ gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALL_ERROR); }; free(command); - main_config.install_thread=NULL; + main_config.install_thread=0; main_config.install_complete=1; yon_debug_output("Install set to: %s\n",yon_char_from_int(main_config.install_complete)); yon_debug_output("Save state: %s\n",yon_char_from_int(main_config.save_done)); @@ -933,7 +934,6 @@ void *on_config_save(void *data){ gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETION); } main_config.config_save_thread=NULL; - } pthread_exit(NULL); } @@ -1047,7 +1047,7 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ break; case YON_PAGE_INSTALL_ERROR:{ - on_summary_log_view((GtkWidget*)NULL); + on_summary_log_view((GtkWidget*)NULL,widgets); yon_switch_page_render(widgets,7); gtk_widget_set_sensitive(widgets->BackButton,0); @@ -1150,8 +1150,14 @@ void *on_setup_system_configuration(void * data){ return NULL; } -void on_log_closed(GtkWidget *, log_window *window); -void on_log_closed(GtkWidget *, log_window *window){ +void on_log_closed(GtkWidget *, dictionary *dict); +void on_log_closed(GtkWidget *, dictionary *dict){ + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + log_window *window = yon_dictionary_get_data(dict->first->next,log_window*); + + gtk_widget_set_sensitive(widgets->ReadFullLogButton,1); + gtk_widget_set_sensitive(widgets->ReadShortLogButton,1); + free(window->command); window->Window=NULL; } @@ -1197,7 +1203,6 @@ log_window *yon_log_window_new(){ window->LogLabel = yon_gtk_builder_get_widget(builder,"LogLabel"); window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); window->ScrollToEndCheck = yon_gtk_builder_get_widget(builder,"ScrollToEndCheck"); - g_signal_connect(G_OBJECT(window->Window),"destroy",G_CALLBACK(on_log_closed),window); gtk_widget_show(window->Window); return window; } @@ -1225,16 +1230,28 @@ if (window->Window){ return 0; } -void on_process_log_view(GtkWidget *); -void on_process_log_view(GtkWidget *){ +void on_process_log_view(GtkWidget *,main_window *widgets); +void on_process_log_view(GtkWidget *,main_window *widgets){ log_window *window = yon_log_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->Window),"destroy",G_CALLBACK(on_log_closed),dict); + gtk_widget_set_sensitive(widgets->ReadFullLogButton,0); + gtk_widget_set_sensitive(widgets->ReadShortLogButton,0); yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,LOG_VIEW_LABEL,icon_path,"log_viewer"); window->command = yon_char_new(short_log_path); gdk_threads_add_timeout(500,(GSourceFunc)yon_read_log,window); } -void on_summary_log_view(GtkWidget *){ +void on_summary_log_view(GtkWidget *,main_window *widgets){ log_window *window = yon_log_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->Window),"destroy",G_CALLBACK(on_log_closed),dict); + gtk_widget_set_sensitive(widgets->ReadFullLogButton,0); + gtk_widget_set_sensitive(widgets->ReadShortLogButton,0); yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,LOG_VIEW_LABEL,icon_path,"log_viewer"); window->command = yon_char_new(full_log_path); gdk_threads_add_timeout(500,(GSourceFunc)yon_read_log,window); @@ -1677,8 +1694,14 @@ 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); + if (!main_config.install_thread){ + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_t tid; + + pthread_create(&tid,&attr,on_config_save,widgets); + memcpy(&main_config.install_thread,&tid,sizeof(pthread_t)); + } gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); } break; @@ -2070,6 +2093,37 @@ 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; +// } + /**yon_main_window_complete(main_window *widgets) * [EN] * @@ -2243,6 +2297,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"); @@ -2526,7 +2581,7 @@ int main(int argc, char *argv[]){ } gtk_init(&argc,&argv); main_window *widgets = NULL; - widgets = yon_main_window_complete((main_window*)widgets); + widgets = yon_main_window_complete(); yon_window_config_setup(GTK_WINDOW(widgets->MainWindow)); yon_window_config_load(config_path); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index ac07455..8cfba08 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -26,6 +26,7 @@ #define glade_path_log_view "/com/ublinux/ui/ubinstall-gtk-log-view.glade" #define ui_glade_path_about "/com/ublinux/ui/ubinstall-gtk-about.glade" #define ui_glade_path_documentation "/com/ublinux/ui/ubinstall-gtk-documentation.glade" +#define glade_path_confirmation "/com/ublinux/ui/ubinstall-gtk-warning.glade" #define CssPath "/com/ublinux/css/ubinstall-gtk.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) @@ -200,13 +201,14 @@ typedef struct { guint slider_thread; int install_mode; GThread *config_save_thread; - GThread *install_thread; + unsigned long install_thread; guint progress_thread; int configure_mode; int log_progress_buzy; int autologin_default; int format_default; int log_end; + int exit_accepted; } config; typedef struct { @@ -434,6 +436,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(); @@ -448,7 +456,7 @@ char* yon_debug_output(char *pattern,char*text); char *yon_save_command_prepare(char *command, char *target); void yon_interface_update(main_window *widgets); -void on_summary_log_view(GtkWidget *); +void on_summary_log_view(GtkWidget *,main_window *widgets); void on_near_installation_device_changed(GtkWidget *self, main_window *widgets); void on_toggle_button_switch_on(GtkWidget *, GtkToggleButton *toggle); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index d38a92d..42384a7 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -165,4 +165,12 @@ #define SCROLL_TO_END_LABEL _("Scroll to the end") #define ADMINISTRATOR_LABEL _("Administrator") -#define DEFAULT_LOCALES_LABEL _("English, U.S.A.; Russian, Russia") \ No newline at end of file +#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") + +#define ACCEPT_LABEL _("Accept") +#define GPARTED_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-warning.glade b/ubinstall-gtk-warning.glade new file mode 100644 index 0000000..704a8d9 --- /dev/null +++ b/ubinstall-gtk-warning.glade @@ -0,0 +1,146 @@ + + + + + + 450 + 250 + False + False + 450 + dialog-question-symbolic + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + 10 + + + True + False + + + True + False + center + 20 + 20 + dialog-question-symbolic + 6 + + + False + True + 0 + + + + + True + False + vertical + 5 + + + True + False + center + Are you sure want to exit and +interrupt installation process? + + + + True + True + 1 + + + + + + True + True + 1 + + + + + + True + True + 0 + + + + + + + True + False + + + True + False + Warning + + + + + + + + Cancel + True + True + True + image8 + + + + + + Accept + True + True + True + image9 + + + + end + 1 + + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.cancel-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.accept-symbolic + + diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index 1d9f769..2988de9 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -583,6 +583,7 @@ agreement center This program will ask you few questions and help you install UBLinux on your computer + center True @@ -1588,7 +1589,7 @@ and help you install UBLinux on your computer True - False + True Region: @@ -1614,7 +1615,7 @@ and help you install UBLinux on your computer True False - False + True False @@ -1651,7 +1652,7 @@ and help you install UBLinux on your computer True False - False + True False @@ -1699,7 +1700,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -1764,7 +1765,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -1786,7 +1787,7 @@ and help you install UBLinux on your computer True False - False + True LanguagesFilter 2 @@ -1893,7 +1894,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -1915,7 +1916,7 @@ and help you install UBLinux on your computer True False - False + True 0 Default (Regular 105-key) @@ -1943,7 +1944,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -1965,7 +1966,7 @@ and help you install UBLinux on your computer True False - False + True 0 Default (L_Alt + L_Shift) @@ -2025,7 +2026,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -2290,7 +2291,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -2338,7 +2339,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -2386,7 +2387,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -2408,7 +2409,7 @@ and help you install UBLinux on your computer True False - False + True 0 Default @@ -2453,7 +2454,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -2497,7 +2498,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -2519,7 +2520,7 @@ and help you install UBLinux on your computer True False - False + True 0 Default @@ -2575,7 +2576,7 @@ and help you install UBLinux on your computer True - False + True False True @@ -2854,6 +2855,8 @@ or continue working in the UBLinux Live environment. True False + 10 + 5 True @@ -2955,6 +2958,7 @@ or continue working in the UBLinux Live environment. True True True + Start GParted image5