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

@ -2,7 +2,6 @@ const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
@ -16,41 +15,39 @@ const APP_WHITELIST = ['gnome-control-center.desktop'];
var DialogResponse = Meta.InhibitShortcutsDialogResponse;
var InhibitShortcutsDialog = new Lang.Class({
Name: 'InhibitShortcutsDialog',
Extends: GObject.Object,
var InhibitShortcutsDialog = GObject.registerClass({
Implements: [Meta.InhibitShortcutsDialog],
Properties: {
'window': GObject.ParamSpec.override('window', Meta.InhibitShortcutsDialog)
},
}
}, class InhibitShortcutsDialog extends GObject.Object {
_init(window) {
this.parent();
super._init();
this._window = window;
this._dialog = new ModalDialog.ModalDialog();
this._buildLayout();
},
}
get window() {
return this._window;
},
}
set window(window) {
this._window = window;
},
}
get _app() {
let windowTracker = Shell.WindowTracker.get_default();
return windowTracker.get_window_app(this._window);
},
}
_getRestoreAccel() {
let settings = new Gio.Settings({ schema_id: WAYLAND_KEYBINDINGS_SCHEMA });
let accel = settings.get_strv('restore-shortcuts')[0] || '';
return Gtk.accelerator_get_label.apply(null,
Gtk.accelerator_parse(accel));
},
}
_buildLayout() {
let name = this._app ? this._app.get_name() : this._window.title;
@ -82,19 +79,19 @@ var InhibitShortcutsDialog = new Lang.Class({
this._emitResponse(DialogResponse.ALLOW);
},
default: true });
},
}
_emitResponse(response) {
this.emit('response', response);
this._dialog.close();
},
}
vfunc_show() {
if (this._app && APP_WHITELIST.indexOf(this._app.get_id()) != -1)
this._emitResponse(DialogResponse.ALLOW);
else
this._dialog.open();
},
}
vfunc_hide() {
this._dialog.close();