From bb78937d601409f8c8c8303f5f57292ba5f1cf71 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sat, 28 Dec 2019 13:25:41 +0100 Subject: [PATCH 01/43] minor, 'DrowOnYourScreen' -> 'DrawOnYourScreen' in licence headers --- draw.js | 2 +- extension.js | 2 +- prefs.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/draw.js b/draw.js index 20b8b05..1dd7f6b 100644 --- a/draw.js +++ b/draw.js @@ -3,7 +3,7 @@ /* * Copyright 2019 Abakkk * - * This file is part of DrowOnYourScreen, a drawing extension for GNOME Shell. + * This file is part of DrawOnYourScreen, a drawing extension for GNOME Shell. * https://framagit.org/abakkk/DrawOnYourScreen * * This program is free software: you can redistribute it and/or modify diff --git a/extension.js b/extension.js index 5e712e2..6491dfb 100644 --- a/extension.js +++ b/extension.js @@ -3,7 +3,7 @@ /* * Copyright 2019 Abakkk * - * This file is part of DrowOnYourScreen, a drawing extension for GNOME Shell. + * This file is part of DrawOnYourScreen, a drawing extension for GNOME Shell. * https://framagit.org/abakkk/DrawOnYourScreen * * This program is free software: you can redistribute it and/or modify diff --git a/prefs.js b/prefs.js index e35e294..2488cf3 100644 --- a/prefs.js +++ b/prefs.js @@ -3,7 +3,7 @@ /* * Copyright 2019 Abakkk * - * This file is part of DrowOnYourScreen, a drawing extension for GNOME Shell. + * This file is part of DrawOnYourScreen, a drawing extension for GNOME Shell. * https://framagit.org/abakkk/DrawOnYourScreen * * This program is free software: you can redistribute it and/or modify From 944500fc24e10b6b8eced0069df9f4745e6c95b7 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sat, 28 Dec 2019 13:28:25 +0100 Subject: [PATCH 02/43] do not create menu when leaving drawing mode 'this.menu.close()' called the getter 'this.menu' that create the menu if it's not exist, which is not wanted when leaving drawing mode. --- draw.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/draw.js b/draw.js index 1dd7f6b..be908ec 100644 --- a/draw.js +++ b/draw.js @@ -581,7 +581,8 @@ var DrawingArea = new Lang.Class({ this.dashedLine = false; this.fill = false; this._redisplay(); - this.menu.close(); + if (this._menu) + this._menu.close(); this.get_parent().set_background_color(null); if (save) this.saveAsJson(); From 1c6fa54d69c4b7afa2a3e745e557d383ddc2d5ae Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 29 Dec 2019 15:26:20 +0100 Subject: [PATCH 03/43] drawing menu style improvement * Set 'max-height' property to menu actor. * Reduce size of menu items. * Rename 'draw-on-your-screen-menu-separator' style class to 'draw-on-your-screen-menu-separator-item' because it is relative to the item actor, not the item._separator actor. * Rename 'draw-on-your-screen-separator' style class to 'draw-on-your-screen-helper-separator' not to confuse with menu separator. --- draw.js | 19 ++++++++++--------- stylesheet.css | 20 +++++++++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/draw.js b/draw.js index be908ec..ae5d198 100644 --- a/draw.js +++ b/draw.js @@ -99,7 +99,7 @@ var DrawingArea = new Lang.Class({ get menu() { if (!this._menu) - this._menu = new DrawingMenu(this); + this._menu = new DrawingMenu(this, this.monitor); return this._menu; }, @@ -953,7 +953,7 @@ var DrawingHelper = new Lang.Class({ for (let i = 0; i < Prefs.OTHER_SHORTCUTS.length; i++) { if (Prefs.OTHER_SHORTCUTS[i].desc.indexOf('-separator-') != -1) { - this.vbox.add(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-separator' })); + this.vbox.add(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' })); continue; } let hbox = new St.BoxLayout({ vertical: false }); @@ -962,11 +962,11 @@ var DrawingHelper = new Lang.Class({ this.vbox.add(hbox); } - this.vbox.add(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-separator' })); + this.vbox.add(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' })); for (let settingKey in Prefs.INTERNAL_KEYBINDINGS) { if (settingKey.indexOf('-separator-') != -1) { - this.vbox.add(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-separator' })); + this.vbox.add(new St.BoxLayout({ vertical: false, style_class: 'draw-on-your-screen-helper-separator' })); continue; } let hbox = new St.BoxLayout({ vertical: false }); @@ -1028,7 +1028,7 @@ var DrawingHelper = new Lang.Class({ var DrawingMenu = new Lang.Class({ Name: 'DrawOnYourScreenDrawingMenu', - _init: function(area) { + _init: function(area, monitor) { this.area = area; let side = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL ? St.Side.RIGHT : St.Side.LEFT; this.menu = new PopupMenu.PopupMenu(Main.layoutManager.dummyCursor, 0.25, side); @@ -1037,6 +1037,7 @@ var DrawingMenu = new Lang.Class({ Main.layoutManager.uiGroup.add_actor(this.menu.actor); this.menu.actor.add_style_class_name('background-menu draw-on-your-screen-menu'); + this.menu.actor.set_style('max-height:' + monitor.height + 'px;'); this.menu.actor.hide(); // do not close the menu on item activated @@ -1271,10 +1272,10 @@ var DrawingMenu = new Lang.Class({ }, _addSeparator: function(menu) { - let separator = new PopupMenu.PopupSeparatorMenuItem(' '); - let separatorActor = GS_VERSION < '3.33.0' ? separator.actor : separator; - separatorActor.add_style_class_name('draw-on-your-screen-menu-separator'); - menu.addMenuItem(separator); + let separatorItem = new PopupMenu.PopupSeparatorMenuItem(' '); + let separatorItemActor = GS_VERSION < '3.33.0' ? separatorItem.actor : separatorItem; + separatorItemActor.add_style_class_name('draw-on-your-screen-menu-separator-item'); + menu.addMenuItem(separatorItem); } }); diff --git a/stylesheet.css b/stylesheet.css index 862879a..c68b599 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -73,28 +73,34 @@ font-weight: normal; } -.draw-on-your-screen-separator { +.draw-on-your-screen-helper-separator { min-height: 0.6em; } /* context menu */ .draw-on-your-screen-menu { - font-size: 0.98em; /* default: 1em */ + font-size: 0.97em; /* default: 1em */ } .draw-on-your-screen-menu .popup-menu-item { - padding-top: .37em; /* default: .4em */ - padding-bottom: .37em; + padding-top: .32em; /* default: .4em */ + padding-bottom: .32em; } .draw-on-your-screen-menu .popup-menu-icon { - icon-size: 1.04em; /* default: 1.09 */ + icon-size: 1em; /* default: 1.09 */ + padding-top: 0.03em; } .draw-on-your-screen-menu .toggle-switch { - height: 20px; /* default: 22px */ -} + height: 1.4em; /* default: 22px */ +} + +.draw-on-your-screen-menu .popup-menu-item.draw-on-your-screen-menu-separator-item { + padding-top: 0.14em; + padding-bottom: 0.14em; +} .draw-on-your-screen-menu-separator StLabel { font-size: 0; From 6d27a3747880e2d4dfe1fc23dfa5c37f1df7c724 Mon Sep 17 00:00:00 2001 From: abakkk Date: Thu, 2 Jan 2020 00:32:14 +0100 Subject: [PATCH 04/43] drawing menu separator item style improvement --- stylesheet.css | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stylesheet.css b/stylesheet.css index c68b599..3e96dd6 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -97,15 +97,20 @@ height: 1.4em; /* default: 22px */ } -.draw-on-your-screen-menu .popup-menu-item.draw-on-your-screen-menu-separator-item { +.draw-on-your-screen-menu-separator-item { padding-top: 0.14em; padding-bottom: 0.14em; } -.draw-on-your-screen-menu-separator StLabel { +.draw-on-your-screen-menu-separator-item StLabel { font-size: 0; } +.draw-on-your-screen-menu-separator-item .popup-separator-menu-item { + margin-top: 0.4em; /* default 6px */ + margin-bottom: 0.4em; /* default 6px */ +} + .draw-on-your-screen-menu-slider-label { min-width: 3em; text-align: right; From f0ac2a21b06f2ce0d901c34e04031a665746dc84 Mon Sep 17 00:00:00 2001 From: abakkk Date: Thu, 2 Jan 2020 00:56:40 +0100 Subject: [PATCH 05/43] add iconName param to showOsd function Prepare save and open drawing features. --- draw.js | 24 ++++++++++++------------ extension.js | 7 +++++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/draw.js b/draw.js index ae5d198..77d6ac1 100644 --- a/draw.js +++ b/draw.js @@ -70,7 +70,7 @@ var FontFamilyNames = { 0: 'Default', 1: 'Sans-Serif', 2: 'Serif', 3: 'Monospac var DrawingArea = new Lang.Class({ Name: 'DrawOnYourScreenDrawingArea', Extends: St.DrawingArea, - Signals: { 'show-osd': { param_types: [GObject.TYPE_STRING, GObject.TYPE_DOUBLE] }, + Signals: { 'show-osd': { param_types: [GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_DOUBLE] }, 'stop-drawing': {} }, _init: function(params, monitor, helper, loadJson) { @@ -322,7 +322,7 @@ var DrawingArea = new Lang.Class({ if (this.currentElement.shape == Shapes.TEXT && this.currentElement.state == TextState.DRAWING) { this.currentElement.state = TextState.WRITING; this.currentElement.text = ''; - this.emit('show-osd', _("Type your text\nand press Enter"), -1); + this.emit('show-osd', null, _("Type your text\nand press Enter"), -1); this._updateCursorTimeout(); this.textHasCursor = true; this._redisplay(); @@ -468,38 +468,38 @@ var DrawingArea = new Lang.Class({ this.currentElement.color = this.currentColor.to_string(); this._redisplay(); } - this.emit('show-osd', `${this.currentColor.to_string()}`, -1); + this.emit('show-osd', null, `${this.currentColor.to_string()}`, -1); }, selectShape: function(shape) { this.currentShape = shape; - this.emit('show-osd', _(ShapeNames[shape]), -1); + this.emit('show-osd', null, _(ShapeNames[shape]), -1); this.updatePointerCursor(); }, toggleFill: function() { this.fill = !this.fill; - this.emit('show-osd', this.fill ? _("Fill") : _("Stroke"), -1); + this.emit('show-osd', null, this.fill ? _("Fill") : _("Stroke"), -1); }, toggleDash: function() { this.dashedLine = !this.dashedLine; - this.emit('show-osd', this.dashedLine ? _("Dashed line") : _("Full line"), -1); + this.emit('show-osd', null, this.dashedLine ? _("Dashed line") : _("Full line"), -1); }, incrementLineWidth: function(increment) { this.currentLineWidth = Math.max(this.currentLineWidth + increment, 0); - this.emit('show-osd', this.currentLineWidth + " " + _("px"), 2 * this.currentLineWidth); + this.emit('show-osd', null, this.currentLineWidth + " " + _("px"), 2 * this.currentLineWidth); }, toggleLineJoin: function() { this.currentLineJoin = this.currentLineJoin == 2 ? 0 : this.currentLineJoin + 1; - this.emit('show-osd', _(LineJoinNames[this.currentLineJoin]), -1); + this.emit('show-osd', null, _(LineJoinNames[this.currentLineJoin]), -1); }, toggleLineCap: function() { this.currentLineCap = this.currentLineCap == 2 ? 0 : this.currentLineCap + 1; - this.emit('show-osd', _(LineCapNames[this.currentLineCap]), -1); + this.emit('show-osd', null, _(LineCapNames[this.currentLineCap]), -1); }, toggleFontWeight: function() { @@ -508,7 +508,7 @@ var DrawingArea = new Lang.Class({ this.currentElement.font.weight = this.currentFontWeight; this._redisplay(); } - this.emit('show-osd', `${_(FontWeightNames[this.currentFontWeight])}`, -1); + this.emit('show-osd', null, `${_(FontWeightNames[this.currentFontWeight])}`, -1); }, toggleFontStyle: function() { @@ -517,7 +517,7 @@ var DrawingArea = new Lang.Class({ this.currentElement.font.style = this.currentFontStyle; this._redisplay(); } - this.emit('show-osd', `${_(FontStyleNames[this.currentFontStyle])}`, -1); + this.emit('show-osd', null, `${_(FontStyleNames[this.currentFontStyle])}`, -1); }, toggleFontFamily: function() { @@ -527,7 +527,7 @@ var DrawingArea = new Lang.Class({ this.currentElement.font.family = currentFontFamily; this._redisplay(); } - this.emit('show-osd', `${_(currentFontFamily)}`, -1); + this.emit('show-osd', null, `${_(currentFontFamily)}`, -1); }, toggleHelp: function() { diff --git a/extension.js b/extension.js index 6491dfb..635c99a 100644 --- a/extension.js +++ b/extension.js @@ -315,11 +315,12 @@ var AreaManager = new Lang.Class({ }, // use level -1 to set no level (null) - showOsd: function(emitter, label, level, maxLevel) { + showOsd: function(emitter, iconName, label, level) { if (this.osdDisabled) return; let activeIndex = this.areas.indexOf(this.activeArea); if (activeIndex != -1) { + let maxLevel; if (level == -1) level = null; else if (level > 100) @@ -329,7 +330,9 @@ var AreaManager = new Lang.Class({ // GS 3.34+ : bar from 0 to 1 if (level && GS_VERSION > '3.33.0') level = level / 100; - Main.osdWindowManager.show(activeIndex, this.enterGicon, label, level, maxLevel); + + let icon = iconName && new Gio.ThemedIcon({ name: iconName }); + Main.osdWindowManager.show(activeIndex, icon || this.enterGicon, label, level, maxLevel); Main.osdWindowManager._osdWindows[activeIndex]._label.get_clutter_text().set_use_markup(true); if (level === 0) { From 7878af7157291f18e8920c7759f3295563bf73d4 Mon Sep 17 00:00:00 2001 From: abakkk Date: Thu, 2 Jan 2020 01:22:25 +0100 Subject: [PATCH 06/43] DEFAULT_FILE_NAME and getDateString() Prepare save and open drawing features. --- draw.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/draw.js b/draw.js index 77d6ac1..9528cbc 100644 --- a/draw.js +++ b/draw.js @@ -47,6 +47,7 @@ const Prefs = Extension.imports.prefs; const _ = imports.gettext.domain(Extension.metadata["gettext-domain"]).gettext; const GS_VERSION = Config.PACKAGE_VERSION; +const DEFAULT_FILE_NAME = 'DrawOnYourScreen'; const FILL_ICON_PATH = Extension.dir.get_child('icons').get_child('fill-symbolic.svg').get_path(); const STROKE_ICON_PATH = Extension.dir.get_child('icons').get_child('stroke-symbolic.svg').get_path(); @@ -64,6 +65,11 @@ var FontWeightNames = { 0: 'Normal', 1: 'Bold' }; var FontStyleNames = { 0: 'Normal', 1: 'Italic', 2: 'Oblique' }; var FontFamilyNames = { 0: 'Default', 1: 'Sans-Serif', 2: 'Serif', 3: 'Monospace', 4: 'Cursive', 5: 'Fantasy' }; +function getDateString() { + let date = GLib.DateTime.new_now_local(); + return `${date.format("%F")} ${date.format("%X")}`; +} + // DrawingArea is the widget in which we draw, thanks to Cairo. // It creates and manages a DrawingElement for each "brushstroke". // It handles pointer/mouse/(touch?) events and some keyboard events. @@ -606,8 +612,7 @@ var DrawingArea = new Lang.Class({ } content += "\n"; - let date = GLib.DateTime.new_now_local(); - let filename = `DrawOnYourScreen ${date.format("%F")} ${date.format("%X")}.svg`; + let filename = `${DEFAULT_FILE_NAME} ${getDateString()}.svg`; let dir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES); let path = GLib.build_filenamev([dir, filename]); if (GLib.file_test(path, GLib.FileTest.EXISTS)) @@ -628,7 +633,7 @@ var DrawingArea = new Lang.Class({ }, saveAsJson: function() { - let filename = `DrawOnYourScreen.json`; + let filename = `${DEFAULT_FILE_NAME}.json`; let dir = GLib.get_user_data_dir(); let path = GLib.build_filenamev([dir, filename]); @@ -652,7 +657,7 @@ var DrawingArea = new Lang.Class({ }, _loadJson: function() { - let filename = `DrawOnYourScreen.json`; + let filename = `${DEFAULT_FILE_NAME}.json`; let dir = GLib.get_user_data_dir(); let path = GLib.build_filenamev([dir, filename]); From 97c8393835a0cf9a6fbe41a8342f9e606682f5c7 Mon Sep 17 00:00:00 2001 From: abakkk Date: Thu, 2 Jan 2020 01:38:57 +0100 Subject: [PATCH 07/43] getActor() utility function Prepare save and open drawing features. --- draw.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/draw.js b/draw.js index 9528cbc..2574636 100644 --- a/draw.js +++ b/draw.js @@ -1030,6 +1030,10 @@ var DrawingHelper = new Lang.Class({ }, }); +function getActor(object) { + return GS_VERSION < '3.33.0' ? object.actor : object; +} + var DrawingMenu = new Lang.Class({ Name: 'DrawOnYourScreenDrawingMenu', @@ -1161,10 +1165,9 @@ var DrawingMenu = new Lang.Class({ _addSwitchItem: function(menu, label, iconFalse, iconTrue, target, targetProperty) { let item = new PopupMenu.PopupSwitchMenuItem(label, target[targetProperty]); - let itemActor = GS_VERSION < '3.33.0' ? item.actor : item; item.icon = new St.Icon({ style_class: 'popup-menu-icon' }); - itemActor.insert_child_at_index(item.icon, 1); + getActor(item).insert_child_at_index(item.icon, 1); item.icon.set_gicon(target[targetProperty] ? iconTrue : iconFalse); item.connect('toggled', (item, state) => { @@ -1183,10 +1186,8 @@ var DrawingMenu = new Lang.Class({ _addSliderItem: function(menu, target, targetProperty) { let item = new PopupMenu.PopupBaseMenuItem({ activate: false }); - let itemActor = GS_VERSION < '3.33.0' ? item.actor : item; let label = new St.Label({ text: target[targetProperty] + " " + _("px"), style_class: 'draw-on-your-screen-menu-slider-label' }); let slider = new Slider.Slider(target[targetProperty] / 50); - let sliderActor = GS_VERSION < '3.33.0' ? slider.actor : slider; if (GS_VERSION < '3.33.0') { slider.connect('value-changed', (slider, value, property) => { @@ -1208,9 +1209,9 @@ var DrawingMenu = new Lang.Class({ }); } - itemActor.add(sliderActor, { expand: true }); - itemActor.add(label); - itemActor.connect('key-press-event', slider.onKeyPressEvent.bind(slider)); + getActor(item).add(getActor(slider), { expand: true }); + getActor(item).add(label); + getActor(item).connect('key-press-event', slider.onKeyPressEvent.bind(slider)); menu.addMenuItem(item); }, @@ -1278,8 +1279,7 @@ var DrawingMenu = new Lang.Class({ _addSeparator: function(menu) { let separatorItem = new PopupMenu.PopupSeparatorMenuItem(' '); - let separatorItemActor = GS_VERSION < '3.33.0' ? separatorItem.actor : separatorItem; - separatorItemActor.add_style_class_name('draw-on-your-screen-menu-separator-item'); + getActor(separatorItem).add_style_class_name('draw-on-your-screen-menu-separator-item'); menu.addMenuItem(separatorItem); } }); From 7c7d75a2bae671a90823d2d6b270c30ac2827921 Mon Sep 17 00:00:00 2001 From: abakkk Date: Thu, 2 Jan 2020 01:44:08 +0100 Subject: [PATCH 08/43] minor, true -> GLib.SOURCE_CONTINUE --- draw.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draw.js b/draw.js index 2574636..85e3603 100644 --- a/draw.js +++ b/draw.js @@ -397,7 +397,7 @@ var DrawingArea = new Lang.Class({ this.cursorTimeoutId = Mainloop.timeout_add(600, () => { this.textHasCursor = !this.textHasCursor; this._redisplay(); - return true; + return GLib.SOURCE_CONTINUE; }); }, From 17bbe345affd79ecead8b060219c75fe7dfb407c Mon Sep 17 00:00:00 2001 From: abakkk Date: Sat, 4 Jan 2020 00:16:20 +0100 Subject: [PATCH 09/43] new "Open" and "Save" drawing features * Use a "drawOnYourScreen" subdir in the xdg user data dir * Info item with the name of the last saved/open json file * "Open drawing" sub menu with data dir content * "Save drawing" sub menu with entry * "Save", "Open previous" and "Open next" keybindings --- draw.js | 311 +++++++++++++++++- extension.js | 11 +- locale/draw-on-your-screen.pot | 18 +- prefs.js | 3 + schemas/gschemas.compiled | Bin 3256 -> 3492 bytes ...extensions.draw-on-your-screen.gschema.xml | 15 + stylesheet.css | 24 ++ 7 files changed, 363 insertions(+), 19 deletions(-) diff --git a/draw.js b/draw.js index 85e3603..e44414c 100644 --- a/draw.js +++ b/draw.js @@ -48,6 +48,7 @@ const _ = imports.gettext.domain(Extension.metadata["gettext-domain"]).gettext; const GS_VERSION = Config.PACKAGE_VERSION; const DEFAULT_FILE_NAME = 'DrawOnYourScreen'; +const DATA_SUB_DIR = 'drawOnYourScreen' const FILL_ICON_PATH = Extension.dir.get_child('icons').get_child('fill-symbolic.svg').get_path(); const STROKE_ICON_PATH = Extension.dir.get_child('icons').get_child('stroke-symbolic.svg').get_path(); @@ -70,6 +71,40 @@ function getDateString() { return `${date.format("%F")} ${date.format("%X")}`; } +function getJsonFiles() { + let directory = Gio.File.new_for_path(GLib.build_filenamev([GLib.get_user_data_dir(), DATA_SUB_DIR])); + if (!directory.query_exists(null)) + return []; + + let jsonFiles = []; + let enumerator; + try { + enumerator = directory.enumerate_children('standard::name,standard::display-name,standard::content-type,time::modified', Gio.FileQueryInfoFlags.NONE, null); + } catch(e) { + return []; + } + + let i = 0; + let fileInfo = enumerator.next_file(null); + while (fileInfo) { + if (fileInfo.get_content_type().indexOf('json') != -1 && fileInfo.get_name() != `${DEFAULT_FILE_NAME}.json`) { + let file = enumerator.get_child(fileInfo); + jsonFiles.push({ name: fileInfo.get_name().slice(0, -5), + displayName: fileInfo.get_display_name().slice(0, -5), + modificationDateTime: fileInfo.get_modification_date_time(), + delete: () => file.delete(null) }); + } + fileInfo = enumerator.next_file(null); + } + enumerator.close(null); + + jsonFiles.sort((a, b) => { + return a.modificationDateTime.difference(b.modificationDateTime); + }); + + return jsonFiles; +} + // DrawingArea is the widget in which we draw, thanks to Cairo. // It creates and manages a DrawingElement for each "brushstroke". // It handles pointer/mouse/(touch?) events and some keyboard events. @@ -79,7 +114,7 @@ var DrawingArea = new Lang.Class({ Signals: { 'show-osd': { param_types: [GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_DOUBLE] }, 'stop-drawing': {} }, - _init: function(params, monitor, helper, loadJson) { + _init: function(params, monitor, helper, loadPersistent) { this.parent({ style_class: 'draw-on-your-screen', name: params && params.name ? params.name : ""}); this.connect('repaint', this._repaint.bind(this)); @@ -99,8 +134,8 @@ var DrawingArea = new Lang.Class({ this.fill = false; this.colors = [Clutter.Color.new(0, 0, 0, 255)]; - if (loadJson) - this._loadJson(); + if (loadPersistent) + this._loadPersistent(); }, get menu() { @@ -591,7 +626,7 @@ var DrawingArea = new Lang.Class({ this._menu.close(); this.get_parent().set_background_color(null); if (save) - this.saveAsJson(); + this.savePersistent(); }, saveAsSvg: function() { @@ -632,10 +667,18 @@ var DrawingArea = new Lang.Class({ } }, - saveAsJson: function() { - let filename = `${DEFAULT_FILE_NAME}.json`; - let dir = GLib.get_user_data_dir(); - let path = GLib.build_filenamev([dir, filename]); + _saveAsJson: function(name, notify) { + // stop drawing or writing + if (this.currentElement && this.currentElement.shape == Shapes.TEXT && this.currentElement.state == TextState.WRITING) { + this._stopWriting(); + } else if (this.currentElement && this.currentElement.shape != Shapes.TEXT) { + this._stopDrawing(); + } + + let dir = GLib.build_filenamev([GLib.get_user_data_dir(), DATA_SUB_DIR]); + if (!GLib.file_test(dir, GLib.FileTest.EXISTS)) + GLib.mkdir_with_parents(dir, 0o700); + let path = GLib.build_filenamev([dir, `${name}.json`]); let oldContents; if (GLib.file_test(path, GLib.FileTest.EXISTS)) { @@ -652,14 +695,30 @@ var DrawingArea = new Lang.Class({ // because of compromise between disk usage and human readability let contents = `[\n ` + new Array(...this.elements.map(element => JSON.stringify(element))).join(`,\n\n `) + `\n]`; - if (contents != oldContents) + if (contents != oldContents) { GLib.file_set_contents(path, contents); + if (notify) + this.emit('show-osd', 'document-save-symbolic', name, -1); + if (name != DEFAULT_FILE_NAME) + this.jsonName = name; + } }, - _loadJson: function() { - let filename = `${DEFAULT_FILE_NAME}.json`; + saveAsJsonWithName: function(name) { + this._saveAsJson(name); + }, + + saveAsJson: function() { + this._saveAsJson(getDateString(), true); + }, + + savePersistent: function() { + this._saveAsJson(DEFAULT_FILE_NAME); + }, + + _loadJson: function(name, notify) { let dir = GLib.get_user_data_dir(); - let path = GLib.build_filenamev([dir, filename]); + let path = GLib.build_filenamev([dir, DATA_SUB_DIR, `${name}.json`]); if (!GLib.file_test(path, GLib.FileTest.EXISTS)) return; @@ -669,6 +728,43 @@ var DrawingArea = new Lang.Class({ if (contents instanceof Uint8Array) contents = imports.byteArray.toString(contents); this.elements.push(...JSON.parse(contents).map(object => new DrawingElement(object))); + + if (notify) + this.emit('show-osd', 'document-open-symbolic', name, -1); + if (name != DEFAULT_FILE_NAME) + this.jsonName = name; + }, + + _loadPersistent: function() { + this._loadJson(DEFAULT_FILE_NAME); + }, + + loadJson: function(name, notify) { + this.elements = []; + this.currentElement = null; + this._stopCursorTimeout(); + this._loadJson(name, notify); + this._redisplay(); + }, + + loadNextJson: function() { + let names = getJsonFiles().map(file => file.name); + + if (!names.length) + return; + + let nextName = names[this.jsonName && names.indexOf(this.jsonName) != names.length - 1 ? names.indexOf(this.jsonName) + 1 : 0]; + this.loadJson(nextName, true); + }, + + loadPreviousJson: function() { + let names = getJsonFiles().map(file => file.name); + + if (!names.length) + return; + + let previousName = names[this.jsonName && names.indexOf(this.jsonName) > 0 ? names.indexOf(this.jsonName) - 1 : names.length - 1]; + this.loadJson(previousName, true); }, disable: function() { @@ -1144,8 +1240,12 @@ var DrawingMenu = new Lang.Class({ this._addSwitchItemWithCallback(this.menu, _("Square drawing area"), this.area.isSquareArea, this.area.toggleSquareArea.bind(this.area)); this._addSeparator(this.menu); - this.menu.addAction(_("Save drawing as a SVG file"), this.area.saveAsSvg.bind(this.area), 'document-save-symbolic'); - this.menu.addAction(_("Open stylesheet.css"), manager.openStylesheetFile.bind(manager), 'document-open-symbolic'); + this._addDrawingNameItem(this.menu); + this._addOpenDrawingSubMenuItem(this.menu); + this._addSaveDrawingSubMenuItem(this.menu); + + this.menu.addAction(_("Save drawing as a SVG file"), this.area.saveAsSvg.bind(this.area), 'image-x-generic-symbolic'); + this.menu.addAction(_("Open stylesheet.css"), manager.openStylesheetFile.bind(manager), 'document-page-setup-symbolic'); this.menu.addAction(_("Show help"), this.area.toggleHelp.bind(this.area), 'preferences-desktop-keyboard-shortcuts-symbolic'); this.updateSectionVisibility(); @@ -1277,6 +1377,105 @@ var DrawingMenu = new Lang.Class({ menu.addMenuItem(item); }, + _addDrawingNameItem: function(menu) { + this.drawingNameMenuItem = new PopupMenu.PopupMenuItem('', { reactive: false, activate: false }); + this.drawingNameMenuItem.setSensitive(false); + menu.addMenuItem(this.drawingNameMenuItem); + this._updateDrawingNameMenuItem(); + }, + + _updateDrawingNameMenuItem: function() { + getActor(this.drawingNameMenuItem).visible = this.area.jsonName ? true : false; + if (this.area.jsonName) { + this.drawingNameMenuItem.label.set_text(`${this.area.jsonName}`); + this.drawingNameMenuItem.label.get_clutter_text().set_use_markup(true); + } + }, + + _addOpenDrawingSubMenuItem: function(menu) { + let item = new PopupMenu.PopupSubMenuMenuItem(_("Open drawing"), true); + this.openDrawingSubMenuItem = item; + this.openDrawingSubMenu = item.menu; + item.icon.set_icon_name('document-open-symbolic'); + + item.menu.itemActivated = () => { + item.menu.close(); + }; + + Mainloop.timeout_add(0, () => { + this._populateOpenDrawingSubMenu(); + return GLib.SOURCE_REMOVE; + }); + menu.addMenuItem(item); + }, + + _populateOpenDrawingSubMenu: function() { + this.openDrawingSubMenu.removeAll(); + let jsonFiles = getJsonFiles(); + jsonFiles.forEach(file => { + let item = this.openDrawingSubMenu.addAction(`${file.displayName}`, () => { + this.area.loadJson(file.name); + this._updateDrawingNameMenuItem(); + this._updateSaveDrawingSubMenuItemSensitivity(); + }); + item.label.get_clutter_text().set_use_markup(true); + + let expander = new St.Bin({ + style_class: 'popup-menu-item-expander', + x_expand: true, + }); + getActor(item).add_child(expander); + + let deleteButton = new St.Button({ style_class: 'draw-on-your-screen-menu-delete-button', + child: new St.Icon({ icon_name: 'edit-delete-symbolic', + style_class: 'popup-menu-icon', + x_align: Clutter.ActorAlign.END }) }); + getActor(item).add_child(deleteButton); + + deleteButton.connect('clicked', () => { + file.delete(); + this._populateOpenDrawingSubMenu(); + }); + }); + + this.openDrawingSubMenuItem.setSensitive(!this.openDrawingSubMenu.isEmpty()); + }, + + _addSaveDrawingSubMenuItem: function(menu) { + let item = new PopupMenu.PopupSubMenuMenuItem(_("Save drawing"), true); + this.saveDrawingSubMenuItem = item; + this._updateSaveDrawingSubMenuItemSensitivity(); + this.saveDrawingSubMenu = item.menu; + item.icon.set_icon_name('document-save-symbolic'); + + item.menu.itemActivated = () => { + item.menu.close(); + }; + + Mainloop.timeout_add(0, () => { + this._populateSaveDrawingSubMenu(); + return GLib.SOURCE_REMOVE; + }); + menu.addMenuItem(item); + }, + + _updateSaveDrawingSubMenuItemSensitivity: function() { + this.saveDrawingSubMenuItem.setSensitive(this.area.elements.length > 0); + }, + + _populateSaveDrawingSubMenu: function() { + this.saveEntry = new DrawingMenuEntry({ initialTextGetter: getDateString, + entryActivateCallback: (text) => { + this.area.saveAsJsonWithName(text); + this.saveDrawingSubMenu.toggle(); + this._updateDrawingNameMenuItem(); + this._populateOpenDrawingSubMenu(); + }, + invalidStrings: [DEFAULT_FILE_NAME, '/'], + primaryIconName: 'insert-text' }); + this.saveDrawingSubMenu.addMenuItem(this.saveEntry.item); + }, + _addSeparator: function(menu) { let separatorItem = new PopupMenu.PopupSeparatorMenuItem(' '); getActor(separatorItem).add_style_class_name('draw-on-your-screen-menu-separator-item'); @@ -1284,3 +1483,87 @@ var DrawingMenu = new Lang.Class({ } }); +// based on searchItem.js, https://github.com/leonardo-bartoli/gnome-shell-extension-Recents +var DrawingMenuEntry = new Lang.Class({ + Name: 'DrawOnYourScreenDrawingMenuEntry', + + _init: function (params) { + this.params = params; + this.item = new PopupMenu.PopupBaseMenuItem({ style_class: 'draw-on-your-screen-menu-entry-item', + activate: false, + reactive: true, + can_focus: false }); + + this.itemActor = GS_VERSION < '3.33.0' ? this.item.actor : this.item; + + this.entry = new St.Entry({ + style_class: 'search-entry draw-on-your-screen-menu-entry', + track_hover: true, + reactive: true, + can_focus: true + }); + + this.entry.set_primary_icon(new St.Icon({ style_class: 'search-entry-icon', + icon_name: this.params.primaryIconName })); + + this.entry.clutter_text.connect('text-changed', this._onTextChanged.bind(this)); + this.entry.clutter_text.connect('activate', this._onTextActivated.bind(this)); + + this.clearIcon = new St.Icon({ + style_class: 'search-entry-icon', + icon_name: 'edit-clear-symbolic' + }); + this.entry.connect('secondary-icon-clicked', this._reset.bind(this)); + + getActor(this.item).add(this.entry, { expand: true }); + getActor(this.item).connect('notify::mapped', (actor) => { + if (actor.mapped) { + this.entry.set_text(this.params.initialTextGetter()); + this.entry.clutter_text.grab_key_focus(); + } + }); + }, + + _setError: function(hasError) { + if (hasError) + this.entry.add_style_class_name('draw-on-your-screen-menu-entry-error'); + else + this.entry.remove_style_class_name('draw-on-your-screen-menu-entry-error'); + }, + + _reset: function() { + this.entry.text = ''; + this.entry.clutter_text.set_cursor_visible(true); + this.entry.clutter_text.set_selection(0, 0); + this._setError(false); + }, + + _onTextActivated: function(clutterText) { + let text = clutterText.get_text(); + if (text.length == 0) + return; + if (this._getIsInvalid()) + return; + this._reset(); + this.params.entryActivateCallback(text); + }, + + _onTextChanged: function(clutterText) { + let text = clutterText.get_text(); + this.entry.set_secondary_icon(text.length ? this.clearIcon : null); + + if (text.length) + this._setError(this._getIsInvalid()); + }, + + _getIsInvalid: function() { + for (let i = 0; i < this.params.invalidStrings.length; i++) { + if (this.entry.text.indexOf(this.params.invalidStrings[i]) != -1) + return true; + } + + return false; + } +}); + + diff --git a/extension.js b/extension.js index 635c99a..7e83e57 100644 --- a/extension.js +++ b/extension.js @@ -113,7 +113,7 @@ var AreaManager = new Lang.Class({ onPersistentSettingChanged: function() { if (this.settings.get_boolean('persistent-drawing')) - this.areas[Main.layoutManager.primaryIndex].saveAsJson(); + this.areas[Main.layoutManager.primaryIndex].savePersistent(); }, updateIndicator: function() { @@ -136,8 +136,8 @@ var AreaManager = new Lang.Class({ let monitor = this.monitors[i]; let container = new St.Widget({ name: 'drawOnYourSreenContainer' + i }); let helper = new Draw.DrawingHelper({ name: 'drawOnYourSreenHelper' + i }, monitor); - let load = i == Main.layoutManager.primaryIndex && this.settings.get_boolean('persistent-drawing'); - let area = new Draw.DrawingArea({ name: 'drawOnYourSreenArea' + i }, monitor, helper, load); + let loadPersistent = i == Main.layoutManager.primaryIndex && this.settings.get_boolean('persistent-drawing'); + let area = new Draw.DrawingArea({ name: 'drawOnYourSreenArea' + i }, monitor, helper, loadPersistent); container.add_child(area); container.add_child(helper); @@ -161,6 +161,9 @@ var AreaManager = new Lang.Class({ 'delete-last-element': this.activeArea.deleteLastElement.bind(this.activeArea), 'smooth-last-element': this.activeArea.smoothLastElement.bind(this.activeArea), 'save-as-svg': this.activeArea.saveAsSvg.bind(this.activeArea), + 'save-as-json': this.activeArea.saveAsJson.bind(this.activeArea), + 'open-previous-json': this.activeArea.loadPreviousJson.bind(this.activeArea), + 'open-next-json': this.activeArea.loadNextJson.bind(this.activeArea), 'toggle-background': this.activeArea.toggleBackground.bind(this.activeArea), 'toggle-square-area': this.activeArea.toggleSquareArea.bind(this.activeArea), 'increment-line-width': () => this.activeArea.incrementLineWidth(1), @@ -223,7 +226,7 @@ var AreaManager = new Lang.Class({ for (let i = 0; i < this.areas.length; i++) this.areas[i].erase(); if (this.settings.get_boolean('persistent-drawing')) - this.areas[Main.layoutManager.primaryIndex].saveAsJson(); + this.areas[Main.layoutManager.primaryIndex].savePersistent(); }, togglePanelAndDockOpacity: function() { diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index e579156..d19a5a8 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: 2019-03-04 16:40+0100\n" +"POT-Creation-Date: 2020-01-03 08:00+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -108,6 +108,12 @@ msgstr "" msgid "Color" msgstr "" +msgid "Open drawing" +msgstr "" + +msgid "Save drawing" +msgstr "" + #: prefs.js msgid "Preferences" @@ -196,6 +202,16 @@ msgstr "" msgid "Square drawing area" msgstr "" +msgid "Open previous drawing" +msgstr "" + +msgid "Open next drawing" +msgstr "" + +# already in draw.js +#msgid "Save drawing" +#msgstr "" + msgid "Save drawing as a SVG file" msgstr "" diff --git a/prefs.js b/prefs.js index 2488cf3..6ec03a4 100644 --- a/prefs.js +++ b/prefs.js @@ -68,6 +68,9 @@ var INTERNAL_KEYBINDINGS = { 'toggle-background': "Add a drawing background", 'toggle-square-area': "Square drawing area", '-separator-5': '', + 'open-previous-json': "Open previous drawing", + 'open-next-json': "Open next drawing", + 'save-as-json': "Save drawing", 'save-as-svg': "Save drawing as a SVG file", 'open-stylesheet': "Open stylesheet.css", 'toggle-help': "Show help" diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index 329554d6b23e75f72fdb56ab41f68bcf99307d8f..563aa40844035c1a4d1fb15785f43c11b6d3142f 100644 GIT binary patch literal 3492 zcmZ`+U2GIp6dsf+e}(cR7N`pN!xorbN+}dmt0+=HOo{~4_#mC#xw|{O5kN^>h8lvSvLrh5eq!=}U#2Ac9crdYvLHxeiJ3G5&-Q?r@dgjc% z=bn4+xkJaZhHDv)uc==>xT~mRw<+5s@Z`%wEo456Yn!!U@R=G-tGP?lZsPY|EezT= zZ3O%gAl*zn!?H&2h5e9MH3>qlI?rnXvB%zXkOE)7(HiHT{o+KL_@0ZTN+D z>Upq_fqw^%eQ~3Xc53=F*)_n?lS?J-)YD7)d>-uvSX{VkA zdl%ROM!L_YX{VcB@Yle}r;qNXoq96-$G}&ChQAwJ+NqiUac~`q%-+81 zQQD~&z`hFH0X#nN=NRqOwXk=A2Y?@sEeY~Q&AbhRj{w)s#9yR8HT{o+&jC-Uaj0n@ z178P5U)VRDXNFk}(m~ z6*c$$68LA}?Q`2taUANouwMt)Oow6N_cv&#=6=V_|zQ#F>p6fcx2~E`crcs z2f(ia9m=1Y{)fSz0h^Vbn)VCetH2gzr>1=zT#p04RoSU&kAXJ>qiJhC=cVSly1}~v zf6v8@v{N&lVek>)`LE8~v{Un3oC2Q*{>m*5_K}+VI0pU|sJra`OMhzS2a{{Hz@i23 z2X#fwx~c~^0&m{D@+tkPIZi8h3vj_d@CohIL7ZS8IPvYldfKTO&oG#M))Tf!`MQgL z3@2j?-OCzz0Z07WI$bMgxP$F3rid9{qc1abNlVAq(?-s+2P^&3m411{5w>nPrf$kq zuij^QR?@O9zxYxC-{;R(O=T&m}4 z(;SIltL;}_`KegAsFab9*4>OY&uoB??7~Y8u(2IekK>3{*!{5APaRh=N@63CF*}yWO5x5VS4@?5kLbQhf zv@jl*;4bDJk1Hp*Ps^6yBP}Ode^0pnoRof6n8>v&d$Ad)D_58j@AFs6d)tnzmG;|* zup;iFXY`?xyi(y!^z)RT<=k3UdQQ6PctzuP8X2)`XC4a;hA$q;l(ePWR1pX2uqk@0 zNt?N#qN*(0u8iAI>lCixiRk#WZLt0JwjBi=t#*NoPn>jhFiP3_G4JYV-qqo}@w^e7 zlLS7{62S*rBKSZ{L?390Dj#SGbRAW}!5W)O`NKTT(LBxJJk^fp|L1X|>~~Oh6Bo6n zay@IJdDfKXDfSnBPnyE(^<`cqf_32qwW8aG=j+%Yc8gNn0?oy)>^D)b!n|eqHml^j zrAoeAqWD_E_*Bw-Hodar8hQF*U6)nR+RAmWjl9=R7&q9Ab%>?3F6_s;=&yCv{97mZ zw?_W0)%@2_@LwPKuMhppubF-k^ztA>rMUXlI+bJ6NcCo1S#XM%Ml@owG9UQAgO$fY z2y<5&PgIU)8Xnt!G!71mB~A1f7L|$Q`l6x`g6QxK6+A(!q#L5SrH>4S@u&vk_3<)` n=JC|?;BL#iqR*0rsLe!v+eF$|byTg#l-7m)+hB%q7lZr{MBgWG literal 3256 zcmZu!U2GIp7#)ymp@8LA3RMe=Y{A*hQVOl96|_P{Ng#+pAE2{4cXx-*&MY&t{R0V6 z5;2MqeUKQ5H73FX2{i$t#z=iJ#Ds(=gy;h#nrNb=4?dU}#B*lv&d+u?IXNe1zq$9j z-@SA1oo%mZj-gqeB7e)kdn-CIQ+hMNvu=%blKEd!=~s?}2O1QmVTq#L!|%(vFqD^+ z3*fH++sP;MmR%G{w;)V2DMmbDxrS}IN!`(gRohZW?Xsh~Sw{$q&nk&0eNvSBz{LGP zBQOVO0@%fTU;(fQSRBDpXyPHDMPfPl;RqguCfb0Nz$%Hyz{KNquo~VPpdDB%u?}3t z_`szcO5oRGfik3wpeAnv%JQG?(x;ve{}lKf@#BeQ^r;uap9EhAj%;uJl|D87DR2`C z@a)K6*XUEvgTD;i1$=Pt_C@;CP4N4{uL94>cxuKMz{i1)zTGv!c^ zlRou>@UMVx0)4U_YPRz`xbXo+d0zU|em>wXV5{`0>Gy*Rz~H|ft!$rqA^fA@lfX6^ zPtEvo@FdVLeQNsGz*B&C=xQI^p=O;Mu`pVIsq63TqEF2_C&1mnygysNqfgCo^@Dc+ zFUa<(+5Q0dD6n1n)b!s6PXG<+FXpfv>ZS0nfN#==$#qZ7b^iJr{=h>fNui(E`M**r}ozacm`gCw?12YgFbZ|;uGL* z;QWr$hv`$#g1;HO7g*8qsqa(M9{?W&-cw(@%6Mwl=P39j@bSBc?$D=Z{%65o1Cu#p zDSc}C*TA=d)8|*&^r^WHr@%AuvK~1$@d&%?NHM{4n6^xyY@drpPKET1z!f5Z#nyZvFXDHXGoGVmJ!OgikW4jeo3@jV zwwn&KO)K+TD#6;2P&HR|hw}09xN zyqsPaqi|3-M`-@=!bq!5-W%h2Zw#Y1R@;r1c~eauo5J`_)p(glM#~Q79lLDll{CW0 zOng1E##yZt{y$jF)1NS*tFGtRgILyyOnWq$uA1?oj$L6ZUDbS|k961M-yOzx*Tg$` zsWgi(jC`qr`FCV~Xp46Up7T!tJm1>^-f30?JnMNk;C+Gjh7|ygTwrgq1W>(qG(+>q;N1kq8=T8ibfHI4c+(|UWQTC|Zq+QnoVcCZguc5~i#b>R+rHgdqc8kTNkHP3dUv+MiQw{4k9 zJdZskEVfGWrtrk{ZByyP^m_u!l2P&{^Kc2D_P%)WI{9_?r-!48%%36Sgri|ORgbCI zIVI#dl`LtVUlcr_!iPZ0{}4#|9|EcHLm*Y>Lm-6{Q*Kc?!!#rPYqEboD@FMq=~4Bg 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 9864222..58fa1ad 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 @@ -206,6 +206,21 @@ Save drawing as a svg file Save drawing as a svg file + + ["<Primary><Shift>s"] + Save drawing as a json file + Save drawing as a json file + + + ["<Primary>Left"] + Open previous json file + Open previous json file + + + ["<Primary>Right"] + Open next json file + Open next json file + ["<Primary>F1"] toggle help diff --git a/stylesheet.css b/stylesheet.css index 3e96dd6..6437e87 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -115,5 +115,29 @@ min-width: 3em; text-align: right; } + +.draw-on-your-screen-menu-entry-item { + padding-right: 1.15em; /* default 1.75em */ + spacing: 0; /* default 12px */ +} + +.draw-on-your-screen-menu-entry { + border: none; + border-radius: 3px; + padding: 0.35em 0.57em; + width: 10em; +} + +.draw-on-your-screen-menu-entry-error { + color: #f57900; /* upstream warning_color */ +} + +.draw-on-your-screen-menu-entry:focus { + padding: 0.35em 0.57em; +} + +.draw-on-your-screen-menu-delete-button:hover { + color: #f57900; +} From ec2348b1ec526396aaf0766a44d945c9aeaaadc6 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sat, 4 Jan 2020 12:50:43 +0100 Subject: [PATCH 10/43] Add asterisk to the drawing name item if the drawing has changed since last save or open operation --- draw.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/draw.js b/draw.js index e44414c..1723807 100644 --- a/draw.js +++ b/draw.js @@ -701,6 +701,7 @@ var DrawingArea = new Lang.Class({ this.emit('show-osd', 'document-save-symbolic', name, -1); if (name != DEFAULT_FILE_NAME) this.jsonName = name; + this.lastJsonContents = contents; } }, @@ -733,6 +734,7 @@ var DrawingArea = new Lang.Class({ this.emit('show-osd', 'document-open-symbolic', name, -1); if (name != DEFAULT_FILE_NAME) this.jsonName = name; + this.lastJsonContents = contents; }, _loadPersistent: function() { @@ -767,6 +769,11 @@ var DrawingArea = new Lang.Class({ this.loadJson(previousName, true); }, + get drawingContentsHasChanged() { + let contents = `[\n ` + new Array(...this.elements.map(element => JSON.stringify(element))).join(`,\n\n `) + `\n]`; + return contents != this.lastJsonContents; + }, + disable: function() { this.erase(); this.menu.disable(); @@ -1387,7 +1394,8 @@ var DrawingMenu = new Lang.Class({ _updateDrawingNameMenuItem: function() { getActor(this.drawingNameMenuItem).visible = this.area.jsonName ? true : false; if (this.area.jsonName) { - this.drawingNameMenuItem.label.set_text(`${this.area.jsonName}`); + let prefix = this.area.drawingContentsHasChanged ? "* " : ""; + this.drawingNameMenuItem.label.set_text(`${prefix}${this.area.jsonName}`); this.drawingNameMenuItem.label.get_clutter_text().set_use_markup(true); } }, From 5997c9cba3fce946320ee78e0b8366d85aa2b828 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sat, 4 Jan 2020 12:58:05 +0100 Subject: [PATCH 11/43] small trick to prevent the menu from "jumping" on first opening --- draw.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/draw.js b/draw.js index 1723807..88abd4f 100644 --- a/draw.js +++ b/draw.js @@ -1412,6 +1412,9 @@ var DrawingMenu = new Lang.Class({ Mainloop.timeout_add(0, () => { this._populateOpenDrawingSubMenu(); + // small trick to prevent the menu from "jumping" on first opening + item.menu.open(); + item.menu.close(); return GLib.SOURCE_REMOVE; }); menu.addMenuItem(item); @@ -1462,6 +1465,9 @@ var DrawingMenu = new Lang.Class({ Mainloop.timeout_add(0, () => { this._populateSaveDrawingSubMenu(); + // small trick to prevent the menu from "jumping" on first opening + item.menu.open(); + item.menu.close(); return GLib.SOURCE_REMOVE; }); menu.addMenuItem(item); From 04b119557f7819de2035f41ce670c6da15c9196f Mon Sep 17 00:00:00 2001 From: abakkk Date: Sat, 4 Jan 2020 16:07:53 +0100 Subject: [PATCH 12/43] fix commit ec2348b1e (drawingContentsHasChanged) --- draw.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/draw.js b/draw.js index 88abd4f..9aeadad 100644 --- a/draw.js +++ b/draw.js @@ -699,9 +699,10 @@ var DrawingArea = new Lang.Class({ GLib.file_set_contents(path, contents); if (notify) this.emit('show-osd', 'document-save-symbolic', name, -1); - if (name != DEFAULT_FILE_NAME) + if (name != DEFAULT_FILE_NAME) { this.jsonName = name; - this.lastJsonContents = contents; + this.lastJsonContents = contents; + } } }, @@ -732,9 +733,10 @@ var DrawingArea = new Lang.Class({ if (notify) this.emit('show-osd', 'document-open-symbolic', name, -1); - if (name != DEFAULT_FILE_NAME) + if (name != DEFAULT_FILE_NAME) { this.jsonName = name; - this.lastJsonContents = contents; + this.lastJsonContents = contents; + } }, _loadPersistent: function() { From 74f602b2685f8d6827bf8be0c35c0eeef6fec7af Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 5 Jan 2020 12:36:42 +0100 Subject: [PATCH 13/43] fix cursor update when closing the menu from save entry St.Entry clutter_text set the DEFAULT cursor on leave event with a delay and overrides the cursor set by area.updatePointerCursor(). In order to update drawing cursor on menu closed, we need to leave the saveEntry before closing menu. Since escape key press event can't be captured easily, the job is done in the menu close function. --- draw.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/draw.js b/draw.js index 9aeadad..c13e0ef 100644 --- a/draw.js +++ b/draw.js @@ -1158,6 +1158,18 @@ var DrawingMenu = new Lang.Class({ this.menu.itemActivated = () => {}; this.menu.connect('open-state-changed', this._onMenuOpenStateChanged.bind(this)); + // Case where the menu is closed (escape key) while the save entry clutter_text is active: + // St.Entry clutter_text set the DEFAULT cursor on leave event with a delay and + // overrides the cursor set by area.updatePointerCursor(). + // In order to update drawing cursor on menu closed, we need to leave the saveEntry before closing menu. + // Since escape key press event can't be captured easily, the job is done in the menu close function. + let menuCloseFunc = this.menu.close; + this.menu.close = (animate) => { + if (this.saveDrawingSubMenu.isOpen) + this.saveDrawingSubMenu.close(); + menuCloseFunc.bind(this.menu)(animate); + }; + this.strokeIcon = new Gio.FileIcon({ file: Gio.File.new_for_path(STROKE_ICON_PATH) }); this.fillIcon = new Gio.FileIcon({ file: Gio.File.new_for_path(FILL_ICON_PATH) }); this.linejoinIcon = new Gio.FileIcon({ file: Gio.File.new_for_path(LINEJOIN_ICON_PATH) }); @@ -1179,6 +1191,7 @@ var DrawingMenu = new Lang.Class({ this.area.updatePointerCursor(); // actionMode has changed, set previous actionMode in order to keep internal shortcuts working Main.actionMode = ExtensionJs.DRAWING_ACTION_MODE | Shell.ActionMode.NORMAL; + this.area.grab_key_focus(); } }, From 5b1816d29adb5aa439689bf9f722eb8fdaedc277 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 5 Jan 2020 12:40:35 +0100 Subject: [PATCH 14/43] change some keybindings * increment/decrement line width more: `Primary + Page_Up/Down` --> `Primary + Shift + KP_Add/Subtract` * open previous/next json: `Primary + Left/Right` --> `Primary + Page_Up/Down` * save drawing as svg file: `Primary + S` --> `Primary + Shift + S` * save drawing: `Primary + Shift + S` --> `Primary + S` --- schemas/gschemas.compiled | Bin 3492 -> 3524 bytes ...extensions.draw-on-your-screen.gschema.xml | 12 ++++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index 563aa40844035c1a4d1fb15785f43c11b6d3142f..b02d63a6b6e109af942dfcd432c7dacc44156b03 100644 GIT binary patch delta 1218 zcmZXTUr19?9LJB=*4(_hGD~wp^$;^!f3SxnGb<~zgbfqKhuqXztLa^L(~Qbl_7F&6 zt#CqOS>OV}i6t0e6C@-U*h>w1QShN4LnulJv+wtMsfR9n@Aq@R_jk_u-FxnRnlqWx zRVs~30>>#4gHH}ub|eM6^+H_um2XK$PF^QkL=-*&wUt@sn3LBdPr$!H1231%%*m`b ztPw(jdWW{k%*iI?S@7*p-sfEg=H#`=i{TFFj;%Tv=M7$@XtC1(*3y|ffMPW`(MJ`g%0OWPl9Ar+;M!p+f4jpctpJq;$ zkUN8bcIe~47WLJU`RcmhkD;&6ci!LtG6zKAlh6@uA~N#?d=ZLWYcuhQ$vWi1C`3L~ zqScdGUkrCb!M2;xhg^Uc?6e);4;|G8kky6Z(@?F|y@&N=?)@kDJkm%?fs8q|z%oFfM z=!BM&nHy4tutH^8PL@QlMeGAqL9qtU1};qIllkD+p}>`R33DYf9ux QO(H|>Fs@Gz-IvUN00>wCy8r+H delta 1167 zcmYk5T}V@50ER!UnQk6k_QTABlysrgDya)E%%WEQV4#ICEOJZE=4dwDj<%?FBDEL zqmsaVsV)CW2m*WR=wbc_xA>)YjU4EKb z2+R#7(JzqLv5`ykn6a>&FhCL7?F&^wGm*!1ya zj;})75iN9W>JCr91MW149z>4l6UdwpMJJInxW7GtE=<!m02-!X-r zMSgW|%{)pnA7u*t1u=j0|K)fx?-0%|BnQ4qitlD#E(y$+%Yv>zZmxWK$O&XFRE4fb z=G6WKJvp;cw2Dl=x^AH-b3FfY+v!)Vh%*t( zY0WlPpXl(o)S7@Oisa{Qk7!0?q%WsH3MgKsUA4CRygq+r;#8hBtF+1KR@!X7^XG6G rT=D-Q`$QsUyqCQuAWV^yl3ZBbdecrement the line width - ["<Primary>Page_Up"] + ["<Primary><Shift>KP_Add"] increment the line width even more increment the line width even more - ["<Primary>Page_Down"] + ["<Primary><Shift>KP_Subtract"] decrement the line width even more decrement the line width even more @@ -202,22 +202,22 @@ open stylesheet - ["<Primary>s"] + ["<Primary><Shift>s"] Save drawing as a svg file Save drawing as a svg file - ["<Primary><Shift>s"] + ["<Primary>s"] Save drawing as a json file Save drawing as a json file - ["<Primary>Left"] + ["<Primary>Page_Down"] Open previous json file Open previous json file - ["<Primary>Right"] + ["<Primary>Page_Up"] Open next json file Open next json file From 8f3fbe7aa95da25ad039f61913bb88999ed8595e Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 5 Jan 2020 13:42:05 +0100 Subject: [PATCH 15/43] replace 'smoothed-stroke' pref with 'Ctrl' key modifier --- draw.js | 4 +--- locale/draw-on-your-screen.pot | 10 ++------- prefs.js | 20 +++++------------- schemas/gschemas.compiled | Bin 3524 -> 3448 bytes ...extensions.draw-on-your-screen.gschema.xml | 5 ----- 5 files changed, 8 insertions(+), 31 deletions(-) diff --git a/draw.js b/draw.js index c13e0ef..5112071 100644 --- a/draw.js +++ b/draw.js @@ -311,8 +311,6 @@ var DrawingArea = new Lang.Class({ this._stopDrawing(); }); - this.smoothedStroke = this.settings.get_boolean('smoothed-stroke'); - this.currentElement = new DrawingElement ({ shape: this.currentShape, color: this.currentColor.to_string(), @@ -383,7 +381,7 @@ var DrawingArea = new Lang.Class({ if (!this.currentElement) return; if (this.currentElement.shape == Shapes.NONE) - this.currentElement.addPoint(x, y, this.smoothedStroke); + this.currentElement.addPoint(x, y, controlPressed); else if ((this.currentElement.shape == Shapes.RECTANGLE || this.currentElement.shape == Shapes.TEXT) && (controlPressed || this.currentElement.transform.active)) this.currentElement.transformRectangle(x, y); else if (this.currentElement.shape == Shapes.ELLIPSE && (controlPressed || this.currentElement.transform.active)) diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index d19a5a8..133392b 100644 --- a/locale/draw-on-your-screen.pot +++ b/locale/draw-on-your-screen.pot @@ -313,15 +313,9 @@ msgid "" "By pressing Ctrl key during the drawing process, you can:\n" " . rotate a rectangle or a text area\n" " . extend and rotate an ellipse\n" -" . curve a line (cubic Bezier curve)" -msgstr "" +" . curve a line (cubic Bezier curve)\n" +" . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)" -msgid "Smooth stroke during the drawing process" -msgstr "" - -msgid "" -"You can also smooth the stroke afterward\n" -"See “%s”" msgstr "" msgid "Change the style" diff --git a/prefs.js b/prefs.js index 6ec03a4..42fa58b 100644 --- a/prefs.js +++ b/prefs.js @@ -274,27 +274,17 @@ var PrefsPage = new GObject.Class({ let controlBox = new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN, margin_bottom:MARGIN }); let controlLabel = new Gtk.Label({ use_markup: true, - label: _("By pressing Ctrl key during the drawing process, you can:\n . rotate a rectangle or a text area\n . extend and rotate an ellipse\n . curve a line (cubic Bezier curve)") + label: _("By pressing Ctrl key during the drawing process, you can:\n" + + " . rotate a rectangle or a text area\n" + + " . extend and rotate an ellipse\n" + + " . curve a line (cubic Bezier curve)\n" + + " . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)").format(_("Smooth last brushstroke")) }); controlLabel.set_halign(1); controlLabel.get_style_context().add_class("dim-label"); controlBox.pack_start(controlLabel, true, true, 4); listBox.add(controlBox); - let smoothBox = new Gtk.Box({ margin: MARGIN }); - let smoothLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); - let smoothLabel1 = new Gtk.Label({label: _("Smooth stroke during the drawing process")}); - let smoothLabel2 = new Gtk.Label({ use_markup: true, halign: 1, label: "" + _("You can also smooth the stroke afterward\nSee “%s”").format(_("Smooth last brushstroke")) + "" }); - smoothLabel1.set_halign(1); - smoothLabel2.get_style_context().add_class("dim-label"); - smoothLabelBox.pack_start(smoothLabel1, true, true, 0); - smoothLabelBox.pack_start(smoothLabel2, true, true, 0); - let smoothSwitch = new Gtk.Switch({valign: 3}); - this.settings.bind("smoothed-stroke", smoothSwitch, "active", 0); - smoothBox.pack_start(smoothLabelBox, true, true, 4); - smoothBox.pack_start(smoothSwitch, false, false, 4); - listBox.add(smoothBox); - let internalKeybindingsWidget = new KeybindingsWidget(INTERNAL_KEYBINDINGS, this.settings); internalKeybindingsWidget.margin = MARGIN; listBox.add(internalKeybindingsWidget); diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index b02d63a6b6e109af942dfcd432c7dacc44156b03..40539055c244f546c1590cfddd7a22af81b2c755 100644 GIT binary patch literal 3448 zcmZu!U2GIp7#)PlKa_upMGFXQf!U>$LNQQNtw0fz5`t-bkk0Ph-JN!JW}TVsA4vR5 zY=Ro}MKBUECQ=g;ny3VfMo5eyCYZjcL|-s5iVu=Lkccse=iI%!GrM$>({p;}o9}-2 z&YipW?s?YmEW-&jbu9;X7j^6bdXB;;t;(k`xc3cbw!tpKF@#Cgv4Ct<-54irScA{V%(-a;A zPX}fIa{xA53oHN@0*irVKpn6`p&mRL9)?de0IPu23Twc`qrh5Vox*xB5d#{54ZucV z6L9X^S+D9~j>&wjUmFEq0?vK+=5qSfi{X!he+T;hZLX(Jy%7E#@Jw{>p}G%_(x;vV zzZSd-sA>9m7Jcfa@LR#1z}YYE*3zeDo*u9Ot_H_HrB6+N5d1dq?w1F~=ua9g zeQLhPtE*!@XNsEw6&D+)Qmp~{sg$4Ymo8OjK2u}9yqqI{x`-`v!0va zsaQzn4?ia78#VJR2d@Msems7F@zfmW&ER(6^$#~(r%&AgKMNiL-qN4DMxUDNzzFyh z(D-L!27PLd=NR}3P+C8!xqf~F<{BEfnT#!T+j2y&YdPA^F3-vt-cVaFx)U?}M$5s< znG;SRWAp*b46?{jj(fW6aJy+@ZDg>@=D$!dJfQNST|R@P}wQs-9nc(l%~VY^#P?MCZt zsj9OjjBhE$dqPg9@XpSISt}j14dd&o9;Lzp5_0o`Z#C;2Eg^dj(c#;%x@_0xKtChjg{+(M|-|+^EkYtR$FZp0!raht@E< zwN!VspF67hxg(6<{&crMln4qeCPEK4u7_tTCp$N)(-O9XjY-Lz6Q8~_1aj@3|IEG+f%-?AK-WSgg+|OfMEzbei zrfM4jY|rHWoo9tdfRzBYB=?;q7Qy3Lg6AQgC3rsISpnNAc^2Ur16xgbu2=`25AeLe XbHgTJEzkfo0=zZ=JjYDsKe+w}vpp#H literal 3524 zcmZu!Yitx%6dsgnc@)Y+yD}=@0D#>&p6oqlh zU=A}S5KegzsEuJ3I5AsdE+kVaV;=bY80x`^#Q;*T0N1`8SOKgARs)X#j{{EtYk?%t z05k$m0V=?}iJGP_XEPS-vP2nBCLpf^AHTQ%7WL!{p}zw;>j6c1_f+E~_2jFdUkAAb zsJ9LbQBOV>`Yy=b!2FSCny4qIpFCs%=v%j~g?jRN&>w<42K4{ioS>eZ_G6HjfP*^{ zH>f9H4E-eJpTOyF@77aKPWxIEyAC*cc8yIv`5fq%LN)>ozo%=dCtm>lX2@>fsQTJf z>dEIr-vhZ1_^juAFZJZKKMZ*Sxc&2yZtBUI|0v`IV9)XMUr5s(^UU3V zJdQ(g=7-sD)1I7hM#K;oZ-OFcR3&jYpq zFuV6YM?Lv6=+{B+1fCzdIYB*n9rQhrhk##CuMX-)&boa7c?!67F7+1e$!R|Zc^P;? z`XQ%&67mi({>H&Mykq1w(DSf21D(>Ioc5a`dw_%QjD14?vAC9 z1pNJ1JEqb2$9sh2H(!nq}R55wO1<`=5VE5Z>621S;AB` zOILL}+pi87o{=$3!!P|R=07igXL~R;JS}4iJ@A~&G&sWb3=a+8SJ~_hD~Bi0+m5hQ z3!^~o^XyX75A*HPa$@gp2OAR0+S^yuT%iJ5;5!!IlJRwc2~uDv)3Ag(Xy|?(wxQpb zyY}uXW_(x6`e^p_ZCJXI)qLBXmba`G29^{4erpqYKrE%8ke)wmmI@x)8RdF#jlpva zKH-PYZTVboo@FE1YWwC$JDCd?mDQYRJ^ht_f<;&JV@f;Jf^CvBtr6f{dl*OooPlU@ z=qaT+hHItV4{+Wt1Qr2L1DuoP*_Z%d1*`$$voVS9oVBIqNZcg1H)7exGev(fa$!>o3^0pBFl6?b`j=44f}l=r(@OPgwW% zU3sI|?-;>~xQm`Pfb-;q2Qakrq+i3DexB5V?M}U4(l3tJ7F|b41LviSnYB&ZZJLq? z44a~?nv{9VDo&MQnw5ELG9Te;o`|kd`xevhXx~-D73&bF_|&lLOJSo(h`T=ew!R!U zlqKg4N{;xw1zRJ)$Baz?+1>KR_w z#I)6Ii0lzB_H9ELuheh&eyIzu-?trE5S|Y&I5VoLdA^FRV%G@s7icvmUK?UpJ?dRJ zPqDh|RqEbSrS2_Jwk_rSWbu49!PvEpEdBENj-92AvGa^|Z;Y%rPVpOT$|mFzt_${? zqHmk3*|$!yZ;k9*tJ$|rv2Tm)+sgLwu`?))TweZ%5#}{0*C`D%TDCvu+C{50L?Vxw z%6i~`3B$pKDAz9ZCo28vn#VB^`N4%TY#s0Z++ZEW^+m-&pfNt3!4tGhnjxEM{bZz^ zk8C8~0Eb%?N1kI(_M2ejIj$Hm>|)e)V)nt@>$C?gv|Glk)_>yuv7c->rFAf}qWllp CwlQ%4 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 5847658..1236d96 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 @@ -1,11 +1,6 @@ - - false - smoothed stroke - smoothed stroke - false move drawing on desktop From bc5acc747260866e1727164b5ba0b26cda6daa67 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 5 Jan 2020 14:50:38 +0100 Subject: [PATCH 16/43] change prefs order and style --- locale/draw-on-your-screen.pot | 2 +- prefs.js | 36 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index 133392b..1f51583 100644 --- a/locale/draw-on-your-screen.pot +++ b/locale/draw-on-your-screen.pot @@ -288,7 +288,7 @@ msgstr "" msgid "Drawing on the desktop" msgstr "" -msgid "Draw On Your Screen becomes Draw On Your Desktop" +msgid "Draw On Your Screen becomes Draw On Your Desktop" msgstr "" msgid "Persistent" diff --git a/prefs.js b/prefs.js index 42fa58b..a5a801a 100644 --- a/prefs.js +++ b/prefs.js @@ -196,21 +196,7 @@ var PrefsPage = new GObject.Class({ globalKeybindingsWidget.margin = MARGIN; listBox.add(globalKeybindingsWidget); - let desktopBox = new Gtk.Box({ margin: MARGIN }); - let desktopLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); - let desktopLabel1 = new Gtk.Label({label: _("Drawing on the desktop")}); - let desktopLabel2 = new Gtk.Label({ use_markup: true, halign: 1, label: "" + _("Draw On Your Screen becomes Draw On Your Desktop") + "" }); - desktopLabel1.set_halign(1); - desktopLabel2.get_style_context().add_class("dim-label"); - desktopLabelBox.pack_start(desktopLabel1, true, true, 0); - desktopLabelBox.pack_start(desktopLabel2, true, true, 0); - let desktopSwitch = new Gtk.Switch({valign: 3}); - this.settings.bind("drawing-on-desktop", desktopSwitch, "active", 0); - desktopBox.pack_start(desktopLabelBox, true, true, 4); - desktopBox.pack_start(desktopSwitch, false, false, 4); - listBox.add(desktopBox); - - let persistentBox = new Gtk.Box({ margin: MARGIN }); + let persistentBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); let persistentLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); let persistentLabel1 = new Gtk.Label({label: _("Persistent")}); let persistentLabel2 = new Gtk.Label({ use_markup: true, halign: 1, label: "" + _("Persistent drawing through session restart") + "" }); @@ -224,7 +210,21 @@ var PrefsPage = new GObject.Class({ persistentBox.pack_start(persistentSwitch, false, false, 4); listBox.add(persistentBox); - let osdBox = new Gtk.Box({ margin: MARGIN }); + let desktopBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); + let desktopLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); + let desktopLabel1 = new Gtk.Label({label: _("Drawing on the desktop")}); + let desktopLabel2 = new Gtk.Label({ use_markup: true, halign: 1, label: "" + _("Draw On Your Screen becomes Draw On Your Desktop") + "" }); + desktopLabel1.set_halign(1); + desktopLabel2.get_style_context().add_class("dim-label"); + desktopLabelBox.pack_start(desktopLabel1, true, true, 0); + desktopLabelBox.pack_start(desktopLabel2, true, true, 0); + let desktopSwitch = new Gtk.Switch({valign: 3}); + this.settings.bind("drawing-on-desktop", desktopSwitch, "active", 0); + desktopBox.pack_start(desktopLabelBox, true, true, 4); + desktopBox.pack_start(desktopSwitch, false, false, 4); + listBox.add(desktopBox); + + let osdBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); let osdLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); let osdLabel1 = new Gtk.Label({label: _("Disable on-screen notifications")}); osdLabel1.set_halign(1); @@ -235,7 +235,7 @@ var PrefsPage = new GObject.Class({ osdBox.pack_start(osdSwitch, false, false, 4); listBox.add(osdBox); - let indicatorBox = new Gtk.Box({ margin: MARGIN }); + let indicatorBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); let indicatorLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); let indicatorLabel1 = new Gtk.Label({label: _("Disable panel indicator")}); indicatorLabel1.set_halign(1); @@ -245,6 +245,8 @@ var PrefsPage = new GObject.Class({ indicatorBox.pack_start(indicatorLabelBox, true, true, 4); indicatorBox.pack_start(indicatorSwitch, false, false, 4); listBox.add(indicatorBox); + + listBox.add(new Gtk.Box({ margin_bottom: MARGIN, margin_left: MARGIN, margin_right: MARGIN })); this.addSeparator(listBox); let internalTitleBox = new Gtk.Box({ margin: MARGIN }); From f4ff709fd3dab7ac5a11b19b2a90f23c6a1209b2 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 5 Jan 2020 15:44:51 +0100 Subject: [PATCH 17/43] change imports * Extension -> Me * ExtensionJs -> Extension * Use ExtensionUtils instead of convenience with GS 3.32+ --- draw.js | 36 ++++++++++++++++++------------------ extension.js | 23 ++++++++++++----------- prefs.js | 8 ++++---- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/draw.js b/draw.js index 5112071..a0f3fd6 100644 --- a/draw.js +++ b/draw.js @@ -40,22 +40,22 @@ const Screenshot = imports.ui.screenshot; const Tweener = imports.ui.tweener; const ExtensionUtils = imports.misc.extensionUtils; -const Extension = ExtensionUtils.getCurrentExtension(); -const Convenience = Extension.imports.convenience; -const ExtensionJs = Extension.imports.extension; -const Prefs = Extension.imports.prefs; -const _ = imports.gettext.domain(Extension.metadata["gettext-domain"]).gettext; +const Me = ExtensionUtils.getCurrentExtension(); +const Convenience = ExtensionUtils.getSettings ? ExtensionUtils : Me.imports.convenience; +const Extension = Me.imports.extension; +const Prefs = Me.imports.prefs; +const _ = imports.gettext.domain(Me.metadata["gettext-domain"]).gettext; const GS_VERSION = Config.PACKAGE_VERSION; const DEFAULT_FILE_NAME = 'DrawOnYourScreen'; const DATA_SUB_DIR = 'drawOnYourScreen' -const FILL_ICON_PATH = Extension.dir.get_child('icons').get_child('fill-symbolic.svg').get_path(); -const STROKE_ICON_PATH = Extension.dir.get_child('icons').get_child('stroke-symbolic.svg').get_path(); -const LINEJOIN_ICON_PATH = Extension.dir.get_child('icons').get_child('linejoin-symbolic.svg').get_path(); -const LINECAP_ICON_PATH = Extension.dir.get_child('icons').get_child('linecap-symbolic.svg').get_path(); -const DASHED_LINE_ICON_PATH = Extension.dir.get_child('icons').get_child('dashed-line-symbolic.svg').get_path(); -const FULL_LINE_ICON_PATH = Extension.dir.get_child('icons').get_child('full-line-symbolic.svg').get_path(); +const FILL_ICON_PATH = Me.dir.get_child('icons').get_child('fill-symbolic.svg').get_path(); +const STROKE_ICON_PATH = Me.dir.get_child('icons').get_child('stroke-symbolic.svg').get_path(); +const LINEJOIN_ICON_PATH = Me.dir.get_child('icons').get_child('linejoin-symbolic.svg').get_path(); +const LINECAP_ICON_PATH = Me.dir.get_child('icons').get_child('linecap-symbolic.svg').get_path(); +const DASHED_LINE_ICON_PATH = Me.dir.get_child('icons').get_child('dashed-line-symbolic.svg').get_path(); +const FULL_LINE_ICON_PATH = Me.dir.get_child('icons').get_child('full-line-symbolic.svg').get_path(); var Shapes = { NONE: 0, LINE: 1, ELLIPSE: 2, RECTANGLE: 3, TEXT: 4 }; var TextState = { DRAWING: 0, WRITING: 1 }; @@ -406,7 +406,7 @@ var DrawingArea = new Lang.Class({ setPointerCursor: function(pointerCursorName) { if (!this.currentPointerCursorName || this.currentPointerCursorName != pointerCursorName) { this.currentPointerCursorName = pointerCursorName; - ExtensionJs.setCursor(pointerCursorName); + Extension.setCursor(pointerCursorName); } }, @@ -1188,7 +1188,7 @@ var DrawingMenu = new Lang.Class({ } else { this.area.updatePointerCursor(); // actionMode has changed, set previous actionMode in order to keep internal shortcuts working - Main.actionMode = ExtensionJs.DRAWING_ACTION_MODE | Shell.ActionMode.NORMAL; + Main.actionMode = Extension.DRAWING_ACTION_MODE | Shell.ActionMode.NORMAL; this.area.grab_key_focus(); } }, @@ -1254,7 +1254,7 @@ var DrawingMenu = new Lang.Class({ this.menu.addMenuItem(fontSection); this.fontSection = fontSection; - let manager = ExtensionJs.manager; + let manager = Extension.manager; this._addSwitchItemWithCallback(this.menu, _("Hide panel and dock"), manager.hiddenList ? true : false, manager.togglePanelAndDockOpacity.bind(manager)); this._addSwitchItemWithCallback(this.menu, _("Add a drawing background"), this.area.hasBackground, this.area.toggleBackground.bind(this.area)); this._addSwitchItemWithCallback(this.menu, _("Square drawing area"), this.area.isSquareArea, this.area.toggleSquareArea.bind(this.area)); @@ -1314,18 +1314,18 @@ var DrawingMenu = new Lang.Class({ target[targetProperty] = Math.max(Math.round(value * 50), 0); label.set_text(target[targetProperty] + " px"); if (target[targetProperty] === 0) - label.add_style_class_name(ExtensionJs.WARNING_COLOR_STYLE_CLASS_NAME); + label.add_style_class_name(Extension.WARNING_COLOR_STYLE_CLASS_NAME); else - label.remove_style_class_name(ExtensionJs.WARNING_COLOR_STYLE_CLASS_NAME); + label.remove_style_class_name(Extension.WARNING_COLOR_STYLE_CLASS_NAME); }); } else { slider.connect('notify::value', () => { target[targetProperty] = Math.max(Math.round(slider.value * 50), 0); label.set_text(target[targetProperty] + " px"); if (target[targetProperty] === 0) - label.add_style_class_name(ExtensionJs.WARNING_COLOR_STYLE_CLASS_NAME); + label.add_style_class_name(Extension.WARNING_COLOR_STYLE_CLASS_NAME); else - label.remove_style_class_name(ExtensionJs.WARNING_COLOR_STYLE_CLASS_NAME); + label.remove_style_class_name(Extension.WARNING_COLOR_STYLE_CLASS_NAME); }); } diff --git a/extension.js b/extension.js index 7e83e57..c621f77 100644 --- a/extension.js +++ b/extension.js @@ -31,10 +31,11 @@ const Main = imports.ui.main; const OsdWindow = imports.ui.osdWindow; const PanelMenu = imports.ui.panelMenu; -const Extension = imports.misc.extensionUtils.getCurrentExtension(); -const Convenience = Extension.imports.convenience; -const Draw = Extension.imports.draw; -const _ = imports.gettext.domain(Extension.metadata["gettext-domain"]).gettext; +const ExtensionUtils = imports.misc.extensionUtils; +const Me = ExtensionUtils.getCurrentExtension(); +const Convenience = ExtensionUtils.getSettings && ExtensionUtils.initTranslations ? ExtensionUtils : Me.imports.convenience; +const Draw = Me.imports.draw; +const _ = imports.gettext.domain(Me.metadata["gettext-domain"]).gettext; const GS_VERSION = Config.PACKAGE_VERSION; @@ -92,14 +93,14 @@ var AreaManager = new Lang.Class({ this.desktopSettingHandler = this.settings.connect('changed::drawing-on-desktop', this.onDesktopSettingChanged.bind(this)); this.persistentSettingHandler = this.settings.connect('changed::persistent-drawing', this.onPersistentSettingChanged.bind(this)); - if (Extension.stylesheet) { - this.stylesheetMonitor = Extension.stylesheet.monitor(Gio.FileMonitorFlags.NONE, null); + if (Me.stylesheet) { + this.stylesheetMonitor = Me.stylesheet.monitor(Gio.FileMonitorFlags.NONE, null); this.stylesheetChangedHandler = this.stylesheetMonitor.connect('changed', (monitor, file, otherFile, eventType) => { - if ((eventType != 0 && eventType != 3) || !Extension.stylesheet.query_exists(null)) + if ((eventType != 0 && eventType != 3) || !Me.stylesheet.query_exists(null)) return; let theme = St.ThemeContext.get_for_stage(global.stage).get_theme(); - theme.unload_stylesheet(Extension.stylesheet); - theme.load_stylesheet(Extension.stylesheet); + theme.unload_stylesheet(Me.stylesheet); + theme.load_stylesheet(Me.stylesheet); }); } }, @@ -216,8 +217,8 @@ var AreaManager = new Lang.Class({ }, openStylesheetFile: function() { - if (Extension.stylesheet && Extension.stylesheet.query_exists(null)) - Gio.AppInfo.launch_default_for_uri(Extension.stylesheet.get_uri(), global.create_app_launch_context(0, -1)); + if (Me.stylesheet && Me.stylesheet.query_exists(null)) + Gio.AppInfo.launch_default_for_uri(Me.stylesheet.get_uri(), global.create_app_launch_context(0, -1)); if (this.activeArea) this.toggleDrawing(); }, diff --git a/prefs.js b/prefs.js index a5a801a..0f4cde7 100644 --- a/prefs.js +++ b/prefs.js @@ -26,10 +26,10 @@ const Lang = imports.lang; const Mainloop = imports.mainloop; const ExtensionUtils = imports.misc.extensionUtils; -const Extension = ExtensionUtils.getCurrentExtension(); -const Convenience = Extension.imports.convenience; -const Metadata = Extension.metadata; -const _ = imports.gettext.domain(Extension.metadata["gettext-domain"]).gettext; +const Me = ExtensionUtils.getCurrentExtension(); +const Convenience = ExtensionUtils.getSettings && ExtensionUtils.initTranslations ? ExtensionUtils : Me.imports.convenience; +const Metadata = Me.metadata; +const _ = imports.gettext.domain(Me.metadata["gettext-domain"]).gettext; const _GTK = imports.gettext.domain('gtk30').gettext; const MARGIN = 10; From 8159ff3f7a2c12123a0046f78d7389cd34221a44 Mon Sep 17 00:00:00 2001 From: abakkk Date: Mon, 6 Jan 2020 15:29:01 +0100 Subject: [PATCH 18/43] minor, metadata --- draw.js | 2 +- extension.js | 2 +- prefs.js | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/draw.js b/draw.js index a0f3fd6..d03e8e9 100644 --- a/draw.js +++ b/draw.js @@ -44,7 +44,7 @@ const Me = ExtensionUtils.getCurrentExtension(); const Convenience = ExtensionUtils.getSettings ? ExtensionUtils : Me.imports.convenience; const Extension = Me.imports.extension; const Prefs = Me.imports.prefs; -const _ = imports.gettext.domain(Me.metadata["gettext-domain"]).gettext; +const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext; const GS_VERSION = Config.PACKAGE_VERSION; const DEFAULT_FILE_NAME = 'DrawOnYourScreen'; diff --git a/extension.js b/extension.js index c621f77..396cee9 100644 --- a/extension.js +++ b/extension.js @@ -35,7 +35,7 @@ const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const Convenience = ExtensionUtils.getSettings && ExtensionUtils.initTranslations ? ExtensionUtils : Me.imports.convenience; const Draw = Me.imports.draw; -const _ = imports.gettext.domain(Me.metadata["gettext-domain"]).gettext; +const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext; const GS_VERSION = Config.PACKAGE_VERSION; diff --git a/prefs.js b/prefs.js index 0f4cde7..1cf2e48 100644 --- a/prefs.js +++ b/prefs.js @@ -28,8 +28,7 @@ const Mainloop = imports.mainloop; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const Convenience = ExtensionUtils.getSettings && ExtensionUtils.initTranslations ? ExtensionUtils : Me.imports.convenience; -const Metadata = Me.metadata; -const _ = imports.gettext.domain(Me.metadata["gettext-domain"]).gettext; +const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext; const _GTK = imports.gettext.domain('gtk30').gettext; const MARGIN = 10; @@ -131,10 +130,10 @@ var AboutPage = new GObject.Class({ let vbox= new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, margin: MARGIN*3 }); this.add(vbox); - let name = " " + _(Metadata.name) + ""; - let version = _("Version %d").format(Metadata.version); - let description = _(Metadata.description); - let link = "" + Metadata.url + ""; + let name = " " + _(Me.metadata.name) + ""; + let version = _("Version %d").format(Me.metadata.version); + let description = _(Me.metadata.description); + let link = "" + Me.metadata.url + ""; let licenceName = _GTK("GNU General Public License, version 2 or later"); let licenceLink = "https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"; let licence = "" + _GTK("This program comes with absolutely no warranty.\nSee the %s for details.").format(licenceLink, licenceName) + ""; From 738d06cde666a248eff06f3e5f1e8df2c0028fa9 Mon Sep 17 00:00:00 2001 From: abakkk Date: Mon, 6 Jan 2020 15:32:38 +0100 Subject: [PATCH 19/43] replace DATA_SUB_DIR const with 'data-dir' metadata property --- draw.js | 7 +++---- metadata.json | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/draw.js b/draw.js index d03e8e9..6bea034 100644 --- a/draw.js +++ b/draw.js @@ -48,7 +48,6 @@ const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext; const GS_VERSION = Config.PACKAGE_VERSION; const DEFAULT_FILE_NAME = 'DrawOnYourScreen'; -const DATA_SUB_DIR = 'drawOnYourScreen' const FILL_ICON_PATH = Me.dir.get_child('icons').get_child('fill-symbolic.svg').get_path(); const STROKE_ICON_PATH = Me.dir.get_child('icons').get_child('stroke-symbolic.svg').get_path(); @@ -72,7 +71,7 @@ function getDateString() { } function getJsonFiles() { - let directory = Gio.File.new_for_path(GLib.build_filenamev([GLib.get_user_data_dir(), DATA_SUB_DIR])); + let directory = Gio.File.new_for_path(GLib.build_filenamev([GLib.get_user_data_dir(), Me.metadata['data-dir']])); if (!directory.query_exists(null)) return []; @@ -673,7 +672,7 @@ var DrawingArea = new Lang.Class({ this._stopDrawing(); } - let dir = GLib.build_filenamev([GLib.get_user_data_dir(), DATA_SUB_DIR]); + let dir = GLib.build_filenamev([GLib.get_user_data_dir(), Me.metadata['data-dir']]); if (!GLib.file_test(dir, GLib.FileTest.EXISTS)) GLib.mkdir_with_parents(dir, 0o700); let path = GLib.build_filenamev([dir, `${name}.json`]); @@ -718,7 +717,7 @@ var DrawingArea = new Lang.Class({ _loadJson: function(name, notify) { let dir = GLib.get_user_data_dir(); - let path = GLib.build_filenamev([dir, DATA_SUB_DIR, `${name}.json`]); + let path = GLib.build_filenamev([dir, Me.metadata['data-dir'], `${name}.json`]); if (!GLib.file_test(path, GLib.FileTest.EXISTS)) return; diff --git a/metadata.json b/metadata.json index b612103..08e5a2a 100644 --- a/metadata.json +++ b/metadata.json @@ -5,6 +5,7 @@ "url": "https://framagit.org/abakkk/DrawOnYourScreen", "settings-schema": "org.gnome.shell.extensions.draw-on-your-screen", "gettext-domain": "draw-on-your-screen", + "data-dir": "drawOnYourScreen", "shell-version": [ "3.24", "3.26", From e4d6e327b814c8ba23901d71e7a57e08e9a0ee68 Mon Sep 17 00:00:00 2001 From: abakkk Date: Mon, 6 Jan 2020 15:46:49 +0100 Subject: [PATCH 20/43] icons/ -> data/icons/ --- {icons => data/icons}/dashed-line-symbolic.svg | 0 {icons => data/icons}/fill-symbolic.svg | 0 {icons => data/icons}/full-line-symbolic.svg | 0 {icons => data/icons}/linecap-symbolic.svg | 0 {icons => data/icons}/linejoin-symbolic.svg | 0 {icons => data/icons}/stroke-symbolic.svg | 0 draw.js | 12 ++++++------ 7 files changed, 6 insertions(+), 6 deletions(-) rename {icons => data/icons}/dashed-line-symbolic.svg (100%) rename {icons => data/icons}/fill-symbolic.svg (100%) rename {icons => data/icons}/full-line-symbolic.svg (100%) rename {icons => data/icons}/linecap-symbolic.svg (100%) rename {icons => data/icons}/linejoin-symbolic.svg (100%) rename {icons => data/icons}/stroke-symbolic.svg (100%) diff --git a/icons/dashed-line-symbolic.svg b/data/icons/dashed-line-symbolic.svg similarity index 100% rename from icons/dashed-line-symbolic.svg rename to data/icons/dashed-line-symbolic.svg diff --git a/icons/fill-symbolic.svg b/data/icons/fill-symbolic.svg similarity index 100% rename from icons/fill-symbolic.svg rename to data/icons/fill-symbolic.svg diff --git a/icons/full-line-symbolic.svg b/data/icons/full-line-symbolic.svg similarity index 100% rename from icons/full-line-symbolic.svg rename to data/icons/full-line-symbolic.svg diff --git a/icons/linecap-symbolic.svg b/data/icons/linecap-symbolic.svg similarity index 100% rename from icons/linecap-symbolic.svg rename to data/icons/linecap-symbolic.svg diff --git a/icons/linejoin-symbolic.svg b/data/icons/linejoin-symbolic.svg similarity index 100% rename from icons/linejoin-symbolic.svg rename to data/icons/linejoin-symbolic.svg diff --git a/icons/stroke-symbolic.svg b/data/icons/stroke-symbolic.svg similarity index 100% rename from icons/stroke-symbolic.svg rename to data/icons/stroke-symbolic.svg diff --git a/draw.js b/draw.js index 6bea034..acdfa09 100644 --- a/draw.js +++ b/draw.js @@ -49,12 +49,12 @@ const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext; const GS_VERSION = Config.PACKAGE_VERSION; const DEFAULT_FILE_NAME = 'DrawOnYourScreen'; -const FILL_ICON_PATH = Me.dir.get_child('icons').get_child('fill-symbolic.svg').get_path(); -const STROKE_ICON_PATH = Me.dir.get_child('icons').get_child('stroke-symbolic.svg').get_path(); -const LINEJOIN_ICON_PATH = Me.dir.get_child('icons').get_child('linejoin-symbolic.svg').get_path(); -const LINECAP_ICON_PATH = Me.dir.get_child('icons').get_child('linecap-symbolic.svg').get_path(); -const DASHED_LINE_ICON_PATH = Me.dir.get_child('icons').get_child('dashed-line-symbolic.svg').get_path(); -const FULL_LINE_ICON_PATH = Me.dir.get_child('icons').get_child('full-line-symbolic.svg').get_path(); +const FILL_ICON_PATH = Me.dir.get_child('data').get_child('icons').get_child('fill-symbolic.svg').get_path(); +const STROKE_ICON_PATH = Me.dir.get_child('data').get_child('icons').get_child('stroke-symbolic.svg').get_path(); +const LINEJOIN_ICON_PATH = Me.dir.get_child('data').get_child('icons').get_child('linejoin-symbolic.svg').get_path(); +const LINECAP_ICON_PATH = Me.dir.get_child('data').get_child('icons').get_child('linecap-symbolic.svg').get_path(); +const DASHED_LINE_ICON_PATH = Me.dir.get_child('data').get_child('icons').get_child('dashed-line-symbolic.svg').get_path(); +const FULL_LINE_ICON_PATH = Me.dir.get_child('data').get_child('icons').get_child('full-line-symbolic.svg').get_path(); var Shapes = { NONE: 0, LINE: 1, ELLIPSE: 2, RECTANGLE: 3, TEXT: 4 }; var TextState = { DRAWING: 0, WRITING: 1 }; From 662f229a64ec17f0aa7b86e274a4353e631bdfa0 Mon Sep 17 00:00:00 2001 From: abakkk Date: Mon, 6 Jan 2020 21:24:29 +0100 Subject: [PATCH 21/43] user.css outside extension directory * Move drawing style to `default.css`. * Generate (when opening) and handle `user.css` in `~/.local/share/drawOnYourScreen/`. --- data/default.css | 47 +++++++++++++++ draw.js | 2 +- extension.js | 56 +++++++++++++----- locale/draw-on-your-screen.pot | 10 ++-- prefs.js | 11 ++-- schemas/gschemas.compiled | Bin 3448 -> 3456 bytes ...extensions.draw-on-your-screen.gschema.xml | 6 +- stylesheet.css | 51 +--------------- 8 files changed, 105 insertions(+), 78 deletions(-) create mode 100644 data/default.css diff --git a/data/default.css b/data/default.css new file mode 100644 index 0000000..af85de7 --- /dev/null +++ b/data/default.css @@ -0,0 +1,47 @@ +/* + * Except for the font, you don't need to restart the extension. + * Just save this file as ~/.local/share/drawOnYourScreen/user.css and the changes will be applied for your next brushstroke. + * + * ~/.local/share/drawOnYourScreen/user.css file is automatically generated by activating "Open user.css". + * Delete ~/.local/share/drawOnYourScreen/user.css file to retrieve default drawing style. + * + * line-join (no string): + * 0 : miter, 1 : round, 2 : bevel + * line-cap (no string): + * 0 : butt, 1 : round, 2 : square + * + * dash: + * dash-array-on is the length of dashes (no dashes if 0, you can put 0.1 to get dots or square according to line-cap) + * dash-array-off is the length of gaps (no dashes if 0) + * + * font: + * only one family : no comma separated list of families like "font1, font2, ..., Sans-Serif" + * font family can be any font installed, or a generic family name (Serif, Sans-Serif, Monospace, Cursive, Fantasy) + * font weight and font style : no upper case when string + * weight <= 500 (or lighter, normal, medium) is rendered as normal + * weight > 500 (or bolder, bold) is rendered as bold + * oblique and italic style support depends on the font family and seem to be rendered identically + * + */ + +.draw-on-your-screen { + -drawing-line-width: 5px; + -drawing-line-join: 1; + -drawing-line-cap: 1; + -drawing-dash-array-on: 5px; + -drawing-dash-array-off: 15px; + -drawing-dash-offset: 0px; + -drawing-color1: HotPink; + -drawing-color2: Cyan; + -drawing-color3: yellow; + -drawing-color4: Orangered; + -drawing-color5: Chartreuse; + -drawing-color6: DarkViolet; + -drawing-color7: #ffffff; + -drawing-color8: rgba(130, 130, 130, 0.3); + -drawing-color9: rgb(0, 0, 0); + -drawing-background-color: #2e3436; + font-family: Cantarell; + font-weight: normal; + font-style: normal; +} diff --git a/draw.js b/draw.js index acdfa09..a140b30 100644 --- a/draw.js +++ b/draw.js @@ -1264,7 +1264,7 @@ var DrawingMenu = new Lang.Class({ this._addSaveDrawingSubMenuItem(this.menu); this.menu.addAction(_("Save drawing as a SVG file"), this.area.saveAsSvg.bind(this.area), 'image-x-generic-symbolic'); - this.menu.addAction(_("Open stylesheet.css"), manager.openStylesheetFile.bind(manager), 'document-page-setup-symbolic'); + this.menu.addAction(_("Open user.css"), manager.openUserStyleFile.bind(manager), 'document-page-setup-symbolic'); this.menu.addAction(_("Show help"), this.area.toggleHelp.bind(this.area), 'preferences-desktop-keyboard-shortcuts-symbolic'); this.updateSectionVisibility(); diff --git a/extension.js b/extension.js index 396cee9..18a61b8 100644 --- a/extension.js +++ b/extension.js @@ -21,6 +21,7 @@ */ const Gio = imports.gi.Gio; +const GLib = imports.gi.GLib; const Lang = imports.lang; const Meta = imports.gi.Meta; const Shell = imports.gi.Shell; @@ -93,16 +94,25 @@ var AreaManager = new Lang.Class({ this.desktopSettingHandler = this.settings.connect('changed::drawing-on-desktop', this.onDesktopSettingChanged.bind(this)); this.persistentSettingHandler = this.settings.connect('changed::persistent-drawing', this.onPersistentSettingChanged.bind(this)); - if (Me.stylesheet) { - this.stylesheetMonitor = Me.stylesheet.monitor(Gio.FileMonitorFlags.NONE, null); - this.stylesheetChangedHandler = this.stylesheetMonitor.connect('changed', (monitor, file, otherFile, eventType) => { - if ((eventType != 0 && eventType != 3) || !Me.stylesheet.query_exists(null)) - return; - let theme = St.ThemeContext.get_for_stage(global.stage).get_theme(); - theme.unload_stylesheet(Me.stylesheet); - theme.load_stylesheet(Me.stylesheet); - }); + this.userStyleFile = Gio.File.new_for_path(GLib.build_filenamev([GLib.get_user_data_dir(), Me.metadata['data-dir'], 'user.css'])); + + if (this.userStyleFile.query_exists(null)) { + let theme = St.ThemeContext.get_for_stage(global.stage).get_theme(); + theme.load_stylesheet(this.userStyleFile); } + + this.userStyleMonitor = this.userStyleFile.monitor_file(Gio.FileMonitorFlags.WATCH_MOVES, null); + this.userStyleHandler = this.userStyleMonitor.connect('changed', (monitor, file, otherFile, eventType) => { + // 'CHANGED' events are followed by a 'CHANGES_DONE_HINT' event + if (eventType == Gio.FileMonitorEvent.CHANGED || eventType == Gio.FileMonitorEvent.ATTRIBUTE_CHANGED) + return; + + let theme = St.ThemeContext.get_for_stage(global.stage).get_theme(); + if (theme.get_custom_stylesheets().indexOf(this.userStyleFile) != -1) + theme.unload_stylesheet(this.userStyleFile); + if (this.userStyleFile.query_exists(null)) + theme.load_stylesheet(this.userStyleFile); + }); }, onDesktopSettingChanged: function() { @@ -185,7 +195,7 @@ 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-stylesheet': this.openStylesheetFile.bind(this) + 'open-user-stylesheet': this.openUserStyleFile.bind(this) }; for (let key in this.internalKeybindings) { @@ -216,9 +226,19 @@ var AreaManager = new Lang.Class({ } }, - openStylesheetFile: function() { - if (Me.stylesheet && Me.stylesheet.query_exists(null)) - Gio.AppInfo.launch_default_for_uri(Me.stylesheet.get_uri(), global.create_app_launch_context(0, -1)); + openUserStyleFile: function() { + if (!this.userStyleFile.query_exists(null)) { + if (!this.userStyleFile.get_parent().query_exists(null)) + this.userStyleFile.get_parent().make_directory_with_parents(null); + let defaultStyleFile = Me.dir.get_child('data').get_child('default.css'); + if (!defaultStyleFile.query_exists(null)) + return; + let success = defaultStyleFile.copy(this.userStyleFile, Gio.FileCopyFlags.NONE, null, null); + if (!success) + return; + } + + Gio.AppInfo.launch_default_for_uri(this.userStyleFile.get_uri(), global.create_app_launch_context(0, -1)); if (this.activeArea) this.toggleDrawing(); }, @@ -364,9 +384,13 @@ var AreaManager = new Lang.Class({ }, disable: function() { - if (this.stylesheetChangedHandler) { - this.stylesheetMonitor.disconnect(this.stylesheetChangedHandler); - this.stylesheetChangedHandler = null; + if (this.userStyleHandler && this.userStyleMonitor) { + this.userStyleMonitor.disconnect(this.userStyleHandler); + this.userStyleHandler = null; + } + if (this.userStyleMonitor) { + this.userStyleMonitor.cancel(); + this.userStyleMonitor = null; } if (this.monitorChangedHandler) { Main.layoutManager.disconnect(this.monitorChangedHandler); diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index 1f51583..b6474ed 100644 --- a/locale/draw-on-your-screen.pot +++ b/locale/draw-on-your-screen.pot @@ -215,7 +215,7 @@ msgstr "" msgid "Save drawing as a SVG file" msgstr "" -msgid "Open stylesheet.css" +msgid "Open user.css" msgstr "" msgid "Show help" @@ -315,13 +315,11 @@ msgid "" " . extend and rotate an ellipse\n" " . curve a line (cubic Bezier curve)\n" " . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)" - msgstr "" -msgid "Change the style" -msgstr "" - -msgid "See stylesheet.css" +msgid "" +"Default drawing attributes (colors, font, line, dash) are defined in an editable css file.\n" +"See “%s”." msgstr "" msgid "" diff --git a/prefs.js b/prefs.js index 1cf2e48..e1fc815 100644 --- a/prefs.js +++ b/prefs.js @@ -71,7 +71,7 @@ var INTERNAL_KEYBINDINGS = { 'open-next-json': "Open next drawing", 'save-as-json': "Save drawing", 'save-as-svg': "Save drawing as a SVG file", - 'open-stylesheet': "Open stylesheet.css", + 'open-user-stylesheet': "Open user.css", 'toggle-help': "Show help" }; @@ -291,11 +291,14 @@ var PrefsPage = new GObject.Class({ listBox.add(internalKeybindingsWidget); let styleBox = new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN, margin_bottom:MARGIN }); - let styleLabel = new Gtk.Label({ label: _("Change the style") }); + let styleLabel = new Gtk.Label({ + use_markup: true, + label: _("Default drawing attributes (color palette, font, line, dash) are defined in an editable css file.\n" + + "See “%s”.").format(_("Open user.css")) + }); styleLabel.set_halign(1); - let styleLabel2 = new Gtk.Label({ label: _("See stylesheet.css") }); + styleLabel.get_style_context().add_class("dim-label"); styleBox.pack_start(styleLabel, true, true, 4); - styleBox.pack_start(styleLabel2, false, false, 4); listBox.add(styleBox); let noteBox = new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN, margin_bottom:MARGIN }); diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index 40539055c244f546c1590cfddd7a22af81b2c755..eebc890de348b295b81de90a8af5f07457f944f1 100644 GIT binary patch delta 807 zcmZ{iJxo(k0EKT0Rj@79MgdFFf(R|O5lmc+q60*t4sMH-DAjm$Xn6t;LLv+)H(7;$S2S{@MLe}y>fXkc@ZtcX!*lS z@9$%AI<+(E*~_7Su=-u06$-K)NUZJ8t?h5muX zYvE0;m)8Rw_8Ak0z`YCo%H?&=6?ABVpY0zHle#d3*QXvuQ?RtsyRKY5LcWZyKy2%5 zgK~L&xmENNc#avPzeZm5`HU`9o_hM~&)v1HT*7wpY0I9nEJxQbj^t7^lezprmZy(S z+Oh0yE0f4rb53H~&SolK8{fD~&wTMqQ5JKuX@(}?wTuf?G7qSj2OtCu5Q88@;6%yg n?-@}gRZl8p>Y)V=g6gbF20#^6RnLH`sw($_MjYHwrwQX9F^7V< delta 779 zcmZ{iPe_wt0LI@i4xMmfmlzr=+MY*-xd-JtV~2D=UI&)YSMX=TsvVHm3w=Pp!rb-fruNJ0 zg|^VTpfTa;3ul$f>z>1CD^%C-4=9({myV--w|UGz>)y~pAKqeN6wSj!d$^)pK1{xV zE<@L^GY!h+^-15NtKd6mjDDHCD)bq3OHX|9`o@$q<=W%9bjp;r{ja^v>5P-Ib8bHA zFs-p#6pwSIpsMCb;4;Hb1umAu6 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 1236d96..cef9985 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 @@ -191,10 +191,10 @@ toggle font style toggle font style - + ["<Primary>o"] - open stylesheet - open stylesheet + open user stylesheet + open user stylesheet ["<Primary><Shift>s"] diff --git a/stylesheet.css b/stylesheet.css index 6437e87..03a5136 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -1,50 +1,6 @@ -/* - * Except for the font, - * you don't need to restart the extension. - * Just save this file and the changes will be applied for your next brushstroke. - * - * line-join (no string): - * 0 : miter, 1 : round, 2 : bevel - * line-cap (no string): - * 0 : butt, 1 : round, 2 : square - * - * dash: - * dash-array-on is the length of dashes (no dashes if 0, you can put 0.1 to get dots or square according to line-cap) - * dash-array-off is the length of gaps (no dashes if 0) - * - * font: - * only one family : no comma separated list of families like "font1, font2, ..., Sans-Serif" - * font family can be any font installed, or a generic family name (Serif, Sans-Serif, Monospace, Cursive, Fantasy) - * font weight and font style : no upper case when string - * weight <= 500 (or lighter, normal, medium) is rendered as normal - * weight > 500 (or bolder, bold) is rendered as bold - * oblique and italic style support depends on the font family and seem to be rendered identically - * - */ +@import "./data/default.css"; -.draw-on-your-screen { - -drawing-line-width: 5px; - -drawing-line-join: 1; - -drawing-line-cap: 1; - -drawing-dash-array-on: 5px; - -drawing-dash-array-off: 15px; - -drawing-dash-offset: 0px; - -drawing-color1: HotPink; - -drawing-color2: Cyan; - -drawing-color3: yellow; - -drawing-color4: Orangered; - -drawing-color5: Chartreuse; - -drawing-color6: DarkViolet; - -drawing-color7: #ffffff; - -drawing-color8: rgba(130, 130, 130, 0.3); - -drawing-color9: rgb(0, 0, 0); - -drawing-background-color: #2e3436; /* GS osd_bg_color: #2e3436, GTK Adwaita-dark theme_base_color: #2d2c2e */ - font-family: Cantarell; - font-weight: normal; - font-style: normal; -} - -/*********************************************/ +/* The following styles don't affect the drawing */ /* square area */ @@ -56,8 +12,7 @@ outline: none; } -/* The following styles don't affect the drawing, - * but the "Ctrl + F1" on-screen-display */ + /* "Ctrl + F1" on-screen-display */ .draw-on-your-screen-helper { margin: 0; From 4cc28cf100abe06bf8b6bfa962964d101812e41a Mon Sep 17 00:00:00 2001 From: abakkk Date: Tue, 7 Jan 2020 22:15:18 +0100 Subject: [PATCH 22/43] small rework of prefs.js --- locale/draw-on-your-screen.pot | 20 +++---- prefs.js | 95 ++++++++++++++++++---------------- 2 files changed, 59 insertions(+), 56 deletions(-) diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index b6474ed..54d4974 100644 --- a/locale/draw-on-your-screen.pot +++ b/locale/draw-on-your-screen.pot @@ -285,18 +285,18 @@ msgstr "" msgid "Global" msgstr "" -msgid "Drawing on the desktop" -msgstr "" - -msgid "Draw On Your Screen becomes Draw On Your Desktop" -msgstr "" - msgid "Persistent" msgstr "" msgid "Persistent drawing through session restart" msgstr "" +msgid "Drawing on the desktop" +msgstr "" + +msgid "Draw On Your Screen becomes Draw On Your Desktop" +msgstr "" + msgid "Disable on-screen notifications" msgstr "" @@ -314,18 +314,18 @@ msgid "" " . rotate a rectangle or a text area\n" " . extend and rotate an ellipse\n" " . curve a line (cubic Bezier curve)\n" -" . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)" +" . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)" msgstr "" msgid "" -"Default drawing attributes (colors, font, line, dash) are defined in an editable css file.\n" +"Default drawing attributes (color palette, font, line, dash) are defined in an editable css file.\n" "See “%s”." msgstr "" msgid "" -"Note: When you save elements made with eraser in a SVG file,\n" +"Note: 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)" +"See “%s” or edit the SVG file afterwards." msgstr "" diff --git a/prefs.js b/prefs.js index e1fc815..78d387e 100644 --- a/prefs.js +++ b/prefs.js @@ -176,85 +176,88 @@ var PrefsPage = new GObject.Class({ this.settings = Convenience.getSettings(); - let box = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL, margin: MARGIN*3 }); + let box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, margin: MARGIN*3 }); this.add(box); - let listBox = new Gtk.ListBox({ selection_mode: 0, hexpand: true }); - box.add(listBox); + let globalFrame = new Gtk.Frame({ label_yalign: 1.0 }); + globalFrame.set_label_widget(new Gtk.Label({ margin_bottom: MARGIN/2, use_markup: true, label: "" + _("Global") + "" })); + box.add(globalFrame); + + let listBox = new Gtk.ListBox({ selection_mode: 0, hexpand: true, margin_top: MARGIN/2, margin_bottom: MARGIN/2 }); + globalFrame.add(listBox); let styleContext = listBox.get_style_context(); styleContext.add_class('background'); - let globalTitleBox = new Gtk.Box({ margin: MARGIN }); - let globalTitleLabel = new Gtk.Label({ use_markup: true, label: "" + _("Global") + " :" }); - globalTitleLabel.set_halign(1); - globalTitleBox.pack_start(globalTitleLabel, true, true, 4); - listBox.add(globalTitleBox); - let globalKeybindingsWidget = new KeybindingsWidget(GLOBAL_KEYBINDINGS, this.settings); globalKeybindingsWidget.margin = MARGIN; listBox.add(globalKeybindingsWidget); - let persistentBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); + let persistentBox = new Gtk.Box({ margin_top: MARGIN/2, margin_bottom: MARGIN/2, margin_left: MARGIN, margin_right: MARGIN }); let persistentLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); let persistentLabel1 = new Gtk.Label({label: _("Persistent")}); - let persistentLabel2 = new Gtk.Label({ use_markup: true, halign: 1, label: "" + _("Persistent drawing through session restart") + "" }); + let persistentLabel2 = new Gtk.Label({ use_markup: true, halign: 1, wrap: true, xalign: 0, label: "" + _("Persistent drawing through session restart") + "" }); persistentLabel1.set_halign(1); - persistentLabel2.get_style_context().add_class("dim-label"); + persistentLabel2.get_style_context().add_class('dim-label'); persistentLabelBox.pack_start(persistentLabel1, true, true, 0); persistentLabelBox.pack_start(persistentLabel2, true, true, 0); let persistentSwitch = new Gtk.Switch({valign: 3}); - this.settings.bind("persistent-drawing", persistentSwitch, "active", 0); + this.settings.bind('persistent-drawing', persistentSwitch, 'active', 0); persistentBox.pack_start(persistentLabelBox, true, true, 4); persistentBox.pack_start(persistentSwitch, false, false, 4); listBox.add(persistentBox); - let desktopBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); + let desktopBox = new Gtk.Box({ margin_top: MARGIN/2, margin_bottom: MARGIN/2, margin_left: MARGIN, margin_right: MARGIN }); let desktopLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); let desktopLabel1 = new Gtk.Label({label: _("Drawing on the desktop")}); - let desktopLabel2 = new Gtk.Label({ use_markup: true, halign: 1, label: "" + _("Draw On Your Screen becomes Draw On Your Desktop") + "" }); + let desktopLabel2 = new Gtk.Label({ use_markup: true, halign: 1, wrap: true, xalign: 0, label: "" + _("Draw On Your Screen becomes Draw On Your Desktop") + "" }); desktopLabel1.set_halign(1); - desktopLabel2.get_style_context().add_class("dim-label"); + desktopLabel2.get_style_context().add_class('dim-label'); desktopLabelBox.pack_start(desktopLabel1, true, true, 0); desktopLabelBox.pack_start(desktopLabel2, true, true, 0); let desktopSwitch = new Gtk.Switch({valign: 3}); - this.settings.bind("drawing-on-desktop", desktopSwitch, "active", 0); + this.settings.bind('drawing-on-desktop', desktopSwitch, 'active', 0); desktopBox.pack_start(desktopLabelBox, true, true, 4); desktopBox.pack_start(desktopSwitch, false, false, 4); listBox.add(desktopBox); - let osdBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); + let osdBox = new Gtk.Box({ margin_top: MARGIN/2, margin_bottom: MARGIN/2, margin_left: MARGIN, margin_right: MARGIN }); let osdLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); let osdLabel1 = new Gtk.Label({label: _("Disable on-screen notifications")}); osdLabel1.set_halign(1); osdLabelBox.pack_start(osdLabel1, true, true, 0); let osdSwitch = new Gtk.Switch({valign: 3}); - this.settings.bind("osd-disabled", osdSwitch, "active", 0); + this.settings.bind('osd-disabled', osdSwitch, 'active', 0); osdBox.pack_start(osdLabelBox, true, true, 4); osdBox.pack_start(osdSwitch, false, false, 4); listBox.add(osdBox); - let indicatorBox = new Gtk.Box({ margin_left: MARGIN, margin_right: MARGIN }); + let indicatorBox = new Gtk.Box({ margin_top: MARGIN/2, margin_bottom: MARGIN/2, margin_left: MARGIN, margin_right: MARGIN }); let indicatorLabelBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); let indicatorLabel1 = new Gtk.Label({label: _("Disable panel indicator")}); indicatorLabel1.set_halign(1); indicatorLabelBox.pack_start(indicatorLabel1, true, true, 0); let indicatorSwitch = new Gtk.Switch({valign: 3}); - this.settings.bind("indicator-disabled", indicatorSwitch, "active", 0); + this.settings.bind('indicator-disabled', indicatorSwitch, 'active', 0); indicatorBox.pack_start(indicatorLabelBox, true, true, 4); indicatorBox.pack_start(indicatorSwitch, false, false, 4); listBox.add(indicatorBox); - listBox.add(new Gtk.Box({ margin_bottom: MARGIN, margin_left: MARGIN, margin_right: MARGIN })); - this.addSeparator(listBox); + let children = listBox.get_children(); + for (let i = 0; i < children.length; i++) { + if (children[i].activatable) + children[i].set_activatable(false); + } - let internalTitleBox = new Gtk.Box({ margin: MARGIN }); - let internalTitleLabel = new Gtk.Label({ use_markup: true, label: "" + _("Internal") + " " + _("(in drawing mode)") + " :" }); - internalTitleLabel.set_halign(1); - internalTitleBox.pack_start(internalTitleLabel, true, true, 4); - listBox.add(internalTitleBox); + let internalFrame = new Gtk.Frame({ margin_top: 3*MARGIN, label_yalign: 1.0 }); + internalFrame.set_label_widget(new Gtk.Label({ margin_bottom: MARGIN/2, use_markup: true, label: "" + _("Internal") + " " + _("(in drawing mode)") })); + box.add(internalFrame); - listBox.add(new Gtk.Box({ margin_top: MARGIN/2, margin_left: MARGIN, margin_right: MARGIN })); + listBox = new Gtk.ListBox({ selection_mode: 0, hexpand: true, margin_top: MARGIN }); + internalFrame.add(listBox); + + styleContext = listBox.get_style_context(); + styleContext.add_class('background'); for (let i = 0; i < OTHER_SHORTCUTS.length; i++) { if (OTHER_SHORTCUTS[i].desc.indexOf('-separator-') != -1) { @@ -270,19 +273,19 @@ var PrefsPage = new GObject.Class({ listBox.add(otherBox); } - listBox.add(new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN })); - - let controlBox = new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN, margin_bottom:MARGIN }); + let controlBox = new Gtk.Box({ margin: MARGIN, margin_top: 2*MARGIN }); let controlLabel = new Gtk.Label({ + wrap: true, + xalign: 0, use_markup: true, label: _("By pressing Ctrl key during the drawing process, you can:\n" + " . rotate a rectangle or a text area\n" + " . extend and rotate an ellipse\n" + " . curve a line (cubic Bezier curve)\n" + - " . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)").format(_("Smooth last brushstroke")) + " . smooth a free drawing stroke (you may prefer to smooth the stroke afterward, see “%s”)").format(_("Smooth last brushstroke")) }); controlLabel.set_halign(1); - controlLabel.get_style_context().add_class("dim-label"); + controlLabel.get_style_context().add_class('dim-label'); controlBox.pack_start(controlLabel, true, true, 4); listBox.add(controlBox); @@ -290,38 +293,38 @@ var PrefsPage = new GObject.Class({ internalKeybindingsWidget.margin = MARGIN; listBox.add(internalKeybindingsWidget); - let styleBox = new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN, margin_bottom:MARGIN }); + let styleBox = new Gtk.Box({ margin: MARGIN }); let styleLabel = new Gtk.Label({ + wrap: true, + xalign: 0, use_markup: true, label: _("Default drawing attributes (color palette, font, line, dash) are defined in an editable css file.\n" + "See “%s”.").format(_("Open user.css")) }); styleLabel.set_halign(1); - styleLabel.get_style_context().add_class("dim-label"); + styleLabel.get_style_context().add_class('dim-label'); styleBox.pack_start(styleLabel, true, true, 4); listBox.add(styleBox); - let noteBox = new Gtk.Box({ margin_top: MARGIN, margin_left: MARGIN, margin_right: MARGIN, margin_bottom:MARGIN }); + let noteBox = new Gtk.Box({ margin: MARGIN }); let noteLabel = new Gtk.Label({ + wrap: true, + xalign: 0, use_markup: true, - label: _("Note: When you save elements made with eraser in a SVG file,\nthey are colored with background color, transparent if it is disabled.\n(See “%s” or edit the SVG file afterwards)").format(_("Add a drawing background")) + label: _("Note: 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")) }); noteLabel.set_halign(1); - noteLabel.get_style_context().add_class("dim-label"); + noteLabel.get_style_context().add_class('dim-label'); noteBox.pack_start(noteLabel, true, true, 4); listBox.add(noteBox); - let children = listBox.get_children(); + children = listBox.get_children(); for (let i = 0; i < children.length; i++) { if (children[i].activatable) children[i].set_activatable(false); } - }, - - addSeparator: function(container) { - let separatorRow = new Gtk.ListBoxRow({sensitive: false}); - separatorRow.add(new Gtk.Separator({ margin: MARGIN })); - container.add(separatorRow); } }); From aa0a984878da920166634791806cd1ea3c97d6fa Mon Sep 17 00:00:00 2001 From: abakkk Date: Fri, 10 Jan 2020 12:32:28 +0100 Subject: [PATCH 23/43] define 'persistent-file-name' and 'svg-file-name' in metadata instead of 'DEFAULT-FILE-NAME' const --- draw.js | 15 +++++++-------- metadata.json | 2 ++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/draw.js b/draw.js index a140b30..e43f610 100644 --- a/draw.js +++ b/draw.js @@ -47,7 +47,6 @@ const Prefs = Me.imports.prefs; const _ = imports.gettext.domain(Me.metadata['gettext-domain']).gettext; const GS_VERSION = Config.PACKAGE_VERSION; -const DEFAULT_FILE_NAME = 'DrawOnYourScreen'; const FILL_ICON_PATH = Me.dir.get_child('data').get_child('icons').get_child('fill-symbolic.svg').get_path(); const STROKE_ICON_PATH = Me.dir.get_child('data').get_child('icons').get_child('stroke-symbolic.svg').get_path(); @@ -86,7 +85,7 @@ function getJsonFiles() { let i = 0; let fileInfo = enumerator.next_file(null); while (fileInfo) { - if (fileInfo.get_content_type().indexOf('json') != -1 && fileInfo.get_name() != `${DEFAULT_FILE_NAME}.json`) { + if (fileInfo.get_content_type().indexOf('json') != -1 && fileInfo.get_name() != `${Me.metadata['persistent-file-name']}.json`) { let file = enumerator.get_child(fileInfo); jsonFiles.push({ name: fileInfo.get_name().slice(0, -5), displayName: fileInfo.get_display_name().slice(0, -5), @@ -644,7 +643,7 @@ var DrawingArea = new Lang.Class({ } content += "\n"; - let filename = `${DEFAULT_FILE_NAME} ${getDateString()}.svg`; + let filename = `${Me.metadata['svg-file-name']} ${getDateString()}.svg`; let dir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES); let path = GLib.build_filenamev([dir, filename]); if (GLib.file_test(path, GLib.FileTest.EXISTS)) @@ -696,7 +695,7 @@ var DrawingArea = new Lang.Class({ GLib.file_set_contents(path, contents); if (notify) this.emit('show-osd', 'document-save-symbolic', name, -1); - if (name != DEFAULT_FILE_NAME) { + if (name != Me.metadata['persistent-file-name']) { this.jsonName = name; this.lastJsonContents = contents; } @@ -712,7 +711,7 @@ var DrawingArea = new Lang.Class({ }, savePersistent: function() { - this._saveAsJson(DEFAULT_FILE_NAME); + this._saveAsJson(Me.metadata['persistent-file-name']); }, _loadJson: function(name, notify) { @@ -730,14 +729,14 @@ var DrawingArea = new Lang.Class({ if (notify) this.emit('show-osd', 'document-open-symbolic', name, -1); - if (name != DEFAULT_FILE_NAME) { + if (name != Me.metadata['persistent-file-name']) { this.jsonName = name; this.lastJsonContents = contents; } }, _loadPersistent: function() { - this._loadJson(DEFAULT_FILE_NAME); + this._loadJson(Me.metadata['persistent-file-name']); }, loadJson: function(name, notify) { @@ -1497,7 +1496,7 @@ var DrawingMenu = new Lang.Class({ this._updateDrawingNameMenuItem(); this._populateOpenDrawingSubMenu(); }, - invalidStrings: [DEFAULT_FILE_NAME, '/'], + invalidStrings: [Me.metadata['persistent-file-name'], '/'], primaryIconName: 'insert-text' }); this.saveDrawingSubMenu.addMenuItem(this.saveEntry.item); }, diff --git a/metadata.json b/metadata.json index 08e5a2a..9f028b0 100644 --- a/metadata.json +++ b/metadata.json @@ -6,6 +6,8 @@ "settings-schema": "org.gnome.shell.extensions.draw-on-your-screen", "gettext-domain": "draw-on-your-screen", "data-dir": "drawOnYourScreen", + "persistent-file-name": "persistent", + "svg-file-name": "DrawOnYourScreen", "shell-version": [ "3.24", "3.26", From e0ce5e0096554a366ea423334dcf29435677eaff Mon Sep 17 00:00:00 2001 From: abakkk Date: Fri, 10 Jan 2020 13:01:26 +0100 Subject: [PATCH 24/43] do not override peristent.json with an empty drawing when changing persistency setting --- draw.js | 9 +++++++++ extension.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/draw.js b/draw.js index e43f610..6d871db 100644 --- a/draw.js +++ b/draw.js @@ -714,6 +714,15 @@ var DrawingArea = new Lang.Class({ this._saveAsJson(Me.metadata['persistent-file-name']); }, + syncPersistent: function() { + // do not override peristent.json with an empty drawing when changing persistency setting + if (!this.elements.length) + this._loadPersistent(); + else + this.savePersistent(); + + }, + _loadJson: function(name, notify) { let dir = GLib.get_user_data_dir(); let path = GLib.build_filenamev([dir, Me.metadata['data-dir'], `${name}.json`]); diff --git a/extension.js b/extension.js index 18a61b8..ef5d9ed 100644 --- a/extension.js +++ b/extension.js @@ -124,7 +124,7 @@ var AreaManager = new Lang.Class({ onPersistentSettingChanged: function() { if (this.settings.get_boolean('persistent-drawing')) - this.areas[Main.layoutManager.primaryIndex].savePersistent(); + this.areas[Main.layoutManager.primaryIndex].syncPersistent(); }, updateIndicator: function() { From 528a62fa57bbdd70b9f82285fee772167bc2caf4 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 9 Feb 2020 16:43:21 +0100 Subject: [PATCH 25/43] minor, menuCloseFunction Fixes 'TypeError: this.saveDrawingSubMenu is undefined' --- draw.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draw.js b/draw.js index 6d871db..af05f66 100644 --- a/draw.js +++ b/draw.js @@ -1170,7 +1170,7 @@ var DrawingMenu = new Lang.Class({ // Since escape key press event can't be captured easily, the job is done in the menu close function. let menuCloseFunc = this.menu.close; this.menu.close = (animate) => { - if (this.saveDrawingSubMenu.isOpen) + if (this.saveDrawingSubMenu && this.saveDrawingSubMenu.isOpen) this.saveDrawingSubMenu.close(); menuCloseFunc.bind(this.menu)(animate); }; From cc7e208c35c48a51cb00ee066aa48a72611e2de0 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 9 Feb 2020 17:45:28 +0100 Subject: [PATCH 26/43] minor, imports ByteArray module in header --- draw.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/draw.js b/draw.js index af05f66..dc68f6e 100644 --- a/draw.js +++ b/draw.js @@ -20,6 +20,7 @@ * along with this program. If not, see . */ +const ByteArray = imports.byteArray; const Cairo = imports.cairo; const Clutter = imports.gi.Clutter; const Gio = imports.gi.Gio; @@ -680,7 +681,7 @@ var DrawingArea = new Lang.Class({ if (GLib.file_test(path, GLib.FileTest.EXISTS)) { oldContents = GLib.file_get_contents(path)[1]; if (oldContents instanceof Uint8Array) - oldContents = imports.byteArray.toString(oldContents); + oldContents = ByteArray.toString(oldContents); } // do not create a file to write just an empty array @@ -733,7 +734,7 @@ var DrawingArea = new Lang.Class({ if (!success) return; if (contents instanceof Uint8Array) - contents = imports.byteArray.toString(contents); + contents = ByteArray.toString(contents); this.elements.push(...JSON.parse(contents).map(object => new DrawingElement(object))); if (notify) From c9bde10ff04deeffd7df1c4b2904d32a52557a73 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 9 Feb 2020 17:56:40 +0100 Subject: [PATCH 27/43] cursor -> textCursor Not to be confused with pointer cursor. --- draw.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/draw.js b/draw.js index dc68f6e..27d9635 100644 --- a/draw.js +++ b/draw.js @@ -258,12 +258,12 @@ var DrawingArea = new Lang.Class({ } else if (this.currentElement && this.currentElement.shape == Shapes.TEXT && this.currentElement.state == TextState.WRITING) { if (event.get_key_symbol() == Clutter.KEY_BackSpace) { this.currentElement.text = this.currentElement.text.slice(0, -1); - this._updateCursorTimeout(); + this._updateTextCursorTimeout(); } else if (event.has_control_modifier() && event.get_key_symbol() == 118) { // Ctrl + V St.Clipboard.get_default().get_text(St.ClipboardType.CLIPBOARD, (clipBoard, clipText) => { this.currentElement.text += clipText; - this._updateCursorTimeout(); + this._updateTextCursorTimeout(); this._redisplay(); }); return Clutter.EVENT_STOP; @@ -277,7 +277,7 @@ var DrawingArea = new Lang.Class({ } else { let unicode = event.get_key_unicode(); this.currentElement.text += unicode; - this._updateCursorTimeout(); + this._updateTextCursorTimeout(); } this._redisplay(); return Clutter.EVENT_STOP; @@ -361,7 +361,7 @@ var DrawingArea = new Lang.Class({ this.currentElement.state = TextState.WRITING; this.currentElement.text = ''; this.emit('show-osd', null, _("Type your text\nand press Enter"), -1); - this._updateCursorTimeout(); + this._updateTextCursorTimeout(); this.textHasCursor = true; this._redisplay(); this.updatePointerCursor(); @@ -398,7 +398,7 @@ var DrawingArea = new Lang.Class({ if (this.currentElement.text.length > 0) this.elements.push(this.currentElement); this.currentElement = null; - this._stopCursorTimeout(); + this._stopTextCursorTimeout(); this._redisplay(); }, @@ -416,17 +416,17 @@ var DrawingArea = new Lang.Class({ this.setPointerCursor('MOVE_OR_RESIZE_WINDOW'); }, - _stopCursorTimeout: function() { - if (this.cursorTimeoutId) { - Mainloop.source_remove(this.cursorTimeoutId); - this.cursorTimeoutId = null; + _stopTextCursorTimeout: function() { + if (this.textCursorTimeoutId) { + Mainloop.source_remove(this.textCursorTimeoutId); + this.textCursorTimeoutId = null; } this.textHasCursor = false; }, - _updateCursorTimeout: function() { - this._stopCursorTimeout(); - this.cursorTimeoutId = Mainloop.timeout_add(600, () => { + _updateTextCursorTimeout: function() { + this._stopTextCursorTimeout(); + this.textCursorTimeoutId = Mainloop.timeout_add(600, () => { this.textHasCursor = !this.textHasCursor; this._redisplay(); return GLib.SOURCE_CONTINUE; @@ -451,7 +451,7 @@ var DrawingArea = new Lang.Class({ this.buttonReleasedHandler = null; } this.currentElement = null; - this._stopCursorTimeout(); + this._stopTextCursorTimeout(); } else { this.elements.pop(); } @@ -614,7 +614,7 @@ var DrawingArea = new Lang.Class({ this.helper.hideHelp(); this.currentElement = null; - this._stopCursorTimeout(); + this._stopTextCursorTimeout(); this.currentShape = Shapes.NONE; this.dashedLine = false; this.fill = false; @@ -752,7 +752,7 @@ var DrawingArea = new Lang.Class({ loadJson: function(name, notify) { this.elements = []; this.currentElement = null; - this._stopCursorTimeout(); + this._stopTextCursorTimeout(); this._loadJson(name, notify); this._redisplay(); }, From acb728a117e3b6fe70d94597e6cc205a1996bb37 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 9 Feb 2020 18:03:36 +0100 Subject: [PATCH 28/43] .pot: "Translators" --> "translator-credits" "translator-credits" as in Gtk.AboutDialog --- locale/draw-on-your-screen.pot | 8 ++++---- prefs.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index 54d4974..7b0092f 100644 --- a/locale/draw-on-your-screen.pot +++ b/locale/draw-on-your-screen.pot @@ -19,17 +19,17 @@ msgstr "" # Add your name here, for example: # (add "\n" as separator if there is many translators) -# msgid "Translators" +# msgid "translator-credits" # msgstr "Me" # or, with mail: -# msgid "Translators" +# msgid "translator-credits" # msgstr "Me" # or, with page: -# msgid "Translators" +# msgid "translator-credits" # msgstr "Me" # else keep it empty. # It will be displayed in about page -msgid "Translators" +msgid "translator-credits" msgstr "" #: extension.js diff --git a/prefs.js b/prefs.js index 78d387e..7b13a52 100644 --- a/prefs.js +++ b/prefs.js @@ -154,11 +154,11 @@ var AboutPage = new GObject.Class({ creditBox.pack_start(rightBox, true, true, 5); vbox.add(creditBox); - if (_("Translators") != "Translators" && _("Translators") != "") { + if (_("translator-credits") != "translator-credits" && _("translator-credits") != "") { leftBox.pack_start(new Gtk.Label(), false, false, 0); rightBox.pack_start(new Gtk.Label(), false, false, 0); leftLabel = new Gtk.Label({ wrap: true, valign: 1, halign: 2, justify: 1, use_markup: true, label: "" + _GTK("Translated by") + "" }); - rightLabel = new Gtk.Label({ wrap: true, valign: 1, halign: 1, justify: 0, use_markup: true, label: "" + _("Translators") + "" }); + rightLabel = new Gtk.Label({ wrap: true, valign: 1, halign: 1, justify: 0, use_markup: true, label: "" + _("translator-credits") + "" }); leftBox.pack_start(leftLabel, false, false, 0); rightBox.pack_start(rightLabel, false, false, 0); } From 5e8cb0ea1faf97c44506c11892fbf5c009a4cc98 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 1 Mar 2020 10:41:45 +0100 Subject: [PATCH 29/43] close menu when showing helper --- draw.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/draw.js b/draw.js index 27d9635..e3f283b 100644 --- a/draw.js +++ b/draw.js @@ -569,6 +569,9 @@ var DrawingArea = new Lang.Class({ }, toggleHelp: function() { + if (this._menu) + this._menu.close(); + if (this.helper.visible) this.helper.hideHelp(); else From 1e03967fbfd28d69262d348d5f8288bd6568cc4f Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 1 Mar 2020 13:25:48 +0100 Subject: [PATCH 30/43] introduce space key modifier Pointer movement is ignored when the `space` key is held. To ensure [Screenshot Tool](https://extensions.gnome.org/extension/1112/screenshot-tool/) extension compatibility, we need a way to let the third extension select the screenshot area with pointer but without leaving drawing mode and without drawing. As a side effect, it allows to insert straight line segments in free drawing (after releasing the key). Fixes issue #20 --- README.md | 10 ++++++++++ draw.js | 32 +++++++++++++++++++++++++++++++- locale/draw-on-your-screen.pot | 6 ++++++ prefs.js | 1 + 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8eb7998..65b800c 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,13 @@ Install : 5. Enable the extension in Gnome-tweak-tool 6. `Super + Alt + D` to test 7. [https://framagit.org/abakkk/DrawOnYourScreen/issues](https://framagit.org/abakkk/DrawOnYourScreen/issues) to say it doesn't work + + +Details : +--------- + + * Screenshot Tool extension: + + + [Screenshot Tool](https://extensions.gnome.org/extension/1112/screenshot-tool/) is a convenient extension to “create, copy, store and upload screenshots”. To use it while drawing mode is active, toggle the area selection mode thanks to the Screenshot Tool shortcut (`Super + F11` by default, see its preferences) and **hold** the `space` key when selecting the area with pointer to avoid drawing. + diff --git a/draw.js b/draw.js index e3f283b..7a4cfe1 100644 --- a/draw.js +++ b/draw.js @@ -213,6 +213,9 @@ var DrawingArea = new Lang.Class({ }, _onButtonPressed: function(actor, event) { + if (this.spaceKeyPressed) + return Clutter.EVENT_PROPAGATE; + let button = event.get_button(); let [x, y] = event.get_coords(); let shiftPressed = event.has_shift_modifier(); @@ -250,6 +253,20 @@ var DrawingArea = new Lang.Class({ return Clutter.EVENT_STOP; }, + _onStageKeyPressed: function(actor, event) { + if (event.get_key_symbol() == Clutter.KEY_space) + this.spaceKeyPressed = true; + + return Clutter.EVENT_PROPAGATE; + }, + + _onStageKeyReleased: function(actor, event) { + if (event.get_key_symbol() == Clutter.KEY_space) + this.spaceKeyPressed = false; + + return Clutter.EVENT_PROPAGATE; + }, + _onKeyPressed: function(actor, event) { if (event.get_key_symbol() == Clutter.Escape) { this.emit('stop-drawing'); @@ -332,6 +349,9 @@ var DrawingArea = new Lang.Class({ } this.motionHandler = this.connect('motion-event', (actor, event) => { + if (this.spaceKeyPressed) + return; + let coords = event.get_coords(); let [s, x, y] = this.transform_stage_point(coords[0], coords[1]); if (!s) @@ -579,7 +599,9 @@ var DrawingArea = new Lang.Class({ }, enterDrawingMode: function() { - this.keyPressedHandler = this.connect('key-press-event', this._onKeyPressed.bind(this)); + this.stageKeyPressedHandler = global.stage.connect('key-press-event', this._onStageKeyPressed.bind(this)); + this.stageKeyReleasedHandler = global.stage.connect('key-release-event', this._onStageKeyReleased.bind(this)); + this.keyPressedHandler = this.connect('key-press-event', this._onKeyPressed.bind(this)); this.buttonPressedHandler = this.connect('button-press-event', this._onButtonPressed.bind(this)); this._onKeyboardPopupMenuHandler = this.connect('popup-menu', this._onKeyboardPopupMenu.bind(this)); this.scrollHandler = this.connect('scroll-event', this._onScroll.bind(this)); @@ -588,6 +610,14 @@ var DrawingArea = new Lang.Class({ }, leaveDrawingMode: function(save) { + if (this.stageKeyPressedHandler) { + global.stage.disconnect(this.stageKeyPressedHandler); + this.stageKeyPressedHandler = null; + } + if (this.stageKeyReleasedHandler) { + global.stage.disconnect(this.stageKeyReleasedHandler); + this.stageKeyReleasedHandler = null; + } if (this.keyPressedHandler) { this.disconnect(this.keyPressedHandler); this.keyPressedHandler = null; diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index 7b0092f..f41e436 100644 --- a/locale/draw-on-your-screen.pot +++ b/locale/draw-on-your-screen.pot @@ -262,6 +262,12 @@ msgstr "" msgid "Shift key held" msgstr "" +msgid "Ignore pointer movement" +msgstr "" + +msgid "Space key held" +msgstr "" + msgid "Leave" msgstr "" diff --git a/prefs.js b/prefs.js index 7b13a52..6f534cd 100644 --- a/prefs.js +++ b/prefs.js @@ -83,6 +83,7 @@ var OTHER_SHORTCUTS = [ { 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" } ]; From 34c7c8f57598825734d4c5c84bc90e72d199ffdf Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 1 Mar 2020 15:03:09 +0100 Subject: [PATCH 31/43] let user customize square area size Fixes issue #22 --- data/default.css | 23 +++++++++++++++-------- draw.js | 9 ++++++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/data/default.css b/data/default.css index af85de7..0cc2f24 100644 --- a/data/default.css +++ b/data/default.css @@ -11,16 +11,21 @@ * 0 : butt, 1 : round, 2 : square * * dash: - * dash-array-on is the length of dashes (no dashes if 0, you can put 0.1 to get dots or square according to line-cap) - * dash-array-off is the length of gaps (no dashes if 0) + * dash-array-on is the length of dashes (no dashes if 0, you can put 0.1 to get dots or square according to line-cap). + * dash-array-off is the length of gaps (no dashes if 0). + * + * square area: + * Drawing in a square area is convenient when using the extension as a vector graphics editor. By default, + * when toggling 'Square drawing area', the area is sized to 75% of monitor size. You can fix and customize this size + * by uncommenting square-area-width and square-area-height lines. * * font: - * only one family : no comma separated list of families like "font1, font2, ..., Sans-Serif" - * font family can be any font installed, or a generic family name (Serif, Sans-Serif, Monospace, Cursive, Fantasy) - * font weight and font style : no upper case when string - * weight <= 500 (or lighter, normal, medium) is rendered as normal - * weight > 500 (or bolder, bold) is rendered as bold - * oblique and italic style support depends on the font family and seem to be rendered identically + * Only one family : no comma separated list of families like "font1, font2, ..., Sans-Serif". + * Font family can be any font installed, or a generic family name (Serif, Sans-Serif, Monospace, Cursive, Fantasy). + * Font weight and font style : no upper case when string. + * Weight <= 500 (or lighter, normal, medium) is rendered as normal. + * Weight > 500 (or bolder, bold) is rendered as bold. + * Oblique and italic style supports depend on the font family and seem to be rendered identically. * */ @@ -41,6 +46,8 @@ -drawing-color8: rgba(130, 130, 130, 0.3); -drawing-color9: rgb(0, 0, 0); -drawing-background-color: #2e3436; + /*-drawing-square-area-width: 512px;*/ + /*-drawing-square-area-height: 512px;*/ font-family: Cantarell; font-weight: normal; font-style: normal; diff --git a/draw.js b/draw.js index 7a4cfe1..0bf9966 100644 --- a/draw.js +++ b/draw.js @@ -164,6 +164,8 @@ var DrawingArea = new Lang.Class({ this.fontFamily = font.get_family(); this.currentFontWeight = font.get_weight(); this.currentFontStyle = font.get_style(); + this.squareAreaWidth = themeNode.get_length('-drawing-square-area-width'); + this.squareAreaHeight = themeNode.get_length('-drawing-square-area-height'); } catch(e) { logError(e); } @@ -505,9 +507,10 @@ var DrawingArea = new Lang.Class({ toggleSquareArea: function() { this.isSquareArea = !this.isSquareArea; if (this.isSquareArea) { - let squareWidth = Math.min(this.monitor.width, this.monitor.height) * 3 / 4; - this.set_position(Math.floor(this.monitor.width / 2 - squareWidth / 2), Math.floor(this.monitor.height / 2 - squareWidth / 2)); - this.set_size(squareWidth, squareWidth); + let width = this.squareAreaWidth || this.squareAreaHeight || Math.min(this.monitor.width, this.monitor.height) * 3 / 4; + let height = this.squareAreaHeight || this.squareAreaWidth || Math.min(this.monitor.width, this.monitor.height) * 3 / 4; + this.set_position(Math.floor(this.monitor.width / 2 - width / 2), Math.floor(this.monitor.height / 2 - height / 2)); + this.set_size(width, height); this.add_style_class_name('draw-on-your-screen-square-area'); } else { this.set_position(0, 0); From 0dd7859d4fed304f1a47115ca913b375c7b4b2fc Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 1 Mar 2020 17:33:41 +0100 Subject: [PATCH 32/43] minor, syntax --- draw.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/draw.js b/draw.js index 0bf9966..e2867f8 100644 --- a/draw.js +++ b/draw.js @@ -72,10 +72,7 @@ function getDateString() { function getJsonFiles() { let directory = Gio.File.new_for_path(GLib.build_filenamev([GLib.get_user_data_dir(), Me.metadata['data-dir']])); - if (!directory.query_exists(null)) - return []; - let jsonFiles = []; let enumerator; try { enumerator = directory.enumerate_children('standard::name,standard::display-name,standard::content-type,time::modified', Gio.FileQueryInfoFlags.NONE, null); @@ -83,7 +80,7 @@ function getJsonFiles() { return []; } - let i = 0; + let jsonFiles = []; let fileInfo = enumerator.next_file(null); while (fileInfo) { if (fileInfo.get_content_type().indexOf('json') != -1 && fileInfo.get_name() != `${Me.metadata['persistent-file-name']}.json`) { @@ -114,9 +111,7 @@ var DrawingArea = new Lang.Class({ 'stop-drawing': {} }, _init: function(params, monitor, helper, loadPersistent) { - this.parent({ style_class: 'draw-on-your-screen', name: params && params.name ? params.name : ""}); - - this.connect('repaint', this._repaint.bind(this)); + this.parent({ style_class: 'draw-on-your-screen', name: params.name}); this.settings = Convenience.getSettings(); this.monitor = monitor; @@ -184,8 +179,8 @@ var DrawingArea = new Lang.Class({ this.currentFontStyle = this.currentFontStyle == 2 ? 1 : ( this.currentFontStyle == 1 ? 2 : 0); }, - _repaint: function(area) { - let cr = area.get_context(); + vfunc_repaint: function() { + let cr = this.get_context(); for (let i = 0; i < this.elements.length; i++) { let isStraightLine = this.elements[i].shape == Shapes.LINE && @@ -1150,7 +1145,7 @@ var DrawingHelper = new Lang.Class({ this.opacity = 0; this.show(); - let maxHeight = this.monitor.height*(3/4); + let maxHeight = this.monitor.height * 3 / 4; this.set_height(Math.min(this.height, maxHeight)); this.set_position(Math.floor(this.monitor.width / 2 - this.width / 2), Math.floor(this.monitor.height / 2 - this.height / 2)); From ef99ca7f2ff06f5bb121cefba4e610140fcba8ae Mon Sep 17 00:00:00 2001 From: abakkk Date: Mon, 2 Mar 2020 10:11:46 +0100 Subject: [PATCH 33/43] readme --- README.md | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 65b800c..684b8fc 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ -__Draw On Your Screen__ -======================= +# Draw On Your Screen + Start drawing with Super+Alt+D. Then save your beautiful work by taking a screenshot. ![](https://framagit.org/abakkk/DrawOnYourScreen/raw/ressources/screenshot.jpg) -Features : ----------- +## Features * Basic shapes (rectangle, circle, ellipse, line, curve, text, free) * Smooth stroke @@ -15,23 +14,20 @@ Features : * Multi-monitor support * Export to SVG -Install : ----------- +## Install 1. Download and decompress or clone the repository -2. Place the resulting directory in ~/.local/share/gnome-shell/extensions -3. IMPORTANT: change the directory name to drawOnYourScreen@abakkk.framagit.org -4. A small shot of `alt + F2` `r` to restart Gnome-shell under Xorg, restart or relogin under Wayland -5. Enable the extension in Gnome-tweak-tool +2. Place the resulting directory in `~/.local/share/gnome-shell/extensions` +3. **Change the directory name** to `drawOnYourScreen@abakkk.framagit.org` +4. Xorg: type `alt + F2` and `r` to restart gnome-shell + Wayland: restart or re-login +5. Enable the extension in gnome-tweaks 6. `Super + Alt + D` to test 7. [https://framagit.org/abakkk/DrawOnYourScreen/issues](https://framagit.org/abakkk/DrawOnYourScreen/issues) to say it doesn't work +## Details -Details : ---------- - - * Screenshot Tool extension: - +* Screenshot Tool extension: [Screenshot Tool](https://extensions.gnome.org/extension/1112/screenshot-tool/) is a convenient extension to “create, copy, store and upload screenshots”. To use it while drawing mode is active, toggle the area selection mode thanks to the Screenshot Tool shortcut (`Super + F11` by default, see its preferences) and **hold** the `space` key when selecting the area with pointer to avoid drawing. From d19c3e25ea39d253ecd038b28f800c5f3f09aaa5 Mon Sep 17 00:00:00 2001 From: abakkk Date: Mon, 2 Mar 2020 16:32:50 +0100 Subject: [PATCH 34/43] cleanup --- draw.js | 44 ++++++++++++++++++++++---------------------- prefs.js | 8 ++++---- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/draw.js b/draw.js index e2867f8..7de0e82 100644 --- a/draw.js +++ b/draw.js @@ -57,20 +57,20 @@ const DASHED_LINE_ICON_PATH = Me.dir.get_child('data').get_child('icons').get_ch const FULL_LINE_ICON_PATH = Me.dir.get_child('data').get_child('icons').get_child('full-line-symbolic.svg').get_path(); var Shapes = { NONE: 0, LINE: 1, ELLIPSE: 2, RECTANGLE: 3, TEXT: 4 }; -var TextState = { DRAWING: 0, WRITING: 1 }; -var ShapeNames = { 0: "Free drawing", 1: "Line", 2: "Ellipse", 3: "Rectangle", 4: "Text" }; -var LineCapNames = { 0: 'Butt', 1: 'Round', 2: 'Square' }; -var LineJoinNames = { 0: 'Miter', 1: 'Round', 2: 'Bevel' }; -var FontWeightNames = { 0: 'Normal', 1: 'Bold' }; -var FontStyleNames = { 0: 'Normal', 1: 'Italic', 2: 'Oblique' }; -var FontFamilyNames = { 0: 'Default', 1: 'Sans-Serif', 2: 'Serif', 3: 'Monospace', 4: 'Cursive', 5: 'Fantasy' }; +const TextState = { DRAWING: 0, WRITING: 1 }; +const ShapeNames = { 0: "Free drawing", 1: "Line", 2: "Ellipse", 3: "Rectangle", 4: "Text" }; +const LineCapNames = { 0: 'Butt', 1: 'Round', 2: 'Square' }; +const LineJoinNames = { 0: 'Miter', 1: 'Round', 2: 'Bevel' }; +const FontWeightNames = { 0: 'Normal', 1: 'Bold' }; +const FontStyleNames = { 0: 'Normal', 1: 'Italic', 2: 'Oblique' }; +const FontFamilyNames = { 0: 'Default', 1: 'Sans-Serif', 2: 'Serif', 3: 'Monospace', 4: 'Cursive', 5: 'Fantasy' }; -function getDateString() { +const getDateString = function() { let date = GLib.DateTime.new_now_local(); return `${date.format("%F")} ${date.format("%X")}`; -} +}; -function getJsonFiles() { +const getJsonFiles = function() { let directory = Gio.File.new_for_path(GLib.build_filenamev([GLib.get_user_data_dir(), Me.metadata['data-dir']])); let enumerator; @@ -99,7 +99,7 @@ function getJsonFiles() { }); return jsonFiles; -} +}; // DrawingArea is the widget in which we draw, thanks to Cairo. // It creates and manages a DrawingElement for each "brushstroke". @@ -822,7 +822,7 @@ var DrawingArea = new Lang.Class({ // DrawingElement represents a "brushstroke". // It can be converted into a cairo path as well as a svg element. // See DrawingArea._startDrawing() to know its params. -var DrawingElement = new Lang.Class({ +const DrawingElement = new Lang.Class({ Name: 'DrawOnYourScreenDrawingElement', _init: function(params) { @@ -1041,7 +1041,7 @@ var DrawingElement = new Lang.Class({ }, }); -function getAngle(xO, yO, xA, yA, xB, yB) { +const getAngle = function(xO, yO, xA, yA, xB, yB) { // calculate angle of rotation in absolute value // cos(AOB) = (OA.OB)/(||OA||*||OB||) where OA.OB = (xA-xO)*(xB-xO) + (yA-yO)*(yB-yO) let angle = Math.acos( ((xA - xO)*(xB - xO) + (yA - yO)*(yB - yO)) / (Math.hypot(xA - xO, yA - yO) * Math.hypot(xB - xO, yB - yO)) ); @@ -1055,11 +1055,11 @@ function getAngle(xO, yO, xA, yA, xB, yB) { if (xA < xO) angle = - angle; return angle; -} +}; -var HELPER_ANIMATION_TIME = 0.25; -var MEDIA_KEYS_SCHEMA = 'org.gnome.settings-daemon.plugins.media-keys'; -var MEDIA_KEYS_KEYS = { +const HELPER_ANIMATION_TIME = 0.25; +const MEDIA_KEYS_SCHEMA = 'org.gnome.settings-daemon.plugins.media-keys'; +const MEDIA_KEYS_KEYS = { 'screenshot': "Screenshot", 'screenshot-clip': "Screenshot to clipboard", 'area-screenshot': "Area screenshot", @@ -1172,11 +1172,11 @@ var DrawingHelper = new Lang.Class({ }, }); -function getActor(object) { +const getActor = function(object) { return GS_VERSION < '3.33.0' ? object.actor : object; -} +}; -var DrawingMenu = new Lang.Class({ +const DrawingMenu = new Lang.Class({ Name: 'DrawOnYourScreenDrawingMenu', _init: function(area, monitor) { @@ -1550,10 +1550,10 @@ var DrawingMenu = new Lang.Class({ }); // based on searchItem.js, https://github.com/leonardo-bartoli/gnome-shell-extension-Recents -var DrawingMenuEntry = new Lang.Class({ +const DrawingMenuEntry = new Lang.Class({ Name: 'DrawOnYourScreenDrawingMenuEntry', - _init: function (params) { + _init: function(params) { this.params = params; this.item = new PopupMenu.PopupBaseMenuItem({ style_class: 'draw-on-your-screen-menu-entry-item', activate: false, diff --git a/prefs.js b/prefs.js index 6f534cd..7867a53 100644 --- a/prefs.js +++ b/prefs.js @@ -106,7 +106,7 @@ function buildPrefsWidget() { return topStack; } -var TopStack = new GObject.Class({ +const TopStack = new GObject.Class({ Name: 'DrawOnYourScreenTopStack', GTypeName: 'DrawOnYourScreenTopStack', Extends: Gtk.Stack, @@ -120,7 +120,7 @@ var TopStack = new GObject.Class({ } }); -var AboutPage = new GObject.Class({ +const AboutPage = new GObject.Class({ Name: 'DrawOnYourScreenAboutPage', GTypeName: 'DrawOnYourScreenAboutPage', Extends: Gtk.ScrolledWindow, @@ -167,7 +167,7 @@ var AboutPage = new GObject.Class({ }); -var PrefsPage = new GObject.Class({ +const PrefsPage = new GObject.Class({ Name: 'DrawOnYourScreenPrefsPage', GTypeName: 'DrawOnYourScreenPrefsPage', Extends: Gtk.ScrolledWindow, @@ -330,7 +330,7 @@ var PrefsPage = new GObject.Class({ }); // this code comes from Sticky Notes View by Sam Bull, https://extensions.gnome.org/extension/568/notes/ -var KeybindingsWidget = new GObject.Class({ +const KeybindingsWidget = new GObject.Class({ Name: 'DrawOnYourScreenKeybindings.Widget', GTypeName: 'DrawOnYourScreenKeybindingsWidget', Extends: Gtk.Box, From 8580902bf579888a7c1a5515e4794549b0f0c8a6 Mon Sep 17 00:00:00 2001 From: abakkk Date: Mon, 2 Mar 2020 16:42:46 +0100 Subject: [PATCH 35/43] fix commit 5e8cb0ea1 (close menu when showing helper) --- draw.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/draw.js b/draw.js index 7de0e82..feba951 100644 --- a/draw.js +++ b/draw.js @@ -587,9 +587,6 @@ var DrawingArea = new Lang.Class({ }, toggleHelp: function() { - if (this._menu) - this._menu.close(); - if (this.helper.visible) this.helper.hideHelp(); else @@ -1305,7 +1302,7 @@ const DrawingMenu = new Lang.Class({ this.menu.addAction(_("Save drawing as a SVG file"), this.area.saveAsSvg.bind(this.area), 'image-x-generic-symbolic'); this.menu.addAction(_("Open user.css"), manager.openUserStyleFile.bind(manager), 'document-page-setup-symbolic'); - this.menu.addAction(_("Show help"), this.area.toggleHelp.bind(this.area), 'preferences-desktop-keyboard-shortcuts-symbolic'); + this.menu.addAction(_("Show help"), () => { this.close(); this.area.toggleHelp(); }, 'preferences-desktop-keyboard-shortcuts-symbolic'); this.updateSectionVisibility(); }, From 06f59dbea33ab6f4b54c8a82fa03de5b58911022 Mon Sep 17 00:00:00 2001 From: abakkk Date: Tue, 3 Mar 2020 13:48:31 +0100 Subject: [PATCH 36/43] json files * Do not use fileInfo.get_modification_date_time for compatibility reason. * Inverse 'Open drawing' list order: recent first. * Overwrite identical contents when the save operation is queried by the user. --- draw.js | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/draw.js b/draw.js index feba951..8759a65 100644 --- a/draw.js +++ b/draw.js @@ -87,7 +87,8 @@ const getJsonFiles = function() { let file = enumerator.get_child(fileInfo); jsonFiles.push({ name: fileInfo.get_name().slice(0, -5), displayName: fileInfo.get_display_name().slice(0, -5), - modificationDateTime: fileInfo.get_modification_date_time(), + // fileInfo.get_modification_date_time: Gio 2.62+ + modificationUnixTime: fileInfo.get_attribute_uint64('time::modified'), delete: () => file.delete(null) }); } fileInfo = enumerator.next_file(null); @@ -95,7 +96,7 @@ const getJsonFiles = function() { enumerator.close(null); jsonFiles.sort((a, b) => { - return a.modificationDateTime.difference(b.modificationDateTime); + return b.modificationUnixTime - a.modificationUnixTime; }); return jsonFiles; @@ -706,28 +707,32 @@ var DrawingArea = new Lang.Class({ let path = GLib.build_filenamev([dir, `${name}.json`]); let oldContents; - if (GLib.file_test(path, GLib.FileTest.EXISTS)) { - oldContents = GLib.file_get_contents(path)[1]; - if (oldContents instanceof Uint8Array) - oldContents = ByteArray.toString(oldContents); - } - // do not create a file to write just an empty array - if (!oldContents && this.elements.length == 0) - return; + if (name == Me.metadata['persistent-file-name']) { + if (GLib.file_test(path, GLib.FileTest.EXISTS)) { + oldContents = GLib.file_get_contents(path)[1]; + if (oldContents instanceof Uint8Array) + oldContents = ByteArray.toString(oldContents); + } + + // do not create a file to write just an empty array + if (!oldContents && this.elements.length == 0) + return; + } // do not use "content = JSON.stringify(this.elements, null, 2);", neither "content = JSON.stringify(this.elements);" // because of compromise between disk usage and human readability let contents = `[\n ` + new Array(...this.elements.map(element => JSON.stringify(element))).join(`,\n\n `) + `\n]`; - if (contents != oldContents) { - GLib.file_set_contents(path, contents); - if (notify) - this.emit('show-osd', 'document-save-symbolic', name, -1); - if (name != Me.metadata['persistent-file-name']) { - this.jsonName = name; - this.lastJsonContents = contents; - } + if (name == Me.metadata['persistent-file-name'] && contents == oldContents) + return; + + GLib.file_set_contents(path, contents); + if (notify) + this.emit('show-osd', 'document-save-symbolic', name, -1); + if (name != Me.metadata['persistent-file-name']) { + this.jsonName = name; + this.lastJsonContents = contents; } }, From 7fbbb8ef683a85f395819f41c072224037d555ad Mon Sep 17 00:00:00 2001 From: abakkk Date: Wed, 4 Mar 2020 08:15:53 +0100 Subject: [PATCH 37/43] readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 684b8fc..39e555a 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,12 @@ Then save your beautiful work by taking a screenshot. ## Details +* Draw arrows: + + Intersect two lines and curve the second thanks to the `Ctrl` key. + + ![How to draw an arrow](https://framagit.org/abakkk/DrawOnYourScreen/uploads/af8f96d33cfeff49bb922a1ef9f4a4ce/arrow-screencast.webm) + * Screenshot Tool extension: [Screenshot Tool](https://extensions.gnome.org/extension/1112/screenshot-tool/) is a convenient extension to “create, copy, store and upload screenshots”. To use it while drawing mode is active, toggle the area selection mode thanks to the Screenshot Tool shortcut (`Super + F11` by default, see its preferences) and **hold** the `space` key when selecting the area with pointer to avoid drawing. From 289b280f67bfa18b81ae212d6f4efb0a7892dfe9 Mon Sep 17 00:00:00 2001 From: abakkk Date: Wed, 4 Mar 2020 08:51:36 +0100 Subject: [PATCH 38/43] remove Monospace in openDrawing item styles --- draw.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draw.js b/draw.js index 8759a65..4a36c70 100644 --- a/draw.js +++ b/draw.js @@ -1478,7 +1478,7 @@ const DrawingMenu = new Lang.Class({ this.openDrawingSubMenu.removeAll(); let jsonFiles = getJsonFiles(); jsonFiles.forEach(file => { - let item = this.openDrawingSubMenu.addAction(`${file.displayName}`, () => { + let item = this.openDrawingSubMenu.addAction(`${file.displayName}`, () => { this.area.loadJson(file.name); this._updateDrawingNameMenuItem(); this._updateSaveDrawingSubMenuItemSensitivity(); From 4e3353863cfb10439ea761dc323159cd3f96e053 Mon Sep 17 00:00:00 2001 From: abakkk Date: Wed, 4 Mar 2020 09:33:40 +0100 Subject: [PATCH 39/43] drawing menu style Reduce menu height. --- stylesheet.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stylesheet.css b/stylesheet.css index 03a5136..bd02a07 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -39,8 +39,8 @@ } .draw-on-your-screen-menu .popup-menu-item { - padding-top: .32em; /* default: .4em */ - padding-bottom: .32em; + padding-top: .3em; /* default: .4em */ + padding-bottom: .3em; } .draw-on-your-screen-menu .popup-menu-icon { @@ -49,7 +49,7 @@ } .draw-on-your-screen-menu .toggle-switch { - height: 1.4em; /* default: 22px */ + height: 1.35em; /* default: 22px */ } .draw-on-your-screen-menu-separator-item { @@ -62,8 +62,8 @@ } .draw-on-your-screen-menu-separator-item .popup-separator-menu-item { - margin-top: 0.4em; /* default 6px */ - margin-bottom: 0.4em; /* default 6px */ + margin-top: 0.2em; /* default 6px */ + margin-bottom: 0.2em; /* default 6px */ } .draw-on-your-screen-menu-slider-label { From 0ae23a5d10e74edab52519cd52c51ad1414770db Mon Sep 17 00:00:00 2001 From: abakkk Date: Wed, 4 Mar 2020 14:23:49 +0100 Subject: [PATCH 40/43] "Open user.css" -> "Edit style" --- data/default.css | 2 +- draw.js | 2 +- locale/draw-on-your-screen.pot | 6 +++--- prefs.js | 6 +++--- ...g.gnome.shell.extensions.draw-on-your-screen.gschema.xml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/data/default.css b/data/default.css index 0cc2f24..b5ab3ef 100644 --- a/data/default.css +++ b/data/default.css @@ -2,7 +2,7 @@ * Except for the font, you don't need to restart the extension. * Just save this file as ~/.local/share/drawOnYourScreen/user.css and the changes will be applied for your next brushstroke. * - * ~/.local/share/drawOnYourScreen/user.css file is automatically generated by activating "Open user.css". + * ~/.local/share/drawOnYourScreen/user.css file is automatically generated by activating "Edit style". * Delete ~/.local/share/drawOnYourScreen/user.css file to retrieve default drawing style. * * line-join (no string): diff --git a/draw.js b/draw.js index 4a36c70..ae75252 100644 --- a/draw.js +++ b/draw.js @@ -1306,7 +1306,7 @@ const DrawingMenu = new Lang.Class({ this._addSaveDrawingSubMenuItem(this.menu); this.menu.addAction(_("Save drawing as a SVG file"), this.area.saveAsSvg.bind(this.area), 'image-x-generic-symbolic'); - this.menu.addAction(_("Open user.css"), manager.openUserStyleFile.bind(manager), 'document-page-setup-symbolic'); + this.menu.addAction(_("Edit style"), manager.openUserStyleFile.bind(manager), 'document-page-setup-symbolic'); this.menu.addAction(_("Show help"), () => { this.close(); this.area.toggleHelp(); }, 'preferences-desktop-keyboard-shortcuts-symbolic'); this.updateSectionVisibility(); diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index f41e436..2df55f0 100644 --- a/locale/draw-on-your-screen.pot +++ b/locale/draw-on-your-screen.pot @@ -215,7 +215,7 @@ msgstr "" msgid "Save drawing as a SVG file" msgstr "" -msgid "Open user.css" +msgid "Edit style" msgstr "" msgid "Show help" @@ -324,7 +324,7 @@ msgid "" msgstr "" msgid "" -"Default drawing attributes (color palette, font, line, dash) are defined in an editable css file.\n" +"Default drawing style attributes (color palette, font, line, dash) are defined in an editable css file.\n" "See “%s”." msgstr "" @@ -336,7 +336,7 @@ msgstr "" # The following words refer to SVG attributes. -# You have the choice to translate or not +# You are free to translate them or not. #msgid "Butt" #msgstr "" diff --git a/prefs.js b/prefs.js index 7867a53..3971165 100644 --- a/prefs.js +++ b/prefs.js @@ -71,7 +71,7 @@ var INTERNAL_KEYBINDINGS = { 'open-next-json': "Open next drawing", 'save-as-json': "Save drawing", 'save-as-svg': "Save drawing as a SVG file", - 'open-user-stylesheet': "Open user.css", + 'open-user-stylesheet': "Edit style", 'toggle-help': "Show help" }; @@ -299,8 +299,8 @@ const PrefsPage = new GObject.Class({ wrap: true, xalign: 0, use_markup: true, - label: _("Default drawing attributes (color palette, font, line, dash) are defined in an editable css file.\n" + - "See “%s”.").format(_("Open user.css")) + label: _("Default drawing style attributes (color palette, font, line, dash) are defined in an editable css file.\n" + + "See “%s”.").format(_("Edit style")) }); styleLabel.set_halign(1); styleLabel.get_style_context().add_class('dim-label'); 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 cef9985..8890675 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 @@ -193,8 +193,8 @@ ["<Primary>o"] - open user stylesheet - open user stylesheet + open user stylesheet to edit style + open user stylesheet to edit style ["<Primary><Shift>s"] From 149b188e4e5c8867842e6044a20f6b4d61da5913 Mon Sep 17 00:00:00 2001 From: abakkk Date: Wed, 4 Mar 2020 15:47:36 +0100 Subject: [PATCH 41/43] version -> 5.1 --- NEWS | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ metadata.json | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 NEWS diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..c8590f2 --- /dev/null +++ b/NEWS @@ -0,0 +1,51 @@ +v5.1 - March 2020 +================= + +* Add "Open" and "Save drawing" +* Change some keyboard shortcuts +* Replace "smoothed stroke" preference with `Ctrl` key modifier +* Add `space` key modifier to ignore pointer movement #20 +* User style is now stored in user data directory (`user.css`) +* Customizable square area size #22 + +v5 - December 2019 +================== + +* Improve pointer cursor +* Add 3.24 version as supported +* Use maxLevel in line-width OSD +* Small fix with text shape that displayed keybindings + + +v4.1 - October 2019 +=================== + +* GS 3.34 compatibility +* Create drawing menu on demand +* Allow 0 px line width because stroke lines cannot have color with some transparency + + +v4 - April 2019 +=============== + +* Add drawing menu +* Add panel indicator +* Prefs to disable indicator and notifications +* Change middle click action + +v3 - March 2019 +=============== + +* Fix area container integration #1 +* Add persistence + +v2 - March 2019 +=============== + +* Add transformations +* Add square area + +v1 - March 2019 +=============== + +* Initial release diff --git a/metadata.json b/metadata.json index 9f028b0..fe0a0cd 100644 --- a/metadata.json +++ b/metadata.json @@ -16,5 +16,5 @@ "3.32", "3.34" ], - "version": 5 + "version": 5.1 } From 447b36421b0e06d2c4bce8df19fb2c4ff87ae244 Mon Sep 17 00:00:00 2001 From: albanobattistella Date: Sun, 23 Jun 2019 17:58:36 +0200 Subject: [PATCH 42/43] Upload New File --- .../it_IT/LC_MESSAGES/draw-on-your-screen.po | 325 ++++++++++++++++++ 1 file changed, 325 insertions(+) create mode 100644 locale/it_IT/LC_MESSAGES/draw-on-your-screen.po diff --git a/locale/it_IT/LC_MESSAGES/draw-on-your-screen.po b/locale/it_IT/LC_MESSAGES/draw-on-your-screen.po new file mode 100644 index 0000000..7fc7c82 --- /dev/null +++ b/locale/it_IT/LC_MESSAGES/draw-on-your-screen.po @@ -0,0 +1,325 @@ +# Copyright (C) 2019 Listed translators +# +# This file is distributed under the same license as Draw On Your Screen. +# FIRST AUTHOR , YEAR. +# +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: 2019-06-15 08:47+0200\n" +"PO-Revision-Date: 2019-06-15 09:52+0200\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.7.1\n" +"Last-Translator: albano battistella \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: it_IT\n" + +# add your name here, for example: +# "Albano Battistella\n" +# "Ali\n" +# "" +# It will be displayed in About page +msgid "Translators" +msgstr "Albano Battistella" + +#: extension.js +msgid "Leaving drawing mode" +msgstr "Lascia la modalità di disegno" + +msgid "Press Ctrl + F1 for help" +msgstr "Premi Ctrl + F1 per aiuto" + +msgid "Entering drawing mode" +msgstr "Entra in modalità disegno" + +#: draw.js +msgid "Free drawing" +msgstr "Disegno libero" + +msgid "Line" +msgstr "Linea" + +msgid "Ellipse" +msgstr "Ellisse" + +msgid "Rectangle" +msgstr "Rettangolo" + +msgid "Text" +msgstr "Testo" + +msgid "Fill" +msgstr "Riempi" + +msgid "Stroke" +msgstr "Tratto" + +msgid "Dashed line" +msgstr "Linea tratteggiata" + +msgid "Full line" +msgstr "Linea piena" + +msgid "" +"Type your text\n" +"and press Enter" +msgstr "" +"Digita il tuo testo\n" +"e premere Invio" + +msgid "Screenshot" +msgstr "Screenshot" + +msgid "Screenshot to clipboard" +msgstr "Screenshot negli appunti" + +msgid "Area screenshot" +msgstr "Area screenshot" + +msgid "Area screenshot to clipboard" +msgstr "Area screenshot negli appunti" + +msgid "System" +msgstr "Sistema" + +msgid "Undo" +msgstr "Annulla" + +msgid "Redo" +msgstr "Ripeti" + +msgid "Erase" +msgstr "Cancella" + +msgid "Smooth" +msgstr "Liscio" + +msgid "Dashed" +msgstr "tratteggiato" + +msgid "Color" +msgstr "Colore" + +#: prefs.js +msgid "Preferences" +msgstr "Preferenze" + +msgid "About" +msgstr "Informazioni su" + +# GLOBAL_KEYBINDINGS +msgid "Enter/leave drawing mode" +msgstr "Entra/esci dalla modalità disegno" + +msgid "Erase all drawings" +msgstr "Cancella tutti i disegni" + +# INTERNAL_KEYBINDINGS +msgid "Undo last brushstroke" +msgstr "Annulla l'ultima pennellata" + +msgid "Redo last brushstroke" +msgstr "Ripeti l'ultima pennellata" + +msgid "Erase last brushstroke" +msgstr "Cancella l'ultima pennellata" + +msgid "Smooth last brushstroke" +msgstr "Liscia l'ultima pennellata" + +msgid "Select line" +msgstr "Seleziona la linea" + +msgid "Select ellipse" +msgstr "Seleziona l'ellisse" + +msgid "Select rectangle" +msgstr "Seleziona il rettangolo" + +msgid "Select text" +msgstr "Seleziona il testo" + +msgid "Unselect shape (free drawing)" +msgstr "Deseleziona forma (disegno libero)" + +msgid "Toggle fill/stroke" +msgstr "Attiva / disattiva riempimento / tratto" + +msgid "Increment line width" +msgstr "Incrementa la larghezza della linea" + +msgid "Decrement line width" +msgstr "Decrementa la larghezza della linea" + +msgid "Increment line width even more" +msgstr "Aumentare la larghezza della linea ancora di più" + +msgid "Decrement line width even more" +msgstr "Decrementa la larghezza della linea ancora di più" + +msgid "Change linejoin" +msgstr "Cambia linejoin" + +msgid "Change linecap" +msgstr "Cambia il limite di riga" + +# already in draw.js +# msgid "Dashed line" +# msgstr "" +msgid "Change font family (generic name)" +msgstr "Cambia la famiglia del font (nome generico)" + +msgid "Change font weight" +msgstr "Cambiare spessore del font" + +msgid "Change font style" +msgstr "Cambia stile del font" + +msgid "Hide panel and dock" +msgstr "Nascondi pannello e dock" + +msgid "Add a drawing background" +msgstr "Aggiungi uno sfondo di disegno" + +msgid "Square drawing area" +msgstr "Area di disegno quadrata" + +msgid "Save drawing as a SVG file" +msgstr "Salva disegno come file SVG" + +msgid "Open stylesheet.css" +msgstr "Apri stylesheet.css" + +msgid "Show help" +msgstr "Mostra aiuto" + +# OTHER_SHORTCUTS +msgid "Draw" +msgstr "Disegna" + +msgid "Left click" +msgstr "Clic sinistro" + +msgid "Menu" +msgstr "Menu" + +msgid "Right click" +msgstr "Clic destro" + +msgid "Center click" +msgstr "clic centro" + +msgid "Transform shape (when drawing)" +msgstr "Trasforma la forma (quando si disegna)" + +msgid "Ctrl key" +msgstr "Tasto Ctrl" + +msgid "Increment/decrement line width" +msgstr "Incrementa/decrementa larghezza della linea" + +msgid "Scroll" +msgstr "Scorri" + +msgid "Select color" +msgstr "Seleziona colore" + +msgid "Ctrl+1...9" +msgstr "Ctrl+1...9" + +msgid "Select eraser" +msgstr "Seleziona gomma" + +msgid "Shift key held" +msgstr "Tasto MAIUSC premuto" + +msgid "Leave" +msgstr "Lascia" + +msgid "Escape key" +msgstr "tasto Esc" + +# About page +# you are free to translate the extension name +# msgid "Draw On You Screen" +# msgstr "" +msgid "Version %d" +msgstr "Versione %d" + +msgid "" +"Start drawing with Super+Alt+D and save your beautiful work by taking a " +"screenshot" +msgstr "" +"Inizia a disegnare con Super + Alt + D e salva il tuo bellissimo lavoro " +"scattando uno screenshot" + +# Prefs page +msgid "Global" +msgstr "Globale" + +msgid "Drawing on the desktop" +msgstr "Disegno sul desktop" + +msgid "Draw On Your Screen becomes Draw On Your Desktop" +msgstr "Draw On Your Screen diventa Draw On Your Desktop" + +msgid "Persistent" +msgstr "Persistente" + +msgid "Persistent drawing through session restart" +msgstr "Disegno persistente attraverso il riavvio della sessione" + +msgid "Disable on-screen notifications" +msgstr "Disabilita le notifiche sullo schermo" + +msgid "Disable panel indicator" +msgstr "Disabilita indicatore del pannello" + +msgid "Internal" +msgstr "Interno" + +msgid "(in drawing mode)" +msgstr "(in modalità disegno)" + +msgid "" +"By pressing Ctrl key during the drawing process, you can:\n" +" . rotate a rectangle or a text area\n" +" . extend and rotate an ellipse\n" +" . curve a line (cubic Bezier curve)" +msgstr "" +"Premendo il tasto Ctrl durante del processo di disegno, " +"puoi:\n" +" . ruotare un rettangolo o un'area di testo\n" +" . estendere e ruotare un'ellisse\n" +" . curvare una linea (curva Bezier cubica)" + +msgid "Smooth stroke during the drawing process" +msgstr "Colpo liscio durante il processo di disegno" + +msgid "" +"You can also smooth the stroke afterward\n" +"See “%s”" +msgstr "" +"Puoi anche lisciare il tratto in seguito\n" +"Vedi \"% s\"" + +msgid "Change the style" +msgstr "Cambia lo stile" + +msgid "See stylesheet.css" +msgstr "Vedi stylesheet.css" + +msgid "" +"Note: When you save elements made with eraser in a SVG " +"file,\n" +"they are colored with background color, transparent if it is disabled.\n" +"(See “%s” or edit the SVG file afterwards)" +msgstr "" +" Nota : quando salvi gli elementi creati con gomma da " +"cancellare in un file SVG ,\n" +"questi sono colorati con il colore di sfondo, trasparente se disabilitati.\n" +"(Vedi \"% s\" o modifica il file SVG in seguito)" From 0d83dcead124c3cde932ec348dd70846eeb871cb Mon Sep 17 00:00:00 2001 From: abakkk Date: Wed, 4 Mar 2020 17:50:29 +0100 Subject: [PATCH 43/43] add it locale .mo --- locale/it_IT/LC_MESSAGES/draw-on-your-screen.mo | Bin 0 -> 6600 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 locale/it_IT/LC_MESSAGES/draw-on-your-screen.mo diff --git a/locale/it_IT/LC_MESSAGES/draw-on-your-screen.mo b/locale/it_IT/LC_MESSAGES/draw-on-your-screen.mo new file mode 100644 index 0000000000000000000000000000000000000000..feda332b195e5c4b79ab0aa3c8200bff39e5187f GIT binary patch literal 6600 zcma)`Ynj<*C1L` z{p&|{RejI;=J}hi|B~T&nD#c>@2)fE6Yw)PaN>CU6~?>)J^`PDSD;>XZZhW0FoLgx zpMv`S3-AZ<`|#D!z0#O{Fo7E9bMR*PHTYWi6x8?6z}LgyL5=?+WC-&TY{0+48{xm< ztKf}1ycOOI-wyY~JK-t#Cb$8whmXQT@Glj??y9uiQ zTOqH^Jk)r{q2xLVS&BIawXP4rTi{2b)>S~Q>xr7*f|BPssCj+`)$jLEwX?e-WMT1 z^AAq4%MGtFhM&2Wlg7CV%04so{rjN$JqR`bhoQ#nLXE!(r{H5ya(oA_!Kb16-NMJ> z?NIC92epoOLFw%%)Vv?8@4Ha_9)ptaad-#(DwJG5frsI9@LMl4=3h|u`zDM26Z|QZ zpM3)-)c8Myy8kWIIDdq{fG=Yan)jD*8vX%lzE>cG^mqr9-j6_i|4>Z_CC?*J>-l)i z$Ds83St$9gz<0p!!Fl)_csINOXSfSaL;2@fD8Ic3>0&-zKfeOi@9Xfb@L4FodI4%( zFG0oO^(bnL`rFGs0 z)qe(Rp2JXnxmw?U7|JdQl)fK@{LJU;`)@;3WPSo=mtRAT_dL}6FG9(!$u!?VP9KFU zQ2o9MrH}7I$^8`E4}T2b1^);&Zv!Ev&pV*{FG9()3S~bJCFkStJ@AVVw++591JBS< zaaijLv^3>W9cO8DHwS6&rj3qcTrALJ2l>G0kUe!=tPuP~ms-br>t`cqjfw{yTKDLX zFX_-)wQe2v&?KvlHCiiN?VKLq@;L3Cv{N)p8EiHSucJwC7ihAB4%tmUrQ>7;^B|Pp zet@QYa*p;eO^58E;|T3QxH9H_5EBGj$}jGx$xfKnJVcW(X`j$>Z-sD{t#rtSiaQ;r zY4fzBx~Y#QBvpiCne+Q;OSHqZb=u^y%FPLy;zh^HD}?hR=kv7tXu;p6qQrJHcPUDG zc93@c0duT8aW*advDxy(f_=E}6T6+3Hg{Xz`q&SAQsj2vy53%jioQM8KH)Q$`|Q|k z`-EjMr$?=e4}|-TDE0>%Mc;2*mwDSs<23W#>dUt4Z1%FWOuE(cgSNlun@6v_AEz?;|W!*;Mvr8`P<_FATJ1q;d z*zK~Uk%T*Qn#IgJn|Ctrlf0kOareC~Qrn56VLN3sb8_1bGoR{UCF(AYI-6#x&qUsCq$qa74WfA4 zPW61^Gd@e)0HaU#$cydR?|O2{N4p1Z6;Ybx zJ3X;#^J-so=fb9(lWEH;0U(uJL$mZRvpIgmVLfiq{Hxm93V}C({<~| zE0tNyiWEK@dj-nK0~Ar!3w^lzsiMZL=xkjak6z~WquAwzZD(cP&x|!2>)3%Gv`y&Fh5?fBxP4R-&WDgDR^>9MN{Xx2ut##J{BCwq;C*W~2&N?VgwbUC3m z$}y&Lm5?)bE_bI3o~M{d`RXbeTcpqqlZ42qZ|beSmSt=&rP-!!Z`;Cc%1?GB;8x}5t!-RjVAdttdfHQd zB(=x0br`H`kHD@2oA(tDQ0>RC6K06Lh*( zH5Zb+vPC_|#zd?gFc;;gc;MY#L+-F7b^$Pc+WQW#;1MDO@IBu*opo=Evvnv(@GC zsl@I(Zs!i%HkXsgh!pPPsQB5FsziJ*NkfHXDUq0b)~ZM%KIBHZi?<@% zi=$DU6j>53TM^-&s7$cEbTFV8aq^jtmQPqQMpZbKNmawBqmoT{aj@|Sc4LSL-7=`d_JOpx`=x1U3c63E}KfQuvJ6Es7!j1Em=x6p{B0Ya&-Z9^}S8JRO5!jGASaZYBqbc#_R=l zPJ@C%>aH{*HIS4XZdU84%N}0mq;z89gLYV^5w(?ys}i%IRCJm7Lgf{S7Fo+=ztWbz zDo|${I&;Aa*gLGB_;A0{ajr6}uCuD~s#?pb*vhutPO(Mhp%VqntTs8{`zb>&0$GYXxnUrA|kG>A|Q5@k`(jYiUT zQ59qLDzKCWH%p=PHtRvvQuAavM&Vr)9`h20Mw>L{=*}azQ-%exaNAzrU%njVLQKv1 zfAwKo=%iV&!Z7;TkE-%4c&A1Dx^z?ZNHxQ{JAI!G(#c-q3a-)!^$m4h9J&yhtYNZj ztCMIqqFf|acfA{zbX7=eMs!@2c`KFuRkmer*5@5uoC3{Vn+d8eikUs$E!828WvW=W zMM>JSqkxHaUc~#$xQNIM6h#uq70y&KLD6T{B0m^LQiHM&+HQNitg_ND@`zp4eBPXO zIhh8J7%2wF-d*|q5Bn{aD!%3HGU;9>zS?}_+R*J3hyUeMa)}B>mdz3)S3@&Rrq^*Q zSyDLhXNx31616HD7l#?CNdHgvDjUNef}kWSk-C(mxGu2c77s$M$s)J46_G!r=TR}~ zm5xFcc{yATqKP7sv8;MX3!WJHOw(wUl z)c5O3f|yUm#=udNO8iBln9*jn9$xD@3n8lbNqLSQ^c5e6LRBH5e7XRk7V5%*LwS#Ind^#VpZtg^_smh~!T a&$Epx#>v3JFw&=t9>kfb3>rISg!vCQ*7!gG literal 0 HcmV?d00001