Port to Gtk4

This commit is contained in:
Benjamin Drieu 2022-05-28 22:34:01 +02:00
parent 66f1deed14
commit af32fbefd2
1 changed files with 19 additions and 19 deletions

View File

@ -83,7 +83,6 @@ const prefs = [
function init() {
monitoLog('initializing ${Me.metadata.name} Preferences');
this.settings = ExtensionUtils.getSettings(SETTINGS_SCHEMA);
monitoLog ( 'Foo: ' + Me.metadata );
}
@ -99,7 +98,7 @@ function buildPrefsWidget() {
let mainWidget = new Gtk.Notebook( { } );
let prefsWidget = new Gtk.Grid({
margin: 18,
// margin: 18,
column_spacing: 12,
row_spacing: 12,
column_homogeneous: false,
@ -158,18 +157,20 @@ function buildPrefsWidget() {
// Accounts
this._accountsWidgetContainer = new Gtk.Box( { orientation: Gtk.Orientation.HORIZONTAL,
homogeneous: false, } );
homogeneous: false, } );
mainWidget.append_page ( this._accountsWidgetContainer,
new Gtk.Label ( { label: _('Servers'), } ) );
let accountsChooserContainer = new Gtk.Box( { orientation: Gtk.Orientation.VERTICAL,
homogeneous: false, } );
this._accountsWidgetContainer.pack_start(accountsChooserContainer, true, true, 0);
monitoLog ( 'Box ' + this._accountsWidgetContainer );
monitoLog ( 'Func ' + this._accountsWidgetContainer.pack_start );
this._accountsWidgetContainer.append(accountsChooserContainer, true, true, 0);
this.accountsChooser = new Gtk.ListBox ( { valign: Gtk.Align.FILL,
hexpand: true,
vexpand: true } );
accountsChooserContainer.pack_start(this.accountsChooser, true, true, 0);
accountsChooserContainer.append(this.accountsChooser, true, true, 0);
// Account list
for ( var server_id of this.getServersList ( ) )
@ -178,7 +179,7 @@ function buildPrefsWidget() {
// Action Bar
let accountsChooserActionBar = new Gtk.ActionBar ( { valign: Gtk.Align.END } );
accountsChooserContainer.pack_start(accountsChooserActionBar, true, true, 0);
accountsChooserContainer.append(accountsChooserActionBar, true, true, 0);
let accountCreateButton = Gtk.Button.new_from_icon_name ( 'list-add',
Gtk.IconSize.BUTTON );
@ -192,7 +193,7 @@ function buildPrefsWidget() {
this.createAccountWidgets ( false ) ;
mainVbox.pack_start(mainWidget, true, true, 0);
mainVbox.append(mainWidget, true, true, 0);
mainVbox.show_all();
return mainVbox;
@ -244,7 +245,7 @@ function createAccountWidgets ( isActive )
this.prefWidgets = { };
this._accountsWidget = new Gtk.Notebook( { } );
this._accountsWidgetContainer.pack_start(this._accountsWidget, true, true, 0);
this._accountsWidgetContainer.append(this._accountsWidget, true, true, 0);
for ( var _tab of [ 'Settings', 'Columns', 'Colors', 'Filters', 'Replacements' ] )
{
@ -269,7 +270,7 @@ function createPrefWidgets ( noteBook, type, isActive )
{
let grid = new Gtk.Grid ( {
halign: Gtk.Align.FILL,
margin: 18,
// margin: 18,
column_spacing: 12,
row_spacing: 12,
visible: true,
@ -333,7 +334,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,
@ -353,13 +354,13 @@ function createColumnsPrefTab ( noteBook, type, isActive )
let columnNumbers = new Gtk.TreeViewColumn ( { title: _("Column") } );
let rendererNumbers = new Gtk.CellRendererText ( { editable: true } );
columnNumbers.pack_start(rendererNumbers, true);
columnNumbers.append(rendererNumbers, true);
columnNumbers.add_attribute(rendererNumbers, 'text', 0);
_treeView.append_column(columnNumbers);
let _colSize = new Gtk.TreeViewColumn ( { title: _("Size") } );
let _colRenderer = new Gtk.CellRendererText ( { editable: true } );
_colSize.pack_start(_colRenderer, true);
_colSize.append(_colRenderer, true);
_colSize.add_attribute(_colRenderer, 'text', 1);
_treeView.append_column(_colSize);
@ -438,17 +439,16 @@ function addAccountLine ( server_id )
monitoLog ( '> Add line ' + server_id );
let _account_settings = getAccountSettings ( server_id );
let row = new Gtk.ListBoxRow ( { hexpand: true,
halign: Gtk.Align.FILL } );
halign: Gtk.Align.FILL } );
row.server = server_id;
let _label = new Gtk.Label ( { label: _account_settings.get_string('name'),
hexpand: true,
margin: 5,
halign: Gtk.Align.START,
expand: true } );
row.add ( _label );
this.accountsChooser.add ( row );
this.accountsChooser.show_all();
// margin: 5,
halign: Gtk.Align.START } );
row.set_child ( _label );
this.accountsChooser.append ( row );
this.accountsChooser.show_all(); // XXX Does not work in gtk4 ?
}