diff --git a/source/ubl-settings-logging.c b/source/ubl-settings-logging.c index 2e42cc8..90f4eb6 100644 --- a/source/ubl-settings-logging.c +++ b/source/ubl-settings-logging.c @@ -377,6 +377,35 @@ void on_logrotate_configuration_path_remove(GtkWidget *self, logrotate_configure } } +void on_combo_activate_first(GtkComboBox *self, GtkWidget *target){ + if (gtk_combo_box_get_active(self)==1) gtk_widget_set_sensitive(target,1); + else gtk_widget_set_sensitive(target,0); + +} + +void on_combo_activate_second(GtkComboBox *self, GtkWidget *target){ + if (gtk_combo_box_get_active(self)==2) gtk_widget_set_sensitive(target,1); + else gtk_widget_set_sensitive(target,0); + +} + +void on_file_amount_checked(GtkToggleButton *self, logrotate_configure_window *window){ + if (gtk_toggle_button_get_active(self)==1){ + gtk_widget_set_sensitive(window->FileAmountCombo,1); + gtk_widget_set_sensitive(window->FileAmountSpin,1); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->FileAmountCombo))==2){ + gtk_widget_set_sensitive(window->FileAmountButton,1); + gtk_widget_set_sensitive(window->FileAmountEntry,1); + } + } else { + gtk_widget_set_sensitive(window->FileAmountButton,0); + gtk_widget_set_sensitive(window->FileAmountEntry,0); + gtk_widget_set_sensitive(window->FileAmountSpin,0); + gtk_widget_set_sensitive(window->FileAmountCombo,0); + + } +} + void on_logrotate_save(GtkWidget *self, dictionary *dict){ logrotate_window *dialog = yon_dictionary_get_data(dict->first,logrotate_window*); logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*); @@ -578,8 +607,8 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){ } char *commandline = yon_char_unite(period,yon_add_space_if_exists(size),yon_add_space_if_exists(rotate_count),yon_add_space_if_exists(olddir),yon_add_space_if_exists(su),yon_add_space_if_exists(missingok),yon_add_space_if_exists(ifempty),yon_add_space_if_exists(notifempty),yon_add_space_if_exists(minage),yon_add_space_if_exists(maxage),yon_add_space_if_exists(minsize),yon_add_space_if_exists(maxsize),yon_add_space_if_exists(create),yon_add_space_if_exists(copytruncate),yon_add_space_if_exists(compress),yon_add_space_if_exists(delaycompress),yon_add_space_if_exists(extension),yon_add_space_if_exists(dateext),yon_add_space_if_exists(start),yon_add_space_if_exists(mail),yon_add_space_if_exists(mailfirst),yon_add_space_if_exists(sharedscripts),yon_add_space_if_exists(firstaction),yon_add_space_if_exists(lastaction),yon_add_space_if_exists(prerotate),yon_add_space_if_exists(postrotate),yon_add_space_if_exists(preremove),yon_add_space_if_exists(endscript),NULL); - if (commandline[0]==' '){ - free(yon_char_divide_search(commandline," ",-1)); + if (commandline[0]==','){ + free(yon_char_divide_search(commandline,",",-1)); } if(!yon_char_is_empty(paths)){ GtkTreeIter iter; @@ -699,11 +728,8 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind g_signal_connect(G_OBJECT(window->JournalMaxSizeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->JournalMaxSizeCombo); g_signal_connect(G_OBJECT(window->JournalMaxSizeCheck),"clicked",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->JournalMaxSizeSpin); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountSpin); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountCombo); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountEntry); - g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->FileAmountButton); - + g_signal_connect(G_OBJECT(window->FileAmountCheck),"toggled",G_CALLBACK(on_file_amount_checked),window); + g_signal_connect(G_OBJECT(window->DoNotRotateYoungerCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DoNotRotateYoungerSpin); g_signal_connect(G_OBJECT(window->DeleteOlderCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeleteOlderSpin); @@ -714,11 +740,19 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeSpin); g_signal_connect(G_OBJECT(window->RotateSizeMaxBeforeTimeCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->RotateSizeMaxBeforeTimeCombo); - g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateLogUserCombo); - g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateGroupCombo); - g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateLogEntry); - g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box_inversed),window->CreateLogButton); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(on_combo_activate_second),window->CreateLogUserCombo); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(on_combo_activate_second),window->CreateGroupCombo); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(on_combo_activate_second),window->CreateLogEntry); + g_signal_connect(G_OBJECT(window->CreateLogCombo),"changed",G_CALLBACK(on_combo_activate_second),window->CreateLogButton); + g_signal_connect(G_OBJECT(window->FileAmountCombo),"changed",G_CALLBACK(on_combo_activate_second),window->FileAmountButton); + g_signal_connect(G_OBJECT(window->FileAmountCombo),"changed",G_CALLBACK(on_combo_activate_second),window->FileAmountEntry); + g_signal_connect(G_OBJECT(window->CompressionCombo),"changed",G_CALLBACK(on_combo_activate_first),window->QueueCombo); + g_signal_connect(G_OBJECT(window->SaveOriginalCombo),"changed",G_CALLBACK(on_combo_activate_first),window->SaveOriginalEntry); + g_signal_connect(G_OBJECT(window->OldNumberCombo),"changed",G_CALLBACK(on_combo_activate_first),window->OldNumberEntry); + + g_signal_connect(G_OBJECT(window->EmailCombo),"changed",G_CALLBACK(on_combo_activate_first),window->EmailEntry); + g_signal_connect(G_OBJECT(window->EmailCombo),"changed",G_CALLBACK(on_combo_activate_first),window->EmailContentsCombo); int usize=0; config_str users = yon_ubl_get_all_users(&usize); yon_gtk_combo_box_fill(window->CreateLogUserCombo,users,usize); @@ -751,22 +785,13 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),3); }else if (!strcmp(parsed[i],"yearly")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),4); - }else if (!strcmp(parsed[i],"size")){ - int sizemod = yon_size_get_int_from_letter(parsed[i][strlen(parsed[i])-1]); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->JournalMaxSizeSpin),atol(parsed[i])); - gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalMaxSizeCombo),sizemod); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->JournalMaxSizeCheck),1); - }else if (!strcmp(parsed[i],"rotate")){ - char *value = strstr(parsed[i]," ")+1; - gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->FileAmountSpin),atol(value)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck),1); }else if (!strcmp(parsed[i],"olddir")){ char *value = strstr(parsed[i]," ")+1; gtk_entry_set_text(GTK_ENTRY(window->FileAmountEntry),value); gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),1); }else if (!strcmp(parsed[i],"noolddir")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),2); - }else if (!strcmp(parsed[i],"su")){ + }else if (strstr(parsed[i],"su")){ char *value = strstr(parsed[i]," ")+1; char *nvalue = yon_char_divide_search(value," ",-1); int us = yon_gtk_combo_box_text_find(window->RotationAtUserCombo,nvalue); @@ -781,20 +806,20 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),1); }else if (!strcmp(parsed[i],"notifempty")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),2); - }else if (!strcmp(parsed[i],"minage")){ + }else if (strstr(parsed[i],"minage")){ char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DoNotRotateYoungerSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DoNotRotateYoungerCheck),1); - }else if (!strcmp(parsed[i],"maxage")){ + }else if (strstr(parsed[i],"maxage")){ char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeleteOlderSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeleteOlderCheck),1); - }else if (!strcmp(parsed[i],"minsize")){ + }else if (strstr(parsed[i],"minsize")){ char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotateSizeMaxAfterTimeSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxAfterTimeCheck),1); gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotateSizeMaxAfterTimeCombo),yon_size_get_int_from_letter(value[strlen(value)-1])); - }else if (!strcmp(parsed[i],"maxsize")){ + }else if (strstr(parsed[i],"maxsize")){ char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotateSizeMaxBeforeTimeSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxBeforeTimeCheck),1); @@ -803,6 +828,11 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind // // }else if (!strcmp(parsed[i],"nocreate")){ // + }else if (strstr(parsed[i],"size")){ + int sizemod = yon_size_get_int_from_letter(parsed[i][strlen(parsed[i])-1]); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->JournalMaxSizeSpin),atol(parsed[i])); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalMaxSizeCombo),sizemod); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->JournalMaxSizeCheck),1); }else if (!strcmp(parsed[i],"copytruncate")){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CutCheck),1); }else if (!strcmp(parsed[i],"compress")){ @@ -814,17 +844,17 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind }else if (!strcmp(parsed[i],"nodelaycompress")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->QueueCombo),2); - }else if (!strcmp(parsed[i],"extension")){ + }else if (strstr(parsed[i],"extension")){ char *value = strstr(parsed[i]," ")+1; gtk_combo_box_set_active(GTK_COMBO_BOX(window->SaveOriginalCombo),1); gtk_entry_set_text(GTK_ENTRY(window->SaveOriginalEntry),value); }else if (!strcmp(parsed[i],"dateext")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->AddDateCombo),1); - }else if (!strcmp(parsed[i],"start")){ + }else if (strstr(parsed[i],"start")){ char *value = strstr(parsed[i]," ")+1; gtk_combo_box_set_active(GTK_COMBO_BOX(window->OldNumberCombo),1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->OldNumberEntry),atol(value)); - }else if (!strcmp(parsed[i],"mail")){ + }else if (strstr(parsed[i],"mail")){ char *value = strstr(parsed[i]," ")+1; gtk_entry_set_text(GTK_ENTRY(window->EmailEntry),value); gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),1); @@ -836,19 +866,19 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailContentsCombo),2); }else if (!strcmp(parsed[i],"sharedscripts")){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SharedScenariosCheck),1); - }else if (!strcmp(parsed[i],"firstaction")){ + }else if (strstr(parsed[i],"firstaction")){ char *value = parsed[i+1]; gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value); i++; - }else if (!strcmp(parsed[i],"lastaction")){ + }else if (strstr(parsed[i],"lastaction")){ char *value = parsed[i+1]; gtk_entry_set_text(GTK_ENTRY(window->CommandAfterOnceEntry),value); i++; - }else if (!strcmp(parsed[i],"prerotate")){ + }else if (strstr(parsed[i],"prerotate")){ char *value = parsed[i+1]; gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeEntry),value); i++; - }else if (!strcmp(parsed[i],"postrotate")){ + }else if (strstr(parsed[i],"postrotate")){ char *value = parsed[i+1]; gtk_entry_set_text(GTK_ENTRY(window->CommandAfterEntry),value); i++; @@ -856,6 +886,10 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind // char *value = parsed[i+1]; // gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value); // i++; + }else if (strstr(parsed[i],"rotate")){ + char *value = strstr(parsed[i]," ")+1; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->FileAmountSpin),atol(value)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck),1); }else if (!strcmp(parsed[i],"endscript")){ } } diff --git a/ubl-settings-logging-journald.glade b/ubl-settings-logging-journald.glade index 0ce2cab..43c4722 100644 --- a/ubl-settings-logging-journald.glade +++ b/ubl-settings-logging-journald.glade @@ -166,7 +166,6 @@ True - False True journald diff --git a/ubl-settings-logging-logrotate.glade b/ubl-settings-logging-logrotate.glade index 637791d..b1f96a6 100644 --- a/ubl-settings-logging-logrotate.glade +++ b/ubl-settings-logging-logrotate.glade @@ -1570,6 +1570,7 @@ True + False True adjustment10 diff --git a/ubl-settings-logging-rules.glade b/ubl-settings-logging-rules.glade index c3fd858..6d5f82a 100644 --- a/ubl-settings-logging-rules.glade +++ b/ubl-settings-logging-rules.glade @@ -14,8 +14,6 @@ False - 550 - 450 com.ublinux.ubl-settings-logging @@ -284,7 +282,7 @@ False - False + True True 1