cleanup: Port GObject classes to JS6 classes

GJS added API for defining GObject classes with ES6 class syntax
last cycle, use it to port the remaining Lang.Class classes to
the new syntax.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
This commit is contained in:
Florian Müllner
2017-10-31 02:23:39 +01:00
committed by Georges Basile Stavracas Neto
parent bacfdbbb03
commit e68dfed1f7
43 changed files with 1036 additions and 1235 deletions

View File

@ -1,4 +1,3 @@
const Lang = imports.lang;
const Gettext = imports.gettext;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
@ -240,24 +239,20 @@ var Application = class {
}
};
var DescriptionLabel = new Lang.Class({
Name: 'DescriptionLabel',
Extends: Gtk.Label,
var DescriptionLabel = GObject.registerClass(
class DescriptionLabel extends Gtk.Label {
vfunc_get_preferred_height_for_width(width) {
// Hack: Request the maximum height allowed by the line limit
if (this.lines > 0)
return this.parent(0);
return this.parent(width);
return super.vfunc_get_preferred_height_for_width(0);
return super.vfunc_get_preferred_height_for_width(width);
}
});
var ExtensionRow = new Lang.Class({
Name: 'ExtensionRow',
Extends: Gtk.ListBoxRow,
var ExtensionRow = GObject.registerClass(
class ExtensionRow extends Gtk.ListBoxRow {
_init(uuid) {
this.parent();
super._init();
this.uuid = uuid;
@ -275,7 +270,7 @@ var ExtensionRow = new Lang.Class({
});
this._buildUI();
},
}
_buildUI() {
let extension = ExtensionUtils.extensions[this.uuid];
@ -322,7 +317,7 @@ var ExtensionRow = new Lang.Class({
});
this._switch.connect('state-set', () => true);
hbox.add(this._switch);
},
}
_canEnable() {
let extension = ExtensionUtils.extensions[this.uuid];
@ -330,12 +325,12 @@ var ExtensionRow = new Lang.Class({
return !this._settings.get_boolean('disable-user-extensions') &&
!(checkVersion && ExtensionUtils.isOutOfDate(extension));
},
}
_isEnabled() {
let extensions = this._settings.get_strv('enabled-extensions');
return extensions.indexOf(this.uuid) != -1;
},
}
_enable() {
let extensions = this._settings.get_strv('enabled-extensions');
@ -344,7 +339,7 @@ var ExtensionRow = new Lang.Class({
extensions.push(this.uuid);
this._settings.set_strv('enabled-extensions', extensions);
},
}
_disable() {
let extensions = this._settings.get_strv('enabled-extensions');