From 31c8e753a59aaea7884243c32e00eb7249311abf Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 7 Apr 2025 17:37:52 +0600 Subject: [PATCH 1/3] Added rotation as user enabling check box --- source/ubl-settings-logging.c | 17 +++++++++++------ source/ubl-settings-logging.h | 1 + ubl-settings-logging-logrotate.glade | 8 +++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 71096f3..2cd3deb 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1104,12 +1104,14 @@ void on_logrotate_save(GtkWidget *, dictionary *dict){ } } - 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 (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); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->RotationCheck))){ + 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 (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)); @@ -1387,6 +1389,7 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind window->FileAmountCombo=yon_gtk_builder_get_widget(builder,"FileAmountCombo"); window->FileAmountEntry=yon_gtk_builder_get_widget(builder,"FileAmountEntry"); window->FileAmountButton=yon_gtk_builder_get_widget(builder,"FileAmountButton"); + window->RotationCheck=yon_gtk_builder_get_widget(builder,"RotationCheck"); window->RotationAtUserCombo=yon_gtk_builder_get_widget(builder,"RotationAtUserCombo"); window->RotationAtGroupCombo=yon_gtk_builder_get_widget(builder,"RotationAtGroupCombo"); window->ErrorProcessingCombo=yon_gtk_builder_get_widget(builder,"ErrorProcessingCombo"); @@ -1496,6 +1499,8 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeSpin); g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeCombo); + g_signal_connect(G_OBJECT(window->RotationCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationAtUserCombo); + g_signal_connect(G_OBJECT(window->RotationCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotationAtGroupCombo); g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(on_combo_activate_second),window->CreateLogUserCombo); g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(on_combo_activate_second),window->CreateGroupCombo); diff --git a/source/ubl-settings-logging.h b/source/ubl-settings-logging.h index 1e88364..d9fc736 100644 --- a/source/ubl-settings-logging.h +++ b/source/ubl-settings-logging.h @@ -316,6 +316,7 @@ typedef struct { GtkWidget *FileAmountCombo; GtkWidget *FileAmountEntry; GtkWidget *FileAmountButton; + GtkWidget *RotationCheck; GtkWidget *RotationAtUserCombo; GtkWidget *RotationAtGroupCombo; GtkWidget *ErrorProcessingCombo; diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 169fe5c..3e37a6c 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -668,10 +668,12 @@ False 5 - - True - False + Rotation as user: + True + True + False + True False From 0c60dfdff2b4db91df7086886c3a36e786e63a2a Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 7 Apr 2025 17:46:31 +0600 Subject: [PATCH 2/3] Fixed su saving --- source/ubl-settings-logging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 2cd3deb..35a89bd 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1112,7 +1112,7 @@ void on_logrotate_save(GtkWidget *, dictionary *dict){ 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); } - } + } else su =""; int error_processing = gtk_combo_box_get_active(GTK_COMBO_BOX(window->ErrorProcessingCombo)); if (error_processing==0|| error_processing==1) { From 0cd3290bdc377f353c82bcd67ec26b17d9e94fcd Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 8 Apr 2025 15:21:21 +0600 Subject: [PATCH 3/3] Fixed rotate as user check activeness --- source/ubl-settings-logging.c | 1 + ubl-settings-logging-logrotate.glade | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 35a89bd..57cd416 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -1594,6 +1594,7 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind 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); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationCheck),1); }else if (!strcmp(parsed[i],"missingok")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->ErrorProcessingCombo),1); }else if (!strcmp(parsed[i],"nomissingok")){ diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 3e37a6c..0400aa9 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -1,5 +1,5 @@ - + @@ -684,6 +684,7 @@ True + False False 0 @@ -711,6 +712,7 @@ True + False False 0