minor, use array instead of object for "OTHER" shortcuts
Array is more semantically appropriate. For example 2 actions may have the same translations (error of a translator). With an object (or a map), only the second would be displayed, which is problematic to alert to the problem. Additionally, handle the case where some GSettings keybinding values are empty.
This commit is contained in:
parent
464aae77c6
commit
e53e69efcf
|
|
@ -103,7 +103,7 @@ const AreaManager = new Lang.Class({
|
|||
Me.settings,
|
||||
Meta.KeyBindingFlags.NONE,
|
||||
Shell.ActionMode.ALL,
|
||||
this.eraseDrawing.bind(this));
|
||||
this.eraseDrawings.bind(this));
|
||||
|
||||
this.updateAreas();
|
||||
this.monitorChangedHandler = Main.layoutManager.connect('monitors-changed', this.updateAreas.bind(this));
|
||||
|
|
@ -265,7 +265,7 @@ const AreaManager = new Lang.Class({
|
|||
}
|
||||
},
|
||||
|
||||
eraseDrawing: function() {
|
||||
eraseDrawings: function() {
|
||||
for (let i = 0; i < this.areas.length; i++)
|
||||
this.areas[i].erase();
|
||||
if (Me.settings.get_boolean('persistent-drawing'))
|
||||
|
|
|
|||
19
helper.js
19
helper.js
|
|
@ -71,7 +71,7 @@ var DrawingHelper = new Lang.Class({
|
|||
},
|
||||
|
||||
_updateHelpKeyLabel: function() {
|
||||
let [keyval, mods] = Gtk.accelerator_parse(Me.internalShortcutSettings.get_strv('toggle-help')[0]);
|
||||
let [keyval, mods] = Gtk.accelerator_parse(Me.internalShortcutSettings.get_strv('toggle-help')[0] || '');
|
||||
this._helpKeyLabel = Gtk.accelerator_get_label(keyval, mods);
|
||||
},
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ var DrawingHelper = new Lang.Class({
|
|||
return;
|
||||
|
||||
let hbox = new St.BoxLayout({ vertical: false });
|
||||
let [keyval, mods] = Gtk.accelerator_parse(Me.settings.get_strv(settingKey)[0]);
|
||||
let [keyval, mods] = Gtk.accelerator_parse(Me.settings.get_strv(settingKey)[0] || '');
|
||||
hbox.add_child(new St.Label({ text: Me.settings.settings_schema.get_key(settingKey).get_summary() }));
|
||||
hbox.add_child(new St.Label({ text: Gtk.accelerator_get_label(keyval, mods), x_expand: true }));
|
||||
this.vbox.add_child(hbox);
|
||||
|
|
@ -106,17 +106,18 @@ var DrawingHelper = new Lang.Class({
|
|||
this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' }));
|
||||
this.vbox.add_child(new St.Label({ text: _("Internal") }));
|
||||
|
||||
Shortcuts.OTHERS.forEach((object, index) => {
|
||||
Shortcuts.OTHERS.forEach((pairs, index) => {
|
||||
if (index)
|
||||
this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' }));
|
||||
|
||||
for (let key in object) {
|
||||
pairs.forEach(pair => {
|
||||
let [action, shortcut] = pair;
|
||||
let hbox = new St.BoxLayout({ vertical: false });
|
||||
hbox.add_child(new St.Label({ text: key }));
|
||||
hbox.add_child(new St.Label({ text: object[key], x_expand: true }));
|
||||
hbox.add_child(new St.Label({ text: action }));
|
||||
hbox.add_child(new St.Label({ text: shortcut, x_expand: true }));
|
||||
hbox.get_children()[0].get_clutter_text().set_use_markup(true);
|
||||
this.vbox.add_child(hbox);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.vbox.add_child(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' }));
|
||||
|
|
@ -130,7 +131,7 @@ var DrawingHelper = new Lang.Class({
|
|||
return;
|
||||
|
||||
let hbox = new St.BoxLayout({ vertical: false });
|
||||
let [keyval, mods] = Gtk.accelerator_parse(Me.internalShortcutSettings.get_strv(settingKey)[0]);
|
||||
let [keyval, mods] = Gtk.accelerator_parse(Me.internalShortcutSettings.get_strv(settingKey)[0] || '');
|
||||
hbox.add_child(new St.Label({ text: Me.internalShortcutSettings.settings_schema.get_key(settingKey).get_summary() }));
|
||||
hbox.add_child(new St.Label({ text: Gtk.accelerator_get_label(keyval, mods), x_expand: true }));
|
||||
this.vbox.add_child(hbox);
|
||||
|
|
@ -149,7 +150,7 @@ var DrawingHelper = new Lang.Class({
|
|||
let shortcut = GS_VERSION < '3.33.0' ? mediaKeysSettings.get_string(settingKey) : mediaKeysSettings.get_strv(settingKey)[0];
|
||||
if (!shortcut)
|
||||
continue;
|
||||
let [keyval, mods] = Gtk.accelerator_parse(shortcut);
|
||||
let [keyval, mods] = Gtk.accelerator_parse(shortcut || '');
|
||||
let hbox = new St.BoxLayout({ vertical: false });
|
||||
hbox.add_child(new St.Label({ text: mediaKeysSettings.settings_schema.get_key(settingKey).get_summary() }));
|
||||
hbox.add_child(new St.Label({ text: Gtk.accelerator_get_label(keyval, mods), x_expand: true }));
|
||||
|
|
|
|||
13
prefs.js
13
prefs.js
|
|
@ -430,19 +430,20 @@ const PrefsPage = new GObject.Class({
|
|||
listBox.get_style_context().add_class('background');
|
||||
internalFrame.add(listBox);
|
||||
|
||||
Shortcuts.OTHERS.forEach((object, index) => {
|
||||
Shortcuts.OTHERS.forEach((pairs, index) => {
|
||||
if (index)
|
||||
listBox.add(new Gtk.Box(ROWBOX_MARGIN_PARAMS));
|
||||
|
||||
for (let key in object) {
|
||||
pairs.forEach(pair => {
|
||||
let [action, shortcut] = pair;
|
||||
let otherBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN });
|
||||
let otherLabel = new Gtk.Label({ label: key, use_markup: true });
|
||||
let otherLabel = new Gtk.Label({ label: action, use_markup: true });
|
||||
otherLabel.set_halign(1);
|
||||
let otherLabel2 = new Gtk.Label({ label: object[key] });
|
||||
let otherLabel2 = new Gtk.Label({ label: shortcut });
|
||||
otherBox.pack_start(otherLabel, true, true, 4);
|
||||
otherBox.pack_start(otherLabel2, false, false, 4);
|
||||
listBox.add(otherBox);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
listBox.add(new Gtk.Box(ROWBOX_MARGIN_PARAMS));
|
||||
|
|
@ -743,7 +744,7 @@ const KeybindingsWidget = new GObject.Class({
|
|||
|
||||
this._settingKeys.forEach(settingKey => {
|
||||
let [key, mods] = Gtk.accelerator_parse(
|
||||
this._settings.get_strv(settingKey)[0]
|
||||
this._settings.get_strv(settingKey)[0] || ''
|
||||
);
|
||||
|
||||
let iter = this._store.append();
|
||||
|
|
|
|||
38
shortcuts.js
38
shortcuts.js
|
|
@ -66,27 +66,27 @@ if (GS_VERSION < '3.36') {
|
|||
|
||||
const getOthers = function() {
|
||||
return [
|
||||
{
|
||||
[_("Draw")]: _("Left click"),
|
||||
[_("Menu")]: _("Right click"),
|
||||
[internalShortcutsSchema.get_key('switch-fill').get_summary()]: _("Center click"),
|
||||
[_("Increment/decrement line width")]: _("Scroll"),
|
||||
[
|
||||
[_("Draw"), _("Left click")],
|
||||
[_("Menu"), _("Right click")],
|
||||
[internalShortcutsSchema.get_key('switch-fill').get_summary(), _("Center click")],
|
||||
[_("Increment/decrement line width"), _("Scroll")],
|
||||
// Translators: %s are key labels (Ctrl+F1 and Ctrl+F9)
|
||||
[_("Select color")]: _("%s … %s").format(getKeyLabel('<Primary>1'), getKeyLabel('<Primary>9')),
|
||||
[_("Select color"), _("%s … %s").format(getKeyLabel('<Primary>1'), getKeyLabel('<Primary>9'))],
|
||||
// Translators: %s is a key label
|
||||
[_("Ignore pointer movement")]: _("%s held").format(getKeyLabel('space')),
|
||||
[_("Leave")]: getKeyLabel('Escape'),
|
||||
}, {
|
||||
[_("Select eraser <span alpha=\"50%\">(while starting drawing)</span>")]: getKeyLabel('<Shift>'),
|
||||
[_("Duplicate <span alpha=\"50%\">(while starting handling)</span>")]: getKeyLabel('<Shift>'),
|
||||
[_("Rotate rectangle, polygon, polyline")]: getKeyLabel('<Primary>'),
|
||||
[_("Extend circle to ellipse")]: getKeyLabel('<Primary>'),
|
||||
[_("Curve line")]: getKeyLabel('<Primary>'),
|
||||
[_("Smooth free drawing outline")]: getKeyLabel('<Primary>'),
|
||||
[_("Rotate <span alpha=\"50%\">(while moving)</span>")]: getKeyLabel('<Primary>'),
|
||||
[_("Stretch <span alpha=\"50%\">(while resizing)</span>")]: getKeyLabel('<Primary>'),
|
||||
[_("Inverse <span alpha=\"50%\">(while mirroring)</span>")]: getKeyLabel('<Primary>'),
|
||||
},
|
||||
[_("Ignore pointer movement"), _("%s held").format(getKeyLabel('space'))],
|
||||
[_("Leave"), getKeyLabel('Escape')],
|
||||
], [
|
||||
[_("Select eraser <span alpha=\"50%\">(while starting drawing)</span>"), getKeyLabel('<Shift>')],
|
||||
[_("Duplicate <span alpha=\"50%\">(while starting handling)</span>"), getKeyLabel('<Shift>')],
|
||||
[_("Rotate rectangle, polygon, polyline"), getKeyLabel('<Primary>')],
|
||||
[_("Extend circle to ellipse"), getKeyLabel('<Primary>')],
|
||||
[_("Curve line"), getKeyLabel('<Primary>')],
|
||||
[_("Smooth free drawing outline"), getKeyLabel('<Primary>')],
|
||||
[_("Rotate <span alpha=\"50%\">(while moving)</span>"), getKeyLabel('<Primary>')],
|
||||
[_("Stretch <span alpha=\"50%\">(while resizing)</span>"), getKeyLabel('<Primary>')],
|
||||
[_("Inverse <span alpha=\"50%\">(while mirroring)</span>"), getKeyLabel('<Primary>')],
|
||||
],
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue