Improve columns display

This commit is contained in:
Benjamin Drieu 2023-03-29 08:29:00 +02:00 committed by Benjamin Drieu
parent 6e83fc331b
commit 65771792d3
1 changed files with 23 additions and 10 deletions

View File

@ -53,7 +53,7 @@ const column_definitions = {
next_check: { label: _('Next check'), width: 200, expand: false, type: 'date' },
last_state_change: { label: _('Last state changed'), width: 200, expand: false, type: 'date' },
attempts: { label: _('Attempts'), width: 50, expand: false, },
status_information: { label: _('Information'), width: 600, expand: false, },
status_information: { label: _('Test result'), width: 600, expand: false, },
output: { label: _('Output'), width: 600, expand: false, },
actions: { label: 'Actions', width: 50, expand: false, special: 'actions' },
};
@ -100,7 +100,7 @@ function init() {
this.settings = ExtensionUtils.getSettings(SETTINGS_SCHEMA);
this.gtkVersion = Gtk.get_major_version();
monitoLog ( 'GTK version is ' + this.gtkVersion );
// monitoLog ( 'GTK version is ' + this.gtkVersion );
}
@ -377,7 +377,7 @@ function createColumnsPrefTab ( noteBook, type, isActive )
{
let grid = new Gtk.Grid ( {
halign: Gtk.Align.FILL,
// margin: 18,
margin: 18,
column_spacing: 12,
row_spacing: 12,
visible: true,
@ -395,13 +395,10 @@ function createColumnsPrefTab ( noteBook, type, isActive )
let columnNumbers = new Gtk.TreeViewColumn ( { title: _("Column") } );
this.ColumnNameRenderer = new Gtk.CellRendererCombo ( { editable: true,
has_entry: false,
text_column: 1 } );
text_column: 0 } );
this.ColumnNameRenderer.connect("edited", onComboChanged)
this.ColumnNameRenderer.col = 0;
if ( this.gtkVersion == 4 )
columnNumbers.pack_start(this.ColumnNameRenderer, true);
else
columnNumbers.append(this.ColumnNameRenderer, true);
columnNumbers.pack_start(this.ColumnNameRenderer, true);
columnNumbers.add_attribute(this.ColumnNameRenderer, 'text', 0);
this.treeView.append_column(columnNumbers);
this.ColumnNameRenderer.connect('edited', Lang.bind ( this, this.editColumn ) );
@ -482,7 +479,7 @@ function activateAccountRow ( ) {
for ( var i in _columns )
{
let _iter = this.store.append();
this.store.set_value(_iter, 0, _columns [ i ] );
this.store.set_value(_iter, 0, getEntryLabel ( _columns [ i ] ) );
this.store.set_value(_iter, 1, parseInt(_columnsSizes [ i ]) );
}
@ -642,6 +639,21 @@ function removeColumnRow ( widget ) {
}
function getEntryName ( text )
{
for ( let [ _colName, _colDef ] of Object.entries(column_definitions) )
if ( _colDef.label == text )
return _colName;
return 'N/A';
}
function getEntryLabel ( text )
{
return column_definitions[text].label;
}
function editColumn ( widget, path, text )
{
let _row = this.accountsChooser.get_selected_row();
@ -656,7 +668,8 @@ function editColumn ( widget, path, text )
}
else
{
this.store.set_value(_iter[1], widget.col, text );
this.store.set_value ( _iter[1], widget.col, text );
text = getEntryName ( text );
prefKey = 'columns';
}