extensionPrefs: Skip main window when launched with a UUID
The extension-prefs tool is used by gnome-tweak-tool and the extensions web site to display preferences. However as those already implement their own extension lists, the main window is not useful in that context (to not say it is rather silly). Just skip the main window and only show the specified extension's preference dialog in those cases. https://bugzilla.gnome.org/show_bug.cgi?id=730829
This commit is contained in:
parent
521f5f2b6b
commit
5b3fb024be
@ -52,6 +52,8 @@ const Application = new Lang.Class({
|
|||||||
this._extensionPrefsModules = {};
|
this._extensionPrefsModules = {};
|
||||||
|
|
||||||
this._startupUuid = null;
|
this._startupUuid = null;
|
||||||
|
this._loaded = false;
|
||||||
|
this._skipMainWindow = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
_extensionAvailable: function(uuid) {
|
_extensionAvailable: function(uuid) {
|
||||||
@ -100,8 +102,18 @@ const Application = new Lang.Class({
|
|||||||
|
|
||||||
let dialog = new Gtk.Dialog({ use_header_bar: true,
|
let dialog = new Gtk.Dialog({ use_header_bar: true,
|
||||||
modal: true,
|
modal: true,
|
||||||
title: extension.metadata.name,
|
title: extension.metadata.name });
|
||||||
transient_for: this._window });
|
|
||||||
|
if (this._skipMainWindow) {
|
||||||
|
this.application.add_window(dialog);
|
||||||
|
if (this._window)
|
||||||
|
this._window.destroy();
|
||||||
|
this._window = dialog;
|
||||||
|
this._window.window_position = Gtk.WindowPosition.CENTER;
|
||||||
|
} else {
|
||||||
|
dialog.transient_for = this._window;
|
||||||
|
}
|
||||||
|
|
||||||
dialog.set_default_size(600, 400);
|
dialog.set_default_size(600, 400);
|
||||||
dialog.get_content_area().add(widget);
|
dialog.get_content_area().add(widget);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
@ -220,6 +232,8 @@ const Application = new Lang.Class({
|
|||||||
if (this._startupUuid && this._extensionAvailable(this._startupUuid))
|
if (this._startupUuid && this._extensionAvailable(this._startupUuid))
|
||||||
this._selectExtension(this._startupUuid);
|
this._selectExtension(this._startupUuid);
|
||||||
this._startupUuid = null;
|
this._startupUuid = null;
|
||||||
|
this._skipMainWindow = false;
|
||||||
|
this._loaded = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
_onActivate: function() {
|
_onActivate: function() {
|
||||||
@ -235,16 +249,21 @@ const Application = new Lang.Class({
|
|||||||
_onCommandLine: function(app, commandLine) {
|
_onCommandLine: function(app, commandLine) {
|
||||||
app.activate();
|
app.activate();
|
||||||
let args = commandLine.get_arguments();
|
let args = commandLine.get_arguments();
|
||||||
|
|
||||||
if (args.length) {
|
if (args.length) {
|
||||||
let uuid = args[0];
|
let uuid = args[0];
|
||||||
|
|
||||||
|
this._skipMainWindow = true;
|
||||||
|
|
||||||
// Strip off "extension:///" prefix which fakes a URI, if it exists
|
// Strip off "extension:///" prefix which fakes a URI, if it exists
|
||||||
uuid = stripPrefix(uuid, "extension:///");
|
uuid = stripPrefix(uuid, "extension:///");
|
||||||
|
|
||||||
if (this._extensionAvailable(uuid))
|
if (this._extensionAvailable(uuid))
|
||||||
this._selectExtension(uuid);
|
this._selectExtension(uuid);
|
||||||
else
|
else if (!this._loaded)
|
||||||
this._startupUuid = uuid;
|
this._startupUuid = uuid;
|
||||||
|
else
|
||||||
|
this._skipMainWindow = false;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user