diff --git a/draw.js b/draw.js
index ae32b05..11f4447 100644
--- a/draw.js
+++ b/draw.js
@@ -401,7 +401,7 @@ var DrawingArea = new Lang.Class({
if (this.currentShape == Shapes.POLYGON || this.currentShape == Shapes.POLYLINE) {
this.currentElement.points.push([startX, startY]);
- this.emit('show-osd', null, _("Press Enter\nto mark vertices"), "", -1);
+ this.emit('show-osd', null, _("Press %s\nto mark vertices").format(Gtk.accelerator_get_label(Clutter.KEY_Return, 0)), "", -1);
}
this.motionHandler = this.connect('motion-event', (actor, event) => {
@@ -444,7 +444,7 @@ var DrawingArea = new Lang.Class({
// start writing
this.currentElement.state = TextState.WRITING;
this.currentElement.text = '';
- this.emit('show-osd', null, _("Type your text\nand press Escape"), "", -1);
+ this.emit('show-osd', null, _("Type your text\nand press %s").format(Gtk.accelerator_get_label(Clutter.KEY_Escape, 0)), "", -1);
this._updateTextCursorTimeout();
this.textHasCursor = true;
this._redisplay();
@@ -1238,6 +1238,32 @@ var DrawingHelper = new Lang.Class({
this.parent(params);
this.monitor = monitor;
this.hide();
+ this.settings = Convenience.getSettings();
+
+ this.settingHandler = this.settings.connect('changed', this._onSettingChanged.bind(this));
+ this.connect('destroy', () => this.settings.disconnect(this.settingHandler));
+ },
+
+ _onSettingChanged: function(settings, key) {
+ if (key == 'toggle-help')
+ this._updateHelpKeyLabel();
+
+ if (this.vbox) {
+ this.vbox.destroy();
+ this.vbox = null;
+ }
+ },
+
+ _updateHelpKeyLabel: function() {
+ let [keyval, mods] = Gtk.accelerator_parse(this.settings.get_strv('toggle-help')[0]);
+ this._helpKeyLabel = Gtk.accelerator_get_label(keyval, mods);
+ },
+
+ get helpKeyLabel() {
+ if (!this._helpKeyLabel)
+ this._updateHelpKeyLabel();
+
+ return this._helpKeyLabel;
},
_populate: function() {
@@ -1245,17 +1271,15 @@ var DrawingHelper = new Lang.Class({
this.add_actor(this.vbox);
this.vbox.add_child(new St.Label({ text: _("Global") }));
- let settings = Convenience.getSettings();
-
for (let settingKey in Prefs.GLOBAL_KEYBINDINGS) {
let hbox = new St.BoxLayout({ vertical: false });
if (settingKey.indexOf('-separator-') != -1) {
this.vbox.add_child(hbox);
continue;
}
- if (!settings.get_strv(settingKey)[0])
+ if (!this.settings.get_strv(settingKey)[0])
continue;
- let [keyval, mods] = Gtk.accelerator_parse(settings.get_strv(settingKey)[0]);
+ let [keyval, mods] = Gtk.accelerator_parse(this.settings.get_strv(settingKey)[0]);
hbox.add_child(new St.Label({ text: _(Prefs.GLOBAL_KEYBINDINGS[settingKey]) }));
hbox.add_child(new St.Label({ text: Gtk.accelerator_get_label(keyval, mods), x_expand: true }));
this.vbox.add_child(hbox);
@@ -1270,7 +1294,7 @@ var DrawingHelper = new Lang.Class({
}
let hbox = new St.BoxLayout({ vertical: false });
hbox.add_child(new St.Label({ text: _(Prefs.OTHER_SHORTCUTS[i].desc) }));
- hbox.add_child(new St.Label({ text: _(Prefs.OTHER_SHORTCUTS[i].shortcut), x_expand: true }));
+ hbox.add_child(new St.Label({ text: Prefs.OTHER_SHORTCUTS[i].shortcut, x_expand: true }));
this.vbox.add_child(hbox);
}
@@ -1282,9 +1306,9 @@ var DrawingHelper = new Lang.Class({
continue;
}
let hbox = new St.BoxLayout({ vertical: false });
- if (!settings.get_strv(settingKey)[0])
+ if (!this.settings.get_strv(settingKey)[0])
continue;
- let [keyval, mods] = Gtk.accelerator_parse(settings.get_strv(settingKey)[0]);
+ let [keyval, mods] = Gtk.accelerator_parse(this.settings.get_strv(settingKey)[0]);
hbox.add_child(new St.Label({ text: _(Prefs.INTERNAL_KEYBINDINGS[settingKey]) }));
hbox.add_child(new St.Label({ text: Gtk.accelerator_get_label(keyval, mods), x_expand: true }));
this.vbox.add_child(hbox);
@@ -1339,7 +1363,7 @@ var DrawingHelper = new Lang.Class({
transition: 'easeOutQuad',
onComplete: this.hide.bind(this) });
- },
+ }
});
const getActor = function(object) {
diff --git a/extension.js b/extension.js
index f8854a8..4330d8c 100644
--- a/extension.js
+++ b/extension.js
@@ -336,7 +336,9 @@ var AreaManager = new Lang.Class({
// increase OSD display time
let hideTimeoutSave = OsdWindow.HIDE_TIMEOUT;
try { OsdWindow.HIDE_TIMEOUT = 2000; } catch(e) { /* HIDE_TIMEOUT is not exported with 'var' */ }
- Main.osdWindowManager.show(currentIndex, this.enterGicon, _("Press Ctrl + F1 for help") + "\n\n" + _("Entering drawing mode"), null);
+ let label = _("Press %s for help").format(this.activeArea.helper.helpKeyLabel) + "\n\n" + _("Entering drawing mode");
+ Main.osdWindowManager.show(currentIndex, this.enterGicon, label, null);
+ Main.osdWindowManager._osdWindows[this.areas.indexOf(this.activeArea)]._label.get_clutter_text().set_use_markup(true);
try { OsdWindow.HIDE_TIMEOUT = hideTimeoutSave; } catch(e) {}
}
}
diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot
index e4ca8c7..baefa57 100644
--- a/locale/draw-on-your-screen.pot
+++ b/locale/draw-on-your-screen.pot
@@ -36,7 +36,8 @@ msgstr ""
msgid "Leaving drawing mode"
msgstr ""
-msgid "Press Ctrl + F1 for help"
+# %s is a key label
+msgid "Press %s for help"
msgstr ""
msgid "Entering drawing mode"
@@ -76,14 +77,16 @@ msgstr ""
msgid "Full line"
msgstr ""
+# %s is a key label
msgid ""
-"Press Enter\n"
+"Press %s\n"
"to mark vertices"
msgstr ""
+# %s is a key label
msgid ""
"Type your text\n"
-"and press Escape"
+"and press %s"
msgstr ""
msgid "Screenshot"
@@ -133,7 +136,7 @@ msgstr ""
msgid "About"
msgstr ""
-# GLOBAL_KEYBINDINGS
+#: GLOBAL_KEYBINDINGS
msgid "Enter/leave drawing mode"
msgstr ""
@@ -141,7 +144,7 @@ msgstr ""
msgid "Erase all drawings"
msgstr ""
-# INTERNAL_KEYBINDINGS
+#: INTERNAL_KEYBINDINGS
msgid "Undo last brushstroke"
msgstr ""
@@ -197,9 +200,9 @@ msgstr ""
msgid "Change linecap"
msgstr ""
-# already in draw.js
-#msgid "Dashed line"
-#msgstr ""
+#: already in draw.js
+#:msgid "Dashed line"
+#:msgstr ""
msgid "Change font family (generic name)"
msgstr ""
@@ -228,9 +231,9 @@ msgstr ""
msgid "Open next drawing"
msgstr ""
-# already in draw.js
-#msgid "Save drawing"
-#msgstr ""
+#: already in draw.js
+#:msgid "Save drawing"
+#:msgstr ""
msgid "Save drawing as a SVG file"
msgstr ""
@@ -241,7 +244,7 @@ msgstr ""
msgid "Show help"
msgstr ""
-# OTHER_SHORTCUTS
+#: OTHER_SHORTCUTS
msgid "Draw"
msgstr ""
@@ -261,9 +264,6 @@ msgstr ""
msgid "Transform shape (when drawing)"
msgstr ""
-msgid "Ctrl key"
-msgstr ""
-
msgid "Increment/decrement line width"
msgstr ""
@@ -273,40 +273,36 @@ msgstr ""
msgid "Select color"
msgstr ""
-msgid "Ctrl+1...9"
+# %s are key labels (Ctrl+F1 and Ctrl+F9)
+msgid "%s … %s"
msgstr ""
msgid "Select eraser"
msgstr ""
-msgid "Shift key held"
+# %s is a key label
+msgid "%s held"
msgstr ""
msgid "Ignore pointer movement"
msgstr ""
-msgid "Space key held"
-msgstr ""
-
msgid "Leave"
msgstr ""
-msgid "Escape key"
+#: About page
+
+# You are free to translate the extension name, that is displayed in About page, or not.
+msgid "Draw On You Screen"
msgstr ""
-# About page
-
-# you are free to translate the extension name
-#msgid "Draw On You Screen"
-#msgstr ""
-
msgid "Version %d"
msgstr ""
msgid "Start drawing with Super+Alt+D and save your beautiful work by taking a screenshot"
msgstr ""
-# Prefs page
+#: Prefs page
msgid "Global"
msgstr ""
diff --git a/prefs.js b/prefs.js
index b7ff66e..b46046a 100644
--- a/prefs.js
+++ b/prefs.js
@@ -77,16 +77,21 @@ var INTERNAL_KEYBINDINGS = {
'toggle-help': "Show help"
};
+function getKeyLabel(accel) {
+ let [keyval, mods] = Gtk.accelerator_parse(accel);
+ return Gtk.accelerator_get_label(keyval, mods);
+}
+
var OTHER_SHORTCUTS = [
- { desc: "Draw", shortcut: "Left click" },
- { desc: "Menu", shortcut: "Right click" },
- { desc: "Toggle fill/stroke", shortcut: "Center click" },
- { desc: "Transform shape (when drawing)", shortcut: "Ctrl key" },
- { desc: "Increment/decrement line width", shortcut: "Scroll" },
- { desc: "Select color", shortcut: "Ctrl+1...9" },
- { desc: "Select eraser", shortcut: "Shift key held" },
- { desc: "Ignore pointer movement", shortcut: "Space key held" },
- { desc: "Leave", shortcut: "Escape key" }
+ { desc: "Draw", get shortcut() { return _("Left click"); } },
+ { desc: "Menu", get shortcut() { return _("Right click"); } },
+ { desc: "Toggle fill/stroke", get shortcut() { return _("Center click"); } },
+ { desc: "Transform shape (when drawing)", shortcut: getKeyLabel('') },
+ { desc: "Increment/decrement line width", get shortcut() { return _("Scroll"); } },
+ { desc: "Select color", get shortcut() { return _("%s … %s").format(getKeyLabel('1'), getKeyLabel('9')); } },
+ { desc: "Select eraser", get shortcut() { return _("%s held").format(getKeyLabel('')); } },
+ { desc: "Ignore pointer movement", get shortcut() { return _("%s held").format(getKeyLabel('space')); } },
+ { desc: "Leave", shortcut: getKeyLabel('Escape') }
];
function init() {
@@ -270,7 +275,7 @@ const PrefsPage = new GObject.Class({
let otherBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN });
let otherLabel = new Gtk.Label({ label: _(OTHER_SHORTCUTS[i].desc) });
otherLabel.set_halign(1);
- let otherLabel2 = new Gtk.Label({ label: _(OTHER_SHORTCUTS[i].shortcut) });
+ let otherLabel2 = new Gtk.Label({ label: OTHER_SHORTCUTS[i].shortcut });
otherBox.pack_start(otherLabel, true, true, 4);
otherBox.pack_start(otherLabel2, false, false, 4);
listBox.add(otherBox);