diff --git a/extension.js b/extension.js index 7e60fb4..95c1dd7 100644 --- a/extension.js +++ b/extension.js @@ -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')) diff --git a/helper.js b/helper.js index 91d77fe..444ff93 100644 --- a/helper.js +++ b/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 })); diff --git a/prefs.js b/prefs.js index d334e29..c57f1b6 100644 --- a/prefs.js +++ b/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(); diff --git a/shortcuts.js b/shortcuts.js index de77083..5a04a67 100644 --- a/shortcuts.js +++ b/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('1'), getKeyLabel('9')), + [_("Select color"), _("%s … %s").format(getKeyLabel('1'), getKeyLabel('9'))], // Translators: %s is a key label - [_("Ignore pointer movement")]: _("%s held").format(getKeyLabel('space')), - [_("Leave")]: getKeyLabel('Escape'), - }, { - [_("Select eraser (while starting drawing)")]: getKeyLabel(''), - [_("Duplicate (while starting handling)")]: getKeyLabel(''), - [_("Rotate rectangle, polygon, polyline")]: getKeyLabel(''), - [_("Extend circle to ellipse")]: getKeyLabel(''), - [_("Curve line")]: getKeyLabel(''), - [_("Smooth free drawing outline")]: getKeyLabel(''), - [_("Rotate (while moving)")]: getKeyLabel(''), - [_("Stretch (while resizing)")]: getKeyLabel(''), - [_("Inverse (while mirroring)")]: getKeyLabel(''), - }, + [_("Ignore pointer movement"), _("%s held").format(getKeyLabel('space'))], + [_("Leave"), getKeyLabel('Escape')], + ], [ + [_("Select eraser (while starting drawing)"), getKeyLabel('')], + [_("Duplicate (while starting handling)"), getKeyLabel('')], + [_("Rotate rectangle, polygon, polyline"), getKeyLabel('')], + [_("Extend circle to ellipse"), getKeyLabel('')], + [_("Curve line"), getKeyLabel('')], + [_("Smooth free drawing outline"), getKeyLabel('')], + [_("Rotate (while moving)"), getKeyLabel('')], + [_("Stretch (while resizing)"), getKeyLabel('')], + [_("Inverse (while mirroring)"), getKeyLabel('')], + ], ]; };