add "Open preferences" shortcut

Available since GS 3.36, so the shortcut is hidden for previous versions.
This commit is contained in:
abakkk 2020-06-08 15:26:55 +02:00
parent b4eb418c89
commit 9bde4d3013
5 changed files with 25 additions and 1 deletions

View File

@ -198,7 +198,8 @@ var AreaManager = new Lang.Class({
'toggle-font-style': this.activeArea.toggleFontStyle.bind(this.activeArea),
'toggle-panel-and-dock-visibility': this.togglePanelAndDockOpacity.bind(this),
'toggle-help': this.activeArea.toggleHelp.bind(this.activeArea),
'open-user-stylesheet': this.openUserStyleFile.bind(this)
'open-user-stylesheet': this.openUserStyleFile.bind(this),
'open-preferences': this.openPreferences.bind(this)
};
for (let key in this.internalKeybindings) {
@ -229,6 +230,15 @@ var AreaManager = new Lang.Class({
}
},
openPreferences: function() {
// since GS 3.36
if (ExtensionUtils.openPrefs) {
if (this.activeArea)
this.toggleDrawing();
ExtensionUtils.openPrefs();
}
},
openUserStyleFile: function() {
if (!this.userStyleFile.query_exists(null)) {
if (!this.userStyleFile.get_parent().query_exists(null))

View File

@ -241,6 +241,9 @@ msgstr ""
msgid "Edit style"
msgstr ""
msgid "Open preferences"
msgstr ""
msgid "Show help"
msgstr ""

View File

@ -25,12 +25,14 @@ const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Config = imports.misc.config;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = ExtensionUtils.getSettings && ExtensionUtils.initTranslations ? ExtensionUtils : Me.imports.convenience;
const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext;
const _GTK = imports.gettext.domain('gtk30').gettext;
const GS_VERSION = Config.PACKAGE_VERSION;
const MARGIN = 10;
var GLOBAL_KEYBINDINGS = {
@ -74,9 +76,13 @@ var INTERNAL_KEYBINDINGS = {
'save-as-json': "Save drawing",
'save-as-svg': "Save drawing as a SVG file",
'open-user-stylesheet': "Edit style",
'open-preferences': "Open preferences",
'toggle-help': "Show help"
};
if (GS_VERSION < "3.36")
delete INTERNAL_KEYBINDINGS['open-preferences'];
function getKeyLabel(accel) {
let [keyval, mods] = Gtk.accelerator_parse(accel);
return Gtk.accelerator_get_label(keyval, mods);

Binary file not shown.

View File

@ -231,6 +231,11 @@
<summary>Open next json file</summary>
<description>Open next json file</description>
</key>
<key type="as" name="open-preferences">
<default>["&lt;Primary&gt;comma"]</default>
<summary>Open preferences</summary>
<description>Open preferences</description>
</key>
<key type="as" name="toggle-help">
<default>["&lt;Primary&gt;F1"]</default>
<summary>toggle help</summary>