Fixed journald shrink size buttons

pull/139/head
Ivan Yartsev 4 months ago
parent 2875b20e95
commit fce46dbf3c

@ -2117,10 +2117,45 @@ void on_journald_save(GtkWidget *, journald_window *window){
on_subwindow_close(window->MainWindow);
}
void on_journald_size_lower_size(GtkWidget *, journald_window *window){
long time_long = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LowerSizeEntry));
if (time_long){
char *time = yon_char_from_long(time_long);
char *time_mod = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->LowerSizeCombo));
char *time_full = yon_char_append(time,time_mod);
if (!system(journald_lower_size_command(time_full))){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(SUCCESS_LABEL),5,BACKGROUND_IMAGE_SUCCESS_TYPE);
} else {
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_SUCCESS_TYPE);
}
} else {
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_SUCCESS_TYPE);
yon_ubl_status_highlight_incorrect(window->LowerSizeEntry);
}
}
void on_journald_size_lower_time(GtkWidget *, journald_window *window){
long time_long = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->LowerTimeEntry));
if (time_long){
char *time = yon_char_from_long(time_long);
char *time_mod = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->LowerTimeCombo));
char *time_full = yon_char_append(time,time_mod);
if (!system(journald_lower_time_command(time_full))){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(SUCCESS_LABEL),5,BACKGROUND_IMAGE_SUCCESS_TYPE);
} else {
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_SUCCESS_TYPE);
}
} else {
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_SUCCESS_TYPE);
yon_ubl_status_highlight_incorrect(window->LowerTimeEntry);
}
}
journald_window *yon_journald_open(GtkWidget *, 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->StatusBox=yon_gtk_builder_get_widget(builder,"StatusBox");
window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton");
window->SaveButton=yon_gtk_builder_get_widget(builder,"SaveButton");
window->ResetButton=yon_gtk_builder_get_widget(builder,"ResetButton");
@ -2170,6 +2205,9 @@ journald_window *yon_journald_open(GtkWidget *, main_window *widgets){
}
gtk_window_set_title(GTK_WINDOW(window->MainWindow),JOURNALD_TITLE_LABEL);
g_signal_connect(G_OBJECT(window->LowerSizeButton),"clicked",G_CALLBACK(on_journald_size_lower_size),window);
g_signal_connect(G_OBJECT(window->LowerTimeButton),"clicked",G_CALLBACK(on_journald_size_lower_time),window);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_journald_save),window);
g_signal_connect(G_OBJECT(window->ResetButton),"clicked",G_CALLBACK(on_journald_reset),window);

@ -74,6 +74,9 @@
#define get_file_folder_size(path) yon_char_append("du -hsc ",path)
#define get_all_files_in_path(path) yon_char_append("find ",path)
#define journald_lower_size_command(new_size) yon_char_append("journalctl --rotate; journalctl --vacuum-size=",new_size)
#define journald_lower_time_command(new_time) yon_char_append("journalctl --rotate; journalctl --vacuum-time=",new_time)
#define group_list_path "/etc/group"
#define edit_icon_name "document-edit-symbolic"
@ -257,6 +260,7 @@ typedef struct {
typedef struct {
GtkWidget *MainWindow;
GtkWidget *StatusBox;
GtkWidget *CancelButton;
GtkWidget *SaveButton;
GtkWidget *ResetButton;
@ -433,6 +437,8 @@ void on_logrotate_tab_open(GtkWidget *self, main_window *widgets);
void yon_combo_compress_check(GtkComboBox *self, journald_window *window);
void on_journald_reset(GtkWidget *self, journald_window *window);
void on_journald_save(GtkWidget *self, journald_window *window);
void on_journald_size_lower_size(GtkWidget *, journald_window *window);
void on_journald_size_lower_time(GtkWidget *, journald_window *window);
journald_window *yon_journald_open(GtkWidget *self, main_window *widgets);
void on_journald_open(GtkWidget *self, main_window *widgets);
void on_log_save(GtkWidget *self, dictionary *dict);

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<!-- Generated with glade 3.38.2 -->
<interface domain="ubl-settings-logging">
<requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path ubl-settings-logging.css -->
@ -97,10 +97,23 @@
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkBox" id="StatusBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
@ -837,9 +850,9 @@
<property name="can-focus">False</property>
<property name="active">0</property>
<items>
<item translatable="yes">Kb</item>
<item translatable="yes">Mb</item>
<item translatable="yes">Gb</item>
<item id="K" translatable="yes">Kb</item>
<item id="M" translatable="yes">Mb</item>
<item id="G" translatable="yes">Gb</item>
</items>
</object>
<packing>
@ -905,11 +918,11 @@
<property name="can-focus">False</property>
<property name="active">0</property>
<items>
<item translatable="yes">Minutes</item>
<item translatable="yes">Hours</item>
<item translatable="yes">Days</item>
<item translatable="yes">Weeks</item>
<item translatable="yes">Years</item>
<item id="minutes" translatable="yes">Minutes</item>
<item id="hours" translatable="yes">Hours</item>
<item id="days" translatable="yes">Days</item>
<item id="weeks" translatable="yes">Weeks</item>
<item id="years" translatable="yes">Years</item>
</items>
</object>
<packing>
@ -961,7 +974,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
</object>

Loading…
Cancel
Save