From be36fd4de2e4b4b26b3904c6df42a1c4caae520d Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 28 Jun 2020 13:10:31 +0200 Subject: [PATCH] Prefs, notifications and pot file * Add a long timeout for some OSD notifications. * Change some pref strings. * "Stroke" -> "Outline" * Clean pot file --- draw.js | 44 ++++++++++--------- extension.js | 14 +++--- locale/draw-on-your-screen.pot | 38 ++++------------ prefs.js | 13 +++--- ...extensions.draw-on-your-screen.gschema.xml | 10 ++--- 5 files changed, 51 insertions(+), 68 deletions(-) diff --git a/draw.js b/draw.js index e8a8fd1..42b00ee 100644 --- a/draw.js +++ b/draw.js @@ -130,7 +130,7 @@ const getJsonFiles = function() { var DrawingArea = new Lang.Class({ Name: 'DrawOnYourScreenDrawingArea', Extends: St.DrawingArea, - Signals: { 'show-osd': { param_types: [GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_DOUBLE] }, + Signals: { 'show-osd': { param_types: [GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_DOUBLE, GObject.TYPE_BOOLEAN] }, 'update-action-mode': {}, 'leave-drawing-mode': {} }, @@ -397,8 +397,8 @@ var DrawingArea = new Lang.Class({ event.get_key_symbol() == Clutter.KEY_KP_Enter || event.get_key_symbol() == Clutter.KEY_Control_L) { if (this.currentElement.points.length == 2) - this.emit('show-osd', null, _("Press %s to get a fourth control point") - .format(Gtk.accelerator_get_label(Clutter.KEY_Return, 0)), "", -1); + this.emit('show-osd', null, _("Press %s to get\na fourth control point") + .format(Gtk.accelerator_get_label(Clutter.KEY_Return, 0)), "", -1, true); this.currentElement.addPoint(); this.updatePointerCursor(true); this._redisplay(); @@ -494,7 +494,7 @@ var DrawingArea = new Lang.Class({ if (this.grabbedElementLocked) { this.updatePointerCursor(); let label = controlPressed ? _("Mark a point of symmetry") : _("Draw a line of symmetry"); - this.emit('show-osd', null, label, "", -1); + this.emit('show-osd', null, label, "", -1, true); return; } } @@ -617,7 +617,8 @@ var DrawingArea = new Lang.Class({ this.currentElement.startDrawing(startX, startY); if (this.currentTool == Shapes.POLYGON || this.currentTool == Shapes.POLYLINE) - this.emit('show-osd', null, _("Press %s to mark vertices").format(Gtk.accelerator_get_label(Clutter.KEY_Return, 0)), "", -1); + this.emit('show-osd', null, _("Press %s to mark vertices") + .format(Gtk.accelerator_get_label(Clutter.KEY_Return, 0)), "", -1, true); this.motionHandler = this.connect('motion-event', (actor, event) => { if (this.spaceKeyPressed) @@ -676,7 +677,8 @@ var DrawingArea = new Lang.Class({ _startWriting: function() { this.currentElement.text = ''; this.currentElement.cursorPosition = 0; - this.emit('show-osd', null, _("Type your text and press %s").format(Gtk.accelerator_get_label(Clutter.KEY_Escape, 0)), "", -1); + this.emit('show-osd', null, _("Type your text and press %s") + .format(Gtk.accelerator_get_label(Clutter.KEY_Escape, 0)), "", -1, true); this._updateTextCursorTimeout(); this.textHasCursor = true; this._redisplay(); @@ -873,43 +875,43 @@ var DrawingArea = new Lang.Class({ this._redisplay(); } // Foreground color markup is not displayed since 3.36, use style instead but the transparency is lost. - this.emit('show-osd', null, this.currentColor.to_string(), this.currentColor.to_string().slice(0, 7), -1); + this.emit('show-osd', null, this.currentColor.to_string(), this.currentColor.to_string().slice(0, 7), -1, false); }, selectTool: function(tool) { this.currentTool = tool; - this.emit('show-osd', null, _(ToolNames[tool]), "", -1); + this.emit('show-osd', null, _(ToolNames[tool]), "", -1, false); this.updatePointerCursor(); }, toggleFill: function() { this.fill = !this.fill; - this.emit('show-osd', null, this.fill ? _("Fill") : _("Stroke"), "", -1); + this.emit('show-osd', null, this.fill ? _("Fill") : _("Outline"), "", -1, false); }, toggleDash: function() { this.dashedLine = !this.dashedLine; - this.emit('show-osd', null, this.dashedLine ? _("Dashed line") : _("Full line"), "", -1); + this.emit('show-osd', null, this.dashedLine ? _("Dashed line") : _("Full line"), "", -1, false); }, incrementLineWidth: function(increment) { this.currentLineWidth = Math.max(this.currentLineWidth + increment, 0); - this.emit('show-osd', null, _("%d px").format(this.currentLineWidth), "", 2 * this.currentLineWidth); + this.emit('show-osd', null, _("%d px").format(this.currentLineWidth), "", 2 * this.currentLineWidth, false); }, toggleLineJoin: function() { this.currentLineJoin = this.currentLineJoin == 2 ? 0 : this.currentLineJoin + 1; - this.emit('show-osd', null, _(LineJoinNames[this.currentLineJoin]), "", -1); + this.emit('show-osd', null, _(LineJoinNames[this.currentLineJoin]), "", -1, false); }, toggleLineCap: function() { this.currentLineCap = this.currentLineCap == 2 ? 0 : this.currentLineCap + 1; - this.emit('show-osd', null, _(LineCapNames[this.currentLineCap]), "", -1); + this.emit('show-osd', null, _(LineCapNames[this.currentLineCap]), "", -1, false); }, toggleFillRule: function() { this.currentFillRule = this.currentFillRule == 1 ? 0 : this.currentFillRule + 1; - this.emit('show-osd', null, _(FillRuleNames[this.currentFillRule]), "", -1); + this.emit('show-osd', null, _(FillRuleNames[this.currentFillRule]), "", -1, false); }, toggleFontWeight: function() { @@ -920,7 +922,8 @@ var DrawingArea = new Lang.Class({ this.currentElement.font.weight = this.currentFontWeight; this._redisplay(); } - this.emit('show-osd', null, `${_(FontWeightNames[this.currentFontWeight])}`, "", -1); + this.emit('show-osd', null, `` + + `${_(FontWeightNames[this.currentFontWeight])}`, "", -1, false); }, toggleFontStyle: function() { @@ -929,7 +932,8 @@ var DrawingArea = new Lang.Class({ this.currentElement.font.style = this.currentFontStyle; this._redisplay(); } - this.emit('show-osd', null, `${_(FontStyleNames[this.currentFontStyle])}`, "", -1); + this.emit('show-osd', null, `` + + `${_(FontStyleNames[this.currentFontStyle])}`, "", -1, false); }, toggleFontFamily: function() { @@ -939,7 +943,7 @@ var DrawingArea = new Lang.Class({ this.currentElement.font.family = currentFontFamily; this._redisplay(); } - this.emit('show-osd', null, `${_(currentFontFamily)}`, "", -1); + this.emit('show-osd', null, `${_(currentFontFamily)}`, "", -1, false); }, toggleTextAlignment: function() { @@ -948,7 +952,7 @@ var DrawingArea = new Lang.Class({ this.currentElement.textRightAligned = this.currentTextRightAligned; this._redisplay(); } - this.emit('show-osd', null, this.currentTextRightAligned ? _("Right aligned") : _("Left aligned"), "", -1); + this.emit('show-osd', null, this.currentTextRightAligned ? _("Right aligned") : _("Left aligned"), "", -1, false); }, toggleHelp: function() { @@ -1119,7 +1123,7 @@ var DrawingArea = new Lang.Class({ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => { GLib.file_set_contents(path, contents); if (notify) - this.emit('show-osd', 'document-save-symbolic', name, "", -1); + this.emit('show-osd', 'document-save-symbolic', name, "", -1, false); if (name != Me.metadata['persistent-file-name']) { this.jsonName = name; this.lastJsonContents = contents; @@ -1171,7 +1175,7 @@ var DrawingArea = new Lang.Class({ this.elements.push(...JSON.parse(contents).map(object => new DrawingElement(object))); if (notify) - this.emit('show-osd', 'document-open-symbolic', name, "", -1); + this.emit('show-osd', 'document-open-symbolic', name, "", -1, false); if (name != Me.metadata['persistent-file-name']) { this.jsonName = name; this.lastJsonContents = contents; diff --git a/extension.js b/extension.js index 1c2ba1e..f0c0a48 100644 --- a/extension.js +++ b/extension.js @@ -81,18 +81,18 @@ var AreaManager = new Lang.Class({ Shell.ActionMode.ALL, this.toggleDrawing.bind(this)); - Main.wm.addKeybinding('erase-drawing', - this.settings, - Meta.KeyBindingFlags.NONE, - Shell.ActionMode.ALL, - this.eraseDrawing.bind(this)); - Main.wm.addKeybinding('toggle-modal', this.settings, Meta.KeyBindingFlags.NONE, Shell.ActionMode.ALL, this.toggleModal.bind(this)); + Main.wm.addKeybinding('erase-drawing', + this.settings, + Meta.KeyBindingFlags.NONE, + Shell.ActionMode.ALL, + this.eraseDrawing.bind(this)); + this.updateAreas(); this.monitorChangedHandler = Main.layoutManager.connect('monitors-changed', this.updateAreas.bind(this)); @@ -536,8 +536,8 @@ var AreaManager = new Lang.Class({ if (this.activeArea) this.toggleDrawing(); Main.wm.removeKeybinding('toggle-drawing'); - Main.wm.removeKeybinding('erase-drawing'); Main.wm.removeKeybinding('toggle-modal'); + Main.wm.removeKeybinding('erase-drawing'); this.removeAreas(); if (this.indicator) this.indicator.disable(); diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index 4b6a44e..f3aa818 100644 --- a/locale/draw-on-your-screen.pot +++ b/locale/draw-on-your-screen.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Draw On Your Screen VERSION\n" "Report-Msgid-Bugs-To: https://framagit.org/abakkk/DrawOnYourScreen/issues\n" -"POT-Creation-Date: 2020-01-03 08:00+0100\n" +"POT-Creation-Date: 2019-03-04 16:40+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -74,7 +74,9 @@ msgstr "" msgid "Mirror" msgstr "" -msgid "Press %s to get a fourth control point" +msgid "" +"Press %s to get\n" +"a fourth control point" msgstr "" msgid "Mark a point of symmetry" @@ -115,7 +117,6 @@ msgid "Left aligned" msgstr "" #: helper - msgid "Screenshot" msgstr "" @@ -132,7 +133,6 @@ msgid "System" msgstr "" #: menu - msgid "Undo" msgstr "" @@ -162,7 +162,6 @@ msgid "Save drawing" msgstr "" #: prefs.js - msgid "Preferences" msgstr "" @@ -170,18 +169,16 @@ msgid "About" msgstr "" #: GLOBAL_KEYBINDINGS - msgid "Enter/leave drawing mode" msgstr "" -msgid "Erase all drawings" -msgstr "" - msgid "Toggle modeless/modal" msgstr "" -#: INTERNAL_KEYBINDINGS +msgid "Erase all drawings" +msgstr "" +#: INTERNAL_KEYBINDINGS msgid "Undo last brushstroke" msgstr "" @@ -194,9 +191,6 @@ msgstr "" msgid "Smooth last brushstroke" msgstr "" -msgid "Free drawing" -msgstr "" - msgid "Select line" msgstr "" @@ -248,10 +242,6 @@ msgstr "" msgid "Toggle fill rule" msgstr "" -#: already in draw.js -#:msgid "Dashed line" -#:msgstr "" - msgid "Change font family (generic name)" msgstr "" @@ -282,10 +272,6 @@ msgstr "" msgid "Open next drawing" msgstr "" -#: already in draw.js -#:msgid "Save drawing" -#:msgstr "" - msgid "Save drawing as a SVG file" msgstr "" @@ -299,7 +285,6 @@ msgid "Show help" msgstr "" #: OTHER_SHORTCUTS - msgid "Draw" msgstr "" @@ -341,15 +326,12 @@ msgstr "" msgid "Select eraser (while starting drawing)" msgstr "" -msgid "Duplicate (while starting moving, resizing or mirroring)" +msgid "Duplicate (while starting handling)" msgstr "" msgid "Rotate rectangle, polygon, polyline" msgstr "" -msgid "Translate text area" -msgstr "" - msgid "Extend circle to ellipse" msgstr "" @@ -369,7 +351,6 @@ msgid "Inverse (while mirroring)" msgstr "" #: About page - # You are free to translate the extension name, that is displayed in About page, or not. msgid "Draw On You Screen" msgstr "" @@ -381,7 +362,6 @@ msgid "Start drawing with Super+Alt+D and save your beautiful work by taking a s msgstr "" #: Prefs page - msgid "Global" msgstr "" @@ -415,7 +395,7 @@ msgid "" msgstr "" msgid "" -"Note: When you save elements made with eraser in a SVG file, " +"When you save elements made with eraser in a SVG file, " "they are colored with background color, transparent if it is disabled.\n" "See “%s” or edit the SVG file afterwards." msgstr "" diff --git a/prefs.js b/prefs.js index d4a7837..57c5388 100644 --- a/prefs.js +++ b/prefs.js @@ -37,8 +37,8 @@ const MARGIN = 10; var GLOBAL_KEYBINDINGS = { 'toggle-drawing': "Enter/leave drawing mode", - 'erase-drawing': "Erase all drawings", - 'toggle-modal': "Toggle modeless/modal" + 'toggle-modal': "Toggle modeless/modal", + 'erase-drawing': "Erase all drawings" }; var INTERNAL_KEYBINDINGS = { @@ -58,7 +58,7 @@ var INTERNAL_KEYBINDINGS = { 'select-resize-tool': "Select resize", 'select-mirror-tool': "Select mirror", '-separator-2': '', - 'toggle-fill': "Toggle fill/stroke", + 'toggle-fill': "Toggle fill/outline", 'toggle-fill-rule': "Toggle fill rule", '-separator-3': '', 'increment-line-width': "Increment line width", @@ -99,16 +99,15 @@ function getKeyLabel(accel) { var OTHER_SHORTCUTS = [ { desc: "Draw", get shortcut() { return _("Left click"); } }, { desc: "Menu", get shortcut() { return _("Right click"); } }, - { desc: "Toggle fill/stroke", get shortcut() { return _("Center click"); } }, + { desc: "Toggle fill/outline", get shortcut() { return _("Center click"); } }, { desc: "Increment/decrement line width", get shortcut() { return _("Scroll"); } }, { desc: "Select color", get shortcut() { return _("%s … %s").format(getKeyLabel('1'), getKeyLabel('9')); } }, { desc: "Ignore pointer movement", get shortcut() { return _("%s held").format(getKeyLabel('space')); } }, { desc: "Leave", shortcut: getKeyLabel('Escape') }, { desc: "-separator-1", shortcut: "" }, { desc: "Select eraser (while starting drawing)", shortcut: getKeyLabel('') }, - { desc: "Duplicate (while starting moving, resizing or mirroring)", shortcut: getKeyLabel('') }, + { desc: "Duplicate (while starting handling)", shortcut: getKeyLabel('') }, { desc: "Rotate rectangle, polygon, polyline", shortcut: getKeyLabel('') }, - { desc: "Translate text area", shortcut: getKeyLabel('') }, { desc: "Extend circle to ellipse", shortcut: getKeyLabel('') }, { desc: "Curve line", shortcut: getKeyLabel('') }, { desc: "Smooth free drawing stroke", shortcut: getKeyLabel('') }, @@ -326,7 +325,7 @@ const PrefsPage = new GObject.Class({ wrap: true, xalign: 0, use_markup: true, - label: _("Note: When you save elements made with eraser in a SVG file, " + + label: _("When you save elements made with eraser in a SVG file, " + "they are colored with background color, transparent if it is disabled.\n" + "See “%s” or edit the SVG file afterwards.").format(_("Add a drawing background")) }); diff --git a/schemas/org.gnome.shell.extensions.draw-on-your-screen.gschema.xml b/schemas/org.gnome.shell.extensions.draw-on-your-screen.gschema.xml index e9cb2bf..767f859 100644 --- a/schemas/org.gnome.shell.extensions.draw-on-your-screen.gschema.xml +++ b/schemas/org.gnome.shell.extensions.draw-on-your-screen.gschema.xml @@ -26,16 +26,16 @@ toggle drawing enter or leave drawing mode - - ["<Alt><Super>e"] - erase drawing - erase drawing - ["<Primary><Alt><Super>d"] toggle modeless/modal toggle modeless/modal + + ["<Alt><Super>e"] + erase drawing + erase drawing + ["<Primary>z"] undo