Separate tab for each log file

pull/62/head
parent 35b44744ab
commit 325e891bba

@ -10,6 +10,7 @@
<file>ubl-settings-logging-rules.glade</file>
<file>ubl-settings-logging-filechooser.glade</file>
<file>ubl-settings-logging-logrotate-table.glade</file>
<file>ubl-settings-logging-terminal.glade</file>
</gresource>
<gresource prefix="/com/ublinux/css">
<file>ubl-settings-logging.css</file>

@ -49,6 +49,7 @@ set(DEPENDFILES
../ubl-settings-logging-logrotate.glade
../ubl-settings-logging-logrotate-table.glade
../ubl-settings-logging-filechooser.glade
../ubl-settings-logging-terminal.glade
../gresource.xml
../ubl-settings-logging-banner.png
../ubl-settings-logging.css

@ -237,66 +237,93 @@ void on_inspector_update(GtkWidget *self, inspector_window *window){
GtkTextIter titer,titerend;
config_str output;
if (!strcmp(window->journal_name,"journald")){
GtkWidget *terminal = (GtkWidget*)window->terminals->first->data;
if (self==window->UpdateButton){
switch(window->last_mode){
case 0:
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_output_command,NULL,NULL);
break;
case 1:
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_since_boot_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_output_since_boot_command,NULL,NULL);
break;
case 2:
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_followed_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_output_followed_command,NULL,NULL);
break;
case 3:
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_kernel_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_output_kernel_command,NULL,NULL);
break;
case 4:
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_prioritied_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_output_prioritied_command,NULL,NULL);
break;
case 5:
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_all_boots_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_all_boots_command,NULL,NULL);
break;
case 6:
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_all_units_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_all_units_command,NULL,NULL);
break;
case 7:
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_init_tree_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_init_tree_command,NULL,NULL);
break;
}
}
if (self==window->ShowSinceBootButton){
window->last_mode=1;
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_since_boot_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_output_since_boot_command,NULL,NULL);
}
if (self==window->NewMessagesButton){
window->last_mode=2;
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_followed_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_output_followed_command,NULL,NULL);
}
if (self==window->ShowKernelButton){
window->last_mode=3;
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_kernel_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_output_kernel_command,NULL,NULL);
}
if (self==window->ShowPriorityButton){
window->last_mode=4;
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_output_prioritied_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_output_prioritied_command,NULL,NULL);
}
if (self==window->ShowAllBootsButton){
window->last_mode=5;
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_all_boots_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_all_boots_command,NULL,NULL);
}
if (self==window->ShowAllUnitsButton){
window->last_mode=6;
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_all_units_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_all_units_command,NULL,NULL);
}
if (self==window->ShowInitTreeButton){
window->last_mode=7;
yon_terminal_integrated_start(window->LoggingTerminal, get_journal_init_tree_command,NULL,NULL);
yon_terminal_integrated_start(terminal, get_journal_init_tree_command,NULL,NULL);
}
} else {
window->journal_paths = yon_char_replace(window->journal_paths,"\n"," ");
yon_terminal_integrated_start(window->LoggingTerminal,yon_char_unite("cat ",window->journal_paths,NULL),NULL,NULL);
if (window->terminals){
dictionary *dict=NULL;
for_dictionaries (dict,window->terminals){
GtkWidget *terminal = (GtkWidget*)dict->data;
// window->journal_paths = yon_char_replace(window->journal_paths,"\n"," ");
yon_terminal_integrated_start(terminal,yon_char_unite("cat ",dict->key,NULL),NULL,NULL);
}
}
}
}
GtkWidget *yon_inspector_add_terminal(inspector_window *window,char *page_name){
GtkBuilder *builder = gtk_builder_new_from_resource(glade_terminal_path);
GtkWidget *box = yon_gtk_builder_get_widget(builder,"TerminalBox");
GtkWidget *terminal = yon_gtk_builder_get_widget(builder,"LoggingTerminal");
GtkWidget *label = gtk_label_new(page_name);
gtk_notebook_append_page(GTK_NOTEBOOK(window->LoggingNotebook),box,label);
GdkRGBA rgba;
rgba.alpha=1;
rgba.red=0.95;
rgba.green=0.95;
rgba.blue=0.95;
vte_terminal_set_color_background(VTE_TERMINAL(terminal),&rgba);
rgba.red=0;
rgba.green=0;
rgba.blue=0;
vte_terminal_set_color_foreground(VTE_TERMINAL(terminal),&rgba);
return terminal;
}
void on_inspector_open(GtkWidget *self, main_window *widgets){
@ -310,8 +337,8 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){
window->ShowAllBootsButton=yon_gtk_builder_get_widget(builder,"ShowAllBootsButton");
window->ShowAllUnitsButton=yon_gtk_builder_get_widget(builder,"ShowAllUnitsButton");
window->ShowInitTreeButton=yon_gtk_builder_get_widget(builder,"ShowInitTreeButton");
window->LoggingNotebook=yon_gtk_builder_get_widget(builder,"MainNotebook");
window->UpdateButton=yon_gtk_builder_get_widget(builder,"UpdateButton");
window->LoggingTerminal=yon_gtk_builder_get_widget(builder,"LoggingTerminal");
window->JournalActionsBox=yon_gtk_builder_get_widget(builder,"JournalActionsBox");
yon_window_config_custom_window_setup(GTK_WINDOW(window->MainWindow),"InspectorWindow");
gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL);
@ -320,16 +347,6 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){
GtkTreeIter iter;
char *name;
char *paths;
GdkRGBA rgba;
rgba.alpha=1;
rgba.red=0.95;
rgba.green=0.95;
rgba.blue=0.95;
vte_terminal_set_color_background(VTE_TERMINAL(window->LoggingTerminal),&rgba);
rgba.red=0;
rgba.green=0;
rgba.blue=0;
vte_terminal_set_color_foreground(VTE_TERMINAL(window->LoggingTerminal),&rgba);
g_signal_connect(G_OBJECT(window->UpdateButton),"clicked", G_CALLBACK(on_inspector_update),window);
g_signal_connect(G_OBJECT(window->ShowKernelButton),"clicked", G_CALLBACK(on_inspector_update),window);
g_signal_connect(G_OBJECT(window->NewMessagesButton),"clicked", G_CALLBACK(on_inspector_update),window);
@ -341,14 +358,21 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){
gtk_tree_model_get(model,&iter,0,&name,1,&paths,-1);
window->journal_name=name;
window->journal_paths=yon_char_parse(paths,&window->journal_size,"\n");
window->terminals = NULL;
if (strcmp(name,"journald")){
window->last_mode=-1;
for (int i=0;i<window->journal_size;i++){
if (!access(window->journal_paths[i],F_OK)||!window->terminals)
yon_dictionary_add_or_create_if_exists_with_data(window->terminals,window->journal_paths[i],yon_inspector_add_terminal(window,window->journal_paths[i]));
}
gtk_widget_hide(window->JournalActionsBox);
} else {
window->last_mode=0;
yon_dictionary_add_or_create_if_exists_with_data(window->terminals,"Journald",yon_inspector_add_terminal(window,"Journald"));
}
window->journal_name=name;
window->journal_paths=paths;
on_inspector_update(window->UpdateButton,window);
gtk_widget_show(window->MainWindow);
}

@ -31,6 +31,7 @@
#define glade_logrotate_table_path "/com/ublinux/ui/ubl-settings-logging-logrotate-table.glade"
#define glade_rules_path "/com/ublinux/ui/ubl-settings-logging-rules.glade"
#define glade_filechooser_path "/com/ublinux/ui/ubl-settings-logging-filechooser.glade"
#define glade_terminal_path "/com/ublinux/ui/ubl-settings-logging-terminal.glade"
#define banner_path "/com/ublinux/images/ubl-settings-logging-banner.png"
#define CssPath "/com/ublinux/css/ubl-settings-logging.css"
#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL)
@ -197,11 +198,13 @@ GtkWidget *UpdateButton;
GtkWidget *ShowAllBootsButton;
GtkWidget *ShowAllUnitsButton;
GtkWidget *ShowInitTreeButton;
GtkWidget *LoggingTerminal;
GtkWidget *LoggingNotebook;
GtkWidget *JournalActionsBox;
dictionary *terminals;
int last_mode;
char *journal_name;
char *journal_paths;
int journal_size;
config_str journal_paths;
} inspector_window;

@ -716,11 +716,9 @@ char **yon_char_parse(char *parameters, int *size, char *divider){
string[(*size)]=yon_char_divide(paramline,strlen(paramline)-strlen(param));
*size=(*size)+1;
}
if (string){
string = yon_remalloc(string,sizeof(char*)*((*size)+1));
string[(*size)]=paramline;
(*size)+=1;
}
return string;
}

@ -2,7 +2,6 @@
<!-- Generated with glade 3.38.2 -->
<interface domain="ubl-settings-logging">
<requires lib="gtk+" version="3.24"/>
<requires lib="vte-2.91" version="0.68"/>
<!-- interface-css-provider-path ubl-settings-logging.css -->
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">100</property>
@ -14,11 +13,6 @@
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment3">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -242,16 +236,10 @@
</packing>
</child>
<child>
<object class="VteTerminal" id="LoggingTerminal">
<object class="GtkNotebook" id="MainNotebook">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hscroll-policy">natural</property>
<property name="vadjustment">adjustment3</property>
<property name="vscroll-policy">natural</property>
<property name="encoding">UTF-8</property>
<property name="scrollback-lines">0</property>
<property name="scroll-on-keystroke">True</property>
<property name="scroll-on-output">False</property>
<property name="can-focus">True</property>
<property name="scrollable">True</property>
</object>
<packing>
<property name="expand">True</property>
@ -259,19 +247,6 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScrollbar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="adjustment">adjustment3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
@ -321,5 +296,4 @@
</object>
</child>
</object>
<object class="GtkTextBuffer" id="textbuffer1"/>
</interface>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface domain="ubl-settings-logging">
<requires lib="gtk+" version="3.24"/>
<requires lib="vte-2.91" version="0.68"/>
<object class="GtkBox" id="TerminalBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="VteTerminal" id="LoggingTerminal">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hscroll-policy">natural</property>
<property name="vscroll-policy">natural</property>
<property name="encoding">UTF-8</property>
<property name="scrollback-lines">0</property>
<property name="scroll-on-keystroke">True</property>
<property name="scroll-on-output">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrollbar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<object class="GtkAdjustment" id="adjustment3">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
</interface>
Loading…
Cancel
Save