From fb9e980101690d3307d83f763e36830de15bd9f0 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 27 Oct 2023 09:45:20 +0600 Subject: [PATCH 01/42] Fixed unshown paths lines at log creation --- source/ubl-settings-logging.c | 67 +++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index a4d8b0e..f034761 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1276,27 +1276,6 @@ add_log_window *on_add_open(){ return window; } -void on_log_add(GtkWidget *self, main_window *widgets){ - GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); - GtkTreeIter iter; - add_log_window *window = on_add_open(); - gtk_widget_show(window->MainWindow); - gtk_widget_hide(window->StatisticsFrame); - gtk_widget_hide(window->ControlSectionBox); -} - -void on_log_path_choose(GtkWidget *self,add_log_window *window){ - GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,GTK_WINDOW(window->MainWindow),GTK_FILE_CHOOSER_ACTION_OPEN,CANCEL_LABEL,GTK_RESPONSE_CANCEL,ACCEPT_LABEL,GTK_RESPONSE_ACCEPT,NULL); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),"/"); - int response = gtk_dialog_run(GTK_DIALOG(dialog)); - if (response == GTK_RESPONSE_ACCEPT){ - GtkWidget *parent = gtk_widget_get_parent(self); - GList *list = gtk_container_get_children(GTK_CONTAINER(parent)); - gtk_entry_set_text((GtkEntry*)g_list_nth_data(list,1),gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog))); - } - gtk_widget_destroy(dialog); -} - void on_log_path_remove(GtkWidget *self, add_log_window *window){ GList *paths = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); for (int i=0;iMainWindow),GTK_FILE_CHOOSER_ACTION_OPEN,CANCEL_LABEL,GTK_RESPONSE_CANCEL,ACCEPT_LABEL,GTK_RESPONSE_ACCEPT,NULL); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),"/"); + int response = gtk_dialog_run(GTK_DIALOG(dialog)); + if (response == GTK_RESPONSE_ACCEPT){ + GtkWidget *parent = gtk_widget_get_parent(self); + GList *list = gtk_container_get_children(GTK_CONTAINER(parent)); + gtk_entry_set_text((GtkEntry*)g_list_nth_data(list,1),gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog))); + } + gtk_widget_destroy(dialog); +} + void on_log_path_append(GtkWidget *self, add_log_window *window){ GList *paths = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); GtkWidget *box = (GtkWidget*)g_list_nth_data(paths,g_list_length(paths)-1); - GList *path_widgets = gtk_container_get_children(GTK_CONTAINER(box)); - GtkWidget *entry = (GtkWidget*)g_list_nth_data(path_widgets,1); - if (gtk_widget_get_sensitive(box)&&strcmp(gtk_entry_get_text(GTK_ENTRY(entry)),"")){ + GList *path_widgets; + GtkWidget *entry; + if (box){ + path_widgets = gtk_container_get_children(GTK_CONTAINER(box)); + entry = (GtkWidget*)g_list_nth_data(path_widgets,1); + + if (!gtk_widget_get_sensitive(box)||!strcmp(gtk_entry_get_text(GTK_ENTRY(entry)),"")){ + return; + } else + gtk_widget_hide(self); + } GtkBuilder *builder = gtk_builder_new_from_resource(glade_add_path_path); - GtkWidget *box = yon_gtk_builder_get_widget(builder,"PathBox"); - GtkWidget *entry = yon_gtk_builder_get_widget(builder,"PathEntry"); + GtkWidget *box_path = yon_gtk_builder_get_widget(builder,"PathBox"); + GtkWidget *entry_path = yon_gtk_builder_get_widget(builder,"PathEntry"); GtkWidget *AppendButton = yon_gtk_builder_get_widget(builder,"AppendButton"); GtkWidget *SearchButton = yon_gtk_builder_get_widget(builder,"SearchButton"); GtkWidget *RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); @@ -1333,11 +1332,17 @@ void on_log_path_append(GtkWidget *self, add_log_window *window){ g_signal_connect(G_OBJECT(RemoveButton),"clicked",G_CALLBACK(on_log_path_remove),window); g_signal_connect(G_OBJECT(SearchButton),"clicked",G_CALLBACK(on_log_path_choose),window); gtk_widget_show(AppendButton); - gtk_widget_hide(self); - gtk_box_pack_start(GTK_BOX(window->LogPathsBox),box,0,0,5); - } - g_list_free(paths); - g_list_free(path_widgets); + gtk_box_pack_start(GTK_BOX(window->LogPathsBox),box_path,0,0,5); +} + +void on_log_add(GtkWidget *self, main_window *widgets){ + GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); + GtkTreeIter iter; + add_log_window *window = on_add_open(); + gtk_widget_show(window->MainWindow); + gtk_widget_hide(window->StatisticsFrame); + gtk_widget_hide(window->ControlSectionBox); + on_log_path_append(NULL,window); } void on_log_edit(GtkWidget *self,main_window *widgets){ -- 2.35.1 From 96b872823917c2dfbda8baa83d9381a894c4864f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 27 Oct 2023 16:42:09 +0600 Subject: [PATCH 02/42] Fixes and improvements --- Makefile | 2 + ...ux.ubl-settings-logging.check-symbolic.svg | 43 +++++ ....ubl-settings-logging.uncheck-symbolic.svg | 38 +++++ source/ubl-settings-logging.c | 155 +++++++++++++++++- source/ubl-settings-logging.h | 9 + source/ubl-utils.c | 41 ++++- source/ubl-utils.h | 4 + ubl-settings-logging-add.glade | 1 + ubl-settings-logging-filechooser.glade | 123 ++++++++++++++ ubl-settings-logging.glade | 25 ++- 10 files changed, 430 insertions(+), 11 deletions(-) create mode 100644 icons/com.ublinux.ubl-settings-logging.check-symbolic.svg create mode 100644 icons/com.ublinux.ubl-settings-logging.uncheck-symbolic.svg create mode 100644 ubl-settings-logging-filechooser.glade diff --git a/Makefile b/Makefile index e333928..d23ee79 100644 --- a/Makefile +++ b/Makefile @@ -133,6 +133,8 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.decrease-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.profile-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.edit-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.check-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.uncheck-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/${PKGNAME}/csv/" "journals_list.csv" @install -Dm644 -t "${DESTDIR}/usr/share/${PKGNAME}/csv/" "logging_services.csv" @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "${CMAKE_BUILD_DIR}/com.ublinux.${PKGNAME}${PKGIDENT}.policy" diff --git a/icons/com.ublinux.ubl-settings-logging.check-symbolic.svg b/icons/com.ublinux.ubl-settings-logging.check-symbolic.svg new file mode 100644 index 0000000..a49c2d1 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-logging.check-symbolic.svg @@ -0,0 +1,43 @@ + + + + + + + diff --git a/icons/com.ublinux.ubl-settings-logging.uncheck-symbolic.svg b/icons/com.ublinux.ubl-settings-logging.uncheck-symbolic.svg new file mode 100644 index 0000000..305416e --- /dev/null +++ b/icons/com.ublinux.ubl-settings-logging.uncheck-symbolic.svg @@ -0,0 +1,38 @@ + + + + + + diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index f034761..46baf09 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -660,6 +660,28 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind window->EndworkCommandEntry=yon_gtk_builder_get_widget(builder,"EndworkCommandEntry"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); + if (paths){ + int sz; + float finalsize=0.0; + char *temp_paths = yon_char_new(paths); + config_str parsed_paths = yon_char_parse(temp_paths,&sz,","); + free(temp_paths); + temp_paths=NULL; + for (int i=0;iLogSizeLabel),yon_char_append(fin,yon_size_get_letter_from_int(sizenumber))); + + } dictionary *dict=NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"dialog",dialog); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); @@ -1144,6 +1166,11 @@ journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ window->LowerTimeButton=yon_gtk_builder_get_widget(builder,"LowerTimeButton"); window->headerTopic=yon_gtk_builder_get_widget(builder,"headerTopic"); + { + int sz; + config_str logsize = yon_config_load(journald_size_command,&sz); + gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),logsize[0]); + } gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); @@ -1251,7 +1278,23 @@ void on_journald_open(GtkWidget *self, main_window *widgets){ // Log adding menu -add_log_window *on_add_open(){ +void on_log_save(GtkWidget *self, dictionary *dict){ + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + add_log_window *window = yon_dictionary_get_data(dict->first->next,add_log_window*); + GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); + char *pathse=NULL; + for (int i=0;ilist,&iter); + gtk_list_store_set(widgets->list,&iter,1,pathse,-1); + on_close_subwindow(self); +} + +add_log_window *on_add_open(main_window *widgets){ add_log_window *window = malloc(sizeof(add_log_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_add_path); window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); @@ -1271,8 +1314,11 @@ add_log_window *on_add_open(){ window->ControlSectionBox=yon_gtk_builder_get_widget(builder,"ControlSectionBox"); window->LogPathsBox=yon_gtk_builder_get_widget(builder,"LogPathsBox"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); + 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->CancelButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_log_save),dict); return window; } @@ -1338,7 +1384,7 @@ void on_log_path_append(GtkWidget *self, add_log_window *window){ void on_log_add(GtkWidget *self, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; - add_log_window *window = on_add_open(); + add_log_window *window = on_add_open(widgets); gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); gtk_widget_hide(window->ControlSectionBox); @@ -1349,7 +1395,7 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ - add_log_window *window = on_add_open(); + add_log_window *window = on_add_open(widgets); gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); char *name; @@ -1420,6 +1466,98 @@ void on_service_edit(GtkWidget *self,main_window *widgets){ } } +void on_main_window_tree_selection_changed(GtkWidget *self,main_window *widgets){ + GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ + gtk_widget_set_sensitive(widgets->AddButton,1); + gtk_widget_set_sensitive(widgets->RemoveButton,1); + gtk_widget_set_sensitive(widgets->InspectButton,1); + gtk_widget_set_sensitive(widgets->ConfigureButton,1); + } else { + gtk_widget_set_sensitive(widgets->AddButton,0); + gtk_widget_set_sensitive(widgets->RemoveButton,0); + gtk_widget_set_sensitive(widgets->InspectButton,0); + gtk_widget_set_sensitive(widgets->ConfigureButton,0); + } +} + +void on_main_window_services_tree_selection_changed(GtkWidget *self,main_window *widgets){ + GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ServicesTree)),&model,&iter)){ + gboolean is_active; + gboolean is_enabled; + char *name; + gtk_tree_model_get(model,&iter,0,&is_active,1,&is_enabled,2,&name,-1); + if (is_active){ + gtk_widget_set_sensitive(widgets->ServicesEditButton,1); + gtk_widget_set_sensitive(widgets->ServicesEnableDisableButton,1); + gtk_widget_set_sensitive(widgets->ServicesStartStopButton,1); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesStartStopButton))),stop_icon_name,GTK_ICON_SIZE_BUTTON); + } else { + gtk_widget_set_sensitive(widgets->ServicesEditButton,0); + gtk_widget_set_sensitive(widgets->ServicesEnableDisableButton,1); + gtk_widget_set_sensitive(widgets->ServicesStartStopButton,1); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesStartStopButton))),start_icon_name,GTK_ICON_SIZE_BUTTON); + } + if (is_enabled){ + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesEnableDisableButton))),disable_icon_name,GTK_ICON_SIZE_BUTTON); + } else { + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->ServicesEnableDisableButton))),enable_icon_name,GTK_ICON_SIZE_BUTTON); + + } + if (!strcmp(name,"journald")){ + gtk_widget_set_sensitive(widgets->ServicesEnableDisableButton,0); + gtk_widget_set_sensitive(widgets->ServicesStartStopButton,0); + } + } else { + gtk_widget_set_sensitive(widgets->ServicesEditButton,0); + gtk_widget_set_sensitive(widgets->ServicesEnableDisableButton,0); + gtk_widget_set_sensitive(widgets->ServicesStartStopButton,0); + } +} + +void on_start_stop_clicked(GtkButton *self, main_window *widgets){ + GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ServicesTree)),&model,&iter)){ + char *start_command; + char *stop_command; + gboolean is_started; + gtk_tree_model_get(model,&iter,0,&is_started,5,&start_command,6,&stop_command,-1); + if (is_started){ + yon_launch(stop_command); + gtk_list_store_set(widgets->ServicesList,&iter,0,0,-1); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),start_icon_name,GTK_ICON_SIZE_BUTTON); + } else { + yon_launch(start_command); + gtk_list_store_set(widgets->ServicesList,&iter,0,1,-1); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),stop_icon_name,GTK_ICON_SIZE_BUTTON); + } + } +} + +void on_enable_disable_clicked(GtkButton *self, main_window *widgets){ + GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ServicesTree)),&model,&iter)){ + char *start_command; + char *stop_command; + gboolean is_started; + gtk_tree_model_get(model,&iter,1,&is_started,7,&start_command,8,&stop_command,-1); + if (is_started){ + yon_launch(stop_command); + gtk_list_store_set(widgets->ServicesList,&iter,1,0,-1); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),start_icon_name,GTK_ICON_SIZE_BUTTON); + } else { + yon_launch(start_command); + gtk_list_store_set(widgets->ServicesList,&iter,1,1,-1); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),stop_icon_name,GTK_ICON_SIZE_BUTTON); + } + } +} + // standard functions void config_init(){ @@ -1478,6 +1616,8 @@ main_window *setup_window(){ widgets->RemoveButton = yon_gtk_builder_get_widget(builder,"MainRemoveButton"); widgets->Notebook = yon_gtk_builder_get_widget(builder,"MainNotebook"); widgets->ServicesEditButton = yon_gtk_builder_get_widget(builder,"ServicesEditButton"); + widgets->ServicesStartStopButton = yon_gtk_builder_get_widget(builder,"ServicesStartStopButton"); + widgets->ServicesEnableDisableButton = yon_gtk_builder_get_widget(builder,"ServicesEnableDisableButton"); widgets->ServicesTree = yon_gtk_builder_get_widget(builder,"ServicesTree"); widgets->list = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); widgets->ServicesList = GTK_LIST_STORE(gtk_builder_get_object(builder,"ServicesList")); @@ -1523,7 +1663,7 @@ main_window *setup_window(){ services[i]=yon_char_divide_search(services[i],"\n",-1); config_str log = yon_char_parse(services[i],&log_size,";"); gtk_list_store_append(widgets->ServicesList,&iter); - gtk_list_store_set(widgets->ServicesList,&iter,0,1,1,1,2,log[0],3,log[1],-1); + gtk_list_store_set(widgets->ServicesList,&iter,0,1,1,1,2,log[0],3,log[1],4,log[2],5,log[3],6,log[4],7,log[5],8,log[6],-1); } } config_str dirs = yon_config_load(logrotate_config_command,&dirs_size); @@ -1579,7 +1719,12 @@ main_window *setup_window(){ g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(on_load_global),NULL); g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_load_local),NULL); + + g_signal_connect(G_OBJECT(widgets->MainTree),"cursor-changed",G_CALLBACK(on_main_window_tree_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->ServicesTree),"cursor-changed",G_CALLBACK(on_main_window_services_tree_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->ServicesStartStopButton),"clicked",G_CALLBACK(on_start_stop_clicked),widgets); + g_signal_connect(G_OBJECT(widgets->ServicesEnableDisableButton),"clicked",G_CALLBACK(on_enable_disable_clicked),widgets); gtk_widget_show(widgets->Window); return widgets; diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index b560b95..50fd25e 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -31,6 +31,8 @@ #define journals_list_path "/usr/share/ubl-settings-logging/csv/journals_list.csv" #define services_list_path "/usr/share/ubl-settings-logging/csv/logging_services.csv" #define logrotate_config_command "ls /etc/logrotate.d/ |sed -e 's/ */\\n/g'" +#define journald_size_command "journalctl --disk-usage | grep -oE \"[0-9]{1,}.[0-9]{1,}[A-Z]\"" +#define logrotate_size_command(paths) yon_char_unite("du ",paths," |grep -oE '^[0-9]{1,}'",NULL) #define logrotate_config_path "/etc/logrotate.d/" #define LocalePath "/usr/share/locale" @@ -45,6 +47,11 @@ #define get_journal_output_kernel_command "journalctl --no-pager -k" #define get_journal_output_prioritied_command "journalctl --no-pager -p err..alert" +#define start_icon_name "com.ublinux.ubl-settings-logging.play-symbolic" +#define stop_icon_name "com.ublinux.ubl-settings-logging.stop-symbolic" +#define enable_icon_name "com.ublinux.ubl-settings-logging.check-symbolic" +#define disable_icon_name "com.ublinux.ubl-settings-logging.uncheck-symbolic" + #define yon_add_space_if_exists(string) yon_char_is_empty(string) ? "" : yon_char_append(",",string) typedef char* string; string version_application; @@ -113,6 +120,8 @@ typedef struct { GtkWidget *Notebook; GtkWidget *ServicesTree; GtkWidget *ServicesEditButton; + GtkWidget *ServicesStartStopButton; + GtkWidget *ServicesEnableDisableButton; GtkListStore *list; GtkListStore *ServicesList; // Custom diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 29373da..a50de19 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -607,12 +607,32 @@ char *yon_char_from_int(int int_to_convert) return ch; } +/**yon_char_from_float(int int_to_convert) + * [EN] + * converts float to char*. + * + * [RU] + * Конвертирует float в char* + */ +char *yon_char_from_float(float int_to_convert) +{ + int i = 1; + float convert_check = (float)int_to_convert; + for (i = 1; convert_check >= 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = g_malloc0(i * sizeof(char) + 1); + sprintf(ch, "%f", int_to_convert); + return ch; +} + /**yon_char_from_long(int int_to_convert) * [EN] - * converts int to char*. + * converts long to char*. * * [RU] - * Конвертирует int в char* + * Конвертирует long в char* */ char *yon_char_from_long(long int_to_convert) { @@ -867,6 +887,23 @@ config_str yon_ubl_get_all_users(int *user_size){ // parsing functions +/** yon_size_convert_automatic(int bytes, int *size) + * [EN] + * + * [RU] + * +*/ +float yon_size_convert_automatic(int bytes, int *size){ + float byte_float=bytes; + for (*size=-1;byte_float>1024;*size=*size+1){ + byte_float=byte_float/1024; + } + if (*size==-1) { + *size=0; + byte_float=byte_float/1024; + } + return byte_float; +} apps *yon_apps_scan_and_parse_desktops(int *sizef) { diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 0ed953b..79dcf00 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -141,6 +141,8 @@ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); char *yon_char_from_int(int int_to_convert); +char *yon_char_from_float(float int_to_convert); + char *yon_char_from_long(long int_to_convert); char *yon_char_replace(char *source, char *find, char*replace); @@ -173,6 +175,8 @@ config_str yon_ubl_get_all_users(int *user_size); // parsing functions +float yon_size_convert_automatic(int bytes, int *size); + config_str philos_list_user(int* size); apps *yon_apps_scan_and_parse_desktops(int *sizef); diff --git a/ubl-settings-logging-add.glade b/ubl-settings-logging-add.glade index f7d8eec..e9a1efe 100644 --- a/ubl-settings-logging-add.glade +++ b/ubl-settings-logging-add.glade @@ -50,6 +50,7 @@ 450 + 550 False True com.ublinux.ubl-settings-logging diff --git a/ubl-settings-logging-filechooser.glade b/ubl-settings-logging-filechooser.glade new file mode 100644 index 0000000..226d754 --- /dev/null +++ b/ubl-settings-logging-filechooser.glade @@ -0,0 +1,123 @@ + + + + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + + 800 + 600 + False + com.ublinux.ubl-settings-logging + dialog + True + True + + + False + vertical + 2 + + + False + end + + + Choose directory instead of file + True + True + False + True + + + True + True + 0 + + + + + Cancel + True + True + True + image1 + + + True + True + 1 + + + + + Accept + True + True + True + image2 + + + True + True + 2 + + + + + False + False + 0 + + + + + + + True + False + True + + + True + False + 5 + 5 + 5 + 5 + 2 + Logs and events + + + + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 6 + 32 + com.ublinux.ubl-settings-logging + + + + + + + diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index 3f720ec..4599617 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -207,6 +207,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + + + + + + + + + @@ -232,12 +242,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False - com.ublinux.ubl-settings-logging.stop-symbolic + com.ublinux.ubl-settings-logging.play-symbolic True False - com.ublinux.ubl-settings-logging.play-symbolic + com.ublinux.ubl-settings-logging.check-symbolic True @@ -682,6 +692,7 @@ translated and supported by community. True + False True True Inspect log @@ -699,6 +710,7 @@ translated and supported by community. True + False True True Configure log @@ -716,6 +728,7 @@ translated and supported by community. True + False True True Add log @@ -733,6 +746,7 @@ translated and supported by community. True + False True True Remove log @@ -856,8 +870,9 @@ translated and supported by community. vertical 5 - + True + False True True Stop service @@ -873,8 +888,9 @@ translated and supported by community. - + True + False True True Start service @@ -892,6 +908,7 @@ translated and supported by community. True + False True True Configure service -- 2.35.1 From 9146443d09a9b99cc73a24f92e9fb15241292543 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 27 Oct 2023 18:03:49 +0600 Subject: [PATCH 03/42] csv fixes --- journals_list.csv | 1 + logging_services.csv | 3 ++- source/ubl-settings-logging.c | 13 +++++++------ ubl-settings-logging.glade | 15 ++++++++++++--- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/journals_list.csv b/journals_list.csv index c939ad6..8d3533b 100644 --- a/journals_list.csv +++ b/journals_list.csv @@ -1,3 +1,4 @@ +Service_Name;Path_Log;Service_Description Acpid;/var/log/acpid;Журнал работы и обращений к Acpid Apache2;/var/log/apache2/error.log,/var/log/apache2/access.log;Журнал работы и обращений к веб-серверу Audit;/var/log/audit/audit.log;Журнал аудита (audit) diff --git a/logging_services.csv b/logging_services.csv index e9d43a8..74f8d0c 100644 --- a/logging_services.csv +++ b/logging_services.csv @@ -1,4 +1,5 @@ -journald;Системный журнал событий;systemctl start;systemctl start systemd-journald.service;systemctl stop systemd-journald.service;ubconfig set config SERVICESSTART+=systemd-journald.service;ubconfig set config SERVICESSTART-=systemd-journald.service;systemctl status systemd-journald.service +Service_Name;Service_Description;command_start;command_stop;command_enable;command_disable;command_status +journald;Системный журнал событий;systemctl start systemd-journald.service;systemctl stop systemd-journald.service;ubconfig set config SERVICESSTART+=systemd-journald.service;ubconfig set config SERVICESSTART-=systemd-journald.service;systemctl status systemd-journald.service logrotate;Служба ротации системных журналов событий;systemctl start logrotate.service;systemctl stop logrotate.service;ubconfig set config SERVICESSTART+=logrotate.service;ubconfig set config SERVICESSTART-=logrotate.service;systemctl status logrotate.service #metalog;Системный журнал событий;systemctl start metalog.service;systemctl stop metalog.service;ubconfig set config SERVICESSTART+=metalog.service;ubconfig set config SERVICESSTART-=metalog.service;systemctl status metalog.service #syslog-ng;Сервис сбора сообщений системных событий активных сетевых устройств;systemctl start syslog-ng.service;systemctl stop syslog-ng.service;ubconfig set config SERVICESSTART+=syslog-ng.service;ubconfig set config SERVICESSTART-=syslog-ng.service;systemctl status syslog-ng.service \ No newline at end of file diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 46baf09..ae512d5 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1525,7 +1525,7 @@ void on_start_stop_clicked(GtkButton *self, main_window *widgets){ char *start_command; char *stop_command; gboolean is_started; - gtk_tree_model_get(model,&iter,0,&is_started,5,&start_command,6,&stop_command,-1); + gtk_tree_model_get(model,&iter,0,&is_started,4,&start_command,5,&stop_command,-1); if (is_started){ yon_launch(stop_command); gtk_list_store_set(widgets->ServicesList,&iter,0,0,-1); @@ -1545,15 +1545,15 @@ void on_enable_disable_clicked(GtkButton *self, main_window *widgets){ char *start_command; char *stop_command; gboolean is_started; - gtk_tree_model_get(model,&iter,1,&is_started,7,&start_command,8,&stop_command,-1); + gtk_tree_model_get(model,&iter,1,&is_started,6,&start_command,7,&stop_command,-1); if (is_started){ yon_launch(stop_command); gtk_list_store_set(widgets->ServicesList,&iter,1,0,-1); - gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),start_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),enable_icon_name,GTK_ICON_SIZE_BUTTON); } else { yon_launch(start_command); gtk_list_store_set(widgets->ServicesList,&iter,1,1,-1); - gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),stop_icon_name,GTK_ICON_SIZE_BUTTON); + gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(self)),disable_icon_name,GTK_ICON_SIZE_BUTTON); } } } @@ -1648,7 +1648,7 @@ main_window *setup_window(){ char *cparams=""; GtkTreeIter iter; config_str journals = yon_file_open(journals_list_path,&size); - for (int i=0;ilist,&iter,0,log[0],1,log[1],2,log[2],3,-1,4,-1,5,-1,6,-1,7,-1,-1); } config_str services = yon_file_open(services_list_path,&service_size); - for (int i=0;iServicesList,&iter); + // yon_config_load gtk_list_store_set(widgets->ServicesList,&iter,0,1,1,1,2,log[0],3,log[1],4,log[2],5,log[3],6,log[4],7,log[5],8,log[6],-1); } } diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index 4599617..98912f6 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -786,7 +786,7 @@ translated and supported by community. True fixed - 30 + 50 Log/Journal @@ -803,7 +803,8 @@ translated and supported by community. True fixed - 30 + 130 + 50 Path @@ -820,7 +821,7 @@ translated and supported by community. True fixed - 30 + 50 Description @@ -947,6 +948,8 @@ translated and supported by community. True fixed + 50 + 50 Status @@ -960,6 +963,8 @@ translated and supported by community. True fixed + 70 + 70 Autostart @@ -973,6 +978,8 @@ translated and supported by community. True fixed + 130 + 50 Service @@ -986,6 +993,8 @@ translated and supported by community. True fixed + 130 + 50 Description -- 2.35.1 From e4dc86024f2343fda328d789531020ebf1237151 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 30 Oct 2023 10:25:58 +0600 Subject: [PATCH 04/42] Localisation updates --- journals_list.csv | 24 +++++++-------- logging_services.csv | 8 ++--- source/ubl-settings-logging.c | 4 +-- ubl-settings-logging.glade | 2 +- ubl-settings-logging.pot | 45 ++++++++++++++++++++++++++++ ubl-settings-logging_ru.po | 56 +++++++++++++++++++++++++++++++---- 6 files changed, 115 insertions(+), 24 deletions(-) diff --git a/journals_list.csv b/journals_list.csv index 8d3533b..37454f0 100644 --- a/journals_list.csv +++ b/journals_list.csv @@ -1,13 +1,13 @@ Service_Name;Path_Log;Service_Description -Acpid;/var/log/acpid;Журнал работы и обращений к Acpid -Apache2;/var/log/apache2/error.log,/var/log/apache2/access.log;Журнал работы и обращений к веб-серверу -Audit;/var/log/audit/audit.log;Журнал аудита (audit) -Authlog;/var/log/auth.log;Журнал процедур авторизации -Cron;/var/log/syslog;Журнал работы планировщика заданий (cron) -CUPS;/var/log/cups/access_log,/var/log/cups/page_log,/var/log/cups/cups-pdf_log;Журнал работы и обращений к серверу печати (cups) -Daemonlog;/var/log/daemon.log;Журнал работы и обращения к службам системы -Samba;/var/log/samba/log.smbd,/var/log/samba/log.localhost,/var/log/samba/log.127.0.0.1,/var/log/samba/log.nmbd;Журнал работы и обращения к Samba -Postfix;/var/log/mail.log,/var/log/mail.info,/var/log/mail.warn,/var/log/mail.err;Журнал почтового сервера Postfix -Syslog;/var/log/syslog;Системный журнал -Xorg;/var/log/Xorg.0.log;Журнал работы дисплейного сервера X.org -Xsession;~/.xsession-errors;Журнал сеансов графической системы X \ No newline at end of file +Acpid;/var/log/acpid;Log of work and requests to Acpid +Apache2;/var/log/apache2/error.log,/var/log/apache2/access.log;Log of work and requests to the web server +Audit;/var/log/audit/audit.log;Audit log +Authlog;/var/log/auth.log;Log of authorization procedures +Cron;/var/log/syslog;Job scheduler log (cron) +CUPS;/var/log/cups/access_log,/var/log/cups/page_log,/var/log/cups/cups-pdf_log;Log of work and calls to the print server (cups) +Daemonlog;/var/log/daemon.log;Log of operation and access to system services +Samba;/var/log/samba/log.smbd,/var/log/samba/log.localhost,/var/log/samba/log.127.0.0.1,/var/log/samba/log.nmbd;Log of work and access to Samba +Postfix;/var/log/mail.log,/var/log/mail.info,/var/log/mail.warn,/var/log/mail.err;Postfix mail server log +Syslog;/var/log/syslog;System log +Xorg;/var/log/Xorg.0.log;X.org display server log +Xsession;~/.xsession-errors;Graphics X session log \ No newline at end of file diff --git a/logging_services.csv b/logging_services.csv index 74f8d0c..c64afa1 100644 --- a/logging_services.csv +++ b/logging_services.csv @@ -1,5 +1,5 @@ Service_Name;Service_Description;command_start;command_stop;command_enable;command_disable;command_status -journald;Системный журнал событий;systemctl start systemd-journald.service;systemctl stop systemd-journald.service;ubconfig set config SERVICESSTART+=systemd-journald.service;ubconfig set config SERVICESSTART-=systemd-journald.service;systemctl status systemd-journald.service -logrotate;Служба ротации системных журналов событий;systemctl start logrotate.service;systemctl stop logrotate.service;ubconfig set config SERVICESSTART+=logrotate.service;ubconfig set config SERVICESSTART-=logrotate.service;systemctl status logrotate.service -#metalog;Системный журнал событий;systemctl start metalog.service;systemctl stop metalog.service;ubconfig set config SERVICESSTART+=metalog.service;ubconfig set config SERVICESSTART-=metalog.service;systemctl status metalog.service -#syslog-ng;Сервис сбора сообщений системных событий активных сетевых устройств;systemctl start syslog-ng.service;systemctl stop syslog-ng.service;ubconfig set config SERVICESSTART+=syslog-ng.service;ubconfig set config SERVICESSTART-=syslog-ng.service;systemctl status syslog-ng.service \ No newline at end of file +journald;System event log;systemctl start systemd-journald.service;systemctl stop systemd-journald.service;ubconfig set config SERVICESSTART+=systemd-journald.service;ubconfig set config SERVICESSTART-=systemd-journald.service;systemctl status systemd-journald.service +logrotate;System event log rotation service;systemctl start logrotate.service;systemctl stop logrotate.service;ubconfig set config SERVICESSTART+=logrotate.service;ubconfig set config SERVICESSTART-=logrotate.service;systemctl status logrotate.service +#metalog;System event log;systemctl start metalog.service;systemctl stop metalog.service;ubconfig set config SERVICESSTART+=metalog.service;ubconfig set config SERVICESSTART-=metalog.service;systemctl status metalog.service +#syslog-ng;Service for collecting messages from system events of active network devices;systemctl start syslog-ng.service;systemctl stop syslog-ng.service;ubconfig set config SERVICESSTART+=syslog-ng.service;ubconfig set config SERVICESSTART-=syslog-ng.service;systemctl status syslog-ng.service \ No newline at end of file diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index ae512d5..a788af8 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1654,7 +1654,7 @@ main_window *setup_window(){ config_str log = yon_char_parse(journals[i],&log_size,";"); log[1] = yon_char_replace(log[1],",","\n"); gtk_list_store_append(widgets->list,&iter); - gtk_list_store_set(widgets->list,&iter,0,log[0],1,log[1],2,log[2],3,-1,4,-1,5,-1,6,-1,7,-1,-1); + gtk_list_store_set(widgets->list,&iter,0,log[0],1,log[1],2,_(log[2]),3,-1,4,-1,5,-1,6,-1,7,-1,-1); } config_str services = yon_file_open(services_list_path,&service_size); for (int i=1;iServicesList,&iter); // yon_config_load - gtk_list_store_set(widgets->ServicesList,&iter,0,1,1,1,2,log[0],3,log[1],4,log[2],5,log[3],6,log[4],7,log[5],8,log[6],-1); + gtk_list_store_set(widgets->ServicesList,&iter,0,1,1,1,2,log[0],3,_(log[1]),4,log[2],5,log[3],6,log[4],7,log[5],8,log[6],-1); } } config_str dirs = yon_config_load(logrotate_config_command,&dirs_size); diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index 98912f6..b86e205 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -478,7 +478,7 @@ translated and supported by community. journald /var/log/journal/ - System events journal + System event log 0 0 0 diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 4f011cd..f9b2a68 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -682,3 +682,48 @@ msgstr "" #: source/ubl-strings.h:183 msgid "Log file" msgstr "" + +msgid "System event log rotation service" +msgstr "" + +msgid "System event log" +msgstr "" + +msgid "Service for collecting messages from system events of active network devices" +msgstr "" + +msgid "Log of work and requests to Acpid" +msgstr "" + +msgid "Log of work and requests to the web server" +msgstr "" + +msgid "Audit log" +msgstr "" + +msgid "Log of authorization procedures" +msgstr "" + +msgid "Job scheduler log (cron)" +msgstr "" + +msgid "Log of work and calls to the print server (cups)" +msgstr "" + +msgid "Log of operation and access to system services" +msgstr "" + +msgid "Log of work and access to Samba" +msgstr "" + +msgid "Postfix mail server log" +msgstr "" + +msgid "System log" +msgstr "" + +msgid "X.org display server log" +msgstr "" + +msgid "Graphics X session log" +msgstr "" diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index ddc3ef2..e3e13b7 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -378,24 +378,24 @@ msgstr "Гб" #: source/ubl-strings.h:97 msgid "Minutes" -msgstr "Минута" +msgstr "Минут" #: source/ubl-strings.h:98 msgid "Hours" -msgstr "Час" +msgstr "Часов" #: source/ubl-strings.h:99 msgid "Days" -msgstr "День" +msgstr "Дней" #: source/ubl-strings.h:100 #, fuzzy msgid "Weeks" -msgstr "Неделя" +msgstr "Недель" #: source/ubl-strings.h:101 msgid "Years" -msgstr "Год" +msgstr "Лет" #: source/ubl-strings.h:104 msgid "Log/Journal:" @@ -694,3 +694,49 @@ msgstr "Управление:" #: source/ubl-strings.h:183 msgid "Log file" msgstr "Файл лога" + +msgid "System event log rotation service" +msgstr "Служба ротации системных журналов событий" + +msgid "System event log" +msgstr "Системный журнал событий" + +msgid "" +"Service for collecting messages from system events of active network devices" +msgstr "Сервис сбора сообщений системных событий активных сетевых устройств" + +msgid "Log of work and requests to Acpid" +msgstr "Журнал работы и обращений к Acpid" + +msgid "Log of work and requests to the web server" +msgstr "Журнал работы и обращений к веб-серверу" + +msgid "Audit log" +msgstr "Журнал аудита (audit)" + +msgid "Log of authorization procedures" +msgstr "Журнал процедур авторизации" + +msgid "Job scheduler log (cron)" +msgstr "Журнал работы планировщика заданий (cron)" + +msgid "Log of work and calls to the print server (cups)" +msgstr "Журнал работы и обращений к серверу печати (cups)" + +msgid "Log of operation and access to system services" +msgstr "Журнал работы и обращения к службам системы" + +msgid "Log of work and access to Samba" +msgstr "Журнал работы и обращения к Samba" + +msgid "Postfix mail server log" +msgstr "Журнал почтового сервера Postfix" + +msgid "System log" +msgstr "Системный журнал" + +msgid "X.org display server log" +msgstr "Журнал работы дисплейного сервера X.org" + +msgid "Graphics X session log" +msgstr "Журнал сеансов графической системы X" -- 2.35.1 From 340e96e87c56b671625d53eda2d388a28cdd9807 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 30 Oct 2023 11:45:47 +0600 Subject: [PATCH 05/42] Added columns size saving --- source/ubl-settings-logging.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index a788af8..2e42cc8 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1700,7 +1700,15 @@ main_window *setup_window(){ cparams=""; } - + GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree)); + for (int i=0; iServicesTree)); + for (int i=0; iHeadInfoLabel,"head-text","label",YON_TYPE_STRING); -- 2.35.1 From ba4c4db8444a570eb606dd2e0291b9ce76065f21 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 30 Oct 2023 12:06:17 +0600 Subject: [PATCH 06/42] Fixed journald renaming --- ubl-settings-logging-journald.glade | 1 + 1 file changed, 1 insertion(+) diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index 43c4722..0ce2cab 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -166,6 +166,7 @@ True + False True journald -- 2.35.1 From 806b988285116f20321426c8df0892708e6ccc16 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 30 Oct 2023 17:29:25 +0600 Subject: [PATCH 07/42] Logrotate configuration improvements --- source/ubl-settings-logging.c | 98 +++++++++++++++++++--------- ubl-settings-logging-journald.glade | 1 - ubl-settings-logging-logrotate.glade | 1 + ubl-settings-logging-rules.glade | 4 +- 4 files changed, 68 insertions(+), 36 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 2e42cc8..90f4eb6 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -377,6 +377,35 @@ void on_logrotate_configuration_path_remove(GtkWidget *self, logrotate_configure } } +void on_combo_activate_first(GtkComboBox *self, GtkWidget *target){ + if (gtk_combo_box_get_active(self)==1) gtk_widget_set_sensitive(target,1); + else gtk_widget_set_sensitive(target,0); + +} + +void on_combo_activate_second(GtkComboBox *self, GtkWidget *target){ + if (gtk_combo_box_get_active(self)==2) gtk_widget_set_sensitive(target,1); + else gtk_widget_set_sensitive(target,0); + +} + +void on_file_amount_checked(GtkToggleButton *self, logrotate_configure_window *window){ + if (gtk_toggle_button_get_active(self)==1){ + gtk_widget_set_sensitive(window->FileAmountCombo,1); + gtk_widget_set_sensitive(window->FileAmountSpin,1); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->FileAmountCombo))==2){ + gtk_widget_set_sensitive(window->FileAmountButton,1); + gtk_widget_set_sensitive(window->FileAmountEntry,1); + } + } else { + gtk_widget_set_sensitive(window->FileAmountButton,0); + gtk_widget_set_sensitive(window->FileAmountEntry,0); + gtk_widget_set_sensitive(window->FileAmountSpin,0); + gtk_widget_set_sensitive(window->FileAmountCombo,0); + + } +} + void on_logrotate_save(GtkWidget *self, dictionary *dict){ logrotate_window *dialog = yon_dictionary_get_data(dict->first,logrotate_window*); logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*); @@ -578,8 +607,8 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ } char *commandline = yon_char_unite(period,yon_add_space_if_exists(size),yon_add_space_if_exists(rotate_count),yon_add_space_if_exists(olddir),yon_add_space_if_exists(su),yon_add_space_if_exists(missingok),yon_add_space_if_exists(ifempty),yon_add_space_if_exists(notifempty),yon_add_space_if_exists(minage),yon_add_space_if_exists(maxage),yon_add_space_if_exists(minsize),yon_add_space_if_exists(maxsize),yon_add_space_if_exists(create),yon_add_space_if_exists(copytruncate),yon_add_space_if_exists(compress),yon_add_space_if_exists(delaycompress),yon_add_space_if_exists(extension),yon_add_space_if_exists(dateext),yon_add_space_if_exists(start),yon_add_space_if_exists(mail),yon_add_space_if_exists(mailfirst),yon_add_space_if_exists(sharedscripts),yon_add_space_if_exists(firstaction),yon_add_space_if_exists(lastaction),yon_add_space_if_exists(prerotate),yon_add_space_if_exists(postrotate),yon_add_space_if_exists(preremove),yon_add_space_if_exists(endscript),NULL); - if (commandline[0]==' '){ - free(yon_char_divide_search(commandline," ",-1)); + if (commandline[0]==','){ + free(yon_char_divide_search(commandline,",",-1)); } if(!yon_char_is_empty(paths)){ GtkTreeIter iter; @@ -699,11 +728,8 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind g_signal_connect(G_OBJECT(window->JournalMaxSizeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->JournalMaxSizeCombo); g_signal_connect(G_OBJECT(window->JournalMaxSizeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->JournalMaxSizeSpin); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountSpin); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountCombo); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountEntry); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountButton); - + g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(on_file_amount_checked),window); + g_signal_connect(G_OBJECT(window->DoNotRotateYoungerCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DoNotRotateYoungerSpin); g_signal_connect(G_OBJECT(window->DeleteOlderCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeleteOlderSpin); @@ -714,11 +740,19 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeSpin); g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeCombo); - g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateLogUserCombo); - g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateGroupCombo); - g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateLogEntry); - g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateLogButton); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(on_combo_activate_second),window->CreateLogUserCombo); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(on_combo_activate_second),window->CreateGroupCombo); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(on_combo_activate_second),window->CreateLogEntry); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(on_combo_activate_second),window->CreateLogButton); + g_signal_connect(G_OBJECT(window->FileAmountCombo),"changed",G_CALLBACK(on_combo_activate_second),window->FileAmountButton); + g_signal_connect(G_OBJECT(window->FileAmountCombo),"changed",G_CALLBACK(on_combo_activate_second),window->FileAmountEntry); + g_signal_connect(G_OBJECT(window->CompressionCombo),"changed",G_CALLBACK(on_combo_activate_first),window->QueueCombo); + g_signal_connect(G_OBJECT(window->SaveOriginalCombo),"changed",G_CALLBACK(on_combo_activate_first),window->SaveOriginalEntry); + g_signal_connect(G_OBJECT(window->OldNumberCombo),"changed",G_CALLBACK(on_combo_activate_first),window->OldNumberEntry); + + g_signal_connect(G_OBJECT(window->EmailCombo),"changed",G_CALLBACK(on_combo_activate_first),window->EmailEntry); + g_signal_connect(G_OBJECT(window->EmailCombo),"changed",G_CALLBACK(on_combo_activate_first),window->EmailContentsCombo); int usize=0; config_str users = yon_ubl_get_all_users(&usize); yon_gtk_combo_box_fill(window->CreateLogUserCombo,users,usize); @@ -751,22 +785,13 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),3); }else if (!strcmp(parsed[i],"yearly")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),4); - }else if (!strcmp(parsed[i],"size")){ - int sizemod = yon_size_get_int_from_letter(parsed[i][strlen(parsed[i])-1]); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->JournalMaxSizeSpin),atol(parsed[i])); - gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalMaxSizeCombo),sizemod); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->JournalMaxSizeCheck),1); - }else if (!strcmp(parsed[i],"rotate")){ - char *value = strstr(parsed[i]," ")+1; - gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->FileAmountSpin),atol(value)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck),1); }else if (!strcmp(parsed[i],"olddir")){ char *value = strstr(parsed[i]," ")+1; gtk_entry_set_text(GTK_ENTRY(window->FileAmountEntry),value); gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),1); }else if (!strcmp(parsed[i],"noolddir")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),2); - }else if (!strcmp(parsed[i],"su")){ + }else if (strstr(parsed[i],"su")){ char *value = strstr(parsed[i]," ")+1; char *nvalue = yon_char_divide_search(value," ",-1); int us = yon_gtk_combo_box_text_find(window->RotationAtUserCombo,nvalue); @@ -781,20 +806,20 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),1); }else if (!strcmp(parsed[i],"notifempty")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),2); - }else if (!strcmp(parsed[i],"minage")){ + }else if (strstr(parsed[i],"minage")){ char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DoNotRotateYoungerSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DoNotRotateYoungerCheck),1); - }else if (!strcmp(parsed[i],"maxage")){ + }else if (strstr(parsed[i],"maxage")){ char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeleteOlderSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeleteOlderCheck),1); - }else if (!strcmp(parsed[i],"minsize")){ + }else if (strstr(parsed[i],"minsize")){ char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotateSizeMaxAfterTimeSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxAfterTimeCheck),1); gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotateSizeMaxAfterTimeCombo),yon_size_get_int_from_letter(value[strlen(value)-1])); - }else if (!strcmp(parsed[i],"maxsize")){ + }else if (strstr(parsed[i],"maxsize")){ char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotateSizeMaxBeforeTimeSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxBeforeTimeCheck),1); @@ -803,6 +828,11 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind // // }else if (!strcmp(parsed[i],"nocreate")){ // + }else if (strstr(parsed[i],"size")){ + int sizemod = yon_size_get_int_from_letter(parsed[i][strlen(parsed[i])-1]); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->JournalMaxSizeSpin),atol(parsed[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalMaxSizeCombo),sizemod); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->JournalMaxSizeCheck),1); }else if (!strcmp(parsed[i],"copytruncate")){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CutCheck),1); }else if (!strcmp(parsed[i],"compress")){ @@ -814,17 +844,17 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind }else if (!strcmp(parsed[i],"nodelaycompress")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->QueueCombo),2); - }else if (!strcmp(parsed[i],"extension")){ + }else if (strstr(parsed[i],"extension")){ char *value = strstr(parsed[i]," ")+1; gtk_combo_box_set_active(GTK_COMBO_BOX(window->SaveOriginalCombo),1); gtk_entry_set_text(GTK_ENTRY(window->SaveOriginalEntry),value); }else if (!strcmp(parsed[i],"dateext")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->AddDateCombo),1); - }else if (!strcmp(parsed[i],"start")){ + }else if (strstr(parsed[i],"start")){ char *value = strstr(parsed[i]," ")+1; gtk_combo_box_set_active(GTK_COMBO_BOX(window->OldNumberCombo),1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->OldNumberEntry),atol(value)); - }else if (!strcmp(parsed[i],"mail")){ + }else if (strstr(parsed[i],"mail")){ char *value = strstr(parsed[i]," ")+1; gtk_entry_set_text(GTK_ENTRY(window->EmailEntry),value); gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),1); @@ -836,19 +866,19 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailContentsCombo),2); }else if (!strcmp(parsed[i],"sharedscripts")){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SharedScenariosCheck),1); - }else if (!strcmp(parsed[i],"firstaction")){ + }else if (strstr(parsed[i],"firstaction")){ char *value = parsed[i+1]; gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value); i++; - }else if (!strcmp(parsed[i],"lastaction")){ + }else if (strstr(parsed[i],"lastaction")){ char *value = parsed[i+1]; gtk_entry_set_text(GTK_ENTRY(window->CommandAfterOnceEntry),value); i++; - }else if (!strcmp(parsed[i],"prerotate")){ + }else if (strstr(parsed[i],"prerotate")){ char *value = parsed[i+1]; gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeEntry),value); i++; - }else if (!strcmp(parsed[i],"postrotate")){ + }else if (strstr(parsed[i],"postrotate")){ char *value = parsed[i+1]; gtk_entry_set_text(GTK_ENTRY(window->CommandAfterEntry),value); i++; @@ -856,6 +886,10 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind // char *value = parsed[i+1]; // gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value); // i++; + }else if (strstr(parsed[i],"rotate")){ + char *value = strstr(parsed[i]," ")+1; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->FileAmountSpin),atol(value)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck),1); }else if (!strcmp(parsed[i],"endscript")){ } } diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index 0ce2cab..43c4722 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -166,7 +166,6 @@ True - False True journald diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 637791d..b1f96a6 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -1570,6 +1570,7 @@ True + False True adjustment10 diff --git a/ubl-settings-logging-rules.glade b/ubl-settings-logging-rules.glade index c3fd858..6d5f82a 100644 --- a/ubl-settings-logging-rules.glade +++ b/ubl-settings-logging-rules.glade @@ -14,8 +14,6 @@ False - 550 - 450 com.ublinux.ubl-settings-logging @@ -284,7 +282,7 @@ False - False + True True 1 -- 2.35.1 From b74e308983e269d5cc62321ca340e34dc3378b41 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 30 Oct 2023 17:47:48 +0600 Subject: [PATCH 08/42] Logrotate tab window buttons lock if nothing were chosen --- source/ubl-settings-logging.c | 27 ++++++++++++++++++++++ ubl-settings-logging-logrotate-table.glade | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 90f4eb6..aa1b895 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -996,6 +996,30 @@ void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict){ // Logrotate tab window +void on_logrotate_tab_selection_changed(GtkWidget *self, logrotate_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model,&iter)){ + gtk_widget_set_sensitive(window->AddButton,1); + gtk_widget_set_sensitive(window->RemoveButton,1); + gtk_widget_set_sensitive(window->ConfigureButton,1); + } else { + gtk_widget_set_sensitive(window->AddButton,0); + gtk_widget_set_sensitive(window->RemoveButton,0); + gtk_widget_set_sensitive(window->ConfigureButton,0); + } +} + +void on_logrotate_applications_tab_selection_changed(GtkWidget *self, logrotate_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_apps_list); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->AppsMainTree)),&model,&iter)){ + gtk_widget_set_sensitive(window->AppsConfigureButton,1); + } else { + gtk_widget_set_sensitive(window->AppsConfigureButton,0); + } +} + void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ logrotate_window *window = malloc(sizeof(logrotate_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_table_path); @@ -1019,6 +1043,9 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ g_signal_connect(G_OBJECT(window->RemoveButton),"clicked",G_CALLBACK(on_logrotate_remove),window); g_signal_connect(G_OBJECT(window->ConfigureButton),"clicked",G_CALLBACK(on_logrotate_edit),window); g_signal_connect(G_OBJECT(window->AppsConfigureButton),"clicked",G_CALLBACK(on_logrotate_apps_configure),window); + + g_signal_connect(G_OBJECT(window->MainTree),"cursor-changed",G_CALLBACK(on_logrotate_tab_selection_changed),window); + g_signal_connect(G_OBJECT(window->AppsMainTree),"cursor-changed",G_CALLBACK(on_logrotate_applications_tab_selection_changed),window); gtk_widget_show(window->Window); } diff --git a/ubl-settings-logging-logrotate-table.glade b/ubl-settings-logging-logrotate-table.glade index 7177eaa..b02c0fa 100644 --- a/ubl-settings-logging-logrotate-table.glade +++ b/ubl-settings-logging-logrotate-table.glade @@ -126,6 +126,7 @@ True + False True True image5 @@ -142,6 +143,7 @@ True + False True True image4 @@ -158,6 +160,7 @@ True + False True True image3 @@ -264,6 +267,7 @@ True + False True True image8 -- 2.35.1 From fa048f8067586b32bfbbbf47ec4ac210c9bad67f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 31 Oct 2023 16:34:27 +0600 Subject: [PATCH 09/42] Added filechooser and rules button interaction for logrotate window --- gresource.xml | 1 + source/CMakeLists.txt | 1 + source/ubl-settings-logging.c | 156 ++++++++ source/ubl-settings-logging.h | 24 +- ubl-settings-logging-filechooser.glade | 1 + ubl-settings-logging-rules.glade | 510 +++++++++++++------------ ubl-settings-logging.glade | 8 +- 7 files changed, 443 insertions(+), 258 deletions(-) diff --git a/gresource.xml b/gresource.xml index f7a9968..1f26a40 100644 --- a/gresource.xml +++ b/gresource.xml @@ -8,6 +8,7 @@ ubl-settings-logging-logrotate.glade ubl-settings-logging-journald.glade ubl-settings-logging-rules.glade + ubl-settings-logging-filechooser.glade ubl-settings-logging-logrotate-table.glade diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 24aa362..3edbf50 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -43,6 +43,7 @@ set(DEPENDFILES ../ubl-settings-logging-journald.glade ../ubl-settings-logging-logrotate.glade ../ubl-settings-logging-logrotate-table.glade + ../ubl-settings-logging-filechooser.glade ../gresource.xml ../ubl-settings-logging-banner.png ../ubl-settings-logging.css diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index aa1b895..88b0d51 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -406,6 +406,157 @@ void on_file_amount_checked(GtkToggleButton *self, logrotate_configure_window *w } } +void on_rules_accept(GtkWidget *self, dictionary *dict){ + GtkEntry *entry = yon_dictionary_get_data(dict->first,GtkEntry*); + logrotate_rules_window *window = yon_dictionary_get_data(dict->first->next,logrotate_rules_window*); + int owner_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserReadCheck)); + int owner_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserWriteCheck)); + int owner_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserExecuteCheck)); + + int group_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupReadCheck)); + int group_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupWriteCheck)); + int group_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupExecuteCheck)); + + int public_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicReadCheck)); + int public_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicWriteCheck)); + int public_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicExecuteCheck)); + int owner = owner_read&&owner_write&&owner_exec? 7 : \ + owner_read&&!owner_write&&!owner_exec ? 4 : \ + !owner_read&&owner_write&&!owner_exec ? 2 : \ + !owner_read&&!owner_write&&owner_exec ? 1 : \ + owner_read&&owner_write&&!owner_exec ? 6 : \ + owner_read&&!owner_write&&owner_exec ? 5 : \ + !owner_read&&owner_write&&owner_exec ? 3 : \ + 0; + int group = group_read&&group_write&&group_exec? 7 : \ + group_read&&!group_write&&!group_exec ? 4 : \ + !group_read&&group_write&&!group_exec ? 2 : \ + !group_read&&!group_write&&group_exec ? 1 : \ + group_read&&group_write&&!group_exec ? 6 : \ + group_read&&!group_write&&group_exec ? 5 : \ + !group_read&&group_write&&group_exec ? 3 : \ + 0; + int public = public_read&&public_write&&public_exec? 7 : \ + public_read&&!public_write&&!public_exec ? 4 : \ + !public_read&&public_write&&!public_exec ? 2 : \ + !public_read&&!public_write&&public_exec ? 1 : \ + public_read&&public_write&&!public_exec ? 6 : \ + public_read&&!public_write&&public_exec ? 5 : \ + !public_read&&public_write&&public_exec ? 3 : \ + 0; + gtk_entry_set_text(entry,yon_char_unite(yon_char_from_int(owner),yon_char_from_int(group),yon_char_from_int(public),NULL)); + gtk_widget_destroy(window->Window); +} + +void on_rules_update(GtkWidget *self, logrotate_rules_window *window){ + int owner_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserReadCheck)); + int owner_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserWriteCheck)); + int owner_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserExecuteCheck)); + + int group_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupReadCheck)); + int group_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupWriteCheck)); + int group_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupExecuteCheck)); + + int public_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicReadCheck)); + int public_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicWriteCheck)); + int public_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicExecuteCheck)); + int owner = owner_read&&owner_write&&owner_exec? 7 : \ + owner_read&&!owner_write&&!owner_exec ? 4 : \ + !owner_read&&owner_write&&!owner_exec ? 2 : \ + !owner_read&&!owner_write&&owner_exec ? 1 : \ + owner_read&&owner_write&&!owner_exec ? 6 : \ + owner_read&&!owner_write&&owner_exec ? 5 : \ + !owner_read&&owner_write&&owner_exec ? 3 : \ + 0; + int group = group_read&&group_write&&group_exec? 7 : \ + group_read&&!group_write&&!group_exec ? 4 : \ + !group_read&&group_write&&!group_exec ? 2 : \ + !group_read&&!group_write&&group_exec ? 1 : \ + group_read&&group_write&&!group_exec ? 6 : \ + group_read&&!group_write&&group_exec ? 5 : \ + !group_read&&group_write&&group_exec ? 3 : \ + 0; + int public = public_read&&public_write&&public_exec? 7 : \ + public_read&&!public_write&&!public_exec ? 4 : \ + !public_read&&public_write&&!public_exec ? 2 : \ + !public_read&&!public_write&&public_exec ? 1 : \ + public_read&&public_write&&!public_exec ? 6 : \ + public_read&&!public_write&&public_exec ? 5 : \ + !public_read&&public_write&&public_exec ? 3 : \ + 0; + gtk_entry_set_text(GTK_ENTRY(window->FinalEntry),yon_char_unite(yon_char_from_int(owner),yon_char_from_int(group),yon_char_from_int(public),NULL)); +} + +void on_rules_open(GtkWidget *self,GtkEntry *entry){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_rules_path); + logrotate_rules_window *window = malloc(sizeof(logrotate_rules_window)); + window->Window=yon_gtk_builder_get_widget(builder,"MainWindow"); + window->UserReadCheck=yon_gtk_builder_get_widget(builder,"UserReadCheck"); + window->UserWriteCheck=yon_gtk_builder_get_widget(builder,"UserWriteCheck"); + window->UserExecuteCheck=yon_gtk_builder_get_widget(builder,"UserExecuteCheck"); + window->GroupReadCheck=yon_gtk_builder_get_widget(builder,"GroupReadCheck"); + window->GroupWriteCheck=yon_gtk_builder_get_widget(builder,"GroupWriteCheck"); + window->GroupExecuteCheck=yon_gtk_builder_get_widget(builder,"GroupExecuteCheck"); + window->PublicReadCheck=yon_gtk_builder_get_widget(builder,"PublicReadCheck"); + window->PublicWriteCheck=yon_gtk_builder_get_widget(builder,"PublicWriteCheck"); + window->PublicExecuteCheck=yon_gtk_builder_get_widget(builder,"PublicExecuteCheck"); + window->FinalEntry=yon_gtk_builder_get_widget(builder,"FinalEntry"); + window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); + window->SaveButton=yon_gtk_builder_get_widget(builder,"SaveButton"); + gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); + dictionary *dict = NULL; + yon_dictionary_add_or_create_if_exists_with_data(dict,"entry",entry); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_rules_accept),dict); + + g_signal_connect(G_OBJECT(window->UserReadCheck),"toggled",G_CALLBACK(on_rules_update),window); + g_signal_connect(G_OBJECT(window->UserWriteCheck),"toggled",G_CALLBACK(on_rules_update),window); + g_signal_connect(G_OBJECT(window->UserExecuteCheck),"toggled",G_CALLBACK(on_rules_update),window); + + g_signal_connect(G_OBJECT(window->GroupReadCheck),"toggled",G_CALLBACK(on_rules_update),window); + g_signal_connect(G_OBJECT(window->GroupWriteCheck),"toggled",G_CALLBACK(on_rules_update),window); + g_signal_connect(G_OBJECT(window->GroupExecuteCheck),"toggled",G_CALLBACK(on_rules_update),window); + + g_signal_connect(G_OBJECT(window->PublicReadCheck),"toggled",G_CALLBACK(on_rules_update),window); + g_signal_connect(G_OBJECT(window->PublicWriteCheck),"toggled",G_CALLBACK(on_rules_update),window); + g_signal_connect(G_OBJECT(window->PublicExecuteCheck),"toggled",G_CALLBACK(on_rules_update),window); + gtk_widget_show(window->Window); +} + +void on_filechooser_mode_switch(GtkWidget *self, logrotate_filechooser_window *window){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->FileOrDirCheck))){ + gtk_file_chooser_set_action(GTK_FILE_CHOOSER(window->FileChooser),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); + } + gtk_file_chooser_set_action(GTK_FILE_CHOOSER(window->FileChooser),GTK_FILE_CHOOSER_ACTION_OPEN); +} + +void on_filechooser_save(GtkWidget *self, dictionary *dict){ + logrotate_configure_window *window = yon_dictionary_get_data(dict->first,logrotate_configure_window*); + logrotate_filechooser_window *dialog = yon_dictionary_get_data(dict->first->next,logrotate_filechooser_window*); + char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->FileChooser)); + gtk_entry_set_text(GTK_ENTRY(window->FileAmountEntry),filename); + gtk_widget_destroy(dialog->FileChooser); +} + +void on_filechooser_open(GtkWidget *self, logrotate_configure_window *window){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_filechooser_path); + logrotate_filechooser_window *dialog = malloc(sizeof(logrotate_filechooser_window)); + dialog->FileChooser = yon_gtk_builder_get_widget(builder,"FileChooser"); + dialog->FileOrDirCheck = yon_gtk_builder_get_widget(builder,"FileOrDirCheck"); + dialog->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + dialog->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + + dictionary *dict = NULL; + gtk_window_set_title(GTK_WINDOW(dialog->FileChooser),TITLE_LABEL); + yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); + yon_dictionary_add_or_create_if_exists_with_data(dict,"dialog",dialog); + g_signal_connect(G_OBJECT(dialog->FileOrDirCheck),"toggled",G_CALLBACK(on_filechooser_mode_switch),dialog); + g_signal_connect(G_OBJECT(dialog->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(dialog->AcceptButton),"clicked",G_CALLBACK(on_filechooser_save),dict); + gtk_widget_show(dialog->FileChooser); +} + void on_logrotate_save(GtkWidget *self, dictionary *dict){ logrotate_window *dialog = yon_dictionary_get_data(dict->first,logrotate_window*); logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*); @@ -753,6 +904,11 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind g_signal_connect(G_OBJECT(window->EmailCombo),"changed",G_CALLBACK(on_combo_activate_first),window->EmailEntry); g_signal_connect(G_OBJECT(window->EmailCombo),"changed",G_CALLBACK(on_combo_activate_first),window->EmailContentsCombo); + + g_signal_connect(G_OBJECT(window->FileAmountButton),"clicked",G_CALLBACK(on_filechooser_open),window); + + g_signal_connect(G_OBJECT(window->CreateLogButton),"clicked",G_CALLBACK(on_rules_open),window->CreateLogEntry); + int usize=0; config_str users = yon_ubl_get_all_users(&usize); yon_gtk_combo_box_fill(window->CreateLogUserCombo,users,usize); diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index 50fd25e..d34a001 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -25,6 +25,8 @@ #define glade_journald_path "/com/ublinux/ui/ubl-settings-logging-journald.glade" #define glade_logrotate_path "/com/ublinux/ui/ubl-settings-logging-logrotate.glade" #define glade_logrotate_table_path "/com/ublinux/ui/ubl-settings-logging-logrotate-table.glade" +#define glade_rules_path "/com/ublinux/ui/ubl-settings-logging-rules.glade" +#define glade_filechooser_path "/com/ublinux/ui/ubl-settings-logging-filechooser.glade" #define banner_path "/com/ublinux/images/ubl-settings-logging-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-logging.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) @@ -204,12 +206,26 @@ char *journal_paths; typedef struct { GtkWidget *Window; - GtkWidget *MainTree; - GtkWidget *ConfiguraButton; + GtkWidget *UserReadCheck; + GtkWidget *UserWriteCheck; + GtkWidget *UserExecuteCheck; + GtkWidget *GroupReadCheck; + GtkWidget *GroupWriteCheck; + GtkWidget *GroupExecuteCheck; + GtkWidget *PublicReadCheck; + GtkWidget *PublicWriteCheck; + GtkWidget *PublicExecuteCheck; + GtkWidget *FinalEntry; GtkWidget *CancelButton; GtkWidget *SaveButton; - GtkListStore *list; -} logrotate_tab_window; +} logrotate_rules_window; + +typedef struct { + GtkWidget *FileChooser; + GtkWidget *FileOrDirCheck; + GtkWidget *CancelButton; + GtkWidget *AcceptButton; +} logrotate_filechooser_window; typedef struct { GtkWidget *Window; diff --git a/ubl-settings-logging-filechooser.glade b/ubl-settings-logging-filechooser.glade index 226d754..28ddce1 100644 --- a/ubl-settings-logging-filechooser.glade +++ b/ubl-settings-logging-filechooser.glade @@ -16,6 +16,7 @@ 800 600 False + True com.ublinux.ubl-settings-logging dialog True diff --git a/ubl-settings-logging-rules.glade b/ubl-settings-logging-rules.glade index 6d5f82a..3b1f097 100644 --- a/ubl-settings-logging-rules.glade +++ b/ubl-settings-logging-rules.glade @@ -12,328 +12,342 @@ False emblem-ok-symbolic - + False + True com.ublinux.ubl-settings-logging - - - True + dialog + + False - 5 - 5 - 5 - 5 vertical - 5 - - - True + 2 + + False - 0.019999999552965164 - in + end - + + Cancel True - False - 5 - 5 - 5 - - - True - False - 5 - - - Read - True - True - False - True - - - False - True - 0 - - - - - Write - True - True - False - True - - - False - True - 1 - - - - - Execute - True - True - False - True - - - False - True - 2 - - - - + True + True + image1 + + False + True + 0 + - - + + + Accept True - False - Owner rules + True + True + image2 + + False + True + 1 + False - True + False 0 - + True False - 0.019999999552965164 - in + 5 + 5 + 5 + 5 + vertical + 5 - + True False - 5 - 5 - 5 + 0.019999999552965164 + in - + True False - 5 + 5 + 5 + 5 - - Read + True - True - False - True + False + 5 + + + Read + True + True + False + True + + + False + True + 0 + + + + + Write + True + True + False + True + + + False + True + 1 + + + + + Execute + True + True + False + True + + + False + True + 2 + + - - False - True - 0 - - - - - Write - True - True - False - True - - - False - True - 1 - - - - - Execute - True - True - False - True - - - False - True - 2 - + + + True + False + Owner rules + + + + False + True + 0 + - - - True - False - Group rules - - - - - False - True - 1 - - - - - True - False - 0.019999999552965164 - in - + True False - 5 - 5 - 5 + 0.019999999552965164 + in - + True False - 5 - - - Read - True - True - False - True - - - False - True - 0 - - - - - Write - True - True - False - True - - - False - True - 1 - - + 5 + 5 + 5 - - Execute + True - True - False - True + False + 5 + + + Read + True + True + False + True + + + False + True + 0 + + + + + Write + True + True + False + True + + + False + True + 1 + + + + + Execute + True + True + False + True + + + False + True + 2 + + - - False - True - 2 - - - - - - True - False - Public rules - - - - - False - True - 2 - - - - - True - False - 5 - - - True - False - Value: + + + True + False + Group rules + + False True - 0 - - - - - True - False - - - True - True 1 - - - False - True - 3 - - - - - True - False - end - 5 - - Cancel + True - True - True - image1 + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + Read + True + True + False + True + + + False + True + 0 + + + + + Write + True + True + False + True + + + False + True + 1 + + + + + Execute + True + True + False + True + + + False + True + 2 + + + + + + + + + True + False + Public rules + + False True - 0 + 2 - - Accept + True - True - True - image2 + False + 5 + + + True + False + Value: + + + False + True + 0 + + + + + True + False + 3 + 3 + digits + + + True + True + 1 + + False True - 1 + 3 False True - end - 4 + 1 diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index b86e205..ee39e3d 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -946,10 +946,8 @@ translated and supported by community. - True fixed - 50 - 50 + 30 Status @@ -961,10 +959,8 @@ translated and supported by community. - True fixed - 70 - 70 + 30 Autostart -- 2.35.1 From 17279efa796fafdb32a0d97ed6d2cf9b8f53dbf5 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 1 Nov 2023 15:48:07 +0600 Subject: [PATCH 10/42] Help text update --- source/ubl-strings.h | 2 +- ubl-settings-logging.pot | 4 ++++ ubl-settings-logging_ru.po | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 4c834c2..626766e 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -1,5 +1,5 @@ #define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL) -#define HELP_LABEL yon_char_unite(_("ubl-settings-loggign version:")," ", version_application,"\n",_("Logs and events"),"\n",_("Usage:"), " ubl-settings-loggign ",_("[OPTIONS]"),"\n",_("Options:"),"\n\t--help, -h\t\t\t",_("Show this help"),"\n\t--version, -V\t\t\t",_("Show package version"),"\n\t--lock-help\t\t\t",_("Lock this help menu"),"\n\t--lock-save\t\t\t",_("Lock configuration saving"),"\n\t--lock-save-local\t\t",_("Lock local configration saving"),"\n\t--lock-save-global\t\t",_("Lock global configration saving"),"\n\t--lock-load-global\t\t",_("Lock global configration loading"),"\n",NULL) +#define HELP_LABEL yon_char_unite(_("ubl-settings-loggign version:")," ", version_application,"\n",_("Logs and events"),"\n",_("Usage:"), " ubl-settings-loggign ",_("[OPTIONS]"),"\n",_("Options:"),"\n\t--help, -h\t\t\t",_("Show this help"),"\n\t--version, -V\t\t\t",_("Show package version"),"\n\t--lock-help\t\t\t",_("Lock this help menu"),"\n\t--lock-save\t\t\t",_("Lock configuration saving"),"\n\t--lock-save-local\t\t",_("Lock local configration saving"),"\n\t--lock-save-global\t\t",_("Lock global configration saving"),"\n\t--lock-load-global\t\t",_("Lock global configration loading"),"\n\t--clear-config\t\t",_("Clear application configuration"),"\n",NULL) #define TITLE_LABEL _("Logs and events") #define TITLE_INFO_LABEL _("Logs and events configuration") diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index f9b2a68..9d37848 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -69,6 +69,10 @@ msgstr "" msgid "Lock global configration loading" msgstr "" +#: source/ubl-strings.h:2 +msgid "Clear application configuration" +msgstr "" + #: source/ubl-strings.h:5 msgid "Logs and events configuration" msgstr "" diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index e3e13b7..62c5c8c 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -69,6 +69,10 @@ msgstr "Блокировка сохранения глобальной конф msgid "Lock global configration loading" msgstr "Блокировка загрузки глобальной конфигурации" +#: source/ubl-strings.h:2 +msgid "Clear application configuration" +msgstr "Очистить конфигурацию приложения" + #: source/ubl-strings.h:5 msgid "Logs and events configuration" msgstr "Настройка и просмотр логов и журналов событий системы" -- 2.35.1 From ddce68870fa813ece9bac0278dbb8d324a8d5e9c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 1 Nov 2023 15:48:30 +0600 Subject: [PATCH 11/42] Inspector reworks --- source/CMakeLists.txt | 10 +-- source/ubl-settings-logging.c | 111 ++++++++++++++++----------- source/ubl-settings-logging.h | 15 ++-- source/ubl-utils.c | 12 ++- source/ubl-utils.h | 3 + ubl-settings-logging-inspector.glade | 48 +++++++----- ubl-settings-logging-logrotate.glade | 1 - ubl-settings-logging.glade | 4 +- 8 files changed, 124 insertions(+), 80 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 3edbf50..87c4d28 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -8,10 +8,10 @@ include_directories(${GTK_INCLUDE_DIRS}) link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) -#pkg_check_modules(VTE291 REQUIRED vte-2.91) -#include_directories(${VTE291_INCLUDE_DIRS}) -#link_directories(${VTE291_LIBRARY_DIRS}) -#add_definitions(${VTE291_CFLAGS_OTHER}) +pkg_check_modules(VTE291 REQUIRED vte-2.91) +include_directories(${VTE291_INCLUDE_DIRS}) +link_directories(${VTE291_LIBRARY_DIRS}) +add_definitions(${VTE291_CFLAGS_OTHER}) find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) @@ -89,7 +89,7 @@ set(SOURCE_FILES set(LIBRARIES ${GTK_LIBRARIES} ${WEBKIT_LIBRARIES} -# ${VTE291_LIBRARIES} + ${VTE291_LIBRARIES} pthread) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 88b0d51..76bafe6 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -125,19 +125,20 @@ int yon_size_get_int_from_letter(char size){ //functions - void update_loaded_logrotate(){ int size=0; gtk_list_store_clear(main_config.logrotate_list); GtkTreeIter iter; config_str loaded = yon_config_get_all_by_key("LOGROTATE[",&size); + char *desc; for (int i=0;itextbuffer1,&titer,&titerend); - gtk_text_buffer_delete(window->textbuffer1,&titer,&titerend); config_str output; if (!strcmp(window->journal_name,"journald")){ if (self==window->UpdateButton){ switch(window->last_mode){ - case 0: output = yon_config_load(get_journal_output_command, &size); + case 0: + yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_command,NULL,NULL); break; - case 1: output = yon_config_load(get_journal_output_since_boot_command, &size); + case 1: + yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_since_boot_command,NULL,NULL); break; - case 2: output = yon_config_load(get_journal_output_followed_command, &size); + case 2: + yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_followed_command,NULL,NULL); break; - case 3: output = yon_config_load(get_journal_output_kernel_command, &size); + case 3: + yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_kernel_command,NULL,NULL); break; - case 4: output = yon_config_load(get_journal_output_prioritied_command, &size); + case 4: + yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_prioritied_command,NULL,NULL); break; } } if (self==window->ShowSinceBootButton){ window->last_mode=1; - output = yon_config_load(get_journal_output_since_boot_command, &size); + yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_since_boot_command,NULL,NULL); } if (self==window->NewMessagesButton){ window->last_mode=2; - output = yon_config_load(get_journal_output_followed_command, &size); + yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_followed_command,NULL,NULL); } if (self==window->ShowKernelButton){ window->last_mode=3; - output = yon_config_load(get_journal_output_kernel_command, &size); + yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_kernel_command,NULL,NULL); } if (self==window->ShowPriorityButton){ window->last_mode=4; - output = yon_config_load(get_journal_output_prioritied_command, &size); - } - if (output){ - for (int i=0;itextbuffer1,&titer); - gtk_text_buffer_insert(window->textbuffer1,&titer,output[i],-1); - } - gtk_text_buffer_get_end_iter(window->textbuffer1,&titer); - gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(window->LoggingTextView),&titer,0.25,0,1,0); + yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_prioritied_command,NULL,NULL); } + // if (output){ + // for (int i=0;itextbuffer1,&titer); + // gtk_text_buffer_insert(window->textbuffer1,&titer,output[i],-1); + // } + // gtk_text_buffer_get_end_iter(window->textbuffer1,&titer); + // gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(window->LoggingTerminal),&titer,0.25,0,1,0); + // } } else { - window->journal_paths = yon_char_replace(window->journal_paths,"\n"," "); - output = yon_config_load(yon_char_unite("cat ",window->journal_paths,NULL),&size); - for (int i=0;itextbuffer1,&titer); - gtk_text_buffer_insert(window->textbuffer1,&titer,output[i],-1); - } - gtk_text_buffer_get_end_iter(window->textbuffer1,&titer); - gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(window->LoggingTextView),&titer,0.25,0,1,0); + // window->journal_paths = yon_char_replace(window->journal_paths,"\n"," "); + // output = yon_config_load(yon_char_unite("cat ",window->journal_paths,NULL),&size); + // for (int i=0;itextbuffer1,&titer); + // gtk_text_buffer_insert(window->textbuffer1,&titer,output[i],-1); + // } + // gtk_text_buffer_get_end_iter(window->textbuffer1,&titer); + // gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(window->LoggingTerminal),&titer,0.25,0,1,0); } } void on_inspector_open(GtkWidget *self, main_window *widgets){ inspector_window *window = malloc(sizeof(inspector_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_inspector_path); - window->textbuffer1=GTK_TEXT_BUFFER(gtk_builder_get_object(builder,"textbuffer1")); window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); window->ShowSinceBootButton=yon_gtk_builder_get_widget(builder,"ShowSinceBootButton"); window->NewMessagesButton=yon_gtk_builder_get_widget(builder,"NewMessagesButton"); window->ShowKernelButton=yon_gtk_builder_get_widget(builder,"ShowKernelButton"); window->ShowPriorityButton=yon_gtk_builder_get_widget(builder,"ShowPriorityButton"); window->UpdateButton=yon_gtk_builder_get_widget(builder,"UpdateButton"); - window->LoggingTextView=yon_gtk_builder_get_widget(builder,"LoggingTextView"); + window->LoggingTerminal=yon_gtk_builder_get_widget(builder,"LoggingTerminal"); window->JournalActionsBox=yon_gtk_builder_get_widget(builder,"JournalActionsBox"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); @@ -745,15 +748,27 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ char *after = (char*)gtk_entry_get_text(GTK_ENTRY(window->CommandAfterEntry)); char *endwork = (char*)gtk_entry_get_text(GTK_ENTRY(window->EndworkCommandEntry)); sharedscripts = "sharedscripts"; - if (!yon_char_is_empty(before_once)) + if (!yon_char_is_empty(before_once)) { + before_once = yon_char_replace(before_once,"\"","=--"); + before_once = yon_char_replace(before_once,"=--","\\\""); firstaction = yon_char_append("firstaction ",before_once); - if (!yon_char_is_empty(after_once)) + } + if (!yon_char_is_empty(after_once)) { + after_once = yon_char_replace(after_once,"\"","=--"); + after_once = yon_char_replace(after_once,"=--","\\\""); lastaction = yon_char_append("lastaction ",after_once); - if (!yon_char_is_empty(before)) + } + if (!yon_char_is_empty(before)) { + before = yon_char_replace(before,"\"","=--"); + before = yon_char_replace(before,"=--","\\\""); prerotate = yon_char_append("prerotate ",before); - if (!yon_char_is_empty(after)) + } + if (!yon_char_is_empty(after)) { + after = yon_char_replace(after,"\"","=--"); + after = yon_char_replace(after,"=--","\\\""); postrotate = yon_char_append("postrotate ",after); - if (!yon_char_is_empty(endwork)) + } + if (!yon_char_is_empty(firstaction)||!yon_char_is_empty(after_once)||!yon_char_is_empty(before)||!yon_char_is_empty(after)) endscript = yon_char_append("endscript ",endwork); } @@ -762,8 +777,13 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ free(yon_char_divide_search(commandline,",",-1)); } if(!yon_char_is_empty(paths)){ + if(window->paths){ + yon_config_remove_by_key(window->paths); + yon_window_config_erase_custom_parameter(window->paths,"description"); + } GtkTreeIter iter; yon_config_register(LOGROTATE(paths),"logging",commandline); + yon_window_config_add_custom_parameter(paths,"description",yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry))),YON_TYPE_STRING); GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); if (!dialog||!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->MainTree)),&model,&iter)){ gtk_list_store_append(main_config.logrotate_list,&iter); @@ -839,6 +859,7 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind window->CommandAfterEntry=yon_gtk_builder_get_widget(builder,"CommandAfterEntry"); window->EndworkCommandEntry=yon_gtk_builder_get_widget(builder,"EndworkCommandEntry"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); + window->paths=paths; if (paths){ int sz; @@ -1035,7 +1056,7 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeEntry),value); i++; }else if (strstr(parsed[i],"postrotate")){ - char *value = parsed[i+1]; + char *value = strstr(parsed[i]," ")+1; gtk_entry_set_text(GTK_ENTRY(window->CommandAfterEntry),value); i++; // }else if (!strcmp(parsed[i],"preremove")){ @@ -1082,11 +1103,11 @@ void on_logrotate_edit(GtkWidget *self, logrotate_window *window){ gtk_widget_show(dialog->MainWindow); gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&description,-1); gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name); - gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description); + gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description ? description : ""); gtk_widget_set_can_focus(dialog->LogNameEntry,0); - gtk_widget_set_can_focus(dialog->LogDescriptionEntry,0); + // gtk_widget_set_can_focus(dialog->LogDescriptionEntry,0); gtk_entry_set_has_frame(GTK_ENTRY(dialog->LogNameEntry),0); - gtk_entry_set_has_frame(GTK_ENTRY(dialog->LogDescriptionEntry),0); + // gtk_entry_set_has_frame(GTK_ENTRY(dialog->LogDescriptionEntry),0); gtk_style_context_add_class(gtk_widget_get_style_context(dialog->LogNameEntry),"nobackground"); gtk_style_context_add_class(gtk_widget_get_style_context(dialog->LogDescriptionEntry),"nobackground"); } @@ -1635,7 +1656,7 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ // g_signal_connect(G_OBJECT(window->SyslogButton),"clicked", G_CALLBACK(yon_journald_open),widgets); } window->log_name=name; - gtk_entry_set_text(GTK_ENTRY(window->LogDescriptionEntry),description); + gtk_entry_set_text(GTK_ENTRY(window->LogDescriptionEntry),description ? description : ""); config_str paths_parsed = yon_char_parse(paths,&size,"\n"); GtkWidget *last=NULL; for (int i=0;iLogTypeCombo,0); - gtk_widget_set_sensitive(window->LogDescriptionEntry,0); + // gtk_widget_set_sensitive(window->LogDescriptionEntry,0); } } @@ -1920,12 +1941,15 @@ main_window *setup_window(){ GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree)); for (int i=0; iServicesTree)); for (int i=0; iHeadInfoLabel,"head-text","label",YON_TYPE_STRING); @@ -2045,7 +2069,6 @@ int main(int argc, char *argv[]){ yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); yon_window_config_setup(GTK_WINDOW(widgets->Window)); - yon_load_proceed(YON_CONFIG_LOCAL); yon_window_config_load(config_path); yon_load_proceed(YON_CONFIG_LOCAL); update_loaded_logrotate(); diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index d34a001..7c5a7bb 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "../compile/ubl-cmake.h" #ifdef WEBKIT_FOUND #include @@ -43,11 +44,11 @@ #define JOURNALD(key) yon_char_unite("JOURNALD[",key,"]",NULL) #define LOGROTATE(key) yon_char_unite("LOGROTATE[",key,"]",NULL) -#define get_journal_output_command "journalctl --no-pager" -#define get_journal_output_since_boot_command "journalctl --no-pager -b" -#define get_journal_output_followed_command "journalctl --no-pager -f" -#define get_journal_output_kernel_command "journalctl --no-pager -k" -#define get_journal_output_prioritied_command "journalctl --no-pager -p err..alert" +#define get_journal_output_command "clear;journalctl --no-pager" +#define get_journal_output_since_boot_command "clear;journalctl --no-pager -b" +#define get_journal_output_followed_command "clear;journalctl --no-pager -f" +#define get_journal_output_kernel_command "clear;journalctl --no-pager -k" +#define get_journal_output_prioritied_command "clear;journalctl --no-pager -p err..alert" #define start_icon_name "com.ublinux.ubl-settings-logging.play-symbolic" #define stop_icon_name "com.ublinux.ubl-settings-logging.stop-symbolic" @@ -187,7 +188,6 @@ typedef struct { } add_log_window; typedef struct { -GtkTextBuffer *textbuffer1; GtkWidget *MainWindow; GtkWidget *plugBox; GtkWidget *ShowSinceBootButton; @@ -195,7 +195,7 @@ GtkWidget *NewMessagesButton; GtkWidget *ShowKernelButton; GtkWidget *ShowPriorityButton; GtkWidget *UpdateButton; -GtkWidget *LoggingTextView; +GtkWidget *LoggingTerminal; GtkWidget *JournalActionsBox; int last_mode; char *journal_name; @@ -338,6 +338,7 @@ typedef struct { GtkWidget *CommandBeforeEntry; GtkWidget *CommandAfterEntry; GtkWidget *EndworkCommandEntry; + char *paths; } logrotate_configure_window; main_window *setup_window(); \ No newline at end of file diff --git a/source/ubl-utils.c b/source/ubl-utils.c index a50de19..6d633ee 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1632,7 +1632,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end NULL, NULL, NULL); - vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), 100); + vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); gtk_widget_show_all(terminal); @@ -1860,6 +1860,11 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end param->property = tracked_value; param->containing_type = val_type; yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_parameters,param->parameter_name,param); + dictionary *dict=NULL; + for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ + if (strcmp(dict->key,param->parameter_name)) + yon_dictionary_rip(dict); + } } void yon_window_config_erase_custom_parameter(char *param_name, char *section){ @@ -1962,6 +1967,11 @@ int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find){ } return -1; } +void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column){ + int width= gtk_tree_view_column_get_width(column); + gtk_tree_view_column_set_min_width(column,width); +} + /**yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...) * [EN] * diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 79dcf00..a76516e 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "../compile/ubl-cmake.h" #ifdef WEBKIT_FOUND @@ -291,6 +292,8 @@ int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); +void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column); + int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); diff --git a/ubl-settings-logging-inspector.glade b/ubl-settings-logging-inspector.glade index 33f25fa..907f0f4 100644 --- a/ubl-settings-logging-inspector.glade +++ b/ubl-settings-logging-inspector.glade @@ -2,6 +2,7 @@ + 100 @@ -13,6 +14,11 @@ 1 10 + + 100 + 1 + 10 + True False @@ -53,7 +59,6 @@ False emblem-shared-symbolic - 800 600 @@ -238,27 +243,16 @@ - + True True - adjustment1 - adjustment2 - in - - - True - True - 5 - 5 - 5 - 5 - adjustment1 - adjustment2 - False - textbuffer1 - terminal - - + natural + adjustment3 + natural + UTF-8 + 0 + True + False True @@ -266,6 +260,19 @@ 1 + + + True + False + vertical + adjustment3 + + + False + True + 2 + + True @@ -315,4 +322,5 @@ + diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index b1f96a6..0522ee4 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -232,7 +232,6 @@ True - False True diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index ee39e3d..3447898 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -947,7 +947,7 @@ translated and supported by community. fixed - 30 + 30 Status @@ -960,7 +960,7 @@ translated and supported by community. fixed - 30 + 30 Autostart -- 2.35.1 From 0df8113ad91390106cedde0e2080f606c3cb3612 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 1 Nov 2023 15:55:09 +0600 Subject: [PATCH 12/42] Fixed inspector window focus --- ubl-settings-logging-inspector.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-logging-inspector.glade b/ubl-settings-logging-inspector.glade index 907f0f4..8b08409 100644 --- a/ubl-settings-logging-inspector.glade +++ b/ubl-settings-logging-inspector.glade @@ -245,7 +245,7 @@ True - True + False natural adjustment3 natural -- 2.35.1 From 8262460eab98c43eca57a978fba222d553297488 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 1 Nov 2023 16:07:18 +0600 Subject: [PATCH 13/42] Max value fix --- ubl-settings-logging-inspector.glade | 6 +++--- ubl-settings-logging-journald.glade | 22 +++++++++++----------- ubl-settings-logging-logrotate.glade | 20 ++++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ubl-settings-logging-inspector.glade b/ubl-settings-logging-inspector.glade index 8b08409..a6be75e 100644 --- a/ubl-settings-logging-inspector.glade +++ b/ubl-settings-logging-inspector.glade @@ -165,7 +165,7 @@ True True True - Show only priority error messages, critical messages and warnings + Show all boots image7 + False + vertical + 5 + + + True + True + True + image3 + + + + False + True + 0 + + + + + True + True + True + image7 + + + + False + True + 1 + + + + + True + True + True + image6 + + + + False + True + 2 + + False @@ -249,140 +308,147 @@ - - True - True - True - image7 - - - - False - True - 1 - - - - - True - True - True - image6 - - - - False - True - 2 - - - - - False - True - 0 - - - - - True - True - in - - + True True - liststore1 - False - - - + in - - Path + + True + True + liststore1 + False - - - 0 - + + Path + + + + 0 + + + + + True + True + 1 + - - True - True - 1 - + + + True + False + Paths to log and journals files + + - - - - True - False - Paths to log and journals files - + + False + True + 2 + False True - 2 + 0 - - - False - True - 0 - - - - - True - False - vertical - 5 - + True False - 0.019999999552965164 - in + vertical + 5 - + True False - 5 - 5 - 5 + 0.019999999552965164 + in - + True False - vertical - 5 + 5 + 5 + 5 True False + vertical 5 - - Rotation period: + True - True - False - True + False + 5 + + + Rotation period: + True + True + False + True + + + False + True + 0 + + + + + True + False + False + 0 + + Hourly + Daily + Weekly* + Monthly + Yearly + + + + False + True + 1 + + + + + True + False + False + 0 + + Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday* + + + + False + True + 2 + + False @@ -391,18 +457,55 @@ - + True - False False - 0 - - Hourly - Daily - Weekly* - Monthly - Yearly - + 5 + + + Maximum size of file: + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment4 + + + False + True + 1 + + + + + True + False + False + 0 + + Kb + Mb + Gb + + + + False + True + 2 + + False @@ -410,47 +513,131 @@ 1 - - - True - False - False - 0 - - Monday - Tuesday - Wednesday - Thursday - Friday - Saturday - Sunday* - - - - False - True - 2 - - - - False - True - 0 - + + + + + True + False + Checking frequency configuration + + + + + False + True + 0 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 True False + vertical 5 - - Maximum size of file: + True - True - False - True + False + 5 + + + File amount: + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment6 + + + False + True + 1 + + + + + True + False + Store at: + + + False + True + 2 + + + + + True + False + False + 0 + + Default + Same directory + Separate directory + + + + False + True + 3 + + + + + True + False + True + + + False + True + 4 + + + + + True + False + True + True + image4 + + + False + True + 5 + + False @@ -459,92 +646,142 @@ - - True - False - True - adjustment4 - - - False - True - 1 - - - - + True - False False - 0 - - Kb - Mb - Gb - + 5 + + + True + False + Rotation as user: + + + False + True + 0 + + + + + True + False + 0 + + root* + + + + False + True + 1 + + + + + True + False + Rotation as group: + + + False + True + 2 + + + + + True + False + 0 + + root* + + + + False + True + 3 + + False True - 2 + 1 - - False - True - 1 - + + + True + False + Rotation configuration + + + + False + True + 1 + - - - True - False - Checking frequency configuration - - - - - False - True - 0 - - - - - True - False - 0.019999999552965164 - in - + True False - 5 - 5 - 5 + 0.019999999552965164 + in - + True False - vertical - 5 + 5 + 5 + 5 True False + vertical 5 - - File amount: + True - True - False - True + False + 5 + + + True + False + Error processing: + + + False + True + 0 + + + + + True + False + 0 + + Default + Output errors if log file does not exist* + Do not output errors if log file does not exist + + + + False + True + 1 + + False @@ -553,11 +790,39 @@ - + True - False - True - adjustment6 + False + 5 + + + True + False + Rotation of jurnal even when it is empty: + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + False + True + 1 + + False @@ -566,10 +831,49 @@ - + True False - Store at: + 5 + + + Do not rotate journal younger than + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment7 + + + False + True + 1 + + + + + True + False + days + + + False + True + 2 + + False @@ -578,16 +882,49 @@ - + True - False False - 0 - - Default - Same directory - Separate directory - + 5 + + + Delete rotated journals older than + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment5 + + + False + True + 1 + + + + + True + False + days + + + False + True + 2 + + False @@ -596,10 +933,68 @@ - + True - False - True + False + 5 + + + Rotate journals if size more than + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment8 + + + False + True + 1 + + + + + True + False + False + 0 + + Kb + Mb + Gb + + + + False + True + 2 + + + + + True + False + but not earlier than the specified time interval + True + + + False + True + 3 + + False @@ -608,12 +1003,68 @@ - + True - False - True - True - image4 + False + 5 + + + Rotate journals if size more than + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment9 + + + False + True + 1 + + + + + True + False + False + 0 + + Kb + Mb + Gb + + + + False + True + 2 + + + + + True + False + before specified time interval + True + + + False + True + 3 + + False @@ -622,22 +1073,171 @@ - - False - True - 0 - + + + + + True + False + File choosing configuration + + + + + False + True + 2 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 True False + vertical 5 - + True False - Rotation as user: + 5 + + + True + False + Create log + + + False + True + 0 + + + + + True + False + 0 + + Default + Do not output + Output errors + Off + + + + False + True + 1 + + + + + True + False + as user: + + + False + True + 2 + + + + + True + False + False + 0 + + Default + + + + False + True + 3 + + + + + True + False + as group: + + + False + True + 4 + + + + + True + False + False + 0 + + Default + + + + False + True + 5 + + + + + True + False + rules: + + + False + True + 6 + + + + + True + False + True + + + False + True + 7 + + + + + True + False + True + True + image5 + + + False + True + 8 + + False @@ -646,13 +1246,24 @@ - + True False - 0 - - root* - + 5 + + + Cut source journal fileafter copy creating instead of moving old journal file and creating new one + True + True + False + True + + + False + True + 0 + + False @@ -660,940 +1271,197 @@ 1 + + + + + + + True + False + Files and directories configuration + + + + + False + True + 3 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 - - True - False - Rotation as group: - - - False - True - 2 - - - - + True False - 0 - - root* - + 5 + + + True + False + Use compression: + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + False + True + 1 + + + + + True + False + Delay compression by one journal in queue: + + + False + True + 2 + + + + + True + False + False + 0 + + Default + Yes + No + + + + False + True + 3 + + False True - 3 + 0 - - False - True - 1 - - - - - - - - - True - False - Rotation configuration - - - - - False - True - 1 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - Error processing: - - - False - True - 0 - - - - - True - False - 0 - - Default - Output errors if log file does not exist* - Do not output errors if log file does not exist - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - - - True - False - Rotation of jurnal even when it is empty: - - - False - True - 0 - - - - - True - False - 0 - - Default - On - Off - - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - 5 - - - Do not rotate journal younger than - True - True - False - True - - - False - True - 0 - - - - - True - False - True - adjustment7 - - - False - True - 1 - - - - - True - False - days - - - False - True - 2 - - - - - False - True - 2 - - - - - True - False - 5 - - - Delete rotated journals older than - True - True - False - True - - - False - True - 0 - - - - - True - False - True - adjustment5 - - - False - True - 1 - - - - - True - False - days - - - False - True - 2 - - - - - False - True - 3 - - - - - True - False - 5 - - - Rotate journals if size more than - True - True - False - True - - - False - True - 0 - - - - - True - False - True - adjustment8 - - - False - True - 1 - - - - - True - False - False - 0 - - Kb - Mb - Gb - - - - False - True - 2 - - - - - True - False - but not earlier than the specified time interval - True - - - False - True - 3 - - - - - False - True - 4 - - - - - True - False - 5 - - - Rotate journals if size more than - True - True - False - True - - - False - True - 0 - - - - - True - False - True - adjustment9 - - - False - True - 1 - - - - - True - False - False - 0 - - Kb - Mb - Gb - - - - False - True - 2 - - - - - True - False - before specified time interval - True - - - False - True - 3 - - - - - False - True - 5 - - - - - - - - - True - False - File choosing configuration - - - - - False - True - 2 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - Create log - - - False - True - 0 - - - - - True - False - 0 - - Default - Do not output - Output errors - Off - - - - False - True - 1 - - - - - True - False - as user: - - - False - True - 2 - - - - - True - False - False - 0 - - Default - - - - False - True - 3 - - - - - True - False - as group: - - - False - True - 4 - - - - - True - False - False - 0 - - Default - - - - False - True - 5 - - - - - True - False - rules: - - - False - True - 6 - - - - - True - False - True - - - False - True - 7 - - - - - True - False - True - True - image5 - - - False - True - 8 - - - - - False - True - 0 - - - - - True - False - 5 - - - Cut source journal fileafter copy creating instead of moving old journal file and creating new one - True - True - False - True - - - False - True - 0 - - - - - False - True - 1 - - - - - - - - - True - False - Files and directories configuration - - - - - False - True - 3 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - Use compression: - - - False - True - 0 - - - - - True - False - 0 - - Default - On - Off - - - - False - True - 1 - - - - - True - False - Delay compression by one journal in queue: - - - False - True - 2 - - - - - True - False - False - 0 - - Default - Yes - No - - - - False - True - 3 - - - - - False - True - 0 - - - - - - - - - True - False - Compression configuration - - - - - False - True - 4 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - Save original log file after rotation if it has specified extension: - - - False - True - 0 - - - - - True - False - 0 - - Default - On - Off - - - - False - True - 1 - - - - - True - False - True - - - False - True - 2 - - - - - False - True - 0 - - - - - True - False - 5 - - - True - False - Add date of rotation before log header - - - False - True - 0 - - - - - True - False - 0 - - Default - On - Off - - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - 5 - - - True - False - Number from which numbering of old logs will begin - - - False - True - 0 - - - - - True - False - 0 - - Default - On - Off - - - - False - True - 1 - - - - - True - False - True - adjustment10 - - - False - True - 2 - - - - - False - True - 2 - + + + True + False + Compression configuration + + + + False + True + 4 + - - - True - False - Filename configuration - - - - - False - True - 5 - - - - - True - False - 0.019999999552965164 - in - + True False - 5 - 5 - 5 + 0.019999999552965164 + in - + True False - vertical - 5 + 5 + 5 + 5 True False + vertical 5 - + True False - Email after rotation: + 5 + + + True + False + Save original log file after rotation if it has specified extension: + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + False + True + 1 + + + + + True + False + True + + + False + True + 2 + + False @@ -1602,15 +1470,39 @@ - + True False - 0 - - Default - Send Email - Don't send Email - + 5 + + + True + False + Add date of rotation before log header + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + False + True + 1 + + False @@ -1619,10 +1511,52 @@ - + True False - adress: + 5 + + + True + False + Number from which numbering of old logs will begin + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + False + True + 1 + + + + + True + False + True + adjustment10 + + + False + True + 2 + + False @@ -1630,189 +1564,182 @@ 2 - - - True - False - True - - - False - True - 3 - - - - - True - False - contents: - - - False - True - 4 - - - - - True - False - False - 0 - - Default - First rotated copy - Last rotated copy - - - - False - True - 5 - - - - False - True - 0 - + + + True + False + Filename configuration + + + + False + True + 5 + - - - True - False - Message configuration - - - - - False - True - 6 - - - - - True - False - 0.019999999552965164 - in - + True False - 5 - 5 - 5 + 0.019999999552965164 + in - + True False - vertical - 5 - - - Scenarios are running for each rotated journal - True - True - False - True - - - False - True - 0 - - - - - True - False - 5 - - - True - False - Command before rotation (one time): - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 1 - - + 5 + 5 + 5 True False + vertical 5 - + True False - Command after rotation (one time): - 0 - - - False - True - 0 - - - - - True - True + 5 + + + True + False + Email after rotation: + + + False + True + 0 + + + + + True + False + 0 + + Default + Send Email + Don't send Email + + + + False + True + 1 + + + + + True + False + adress: + + + False + True + 2 + + + + + True + False + True + + + False + True + 3 + + + + + True + False + contents: + + + False + True + 4 + + + + + True + False + False + 0 + + Default + First rotated copy + Last rotated copy + + + + False + True + 5 + + - True + False True - 1 + 0 - - False - True - 2 - + + + + + True + False + Message configuration + + + + + False + True + 6 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 True False + vertical 5 - + + Scenarios are running for each rotated journal True - False - Command before rotation: - 0 + True + False + True False @@ -1821,177 +1748,212 @@ - + True - True + False + 5 + + + True + False + Command before rotation (one time): + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + - True + False True 1 - - - False - True - 3 - - - - - True - False - 5 - + True False - Command after rotation: - 0 + 5 + + + True + False + Command after rotation (one time): + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + False True - 0 + 2 - + True - True + False + 5 + + + True + False + Command before rotation: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + - True + False True - 1 + 3 - - - False - True - 4 - - - - - True - False - 5 - + True False - Endwork command: - 0 + 5 + + + True + False + Command after rotation: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + False True - 0 + 4 - + True - True + False + 5 + + + True + False + Endwork command: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + - True + False True - 1 + 5 - - False - True - 5 - - - - - - True - False - Scenarios - - - - - False - True - 7 - - - - - False - 5 - - - True - False - Manual input: + + + True + False + Scenarios + + False True - 0 - - - - - True - True - - - True - True - 1 + 7 - - - False - True - 8 - - - - - False - True - 1 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - True False 5 True False - Log (-s) size: + Manual input: False @@ -2000,10 +1962,9 @@ - + True - False - loglize + True True @@ -2012,72 +1973,135 @@ + + False + True + 8 + + + False + True + 1 + - - + + True False - Statistics + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + True + False + Log (-s) size: + + + False + True + 0 + + + + + True + False + loglize + + + True + True + 1 + + + + + + + + + True + False + Statistics + + + + False + True + 2 + - - False - True - 2 - - - - - True - True - 0 - - - - - True - False - end - 5 - - - Save - True - True - True - image9 - True True - end - 0 + 1 - - Cancel + True - True - True - image8 + False + end + 5 + + + Save + True + True + True + image9 + + + True + True + end + 0 + + + + + Cancel + True + True + True + image8 + + + True + True + 1 + + - True + False True - 1 + 2 - False + True True 1 diff --git a/ubl-settings-logging.css b/ubl-settings-logging.css index 717c5c0..2f1e822 100644 --- a/ubl-settings-logging.css +++ b/ubl-settings-logging.css @@ -114,4 +114,9 @@ background:transparent; } .instant { transition: 0ms; +} +.errorBox { + border-width: 2px; + border-color: #ea9999; + border-style:solid; } \ No newline at end of file diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index ffb08cd..f254aa1 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -463,15 +463,9 @@ translated and supported by community. - - - - - - - - - + + + @@ -479,11 +473,8 @@ translated and supported by community. journald /var/log/journal/ System event log - 0 + False 0 - 0 - 0 - 0 -- 2.35.1 From b9095293c9894ed608fcbf5f899cb68bc67d1e33 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 16:24:21 +0600 Subject: [PATCH 30/42] Logrotate command changes --- logging_services.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging_services.csv b/logging_services.csv index c64afa1..98be66d 100644 --- a/logging_services.csv +++ b/logging_services.csv @@ -1,5 +1,5 @@ Service_Name;Service_Description;command_start;command_stop;command_enable;command_disable;command_status journald;System event log;systemctl start systemd-journald.service;systemctl stop systemd-journald.service;ubconfig set config SERVICESSTART+=systemd-journald.service;ubconfig set config SERVICESSTART-=systemd-journald.service;systemctl status systemd-journald.service -logrotate;System event log rotation service;systemctl start logrotate.service;systemctl stop logrotate.service;ubconfig set config SERVICESSTART+=logrotate.service;ubconfig set config SERVICESSTART-=logrotate.service;systemctl status logrotate.service +logrotate;System event log rotation service;systemctl start logrotate.timer;systemctl stop logrotate.timer,systemctl stop logrotate.service;ubconfig set config SERVICESNOSTART-=,logrotate.timer;ubconfig set config SERVICESNOSTART+=,logrotate.timer;systemctl status logrotate.service #metalog;System event log;systemctl start metalog.service;systemctl stop metalog.service;ubconfig set config SERVICESSTART+=metalog.service;ubconfig set config SERVICESSTART-=metalog.service;systemctl status metalog.service #syslog-ng;Service for collecting messages from system events of active network devices;systemctl start syslog-ng.service;systemctl stop syslog-ng.service;ubconfig set config SERVICESSTART+=syslog-ng.service;ubconfig set config SERVICESSTART-=syslog-ng.service;systemctl status syslog-ng.service \ No newline at end of file -- 2.35.1 From 08807aa402e87e5590339fc8d56977bc688ac413 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 16:34:17 +0600 Subject: [PATCH 31/42] Ability to change name and description for custom journal bundles --- source/ubl-settings-logging.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 5889ccb..88f90cf 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1589,7 +1589,10 @@ void on_log_save(GtkWidget *self, dictionary *dict){ char *name = (char*)gtk_entry_get_text(GTK_ENTRY(window->NameEntry)); char *desc = (char*)gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry)); if (!yon_char_is_empty(name)){ - gtk_list_store_append(widgets->list,&iter); + GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); + GtkTreeIter iter; + if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)) + gtk_list_store_append(widgets->list,&iter); gtk_list_store_set(widgets->list,&iter,0,name,1,pathse,2,&desc ? desc : "",-1); } on_close_subwindow(self); @@ -1685,6 +1688,7 @@ void on_log_add(GtkWidget *self, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; add_log_window *window = on_add_open(widgets); + gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree))); gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); gtk_widget_hide(window->ControlSectionBox); @@ -1702,14 +1706,10 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ char *paths; int size; char *description; + gboolean is_standard; int protect; - gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&description,4,&protect,-1); + gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&description,3,&is_standard,4,&protect,-1); gtk_entry_set_text(GTK_ENTRY(window->NameEntry),name); - gtk_entry_set_has_frame(GTK_ENTRY(window->NameEntry),0); - gtk_widget_set_sensitive(window->NameEntry,0); - gtk_style_context_add_class(gtk_widget_get_style_context(window->NameEntry),"nobackground"); - gtk_style_context_add_class(gtk_widget_get_style_context(window->NameEntry),"noborder"); - gtk_style_context_add_class(gtk_widget_get_style_context(window->NameEntry),"instant"); if (!strcmp(name,"journald")){ gtk_widget_hide(window->LogrotateButton); gtk_widget_hide(window->MetalogButton); @@ -1758,7 +1758,18 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ gtk_widget_show(last); g_signal_connect(G_OBJECT(last),"clicked",G_CALLBACK(on_log_path_append),window); gtk_widget_set_sensitive(window->LogTypeCombo,0); - // gtk_widget_set_sensitive(window->LogDescriptionEntry,0); + if (is_standard) { + gtk_widget_set_sensitive(window->NameEntry,0); + gtk_widget_set_sensitive(window->LogDescriptionEntry,0); + gtk_entry_set_has_frame(GTK_ENTRY(window->NameEntry),0); + gtk_widget_set_sensitive(window->NameEntry,0); + gtk_style_context_add_class(gtk_widget_get_style_context(window->NameEntry),"nobackground"); + gtk_style_context_add_class(gtk_widget_get_style_context(window->NameEntry),"noborder"); + gtk_style_context_add_class(gtk_widget_get_style_context(window->NameEntry),"instant"); + } else { + gtk_widget_set_sensitive(window->NameEntry,1); + gtk_widget_set_sensitive(window->LogDescriptionEntry,1); + } } } -- 2.35.1 From 36940d5ae4929cf4c81f7ffe3ea297357401eb7d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 16:38:23 +0600 Subject: [PATCH 32/42] logrotate tab window configura button icon has ben replaced --- ubl-settings-logging-logrotate-table.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-logging-logrotate-table.glade b/ubl-settings-logging-logrotate-table.glade index e07caf1..f6c0dfa 100644 --- a/ubl-settings-logging-logrotate-table.glade +++ b/ubl-settings-logging-logrotate-table.glade @@ -32,7 +32,7 @@ True False - document-edit-symbolic + com.ublinux.ubl-settings-logging.settings-symbolic True -- 2.35.1 From 7fd692cd3cd77dde9d294cd00f69a0ebc727c778 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 16:43:42 +0600 Subject: [PATCH 33/42] Test fix for SystemMaxUse parameter --- source/ubl-settings-logging.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 88f90cf..7ed3ddd 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1359,8 +1359,12 @@ void on_journald_save(GtkWidget *self, journald_window *window){ for (int i=0;i0) - yon_config_register(JOURNALD("SystemMaxUse"),"logging",yon_char_from_long(logssize)); + if (logssize>0){ + float val; + int size; + val = yon_size_convert_automatic(logssize,&size); + yon_config_register(JOURNALD("SystemMaxUse"),"logging",yon_char_append(yon_char_from_float(val),yon_size_get_letter_from_int(size))); + } } else yon_config_remove_by_key(JOURNALD("SystemMaxUse")); -- 2.35.1 From 1801dd0dd9592d5b07a9f60a17e37229d0e19daf Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 16:50:48 +0600 Subject: [PATCH 34/42] Fixed logrotate period interaction --- source/ubl-settings-logging.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 7ed3ddd..9bc3756 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -568,6 +568,17 @@ void on_filechooser_open(GtkWidget *self, logrotate_configure_window *window){ gtk_widget_show(dialog->FileChooser); } +void on_logrotate_period_check_toggled(GtkToggleButton *self,logrotate_configure_window *window){ + if (gtk_toggle_button_get_active(self)){ + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo))==2) gtk_widget_set_sensitive(window->RotationPeriodAdditionalCombo,1); + else gtk_widget_set_sensitive(window->RotationPeriodAdditionalCombo,0); + gtk_widget_set_sensitive(window->RotationPeriodMainCombo,1); + } else { + gtk_widget_set_sensitive(window->RotationPeriodMainCombo,0); + gtk_widget_set_sensitive(window->RotationPeriodAdditionalCombo,0); + } +} + void on_logrotate_save(GtkWidget *self, dictionary *dict){ logrotate_window *dialog = yon_dictionary_get_data(dict->first,logrotate_window*); logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*); @@ -926,8 +937,7 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind g_signal_connect(G_OBJECT(window->LogPathEditButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_edit),window); g_signal_connect(G_OBJECT(window->LogPathRemoveButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_remove),window); - g_signal_connect(G_OBJECT(window->RotationPeriodCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationPeriodAdditionalCombo); - g_signal_connect(G_OBJECT(window->RotationPeriodCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationPeriodMainCombo); + g_signal_connect(G_OBJECT(window->RotationPeriodCheck),"toggled",G_CALLBACK(on_logrotate_period_check_toggled),window); g_signal_connect(G_OBJECT(window->JournalMaxSizeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->JournalMaxSizeCombo); g_signal_connect(G_OBJECT(window->JournalMaxSizeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->JournalMaxSizeSpin); -- 2.35.1 From 2092c0f8ac69d99b4421a387a188c1fd96622c3f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 17:32:37 +0600 Subject: [PATCH 35/42] Status messages for logrotate tab window --- source/ubl-settings-logging.c | 8 +- source/ubl-settings-logging.h | 1 + source/ubl-utils.c | 97 ++--- source/ubl-utils.h | 1 + ubl-settings-logging-logrotate-table.glade | 429 +++++++++++---------- 5 files changed, 286 insertions(+), 250 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 9bc3756..dee4abb 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1202,12 +1202,17 @@ void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){ if (!strcmp(cur[i],parsed_check[j])) found ++; } } - if (cur_size==found) return; + if (cur_size==found) { + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),REPEATED_PATHS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } + } settings = yon_char_replace(settings,",\t",","); if (settings[0]==',') yon_char_divide_search(settings,",",-1); yon_config_register(LOGROTATE(yon_char_replace(paths,"\n",",")),"logging",settings); gtk_list_store_set(main_config.logrotate_list,&itar,0,name,1,paths,-1); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),SUCCESS_LABEL,5,BACKGROUND_IMAGE_SUCCESS_TYPE); } } @@ -1278,6 +1283,7 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ window->ConfigureButton = yon_gtk_builder_get_widget(builder,"ConfigureButton"); window->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); window->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); gtk_tree_view_set_model(GTK_TREE_VIEW(window->MainTree),GTK_TREE_MODEL(main_config.logrotate_list)); diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index bd964a2..b2da285 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -228,6 +228,7 @@ typedef struct { GtkWidget *ConfigureButton; GtkWidget *CancelButton; GtkWidget *SaveButton; + GtkWidget *StatusBox; } logrotate_window; typedef struct { diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 93b95bb..e264544 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1363,11 +1363,13 @@ int yon_config_save_registered(char *path){ if (sections_add) for_dictionaries(dct,sections_add){ char *command = yon_dictionary_get_data(dct,char*); + printf(command); yon_launch(command); } if (sections_remove) for_dictionaries(dct,sections_remove){ char *command = yon_dictionary_get_data(dct,char*); + printf(command); yon_launch(command); } return 1; @@ -2103,58 +2105,63 @@ void _yon_ubl_status_box_timed_remove(struct temp_statusbox *statusstruct){ gtk_revealer_set_reveal_child(GTK_REVEALER(statusstruct->revealer),0); sleep(1); gtk_widget_destroy(statusstruct->revealer); + } + status_thread_busy=0; } void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type){ - GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - GtkWidget *revealer = gtk_revealer_new(); - GtkWidget *label = gtk_label_new(""); - GtkWidget *icon = gtk_image_new(); - gtk_container_add(GTK_CONTAINER(revealer),box); - gtk_box_pack_start(GTK_BOX(box),icon,0,0,5); - gtk_box_pack_start(GTK_BOX(box),label,0,0,5); - gtk_container_add(container,revealer); - - gtk_widget_show_all(revealer); - gtk_revealer_set_reveal_child(GTK_REVEALER(revealer),1); - - gtk_widget_set_margin_bottom(label,9); - gtk_widget_set_margin_top(label,9); - gtk_label_set_xalign(GTK_LABEL(label),0.0); - PangoAttrList *attributes = pango_attr_list_new(); - PangoAttribute *boldAttr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); - pango_attr_list_insert(attributes, boldAttr); - gtk_label_set_attributes(GTK_LABEL(label),attributes); - - GdkRGBA textColor; - gdk_rgba_parse(&textColor, "#4d4d4d4d4d4d"); - PangoAttribute *colorAttr = pango_attr_foreground_new( - (int)(textColor.red * 65535), - (int)(textColor.green * 65535), - (int)(textColor.blue * 65535) - ); - pango_attr_list_insert(attributes, colorAttr); - - GtkIconTheme *ictheme = gtk_icon_theme_get_default(); - if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessError"); - gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); - gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); - } - else if (type == BACKGROUND_IMAGE_FAIL_TYPE) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); - gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessError"); - gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); - } - if (display_text) - gtk_label_set_text(GTK_LABEL(label),display_text); + if (!status_thread_busy){ + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + GtkWidget *revealer = gtk_revealer_new(); + GtkWidget *label = gtk_label_new(""); + GtkWidget *icon = gtk_image_new(); + gtk_container_add(GTK_CONTAINER(revealer),box); + gtk_box_pack_start(GTK_BOX(box),icon,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(container,revealer); + + gtk_widget_show_all(revealer); + gtk_revealer_set_reveal_child(GTK_REVEALER(revealer),1); + + gtk_widget_set_margin_bottom(label,9); + gtk_widget_set_margin_top(label,9); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + PangoAttrList *attributes = pango_attr_list_new(); + PangoAttribute *boldAttr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); + pango_attr_list_insert(attributes, boldAttr); + gtk_label_set_attributes(GTK_LABEL(label),attributes); + + GdkRGBA textColor; + gdk_rgba_parse(&textColor, "#4d4d4d4d4d4d"); + PangoAttribute *colorAttr = pango_attr_foreground_new( + (int)(textColor.red * 65535), + (int)(textColor.green * 65535), + (int)(textColor.blue * 65535) + ); + pango_attr_list_insert(attributes, colorAttr); + + GtkIconTheme *ictheme = gtk_icon_theme_get_default(); + if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessError"); + gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); + gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + else if (type == BACKGROUND_IMAGE_FAIL_TYPE) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); + gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessError"); + gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-logging.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + } + if (display_text) + gtk_label_set_text(GTK_LABEL(label),display_text); struct temp_statusbox *statusstruct = malloc(sizeof(struct temp_statusbox)); statusstruct->revealer = revealer; statusstruct->times = timeout; - GThread *thread = g_thread_new(NULL,(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct); + GThread *thread = g_thread_new("StatusThread",(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct); + status_thread_busy=1; + } } /**yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id) diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 7ddc5c0..d488149 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -354,6 +354,7 @@ void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); void yon_ubl_status_highlight_incorrect(GtkWidget *widget); +static int status_thread_busy; void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type); #ifdef __cplusplus diff --git a/ubl-settings-logging-logrotate-table.glade b/ubl-settings-logging-logrotate-table.glade index f6c0dfa..fc75f46 100644 --- a/ubl-settings-logging-logrotate-table.glade +++ b/ubl-settings-logging-logrotate-table.glade @@ -60,40 +60,101 @@ True False - 5 - 5 - 5 - 5 vertical - 5 - + True - True + False + vertical - + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + True - False - 5 - 5 - 5 - 5 - 5 + True True False - vertical + 5 + 5 + 5 + 5 5 - + True - True - True - image5 - + False + vertical + 5 + + + True + True + True + image5 + + + + False + True + 0 + + + + + True + False + True + True + image4 + + + + False + True + 1 + + + + + True + False + True + True + image3 + + + + False + True + 2 + + False @@ -102,146 +163,186 @@ - + True - False True - True - image4 - + in + + + True + True + + + Log/Journal + + + + 0 + + + + + + + Path + + + + 1 + + + + + + + Description + + + + 2 + + + + + + - False + True True 1 - - - True - False - True - True - image3 - - - - False - True - 2 - - + + + + + True + False + System configuration - False - True - 0 + False - + True - True - in + False + 5 + 5 + 5 + 5 + 5 + 5 + 5 - + True - True - - - + False + vertical + 5 - - Log/Journal - - - - 0 - - + + True + False + True + True + image8 + + + False + True + 2 + + + + False + True + 0 + + + + + True + True + in - - Path + + True + True - - - 1 - + + Log/Journal + + + + 0 + + + - - - - - Description - - - 2 - + + Path + + + + 1 + + + + + True + True + 1 + - True - True 1 - - - - - True - False - System configuration + + + True + False + Applications configuration + + + 1 + False + + - False + True + True + 0 True False - 5 - 5 - 5 - 5 - 5 - 5 + end 5 + True - + + Cancel True - False - vertical - 5 - - - True - False - True - True - image8 - - - - False - True - 2 - - + True + True + image1 False @@ -250,100 +351,20 @@ - + + Save True True - in - - - True - True - - - - - - Log/Journal - - - - 0 - - - - - - - Path - - - - 1 - - - - - - + True + image2 - True + False True 1 - - 1 - - - - - True - False - Applications configuration - - - 1 - False - - - - - True - True - 0 - - - - - True - False - end - 5 - True - - - Cancel - True - True - True - image1 - - - False - True - 0 - - - - - Save - True - True - True - image2 - False True @@ -352,7 +373,7 @@ - False + True True 1 -- 2.35.1 From 4e4a6ee5eb2b53ef8690a561931a214295ed5199 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 17:43:53 +0600 Subject: [PATCH 36/42] Test --- source/ubl-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index e264544..d0fb901 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1363,13 +1363,13 @@ int yon_config_save_registered(char *path){ if (sections_add) for_dictionaries(dct,sections_add){ char *command = yon_dictionary_get_data(dct,char*); - printf(command); + printf("%s\n",command); yon_launch(command); } if (sections_remove) for_dictionaries(dct,sections_remove){ char *command = yon_dictionary_get_data(dct,char*); - printf(command); + printf("%s\n",command); yon_launch(command); } return 1; -- 2.35.1 From 1a48ddc4691eb937f3cd6b394c17ece173b3a80f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 17:52:08 +0600 Subject: [PATCH 37/42] Fixed saving error --- source/ubl-utils.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index d0fb901..c7b87c4 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1363,13 +1363,11 @@ int yon_config_save_registered(char *path){ if (sections_add) for_dictionaries(dct,sections_add){ char *command = yon_dictionary_get_data(dct,char*); - printf("%s\n",command); yon_launch(command); } if (sections_remove) for_dictionaries(dct,sections_remove){ char *command = yon_dictionary_get_data(dct,char*); - printf("%s\n",command); yon_launch(command); } return 1; @@ -1392,7 +1390,7 @@ int yon_config_force_save_registered(char *path){ if (dct->data&&strcmp(yon_dictionary_get_data(dct,char*),"")!=0){ if (((yon_config_parameter*)dct)->flag1==1||((yon_config_parameter*)dct)->flag1==0){ if (sections_add&&yon_dictionary_get(§ions_add,((yon_config_parameter*)dct)->section)) sections_add->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_add,char*)," ",dct->key,"=",yon_dictionary_get_data(dct,char*),NULL); - else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=",yon_dictionary_get_data(dct,char*),NULL)); + else yon_dictionary_add_or_create_if_exists_with_data(sections_add,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", ((yon_config_parameter*)dct)->section, " ",dct->key,"=\"",yon_dictionary_get_data(dct,char*),"\"",NULL)); } else if (((yon_config_parameter*)dct)->flag1==-1){ if (sections_remove&&yon_dictionary_get(§ions_remove,((yon_config_parameter*)dct)->section)) sections_remove->data=(void*)yon_char_unite(yon_dictionary_get_data(sections_remove,char*)," ",dct->key,NULL); else yon_dictionary_add_or_create_if_exists_with_data(sections_remove,((yon_config_parameter*)dct)->section,yon_char_unite (ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " remove ", ((yon_config_parameter*)dct)->section, " ",dct->key,NULL)); -- 2.35.1 From 14387dc3feb0141ab0de222670a77b2e7e447a57 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 17:53:06 +0600 Subject: [PATCH 38/42] Cross-config save error has been fixed --- source/ubl-settings-logging.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index dee4abb..9c732b6 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -170,11 +170,11 @@ void yon_save_proceed(char *path,YON_CONFIG_TYPE type){ yon_config_save_registered(path); else{ if (type==YON_CONFIG_BOTH) - yon_launch("ubconfig remove system LOGROTATE[*] JOURNALD[*]"); + yon_launch("ubconfig remove logging LOGROTATE[*] JOURNALD[*]"); else if (type==YON_CONFIG_LOCAL) - yon_launch("ubconfig --target system remove system LOGROTATE[*] JOURNALD[*]"); + yon_launch("ubconfig --target system remove logging LOGROTATE[*] JOURNALD[*]"); else if (type==YON_CONFIG_GLOBAL) - yon_launch("ubconfig --target global remove system LOGROTATE[*] JOURNALD[*]"); + yon_launch("ubconfig --target global remove logging LOGROTATE[*] JOURNALD[*]"); yon_config_force_save_registered(path); } -- 2.35.1 From 70b875c8a8570f058b4a6880c62567af10f66a78 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 17:57:26 +0600 Subject: [PATCH 39/42] Preremove command test fix --- source/ubl-settings-logging.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 9c732b6..cd07e81 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -808,8 +808,13 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ after = yon_char_replace(after,"=--","\\\""); postrotate = yon_char_append("postrotate,",after); } + if (!yon_char_is_empty(endwork)){ + endwork = yon_char_replace(endwork,"\"","=--"); + endwork = yon_char_replace(endwork,"=--","\\\""); + preremove = yon_char_append("preremove,",after); + } if (!yon_char_is_empty(firstaction)||!yon_char_is_empty(after_once)||!yon_char_is_empty(before)||!yon_char_is_empty(after)) - endscript = yon_char_append("endscript ",endwork); + endscript = "endscript"; } char *commandline = yon_char_unite(period,yon_add_space_if_exists(size),yon_add_space_if_exists(rotate_count),yon_add_space_if_exists(olddir),yon_add_space_if_exists(su),yon_add_space_if_exists(missingok),yon_add_space_if_exists(ifempty),yon_add_space_if_exists(notifempty),yon_add_space_if_exists(minage),yon_add_space_if_exists(maxage),yon_add_space_if_exists(minsize),yon_add_space_if_exists(maxsize),yon_add_space_if_exists(create),yon_add_space_if_exists(copytruncate),yon_add_space_if_exists(compress),yon_add_space_if_exists(delaycompress),yon_add_space_if_exists(extension),yon_add_space_if_exists(dateext),yon_add_space_if_exists(start),yon_add_space_if_exists(mail),yon_add_space_if_exists(mailfirst),yon_add_space_if_exists(sharedscripts),yon_add_space_if_exists(firstaction),yon_add_space_if_exists(lastaction),yon_add_space_if_exists(prerotate),yon_add_space_if_exists(postrotate),yon_add_space_if_exists(preremove),yon_add_space_if_exists(endscript),NULL); -- 2.35.1 From 8949e8340785d46187f5e936ef13b9c779cedb41 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 18:08:00 +0600 Subject: [PATCH 40/42] Fixed global saving --- source/ubl-settings-logging.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index cd07e81..40b8d95 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -166,7 +166,7 @@ void on_load_local(){ } void yon_save_proceed(char *path,YON_CONFIG_TYPE type){ - if (!path||((type==YON_CONFIG_LOCAL&& main_config.load_mode==1)||(type==YON_CONFIG_GLOBAL&& main_config.load_mode==0))) + if (((type==YON_CONFIG_LOCAL&& main_config.load_mode==1)||(type==YON_CONFIG_GLOBAL&& main_config.load_mode==0))) yon_config_save_registered(path); else{ if (type==YON_CONFIG_BOTH) @@ -1193,7 +1193,6 @@ void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){ char *settings; int cur_size=0; int found=0; - gtk_list_store_append(main_config.logrotate_list,&itar); gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&settings,-1); config_str cur = yon_char_parse(paths,&cur_size,"\n"); int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(main_config.logrotate_list),&itor); @@ -1213,8 +1212,9 @@ void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){ } } - settings = yon_char_replace(settings,",\t",","); - if (settings[0]==',') yon_char_divide_search(settings,",",-1); + gtk_list_store_append(main_config.logrotate_list,&itar); + settings = yon_char_replace(settings,",\t",","); + if (settings[0]==',') yon_char_divide_search(settings,",",-1); yon_config_register(LOGROTATE(yon_char_replace(paths,"\n",",")),"logging",settings); gtk_list_store_set(main_config.logrotate_list,&itar,0,name,1,paths,-1); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),SUCCESS_LABEL,5,BACKGROUND_IMAGE_SUCCESS_TYPE); -- 2.35.1 From b36d1aac67dfaf01d1c6956e254e0e4bb4ab3de4 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 18:28:30 +0600 Subject: [PATCH 41/42] Fixed logrotate window crash --- source/ubl-settings-logging.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 40b8d95..12cbc86 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -187,13 +187,13 @@ void on_save_global_local(){ } void on_save_global(){ - yon_save_proceed("global",YON_CONFIG_LOCAL); + yon_save_proceed("global",YON_CONFIG_GLOBAL); yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } void on_save_local(){ - yon_save_proceed("system",YON_CONFIG_GLOBAL); + yon_save_proceed("system",YON_CONFIG_LOCAL); yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } @@ -1088,12 +1088,12 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind char *value = strstr(parsed[i]," ")+1; gtk_combo_box_set_active(GTK_COMBO_BOX(window->OldNumberCombo),1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->OldNumberEntry),atol(value)); + }else if (!strcmp(parsed[i],"nomail")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),2); }else if (strstr(parsed[i],"mail")){ char *value = strstr(parsed[i]," ")+1; gtk_entry_set_text(GTK_ENTRY(window->EmailEntry),value); gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),1); - }else if (!strcmp(parsed[i],"nomail")){ - gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),2); }else if (!strcmp(parsed[i],"mailfirst")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailContentsCombo),1); }else if (!strcmp(parsed[i],"maillast")){ -- 2.35.1 From 4a6901a88ce98fe2df9f48087e8184e5c27e8ec0 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 3 Nov 2023 18:33:20 +0600 Subject: [PATCH 42/42] Fixed endwork function --- source/ubl-settings-logging.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 12cbc86..dce0000 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -811,7 +811,7 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ if (!yon_char_is_empty(endwork)){ endwork = yon_char_replace(endwork,"\"","=--"); endwork = yon_char_replace(endwork,"=--","\\\""); - preremove = yon_char_append("preremove,",after); + preremove = yon_char_append("preremove,",endwork); } if (!yon_char_is_empty(firstaction)||!yon_char_is_empty(after_once)||!yon_char_is_empty(before)||!yon_char_is_empty(after)) endscript = "endscript"; @@ -1116,10 +1116,10 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind char *value = parsed[i+1]; gtk_entry_set_text(GTK_ENTRY(window->CommandAfterEntry),value); i++; - // }else if (!strcmp(parsed[i],"preremove")){ - // char *value = parsed[i+1]; - // gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value); - // i++; + }else if (!strcmp(parsed[i],"preremove")){ + char *value = parsed[i+1]; + gtk_entry_set_text(GTK_ENTRY(window->EndworkCommandEntry),value); + i++; }else if (strstr(parsed[i],"rotate")){ char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->FileAmountSpin),atol(value)); -- 2.35.1