extensionPrefs: Inherit from Gtk.Application
Extension preferences Application class is just a container for a GtkApplication so instead of using composition we can inherit from the base GObject class. Also replace signal connections with vfunc's. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/631
This commit is contained in:
parent
08464eadff
commit
b82b553b9e
@ -17,18 +17,16 @@ function stripPrefix(string, prefix) {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
var Application = class {
|
var Application = GObject.registerClass({
|
||||||
constructor() {
|
GTypeName: 'ExtensionPrefs_Application'
|
||||||
|
}, class Application extends Gtk.Application {
|
||||||
|
_init() {
|
||||||
GLib.set_prgname('gnome-shell-extension-prefs');
|
GLib.set_prgname('gnome-shell-extension-prefs');
|
||||||
this.application = new Gtk.Application({
|
super._init({
|
||||||
application_id: 'org.gnome.shell.ExtensionPrefs',
|
application_id: 'org.gnome.shell.ExtensionPrefs',
|
||||||
flags: Gio.ApplicationFlags.HANDLES_COMMAND_LINE
|
flags: Gio.ApplicationFlags.HANDLES_COMMAND_LINE
|
||||||
});
|
});
|
||||||
|
|
||||||
this.application.connect('activate', this._onActivate.bind(this));
|
|
||||||
this.application.connect('command-line', this._onCommandLine.bind(this));
|
|
||||||
this.application.connect('startup', this._onStartup.bind(this));
|
|
||||||
|
|
||||||
this._extensionPrefsModules = {};
|
this._extensionPrefsModules = {};
|
||||||
|
|
||||||
this._startupUuid = null;
|
this._startupUuid = null;
|
||||||
@ -84,7 +82,7 @@ var Application = class {
|
|||||||
visible: true }));
|
visible: true }));
|
||||||
|
|
||||||
if (this._skipMainWindow) {
|
if (this._skipMainWindow) {
|
||||||
this.application.add_window(dialog);
|
this.add_window(dialog);
|
||||||
if (this._window)
|
if (this._window)
|
||||||
this._window.destroy();
|
this._window.destroy();
|
||||||
this._window = dialog;
|
this._window = dialog;
|
||||||
@ -213,8 +211,8 @@ var Application = class {
|
|||||||
return scroll;
|
return scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildUI(app) {
|
_buildUI() {
|
||||||
this._window = new Gtk.ApplicationWindow({ application: app,
|
this._window = new Gtk.ApplicationWindow({ application: this,
|
||||||
window_position: Gtk.WindowPosition.CENTER });
|
window_position: Gtk.WindowPosition.CENTER });
|
||||||
|
|
||||||
this._window.set_default_size(800, 500);
|
this._window.set_default_size(800, 500);
|
||||||
@ -302,17 +300,19 @@ var Application = class {
|
|||||||
this._loaded = true;
|
this._loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onActivate() {
|
vfunc_activate() {
|
||||||
this._window.present();
|
this._window.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
_onStartup(app) {
|
vfunc_startup() {
|
||||||
this._buildUI(app);
|
super.vfunc_startup();
|
||||||
|
|
||||||
|
this._buildUI();
|
||||||
this._scanExtensions();
|
this._scanExtensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
_onCommandLine(app, commandLine) {
|
vfunc_command_line(commandLine) {
|
||||||
app.activate();
|
this.activate();
|
||||||
let args = commandLine.get_arguments();
|
let args = commandLine.get_arguments();
|
||||||
|
|
||||||
if (args.length) {
|
if (args.length) {
|
||||||
@ -332,7 +332,7 @@ var Application = class {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
var Expander = GObject.registerClass({
|
var Expander = GObject.registerClass({
|
||||||
Properties: {
|
Properties: {
|
||||||
@ -638,6 +638,5 @@ function main(argv) {
|
|||||||
Gettext.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
|
Gettext.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
|
||||||
Gettext.textdomain(Config.GETTEXT_PACKAGE);
|
Gettext.textdomain(Config.GETTEXT_PACKAGE);
|
||||||
|
|
||||||
let app = new Application();
|
new Application().run(argv);
|
||||||
app.application.run(argv);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user