From 34e0b34d918fb6ccff86d4afe67068903469b90c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 27 Jun 2024 11:45:22 +0600 Subject: [PATCH] Fixes, functionality addtions --- source/ubinstall-gtk.c | 85 ++++++++++++++++++++++++++------ source/ubinstall-gtk.h | 7 +++ ubinstall-gtk.glade | 107 +++++++++++++++++++++++++---------------- 3 files changed, 142 insertions(+), 57 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index cb38358..d0f76aa 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -155,6 +155,9 @@ 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=NULL; + main_config.progress_thread=NULL; } int yon_image_resize_from_container(GtkImage *target, GdkPixbuf *pixbuf_unscaled); @@ -240,6 +243,42 @@ gboolean on_image_slide(void *data){ return 1; } +void *on_config_save(char *command); +void *on_config_save(char *command){ + if (system(command)){}; + main_config.config_save_thread=NULL; + return NULL; +} + +void *yon_installation_start(); +void *yon_installation_start(){ + if (system(start_fast_install_command)){}; + main_config.install_thread=NULL; + g_thread_exit(NULL); + return NULL; + +} + +void *yon_installation_progress_update(void *data); +void *yon_installation_progress_update(void *data){ + main_window *widgets = (main_window*)data; + FILE *file = fopen(progress_path,"r"); + char *current = g_malloc0(4096); + if (file){ + while (main_config.install_thread){ + current = fgets(current,4096,file); + if (current[0]!='#'){ + int size; + config_str parsed = yon_char_parse(current,&size,"|"); + gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),parsed[1]); + gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress),atof(parsed[0])); + } + + } + } + return NULL; +} + void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets); void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ yon_switch_page_render(widgets,page>3?page-2:page); @@ -247,6 +286,7 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ case YON_PAGE_WELCOME: { gtk_widget_hide(widgets->CancelInstallButton); gtk_widget_set_sensitive(widgets->BackButton,0); + gtk_widget_set_sensitive(widgets->NextButton,1); } break; case YON_PAGE_LICENCE:{ gtk_widget_show(widgets->CancelInstallButton); @@ -260,10 +300,28 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ yon_image_resize_from_container(GTK_IMAGE(widgets->KeyboardImage), widgets->keyboard_original); } break; + case YON_PAGE_INSTALLATION:{ + gtk_widget_set_sensitive(widgets->BackButton,0); + g_thread_join(main_config.config_save_thread); + if (!main_config.install_thread) + main_config.install_thread = g_thread_new("InstallThread",(GThreadFunc)on_config_save,NULL); + if (!main_config.install_thread) + main_config.progress_thread = g_thread_new("ProgressThread",(GThreadFunc)yon_installation_progress_update,widgets); + + if (!main_config.slider_thread) + main_config.slider_thread = g_timeout_add(5000,(GSourceFunc)on_image_slide,widgets); + gtk_widget_show(gtk_widget_get_parent(widgets->InstallationProgress)); + } break; case YON_PAGE_OS_COMPONENTS: case YON_PAGE_SOFTWARE: yon_switch_page_render(widgets,3); break; + case YON_PAGE_USERS: + gtk_widget_set_sensitive(widgets->NextButton,1); + break; + case YON_PAGE_COMPLETION: + gtk_widget_set_sensitive(widgets->NextButton,0); + break; case YON_PAGE_INSTALL_COMMON: case YON_PAGE_INSTALL_SEPARATE: case YON_PAGE_INSTALL_SAME_PARTITION: { @@ -340,12 +398,6 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ gtk_widget_set_sensitive(widgets->BackButton,1); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),page+1); }break; - case YON_PAGE_SOFTWARE: - gtk_widget_set_sensitive(widgets->BackButton,0); - gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),page+1); - yon_config_save_simple(YON_CONFIG_BOTH,""); - yon_launch_app_with_arguments(start_fast_install_command,""); - break; case YON_PAGE_INSTALL_COMMON: { GtkTreeModel *model; GtkTreeIter iter; @@ -359,9 +411,10 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"fast"); yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_DEVICE_command,device); - gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),3); - if (!main_config.slider_thread) - main_config.slider_thread = g_timeout_add(5000,(GSourceFunc)on_image_slide,widgets); + int size=0; + config_str parameters = yon_config_get_all(&size); + main_config.config_save_thread = g_thread_new("savethread",(GThreadFunc)on_config_save,save_config_command(yon_char_parsed_to_string(parameters,size," "))); + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); }break; case YON_PAGE_INSTALL_SEPARATE: { @@ -385,9 +438,10 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_DEVICE_command,device); yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOSTART_PARTS_command,part); - gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),3); - if (!main_config.slider_thread) - main_config.slider_thread = g_timeout_add(5000,(GSourceFunc)on_image_slide,widgets); + int size=0; + config_str parameters = yon_config_get_all(&size); + main_config.config_save_thread = g_thread_new("savethread",(GThreadFunc)on_config_save,save_config_command(yon_char_parsed_to_string(parameters,size," "))); + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); } break; case YON_PAGE_INSTALL_SAME_PARTITION: @@ -412,9 +466,10 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){ yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_DEVICE_command,device); yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOSTART_PARTS_command,part); - gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),3); - if (!main_config.slider_thread) - main_config.slider_thread = g_timeout_add(5000,(GSourceFunc)on_image_slide,widgets); + int size=0; + config_str parameters = yon_config_get_all(&size); + main_config.config_save_thread = g_thread_new("savethread",(GThreadFunc)on_config_save,save_config_command(yon_char_parsed_to_string(parameters,size," "))); + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); } } } break; diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 978d76a..8fbb7bc 100644 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -71,12 +71,16 @@ NULL #define AUTOINSTALL_DEVICE "AUTOINSTALL[device]" #define AUTOSTART_PARTS "AUTOINSTALL[part]" +#define save_config_command(parameters) yon_char_append("pkexec ubconfig set [autoinstall] ",parameters) + #define AUTOINSTALL_TYPE_INSTALL_command "ubconfig --source global get autoinstall AUTOINSTALL[type_install]" #define AUTOINSTALL_DEVICE_command "ubconfig --source global get autoinstall AUTOINSTALL[device]" #define AUTOSTART_PARTS_command "ubconfig --source global get autoinstall AUTOINSTALL[part]" #define start_fast_install_command "ubinstall2 --autoinstall" +#define progress_path "/tmp/ubinstall/ubinstall_progress.log" + typedef char* string; string version_application; @@ -114,6 +118,9 @@ typedef struct { int debug_mode; guint slider_thread; int install_mode; + GThread *config_save_thread; + GThread *install_thread; + GThread *progress_thread; } config; typedef struct { diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index df93de2..4589922 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -1865,7 +1865,6 @@ and help you install UBLinux on your computer True False - gtk-missing-image True @@ -2216,7 +2215,6 @@ and help you install UBLinux on your computer True False - gtk-missing-image True @@ -5404,30 +5402,19 @@ separately into the selected partition. + True False vertical 5 - - - True - False - - - False - True - 0 - - - True False + vertical 5 - + True False - label False @@ -5436,15 +5423,39 @@ separately into the selected partition. - - button - True - True + + True + False + 5 + + + True + False + label + + + False + True + 0 + + + + + button + True + True + + + False + True + end + 1 + + False True - end 1 @@ -5452,30 +5463,18 @@ separately into the selected partition. False True - 1 - - - - - True - False - - - False - True - 2 + 0 - True False + vertical 5 - + True False - label False @@ -5484,15 +5483,39 @@ separately into the selected partition. - - button - True - True + + True + False + 5 + + + True + False + label + + + False + True + 0 + + + + + button + True + True + + + False + True + end + 1 + + False True - end 1 @@ -5500,7 +5523,7 @@ separately into the selected partition. False True - 3 + 2