From ba55018a765f8b14a057f5abcd2246e72c91ac46 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 19 Oct 2023 10:44:24 +0600 Subject: [PATCH 01/25] Interface fixes and edits, localisation --- Makefile | 1 + ...nux.ubl-settings-logging.edit-symbolic.svg | 4 + source/ubl-settings-logging.c | 13 +- source/ubl-strings.h | 99 ++++- ubl-settings-logging-journald.glade | 2 + ubl-settings-logging-logrotate.glade | 401 +++++++++++++++-- ubl-settings-logging.glade | 24 +- ubl-settings-logging.pot | 398 +++++++++++++++-- ubl-settings-logging_ru.po | 414 ++++++++++++++++-- 9 files changed, 1253 insertions(+), 103 deletions(-) create mode 100644 icons/com.ublinux.ubl-settings-logging.edit-symbolic.svg diff --git a/Makefile b/Makefile index 1399ffb..e333928 100644 --- a/Makefile +++ b/Makefile @@ -132,6 +132,7 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.increase-symbolic.svg" @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/${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.edit-symbolic.svg b/icons/com.ublinux.ubl-settings-logging.edit-symbolic.svg new file mode 100644 index 0000000..baba3f9 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-logging.edit-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 3b35ba2..cfde1e3 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -93,6 +93,7 @@ void on_about(){ gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(window),PROJECT_HOME_LABEL); gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),TITLE_LABEL); + gtk_window_set_title(GTK_WINDOW(window),TITLE_LABEL); gtk_label_set_text(GTK_LABEL(title),TITLE_LABEL); g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),NULL); gtk_widget_set_visible(hideButtonBox,0); @@ -187,6 +188,7 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ window->UpdateButton=yon_gtk_builder_get_widget(builder,"UpdateButton"); window->LoggingTextView=yon_gtk_builder_get_widget(builder,"LoggingTextView"); 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); GtkTreeIter iter; char *name; @@ -279,6 +281,7 @@ logrotate_configure_window *yon_logrotate_window_new(){ window->headerTopic=yon_gtk_builder_get_widget(builder,"headerTopic"); window->LogNameDescriptionLabel=yon_gtk_builder_get_widget(builder,"LogNameDescriptionLabel"); window->list=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); + gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); 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); @@ -288,13 +291,7 @@ logrotate_configure_window *yon_logrotate_window_new(){ void on_logrotate_add(GtkWidget *self, main_window *widgets){ logrotate_configure_window *window = yon_logrotate_window_new(); gtk_widget_show(window->MainWindow); - add_log_window *dialog = on_add_open(); - gtk_widget_hide(dialog->StatisticsFrame); - gtk_widget_hide(dialog->JournaldButton); - gtk_label_set_text(GTK_LABEL(window->LogNamelabel),""); - gtk_label_set_text(GTK_LABEL(window->LogNameDescriptionLabel),""); gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),""); - gtk_window_present(GTK_WINDOW(dialog->MainWindow)); } void on_logrotate_edit(GtkWidget *self, logrotate_tab_window *window){ @@ -454,7 +451,7 @@ void on_service_edit(GtkWidget *self,main_window *widgets){ GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->ServicesTree)),&model,&iter)){ char *name; - gtk_tree_model_get(model,&iter,1,&name,-1); + gtk_tree_model_get(model,&iter,2,&name,-1); if (!strcmp(name,"journald")){ on_journald_open(NULL,widgets); } else { @@ -564,7 +561,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,0,1,log[0],2,log[1],-1); + gtk_list_store_set(widgets->ServicesList,&iter,0,0,1,0,2,log[0],3,log[1],-1); // yon_char_parsed_free(log,log_size); } // yon_char_parsed_free(services,service_size); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 58c1749..fccda42 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -36,4 +36,101 @@ #define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded.") #define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded.") #define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded.") -#define ACCEPT_LABEL _("Accept") \ No newline at end of file +#define ACCEPT_LABEL _("Accept") +//ubl-settings-logging.glade +#define JOURNALS_LABEL _("Journals") +#define SERVICES_LABEL _("Services") +#define LOG_JOURNAL_TAB_LABEL _("Log/Journal") +#define PATH_LABEL _("Path") +#define DESCRIPTION_LABEL _("Description") +#define INSPECT_LABEL _("Inspect log") +#define CONFIGURE_LOG_LABEL _("Configure log") +#define ADD_LOG_LABEL _("Add log") +#define REMOVE_LOG_LABEL _("Remove log") +#define STOP_SERVICE_LABEL _("Stop service") +#define START_SERVICE_LABEL _("Start service") +#define CONFIGURE_SERVICE_LABEL _("Configure service") +#define STATUS_LABEL _("Status") +#define SERVICE_LABEL _("Service") +#define AUTOSTART_LABEL _("Autostart") + +//ubl-settings-logging-inspector.glade +#define TOOLTIP_BOOT_LABEL _("Show messages since the current system boot") +#define TOOLTIP_FOLLOW_LABEL _("Follow for new messages") +#define TOOLTIP_KERNEL_LABEL _("Show kernel ring buffer") +#define TOOLTIP_PRIORITY_LABEL _("Show only priority error messages, critical messages and warnings") +// #define LABEL _("Cancel") +// #define LABEL _("Cancel") +// #define LABEL _("Cancel") +#define UPDATE_LABEL _("Update") + +//ubl-settings-logging-journald.glade +#define JOURNAL_DESCRIPTION_LABEL _("Description:") +#define JOURNAL_STORAGE_LABEL _("Journal storage place:") +#define COMPRESSION_LABEL _("Use compression:") +#define DIVIDE_LABEL _("Divide journal files:") +#define INTERVAL_LABEL _("Log recording journal interval:") +#define RECORDS_COUNT_LABEL _("Records amount:") +#define MAX_SIZE_LABEL _("Maximum size of all logs:") +#define MAX_ROTATION_SIZE_LABEL _("Maximum size of rotation journal:") +#define FREE_SPACE_LABEL _("Leave free space at storage:") +#define REDIRECT_LABEL _("Redirect to console:") +#define TTY_LABEL _("TTY:") +#define MESSAGES_TYPE_LABEL _("Type of forwarded messages:") +#define COURNAL_CONFIGURATION_LABEL _("Journal configuration") +#define TOTAL_SIZE_LABEL _("Total log size:") +#define LOWER_SIZE_LABEL _("Lower size to:") +#define APPLY_LABEL _("Apply") +#define STATISTICS_LABEL _("Statistics") + +//ubl-settings-logging-logrotate.glade +#define LOGROTATE_LOG_JOURNAL_TAB_LABEL _("Log/Journal:") +#define PATHS_LABEL _("Paths to log and journals files") +#define DEFAULT_LABEL _("Default") +#define ON_LABEL _("On") +#define OFF_LABEL _("Off") +#define SCENARIOS_LABEL _("Scenarios") +#define SCENARIO_RUN_LABEL _("Scenarios are running for each rotated journal") +#define COMMAND_SINGLE_BEFORE_LABEL _("Command before rotation (one time):") +#define COMMAND_SINGLE_AFTER_LABEL _("Command after rotation (one time):") +#define COMMAND_BEFORE_LABEL _("Command before rotation:") +#define COMMAND_AFTER_LABEL _("Command after rotation:") +#define ROTATION_LABEL _("Rotation period:") +#define FILE_SIZE_LABEL _("Maximum size of file:") +#define FREQUENCY_LABEL _("Checking frequency configuration") +#define FILE_AMOUNT_LABEL _("File amount:") +#define STORE_LABEL _("Store at:") +#define ROTATION_USER_LABEL _("Rotation as user:") +#define ROTATION_GROUP_LABEL _("Rotation as group:") +#define ROTATION_CONFIGURATION_LABEL _("Rotation configuration") +#define ERROR_LABEL _("Error processing:") +#define ROTATION_EMPTY_LABEL _("Rotation of jurnal even when it is empty:") +#define DONT_ROTATE_YOUNGER_LABEL _("Do not rotate journal younger than") +#define DAYS_LABEL _("days") +#define DELETE_ROTATED_LABEL _("Delete rotated journals older than") +#define ROTATE_SIZE_LABEL _("Rotate journals if size more than") +#define ROTATE_TIME_LABEL _("but not earlier than the specified time interval") +#define ROTATE_BEFORE_LABEL _("before specified time interval") +#define FILE_CHOOSE_LABEL _("File choosing configuration") +#define CREATE_LOG_LABEL _("Create log") +#define AS_USER_LABEL _("as user:") +#define AS_GROUP_LABEL _("as group:") +#define RULES_LABEL _("rules:") +#define CUT_SOURCE_LABEL _("Cut source journal fileafter copy creating instead of moving old journal file and creating new one") +#define FILES_DIRS_CONFIGURATION_LABEL _("Files and directories configuration") +#define DELAY_LABEL _("Delay compression by one journal in queue:") +#define COMPRESSION_CONFIGURATION_LABEL _("Compression configuration") +#define SAVE_ORIGINAL_LABEL _("Save original log file after rotation if it has specified extension:") +#define ADD_DATE_LABEL _("Add date of rotation before log header") +#define START_NUMBER_LABEL _("Number from which numbering of old logs will begin") +#define FILENAME_CONFIGURATION_LABEL _("Filename configuration") +#define EMAIL_AT_ROTATION_LABEL _("Email after rotation:") +#define ADRESS_LABEL _("adress:") +#define CONTENTS_LABEL _("contents:") +#define MESSAGE_CONFIGURATION_LABEL _("Message configuration") +#define MANUAL_LABEL _("Manual input:") +#define LOG_SIZE_LABEL _("Log size:") + +//ubl-settings-logging-logrotate-table.glade +#define SYSTEM_CONFIGURATION_LABEL _("System configuration") +#define APPLITATIONS_CONFIGURATION_LABEL _("Applications configuration") \ No newline at end of file diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index 28c9956..185ec96 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -128,6 +128,8 @@ True False + vertical + 5 True diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index ce37634..12023f7 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -3,7 +3,6 @@ - 1024 1 @@ -62,7 +61,7 @@ True False - document-edit-symbolic + com.ublinux.ubl-settings-logging.edit-symbolic True @@ -133,6 +132,7 @@ True True + never in @@ -160,7 +160,7 @@ False 5 - + True False Log/Journal: @@ -172,28 +172,14 @@ - - True - False - Logname - - - False - True - 1 - - - - + True True - True - image3 - False + True True - 2 + 1 @@ -209,7 +195,7 @@ False 5 - + True False Description: @@ -221,13 +207,12 @@ - + True - False - logdescription + True - False + True True 1 @@ -239,6 +224,124 @@ 1 + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + 5 + + + True + 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 + True + 0 + + + + + True + True + in + + + True + True + + + + + + + + True + True + 1 + + + + + + + + + True + False + Paths to log and journals files + + + + + False + True + 2 + + False @@ -250,7 +353,7 @@ True False - 0 + 0.019999999552965164 in @@ -269,7 +372,7 @@ True False - 0 + 0.019999999552965164 in @@ -414,7 +517,7 @@ True False - 0 + 0.019999999552965164 in @@ -597,7 +700,7 @@ True False - 0 + 0.019999999552965164 in @@ -837,6 +940,7 @@ True False but not earlier than the specified time interval + True False @@ -903,6 +1007,7 @@ True False before specified time interval + True False @@ -939,7 +1044,7 @@ True False - 0 + 0.019999999552965164 in @@ -1128,7 +1233,7 @@ True False - 0 + 0.019999999552965164 in @@ -1180,7 +1285,7 @@ True False - Delay compressin by one journal in queue: + Delay compression by one journal in queue: False @@ -1232,7 +1337,7 @@ True False - 0 + 0.019999999552965164 in @@ -1372,6 +1477,7 @@ True True + digits False @@ -1408,7 +1514,7 @@ True False - 0 + 0.019999999552965164 in @@ -1530,6 +1636,201 @@ 6 + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + 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 + + + + + True + False + 5 + + + True + False + Command after rotation (one time): + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Command before rotation: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 3 + + + + + True + False + 5 + + + True + False + Command after rotation: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 4 + + + + + + + + + True + False + Scenarios + + + + + False + True + 7 + + True @@ -1562,7 +1863,7 @@ False True - 7 + 8 @@ -1587,7 +1888,7 @@ True False - 0 + 0.019999999552965164 in @@ -1696,5 +1997,33 @@ + + + + + + + + + + + + + + + + + + + + True + False + com.ublinux.ubl-settings-logging.decrease-symbolic + + + True + False + com.ublinux.ubl-settings-logging.increase-symbolic + diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index 2247491..46d62d2 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -201,6 +201,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + @@ -681,6 +683,7 @@ translated and supported by community. True True True + Inspect log image1 diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index 8b65cb1..aa8e49c 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -102,8 +102,8 @@ msgid "Save to global configuration" msgstr "Сохранить в глобальную конфигурацию" #: source/ubl-strings.h:15 -msgid "Save configuration" -msgstr "Сохранить конфигурацию" +msgid "Save to global and local configuration" +msgstr "Сохранить в глобальную и локальную конфигурацию" #: source/ubl-strings.h:16 msgid "Save" From 65359b00c0f82629b051310d293fa4800d76c81b Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 20 Oct 2023 09:29:25 +0600 Subject: [PATCH 07/25] Russian localisation fix --- ubl-settings-logging_ru.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index aa8e49c..f041837 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -111,7 +111,7 @@ msgstr "Сохранить" #: source/ubl-strings.h:18 msgid "Load local configuration" -msgstr "Загрузить локальную конфигуруцию" +msgstr "Загрузить локальную конфигурацию" #: source/ubl-strings.h:19 msgid "Load global configuration" From 6c33265383c122f5127e5a41fe504380a8a9e158 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 20 Oct 2023 09:38:41 +0600 Subject: [PATCH 08/25] Russian localisation dix --- ubl-settings-logging_ru.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index f041837..9c7fac6 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -325,7 +325,7 @@ msgstr "Уменьшить размер до:" #: source/ubl-strings.h:83 msgid "Apply" -msgstr "Примернить" +msgstr "Применить" #: source/ubl-strings.h:84 msgid "Statistics" From 4db5fe1df13374a074add438221f5f52f3b5b3d1 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 20 Oct 2023 17:49:54 +0600 Subject: [PATCH 09/25] Log add window startup functions --- gresource.xml | 1 + source/CMakeLists.txt | 1 + source/ubl-settings-logging.c | 159 ++++++++++++++++++++------- source/ubl-settings-logging.h | 3 + ubl-settings-logging-add-path.glade | 96 ++++++++++++++++ ubl-settings-logging-add.glade | 119 +++++--------------- ubl-settings-logging-logrotate.glade | 28 +++-- 7 files changed, 265 insertions(+), 142 deletions(-) create mode 100644 ubl-settings-logging-add-path.glade diff --git a/gresource.xml b/gresource.xml index 1914fde..bf9d603 100644 --- a/gresource.xml +++ b/gresource.xml @@ -3,6 +3,7 @@ ubl-settings-logging.glade ubl-settings-logging-add.glade + ubl-settings-logging-add-path.glade ubl-settings-logging-inspector.glade ubl-settings-logging-logrotate.glade ubl-settings-logging-journald.glade diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index c9220c0..48c020f 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -37,6 +37,7 @@ add_custom_target(GLADE ubl-settings-logging.glade) set(DEPENDFILES ../ubl-settings-logging.glade ../ubl-settings-logging-add.glade + ../ubl-settings-logging-add-path.glade ../ubl-settings-logging-inspector.glade ../ubl-settings-logging-journald.glade ../ubl-settings-logging-logrotate.glade diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index cdf4796..f59ebe2 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -108,28 +108,6 @@ void yon_load_proceed(char *command){ } -add_log_window *on_add_open(){ - 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"); - window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); - window->SaveButton=yon_gtk_builder_get_widget(builder,"SaveButton"); - window->LogAddingBox=yon_gtk_builder_get_widget(builder,"LogAddingBox"); - window->LogTypeCombo=yon_gtk_builder_get_widget(builder,"LogTypeCombo"); - window->LogPathEntry=yon_gtk_builder_get_widget(builder,"LogPathEntry"); - window->LogFindButton=yon_gtk_builder_get_widget(builder,"LogFindButton"); - window->LogDescriptionEntry=yon_gtk_builder_get_widget(builder,"LogDescriptionEntry"); - window->LogrotateButton=yon_gtk_builder_get_widget(builder,"LogrotateButton"); - window->MetalogButton=yon_gtk_builder_get_widget(builder,"MetalogButton"); - window->SyslogButton=yon_gtk_builder_get_widget(builder,"SyslogButton"); - window->JournaldButton=yon_gtk_builder_get_widget(builder,"JournaldButton"); - window->LogSizeLabel=yon_gtk_builder_get_widget(builder,"LogSizeLabel"); - window->StatisticsFrame=yon_gtk_builder_get_widget(builder,"StatisticsFrame"); - gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); - return window; -} - void on_inspector_update(GtkWidget *self, inspector_window *window){ int size; GtkTextIter titer,titerend; @@ -227,6 +205,8 @@ void on_log_choose(GtkWidget *self,add_log_window *window){ gtk_widget_destroy(dialog); } +// Logrotate window + logrotate_configure_window *yon_logrotate_window_new(){ logrotate_configure_window *window = malloc(sizeof(logrotate_configure_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_path); @@ -343,6 +323,8 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ gtk_widget_show(window->Window); } +// Journald window + void on_journald_open(GtkWidget *self, main_window *widgets){ journald_window *window = malloc(sizeof(journald_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_journald_path); @@ -388,18 +370,35 @@ void on_journald_open(GtkWidget *self, main_window *widgets){ gtk_widget_show(window->MainWindow); } -void on_serivces_open(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)){ - char *service_name; - gtk_tree_model_get(model,&iter,1,&service_name,-1); - if (!strcmp(service_name,"journald")){ - on_journald_open(NULL,widgets); - } else { - on_logrotate_tab_open(NULL,widgets); - } - } + +// Log adding menu + +add_log_window *on_add_open(){ + 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"); + window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); + window->SaveButton=yon_gtk_builder_get_widget(builder,"SaveButton"); + window->LogAddingBox=yon_gtk_builder_get_widget(builder,"LogAddingBox"); + window->LogTypeCombo=yon_gtk_builder_get_widget(builder,"LogTypeCombo"); + window->LogPathEntry=yon_gtk_builder_get_widget(builder,"LogPathEntry"); + window->LogFindButton=yon_gtk_builder_get_widget(builder,"LogFindButton"); + window->LogDescriptionEntry=yon_gtk_builder_get_widget(builder,"LogDescriptionEntry"); + window->LogrotateButton=yon_gtk_builder_get_widget(builder,"LogrotateButton"); + window->MetalogButton=yon_gtk_builder_get_widget(builder,"MetalogButton"); + window->SyslogButton=yon_gtk_builder_get_widget(builder,"SyslogButton"); + window->JournaldButton=yon_gtk_builder_get_widget(builder,"JournaldButton"); + window->LogSizeLabel=yon_gtk_builder_get_widget(builder,"LogSizeLabel"); + window->StatisticsFrame=yon_gtk_builder_get_widget(builder,"StatisticsFrame"); + 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); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); + return window; +} + + +void on_log_edit_logrotate_settings(GtkWidget *self, add_log_window *window){ } @@ -409,10 +408,65 @@ void on_log_add(GtkWidget *self, main_window *widgets){ add_log_window *window = on_add_open(); gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); - gtk_widget_hide(window->JournaldButton); + gtk_widget_hide(window->ControlSectionBox); g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); } +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;i1&>k_widget_get_sensitive(g_list_nth_data(list,3))){ + GtkWidget *prevbox = (GtkWidget*)g_list_nth_data(paths,i-1); + GList *prevlist = gtk_container_get_children(GTK_CONTAINER(prevbox)); + gtk_widget_show(g_list_nth_data(prevlist,3)); + g_list_free(prevlist); + gtk_widget_destroy(box); + } + } + g_list_free(list); + } + g_list_free(paths); +} + +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)),"")){ + 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 *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"); + g_signal_connect(G_OBJECT(AppendButton),"clicked",G_CALLBACK(on_log_path_append),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); +} + void on_log_edit(GtkWidget *self,main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; @@ -421,7 +475,10 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); char *name; - gtk_tree_model_get(model,&iter,0,&name,-1); + char *paths; + int size; + char *description; + gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&description,-1); if (!strcmp(name,"journald")){ gtk_widget_hide(window->LogrotateButton); gtk_widget_hide(window->MetalogButton); @@ -429,11 +486,30 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ g_signal_connect(G_OBJECT(window->JournaldButton),"clicked", G_CALLBACK(on_journald_open),widgets); } else { gtk_widget_hide(window->JournaldButton); - // g_signal_connect(G_OBJECT(window->JournaldButton),"clicked", G_CALLBACK(on_journald_open),widgets); - // g_signal_connect(G_OBJECT(window->JournaldButton),"clicked", G_CALLBACK(on_log),widgets); - // g_signal_connect(G_OBJECT(window->JournaldButton),"clicked", G_CALLBACK(on_journald_open),widgets); + g_signal_connect(G_OBJECT(window->LogrotateButton),"clicked", G_CALLBACK(on_log_edit_logrotate_settings),widgets); + // g_signal_connect(G_OBJECT(window->MetalogButton),"clicked", G_CALLBACK(on_log),widgets); + // g_signal_connect(G_OBJECT(window->SyslogButton),"clicked", G_CALLBACK(on_journald_open),widgets); + } + gtk_entry_set_text(GTK_ENTRY(window->LogDescriptionEntry),description); + config_str paths_parsed = yon_char_parse(paths,&size,"\n"); + GtkWidget *last=NULL; + for (int i=0;iLogPathsBox),box,0,0,5); + last = AppendButton; } - gtk_widget_set_sensitive(window->LogAddingBox,0); + 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); g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); } } @@ -446,6 +522,8 @@ void on_log_remove(GtkWidget *self, main_window *widgets){ } } +// Main window + void on_service_edit(GtkWidget *self,main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); GtkTreeIter iter; @@ -552,6 +630,7 @@ main_window *setup_window(){ int log_size; journals[i]=yon_char_divide_search(journals[i],"\n",-1); 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); } diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index 68bfa6a..566c763 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -20,6 +20,7 @@ #define glade_path "/com/ublinux/ui/ubl-settings-logging.glade" #define glade_add_path "/com/ublinux/ui/ubl-settings-logging-add.glade" +#define glade_add_path_path "/com/ublinux/ui/ubl-settings-logging-add-path.glade" #define glade_inspector_path "/com/ublinux/ui/ubl-settings-logging-inspector.glade" #define glade_journald_path "/com/ublinux/ui/ubl-settings-logging-journald.glade" #define glade_logrotate_path "/com/ublinux/ui/ubl-settings-logging-logrotate.glade" @@ -161,6 +162,8 @@ typedef struct { GtkWidget *JournaldButton; GtkWidget *LogSizeLabel; GtkWidget *StatisticsFrame; + GtkWidget *ControlSectionBox; + GtkWidget *LogPathsBox; } add_log_window; typedef struct { diff --git a/ubl-settings-logging-add-path.glade b/ubl-settings-logging-add-path.glade new file mode 100644 index 0000000..b3f0a35 --- /dev/null +++ b/ubl-settings-logging-add-path.glade @@ -0,0 +1,96 @@ + + + + + + True + False + 5 + + + True + False + Path (-s): + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image4 + + + + False + True + 2 + + + + + True + True + image3 + + + + False + True + 3 + + + + + True + True + True + image9 + + + + False + True + 4 + + + + + True + False + com.ublinux.ubl-settings-logging.increase-symbolic + + + True + False + com.ublinux.ubl-settings-logging.zoom-symbolic + + + True + False + com.ublinux.ubl-settings-logging.decrease-symbolic + + diff --git a/ubl-settings-logging-add.glade b/ubl-settings-logging-add.glade index dcba07a..f7d8eec 100644 --- a/ubl-settings-logging-add.glade +++ b/ubl-settings-logging-add.glade @@ -28,16 +28,6 @@ False emblem-ok-symbolic - - True - False - com.ublinux.ubl-settings-logging.increase-symbolic - - - True - False - com.ublinux.ubl-settings-logging.zoom-symbolic - True False @@ -135,6 +125,7 @@ True False Log/Journal: + 0 False @@ -166,85 +157,34 @@ - + True - False - 5 + True + never + in - + True False - Path (-s): - 0 + 5 + 5 + 5 + 5 + + + True + False + vertical + + + + + - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - True - True - True - image4 - - - - False - True - 2 - - - - - True - True - True - image3 - - - - False - True - 3 - - - - - True - True - True - image9 - - - - False - True - 4 - - False + True True 1 @@ -259,6 +199,7 @@ True False Description: + 0 False @@ -286,14 +227,14 @@ - False + True True 0 - False + True True 0 @@ -312,7 +253,7 @@ - + True False 5 @@ -321,6 +262,7 @@ True False Control: + 0 False @@ -409,7 +351,7 @@ True False - 0 + 0.019999999552965164 in @@ -429,6 +371,7 @@ True False Log size: + 0 False @@ -513,13 +456,7 @@ - - - True - False - com.ublinux.ubl-settings-logging.decrease-symbolic - diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index cd7e181..cf4edb4 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -73,6 +73,22 @@ False com.ublinux.ubl-settings-logging.profile-symbolic + + True + False + com.ublinux.ubl-settings-logging.decrease-symbolic + + + True + False + com.ublinux.ubl-settings-logging.increase-symbolic + + + + + + + 800 600 @@ -312,6 +328,7 @@ True True + liststore1 False @@ -2027,15 +2044,4 @@ - - True - False - com.ublinux.ubl-settings-logging.decrease-symbolic - - - True - False - com.ublinux.ubl-settings-logging.increase-symbolic - - From d324a337f854a0c95487e3feefdd9fdd6d0fa607 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Sat, 21 Oct 2023 16:38:02 +0600 Subject: [PATCH 10/25] Button functionality for logrotate window --- journals_list.csv | 24 ++--- source/ubl-settings-logging.c | 154 +++++++++++++++++++++++++-- source/ubl-settings-logging.h | 12 ++- source/ubl-utils.c | 2 +- ubl-settings-logging-logrotate.glade | 50 +++++++-- 5 files changed, 208 insertions(+), 34 deletions(-) diff --git a/journals_list.csv b/journals_list.csv index be0612f..c939ad6 100644 --- a/journals_list.csv +++ b/journals_list.csv @@ -1,12 +1,12 @@ -Журнал Acpid;/var/log/acpid;Журнал работы и обращений к Acpid -Журнал веб-сервера;/var/log/apache2/error.log,/var/log/apache2/access.log;Журнал работы и обращений к веб-серверу -Журнал аудита;/var/log/audit/audit.log;Журнал аудита (audit) -Журнал авторизации;/var/log/auth.log;Журнал процедур авторизации -Журнал планировщика заданий;/var/log/syslog;Журнал работы планировщика заданий (cron) -Журнал сервера печати;/var/log/cups/access_log,/var/log/cups/page_log,/var/log/cups/cups-pdf_log;Журнал работы и обращений к серверу печати (cups) -Журналы служб;/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 -Журнал почтового сервера;/var/log/mail.log,/var/log/mail.info,/var/log/mail.warn,/var/log/mail.err;Журнал почтового сервера Postfix -Системный журнал;/var/log/syslog;Системный журнал -Журнал дисплейного сервера;/var/log/Xorg.0.log;Журнал работы дисплейного сервера X.org -Журнал сеансов графической системы X;~/.xsession-errors/;Журнал сеансов графической системы X \ No newline at end of file +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 diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index f59ebe2..36c6b72 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -108,6 +108,8 @@ void yon_load_proceed(char *command){ } +// Inspector functions + void on_inspector_update(GtkWidget *self, inspector_window *window){ int size; GtkTextIter titer,titerend; @@ -207,14 +209,79 @@ void on_log_choose(GtkWidget *self,add_log_window *window){ // Logrotate window +void on_logrotate_configuration_path_add(GtkWidget *self, logrotate_configure_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(window->list); + GtkTreeIter iter; + gtk_list_store_append(window->list, &iter); + GtkTreeViewColumn *column = gtk_tree_view_get_column(GTK_TREE_VIEW(window->LogPathsTree),0); + GList *list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column)); + GValue *val = g_malloc0(sizeof(GValue)); + g_object_get_property(G_OBJECT(list->data),"editable",val); + g_value_set_boolean(val,1); + g_object_set_property(G_OBJECT(list->data),"editable",val); + free(val); + gtk_tree_view_set_cursor(GTK_TREE_VIEW(window->LogPathsTree),gtk_tree_model_get_path(model,&iter),column,1); +} + +void on_path_editing_done(GtkCellRendererText* self,gchar* path,gchar* new_text,logrotate_configure_window *window){ + GtkTreeIter iter; + char *cur_path; + gtk_tree_model_get_iter(GTK_TREE_MODEL(window->list),&iter,gtk_tree_path_new_from_string(path)); + gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&cur_path,-1); + + if (cur_path&&!strcmp(cur_path,"")&&!strcmp(new_text,"")) + gtk_list_store_remove(window->list,&iter); + else if (new_text&&strcmp(new_text,"")) + gtk_list_store_set(window->list,&iter,0,new_text,-1); + GValue *val = g_malloc0(sizeof(GValue)); + g_object_get_property(G_OBJECT(self),"editable",val); + g_value_set_boolean(val,0); + g_object_set_property(G_OBJECT(self),"editable",val); + free(val); +} + +void on_path_editing_cancel(GtkCellRendererText* self,logrotate_configure_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(window->list); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ + char *path; + gtk_tree_model_get(model,&iter,0,&path,-1); + if (!path||!strcmp(path,"")) + gtk_list_store_remove(window->list,&iter); + } +} + +void on_logrotate_configuration_path_edit(GtkWidget *self, logrotate_configure_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(window->list); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ + GtkTreeViewColumn *column = gtk_tree_view_get_column(GTK_TREE_VIEW(window->LogPathsTree),0); + GList *list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column)); + GValue *val = g_malloc0(sizeof(GValue)); + g_object_get_property(G_OBJECT(list->data),"editable",val); + g_value_set_boolean(val,1); + g_object_set_property(G_OBJECT(list->data),"editable",val); + free(val); + gtk_tree_view_set_cursor(GTK_TREE_VIEW(window->LogPathsTree),gtk_tree_model_get_path(model,&iter),column,1); + } +} + +void on_logrotate_configuration_path_remove(GtkWidget *self, logrotate_configure_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(window->list); + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->LogPathsTree)),&model,&iter)){ + gtk_list_store_remove(window->list,&iter); + } +} + logrotate_configure_window *yon_logrotate_window_new(){ logrotate_configure_window *window = malloc(sizeof(logrotate_configure_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_path); window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); window->SaveButton=yon_gtk_builder_get_widget(builder,"SaveButton"); - window->LogNamelabel=yon_gtk_builder_get_widget(builder,"LogNamelabel"); - window->LogNameButton=yon_gtk_builder_get_widget(builder,"LogNameButton"); + window->LogNameEntry=yon_gtk_builder_get_widget(builder,"LogNameEntry"); + window->LogDescriptionEntry=yon_gtk_builder_get_widget(builder,"LogDescriptionEntry"); window->RotationPeriodCheck=yon_gtk_builder_get_widget(builder,"RotationPeriodCheck"); window->RotationPeriodMainCombo=yon_gtk_builder_get_widget(builder,"RotationPeriodMainCombo"); window->RotationPeriodAdditionalCombo=yon_gtk_builder_get_widget(builder,"RotationPeriodAdditionalCombo"); @@ -259,12 +326,46 @@ logrotate_configure_window *yon_logrotate_window_new(){ window->ManualInputEntry=yon_gtk_builder_get_widget(builder,"ManualInputEntry"); window->LogSizeLabel=yon_gtk_builder_get_widget(builder,"LogSizeLabel"); window->headerTopic=yon_gtk_builder_get_widget(builder,"headerTopic"); - window->LogNameDescriptionLabel=yon_gtk_builder_get_widget(builder,"LogNameDescriptionLabel"); + window->LogPathsTree=yon_gtk_builder_get_widget(builder,"LogPathsTree"); + window->LogPathEditButton=yon_gtk_builder_get_widget(builder,"LogPathEditButton"); + window->LogPathAddButton=yon_gtk_builder_get_widget(builder,"LogPathAddButton"); + window->LogPathRemoveButton=yon_gtk_builder_get_widget(builder,"LogPathRemoveButton"); window->list=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); + window->PathCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"PathCell")); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); 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->PathCell),"edited",G_CALLBACK(on_path_editing_done),window); + g_signal_connect(G_OBJECT(window->PathCell),"editing-canceled",G_CALLBACK(on_path_editing_cancel),window); + g_signal_connect(G_OBJECT(window->LogPathAddButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_add),window); + 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),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationPeriodAdditionalCombo); + g_signal_connect(G_OBJECT(window->RotationPeriodCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationPeriodMainCombo); + + 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),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountSpin); + g_signal_connect(G_OBJECT(window->FileAmountCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountCombo); + g_signal_connect(G_OBJECT(window->FileAmountCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountEntry); + g_signal_connect(G_OBJECT(window->FileAmountCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountButton); + g_signal_connect(G_OBJECT(window->DoNotRotateYoungerCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DoNotRotateYoungerSpin); + + g_signal_connect(G_OBJECT(window->DeleteOlderCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeleteOlderSpin); + + g_signal_connect(G_OBJECT(window->RotateSizeMaxAfterTimeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxAfterTimeSpin); + g_signal_connect(G_OBJECT(window->RotateSizeMaxAfterTimeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxAfterTimeCombo); + + g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeSpin); + g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"clicked",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); return window; } @@ -297,6 +398,38 @@ void on_logrotate_apps_configure(){ } +void on_log_edit_logrotate_settings(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*); + GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); + GtkTreeIter iter,itar; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ + char *name; + char *description; + logrotate_configure_window *dialog = yon_logrotate_window_new(); + gtk_widget_show(dialog->MainWindow); + gtk_tree_model_get(model,&iter,0,&name,2,&description,-1); + gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name); + gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description); + gtk_widget_set_can_focus(dialog->LogNameEntry,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_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"); + GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); + for (int i=0;ilist,&itar); + GList *paths = gtk_container_get_children((GtkContainer*)g_list_nth_data(list,i)); + gtk_list_store_set(dialog->list,&itar,0,gtk_entry_get_text((GtkEntry*)g_list_nth_data(paths,1)),-1); + g_list_free(paths); + } + + } +} + +// Logrotate tab window + 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); @@ -394,14 +527,11 @@ add_log_window *on_add_open(){ window->LogPathsBox=yon_gtk_builder_get_widget(builder,"LogPathsBox"); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); 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_close_subwindow),NULL); return window; } - -void on_log_edit_logrotate_settings(GtkWidget *self, add_log_window *window){ - -} - void on_log_add(GtkWidget *self, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; @@ -409,7 +539,6 @@ void on_log_add(GtkWidget *self, main_window *widgets){ gtk_widget_show(window->MainWindow); gtk_widget_hide(window->StatisticsFrame); gtk_widget_hide(window->ControlSectionBox); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); } void on_log_path_choose(GtkWidget *self,add_log_window *window){ @@ -486,10 +615,14 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ g_signal_connect(G_OBJECT(window->JournaldButton),"clicked", G_CALLBACK(on_journald_open),widgets); } else { gtk_widget_hide(window->JournaldButton); - g_signal_connect(G_OBJECT(window->LogrotateButton),"clicked", G_CALLBACK(on_log_edit_logrotate_settings),widgets); + 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->LogrotateButton),"clicked", G_CALLBACK(on_log_edit_logrotate_settings),dict); // g_signal_connect(G_OBJECT(window->MetalogButton),"clicked", G_CALLBACK(on_log),widgets); // g_signal_connect(G_OBJECT(window->SyslogButton),"clicked", G_CALLBACK(on_journald_open),widgets); } + window->log_name=name; gtk_entry_set_text(GTK_ENTRY(window->LogDescriptionEntry),description); config_str paths_parsed = yon_char_parse(paths,&size,"\n"); GtkWidget *last=NULL; @@ -510,7 +643,6 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ 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); - g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_close_subwindow),NULL); } } diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index 566c763..70e4fd1 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -164,6 +164,8 @@ typedef struct { GtkWidget *StatisticsFrame; GtkWidget *ControlSectionBox; GtkWidget *LogPathsBox; + + char *log_name; } add_log_window; typedef struct { @@ -244,9 +246,12 @@ typedef struct { GtkWidget *MainWindow; GtkWidget *CancelButton; GtkWidget *SaveButton; - GtkWidget *LogNamelabel; - GtkWidget *LogNameButton; - GtkWidget *LogNameDescriptionLabel; + GtkWidget *LogNameEntry; + GtkWidget *LogDescriptionEntry; + GtkWidget *LogPathsTree; + GtkWidget *LogPathEditButton; + GtkWidget *LogPathAddButton; + GtkWidget *LogPathRemoveButton; GtkWidget *RotationPeriodCheck; GtkWidget *RotationPeriodMainCombo; GtkWidget *RotationPeriodAdditionalCombo; @@ -292,6 +297,7 @@ typedef struct { GtkWidget *LogSizeLabel; GtkWidget *headerTopic; GtkListStore *list; + GtkCellRenderer *PathCell; } 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 8c9ae28..a218d94 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1929,7 +1929,7 @@ void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget gtk_widget_set_sensitive(target,gtk_combo_box_get_active(toggle)>=0 ? 1 : 0); } -void yon_gtk_widget_set_sensitive_from_toggle_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ +void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>=0 ? 0 : 1); } diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index cf4edb4..ae79699 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -188,7 +188,7 @@ - + True True @@ -223,7 +223,7 @@ - + True True @@ -265,7 +265,7 @@ vertical 5 - + True True True @@ -281,7 +281,7 @@ - + True True True @@ -297,7 +297,7 @@ - + True True True @@ -325,7 +325,7 @@ True in - + True True liststore1 @@ -337,7 +337,7 @@ Path - + 0 @@ -438,6 +438,7 @@ True + False False Week @@ -454,6 +455,7 @@ True + False False @@ -491,6 +493,7 @@ True + False True adjustment4 @@ -503,6 +506,7 @@ True + False False Kb @@ -583,6 +587,7 @@ True + False True adjustment6 @@ -607,6 +612,7 @@ True + False False Default @@ -621,6 +627,7 @@ True + False True @@ -632,6 +639,7 @@ True + False True True image4 @@ -803,6 +811,10 @@ True False + + On + Off + False @@ -839,6 +851,7 @@ True + False True adjustment7 @@ -889,6 +902,7 @@ True + False True adjustment5 @@ -939,6 +953,7 @@ True + False True adjustment8 @@ -951,6 +966,7 @@ True + False False Kb @@ -1006,6 +1022,7 @@ True + False True adjustment9 @@ -1018,6 +1035,7 @@ True + False False Kb @@ -1111,6 +1129,9 @@ False Default + Do not output + Output errors + Off @@ -1134,6 +1155,7 @@ True + False False Default @@ -1160,6 +1182,7 @@ True + False False Default @@ -1186,6 +1209,7 @@ True + False True @@ -1197,6 +1221,7 @@ True + False True True image5 @@ -1325,6 +1350,7 @@ True + False False 0 @@ -1405,6 +1431,8 @@ 0 Default + On + Off @@ -1416,6 +1444,7 @@ True + False True @@ -1455,6 +1484,8 @@ 0 Default + On + Off @@ -1494,6 +1525,8 @@ 0 Default + On + Off @@ -1505,6 +1538,7 @@ True + False True digits @@ -1605,6 +1639,7 @@ True + False True @@ -1628,6 +1663,7 @@ True + False False 0 From ef6504ce84c9f22e2103629d15b81ef008343d55 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Sat, 21 Oct 2023 18:00:40 +0600 Subject: [PATCH 11/25] Startup windows set up for future interactions --- source/ubl-settings-logging.c | 77 +++++++++++++++++----- ubl-settings-logging-journald.glade | 44 +++++++++++-- ubl-settings-logging-logrotate-table.glade | 9 +++ ubl-settings-logging-logrotate.glade | 10 ++- 4 files changed, 115 insertions(+), 25 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 36c6b72..226ae37 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -341,26 +341,26 @@ logrotate_configure_window *yon_logrotate_window_new(){ 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),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationPeriodAdditionalCombo); - g_signal_connect(G_OBJECT(window->RotationPeriodCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationPeriodMainCombo); + 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->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),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountSpin); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountCombo); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountEntry); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountButton); + 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->DoNotRotateYoungerCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DoNotRotateYoungerSpin); + 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),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeleteOlderSpin); + g_signal_connect(G_OBJECT(window->DeleteOlderCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeleteOlderSpin); - g_signal_connect(G_OBJECT(window->RotateSizeMaxAfterTimeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxAfterTimeSpin); - g_signal_connect(G_OBJECT(window->RotateSizeMaxAfterTimeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxAfterTimeCombo); + g_signal_connect(G_OBJECT(window->RotateSizeMaxAfterTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxAfterTimeSpin); + g_signal_connect(G_OBJECT(window->RotateSizeMaxAfterTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxAfterTimeCombo); - g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeSpin); - g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeCombo); + 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); @@ -377,11 +377,26 @@ void on_logrotate_add(GtkWidget *self, main_window *widgets){ void on_logrotate_edit(GtkWidget *self, logrotate_tab_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); - GtkTreeIter iter; + GtkTreeIter iter,itar; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model, &iter)){ + char *name; + char *paths; logrotate_configure_window *dialog = yon_logrotate_window_new(); - - gtk_widget_show(dialog->MainWindow); + gtk_widget_show(dialog->MainWindow); + gtk_tree_model_get(model,&iter,0,&name,1,&paths,-1); + gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name); + gtk_widget_set_can_focus(dialog->LogNameEntry,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_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"); + int size=0; + config_str path_parsed = yon_char_parse(paths,&size,"\n"); + for (int i=0;ilist,&itar); + gtk_list_store_set(dialog->list,&itar,0,path_parsed[i],-1); + } } } @@ -394,8 +409,16 @@ void on_logrotate_remove(GtkWidget *self, logrotate_tab_window *window){ } } -void on_logrotate_apps_configure(){ - +void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){ + GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_apps_list); + GtkTreeIter iter,itar; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->AppsMainTree)),&model,&iter)){ + char *paths; + char *name; + gtk_list_store_append(main_config.logrotate_list,&itar); + gtk_tree_model_get(model,&iter,0,&name,1,&paths,-1); + gtk_list_store_set(main_config.logrotate_list,&itar,0,name,1,paths,-1); + } } void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict){ @@ -452,7 +475,7 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_logrotate_add),window); 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),NULL); + g_signal_connect(G_OBJECT(window->AppsConfigureButton),"clicked",G_CALLBACK(on_logrotate_apps_configure),window); gtk_widget_show(window->Window); } @@ -500,6 +523,24 @@ void on_journald_open(GtkWidget *self, main_window *widgets){ 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->LogIntervalCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogIntervalSpin); + g_signal_connect(G_OBJECT(window->LogIntervalCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogIntervalAmountCheck); + g_signal_connect(G_OBJECT(window->LogIntervalAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogIntervalAmountSpin); + + g_signal_connect(G_OBJECT(window->LogSizeMaxCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogSizeMaxSpin); + g_signal_connect(G_OBJECT(window->LogSizeMaxCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogSizeMaxCombo); + + g_signal_connect(G_OBJECT(window->RotationSizeMaxCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationSizeMaxSpin); + g_signal_connect(G_OBJECT(window->RotationSizeMaxCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationSizeMaxCombo); + + g_signal_connect(G_OBJECT(window->LogFreeSpaceCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogFreeSpaceSpin); + g_signal_connect(G_OBJECT(window->LogFreeSpaceCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogFreeSpaceCombo); + + g_signal_connect(G_OBJECT(window->RedirectCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->RedirectTTYEntry); + + g_signal_connect(G_OBJECT(window->LogCompressionCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogCompressionEntry); + g_signal_connect(G_OBJECT(window->LogCompressionCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogCompressionSizeCombo); gtk_widget_show(window->MainWindow); } diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index 185ec96..b2c6f1d 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -253,6 +253,9 @@ 0 Default + RAM + Drive + Off @@ -292,6 +295,9 @@ 0 Default + Yes + No + After @@ -303,7 +309,9 @@ True + False True + number False @@ -314,6 +322,7 @@ True + False False 0 @@ -345,7 +354,7 @@ True False - Divide journal files: + Split journal files: False @@ -360,6 +369,8 @@ 0 Default + UID + No @@ -397,6 +408,7 @@ True + False True adjustment4 @@ -410,6 +422,7 @@ Records amount: True + False True False True @@ -423,6 +436,7 @@ True + False True adjustment5 @@ -461,6 +475,7 @@ True + False True adjustment6 @@ -473,13 +488,13 @@ True + False False 0 Kb Mb Gb - Tb @@ -517,6 +532,7 @@ True + False True adjustment7 @@ -529,12 +545,13 @@ True + False False + 0 Kb Mb Gb - Tb @@ -572,6 +589,7 @@ True + False True adjustment8 @@ -584,12 +602,13 @@ True + False False + 0 Kb Mb Gb - Tb @@ -628,6 +647,8 @@ False Default + Yes + No @@ -651,7 +672,9 @@ True + False True + alpha False @@ -689,6 +712,13 @@ False Default + emerg + alert + critlerr + warning + notice + info + debug @@ -798,6 +828,7 @@ True True + number False @@ -813,7 +844,6 @@ Kb Mb Gb - Tb @@ -864,6 +894,7 @@ True True + number False @@ -875,12 +906,13 @@ True False + 0 Minutes Hours Days Weeks - Months + Years diff --git a/ubl-settings-logging-logrotate-table.glade b/ubl-settings-logging-logrotate-table.glade index 5eeb2c1..7177eaa 100644 --- a/ubl-settings-logging-logrotate-table.glade +++ b/ubl-settings-logging-logrotate-table.glade @@ -195,6 +195,9 @@ Log/Journal + + 0 + @@ -203,6 +206,9 @@ Path + + 1 + @@ -211,6 +217,9 @@ Description + + 2 + diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index ae79699..749eaef 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -440,6 +440,7 @@ True False False + 0 Week Month @@ -508,11 +509,11 @@ True False False + 0 Kb Mb Gb - Tb @@ -614,6 +615,7 @@ True False False + 0 Default @@ -811,6 +813,7 @@ True False + 0 On Off @@ -968,6 +971,7 @@ True False False + 0 Kb Mb @@ -1037,6 +1041,7 @@ True False False + 0 Kb Mb @@ -1127,6 +1132,7 @@ True False + 0 Default Do not output @@ -1157,6 +1163,7 @@ True False False + 0 Default @@ -1184,6 +1191,7 @@ True False False + 0 Default From 850cac908ce49bd22919a97be592aed06e2d75bd Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 23 Oct 2023 18:02:46 +0600 Subject: [PATCH 12/25] Journald settings saving --- logging_services.csv | 4 +- source/ubl-settings-logging.c | 214 ++++++++++++++++++++++++--- source/ubl-settings-logging.h | 1 + source/ubl-strings.h | 3 +- source/ubl-utils.c | 38 ++++- source/ubl-utils.h | 6 + ubl-settings-logging-journald.glade | 75 ++++++---- ubl-settings-logging-logrotate.glade | 1 + ubl-settings-logging.pot | 2 +- ubl-settings-logging_ru.po | 2 +- 10 files changed, 296 insertions(+), 50 deletions(-) diff --git a/logging_services.csv b/logging_services.csv index ccc34a9..e9d43a8 100644 --- a/logging_services.csv +++ b/logging_services.csv @@ -1,4 +1,4 @@ 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 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 +#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 226ae37..b89a994 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -101,6 +101,28 @@ void on_about(){ gtk_widget_show(window); } +char *yon_size_get_letter_from_int(int size){ + switch (size){ + case 0: return "K"; + break; + case 1: return "M"; + break; + case 2: return "G"; + break; + } +} + +int yon_size_get_int_from_letter(char size){ + switch (size){ + case 'K': return 0; + break; + case 'M': return 1; + break; + case 'G': return 2; + break; + } +} + //functions void yon_load_proceed(char *command){ @@ -481,17 +503,145 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets){ // Journald window -void on_journald_open(GtkWidget *self, main_window *widgets){ +void yon_combo_compress_check(GtkComboBox *self, journald_window *window){ + if (gtk_combo_box_get_active(self)==3){ + gtk_widget_set_sensitive(window->LogCompressionSizeCombo,1); + gtk_widget_set_sensitive(window->LogCompressionEntry,1); + } else { + gtk_widget_set_sensitive(window->LogCompressionSizeCombo,0); + gtk_widget_set_sensitive(window->LogCompressionEntry,0); + } +} + +void on_journald_save(GtkWidget *self, journald_window *window){ + char *storage; + int storage_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogStorageCombo)); + switch (storage_active){ + case 0: storage="auto"; + break; + case 1: storage="volatile"; + break; + case 2: storage="persistent"; + break; + case 3: storage="none"; + break; + + } + char *compress; + int compress_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogCompressionCombo)); + if (compress_active==1) compress = "yes"; + else if (compress_active==2) compress = "no"; + else if (compress_active==3) { + int compress_size_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogCompressionSizeCombo)); + int compress_size = atoi(gtk_entry_get_text(GTK_ENTRY(window->LogCompressionEntry))); + compress=yon_char_from_int(compress_size); + if (compress_size==0) + compress_active=0; + switch (compress_size_active){ + case 0: compress = yon_char_append(compress,"K"); + break; + case 1: compress = yon_char_append(compress,"M"); + break; + case 2: compress = yon_char_append(compress,"G"); + break; + } + } + char *splitmode; + int splitmode_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->DivideJournalFilesCombo)); + if (splitmode_active == 1) splitmode = "uid"; + else if (splitmode_active == 2 ) splitmode = "none"; + + long interval=-1; + long amount=-1; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogIntervalCheck))){ + interval = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LogIntervalSpin)); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogIntervalAmountCheck))){ + amount = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LogIntervalAmountSpin)); + yon_config_register(JOURNALD("RateLimitBurst"),"logging",yon_char_from_long(amount)); + } + if (amount>0) + yon_config_register(JOURNALD("RateLimitIntervalSec"),"logging",yon_char_from_long(interval)); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogSizeMaxCheck))){ + long logssize=-1; + logssize = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LogSizeMaxSpin)); + int log_size_mod = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogSizeMaxCombo)); + for (int i=0;i0) + yon_config_register(JOURNALD("SystemMaxUse"),"logging",yon_char_from_long(logssize)); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotationSizeMaxCheck))){ + char * rotationMaxSize; + long maxsize = 0; + maxsize=gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->RotationSizeMaxSpin)); + char *modif = yon_size_get_letter_from_int(gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationSizeMaxCombo))); + rotationMaxSize = yon_char_append(yon_char_from_long(maxsize),modif); + if (maxsize>0) + yon_config_register(JOURNALD("SystemMaxFileSize"),"logging",rotationMaxSize); + } + + long storagefree; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogFreeSpaceCheck))){ + char *storagespace; + storagefree = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LogFreeSpaceSpin)); + char *modif = yon_size_get_letter_from_int(gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogFreeSpaceCombo))); + storagespace = yon_char_append(yon_char_from_long(storagefree),modif); + + if (storagefree>0) + yon_config_register(JOURNALD("SystemKeepFree"),"logging",storagespace); + } + + int consoleforwardactive = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RedirectCombo)); + char *confor=NULL; + char *TTY=NULL; + if (consoleforwardactive == 1){ + confor = "yes"; + TTY = (char*)gtk_entry_get_text(GTK_ENTRY(window->RedirectTTYEntry)); + if (yon_char_is_empty(TTY)) + consoleforwardactive=0; + } + else if (consoleforwardactive == 2){ + confor = "no"; + } + + int forwardempty = gtk_combo_box_get_active(GTK_COMBO_BOX(window->ForwardedTypeCombo)); + + + yon_config_register(JOURNALD("Storage"),"logging",storage); + if (compress_active!=0) + yon_config_register(JOURNALD("Compress"),"logging",compress); + else + yon_config_remove_by_key(JOURNALD("Compress")); + if (splitmode_active!=0) + yon_config_register(JOURNALD("SplitMode"),"logging",splitmode); + else + yon_config_remove_by_key(JOURNALD("SplitMode")); + if (consoleforwardactive != 0) + yon_config_register(JOURNALD("ForwardToConsole"),"logging",confor); + else + yon_config_remove_by_key(JOURNALD("ForwardToConsole")); + if (forwardempty!=0) + yon_config_register(JOURNALD("MaxLevelConsole"),"logging",yon_char_from_int(forwardempty-1)); + else + yon_config_remove_by_key(JOURNALD("MaxLevelConsole")); + on_close_subwindow(window->MainWindow); +} + +journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ journald_window *window = malloc(sizeof(journald_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_journald_path); window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); window->SaveButton=yon_gtk_builder_get_widget(builder,"SaveButton"); - window->LogNameLabel=yon_gtk_builder_get_widget(builder,"LogNameLabel"); - window->LogDescriptionLabel=yon_gtk_builder_get_widget(builder,"LogDescriptionLabel"); + window->LogNameLabel=yon_gtk_builder_get_widget(builder,"LogNameEntry"); + window->LogDescriptionLabel=yon_gtk_builder_get_widget(builder,"LogDescriptionEntry"); window->LogStorageCombo=yon_gtk_builder_get_widget(builder,"LogStorageCombo"); window->LogCompressionCombo=yon_gtk_builder_get_widget(builder,"LogCompressionCombo"); - window->LogCompressionEntry=yon_gtk_builder_get_widget(builder,"LogCompressionEntry"); + window->LogCompressionEntry=yon_gtk_builder_get_widget(builder,"LogCompressionSpin"); window->LogCompressionSizeCombo=yon_gtk_builder_get_widget(builder,"LogCompressionSizeCombo"); window->DivideJournalFilesCombo=yon_gtk_builder_get_widget(builder,"DivideJournalFilesCombo"); window->LogIntervalCheck=yon_gtk_builder_get_widget(builder,"LogIntervalCheck"); @@ -511,10 +661,10 @@ void on_journald_open(GtkWidget *self, main_window *widgets){ window->RedirectTTYEntry=yon_gtk_builder_get_widget(builder,"RedirectTTYEntry"); window->ForwardedTypeCombo=yon_gtk_builder_get_widget(builder,"ForwardedTypeCombo"); window->LogSizeLabel=yon_gtk_builder_get_widget(builder,"LogSizeLabel"); - window->LowerSizeEntry=yon_gtk_builder_get_widget(builder,"LowerSizeEntry"); + window->LowerSizeEntry=yon_gtk_builder_get_widget(builder,"LowerSizeSpin"); window->LowerSizeCombo=yon_gtk_builder_get_widget(builder,"LowerSizeCombo"); window->LowerSizeButton=yon_gtk_builder_get_widget(builder,"LowerSizeButton"); - window->LowerTimeEntry=yon_gtk_builder_get_widget(builder,"LowerTimeEntry"); + window->LowerTimeEntry=yon_gtk_builder_get_widget(builder,"LowerTimeSpin"); window->LowerTimeCombo=yon_gtk_builder_get_widget(builder,"LowerTimeCombo"); window->LowerTimeButton=yon_gtk_builder_get_widget(builder,"LowerTimeButton"); window->headerTopic=yon_gtk_builder_get_widget(builder,"headerTopic"); @@ -522,7 +672,7 @@ void on_journald_open(GtkWidget *self, main_window *widgets){ gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); 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_journald_save),window); g_signal_connect(G_OBJECT(window->LogIntervalCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogIntervalSpin); g_signal_connect(G_OBJECT(window->LogIntervalCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogIntervalAmountCheck); @@ -539,11 +689,37 @@ void on_journald_open(GtkWidget *self, main_window *widgets){ g_signal_connect(G_OBJECT(window->RedirectCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->RedirectTTYEntry); - g_signal_connect(G_OBJECT(window->LogCompressionCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogCompressionEntry); - g_signal_connect(G_OBJECT(window->LogCompressionCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogCompressionSizeCombo); - gtk_widget_show(window->MainWindow); + g_signal_connect(G_OBJECT(window->LogCompressionCombo),"changed",G_CALLBACK(yon_combo_compress_check),window); + return window; } +void on_journald_open(GtkWidget *self, main_window *widgets){ + journald_window *window = yon_journald_open(self,widgets); + GtkTreeIter iter; + GtkTreeModel *model; + GtkWidget *tree_view; + char *name, *description; + int name_col, desc_col; + if (self == widgets->ServicesEditButton){ + model = GTK_TREE_MODEL(widgets->ServicesList); + tree_view = widgets->ServicesTree; + name_col = 2; + desc_col = 3; + } else { + model = GTK_TREE_MODEL(widgets->list); + tree_view = widgets->MainTree; + name_col = 0; + desc_col = 2; + } + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)),&model,&iter)){ + gtk_tree_model_get(model,&iter,name_col,&name,desc_col,&description,-1); + gtk_entry_set_text(GTK_ENTRY(window->LogDescriptionLabel),description); + gtk_entry_set_text(GTK_ENTRY(window->LogNameLabel),name); + } + int jsize; + config_str journald_parameters = yon_config_get_all_by_key("JOURNALD[",&jsize); + gtk_widget_show(window->MainWindow); +} // Log adding menu @@ -569,7 +745,6 @@ add_log_window *on_add_open(){ gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); 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_close_subwindow),NULL); return window; } @@ -661,7 +836,7 @@ void on_log_edit(GtkWidget *self,main_window *widgets){ yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); g_signal_connect(G_OBJECT(window->LogrotateButton),"clicked", G_CALLBACK(on_log_edit_logrotate_settings),dict); // g_signal_connect(G_OBJECT(window->MetalogButton),"clicked", G_CALLBACK(on_log),widgets); - // g_signal_connect(G_OBJECT(window->SyslogButton),"clicked", G_CALLBACK(on_journald_open),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); @@ -697,6 +872,7 @@ void on_log_remove(GtkWidget *self, main_window *widgets){ // Main window + void on_service_edit(GtkWidget *self,main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->ServicesList); GtkTreeIter iter; @@ -704,7 +880,7 @@ void on_service_edit(GtkWidget *self,main_window *widgets){ char *name; gtk_tree_model_get(model,&iter,2,&name,-1); if (!strcmp(name,"journald")){ - on_journald_open(NULL,widgets); + on_journald_open(self,widgets); } else { on_logrotate_tab_open(NULL,widgets); } @@ -809,11 +985,13 @@ main_window *setup_window(){ } config_str services = yon_file_open(services_list_path,&service_size); for (int i=0;iServicesList,&iter); - gtk_list_store_set(widgets->ServicesList,&iter,0,0,1,0,2,log[0],3,log[1],-1); + if (services[i][0]!='#'){ + int log_size; + 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,0,1,0,2,log[0],3,log[1],-1); + } } config_str dirs = yon_config_load(logrotate_config_command,&dirs_size); for (int i=0;i= 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = g_malloc0(i * sizeof(char) + 1); + sprintf(ch, "%ld", int_to_convert); + return ch; +} + /**yon_char_replace(char *source, char *find, char*replace) * [EN] * @@ -1161,6 +1181,20 @@ void *yon_config_get_by_key(char *key){ return NULL; } +void *yon_config_get_all_by_key(char *key, int *size){ + check_config{ + config_str ret_data=NULL; + dictionary *dict = NULL; + for_dictionaries(dict, (dictionary*)__yon__config__strings){ + if (strstr(dict->key,key)) { + if (ret_data) ret_data = yon_char_parsed_append(ret_data,size,dict->key); + else ret_data = yon_char_parsed_new(size,dict->key,NULL); + } + } + return ret_data; + } +} + /**yon_config_get_key_by_data(char *data) * [EN] * @@ -1926,11 +1960,11 @@ void yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *t } void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target){ - gtk_widget_set_sensitive(target,gtk_combo_box_get_active(toggle)>=0 ? 1 : 0); + gtk_widget_set_sensitive(target,gtk_combo_box_get_active(toggle)>0 ? 1 : 0); } void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ - gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>=0 ? 0 : 1); + gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>0 ? 0 : 1); } void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) diff --git a/source/ubl-utils.h b/source/ubl-utils.h index db8ade7..8261a80 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -123,6 +123,8 @@ void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(vo #define yon_char_divide_search_self(str,find,delete_divider) {char *temp = str; str = yon_char_divide_search(str,find,delete_divider); free(temp);} +#define yon_char_is_empty(string) !string||!strcmp(string,"") + int yon_char_find_last(char *source, char find); char *yon_char_append(char *source, char *append); @@ -139,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_long(long int_to_convert); + char *yon_char_replace(char *source, char *find, char*replace); char **yon_char_parse(char *parameters, int *size, char *divider); @@ -206,6 +210,8 @@ int yon_config_remove_element(char *key, char *deleted); void *yon_config_get_by_key(char *key); +void *yon_config_get_all_by_key(char *key, int *size); + char *yon_config_get_key_by_data(char *data); int yon_config_set(char *key, void *data); diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index b2c6f1d..3db6728 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -9,6 +9,16 @@ 1 10 + + 100 + 1 + 10 + + + 100 + 1 + 10 + 1024 1 @@ -44,6 +54,11 @@ 1 10 + + 100 + 1 + 10 + True False @@ -136,10 +151,11 @@ False 5 - + True False Log/Journal: + 0 False @@ -148,15 +164,15 @@ - + True - False - logname + True + journald - False + True True - 1 + 2 @@ -172,10 +188,11 @@ False 5 - + True False Description: + 0 False @@ -184,15 +201,15 @@ - + True - False - logdescription + False + True - False + True True - 1 + 2 @@ -214,7 +231,7 @@ True False - 0 + 0.019999999552965164 in @@ -255,7 +272,7 @@ Default RAM Drive - Off + None @@ -307,11 +324,10 @@ - + True - False True - number + adjustment11 False @@ -329,7 +345,6 @@ Kb Mb Gb - Tb @@ -574,7 +589,7 @@ 5 - Leave free space at storage: + Leave free space at storage: True True False @@ -645,6 +660,7 @@ True False + 0 Default Yes @@ -710,11 +726,13 @@ True False + 0 Default emerg alert - critlerr + crit + err warning notice info @@ -756,7 +774,7 @@ True False - 0 + 0.019999999552965164 in @@ -825,10 +843,10 @@ - + True True - number + adjustment9 False @@ -840,6 +858,7 @@ True False + 0 Kb Mb @@ -891,10 +910,10 @@ - + True True - number + adjustment10 False @@ -1009,4 +1028,10 @@ + + + + + + diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 749eaef..2348b62 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -775,6 +775,7 @@ True False + 0 Output errors if log file does not exist diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 12654a8..2084a25 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -270,7 +270,7 @@ msgid "Use compression:" msgstr "" #: source/ubl-strings.h:71 -msgid "Divide journal files:" +msgid "Split journal files:" msgstr "" #: source/ubl-strings.h:72 diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index 9c7fac6..e634f7e 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -276,7 +276,7 @@ msgid "Use compression:" msgstr "Использовать сжатие:" #: source/ubl-strings.h:71 -msgid "Divide journal files:" +msgid "Split journal files:" msgstr "Разделять файлы журнала:" #: source/ubl-strings.h:72 From 6c993474ce459120c8f92043ef2c19e07be11ca0 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 23 Oct 2023 18:12:15 +0600 Subject: [PATCH 13/25] Fixes --- source/ubl-settings-logging.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index b89a994..50f8252 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -517,13 +517,13 @@ void on_journald_save(GtkWidget *self, journald_window *window){ char *storage; int storage_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogStorageCombo)); switch (storage_active){ - case 0: storage="auto"; + case 1: storage="auto"; break; - case 1: storage="volatile"; + case 2: storage="volatile"; break; - case 2: storage="persistent"; + case 3: storage="persistent"; break; - case 3: storage="none"; + case 4: storage="none"; break; } @@ -561,6 +561,10 @@ void on_journald_save(GtkWidget *self, journald_window *window){ } if (amount>0) yon_config_register(JOURNALD("RateLimitIntervalSec"),"logging",yon_char_from_long(interval)); + } else { + yon_config_remove_by_key(JOURNALD("RateLimitBurst")); + yon_config_remove_by_key(JOURNALD("RateLimitIntervalSec")); + } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogSizeMaxCheck))){ @@ -572,7 +576,8 @@ void on_journald_save(GtkWidget *self, journald_window *window){ } if (logssize>0) yon_config_register(JOURNALD("SystemMaxUse"),"logging",yon_char_from_long(logssize)); - } + } else + yon_config_remove_by_key(JOURNALD("SystemMaxUse")); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotationSizeMaxCheck))){ char * rotationMaxSize; @@ -582,7 +587,8 @@ void on_journald_save(GtkWidget *self, journald_window *window){ rotationMaxSize = yon_char_append(yon_char_from_long(maxsize),modif); if (maxsize>0) yon_config_register(JOURNALD("SystemMaxFileSize"),"logging",rotationMaxSize); - } + } else + yon_config_remove_by_key(JOURNALD("SystemMaxFileSize")); long storagefree; if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogFreeSpaceCheck))){ @@ -593,7 +599,8 @@ void on_journald_save(GtkWidget *self, journald_window *window){ if (storagefree>0) yon_config_register(JOURNALD("SystemKeepFree"),"logging",storagespace); - } + } else + yon_config_remove_by_key(JOURNALD("SystemKeepFree")); int consoleforwardactive = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RedirectCombo)); char *confor=NULL; @@ -610,8 +617,10 @@ void on_journald_save(GtkWidget *self, journald_window *window){ int forwardempty = gtk_combo_box_get_active(GTK_COMBO_BOX(window->ForwardedTypeCombo)); - - yon_config_register(JOURNALD("Storage"),"logging",storage); + if (storage_active!=0) + yon_config_register(JOURNALD("Storage"),"logging",storage); + else + yon_config_remove_by_key(JOURNALD("Storage")); if (compress_active!=0) yon_config_register(JOURNALD("Compress"),"logging",compress); else From 448912713e3a8d80e736f753e02bb294233d52bc Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 24 Oct 2023 09:26:36 +0600 Subject: [PATCH 14/25] Fixed moving status label --- ubl-settings-logging.glade | 1 + 1 file changed, 1 insertion(+) diff --git a/ubl-settings-logging.glade b/ubl-settings-logging.glade index a900475..3f720ec 100644 --- a/ubl-settings-logging.glade +++ b/ubl-settings-logging.glade @@ -594,6 +594,7 @@ translated and supported by community. 6 6 True + 0 From 92dba6c91098e24d412ecbdb2a69f3ba04fbcefb Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 24 Oct 2023 09:53:25 +0600 Subject: [PATCH 15/25] Journald window entry fixes --- source/ubl-strings.h | 2 +- ubl-settings-logging-logrotate.glade | 6 +++++- ubl-settings-logging.pot | 2 +- ubl-settings-logging_ru.po | 8 ++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 98bec25..6a45a4d 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -130,7 +130,7 @@ #define CONTENTS_LABEL _("contents:") #define MESSAGE_CONFIGURATION_LABEL _("Message configuration") #define MANUAL_LABEL _("Manual input:") -#define LOG_SIZE_LABEL _("Log size:") +#define LOG_SIZE_LABEL _("Log (-s) size:") //ubl-settings-logging-logrotate-table.glade #define SYSTEM_CONFIGURATION_LABEL _("System configuration") diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 2348b62..a706520 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -180,6 +180,7 @@ True False Log/Journal: + 0 False @@ -190,6 +191,7 @@ True + False True @@ -215,6 +217,7 @@ True False Description: + 0 False @@ -225,6 +228,7 @@ True + False True @@ -1980,7 +1984,7 @@ True False - Log size: + Log (-s) size: False diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 2084a25..0b7d365 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -508,7 +508,7 @@ msgid "Manual input:" msgstr "" #: source/ubl-strings.h:132 -msgid "Log size:" +msgid "Log (-s) size:" msgstr "" #: source/ubl-strings.h:135 diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index e634f7e..56c15ba 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -341,7 +341,7 @@ msgstr "Пути к файлам лога/журнала" #: source/ubl-strings.h:89 msgid "Default" -msgstr "По умлочанию" +msgstr "По умолчанию" #: source/ubl-strings.h:90 msgid "On" @@ -465,7 +465,7 @@ msgid "" "file and creating new one" msgstr "" "После создания копии, обрезать исходный файл журнала взамен перемещения " -"старого\n" +"старого " "файла журнала и создания нового" #: source/ubl-strings.h:120 @@ -518,8 +518,8 @@ msgid "Manual input:" msgstr "Команды настройки" #: source/ubl-strings.h:132 -msgid "Log size:" -msgstr "Общий размер лога" +msgid "Log (-s) size:" +msgstr "Общий размер лога (-ов):" #: source/ubl-strings.h:135 msgid "System configuration" From ad4068628035ca8169a79dae9744e7b2db210cb4 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 24 Oct 2023 10:11:51 +0600 Subject: [PATCH 16/25] Horizontal scroll for logrotate window --- ubl-settings-logging-logrotate.glade | 1 - 1 file changed, 1 deletion(-) diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index a706520..b870edd 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -148,7 +148,6 @@ True True - never in From b50f83abb950bcee52e0a4fcc2d36521f83618aa Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 24 Oct 2023 18:08:31 +0600 Subject: [PATCH 17/25] Logrotate saving has been partially implemented --- source/ubl-settings-logging.c | 189 ++++++++++++++++++++++++++- source/ubl-utils.c | 5 +- ubl-settings-logging-journald.glade | 2 + ubl-settings-logging-logrotate.glade | 30 ++++- 4 files changed, 214 insertions(+), 12 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 50f8252..44bc85d 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -296,6 +296,129 @@ void on_logrotate_configuration_path_remove(GtkWidget *self, logrotate_configure } } +void on_logrotate_save(GtkWidget *self, logrotate_configure_window *window){ + char *paths=""; + char *period=""; + char *size=""; + char *rotate_count=""; + char *olddir=""; + char *su=""; + char *missingok=""; + char *ifempty=""; + char *notifempty=""; + char *minage=""; + char *maxage=""; + char *minsize=""; + char *maxsize=""; + char *create=""; + char *copytruncate=""; + char *compress=""; + char *delaycompress=""; + char *extension=""; + char *dateext=""; + char *start=""; + char *mail=""; + char *mailfirst=""; + char *sharedscripts=""; + char *firstaction=""; + char *lastaction=""; + char *prerotate=""; + char *postrotate=""; + char *preremove=""; + char *endscript=""; + + GtkTreeIter iter; + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){ + char *cur_path; + gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&cur_path,-1); + paths = yon_char_unite(paths,strcmp(paths,"") ? "," : "", cur_path,NULL); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck))){ + int active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo)); + switch (active){ + case 0: period = "hourly"; + break; + case 2: period = "daily"; + break; + case 3: period = "weekly"; + int weekday = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationPeriodAdditionalCombo)); + weekday++; + if (weekday==7) weekday=0; + period = yon_char_unite(period,", ",yon_char_from_int(weekday)); + break; + case 4: period = "monthly"; + break; + case 5: period = "yearly"; + break; + } + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->JournalMaxSizeCheck))){ + int last = gtk_combo_box_get_active(GTK_COMBO_BOX(window->JournalMaxSizeCombo)); + long maxsize = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->JournalMaxSizeSpin)); + size = yon_char_unite(yon_char_from_long(maxsize),yon_size_get_letter_from_int(last)); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck))){ + long fileamount = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->FileAmountSpin)); + int active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->FileAmountCombo)); + if (active==2){ + const char *text = gtk_entry_get_text(GTK_ENTRY(window->FileAmountEntry)); + rotate_count=yon_char_unite("olddir",",",text,NULL); + } + } + + char *user_rotate = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RotationAtUserCombo)); + char *group_rotate = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RotationAtGroupCombo)); + if (!yon_char_is_empty(user_rotate)&&!yon_char_is_empty(group_rotate)) + su = yon_char_unite("su ",user_rotate," ",group_rotate,NULL); + + int error_processing = gtk_combo_box_get_active(GTK_COMBO_BOX(window->ErrorProcessingCombo)); + if (error_processing==0|| error_processing==1) { + error_processing=1; + missingok = "missingok"; + } else { + missingok = "nomissingok"; + } + + int empty_journal = gtk_combo_box_get_active(window->JournalEmptyCombo); + if (empty_journal==0||empty_journal==1) { + empty_journal = 1; + ifempty = "ifempty"; + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DoNotRotateYoungerCheck))){ + long younger = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DoNotRotateYoungerSpin)); + minage = yon_char_append("minage ",yon_char_from_long(younger)); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeleteOlderCheck))){ + long older = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeleteOlderSpin)); + maxage = yon_char_append("maxage ", yon_char_from_long(older)); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxAfterTimeCheck))){ + long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->RotateSizeMaxAfterTimeSpin)); + int last = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotateSizeMaxAfterTimeCombo)); + minsize = yon_char_unite("minsize ",yon_char_from_long(value),yon_size_get_letter_from_int(last)); + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxBeforeTimeCheck))){ + long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->RotateSizeMaxBeforeTimeSpin)); + int last = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotateSizeMaxBeforeTimeCombo)); + maxsize = yon_char_unite("maxsize ", yon_char_from_long(value),yon_size_get_letter_from_int(last)); + } + + // int create_log_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->CreateLogCombo)); + // if (create_log_active){ + // if (create_log_active==2) + // } + + copytruncate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CutCheck)) ? "copytruncate" : ""; + +} + logrotate_configure_window *yon_logrotate_window_new(){ logrotate_configure_window *window = malloc(sizeof(logrotate_configure_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_path); @@ -356,7 +479,7 @@ logrotate_configure_window *yon_logrotate_window_new(){ window->PathCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"PathCell")); gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL); 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_logrotate_save),NULL); g_signal_connect(G_OBJECT(window->PathCell),"edited",G_CALLBACK(on_path_editing_done),window); g_signal_connect(G_OBJECT(window->PathCell),"editing-canceled",G_CALLBACK(on_path_editing_cancel),window); g_signal_connect(G_OBJECT(window->LogPathAddButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_add),window); @@ -517,11 +640,11 @@ void on_journald_save(GtkWidget *self, journald_window *window){ char *storage; int storage_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->LogStorageCombo)); switch (storage_active){ - case 1: storage="auto"; + case 1: storage="volatile"; break; - case 2: storage="volatile"; + case 2: storage="persistent"; break; - case 3: storage="persistent"; + case 3: storage="auto"; break; case 4: storage="none"; break; @@ -557,9 +680,10 @@ void on_journald_save(GtkWidget *self, journald_window *window){ interval = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LogIntervalSpin)); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->LogIntervalAmountCheck))){ amount = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LogIntervalAmountSpin)); - yon_config_register(JOURNALD("RateLimitBurst"),"logging",yon_char_from_long(amount)); + if (amount>0) + yon_config_register(JOURNALD("RateLimitBurst"),"logging",yon_char_from_long(amount)); } - if (amount>0) + if (interval>0) yon_config_register(JOURNALD("RateLimitIntervalSec"),"logging",yon_char_from_long(interval)); } else { yon_config_remove_by_key(JOURNALD("RateLimitBurst")); @@ -697,6 +821,59 @@ journald_window *yon_journald_open(GtkWidget *self, main_window *widgets){ g_signal_connect(G_OBJECT(window->LogFreeSpaceCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->LogFreeSpaceCombo); g_signal_connect(G_OBJECT(window->RedirectCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->RedirectTTYEntry); + int size=0; + config_str settings = yon_config_get_all_by_key("JOURNALD",&size); + for (int i=0;iLogStorageCombo),1); + else if (!strcmp(settings[i],"persistent")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogStorageCombo),2); + else if (!strcmp(settings[i],"auto")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogStorageCombo),3); + else if (!strcmp(settings[i],"none")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogStorageCombo),4); + + }else if (!strcmp(JOURNALD("Compress"),name)){ + if (!strcmp(settings[i],"yes")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionCombo),1); + else if (!strcmp(settings[i],"no")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionCombo),2); + else { + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionCombo),3); + char last = settings[i][strlen(settings[i])-1]; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogCompressionEntry),atoi(settings[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogCompressionSizeCombo),yon_size_get_int_from_letter(last)); + } + + }else if (!strcmp(JOURNALD("SplitMode"),name)){ + if (!strcmp(settings[i],"uid")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->DivideJournalFilesCombo),1); + else if (!strcmp(settings[i],"none")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->DivideJournalFilesCombo),2); + }else if (!strcmp(JOURNALD("RateLimitIntervalSec"),name)){ + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogIntervalSpin),atol(settings[i])); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogIntervalCheck),1); + }else if (!strcmp(JOURNALD("RateLimitBurst"),name)){ + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogIntervalAmountSpin),atol(settings[i])); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogIntervalAmountCheck),1); + }else if (!strcmp(JOURNALD("SystemMaxUse"),name)){ + char last = settings[i][strlen(settings[i])-1]; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogSizeMaxSpin),atol(settings[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogSizeMaxCombo),yon_size_get_int_from_letter(last)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogSizeMaxCheck),1); + }else if (!strcmp(JOURNALD("SystemKeepFree"),name)){ + char last = settings[i][strlen(settings[i])-1]; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->LogFreeSpaceSpin),atol(settings[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->LogFreeSpaceCombo),yon_size_get_int_from_letter(last)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->LogFreeSpaceCheck),1); + }else if (!strcmp(JOURNALD("SystemMaxFileSize"),name)){ + char last = settings[i][strlen(settings[i])-1]; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotationSizeMaxSpin),atol(settings[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationSizeMaxCombo),yon_size_get_int_from_letter(last)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationSizeMaxCheck),1); + }else if (!strcmp(JOURNALD("ForwardToConsole"),name)){ + if (!strcmp(settings[i],"yes")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->RedirectCombo),1); + else if (!strcmp(settings[i],"no")) gtk_combo_box_set_active(GTK_COMBO_BOX(window->RedirectCombo),2); + }else if (!strcmp(JOURNALD("TTYPath"),name)){ + gtk_entry_set_text(GTK_ENTRY(window->RedirectTTYEntry), settings[i]); + }else if (!strcmp(JOURNALD("MaxLevelConsole"),name)){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->ForwardedTypeCombo),atoi(settings[i])+1); + } + } g_signal_connect(G_OBJECT(window->LogCompressionCombo),"changed",G_CALLBACK(yon_combo_compress_check),window); return window; diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 27d75ac..3ed0e09 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1187,8 +1187,9 @@ void *yon_config_get_all_by_key(char *key, int *size){ dictionary *dict = NULL; for_dictionaries(dict, (dictionary*)__yon__config__strings){ if (strstr(dict->key,key)) { - if (ret_data) ret_data = yon_char_parsed_append(ret_data,size,dict->key); - else ret_data = yon_char_parsed_new(size,dict->key,NULL); + char *ret_string = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); + if (ret_data) ret_data = yon_char_parsed_append(ret_data,size,ret_string); + else ret_data = yon_char_parsed_new(size,ret_string,NULL); } } return ret_data; diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index 3db6728..43c4722 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -272,6 +272,7 @@ Default RAM Drive + Auto None @@ -326,6 +327,7 @@ True + False True adjustment11 diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index b870edd..d324d06 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -445,9 +445,11 @@ False 0 - Week - Month - Year + Hourly + Daily + Weekly + Monthly + Yearly @@ -461,6 +463,15 @@ True False False + + Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday + False @@ -621,6 +632,8 @@ 0 Default + Same directory + Separate directory @@ -683,6 +696,9 @@ True False + + root* + False @@ -706,6 +722,9 @@ True False + + root* + False @@ -780,7 +799,9 @@ False 0 - Output errors if log file does not exist + Default + Output errors if log file does not exist* + Do not output errors if log file does not exist @@ -819,6 +840,7 @@ False 0 + Default On Off From ffb3141fa052ded32f1251fc199507e15d1e12fd Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 25 Oct 2023 14:06:46 +0600 Subject: [PATCH 18/25] Logrotate window saving --- source/ubl-settings-logging.c | 107 +++++++++++++++++++++++++-- source/ubl-settings-logging.h | 9 +++ source/ubl-utils.h | 2 +- ubl-settings-logging-logrotate.glade | 67 ++++++++++++++--- 4 files changed, 168 insertions(+), 17 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 44bc85d..2d3f6c0 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -345,7 +345,7 @@ void on_logrotate_save(GtkWidget *self, logrotate_configure_window *window){ int weekday = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationPeriodAdditionalCombo)); weekday++; if (weekday==7) weekday=0; - period = yon_char_unite(period,", ",yon_char_from_int(weekday)); + period = yon_char_unite(period,", ",yon_char_from_int(weekday),NULL); break; case 4: period = "monthly"; break; @@ -357,7 +357,7 @@ void on_logrotate_save(GtkWidget *self, logrotate_configure_window *window){ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->JournalMaxSizeCheck))){ int last = gtk_combo_box_get_active(GTK_COMBO_BOX(window->JournalMaxSizeCombo)); long maxsize = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->JournalMaxSizeSpin)); - size = yon_char_unite(yon_char_from_long(maxsize),yon_size_get_letter_from_int(last)); + size = yon_char_unite("size ",yon_char_from_long(maxsize),yon_size_get_letter_from_int(last),NULL); } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck))){ @@ -371,8 +371,11 @@ void on_logrotate_save(GtkWidget *self, logrotate_configure_window *window){ char *user_rotate = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RotationAtUserCombo)); char *group_rotate = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->RotationAtGroupCombo)); - if (!yon_char_is_empty(user_rotate)&&!yon_char_is_empty(group_rotate)) + if (!yon_char_is_empty(user_rotate)&&!yon_char_is_empty(group_rotate)){ + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationAtUserCombo))==0) user_rotate = "root"; + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationAtGroupCombo))==0) group_rotate = "root"; su = yon_char_unite("su ",user_rotate," ",group_rotate,NULL); + } int error_processing = gtk_combo_box_get_active(GTK_COMBO_BOX(window->ErrorProcessingCombo)); if (error_processing==0|| error_processing==1) { @@ -382,7 +385,7 @@ void on_logrotate_save(GtkWidget *self, logrotate_configure_window *window){ missingok = "nomissingok"; } - int empty_journal = gtk_combo_box_get_active(window->JournalEmptyCombo); + int empty_journal = gtk_combo_box_get_active(GTK_COMBO_BOX(window->JournalEmptyCombo)); if (empty_journal==0||empty_journal==1) { empty_journal = 1; ifempty = "ifempty"; @@ -401,13 +404,13 @@ void on_logrotate_save(GtkWidget *self, logrotate_configure_window *window){ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxAfterTimeCheck))){ long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->RotateSizeMaxAfterTimeSpin)); int last = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotateSizeMaxAfterTimeCombo)); - minsize = yon_char_unite("minsize ",yon_char_from_long(value),yon_size_get_letter_from_int(last)); + minsize = yon_char_unite("minsize ",yon_char_from_long(value),yon_size_get_letter_from_int(last),NULL); } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxBeforeTimeCheck))){ long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->RotateSizeMaxBeforeTimeSpin)); int last = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotateSizeMaxBeforeTimeCombo)); - maxsize = yon_char_unite("maxsize ", yon_char_from_long(value),yon_size_get_letter_from_int(last)); + maxsize = yon_char_unite("maxsize ", yon_char_from_long(value),yon_size_get_letter_from_int(last),NULL); } // int create_log_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->CreateLogCombo)); @@ -416,7 +419,88 @@ void on_logrotate_save(GtkWidget *self, logrotate_configure_window *window){ // } copytruncate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CutCheck)) ? "copytruncate" : ""; + + int compression_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->CompressionCombo)); + if (compression_active){ + switch (compression_active){ + case 1: compress = "compress"; + break; + case 2: compress = "nocompress"; + break; + } + } + + int compression_delay_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->QueueCombo)); + if (compression_delay_active){ + switch (compression_delay_active){ + case 1: delaycompress = "delaycompress"; + break; + case 2: delaycompress = "nodelaycompress"; + break; + } + } + + int original_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->SaveOriginalCombo)); + if (original_active==1){ + char *ext_file = (char*)gtk_entry_get_text(GTK_ENTRY(window->SaveOriginalEntry)); + extension = yon_char_append("extension ",ext_file); + } + + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->AddDateCombo))==1){ + dateext = "dateext"; + } + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->OldNumberCombo))==1){ + long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->OldNumberEntry)); + if (value>0) + start = yon_char_append("start ",yon_char_from_long(value)); + } + + int email_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->EmailCombo)); + if (email_active){ + switch(email_active){ + case 1: + char *adress = (char*)gtk_entry_get_text(GTK_ENTRY(window->EmailEntry)); + if (!yon_char_is_empty(adress)) + mail=yon_char_append("mail ", adress); + int contents_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->EmailContentsCombo)); + if (contents_active==1) + mailfirst = "mailfirst"; + else if (contents_active==2) + mailfirst = "maillast"; + break; + case 2: mail = "nomail"; + break; + } + } + + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->SharedScenariosCheck))){ + char *before_once = (char*)gtk_entry_get_text(GTK_ENTRY(window->CommandBeforeOnceEntry)); + char *after_once = (char*)gtk_entry_get_text(GTK_ENTRY(window->CommandAfterOnceEntry)); + char *before = (char*)gtk_entry_get_text(GTK_ENTRY(window->CommandBeforeEntry)); + 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)) + firstaction = yon_char_append("firstaction ",before_once); + if (!yon_char_is_empty(after_once)) + lastaction = yon_char_append("lastaction ",after_once); + if (!yon_char_is_empty(before)) + prerotate = yon_char_append("prerotate ",before); + if (!yon_char_is_empty(after)) + postrotate = yon_char_append("postrotate ",after); + if (!yon_char_is_empty(endwork)) + endscript = yon_char_append("endscript ",endwork); + } + + 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(!yon_char_is_empty(paths)){ + yon_config_register(LOGROTATE(paths),"logging",commandline); + on_close_subwindow(window->MainWindow); + } } logrotate_configure_window *yon_logrotate_window_new(){ @@ -477,9 +561,15 @@ logrotate_configure_window *yon_logrotate_window_new(){ window->LogPathRemoveButton=yon_gtk_builder_get_widget(builder,"LogPathRemoveButton"); window->list=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); window->PathCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"PathCell")); + window->SharedScenariosCheck=yon_gtk_builder_get_widget(builder,"SharedScenariosCheck"); + window->CommandBeforeOnceEntry=yon_gtk_builder_get_widget(builder,"CommandBeforeOnceEntry"); + window->CommandAfterOnceEntry=yon_gtk_builder_get_widget(builder,"CommandAfterOnceEntry"); + window->CommandBeforeEntry=yon_gtk_builder_get_widget(builder,"CommandBeforeEntry"); + 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); 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_logrotate_save),NULL); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_logrotate_save),window); g_signal_connect(G_OBJECT(window->PathCell),"edited",G_CALLBACK(on_path_editing_done),window); g_signal_connect(G_OBJECT(window->PathCell),"editing-canceled",G_CALLBACK(on_path_editing_cancel),window); g_signal_connect(G_OBJECT(window->LogPathAddButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_add),window); @@ -511,6 +601,9 @@ logrotate_configure_window *yon_logrotate_window_new(){ 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); + + + return window; } diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index ec704e8..ac762ff 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -37,12 +37,15 @@ #define LocaleName "ubl-settings-logging" #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 yon_add_space_if_exists(string) yon_char_is_empty(string) ? "" : yon_char_append(" ",string) typedef char* string; string version_application; @@ -299,6 +302,12 @@ typedef struct { GtkWidget *headerTopic; GtkListStore *list; GtkCellRenderer *PathCell; + GtkWidget *SharedScenariosCheck; + GtkWidget *CommandBeforeOnceEntry; + GtkWidget *CommandAfterOnceEntry; + GtkWidget *CommandBeforeEntry; + GtkWidget *CommandAfterEntry; + GtkWidget *EndworkCommandEntry; } logrotate_configure_window; main_window *setup_window(); \ No newline at end of file diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 8261a80..e6e2fdf 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -123,7 +123,7 @@ void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(vo #define yon_char_divide_search_self(str,find,delete_divider) {char *temp = str; str = yon_char_divide_search(str,find,delete_divider); free(temp);} -#define yon_char_is_empty(string) !string||!strcmp(string,"") +#define yon_char_is_empty(string) !(string&&strcmp(string,"")) int yon_char_find_last(char *source, char find); diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index d324d06..20e0047 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -8,6 +8,11 @@ 1 10 + + 100 + 1 + 10 + 1024 1 @@ -463,6 +468,7 @@ True False False + 0 Monday Tuesday @@ -696,6 +702,7 @@ True False + 0 root* @@ -722,6 +729,7 @@ True False + 0 root* @@ -1359,6 +1367,7 @@ False 0 + Default On Off @@ -1389,6 +1398,8 @@ 0 Default + Yes + No @@ -1570,11 +1581,10 @@ - + True - False True - digits + adjustment10 False @@ -1650,6 +1660,8 @@ 0 Default + Send Email + Don't send email @@ -1702,6 +1714,8 @@ 0 Default + First rotated copy + Last rotated copy @@ -1755,7 +1769,7 @@ vertical 5 - + Scenarios are running for each rotated journal True True @@ -1787,7 +1801,7 @@ - + True True @@ -1823,7 +1837,7 @@ - + True True @@ -1859,7 +1873,7 @@ - + True True @@ -1895,7 +1909,7 @@ - + True True @@ -1912,6 +1926,42 @@ 4 + + + True + False + 5 + + + True + False + Endwork command: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 5 + + @@ -1932,7 +1982,6 @@ - True False 5 From 8734cfeb9822299c064931c7d3b90a9897ee4ce7 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 25 Oct 2023 18:33:45 +0600 Subject: [PATCH 19/25] Logrotate loading --- source/ubl-settings-logging.c | 191 ++++++++++++++++++++++++++++++---- source/ubl-utils.c | 2 +- 2 files changed, 171 insertions(+), 22 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 2d3f6c0..a3c4798 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -363,9 +363,10 @@ void on_logrotate_save(GtkWidget *self, logrotate_configure_window *window){ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck))){ long fileamount = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->FileAmountSpin)); int active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->FileAmountCombo)); + rotate_count = yon_char_append("rotate ",yon_char_from_long(fileamount)); if (active==2){ const char *text = gtk_entry_get_text(GTK_ENTRY(window->FileAmountEntry)); - rotate_count=yon_char_unite("olddir",",",text,NULL); + olddir=yon_char_unite("olddir ",text,NULL); } } @@ -498,12 +499,15 @@ void on_logrotate_save(GtkWidget *self, logrotate_configure_window *window){ free(yon_char_divide_search(commandline," ",-1)); } if(!yon_char_is_empty(paths)){ + GtkTreeIter iter; yon_config_register(LOGROTATE(paths),"logging",commandline); + gtk_list_store_append(main_config.logrotate_list,&iter); + gtk_list_store_set(main_config.logrotate_list,&iter,0,gtk_entry_get_text(GTK_ENTRY(window->LogNameEntry)),1,paths,2,gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry)),-1); on_close_subwindow(window->MainWindow); } } -logrotate_configure_window *yon_logrotate_window_new(){ +logrotate_configure_window *yon_logrotate_window_new(char *paths){ logrotate_configure_window *window = malloc(sizeof(logrotate_configure_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_path); window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); @@ -602,14 +606,157 @@ logrotate_configure_window *yon_logrotate_window_new(){ 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); - + if (paths){ + int size; + GtkTreeIter iter; + config_str parsed = yon_char_parse(paths,&size,","); + for (int i=0; ilist,&iter); + gtk_list_store_set(window->list,&iter,0,parsed[i],-1); + } + yon_char_parsed_free(parsed,size); + char *parameters = yon_config_get_by_key(LOGROTATE(paths)); + if (parameters){ + parameters = yon_char_replace(parameters,",\t",","); + if (parameters[0]==',') yon_char_divide_search(parameters,",",-1); + parsed = yon_char_parse(parameters,&size,","); + for (int i=0;iRotationPeriodMainCombo),0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1); + } else if (!strcmp(parsed[i],"daily")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),1); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1); + }else if (!strcmp(parsed[i],"weekly")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),2); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodAdditionalCombo),atoi(parsed[i+1])); + }else if (!strcmp(parsed[i],"monthly")){ + 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")){ + 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); + int gr = yon_gtk_combo_box_text_find(window->RotationAtGroupCombo,value); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationAtUserCombo),us); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationAtGroupCombo),gr); + }else if (!strcmp(parsed[i],"missingok")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->ErrorProcessingCombo),1); + }else if (!strcmp(parsed[i],"nomissingok")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->ErrorProcessingCombo),2); + }else if (!strcmp(parsed[i],"ifempty")){ + 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")){ + 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")){ + 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")){ + 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")){ + 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); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotateSizeMaxBeforeTimeCombo),yon_size_get_int_from_letter(value[strlen(value)-1])); + // }else if (!strcmp(parsed[i],"create")){ + // + // }else if (!strcmp(parsed[i],"nocreate")){ + // + }else if (!strcmp(parsed[i],"copytruncate")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CutCheck),1); + }else if (!strcmp(parsed[i],"compress")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->CompressionCombo),1); + }else if (!strcmp(parsed[i],"nocompress")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->CompressionCombo),2); + }else if (!strcmp(parsed[i],"delaycompress")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->QueueCombo),1); + + }else if (!strcmp(parsed[i],"nodelaycompress")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->QueueCombo),2); + }else if (!strcmp(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")){ + 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")){ + 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")){ + 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")){ + char *value = parsed[i+1]; + gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value); + i++; + }else if (!strcmp(parsed[i],"lastaction")){ + char *value = parsed[i+1]; + gtk_entry_set_text(GTK_ENTRY(window->CommandAfterOnceEntry),value); + i++; + }else if (!strcmp(parsed[i],"prerotate")){ + char *value = parsed[i+1]; + gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeEntry),value); + i++; + }else if (!strcmp(parsed[i],"postrotate")){ + 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],"endscript")){ + char *value = parsed[i+1]; + gtk_entry_set_text(GTK_ENTRY(window->EndworkCommandEntry),value); + i++; + } + } + } + } return window; } void on_logrotate_add(GtkWidget *self, main_window *widgets){ - logrotate_configure_window *window = yon_logrotate_window_new(); + logrotate_configure_window *window = yon_logrotate_window_new(NULL); gtk_widget_show(window->MainWindow); + gtk_widget_set_sensitive(window->LogNameEntry,1); + gtk_widget_set_sensitive(window->LogDescriptionEntry,1); gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),""); } @@ -618,8 +765,15 @@ void on_logrotate_edit(GtkWidget *self, logrotate_tab_window *window){ GtkTreeIter iter,itar; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model, &iter)){ char *name; + int size=0; char *paths; - logrotate_configure_window *dialog = yon_logrotate_window_new(); + gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(window->MainTree)),&iter,1,&paths,-1); + config_str path_parsed = yon_char_parse(paths,&size,"\n"); + paths=NULL; + for (int i=0;iMainWindow); gtk_tree_model_get(model,&iter,0,&name,1,&paths,-1); gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name); @@ -629,12 +783,6 @@ void on_logrotate_edit(GtkWidget *self, logrotate_tab_window *window){ 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"); - int size=0; - config_str path_parsed = yon_char_parse(paths,&size,"\n"); - for (int i=0;ilist,&itar); - gtk_list_store_set(dialog->list,&itar,0,path_parsed[i],-1); - } } } @@ -653,8 +801,10 @@ void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){ if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->AppsMainTree)),&model,&iter)){ char *paths; char *name; + char *settings; gtk_list_store_append(main_config.logrotate_list,&itar); - gtk_tree_model_get(model,&iter,0,&name,1,&paths,-1); + gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&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); } } @@ -667,9 +817,15 @@ void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict){ if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ char *name; char *description; - logrotate_configure_window *dialog = yon_logrotate_window_new(); - gtk_widget_show(dialog->MainWindow); gtk_tree_model_get(model,&iter,0,&name,2,&description,-1); + GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); + char *pathse=NULL; + for (int i=0;iMainWindow); gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name); gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description); gtk_widget_set_can_focus(dialog->LogNameEntry,0); @@ -678,13 +834,6 @@ void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict){ 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"); - GList *list = gtk_container_get_children(GTK_CONTAINER(window->LogPathsBox)); - for (int i=0;ilist,&itar); - GList *paths = gtk_container_get_children((GtkContainer*)g_list_nth_data(list,i)); - gtk_list_store_set(dialog->list,&itar,0,gtk_entry_get_text((GtkEntry*)g_list_nth_data(paths,1)),-1); - g_list_free(paths); - } } } diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 3ed0e09..5377bac 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -645,7 +645,7 @@ char *yon_char_replace(char *source, char *find, char*replace){ memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); memcpy(temp,source,strlen(source)-strlen(final)); temp=yon_char_append(temp,replace); - source=yon_char_append(temp,final+1); + source=yon_char_append(temp,final+strlen(find)); } } From 186de985efa4d94587f673bef8624fafdcfafb1d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Oct 2023 10:56:37 +0600 Subject: [PATCH 20/25] Localisation updates --- ubl-settings-logging.pot | 284 ++++++++++++++++++++++++++--------- ubl-settings-logging_ru.po | 294 ++++++++++++++++++++++++++++--------- 2 files changed, 442 insertions(+), 136 deletions(-) diff --git a/ubl-settings-logging.pot b/ubl-settings-logging.pot index 0b7d365..4f011cd 100644 --- a/ubl-settings-logging.pot +++ b/ubl-settings-logging.pot @@ -100,7 +100,7 @@ msgid "Save to global configuration" msgstr "" #: source/ubl-strings.h:15 -msgid "Save configuration" +msgid "Save to global and local configuration" msgstr "" #: source/ubl-strings.h:16 @@ -265,268 +265,420 @@ msgstr "" msgid "Journal storage place:" msgstr "" -#: source/ubl-strings.h:70 +#: source/ubl-strings.h:70 source/ubl-strings.h:71 msgid "Use compression:" msgstr "" -#: source/ubl-strings.h:71 +#: source/ubl-strings.h:72 msgid "Split journal files:" msgstr "" -#: source/ubl-strings.h:72 +#: source/ubl-strings.h:73 msgid "Log recording journal interval:" msgstr "" -#: source/ubl-strings.h:73 +#: source/ubl-strings.h:74 msgid "Records amount:" msgstr "" -#: source/ubl-strings.h:74 +#: source/ubl-strings.h:75 msgid "Maximum size of all logs:" msgstr "" -#: source/ubl-strings.h:75 +#: source/ubl-strings.h:76 msgid "Maximum size of rotation journal:" msgstr "" -#: source/ubl-strings.h:76 +#: source/ubl-strings.h:77 msgid "Leave free space at storage:" msgstr "" -#: source/ubl-strings.h:77 +#: source/ubl-strings.h:78 msgid "Redirect to console:" msgstr "" -#: source/ubl-strings.h:78 +#: source/ubl-strings.h:79 msgid "TTY:" msgstr "" -#: source/ubl-strings.h:79 +#: source/ubl-strings.h:80 msgid "Type of forwarded messages:" msgstr "" -#: source/ubl-strings.h:80 +#: source/ubl-strings.h:81 msgid "Journal configuration" msgstr "" -#: source/ubl-strings.h:81 +#: source/ubl-strings.h:82 msgid "Total log size:" msgstr "" -#: source/ubl-strings.h:82 +#: source/ubl-strings.h:83 msgid "Lower size to:" msgstr "" -#: source/ubl-strings.h:83 +#: source/ubl-strings.h:84 msgid "Apply" msgstr "" -#: source/ubl-strings.h:84 +#: source/ubl-strings.h:85 msgid "Statistics" msgstr "" +#: source/ubl-strings.h:86 +msgid "Default" +msgstr "" + #: source/ubl-strings.h:87 -msgid "Log/Journal:" +msgid "RAM" msgstr "" #: source/ubl-strings.h:88 -msgid "Paths to log and journals files" +msgid "Drive" msgstr "" #: source/ubl-strings.h:89 -msgid "Default" +msgid "Auto" msgstr "" #: source/ubl-strings.h:90 -msgid "On" +msgid "None" msgstr "" #: source/ubl-strings.h:91 -msgid "Off" +msgid "Yes" msgstr "" #: source/ubl-strings.h:92 -msgid "Scenarios" +msgid "No" msgstr "" #: source/ubl-strings.h:93 -msgid "Scenarios are running for each rotated journal" +msgid "After" msgstr "" #: source/ubl-strings.h:94 -msgid "Command before rotation (one time):" +msgid "Kb" msgstr "" #: source/ubl-strings.h:95 -msgid "Command after rotation (one time):" +msgid "Mb" msgstr "" #: source/ubl-strings.h:96 -msgid "Command before rotation:" +msgid "Gb" msgstr "" #: source/ubl-strings.h:97 -msgid "Command after rotation:" +msgid "Minutes" msgstr "" #: source/ubl-strings.h:98 -msgid "Rotation period:" +msgid "Hours" msgstr "" #: source/ubl-strings.h:99 -msgid "Maximum size of file:" +msgid "Days" msgstr "" #: source/ubl-strings.h:100 -msgid "Checking frequency configuration" +msgid "Weeks" msgstr "" #: source/ubl-strings.h:101 +msgid "Years" +msgstr "" + +#: source/ubl-strings.h:104 +msgid "Log/Journal:" +msgstr "" + +#: source/ubl-strings.h:105 +msgid "Paths to log and journals files" +msgstr "" + +#: source/ubl-strings.h:106 +msgid "On" +msgstr "" + +#: source/ubl-strings.h:107 +msgid "Off" +msgstr "" + +#: source/ubl-strings.h:108 source/ubl-strings.h:162 +msgid "Scenarios" +msgstr "" + +#: source/ubl-strings.h:109 source/ubl-strings.h:161 +msgid "Scenarios are running for each rotated journal" +msgstr "" + +#: source/ubl-strings.h:110 +msgid "Command before rotation (one time):" +msgstr "" + +#: source/ubl-strings.h:111 +msgid "Command after rotation (one time):" +msgstr "" + +#: source/ubl-strings.h:112 +msgid "Command before rotation:" +msgstr "" + +#: source/ubl-strings.h:113 +msgid "Command after rotation:" +msgstr "" + +#: source/ubl-strings.h:114 +msgid "Rotation period:" +msgstr "" + +#: source/ubl-strings.h:115 +msgid "Maximum size of file:" +msgstr "" + +#: source/ubl-strings.h:116 +msgid "Checking frequency configuration" +msgstr "" + +#: source/ubl-strings.h:117 msgid "File amount:" msgstr "" -#: source/ubl-strings.h:102 +#: source/ubl-strings.h:118 msgid "Store at:" msgstr "" -#: source/ubl-strings.h:103 +#: source/ubl-strings.h:119 msgid "Rotation as user:" msgstr "" -#: source/ubl-strings.h:104 +#: source/ubl-strings.h:120 msgid "Rotation as group:" msgstr "" -#: source/ubl-strings.h:105 +#: source/ubl-strings.h:121 msgid "Rotation configuration" msgstr "" -#: source/ubl-strings.h:106 +#: source/ubl-strings.h:122 msgid "Error processing:" msgstr "" -#: source/ubl-strings.h:107 +#: source/ubl-strings.h:123 msgid "Rotation of jurnal even when it is empty:" msgstr "" -#: source/ubl-strings.h:108 +#: source/ubl-strings.h:124 msgid "Do not rotate journal younger than" msgstr "" -#: source/ubl-strings.h:109 +#: source/ubl-strings.h:125 msgid "days" msgstr "" -#: source/ubl-strings.h:110 +#: source/ubl-strings.h:126 msgid "Delete rotated journals older than" msgstr "" -#: source/ubl-strings.h:111 +#: source/ubl-strings.h:127 msgid "Rotate journals if size more than" msgstr "" -#: source/ubl-strings.h:112 +#: source/ubl-strings.h:128 msgid "but not earlier than the specified time interval" msgstr "" -#: source/ubl-strings.h:113 +#: source/ubl-strings.h:129 msgid "before specified time interval" msgstr "" -#: source/ubl-strings.h:114 +#: source/ubl-strings.h:130 msgid "File choosing configuration" msgstr "" -#: source/ubl-strings.h:115 +#: source/ubl-strings.h:131 msgid "Create log" msgstr "" -#: source/ubl-strings.h:116 +#: source/ubl-strings.h:132 msgid "as user:" msgstr "" -#: source/ubl-strings.h:117 +#: source/ubl-strings.h:133 msgid "as group:" msgstr "" -#: source/ubl-strings.h:118 +#: source/ubl-strings.h:134 msgid "rules:" msgstr "" -#: source/ubl-strings.h:119 +#: source/ubl-strings.h:135 msgid "" "Cut source journal fileafter copy creating instead of moving old journal " "file and creating new one" msgstr "" -#: source/ubl-strings.h:120 +#: source/ubl-strings.h:136 msgid "Files and directories configuration" msgstr "" -#: source/ubl-strings.h:121 +#: source/ubl-strings.h:137 msgid "Delay compression by one journal in queue:" msgstr "" -#: source/ubl-strings.h:122 +#: source/ubl-strings.h:138 msgid "Compression configuration" msgstr "" -#: source/ubl-strings.h:123 +#: source/ubl-strings.h:139 msgid "Save original log file after rotation if it has specified extension:" msgstr "" -#: source/ubl-strings.h:124 +#: source/ubl-strings.h:140 msgid "Add date of rotation before log header" msgstr "" -#: source/ubl-strings.h:125 +#: source/ubl-strings.h:141 msgid "Number from which numbering of old logs will begin" msgstr "" -#: source/ubl-strings.h:126 +#: source/ubl-strings.h:142 msgid "Filename configuration" msgstr "" -#: source/ubl-strings.h:127 +#: source/ubl-strings.h:143 msgid "Email after rotation:" msgstr "" -#: source/ubl-strings.h:128 +#: source/ubl-strings.h:144 msgid "adress:" msgstr "" -#: source/ubl-strings.h:129 +#: source/ubl-strings.h:145 msgid "contents:" msgstr "" -#: source/ubl-strings.h:130 +#: source/ubl-strings.h:146 source/ubl-strings.h:159 msgid "Message configuration" msgstr "" -#: source/ubl-strings.h:131 +#: source/ubl-strings.h:147 msgid "Manual input:" msgstr "" -#: source/ubl-strings.h:132 +#: source/ubl-strings.h:148 msgid "Log (-s) size:" msgstr "" -#: source/ubl-strings.h:135 +#: source/ubl-strings.h:149 +msgid "Same directory" +msgstr "" + +#: source/ubl-strings.h:150 +msgid "Separate directory" +msgstr "" + +#: source/ubl-strings.h:151 +msgid "Output errors if log file does not exist*" +msgstr "" + +#: source/ubl-strings.h:152 +msgid "Do not output errors if log file does not exist" +msgstr "" + +#: source/ubl-strings.h:153 +msgid "Do not output" +msgstr "" + +#: source/ubl-strings.h:154 +msgid "Output errors" +msgstr "" + +#: source/ubl-strings.h:155 +msgid "Send Email" +msgstr "" + +#: source/ubl-strings.h:156 +msgid "Don't send Email" +msgstr "" + +#: source/ubl-strings.h:157 +msgid "First rotated copy" +msgstr "" + +#: source/ubl-strings.h:158 +msgid "Last rotated copy" +msgstr "" + +#: source/ubl-strings.h:160 +msgid "Endwork command:" +msgstr "" + +#: source/ubl-strings.h:163 +msgid "Hourly" +msgstr "" + +#: source/ubl-strings.h:164 +msgid "Daily" +msgstr "" + +#: source/ubl-strings.h:165 +msgid "Weekly*" +msgstr "" + +#: source/ubl-strings.h:166 +msgid "Monthly" +msgstr "" + +#: source/ubl-strings.h:167 +msgid "Yearly" +msgstr "" + +#: source/ubl-strings.h:168 +msgid "Monday" +msgstr "" + +#: source/ubl-strings.h:169 +msgid "Tuesday" +msgstr "" + +#: source/ubl-strings.h:170 +msgid "Wednesday" +msgstr "" + +#: source/ubl-strings.h:171 +msgid "Thursday" +msgstr "" + +#: source/ubl-strings.h:172 +msgid "Friday" +msgstr "" + +#: source/ubl-strings.h:173 +msgid "Saturday" +msgstr "" + +#: source/ubl-strings.h:174 +msgid "Sunday*" +msgstr "" + +#: source/ubl-strings.h:177 msgid "System configuration" msgstr "" -#: source/ubl-strings.h:136 +#: source/ubl-strings.h:178 msgid "Applications configuration" msgstr "" -#: source/ubl-strings.h:139 +#: source/ubl-strings.h:181 msgid "Path (-s):" msgstr "" -#: source/ubl-strings.h:140 +#: source/ubl-strings.h:182 msgid "Control:" msgstr "" -#: source/ubl-strings.h:141 +#: source/ubl-strings.h:183 msgid "Log file" msgstr "" diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index 56c15ba..ac0207b 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -271,272 +271,426 @@ msgstr "Описание:" msgid "Journal storage place:" msgstr "Место хранения журнала:" -#: source/ubl-strings.h:70 +#: source/ubl-strings.h:70 source/ubl-strings.h:71 msgid "Use compression:" msgstr "Использовать сжатие:" -#: source/ubl-strings.h:71 +#: source/ubl-strings.h:72 msgid "Split journal files:" msgstr "Разделять файлы журнала:" -#: source/ubl-strings.h:72 +#: source/ubl-strings.h:73 msgid "Log recording journal interval:" msgstr "Интервал записи журнала:" -#: source/ubl-strings.h:73 +#: source/ubl-strings.h:74 msgid "Records amount:" msgstr "Количество записей:" -#: source/ubl-strings.h:74 +#: source/ubl-strings.h:75 msgid "Maximum size of all logs:" msgstr "Максимальный размер всех журналов:" -#: source/ubl-strings.h:75 +#: source/ubl-strings.h:76 msgid "Maximum size of rotation journal:" msgstr "Максимальный размер журнала для ротации:" -#: source/ubl-strings.h:76 +#: source/ubl-strings.h:77 msgid "Leave free space at storage:" msgstr "Оставлять в хранилище свободным:" -#: source/ubl-strings.h:77 +#: source/ubl-strings.h:78 msgid "Redirect to console:" msgstr "Перенаправление в консоль:" -#: source/ubl-strings.h:78 +#: source/ubl-strings.h:79 msgid "TTY:" msgstr "TTY:" -#: source/ubl-strings.h:79 +#: source/ubl-strings.h:80 msgid "Type of forwarded messages:" msgstr "Тип перенаправляемых сообщений:" -#: source/ubl-strings.h:80 +#: source/ubl-strings.h:81 msgid "Journal configuration" msgstr "Настройка файла журнала" -#: source/ubl-strings.h:81 +#: source/ubl-strings.h:82 msgid "Total log size:" msgstr "Общий размер журналов:" -#: source/ubl-strings.h:82 +#: source/ubl-strings.h:83 msgid "Lower size to:" msgstr "Уменьшить размер до:" -#: source/ubl-strings.h:83 +#: source/ubl-strings.h:84 msgid "Apply" msgstr "Применить" -#: source/ubl-strings.h:84 +#: source/ubl-strings.h:85 msgid "Statistics" msgstr "Статистика" +#: source/ubl-strings.h:86 +msgid "Default" +msgstr "По умолчанию" + #: source/ubl-strings.h:87 -msgid "Log/Journal:" -msgstr "Лог/Журнал:" +msgid "RAM" +msgstr "Оперативная память" #: source/ubl-strings.h:88 -msgid "Paths to log and journals files" -msgstr "Пути к файлам лога/журнала" +msgid "Drive" +msgstr "Диск" #: source/ubl-strings.h:89 -msgid "Default" -msgstr "По умолчанию" +#, fuzzy +msgid "Auto" +msgstr "Автоматически" #: source/ubl-strings.h:90 +msgid "None" +msgstr "Нет" + +#: source/ubl-strings.h:91 +msgid "Yes" +msgstr "Да" + +#: source/ubl-strings.h:92 +msgid "No" +msgstr "Нет" + +#: source/ubl-strings.h:93 +msgid "After" +msgstr "После" + +#: source/ubl-strings.h:94 +msgid "Kb" +msgstr "Кб" + +#: source/ubl-strings.h:95 +msgid "Mb" +msgstr "Мб" + +#: source/ubl-strings.h:96 +msgid "Gb" +msgstr "Гб" + +#: source/ubl-strings.h:97 +msgid "Minutes" +msgstr "Минута" + +#: source/ubl-strings.h:98 +msgid "Hours" +msgstr "Час" + +#: source/ubl-strings.h:99 +msgid "Days" +msgstr "День" + +#: source/ubl-strings.h:100 +#, fuzzy +msgid "Weeks" +msgstr "Неделя" + +#: source/ubl-strings.h:101 +msgid "Years" +msgstr "Год" + +#: source/ubl-strings.h:104 +msgid "Log/Journal:" +msgstr "Лог/Журнал:" + +#: source/ubl-strings.h:105 +msgid "Paths to log and journals files" +msgstr "Пути к файлам лога/журнала" + +#: source/ubl-strings.h:106 msgid "On" msgstr "Включено" -#: source/ubl-strings.h:91 +#: source/ubl-strings.h:107 msgid "Off" msgstr "Выключено" -#: source/ubl-strings.h:92 +#: source/ubl-strings.h:108 source/ubl-strings.h:162 msgid "Scenarios" msgstr "Сценарии" -#: source/ubl-strings.h:93 +#: source/ubl-strings.h:109 source/ubl-strings.h:161 msgid "Scenarios are running for each rotated journal" msgstr "Сценарии запускаются для каждого ротируемого журнала" -#: source/ubl-strings.h:94 +#: source/ubl-strings.h:110 msgid "Command before rotation (one time):" msgstr "Команда перед ротацией (один раз):" -#: source/ubl-strings.h:95 +#: source/ubl-strings.h:111 msgid "Command after rotation (one time):" msgstr "Команда после ротации (один раз):" -#: source/ubl-strings.h:96 +#: source/ubl-strings.h:112 msgid "Command before rotation:" msgstr "Команда перед ротацией:" -#: source/ubl-strings.h:97 +#: source/ubl-strings.h:113 msgid "Command after rotation:" msgstr "Команда после ротации:" -#: source/ubl-strings.h:98 +#: source/ubl-strings.h:114 msgid "Rotation period:" msgstr "Период ротации:" -#: source/ubl-strings.h:99 +#: source/ubl-strings.h:115 msgid "Maximum size of file:" msgstr "Максимальный размер файла:" -#: source/ubl-strings.h:100 +#: source/ubl-strings.h:116 msgid "Checking frequency configuration" msgstr "Настройки частоты проверки" -#: source/ubl-strings.h:101 +#: source/ubl-strings.h:117 msgid "File amount:" msgstr "Количество файлов:" -#: source/ubl-strings.h:102 +#: source/ubl-strings.h:118 msgid "Store at:" msgstr "Хранить в:" -#: source/ubl-strings.h:103 +#: source/ubl-strings.h:119 msgid "Rotation as user:" msgstr "Ротация от пользователя:" -#: source/ubl-strings.h:104 +#: source/ubl-strings.h:120 msgid "Rotation as group:" msgstr "Ротация от группы:" -#: source/ubl-strings.h:105 +#: source/ubl-strings.h:121 msgid "Rotation configuration" msgstr "Настройки ротации" -#: source/ubl-strings.h:106 +#: source/ubl-strings.h:122 msgid "Error processing:" msgstr "Обработка ошибок:" -#: source/ubl-strings.h:107 +#: source/ubl-strings.h:123 msgid "Rotation of jurnal even when it is empty:" msgstr "ротация файла журнала даже если он пуст:" -#: source/ubl-strings.h:108 +#: source/ubl-strings.h:124 msgid "Do not rotate journal younger than" msgstr "Не ратировать журналы, возраст которых меньше" -#: source/ubl-strings.h:109 +#: source/ubl-strings.h:125 msgid "days" msgstr "дней" -#: source/ubl-strings.h:110 +#: source/ubl-strings.h:126 msgid "Delete rotated journals older than" msgstr "Удалить ротированные журналы старше" -#: source/ubl-strings.h:111 +#: source/ubl-strings.h:127 msgid "Rotate journals if size more than" msgstr "Ротация журналов, если размер превышает" -#: source/ubl-strings.h:112 +#: source/ubl-strings.h:128 msgid "but not earlier than the specified time interval" msgstr "но не раньше указанного интервала времени" -#: source/ubl-strings.h:113 +#: source/ubl-strings.h:129 msgid "before specified time interval" msgstr "до истечения указанного интервала времени" -#: source/ubl-strings.h:114 +#: source/ubl-strings.h:130 msgid "File choosing configuration" msgstr "Настройки выбора файла" -#: source/ubl-strings.h:115 +#: source/ubl-strings.h:131 msgid "Create log" msgstr "Создавать лог" -#: source/ubl-strings.h:116 +#: source/ubl-strings.h:132 msgid "as user:" msgstr "от пользователя:" -#: source/ubl-strings.h:117 +#: source/ubl-strings.h:133 msgid "as group:" msgstr "от группы:" -#: source/ubl-strings.h:118 +#: source/ubl-strings.h:134 msgid "rules:" msgstr "права:" -#: source/ubl-strings.h:119 +#: source/ubl-strings.h:135 msgid "" "Cut source journal fileafter copy creating instead of moving old journal " "file and creating new one" msgstr "" "После создания копии, обрезать исходный файл журнала взамен перемещения " -"старого " -"файла журнала и создания нового" +"старого файла журнала и создания нового" -#: source/ubl-strings.h:120 +#: source/ubl-strings.h:136 msgid "Files and directories configuration" msgstr "Настройки файлов и папок" -#: source/ubl-strings.h:121 +#: source/ubl-strings.h:137 msgid "Delay compression by one journal in queue:" msgstr "Отложить сжание на один журнал в очереди:" -#: source/ubl-strings.h:122 +#: source/ubl-strings.h:138 msgid "Compression configuration" msgstr "Настройка сжатия" -#: source/ubl-strings.h:123 +#: source/ubl-strings.h:139 msgid "Save original log file after rotation if it has specified extension:" msgstr "" "Сохранять оригинальный лог после ротации, если у него указано расширение:" -#: source/ubl-strings.h:124 +#: source/ubl-strings.h:140 msgid "Add date of rotation before log header" msgstr "Добавлять дату ротации перед заголовком старого лога:" -#: source/ubl-strings.h:125 +#: source/ubl-strings.h:141 msgid "Number from which numbering of old logs will begin" msgstr "Номер, с которого будет начата нумерация старых логов:" -#: source/ubl-strings.h:126 +#: source/ubl-strings.h:142 msgid "Filename configuration" msgstr "Настройка имени файлов" -#: source/ubl-strings.h:127 +#: source/ubl-strings.h:143 msgid "Email after rotation:" msgstr "Отправка Email после ротации:" -#: source/ubl-strings.h:128 +#: source/ubl-strings.h:144 msgid "adress:" msgstr "на адрес:" -#: source/ubl-strings.h:129 +#: source/ubl-strings.h:145 msgid "contents:" msgstr "содержимое:" -#: source/ubl-strings.h:130 +#: source/ubl-strings.h:146 source/ubl-strings.h:159 msgid "Message configuration" msgstr "Настройка сообщения" -#: source/ubl-strings.h:131 +#: source/ubl-strings.h:147 msgid "Manual input:" msgstr "Команды настройки" -#: source/ubl-strings.h:132 +#: source/ubl-strings.h:148 msgid "Log (-s) size:" msgstr "Общий размер лога (-ов):" -#: source/ubl-strings.h:135 +#: source/ubl-strings.h:149 +msgid "Same directory" +msgstr "Той же папке" + +#: source/ubl-strings.h:150 +msgid "Separate directory" +msgstr "Другой папке" + +#: source/ubl-strings.h:151 +msgid "Output errors if log file does not exist*" +msgstr "Выводить ошибки, если лог файла не существует*" + +#: source/ubl-strings.h:152 +msgid "Do not output errors if log file does not exist" +msgstr "Не выводить ошибки, если лог файла не существует" + +#: source/ubl-strings.h:153 +msgid "Do not output" +msgstr "Не выводить" + +#: source/ubl-strings.h:154 +msgid "Output errors" +msgstr "Выводить ошибки" + +#: source/ubl-strings.h:155 +msgid "Send Email" +msgstr "Отправлять Email" + +#: source/ubl-strings.h:156 +msgid "Don't send Email" +msgstr "Не отправлять Email" + +#: source/ubl-strings.h:157 +msgid "First rotated copy" +msgstr "Первая ротированная копия" + +#: source/ubl-strings.h:158 +msgid "Last rotated copy" +msgstr "Последняя ротированная копия" + +#: source/ubl-strings.h:160 +msgid "Endwork command:" +msgstr "Команда конца работы:" + +#: source/ubl-strings.h:163 +#, fuzzy +msgid "Hourly" +msgstr "Час" + +#: source/ubl-strings.h:164 +msgid "Daily" +msgstr "День" + +#: source/ubl-strings.h:165 +msgid "Weekly*" +msgstr "Неделя*" + +#: source/ubl-strings.h:166 +msgid "Monthly" +msgstr "Месяц" + +#: source/ubl-strings.h:167 +msgid "Yearly" +msgstr "Год" + +#: source/ubl-strings.h:168 +msgid "Monday" +msgstr "Понедельник" + +#: source/ubl-strings.h:169 +msgid "Tuesday" +msgstr "Вторник" + +#: source/ubl-strings.h:170 +msgid "Wednesday" +msgstr "Среда" + +#: source/ubl-strings.h:171 +msgid "Thursday" +msgstr "Четверг" + +#: source/ubl-strings.h:172 +msgid "Friday" +msgstr "Пятница" + +#: source/ubl-strings.h:173 +msgid "Saturday" +msgstr "Суббота" + +#: source/ubl-strings.h:174 +msgid "Sunday*" +msgstr "Воскресенье*" + +#: source/ubl-strings.h:177 msgid "System configuration" msgstr "Настройки системы" -#: source/ubl-strings.h:136 +#: source/ubl-strings.h:178 msgid "Applications configuration" msgstr "Настройки приложений" -#: source/ubl-strings.h:139 +#: source/ubl-strings.h:181 msgid "Path (-s):" msgstr "Путь (-и):" -#: source/ubl-strings.h:140 +#: source/ubl-strings.h:182 msgid "Control:" msgstr "Управление:" -#: source/ubl-strings.h:141 +#: source/ubl-strings.h:183 msgid "Log file" msgstr "Файл лога" From 1706867e5172c79259a43c5bd82c40eb27a3c97e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Oct 2023 14:37:00 +0600 Subject: [PATCH 21/25] Saving and loading --- source/ubl-settings-logging.c | 52 +++++++++++- source/ubl-settings-logging.h | 3 + source/ubl-strings.h | 45 +++++++++- source/ubl-utils.c | 122 +++++++++++++-------------- source/ubl-utils.h | 2 + ubl-settings-logging-logrotate.glade | 6 +- ubl-settings-logging_ru.po | 4 +- 7 files changed, 164 insertions(+), 70 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index a3c4798..70f452b 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -125,11 +125,58 @@ int yon_size_get_int_from_letter(char size){ //functions -void yon_load_proceed(char *command){ - yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); +int yon_load_proceed(YON_CONFIG_TYPE type){ + if (yon_config_load_register(type,"logging",LOGROTATE("*"),JOURNALD("*"),NULL)) + return 1; } +void on_load_global(){ + yon_load_proceed(YON_CONFIG_GLOBAL); + main_config.load_mode=0; + yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); +} + +void on_load_local(){ + yon_load_proceed(YON_CONFIG_LOCAL); + main_config.load_mode=1; + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + +} + +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))) + yon_config_save_registered(path); + else{ + if (type==YON_CONFIG_BOTH) + yon_launch("ubconfig remove system LOGROTATE[*] JOURNALD[*]"); + else if (type==YON_CONFIG_LOCAL) + yon_launch("ubconfig --target system remove system LOGROTATE[*] JOURNALD[*]"); + else if (type==YON_CONFIG_GLOBAL) + yon_launch("ubconfig --target global remove system LOGROTATE[*] JOURNALD[*]"); + yon_config_force_save_registered(path); + } + +} + +void on_save_global_local(){ + yon_save_proceed(NULL,YON_CONFIG_BOTH); + yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + +} + +void on_save_global(){ + yon_save_proceed("system",YON_CONFIG_LOCAL); + yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + +} + +void on_save_local(){ + yon_save_proceed("global",YON_CONFIG_GLOBAL); + yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + +} + // Inspector functions void on_inspector_update(GtkWidget *self, inspector_window *window){ @@ -1562,6 +1609,7 @@ 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); GtkCssProvider *css=gtk_css_provider_new(); gtk_css_provider_load_from_resource(css,CssPath); diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index ac762ff..07d497e 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -67,6 +67,8 @@ typedef struct { int lock_save_global; int lock_load_global; + int load_mode; + GtkListStore *logrotate_list; GtkListStore *logrotate_apps_list; } config; @@ -107,6 +109,7 @@ typedef struct { GtkWidget *AddButton; GtkWidget *RemoveButton; + GtkWidget *Notebook; GtkWidget *ServicesTree; GtkWidget *ServicesEditButton; diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 6a45a4d..4c834c2 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -83,11 +83,26 @@ #define LOWER_SIZE_LABEL _("Lower size to:") #define APPLY_LABEL _("Apply") #define STATISTICS_LABEL _("Statistics") +#define DEFAULT_LABEL _("Default") +#define RAM_LABEL _("RAM") +#define DRIVE_LABEL _("Drive") +#define AUTO_LABEL _("Auto") +#define NONE_LABEL _("None") +#define YES_LABEL _("Yes") +#define NO_LABEL _("No") +#define AFTER_LABEL _("After") +#define KB_LABEL _("Kb") +#define MB_LABEL _("Mb") +#define GB_LABEL _("Gb") +#define MINUTES_LABEL _("Minutes") +#define HOURS_LABEL _("Hours") +#define DAYS_LABEL _("Days") +#define WEEKS_LABEL _("Weeks") +#define YEARS_LABEL _("Years") //ubl-settings-logging-logrotate.glade #define LOGROTATE_LOG_JOURNAL_TAB_LABEL _("Log/Journal:") #define PATHS_LABEL _("Paths to log and journals files") -#define DEFAULT_LABEL _("Default") #define ON_LABEL _("On") #define OFF_LABEL _("Off") #define SCENARIOS_LABEL _("Scenarios") @@ -107,7 +122,7 @@ #define ERROR_LABEL _("Error processing:") #define ROTATION_EMPTY_LABEL _("Rotation of jurnal even when it is empty:") #define DONT_ROTATE_YOUNGER_LABEL _("Do not rotate journal younger than") -#define DAYS_LABEL _("days") +#define DAYS_text_LABEL _("days") #define DELETE_ROTATED_LABEL _("Delete rotated journals older than") #define ROTATE_SIZE_LABEL _("Rotate journals if size more than") #define ROTATE_TIME_LABEL _("but not earlier than the specified time interval") @@ -131,6 +146,32 @@ #define MESSAGE_CONFIGURATION_LABEL _("Message configuration") #define MANUAL_LABEL _("Manual input:") #define LOG_SIZE_LABEL _("Log (-s) size:") +#define SAME_DIR_LABEL _("Same directory") +#define SEPARATE_DIR_LABEL _("Separate directory") +#define OUTPUT_ERRORS_LABEL _("Output errors if log file does not exist*") +#define NO_OUTPUT_ERRORS_LABEL _("Do not output errors if log file does not exist") +#define NO_OUTPUT_LABEL _("Do not output") +#define OURPUT_LABEL _("Output errors") +#define SEND_EMAIL_LABEL _("Send Email") +#define NO_SEND_EMAIL_LABEL _("Don't send Email") +#define FIRST_ROTATED_LABEL _("First rotated copy") +#define LAST_ROTATED_LABEL _("Last rotated copy") +#define MESSAGE_CONFIGURATION_LABEL _("Message configuration") +#define ENDWORK_LABEL _("Endwork command:") +#define SCENARIOS_ROTATE_LABEL _("Scenarios are running for each rotated journal") +#define SCENARIOS_LABEL _("Scenarios") +#define HOURLY_LABEL _("Hourly") +#define DAILY_LABEL _("Daily") +#define WEEKLY_LABEL _("Weekly*") +#define MONTHLY_LABEL _("Monthly") +#define YEARLY_LABEL _("Yearly") +#define MONDAY_LABEL _("Monday") +#define TUESDAY_LABEL _("Tuesday") +#define WEDNESDAY_LABEL _("Wednesday") +#define THURSDAY_LABEL _("Thursday") +#define FRIDAY_LABEL _("Friday") +#define SATURDAY_LABEL _("Saturday") +#define SUNDAY_LABEL _("Sunday*") //ubl-settings-logging-logrotate-table.glade #define SYSTEM_CONFIGURATION_LABEL _("System configuration") diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 5377bac..ad2664a 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -455,9 +455,9 @@ char *yon_char_append(char *source, char *append) int size = strlen(source) + strlen(append) + 1; char *final = malloc(size); memset(final, 0, size); - if (strstr(source, "%%")) - sprintf(final, source, append); - else + // if (strstr(source, "%%")) + // sprintf(final, source, append); + // else sprintf(final, "%s%s", source, append); return final; } @@ -666,10 +666,10 @@ char **yon_char_parse(char *parameters, int *size, char *divider){ char *paramline=yon_char_new(parameters); char *param; while ((param=yon_char_divide_search(paramline,divider,1))){ - if (strcmp(param,paramline)==0) break; string=realloc(string,sizeof(char*)*i); string[i-1]=yon_char_new(param); i++; + if (strcmp(param,paramline)==0) break; } string=realloc(string,sizeof(char*)*i); string[i-1]=yon_char_new(paramline); @@ -785,7 +785,7 @@ void yon_char_parsed_free(config_str source, int size){ * Копирует массив строк [to_copy] в [source] */ void yon_char_parsed_copy(config_str *source, config_str *to_copy){ - if (source&&!*source&&to_copy&&*to_copy){ + if (source&&!*source&&to_copy){ int size=0; config_str new_char = yon_char_parsed_new(&size,(*to_copy)[0]); for (int i=0;(*to_copy)[i];i++){ @@ -802,7 +802,7 @@ void yon_char_parsed_copy(config_str *source, config_str *to_copy){ * Добавляет строку [string] в конец массива строк [parsed] с длинной [size]. */ config_str yon_char_parsed_append(config_str parsed, int *size, char *string){ - config_str new_parsed=realloc(parsed,((*size)+2)*sizeof(char*)); + config_str new_parsed=realloc(parsed,(*size+1)*sizeof(char*)); new_parsed[(*size)]=yon_char_new(string); (*size)++; return new_parsed; @@ -969,18 +969,6 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size) return NULL; }; -config_str yon_file_open(char *file_path, int *size){ - *size=0; - FILE *file = fopen(file_path,"r"); - if (file){ - char *str_loaded=malloc(4098); - config_str final_string = NULL; - while (fgets(str_loaded,4098,file)){ - final_string = final_string ? yon_char_parsed_append(final_string,size,str_loaded) : yon_char_parsed_new(size,str_loaded,NULL); - } - return final_string; - } -} /** * yon_dir_get_contents(char *dir_path, int *size) @@ -1116,26 +1104,6 @@ int yon_config_remove_by_key(char *key){ return 0; } -/**yon_config_remove_by_data(void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу на наличие параметра со значением [data] и удаляет найденное значение из конфига. -*/ -int yon_config_remove_by_data(void *data){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict,(dictionary*)__yon__config__strings){ - if (dict->data==data){ - yon_dictionary_rip(dict); - return 1; - } - } - return 0; - } - return 0; -} - /**yon_config_remove_element(char *key, char *deleted) * [EN] * @@ -1331,12 +1299,50 @@ int yon_config_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)); + 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 if (((yon_config_parameter*)dct)->flag1==-1){ ((yon_config_parameter*)dct)->flag1=0; 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)); + yon_dictionary_rip(dct); + } + } + } + if (sections_add) + for_dictionaries(dct,sections_add){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + if (sections_remove) + for_dictionaries(dct,sections_remove){ + char *command = yon_dictionary_get_data(dct,char*); + yon_launch(command); + } + return 1; + } else return 1; +} + +/**int yon_config_force_save_registered(char *path, char *section) + * [EN] + * Saves config with [command] + * [RU] + * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: + * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" +*/ +int yon_config_force_save_registered(char *path){ + check_config{ + dictionary *dct; + dictionary *sections_add=NULL; + dictionary *sections_remove=NULL; + for_dictionaries(dct,(dictionary*)__yon__config__strings){ + 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 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)); } } } @@ -1352,24 +1358,6 @@ int yon_config_save_registered(char *path){ } - // char *command = yon_char_unite(ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", section, " ", yon_dictionary_get_data(dct,char*),NULL); - // char *remove_command = yon_char_unite(ubconfig_save_command, path ? yon_char_append(" --target ",path):"", " remove "," ", yon_dictionary_get_data(dct,char*), section,NULL); - // dictionary *dict = NULL; - // int any_add = 0; - // int any_remove = 0; - // for_dictionaries(dict,(dictionary*)__yon__config__strings){ - // char *data = yon_dictionary_get_data(dict,char*); - // if (((yon_config_parameter*)dict)->flag1==1&&strcmp(data,"")!=0){ - // command = yon_char_unite(command, " ", dict->key,"=\"", yon_dictionary_get_data(dict,char*),"\"", NULL); - // any_add=1; - // } - // if (strcmp(data,"")==0){ - // remove_command = yon_char_unite(remove_command, " ", dict->key, NULL); - // any_remove=1; - // } - // } - // if (any_add) yon_launch(command); - // if (any_remove) yon_launch(remove_command); return 1; } else return 1; } @@ -1393,6 +1381,7 @@ config_str yon_config_get_all(int *size){ } conf = yon_remalloc(conf,sizeof(char*)*(*size)); conf[*size-1] = NULL; + (*size)=(*size)-1; return conf; } else return NULL; } @@ -1430,7 +1419,18 @@ char *yon_config_get_parameter(config_str parameters, int size, char *param) return NULL; } - +config_str yon_file_open(char *file_path, int *size){ + *size=0; + FILE *file = fopen(file_path,"r"); + if (file){ + char str_loaded[4098]; + config_str final_string = NULL; + while (fgets(str_loaded,4098,file)){ + final_string = final_string ? yon_char_parsed_append(final_string,size,str_loaded) : yon_char_parsed_new(size,str_loaded,NULL); + } + return final_string; + } +} // terminal-using functions @@ -1818,7 +1818,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end param->section=section; yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.deleted_parameters,param->parameter_name,param); } - + int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type){ GError *err=NULL; switch (type){ @@ -1860,7 +1860,7 @@ GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ GtkWidget *menu_item = gtk_menu_item_new(); - gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemtop"); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemmiddle"); GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); GtkWidget *label = gtk_label_new(buttonname); GtkWidget *image = gtk_image_new_from_icon_name("dialog-question-symbolic",GTK_ICON_SIZE_BUTTON); diff --git a/source/ubl-utils.h b/source/ubl-utils.h index e6e2fdf..c60d0c6 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -198,6 +198,8 @@ config_str yon_config_load(char *command, int *str_len); int yon_config_save_registered(char *path); +int yon_config_force_save_registered(char *path); + char *yon_config_get_parameter(config_str parameters, int size, char *param); int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...); diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 20e0047..da07a3b 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -450,9 +450,9 @@ False 0 - Hourly + Hourly Daily - Weekly + Weekly* Monthly Yearly @@ -476,7 +476,7 @@ Thursday Friday Saturday - Sunday + Sunday* diff --git a/ubl-settings-logging_ru.po b/ubl-settings-logging_ru.po index ac0207b..a9b17a8 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -475,11 +475,11 @@ msgstr "Обработка ошибок:" #: source/ubl-strings.h:123 msgid "Rotation of jurnal even when it is empty:" -msgstr "ротация файла журнала даже если он пуст:" +msgstr "Ротация файла журнала даже если он пуст:" #: source/ubl-strings.h:124 msgid "Do not rotate journal younger than" -msgstr "Не ратировать журналы, возраст которых меньше" +msgstr "Не ротировать журналы, возраст которых меньше" #: source/ubl-strings.h:125 msgid "days" From 2b97316728d3fc8407502b161cb8a1284332ad25 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Oct 2023 14:58:16 +0600 Subject: [PATCH 22/25] Fixes, improvements --- source/ubl-settings-logging.c | 65 +++++++++++++++++++++++----- source/ubl-utils.c | 24 +++++++--- source/ubl-utils.h | 2 + ubl-settings-logging-logrotate.glade | 2 +- 4 files changed, 75 insertions(+), 18 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 70f452b..ac34c9d 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -125,9 +125,27 @@ 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); + for (int i=0;ifirst,logrotate_window*); + logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*); char *paths=""; char *period=""; char *size=""; @@ -548,13 +568,17 @@ void on_logrotate_save(GtkWidget *self, logrotate_configure_window *window){ if(!yon_char_is_empty(paths)){ GtkTreeIter iter; yon_config_register(LOGROTATE(paths),"logging",commandline); - gtk_list_store_append(main_config.logrotate_list,&iter); + 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); + } + paths=yon_char_replace(paths,",","\n"); gtk_list_store_set(main_config.logrotate_list,&iter,0,gtk_entry_get_text(GTK_ENTRY(window->LogNameEntry)),1,paths,2,gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry)),-1); on_close_subwindow(window->MainWindow); } } -logrotate_configure_window *yon_logrotate_window_new(char *paths){ +logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_window *dialog){ logrotate_configure_window *window = malloc(sizeof(logrotate_configure_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_path); window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); @@ -619,8 +643,12 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths){ 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); + + 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); 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_logrotate_save),window); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_logrotate_save),dict); g_signal_connect(G_OBJECT(window->PathCell),"edited",G_CALLBACK(on_path_editing_done),window); g_signal_connect(G_OBJECT(window->PathCell),"editing-canceled",G_CALLBACK(on_path_editing_cancel),window); g_signal_connect(G_OBJECT(window->LogPathAddButton),"clicked",G_CALLBACK(on_logrotate_configuration_path_add),window); @@ -653,6 +681,11 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths){ 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); + int usize=0; + config_str users = yon_ubl_get_all_users(&usize); + yon_gtk_combo_box_fill(window->CreateLogUserCombo,users,usize); + yon_gtk_combo_box_fill(window->RotationAtUserCombo,users,usize); + if (paths){ int size; GtkTreeIter iter; @@ -799,31 +832,34 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths){ return window; } -void on_logrotate_add(GtkWidget *self, main_window *widgets){ - logrotate_configure_window *window = yon_logrotate_window_new(NULL); +void on_logrotate_add(GtkWidget *self, logrotate_window *dialog){ + logrotate_configure_window *window = yon_logrotate_window_new(NULL,NULL); + gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->MainTree))); gtk_widget_show(window->MainWindow); gtk_widget_set_sensitive(window->LogNameEntry,1); gtk_widget_set_sensitive(window->LogDescriptionEntry,1); gtk_label_set_text(GTK_LABEL(window->LogSizeLabel),""); } -void on_logrotate_edit(GtkWidget *self, logrotate_tab_window *window){ +void on_logrotate_edit(GtkWidget *self, logrotate_window *window){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); GtkTreeIter iter,itar; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model, &iter)){ char *name; int size=0; char *paths; + char *description; gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(window->MainTree)),&iter,1,&paths,-1); config_str path_parsed = yon_char_parse(paths,&size,"\n"); paths=NULL; for (int i=0;iMainWindow); - gtk_tree_model_get(model,&iter,0,&name,1,&paths,-1); + 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_widget_set_can_focus(dialog->LogNameEntry,0); gtk_widget_set_can_focus(dialog->LogDescriptionEntry,0); gtk_entry_set_has_frame(GTK_ENTRY(dialog->LogNameEntry),0); @@ -834,11 +870,15 @@ void on_logrotate_edit(GtkWidget *self, logrotate_tab_window *window){ } -void on_logrotate_remove(GtkWidget *self, logrotate_tab_window *window){ +void on_logrotate_remove(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)){ + char *paths; + gtk_tree_model_get(model,&iter,1,&paths,-1); gtk_list_store_remove(main_config.logrotate_list,&iter); + yon_char_replace(paths,"\n",","); + yon_config_remove_by_key(paths); } } @@ -871,7 +911,7 @@ void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict){ GList *paths = gtk_container_get_children((GtkContainer*)g_list_nth_data(list,i)); pathse=yon_char_unite(pathse ? yon_char_append(pathse,","):"",gtk_entry_get_text((GtkEntry*)g_list_nth_data(paths,1)),NULL); } - logrotate_configure_window *dialog = yon_logrotate_window_new(pathse); + logrotate_configure_window *dialog = yon_logrotate_window_new(pathse,NULL); gtk_widget_show(dialog->MainWindow); gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name); gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description); @@ -1611,6 +1651,7 @@ int main(int argc, char *argv[]){ yon_window_config_setup(GTK_WINDOW(widgets->Window)); yon_load_proceed(YON_CONFIG_LOCAL); yon_window_config_load(config_path); + update_loaded_logrotate(); GtkCssProvider *css=gtk_css_provider_new(); gtk_css_provider_load_from_resource(css,CssPath); gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), diff --git a/source/ubl-utils.c b/source/ubl-utils.c index ad2664a..32460ab 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -671,9 +671,9 @@ char **yon_char_parse(char *parameters, int *size, char *divider){ i++; if (strcmp(param,paramline)==0) break; } - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(paramline); - i++; + // string=realloc(string,sizeof(char*)*i); + // string[i-1]=yon_char_new(paramline); + // i++; // printf("%d\n",i); *size=i-1; return string; @@ -851,6 +851,20 @@ char *yon_ubl_user_get_home_directory(){ return ret; } +config_str yon_ubl_get_all_users(int *user_size){ + struct passwd *user = NULL; + config_str user_list = NULL; + while ((user = getpwent())) { + if (!user_list) + user_list = yon_char_parsed_new(user_size,user->pw_name,NULL); + else { + user_list = yon_char_parsed_append(user_list,user_size,user->pw_name); + } + } + endpwent(); + return user_list; +} + // parsing functions @@ -1875,13 +1889,13 @@ GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ // other Gtk functions -/**yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size) +/**yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size) * [EN] * * [RU] * Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size] */ -int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size){ +int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){ if (combo&¶meters){ for (int i=0;i Default Send Email - Don't send email + Don't send Email From 2f5850a8281dd06b2300cb98bc2c64a65efc7c23 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Oct 2023 17:26:16 +0600 Subject: [PATCH 23/25] Fixes and improvements --- gresource.xml | 1 + source/CMakeLists.txt | 1 + source/ubl-settings-logging.c | 27 +- source/ubl-utils.c | 2 +- ubl-settings-logging-logrotate.glade | 2986 +++++++++++++------------- ubl-settings-logging-rules.glade | 383 ++++ ubl-settings-logging_ru.po | 2 +- 7 files changed, 1885 insertions(+), 1517 deletions(-) create mode 100644 ubl-settings-logging-rules.glade diff --git a/gresource.xml b/gresource.xml index bf9d603..f7a9968 100644 --- a/gresource.xml +++ b/gresource.xml @@ -7,6 +7,7 @@ ubl-settings-logging-inspector.glade ubl-settings-logging-logrotate.glade ubl-settings-logging-journald.glade + ubl-settings-logging-rules.glade ubl-settings-logging-logrotate-table.glade diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 48c020f..24aa362 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -38,6 +38,7 @@ set(DEPENDFILES ../ubl-settings-logging.glade ../ubl-settings-logging-add.glade ../ubl-settings-logging-add-path.glade + ../ubl-settings-logging-rules.glade ../ubl-settings-logging-inspector.glade ../ubl-settings-logging-journald.glade ../ubl-settings-logging-logrotate.glade diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index ac34c9d..cd8a2c7 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -135,7 +135,7 @@ void update_loaded_logrotate(){ char *paths = yon_char_divide_search(loaded[i],"=",-1); yon_char_divide(paths,strlen("LOGROTATE")); yon_char_divide_search_self(paths,"]",-1); - yon_char_replace(loaded[i],",","\n"); + loaded[i] = yon_char_replace(loaded[i],",","\n"); gtk_list_store_append(main_config.logrotate_list,&iter); gtk_list_store_set(main_config.logrotate_list,&iter,1,paths,-1); } @@ -153,12 +153,14 @@ void on_load_global(){ yon_load_proceed(YON_CONFIG_GLOBAL); main_config.load_mode=0; yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + update_loaded_logrotate(); } void on_load_local(){ yon_load_proceed(YON_CONFIG_LOCAL); main_config.load_mode=1; yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + update_loaded_logrotate(); } @@ -184,13 +186,13 @@ void on_save_global_local(){ } void on_save_global(){ - yon_save_proceed("system",YON_CONFIG_LOCAL); + yon_save_proceed("global",YON_CONFIG_LOCAL); yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } void on_save_local(){ - yon_save_proceed("global",YON_CONFIG_GLOBAL); + yon_save_proceed("system",YON_CONFIG_GLOBAL); yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } @@ -697,8 +699,6 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind yon_char_parsed_free(parsed,size); char *parameters = yon_config_get_by_key(LOGROTATE(paths)); if (parameters){ - parameters = yon_char_replace(parameters,",\t",","); - if (parameters[0]==',') yon_char_divide_search(parameters,",",-1); parsed = yon_char_parse(parameters,&size,","); for (int i=0;iCommandBeforeOnceEntry),value); // i++; }else if (!strcmp(parsed[i],"endscript")){ - char *value = parsed[i+1]; - gtk_entry_set_text(GTK_ENTRY(window->EndworkCommandEntry),value); - i++; } } } @@ -878,7 +875,7 @@ void on_logrotate_remove(GtkWidget *self, logrotate_window *window){ gtk_tree_model_get(model,&iter,1,&paths,-1); gtk_list_store_remove(main_config.logrotate_list,&iter); yon_char_replace(paths,"\n",","); - yon_config_remove_by_key(paths); + yon_config_remove_by_key(LOGROTATE(paths)); } } @@ -891,6 +888,8 @@ void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){ char *settings; gtk_list_store_append(main_config.logrotate_list,&itar); gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&settings,-1); + 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); } @@ -1505,7 +1504,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,0,1,0,2,log[0],3,log[1],-1); + gtk_list_store_set(widgets->ServicesList,&iter,0,1,1,1,2,log[0],3,log[1],-1); } } config_str dirs = yon_config_load(logrotate_config_command,&dirs_size); @@ -1554,6 +1553,13 @@ main_window *setup_window(){ g_signal_connect(G_OBJECT(widgets->ConfigureButton),"clicked",G_CALLBACK(on_log_edit),widgets); g_signal_connect(G_OBJECT(widgets->RemoveButton),"clicked",G_CALLBACK(on_log_remove),widgets); g_signal_connect(G_OBJECT(widgets->ServicesEditButton),"clicked",G_CALLBACK(on_service_edit),widgets); + + g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(on_save_global_local),NULL); + g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(on_save_global),NULL); + g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(on_save_local),NULL); + + 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); gtk_widget_show(widgets->Window); @@ -1651,6 +1657,7 @@ int main(int argc, char *argv[]){ 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(); GtkCssProvider *css=gtk_css_provider_new(); gtk_css_provider_load_from_resource(css,CssPath); diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 32460ab..29373da 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1314,7 +1314,7 @@ int yon_config_save_registered(char *path){ 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){ ((yon_config_parameter*)dct)->flag1=0; 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); diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 2a16c16..637791d 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -387,1643 +387,1619 @@ - + True False - 0.019999999552965164 - in + vertical + 5 - + True False - 5 - 5 - 5 + 0.019999999552965164 + in - + True False - vertical - 5 + 5 + 5 + 5 - + True False - 0.019999999552965164 - in + vertical + 5 - + True False - 5 - 5 - 5 + 5 + + + Rotation period: + True + True + False + True + + + False + True + 0 + + - + True + False False - vertical - 5 - - - 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 - True - 0 - - - - - True - False - 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 - True - 1 - - + 0 + + Hourly + Daily + Weekly* + Monthly + Yearly + + + False + True + 1 + - - - - - True - False - Checking frequency configuration - - - - - False - True - 0 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - + True + False False - vertical - 5 - - - 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 - True - 0 - - - - - True - False - 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 - 1 - - + 0 + + Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday* + + + False + True + 2 + + + False + True + 0 + - - - True - False - Rotation configuration - - - - - False - True - 1 - - - - - True - False - 0.019999999552965164 - in - + True False - 5 - 5 - 5 + 5 + + + Maximum size of file: + True + True + False + True + + + False + True + 0 + + + + + True + False + True + adjustment4 + + + False + True + 1 + + - + True + False 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 - - + 0 + + Kb + Mb + Gb + + + False + True + 2 + - - - - True - False - File choosing configuration - + + False + True + 1 + - - False - True - 2 - + + + + + True + False + Checking frequency configuration + + + + + False + True + 0 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 - + True False - 0.019999999552965164 - in + vertical + 5 - + True False - 5 - 5 - 5 + 5 - + + File amount: 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 + 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 + True + 0 + + + + + True + False + 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 + 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 - Files and directories configuration - - - - - False - True - 3 - - - - - True - False - 0.019999999552965164 - in - + True False - 5 - 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 - - + Add date of rotation before log header + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + False + True + 1 + + + False + True + 1 + - - + + True False - Compression configuration + 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 + True + adjustment10 + + + False + True + 2 + + + + False + True + 2 + - - False - True - 4 - + + + + + True + False + Filename configuration + + + + + False + True + 5 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 - + True False - 0.019999999552965164 - in + vertical + 5 - + True False - 5 - 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 - True - adjustment10 - - - False - True - 2 - - - - - False - True - 2 - - + 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 - Filename configuration - + + False + True + 0 + - - False - True - 5 - + + + + + True + False + Message configuration + + + + + False + True + 6 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 - + True False - 0.019999999552965164 - in + vertical + 5 + + + Scenarios are running for each rotated journal + True + True + False + True + + + False + True + 0 + + - + True False - 5 - 5 - 5 + 5 - + True False - vertical - 5 - - - True - False - 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 - - - - - False - True - 0 - - + Command before rotation (one time): + 0 + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + False + True + 1 + - - - True - False - Message configuration - - - - - False - True - 6 - - - - - True - False - 0.019999999552965164 - in - + True False - 5 - 5 - 5 + 5 - + 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 - - - - - True - False - 5 - - - True - False - Command after rotation (one time): - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 2 - - - - - True - False - 5 - - - True - False - Command before rotation: - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 3 - - - - - True - False - 5 - - - True - False - Command after rotation: - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 4 - - - - - True - False - 5 - - - True - False - Endwork command: - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 5 - - + Command after rotation (one time): + 0 + + + False + True + 0 + + + + + True + True + + True + True + 1 + + + False + True + 2 + - - + + True False - Scenarios + 5 + + + True + False + Command before rotation: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + False + True + 3 + - - - False - True - 7 - - - - - False - 5 - + True False - Manual input: + 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 - 8 - + + + True + False + Scenarios + + + + False + True + 7 + - - - True + + False - Rotation configuration + 5 + + + True + False + Manual input: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + False + True + 8 + diff --git a/ubl-settings-logging-rules.glade b/ubl-settings-logging-rules.glade new file mode 100644 index 0000000..c3fd858 --- /dev/null +++ b/ubl-settings-logging-rules.glade @@ -0,0 +1,383 @@ + + + + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + + False + 550 + 450 + com.ublinux.ubl-settings-logging + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + 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 + Owner rules + + + + + False + True + 0 + + + + + True + 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 + Group rules + + + + + False + True + 1 + + + + + True + 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 + 2 + + + + + True + False + 5 + + + True + False + Value: + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + False + True + 3 + + + + + True + False + end + 5 + + + Cancel + True + True + True + image1 + + + False + True + 0 + + + + + Accept + True + True + True + image2 + + + False + True + 1 + + + + + False + True + end + 4 + + + + + + + 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_ru.po b/ubl-settings-logging_ru.po index a9b17a8..ddc3ef2 100644 --- a/ubl-settings-logging_ru.po +++ b/ubl-settings-logging_ru.po @@ -624,7 +624,7 @@ msgstr "Последняя ротированная копия" #: source/ubl-strings.h:160 msgid "Endwork command:" -msgstr "Команда конца работы:" +msgstr "Команда перед удалением файла журнала:" #: source/ubl-strings.h:163 #, fuzzy From c68cbb1c267d71dea12c8be1b6a3d979012709cd Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Oct 2023 17:51:48 +0600 Subject: [PATCH 24/25] Log inspector fix --- source/ubl-settings-logging.c | 76 +++++++++++++++++++++-------------- source/ubl-settings-logging.h | 4 +- 2 files changed, 48 insertions(+), 32 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index cd8a2c7..5b01d01 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -205,37 +205,48 @@ void on_inspector_update(GtkWidget *self, inspector_window *window){ gtk_text_buffer_get_bounds(window->textbuffer1,&titer,&titerend); gtk_text_buffer_delete(window->textbuffer1,&titer,&titerend); config_str output; - if (self==window->UpdateButton){ - switch(window->last_mode){ - case 0: output = yon_config_load(get_journal_output_command, &size); - break; - case 1: output = yon_config_load(get_journal_output_since_boot_command, &size); - break; - case 2: output = yon_config_load(get_journal_output_followed_command, &size); - break; - case 3: output = yon_config_load(get_journal_output_kernel_command, &size); - break; - case 4: output = yon_config_load(get_journal_output_prioritied_command, &size); - break; + 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); + break; + case 1: output = yon_config_load(get_journal_output_since_boot_command, &size); + break; + case 2: output = yon_config_load(get_journal_output_followed_command, &size); + break; + case 3: output = yon_config_load(get_journal_output_kernel_command, &size); + break; + case 4: output = yon_config_load(get_journal_output_prioritied_command, &size); + break; + } } - } - if (self==window->ShowSinceBootButton){ - window->last_mode=1; - output = yon_config_load(get_journal_output_since_boot_command, &size); - } - if (self==window->NewMessagesButton){ - window->last_mode=2; - output = yon_config_load(get_journal_output_followed_command, &size); - } - if (self==window->ShowKernelButton){ - window->last_mode=3; - output = yon_config_load(get_journal_output_kernel_command, &size); - } - if (self==window->ShowPriorityButton){ - window->last_mode=4; - output = yon_config_load(get_journal_output_prioritied_command, &size); - } - if (output){ + if (self==window->ShowSinceBootButton){ + window->last_mode=1; + output = yon_config_load(get_journal_output_since_boot_command, &size); + } + if (self==window->NewMessagesButton){ + window->last_mode=2; + output = yon_config_load(get_journal_output_followed_command, &size); + } + if (self==window->ShowKernelButton){ + window->last_mode=3; + output = yon_config_load(get_journal_output_kernel_command, &size); + } + 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); + } + } 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); @@ -261,19 +272,22 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->list); GtkTreeIter iter; char *name; + char *paths; g_signal_connect(G_OBJECT(window->UpdateButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->ShowKernelButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->NewMessagesButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->ShowPriorityButton),"clicked", G_CALLBACK(on_inspector_update),window); g_signal_connect(G_OBJECT(window->ShowSinceBootButton),"clicked", G_CALLBACK(on_inspector_update),window); if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ - gtk_tree_model_get(model,&iter,0,&name,-1); + gtk_tree_model_get(model,&iter,0,&name,1,&paths,-1); if (strcmp(name,"journald")){ window->last_mode=-1; gtk_widget_hide(window->JournalActionsBox); } else { window->last_mode=0; } + window->journal_name=name; + window->journal_paths=paths; on_inspector_update(window->UpdateButton,window); gtk_widget_show(window->MainWindow); } diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index 07d497e..b560b95 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -45,7 +45,7 @@ #define get_journal_output_kernel_command "journalctl --no-pager -k" #define get_journal_output_prioritied_command "journalctl --no-pager -p err..alert" -#define yon_add_space_if_exists(string) yon_char_is_empty(string) ? "" : yon_char_append(" ",string) +#define yon_add_space_if_exists(string) yon_char_is_empty(string) ? "" : yon_char_append(",",string) typedef char* string; string version_application; @@ -187,6 +187,8 @@ GtkWidget *UpdateButton; GtkWidget *LoggingTextView; GtkWidget *JournalActionsBox; int last_mode; +char *journal_name; +char *journal_paths; } inspector_window; From 6e6d294503a0d88daa0296b0bb8950476f7b52e6 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 26 Oct 2023 18:00:16 +0600 Subject: [PATCH 25/25] Fixes --- 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 5b01d01..a4d8b0e 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -422,17 +422,17 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ switch (active){ case 0: period = "hourly"; break; - case 2: period = "daily"; + case 1: period = "daily"; break; - case 3: period = "weekly"; + case 2: period = "weekly"; int weekday = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RotationPeriodAdditionalCombo)); weekday++; if (weekday==7) weekday=0; period = yon_char_unite(period,", ",yon_char_from_int(weekday),NULL); break; - case 4: period = "monthly"; + case 3: period = "monthly"; break; - case 5: period = "yearly"; + case 4: period = "yearly"; break; } }