From bcba8c4da47437d5ba103a2f6c61c8bd6d60f770 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 16 Jul 2024 15:36:29 +0600 Subject: [PATCH] Added log view window --- gresource.xml | 1 + source/CMakeLists.txt | 1 + source/ubinstall-gtk.c | 55 ++++++++++++++++++ source/ubinstall-gtk.h | 15 +++++ ubinstall-gtk-log-view.glade | 110 +++++++++++++++++++++++++++++++++++ ubinstall-gtk.glade | 26 +++++++-- 6 files changed, 204 insertions(+), 4 deletions(-) create mode 100644 ubinstall-gtk-log-view.glade diff --git a/gresource.xml b/gresource.xml index 9844d18..fab2075 100644 --- a/gresource.xml +++ b/gresource.xml @@ -6,6 +6,7 @@ ubinstall-gtk-keyboard.glade ubinstall-gtk-about.glade ubinstall-gtk-documentation.glade + ubinstall-gtk-log-view.glade ubinstall-gtk.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index f4b0dd8..6442a1f 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -63,6 +63,7 @@ set(DEPENDFILES ../ubinstall-gtk-keyboard.glade ../ubinstall-gtk-about.glade ../ubinstall-gtk-documentation.glade + ../ubinstall-gtk-log-view.glade ../gresource.xml ../ubinstall-gtk.css ../modules.csv diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index f34c5bf..e7caad8 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -516,6 +516,56 @@ 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){ + free(window->command); + window->Window=NULL; +} + +log_window *yon_log_window_new(); +log_window *yon_log_window_new(){ + log_window *window = malloc(sizeof(log_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_log_view); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->HeadLabel = yon_gtk_builder_get_widget(builder,"headerTopic"); + window->LogLabel = yon_gtk_builder_get_widget(builder,"LogLabel"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + g_signal_connect(G_OBJECT(window->Window),"destroy",G_CALLBACK(on_log_closed),window); + return window; +} + +gboolean yon_read_log(void *data); +gboolean yon_read_log(void *data){ +log_window *window = (log_window*)data; +if (window->Window){ + int size; + config_str parsed = yon_config_load(window->command,&size); + if (size){ + char *final = yon_char_parsed_to_string(parsed,size,""); + gtk_label_set_text(GTK_LABEL(window->LogLabel),final); + free(final); + yon_char_parsed_free(parsed,size); + } + return 1; +} +return 0; +} + +void on_process_log_view(); +void on_process_log_view(){ + log_window *window = yon_log_window_new(); + window->command = yon_char_new(short_log_path); + gdk_threads_add_timeout(500,(GSourceFunc)yon_read_log,window); +} + +void on_summary_log_view(); +void on_summary_log_view(){ + log_window *window = yon_log_window_new(); + window->command = yon_char_new(full_log_path); + gdk_threads_add_timeout(500,(GSourceFunc)yon_read_log,window); + +} + void yon_install_options_save(GtkWidget *device_tree, GtkWidget *part_tree,char *mode,main_window *widgets); void yon_install_options_save(GtkWidget *device_tree, GtkWidget *part_tree,char *mode,main_window *widgets){ GtkTreeIter iter,itar; @@ -1278,8 +1328,10 @@ main_window *yon_main_window_complete(){ widgets->InstallationProgress = yon_gtk_builder_get_widget(builder,"InstallationProgress"); widgets->InstallationLabel = yon_gtk_builder_get_widget(builder,"InstallationLabel"); + widgets->ReadShortLogButton = yon_gtk_builder_get_widget(builder,"ReadShortLogButton"); widgets->PackageInstallationProgress = yon_gtk_builder_get_widget(builder,"PackageInstallationProgress"); widgets->PackageInstallationLabel = yon_gtk_builder_get_widget(builder,"PackageInstallationLabel"); + widgets->ReadFullLogButton = yon_gtk_builder_get_widget(builder,"ReadFullLogButton"); widgets->SameInstallationFilesystemTypeCombo = yon_gtk_builder_get_widget(builder,"SameInstallationFilesystemTypeCombo"); widgets->SameInstallationFormatCheck = yon_gtk_builder_get_widget(builder,"SameInstallationFormatCheck"); @@ -1335,6 +1387,9 @@ main_window *yon_main_window_complete(){ widgets->AdditionalSoftwareList = GTK_LIST_STORE(gtk_builder_get_object(builder,"AdditionalSoftwareList")); widgets->PartitionsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"PartitionsList")); + g_signal_connect(G_OBJECT(widgets->ReadFullLogButton),"clicked",G_CALLBACK(on_summary_log_view),NULL); + g_signal_connect(G_OBJECT(widgets->ReadShortLogButton),"clicked",G_CALLBACK(on_process_log_view),NULL); + g_signal_connect(G_OBJECT(widgets->GpartedCommonButton),"clicked",G_CALLBACK(on_gparted_open),NULL); 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); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 9839992..4eff327 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -23,6 +23,7 @@ #define glade_path "/com/ublinux/ui/ubinstall-gtk.glade" #define glade_path_ubinstall_keyboard "/com/ublinux/ui/ubinstall-gtk-keyboard.glade" #define glade_path_ubinstall_language "/com/ublinux/ui/ubinstall-gtk-language.glade" +#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" @@ -130,6 +131,10 @@ NULL #define password_limits_path "/etc/security/pwquiality.conf" +#define short_log_path "/var/log/ubinstall_progress.log" + +#define full_log_path "/var/log/ubinstall.log" + typedef char* string; string version_application; @@ -271,8 +276,10 @@ typedef struct { GtkWidget *InstallationProgress; GtkWidget *InstallationLabel; + GtkWidget *ReadShortLogButton; GtkWidget *PackageInstallationProgress; GtkWidget *PackageInstallationLabel; + GtkWidget *ReadFullLogButton; GtkWidget *GpartedCommonButton; GtkWidget *GpartedNearButton; @@ -370,6 +377,14 @@ typedef struct{ GtkWidget *NoEncriptionCheck; } password_window; +typedef struct { + GtkWidget *Window; + GtkWidget *StatusBox; + GtkWidget *HeadLabel; + GtkWidget *LogLabel; + char *command; +} log_window; + void config_init(); main_window *yon_main_window_complete(); ubinstall_language_window *yon_ubinstall_language_new(); diff --git a/ubinstall-gtk-log-view.glade b/ubinstall-gtk-log-view.glade new file mode 100644 index 0000000..a09a1e4 --- /dev/null +++ b/ubinstall-gtk-log-view.glade @@ -0,0 +1,110 @@ + + + + + + + 200 + 400 + False + True + 800 + com.ublinux.ubinstall-gtk + + + True + False + vertical + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + vertical + 5 + + + True + True + in + + + True + False + + + True + False + label + 0 + 0 + + + + + + + True + True + 1 + + + + + True + True + 1 + + + + + + + True + False + True + + + True + False + Keyboard layout language + + + + + + + + True + False + 32 + com.ublinux.ubinstall-gtk + + + + + + + diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index 19ad7ab..e70d5dd 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -107,6 +107,16 @@ False com.ublinux.libublsettingsui-gtk3.trash-symbolic + + True + False + com.ublinux.ubinstall.properties-symbolic + + + True + False + com.ublinux.ubinstall.properties-symbolic + True False @@ -6844,10 +6854,14 @@ separately into the selected partition. - - button + + True True True + image16 + False @@ -6903,10 +6917,14 @@ separately into the selected partition. - - button + + True True True + image15 + False