Fixed rules entry

pull/129/head
Ivan Yartsev 6 months ago
parent 52e8c8edc7
commit 219a2782b3

@ -1370,6 +1370,26 @@ void on_logrotate_save(GtkWidget *, dictionary *dict){
} }
} }
void on_rules_changed(GtkEditable *editable, const gchar *text, gint length, gint *position){
gchar *new_text = g_new(gchar, length + 1);
gint i, j = 0;
for (i = 0; i < length; i++) {
if (text[i]>'0'&&text[i]<'7') {
new_text[j] = text[i];
j++;
}
}
if (j < length) {
g_signal_handlers_block_by_func(editable, G_CALLBACK(on_rules_changed), NULL);
gtk_editable_insert_text(editable, new_text, j, position);
g_signal_handlers_unblock_by_func(editable, G_CALLBACK(on_rules_changed), NULL);
g_signal_stop_emission_by_name(editable, "insert-text");
}
g_free(new_text);
}
logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_window *dialog, char *log_name){ 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);
@ -1435,6 +1455,7 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind
window->CommandAfterEntry=yon_gtk_builder_get_widget(builder,"CommandAfterEntry"); window->CommandAfterEntry=yon_gtk_builder_get_widget(builder,"CommandAfterEntry");
window->EndworkCommandEntry=yon_gtk_builder_get_widget(builder,"EndworkCommandEntry"); window->EndworkCommandEntry=yon_gtk_builder_get_widget(builder,"EndworkCommandEntry");
window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox"); window->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox");
g_signal_connect(G_OBJECT(window->CreateLogEntry),"insert-text",G_CALLBACK(on_rules_changed),NULL);
gtk_window_set_title(GTK_WINDOW(window->MainWindow),LOGROTATE_TITLE_LABEL); gtk_window_set_title(GTK_WINDOW(window->MainWindow),LOGROTATE_TITLE_LABEL);
if (dialog) if (dialog)
@ -1463,6 +1484,12 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind
} }
yon_entry_set_entry_type(GTK_ENTRY(window->EmailEntry),GTK_BOX(window->StatusBox)); yon_entry_set_entry_type(GTK_ENTRY(window->EmailEntry),GTK_BOX(window->StatusBox));
yon_entry_set_entry_type(GTK_ENTRY(window->FileAmountEntry),GTK_BOX(window->StatusBox));
yon_entry_set_entry_type(GTK_ENTRY(window->CommandBeforeOnceEntry),GTK_BOX(window->StatusBox));
yon_entry_set_entry_type(GTK_ENTRY(window->CommandAfterOnceEntry),GTK_BOX(window->StatusBox));
yon_entry_set_entry_type(GTK_ENTRY(window->CommandBeforeEntry),GTK_BOX(window->StatusBox));
yon_entry_set_entry_type(GTK_ENTRY(window->CommandAfterEntry),GTK_BOX(window->StatusBox));
yon_entry_set_entry_type(GTK_ENTRY(window->EndworkCommandEntry),GTK_BOX(window->StatusBox));
dictionary *dict=NULL; 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,"dialog",dialog);
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);

@ -457,4 +457,5 @@ void yon_main_window_complete(template_main_window **window);
void on_logrotate_apps_configure_activate(GtkWidget *, GtkTreePath*, GtkTreeViewColumn*,logrotate_window *window); void on_logrotate_apps_configure_activate(GtkWidget *, GtkTreePath*, GtkTreeViewColumn*,logrotate_window *window);
void on_logrotate_edit_activate(GtkWidget*,GtkTreePath*,GtkTreeViewColumn*, logrotate_window *window); void on_logrotate_edit_activate(GtkWidget*,GtkTreePath*,GtkTreeViewColumn*, logrotate_window *window);
void on_logrotate_closed(GtkWidget *,logrotate_window *window); void on_logrotate_closed(GtkWidget *,logrotate_window *window);
void on_rules_changed(GtkEditable *editable, const gchar *text, gint length, gint *position);
int main(int argc, char *argv[]); int main(int argc, char *argv[]);

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 --> <!-- Generated with glade 3.38.2 -->
<interface domain="ubl-settings-logging"> <interface domain="ubl-settings-logging">
<requires lib="gtk+" version="3.24"/> <requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path ubl-settings-logging.css --> <!-- interface-css-provider-path ubl-settings-logging.css -->
@ -1233,6 +1233,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property> <property name="sensitive">False</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="max-length">3</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

Loading…
Cancel
Save