Merge branch 'pile' into 'face'

v11.1
This commit is contained in:
abakkk 2021-04-26 15:00:37 +02:00
commit 5df2f8b992
6 changed files with 44 additions and 49 deletions

5
NEWS
View File

@ -1,3 +1,8 @@
v11.1 - April 2021
==================
* Not to erase the text when pressing "Escape" #60
v11 - February 2021 v11 - February 2021
=================== ===================

View File

@ -38,7 +38,7 @@ Then save your beautiful work by taking a screenshot.
Intersect two lines and curve the second thanks to the `Ctrl` key. 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) ![How to draw an arrow](https://framagit.org/abakkk/DrawOnYourScreen/-/raw/media/arrow.webm)
* Duplicate an element: * Duplicate an element:

View File

@ -845,9 +845,6 @@ var DrawingArea = new Lang.Class({
this.textEntry.clutterText.set_single_line_mode(false); this.textEntry.clutterText.set_single_line_mode(false);
this.textEntry.clutterText.set_activatable(false); this.textEntry.clutterText.set_activatable(false);
this.textEntry.clutterText.connect('activate', (clutterText) => {
this._stopWriting();
});
let showCursorOnPositionChanged = true; let showCursorOnPositionChanged = true;
this.textEntry.clutterText.connect('text-changed', clutterText => { this.textEntry.clutterText.connect('text-changed', clutterText => {
@ -868,7 +865,6 @@ var DrawingArea = new Lang.Class({
this.textEntry.clutterText.connect('key-press-event', (clutterText, event) => { this.textEntry.clutterText.connect('key-press-event', (clutterText, event) => {
if (event.get_key_symbol() == Clutter.KEY_Escape) { if (event.get_key_symbol() == Clutter.KEY_Escape) {
this.currentElement.text = "";
this._stopWriting(); this._stopWriting();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }

View File

@ -73,8 +73,13 @@ var DrawingHelper = new Lang.Class({
}, },
_updateHelpKeyLabel: function() { _updateHelpKeyLabel: function() {
let [keyval, mods] = Gtk.accelerator_parse(Me.internalShortcutSettings.get_strv('toggle-help')[0] || ''); try {
this._helpKeyLabel = Gtk.accelerator_get_label(keyval, mods); let [keyval, mods] = Gtk.accelerator_parse(Me.internalShortcutSettings.get_strv('toggle-help')[0] || '');
this._helpKeyLabel = Gtk.accelerator_get_label(keyval, mods);
} catch(e) {
logError(e);
this._helpKeyLabel = " ";
}
}, },
get helpKeyLabel() { get helpKeyLabel() {
@ -172,10 +177,11 @@ var DrawingHelper = new Lang.Class({
this.set_position(Math.floor(this.monitor.width / 2 - this.width / 2), this.set_position(Math.floor(this.monitor.width / 2 - this.width / 2),
Math.floor(this.monitor.height / 2 - this.height / 2)); Math.floor(this.monitor.height / 2 - this.height / 2));
// St.PolicyType: GS 3.32+
if (this.height == maxHeight) if (this.height == maxHeight)
this.vscrollbar_policy = Gtk.PolicyType.ALWAYS; this.vscrollbar_policy = St.PolicyType ? St.PolicyType.ALWAYS : Gtk.PolicyType.ALWAYS;
else else
this.vscrollbar_policy = Gtk.PolicyType.NEVER; this.vscrollbar_policy = St.PolicyType ? St.PolicyType.NEVER : Gtk.PolicyType.NEVER;
if (Tweener) { if (Tweener) {
Tweener.removeTweens(this); Tweener.removeTweens(this);

View File

@ -19,5 +19,5 @@
"3.38", "3.38",
"40" "40"
], ],
"version": 11 "version": 11.1
} }

View File

@ -65,19 +65,10 @@ const setAccessibleDescription = function(widget, description) {
}; };
const getChildrenOf = function(widget) { const getChildrenOf = function(widget) {
if (IS_GTK3) { if (IS_GTK3)
return widget.get_children(); return widget.get_children();
} else { else
let listModel = widget.observe_children(); return [...widget];
let i = 0;
let children = [];
let child;
while (!!(child = listModel.get_item(i))) {
children.push(child);
i++;
}
return children;
}
}; };
function init() { function init() {
@ -612,7 +603,7 @@ const PrefRow = new GObject.Class({
} }
}); });
const PixelSpinButton = new GObject.Class(Object.assign({ const PixelSpinButton = new GObject.Class({
Name: `${UUID}-PixelSpinButton`, Name: `${UUID}-PixelSpinButton`,
Extends: Gtk.SpinButton, Extends: Gtk.SpinButton,
Properties: { Properties: {
@ -638,22 +629,24 @@ const PixelSpinButton = new GObject.Class(Object.assign({
this.adjustment.set_page_increment(step * 10); this.adjustment.set_page_increment(step * 10);
}, },
vfunc_constructed() { on_output: function() {
this.parent(); this.text = _("%f px").format(Number(this.value).toFixed(2));
return true;
},
// Prevent accidental scrolling (GTK 3).
on_scroll_event: function(event) {
if (this.has_focus) {
try {
GObject.signal_chain_from_overridden([this, event], false);
} catch(e) { }
return Gdk.EVENT_STOP;
}
// No virtual functions with Gtk4 :/. return Gdk.EVENT_PROPAGATE;
// Add 'px' unit.
this.connect('output', spinButton => {
this.text = _("%f px").format(Number(spinButton.value).toFixed(2));
return true;
});
} }
}, IS_GTK3 ? { });
// Prevent accidental scrolling.
vfunc_scroll_event: function(event) {
return this.has_focus ? this.parent(event) : Gdk.EVENT_PROPAGATE;
}
} : {}));
// A color button that can be easily bound with a color string setting. // A color button that can be easily bound with a color string setting.
const ColorStringButton = new GObject.Class({ const ColorStringButton = new GObject.Class({
@ -676,20 +669,15 @@ const ColorStringButton = new GObject.Class({
this.set_rgba(newRgba); this.set_rgba(newRgba);
}, },
vfunc_constructed() { on_color_set: function() {
this.parent(); let oldRgba = new Gdk.RGBA();
oldRgba.parse(this.color_string);
// No virtual functions with Gtk4 :/.
// Do nothing if the new color is equivalent to the old color (e.g. "black" and "rgb(0,0,0)"). // Do nothing if the new color is equivalent to the old color (e.g. "black" and "rgb(0,0,0)").
this.connect('color-set', colorButton => { if (!this.rgba.equal(oldRgba)) {
let oldRgba = new Gdk.RGBA(); this._color_string = this.rgba.to_string();
oldRgba.parse(colorButton.color_string); this.notify('color-string');
}
if (!this.rgba.equal(oldRgba)) {
this._color_string = colorButton.rgba.to_string();
this.notify('color-string');
}
});
} }
}); });