Logrotate saving pattern has been reworked

pull/80/head
Ivan Yartsev 2 years ago
parent 14d263861a
commit edc6a68289

@ -170,9 +170,14 @@ void update_loaded_logrotate(){
yon_char_divide_search_self(paths,"]",-1); yon_char_divide_search_self(paths,"]",-1);
yon_window_config_get_parameter("description",paths,&desc,YON_TYPE_STRING); yon_window_config_get_parameter("description",paths,&desc,YON_TYPE_STRING);
yon_window_config_get_parameter("render_name",paths,&name,YON_TYPE_STRING); yon_window_config_get_parameter("render_name",paths,&name,YON_TYPE_STRING);
paths = yon_char_replace(paths,",","\n"); char *parameters = strstr(loaded[i],":");
if(!parameters) continue;
char *paths_found=yon_char_divide(loaded[i],strlen(loaded[i])-strlen(parameters));
paths_found = yon_char_replace(paths_found,",","\n");
if(paths_found[0]=='\"') yon_char_divide(paths_found,0);
if(paths_found[strlen(paths_found)-1]=='\"') paths_found[strlen(paths_found)-1]='\"';
gtk_list_store_append(main_config.logrotate_list,&iter); gtk_list_store_append(main_config.logrotate_list,&iter);
gtk_list_store_set(main_config.logrotate_list,&iter,0,name,1,paths,2,desc ? desc : "",-1); gtk_list_store_set(main_config.logrotate_list,&iter,0,paths,1,paths_found,2,desc ? desc : "",-1);
} }
} }
@ -1032,7 +1037,8 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){
yon_window_config_erase_custom_parameter(window->paths,"description"); yon_window_config_erase_custom_parameter(window->paths,"description");
} }
GtkTreeIter iter; GtkTreeIter iter;
yon_config_register(LOGROTATE(paths),"logging",commandline); paths = yon_char_replace(paths,"\n",",");
yon_config_register(LOGROTATE(log_name),"logging",yon_char_unite(paths,":",commandline,NULL));
yon_window_config_add_custom_parameter(paths,"description",yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry))),YON_TYPE_STRING); yon_window_config_add_custom_parameter(paths,"description",yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->LogDescriptionEntry))),YON_TYPE_STRING);
yon_window_config_add_custom_parameter(paths,"render_name",yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->LogNameEntry))),YON_TYPE_STRING); yon_window_config_add_custom_parameter(paths,"render_name",yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->LogNameEntry))),YON_TYPE_STRING);
GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list); GtkTreeModel *model = GTK_TREE_MODEL(main_config.logrotate_list);
@ -1045,7 +1051,7 @@ void on_logrotate_save(GtkWidget *self, dictionary *dict){
} }
} }
logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_window *dialog){ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_window *dialog, char *log_name){
logrotate_configure_window *window = malloc(sizeof(logrotate_configure_window)); logrotate_configure_window *window = malloc(sizeof(logrotate_configure_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_path); GtkBuilder *builder = gtk_builder_new_from_resource(glade_logrotate_path);
window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); window->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow");
@ -1121,7 +1127,7 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind
int sz; int sz;
float finalsize=0.0; float finalsize=0.0;
char *temp_paths = yon_char_new(paths); char *temp_paths = yon_char_new(paths);
config_str parsed_paths = yon_char_parse(temp_paths,&sz,","); config_str parsed_paths = yon_char_parse(temp_paths,&sz,"\n");
free(temp_paths); free(temp_paths);
temp_paths=NULL; temp_paths=NULL;
for (int i=0;i<sz;i++){ for (int i=0;i<sz;i++){
@ -1200,135 +1206,149 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind
if (paths){ if (paths){
int size; int size;
GtkTreeIter iter; GtkTreeIter iter;
config_str parsed = yon_char_parse(paths,&size,","); config_str parsed = yon_char_parse(paths,&size,"\n");
for (int i=0; i<size;i++){ for (int i=0; i<size;i++){
gtk_list_store_append(window->list,&iter); gtk_list_store_append(window->list,&iter);
gtk_list_store_set(window->list,&iter,0,parsed[i],-1); gtk_list_store_set(window->list,&iter,0,parsed[i],-1);
} }
yon_char_parsed_free(parsed,size); yon_char_parsed_free(parsed,size);
char *parameters = yon_config_get_by_key(LOGROTATE(paths)); if (log_name){
if (parameters){ char *parameters = yon_config_get_by_key(LOGROTATE(log_name));
parsed = yon_char_parse(parameters,&size,","); if (parameters){
for (int i=0;i<size;i++){ if(parameters[strlen(parameters)-1]=='\"') parameters[strlen(parameters)-1]='\0';
if (!strcmp(parsed[i],"hourly")){ parameters=strstr(parameters,":");
gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),0); if (parameters) parameters++;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1); parsed = yon_char_parse(parameters,&size,",");
} else if (!strcmp(parsed[i],"daily")){ for (int i=0;i<size;i++){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),1); if (!strcmp(parsed[i],"hourly")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1); gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),0);
}else if (strstr(parsed[i],"weekly")){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),2); } else if (!strcmp(parsed[i],"daily")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1); gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),1);
int dayofweek = atoi(strstr(parsed[i]," ")+1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1);
if (dayofweek==0) dayofweek=7; }else if (strstr(parsed[i],"weekly")){
dayofweek--; gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),2);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodAdditionalCombo),dayofweek); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotationPeriodCheck),1);
}else if (!strcmp(parsed[i],"monthly")){ int dayofweek = atoi(strstr(parsed[i]," ")+1);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),3); if (dayofweek==0) dayofweek=7;
}else if (!strcmp(parsed[i],"yearly")){ dayofweek--;
gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),4); gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodAdditionalCombo),dayofweek);
}else if (!strcmp(parsed[i],"olddir")){ }else if (!strcmp(parsed[i],"monthly")){
char *value = strstr(parsed[i]," ")+1; gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),3);
gtk_entry_set_text(GTK_ENTRY(window->FileAmountEntry),value); }else if (!strcmp(parsed[i],"yearly")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),1); gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationPeriodMainCombo),4);
}else if (!strcmp(parsed[i],"noolddir")){ }else if (!strcmp(parsed[i],"olddir")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),2); char *value = strstr(parsed[i]," ");
}else if (strstr(parsed[i],"su")){ if (value) value++;
char *value = strstr(parsed[i]," ")+1; gtk_entry_set_text(GTK_ENTRY(window->FileAmountEntry),value);
char *nvalue = yon_char_divide_search(value," ",-1); gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),1);
int us = yon_gtk_combo_box_text_find(window->RotationAtUserCombo,nvalue); }else if (!strcmp(parsed[i],"noolddir")){
int gr = yon_gtk_combo_box_text_find(window->RotationAtGroupCombo,value); gtk_combo_box_set_active(GTK_COMBO_BOX(window->FileAmountCombo),2);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationAtUserCombo),us); }else if (strstr(parsed[i],"su")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationAtGroupCombo),gr); char *value = strstr(parsed[i]," ");
}else if (!strcmp(parsed[i],"missingok")){ if (value) value++;
gtk_combo_box_set_active(GTK_COMBO_BOX(window->ErrorProcessingCombo),1); char *nvalue = yon_char_divide_search(value," ",-1);
}else if (!strcmp(parsed[i],"nomissingok")){ int us = yon_gtk_combo_box_text_find(window->RotationAtUserCombo,nvalue);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->ErrorProcessingCombo),2); int gr = yon_gtk_combo_box_text_find(window->RotationAtGroupCombo,value);
}else if (!strcmp(parsed[i],"ifempty")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationAtUserCombo),us);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),1); gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotationAtGroupCombo),gr);
}else if (!strcmp(parsed[i],"notifempty")){ }else if (!strcmp(parsed[i],"missingok")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),2); gtk_combo_box_set_active(GTK_COMBO_BOX(window->ErrorProcessingCombo),1);
}else if (strstr(parsed[i],"minage")){ }else if (!strcmp(parsed[i],"nomissingok")){
char *value = strstr(parsed[i]," ")+1; gtk_combo_box_set_active(GTK_COMBO_BOX(window->ErrorProcessingCombo),2);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DoNotRotateYoungerSpin),atol(value)); }else if (!strcmp(parsed[i],"ifempty")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DoNotRotateYoungerCheck),1); gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),1);
}else if (strstr(parsed[i],"maxage")){ }else if (!strcmp(parsed[i],"notifempty")){
char *value = strstr(parsed[i]," ")+1; gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalEmptyCombo),2);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeleteOlderSpin),atol(value)); }else if (strstr(parsed[i],"minage")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeleteOlderCheck),1); char *value = strstr(parsed[i]," ");
}else if (strstr(parsed[i],"minsize")){ if (value) value++;
char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DoNotRotateYoungerSpin),atol(value));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotateSizeMaxAfterTimeSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DoNotRotateYoungerCheck),1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxAfterTimeCheck),1); }else if (strstr(parsed[i],"maxage")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotateSizeMaxAfterTimeCombo),yon_size_get_int_from_letter(value[strlen(value)-1])); char *value = strstr(parsed[i]," ");
}else if (strstr(parsed[i],"maxsize")){ if (value) value++;
char *value = strstr(parsed[i]," ")+1; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeleteOlderSpin),atol(value));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotateSizeMaxBeforeTimeSpin),atol(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeleteOlderCheck),1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxBeforeTimeCheck),1); }else if (strstr(parsed[i],"minsize")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotateSizeMaxBeforeTimeCombo),yon_size_get_int_from_letter(value[strlen(value)-1])); char *value = strstr(parsed[i]," ");
}else if (strstr(parsed[i],"size")){ if (value) value++;
int sizemod = yon_size_get_int_from_letter(parsed[i][strlen(parsed[i])-1]); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotateSizeMaxAfterTimeSpin),atol(value));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->JournalMaxSizeSpin),atol(strstr(parsed[i], " ")+1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxAfterTimeCheck),1);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalMaxSizeCombo),sizemod); gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotateSizeMaxAfterTimeCombo),yon_size_get_int_from_letter(value[strlen(value)-1]));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->JournalMaxSizeCheck),1); }else if (strstr(parsed[i],"maxsize")){
}else if (!strcmp(parsed[i],"copytruncate")){ char *value = strstr(parsed[i]," ");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CutCheck),1); if (value) value++;
}else if (!strcmp(parsed[i],"compress")){ gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->RotateSizeMaxBeforeTimeSpin),atol(value));
gtk_combo_box_set_active(GTK_COMBO_BOX(window->CompressionCombo),1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->RotateSizeMaxBeforeTimeCheck),1);
}else if (!strcmp(parsed[i],"nocompress")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->RotateSizeMaxBeforeTimeCombo),yon_size_get_int_from_letter(value[strlen(value)-1]));
gtk_combo_box_set_active(GTK_COMBO_BOX(window->CompressionCombo),2); }else if (strstr(parsed[i],"size")){
}else if (!strcmp(parsed[i],"delaycompress")){ int sizemod = yon_size_get_int_from_letter(parsed[i][strlen(parsed[i])-1]);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->QueueCombo),1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->JournalMaxSizeSpin),atol(strstr(parsed[i], " ")+1));
gtk_combo_box_set_active(GTK_COMBO_BOX(window->JournalMaxSizeCombo),sizemod);
}else if (!strcmp(parsed[i],"nodelaycompress")){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->JournalMaxSizeCheck),1);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->QueueCombo),2); }else if (!strcmp(parsed[i],"copytruncate")){
}else if (strstr(parsed[i],"extension")){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CutCheck),1);
char *value = strstr(parsed[i]," ")+1; }else if (!strcmp(parsed[i],"compress")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->SaveOriginalCombo),1); gtk_combo_box_set_active(GTK_COMBO_BOX(window->CompressionCombo),1);
gtk_entry_set_text(GTK_ENTRY(window->SaveOriginalEntry),value); }else if (!strcmp(parsed[i],"nocompress")){
}else if (!strcmp(parsed[i],"dateext")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->CompressionCombo),2);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->AddDateCombo),1); }else if (!strcmp(parsed[i],"delaycompress")){
}else if (strstr(parsed[i],"start")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->QueueCombo),1);
char *value = strstr(parsed[i]," ")+1;
gtk_combo_box_set_active(GTK_COMBO_BOX(window->OldNumberCombo),1); }else if (!strcmp(parsed[i],"nodelaycompress")){
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->OldNumberEntry),atol(value)); gtk_combo_box_set_active(GTK_COMBO_BOX(window->QueueCombo),2);
}else if (!strcmp(parsed[i],"nomail")){ }else if (strstr(parsed[i],"extension")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),2); char *value = strstr(parsed[i]," ");
}else if (strstr(parsed[i],"mail")){ if (value) value++;
char *value = strstr(parsed[i]," ")+1; gtk_combo_box_set_active(GTK_COMBO_BOX(window->SaveOriginalCombo),1);
gtk_entry_set_text(GTK_ENTRY(window->EmailEntry),value); gtk_entry_set_text(GTK_ENTRY(window->SaveOriginalEntry),value);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),1); }else if (!strcmp(parsed[i],"dateext")){
}else if (!strcmp(parsed[i],"mailfirst")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->AddDateCombo),1);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailContentsCombo),1); }else if (strstr(parsed[i],"start")){
}else if (!strcmp(parsed[i],"maillast")){ char *value = strstr(parsed[i]," ");
gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailContentsCombo),2); if (value) value++;
}else if (!strcmp(parsed[i],"sharedscripts")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->OldNumberCombo),1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SharedScenariosCheck),1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->OldNumberEntry),atol(value));
}else if (strstr(parsed[i],"firstaction")){ }else if (!strcmp(parsed[i],"mailfirst")){
char *value = parsed[i+1]; gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailContentsCombo),1);
gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value); }else if (!strcmp(parsed[i],"maillast")){
i++; gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailContentsCombo),2);
}else if (strstr(parsed[i],"lastaction")){ }else if (!strcmp(parsed[i],"nomail")){
char *value = parsed[i+1]; gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),2);
gtk_entry_set_text(GTK_ENTRY(window->CommandAfterOnceEntry),value); }else if (strstr(parsed[i],"mail")){
i++; char *value = strstr(parsed[i]," ");
}else if (strstr(parsed[i],"prerotate")){ if (value) value++;
char *value = parsed[i+1]; gtk_entry_set_text(GTK_ENTRY(window->EmailEntry),value);
gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeEntry),value); gtk_combo_box_set_active(GTK_COMBO_BOX(window->EmailCombo),1);
i++; }else if (!strcmp(parsed[i],"sharedscripts")){
}else if (strstr(parsed[i],"postrotate")){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SharedScenariosCheck),1);
char *value = parsed[i+1]; }else if (strstr(parsed[i],"firstaction")){
gtk_entry_set_text(GTK_ENTRY(window->CommandAfterEntry),value); char *value = parsed[i+1];
i++; gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeOnceEntry),value);
}else if (!strcmp(parsed[i],"preremove")){ i++;
char *value = parsed[i+1]; }else if (strstr(parsed[i],"lastaction")){
gtk_entry_set_text(GTK_ENTRY(window->EndworkCommandEntry),value); char *value = parsed[i+1];
i++; gtk_entry_set_text(GTK_ENTRY(window->CommandAfterOnceEntry),value);
}else if (strstr(parsed[i],"rotate")){ i++;
char *value = strstr(parsed[i]," ")+1; }else if (strstr(parsed[i],"prerotate")){
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->FileAmountSpin),atol(value)); char *value = parsed[i+1];
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck),1); gtk_entry_set_text(GTK_ENTRY(window->CommandBeforeEntry),value);
}else if (!strcmp(parsed[i],"endscript")){ i++;
}else if (strstr(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->EndworkCommandEntry),value);
i++;
}else if (strstr(parsed[i],"rotate")){
char *value = strstr(parsed[i]," ")+1;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->FileAmountSpin),atol(value));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->FileAmountCheck),1);
}else if (!strcmp(parsed[i],"endscript")){
}
} }
} }
} }
@ -1338,7 +1358,7 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind
} }
void on_logrotate_add(GtkWidget *self, logrotate_window *dialog){ void on_logrotate_add(GtkWidget *self, logrotate_window *dialog){
logrotate_configure_window *window = yon_logrotate_window_new(NULL,NULL); logrotate_configure_window *window = yon_logrotate_window_new(NULL,NULL,NULL);
gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->MainTree))); gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->MainTree)));
gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(dialog->Window)); gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(dialog->Window));
gtk_widget_show(window->MainWindow); gtk_widget_show(window->MainWindow);
@ -1361,9 +1381,9 @@ void on_logrotate_edit(GtkWidget *self, logrotate_window *window){
for (int i=0;i<size;i++){ for (int i=0;i<size;i++){
paths=yon_char_unite(paths ? yon_char_append(paths,","):"",path_parsed[i],NULL); paths=yon_char_unite(paths ? yon_char_append(paths,","):"",path_parsed[i],NULL);
} }
logrotate_configure_window *dialog = yon_logrotate_window_new(paths,window);
gtk_widget_show(dialog->MainWindow);
gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&description,-1); gtk_tree_model_get(model,&iter,0,&name,1,&paths,2,&description,-1);
logrotate_configure_window *dialog = yon_logrotate_window_new(paths,window,name);
gtk_widget_show(dialog->MainWindow);
gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name ? name : ""); gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name ? name : "");
gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description ? description : ""); gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description ? description : "");
gtk_widget_set_can_focus(dialog->LogNameEntry,0); gtk_widget_set_can_focus(dialog->LogNameEntry,0);
@ -1379,7 +1399,7 @@ void on_logrotate_remove(GtkWidget *self, logrotate_window *window){
GtkTreeIter iter; GtkTreeIter iter;
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model, &iter)){ if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model, &iter)){
char *paths; char *paths;
gtk_tree_model_get(model,&iter,1,&paths,-1); gtk_tree_model_get(model,&iter,0,&paths,-1);
gtk_list_store_remove(main_config.logrotate_list,&iter); gtk_list_store_remove(main_config.logrotate_list,&iter);
yon_char_replace(paths,"\n",","); yon_char_replace(paths,"\n",",");
yon_config_remove_by_key(LOGROTATE(paths)); yon_config_remove_by_key(LOGROTATE(paths));
@ -1417,8 +1437,9 @@ void on_logrotate_apps_configure(GtkWidget *self, logrotate_window *window){
gtk_list_store_append(main_config.logrotate_list,&itar); gtk_list_store_append(main_config.logrotate_list,&itar);
settings = yon_char_replace(settings,",\t",","); settings = yon_char_replace(settings,",\t",",");
if (settings[0]==',') yon_char_divide_search(settings,",",-1); 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); gtk_list_store_set(main_config.logrotate_list,&itar,0,name,1,paths,-1);
paths = yon_char_replace(paths,"\n",",");
yon_config_register(LOGROTATE(name),"logging",yon_char_unite(paths,":",settings,NULL));
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),SUCCESS_LABEL,5,BACKGROUND_IMAGE_SUCCESS_TYPE); yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),SUCCESS_LABEL,5,BACKGROUND_IMAGE_SUCCESS_TYPE);
} }
} }
@ -1438,7 +1459,7 @@ void on_log_edit_logrotate_settings(GtkWidget *self, dictionary *dict){
GList *paths = gtk_container_get_children((GtkContainer*)g_list_nth_data(list,i)); 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); 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,NULL); logrotate_configure_window *dialog = yon_logrotate_window_new(pathse,NULL,name);
gtk_widget_show(dialog->MainWindow); gtk_widget_show(dialog->MainWindow);
gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name); gtk_entry_set_text(GTK_ENTRY(dialog->LogNameEntry),name);
gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description); gtk_entry_set_text(GTK_ENTRY(dialog->LogDescriptionEntry),description);
@ -2339,6 +2360,7 @@ void config_init(){
main_config.logrotate_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING); main_config.logrotate_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
main_config.logrotate_apps_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING); main_config.logrotate_apps_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
main_config.remove_thread=-1; main_config.remove_thread=-1;
main_config.load_mode=1;
PolkitSubject *subject = NULL; PolkitSubject *subject = NULL;

Loading…
Cancel
Save