From 4e0455af34fd6e8c8f8c410e981bb66426b58a95 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sat, 8 Aug 2020 00:27:41 +0200 Subject: [PATCH] GS 3.24 compatibility * item actor * Gio.File.load_bytes not available --- files.js | 11 ++++++++++- menu.js | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/files.js b/files.js index 16bb534..0001cc4 100644 --- a/files.js +++ b/files.js @@ -64,7 +64,16 @@ var Image = new Lang.Class({ get bytes() { if (!this._bytes) { if (this.file) - this._bytes = this.file.load_bytes(null)[0]; + try { + // load_bytes available in GLib 2.56+ + this._bytes = this.file.load_bytes(null)[0]; + } catch(e) { + let [success_, contents] = this.file.load_contents(null); + if (contents instanceof Uint8Array) + this._bytes = ByteArray.toGBytes(contents); + else + this._bytes = contents.toGBytes(); + } else this._bytes = new GLib.Bytes(GLib.base64_decode(this.base64)); } diff --git a/menu.js b/menu.js index 2c97c36..911f082 100644 --- a/menu.js +++ b/menu.js @@ -156,10 +156,10 @@ var DrawingMenu = new Lang.Class({ this.actionButtons = []; let groupItem = new PopupMenu.PopupBaseMenuItem({ reactive: false, can_focus: false, style_class: "draw-on-your-screen-menu-group-item" }); - groupItem.add_child(this._createActionButton(_("Undo"), this.area.undo.bind(this.area), 'edit-undo-symbolic')); - groupItem.add_child(this._createActionButton(_("Redo"), this.area.redo.bind(this.area), 'edit-redo-symbolic')); - groupItem.add_child(this._createActionButton(_("Erase"), this.area.deleteLastElement.bind(this.area), 'edit-clear-all-symbolic')); - groupItem.add_child(this._createActionButton(_("Smooth"), this.area.smoothLastElement.bind(this.area), this.smoothIcon)); + getActor(groupItem).add_child(this._createActionButton(_("Undo"), this.area.undo.bind(this.area), 'edit-undo-symbolic')); + getActor(groupItem).add_child(this._createActionButton(_("Redo"), this.area.redo.bind(this.area), 'edit-redo-symbolic')); + getActor(groupItem).add_child(this._createActionButton(_("Erase"), this.area.deleteLastElement.bind(this.area), 'edit-clear-all-symbolic')); + getActor(groupItem).add_child(this._createActionButton(_("Smooth"), this.area.smoothLastElement.bind(this.area), this.smoothIcon)); this.menu.addMenuItem(groupItem); this._addSeparator(this.menu, true);