From 7894ab25ebed0698bfc7d167f92a2971adf10f9e Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Tue, 24 Jul 2012 20:28:48 +0200 Subject: [PATCH] Flattr: Flattr-on-play for QML UI, fixes for Gtk UI --- share/gpodder/ui/qml/Main.qml | 11 +++++++---- src/gpodder/gtkui/main.py | 6 ++++-- src/gpodder/qmlui/__init__.py | 8 ++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/share/gpodder/ui/qml/Main.qml b/share/gpodder/ui/qml/Main.qml index 9ff7f9e06..b58405f48 100644 --- a/share/gpodder/ui/qml/Main.qml +++ b/share/gpodder/ui/qml/Main.qml @@ -103,10 +103,13 @@ Image { } function togglePlayback(episode) { - if (episode !== undefined && episode.qfiletype == 'video') { - controller.playVideo(episode) - } else { - mediaPlayer.togglePlayback(episode) + if (episode !== undefined) { + if (episode.qfiletype == 'video') { + controller.playVideo(episode); + } else { + mediaPlayer.togglePlayback(episode); + } + controller.onPlayback(episode); } } diff --git a/src/gpodder/gtkui/main.py b/src/gpodder/gtkui/main.py index 63350fa4d..d3b0a1a4d 100644 --- a/src/gpodder/gtkui/main.py +++ b/src/gpodder/gtkui/main.py @@ -1908,9 +1908,11 @@ def error_handler(filename, err): logger.error('Calling Panucci using D-Bus', exc_info=True) # flattr episode if auto-flattr is enabled - if self.config.flattr.token and self.config.flattr.flattr_on_play: + if (episode.payment_url and self.config.flattr.token and + self.config.flattr.flattr_on_play): success, message = self.flattr.flattr_url(episode.payment_url) - self.show_message(message, title=_('Flattr status'), important=not success) + self.show_message(message, title=_('Flattr status'), + important=not success) groups[player].append(filename) diff --git a/src/gpodder/qmlui/__init__.py b/src/gpodder/qmlui/__init__.py index 73feedc9c..972cf2b6b 100644 --- a/src/gpodder/qmlui/__init__.py +++ b/src/gpodder/qmlui/__init__.py @@ -168,6 +168,14 @@ def getFlattrButtonText(self): flattrButtonText = Property(unicode, getFlattrButtonText, setFlattrButtonText, notify=flattrButtonTextChanged) + @Slot(QObject) + def onPlayback(self, qepisode): + if (qepisode.payment_url and self.root.config.flattr.token and + self.root.config.flattr.flattr_on_play): + success, message = self._flattr.flattr_url(qepisode.payment_url) + if not success: + logger.warn('Flattr message on playback action: %s', message) + @Slot(QObject) def updateFlattrButtonText(self, qepisode): self.setFlattrButtonText('')