From dc746064f445b41bb9c623edc531168f13ee1999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1nos=20T=C5=91berling?= <30544813+jtoberling@users.noreply.github.com> Date: Fri, 13 Oct 2023 12:17:18 +0200 Subject: [PATCH] yarr@jtoberling: Changes due to reloading issue (#929) * fix reloading issue --- .../files/yarr@jtoberling/desklet.js | 27 ++++++++++--------- .../files/yarr@jtoberling/linkbutton.js | 25 ----------------- .../files/yarr@jtoberling/metadata.json | 2 +- 3 files changed, 16 insertions(+), 38 deletions(-) delete mode 100644 yarr@jtoberling/files/yarr@jtoberling/linkbutton.js diff --git a/yarr@jtoberling/files/yarr@jtoberling/desklet.js b/yarr@jtoberling/files/yarr@jtoberling/desklet.js index f79a78967..a8a3505f6 100755 --- a/yarr@jtoberling/files/yarr@jtoberling/desklet.js +++ b/yarr@jtoberling/files/yarr@jtoberling/desklet.js @@ -334,13 +334,13 @@ class YarrDesklet extends Desklet.Desklet { context, { 'channel': feed.name, - 'timestamp': parsedDate, + 'timestamp': parsedDate, 'pubDate': item.pubDate, 'title': item.title, - 'link': item.link, - 'category': catStr, - 'description': item.description, - "labelColor": feed.labelcolor + 'link': item.link, + 'category': catStr, + 'description': item.description, + "labelColor": feed.labelcolor } ); } @@ -423,6 +423,11 @@ class YarrDesklet extends Desklet.Desklet { return retStr; } + onClickedButton(selfObj, p2, uri) { + Gio.app_info_launch_default_for_uri(uri, global.create_app_launch_context()); + } + + displayItems(context) { let updated= new Date(); @@ -433,9 +438,8 @@ class YarrDesklet extends Desklet.Desklet { for(let [key, item] of context.items ) { const lineBox = new St.BoxLayout({ vertical: false }); - - const feedButton = new YarrLinkButton.YarrLinkButton({ label: "["+item.channel +"]" , style_class: 'channelbutton', style: 'background-color: ' + item.labelColor }); - feedButton.setUri(item.link); + + const feedButton = new St.Button({ label: "["+item.channel +"]" , style_class: 'channelbutton', style: 'width: 80px; background-color: ' + item.labelColor }); let toolTipText = '' + this.formatTextWrap(item.channel + ': ' + item.title, 100) + '' @@ -450,10 +454,9 @@ class YarrDesklet extends Desklet.Desklet { toolTip._tooltip.clutter_text.allocate_preferred_size(Clutter.AllocationFlags.NONE); toolTip._tooltip.queue_relayout(); - lineBox.add( feedButton ); - feedButton.connect("clicked", Lang.bind(this, function(p1, p2) { - Gio.app_info_launch_default_for_uri(p1.getUri(), global.create_app_launch_context()); - })); + lineBox.add(feedButton); + + this._signals.connect( feedButton, 'clicked', (...args) => this.onClickedButton(...args, item.link) ); const dateLabel = new St.Label({ text: ' ' + context._formatedDate(item.timestamp, false) + ' ', style: 'text-align: center;' }); lineBox.add(dateLabel); diff --git a/yarr@jtoberling/files/yarr@jtoberling/linkbutton.js b/yarr@jtoberling/files/yarr@jtoberling/linkbutton.js deleted file mode 100644 index ca8c449f9..000000000 --- a/yarr@jtoberling/files/yarr@jtoberling/linkbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -const Lang = imports.lang; -const St = imports.gi.St; -const GObject = imports.gi.GObject; - -// FIXEE: Reload should not redefine GType - needs a workaround -// Desklet works only by restart cinnamon. - -const YarrLinkButton = GObject.registerClass({ - }, - class YarrLinkButton extends St.Button { - - constructor(params) { - super(params); - } - - setUri(puri) { - this.uri = puri; - } - - getUri(uri) { - return this.uri; - } - -}); - diff --git a/yarr@jtoberling/files/yarr@jtoberling/metadata.json b/yarr@jtoberling/files/yarr@jtoberling/metadata.json index 9ce938eab..69611959c 100755 --- a/yarr@jtoberling/files/yarr@jtoberling/metadata.json +++ b/yarr@jtoberling/files/yarr@jtoberling/metadata.json @@ -2,7 +2,7 @@ "max-instances": "1", "description": "Yet Another RSS Reader - now as Cinnamon Desklet", "name": "Yet Another RSS Reader", - "version": "0.0.3", + "version": "0.0.4", "uuid": "yarr@jtoberling", "multiversion": true, "author": "jtoberling",