cleanup: Port non-GObject classes to JS6 classes
ES6 finally adds standard class syntax to the language, so we can replace our custom Lang.Class framework with the new syntax. Any classes that inherit from GObject will need special treatment, so limit the port to regular javascript classes for now. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
This commit is contained in:

committed by
Georges Basile Stavracas Neto

parent
99ce3deeb0
commit
bacfdbbb03
@ -1,4 +1,3 @@
|
||||
|
||||
const Lang = imports.lang;
|
||||
const Gettext = imports.gettext;
|
||||
const GLib = imports.gi.GLib;
|
||||
@ -24,9 +23,8 @@ function stripPrefix(string, prefix) {
|
||||
return string;
|
||||
}
|
||||
|
||||
var Application = new Lang.Class({
|
||||
Name: 'Application',
|
||||
_init() {
|
||||
var Application = class {
|
||||
constructor() {
|
||||
GLib.set_prgname('gnome-shell-extension-prefs');
|
||||
this.application = new Gtk.Application({
|
||||
application_id: 'org.gnome.shell.ExtensionPrefs',
|
||||
@ -42,7 +40,7 @@ var Application = new Lang.Class({
|
||||
this._startupUuid = null;
|
||||
this._loaded = false;
|
||||
this._skipMainWindow = false;
|
||||
},
|
||||
}
|
||||
|
||||
_extensionAvailable(uuid) {
|
||||
let extension = ExtensionUtils.extensions[uuid];
|
||||
@ -54,7 +52,7 @@ var Application = new Lang.Class({
|
||||
return false;
|
||||
|
||||
return true;
|
||||
},
|
||||
}
|
||||
|
||||
_getExtensionPrefsModule(extension) {
|
||||
let uuid = extension.metadata.uuid;
|
||||
@ -69,7 +67,7 @@ var Application = new Lang.Class({
|
||||
|
||||
this._extensionPrefsModules[uuid] = prefsModule;
|
||||
return prefsModule;
|
||||
},
|
||||
}
|
||||
|
||||
_selectExtension(uuid) {
|
||||
if (!this._extensionAvailable(uuid))
|
||||
@ -104,7 +102,7 @@ var Application = new Lang.Class({
|
||||
dialog.set_default_size(600, 400);
|
||||
dialog.add(widget);
|
||||
dialog.show();
|
||||
},
|
||||
}
|
||||
|
||||
_buildErrorUI(extension, exc) {
|
||||
let box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
|
||||
@ -130,7 +128,7 @@ var Application = new Lang.Class({
|
||||
|
||||
box.show_all();
|
||||
return box;
|
||||
},
|
||||
}
|
||||
|
||||
_buildUI(app) {
|
||||
this._window = new Gtk.ApplicationWindow({ application: app,
|
||||
@ -167,13 +165,13 @@ var Application = new Lang.Class({
|
||||
});
|
||||
|
||||
this._window.show_all();
|
||||
},
|
||||
}
|
||||
|
||||
_sortList(row1, row2) {
|
||||
let name1 = ExtensionUtils.extensions[row1.uuid].metadata.name;
|
||||
let name2 = ExtensionUtils.extensions[row2.uuid].metadata.name;
|
||||
return name1.localeCompare(name2);
|
||||
},
|
||||
}
|
||||
|
||||
_updateHeader(row, before) {
|
||||
if (!before || row.get_header())
|
||||
@ -181,14 +179,14 @@ var Application = new Lang.Class({
|
||||
|
||||
let sep = new Gtk.Separator({ orientation: Gtk.Orientation.HORIZONTAL });
|
||||
row.set_header(sep);
|
||||
},
|
||||
}
|
||||
|
||||
_scanExtensions() {
|
||||
let finder = new ExtensionUtils.ExtensionFinder();
|
||||
finder.connect('extension-found', this._extensionFound.bind(this));
|
||||
finder.scanExtensions();
|
||||
this._extensionsLoaded();
|
||||
},
|
||||
}
|
||||
|
||||
_extensionFound(finder, extension) {
|
||||
let row = new ExtensionRow(extension.uuid);
|
||||
@ -200,7 +198,7 @@ var Application = new Lang.Class({
|
||||
|
||||
row.show_all();
|
||||
this._extensionSelector.add(row);
|
||||
},
|
||||
}
|
||||
|
||||
_extensionsLoaded() {
|
||||
if (this._startupUuid && this._extensionAvailable(this._startupUuid))
|
||||
@ -208,16 +206,16 @@ var Application = new Lang.Class({
|
||||
this._startupUuid = null;
|
||||
this._skipMainWindow = false;
|
||||
this._loaded = true;
|
||||
},
|
||||
}
|
||||
|
||||
_onActivate() {
|
||||
this._window.present();
|
||||
},
|
||||
}
|
||||
|
||||
_onStartup(app) {
|
||||
this._buildUI(app);
|
||||
this._scanExtensions();
|
||||
},
|
||||
}
|
||||
|
||||
_onCommandLine(app, commandLine) {
|
||||
app.activate();
|
||||
@ -240,7 +238,7 @@ var Application = new Lang.Class({
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var DescriptionLabel = new Lang.Class({
|
||||
Name: 'DescriptionLabel',
|
||||
|
Reference in New Issue
Block a user