[gnome-music/wip/jfelder/lastfm-ui-part-2: 23/24] appmenu: Add a menu to configure Last.fm scrobbler
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/lastfm-ui-part-2: 23/24] appmenu: Add a menu to configure Last.fm scrobbler
- Date: Sat, 15 Feb 2020 11:16:51 +0000 (UTC)
commit 4016b63c348ee5783dd2939e5ee7c3df32ff7e19
Author: Jean Felder <jfelder src gnome org>
Date: Tue Jan 14 21:06:37 2020 +0100
appmenu: Add a menu to configure Last.fm scrobbler
The LastfmDialog can be launched if a Last.fm account can be
configured (scrobbler's state is at least NOT_CONFIGURED).
If Goa Last.fm support is disabled, the button stays insensitive.
Related: #218
data/ui/AppMenu.ui | 2 +-
gnomemusic/application.py | 7 +++++++
gnomemusic/widgets/appmenu.py | 13 ++++++++++++-
3 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/AppMenu.ui b/data/ui/AppMenu.ui
index ae301568..82168527 100644
--- a/data/ui/AppMenu.ui
+++ b/data/ui/AppMenu.ui
@@ -15,8 +15,8 @@
<property name="can_focus">False</property>
<property name="halign">fill</property>
<property name="hexpand">False</property>
- <property name="sensitive">False</property>
<property name="visible">True</property>
+ <property name="action_name">app.lastfm-configure</property>
<property name="text" translatable="yes">Last.fm Account</property>
</object>
<packing>
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index af57125b..1ec542f6 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -43,6 +43,7 @@ from gnomemusic.pauseonsuspend import PauseOnSuspend
from gnomemusic.player import Player
from gnomemusic.scrobbler import LastFmScrobbler
from gnomemusic.widgets.aboutdialog import AboutDialog
+from gnomemusic.widgets.lastfmdialog import LastfmDialog
from gnomemusic.window import Window
@@ -151,6 +152,7 @@ class Application(Gtk.Application):
action_entries = [
('about', self._about, None),
("help", self._help, ("app.help", ["F1"])),
+ ("lastfm-configure", self._lastfm_account, None),
("quit", self._quit, ("app.quit", ["<Ctrl>Q"]))
]
@@ -167,6 +169,11 @@ class Application(Gtk.Application):
except GLib.Error:
self._log.message("Help handler not available.")
+ def _lastfm_account(self, action, param):
+ lastfm_dialog = LastfmDialog(self._window, self._lastfm_scrobbler)
+ lastfm_dialog.run()
+ lastfm_dialog.destroy()
+
def _about(self, action, param):
about = AboutDialog()
about.props.transient_for = self._window
diff --git a/gnomemusic/widgets/appmenu.py b/gnomemusic/widgets/appmenu.py
index 997be53d..4b3598c9 100644
--- a/gnomemusic/widgets/appmenu.py
+++ b/gnomemusic/widgets/appmenu.py
@@ -45,13 +45,24 @@ class AppMenu(Gtk.PopoverMenu):
self._lastfm_switcher_id = None
+ self._lastfm_configure_action = application.lookup_action(
+ "lastfm-configure")
+
self._lastfm_scrobbler = application.props.lastfm_scrobbler
self._lastfm_scrobbler.connect(
"notify::can-scrobble", self._on_scrobbler_state_changed)
+ self._on_scrobbler_state_changed(None, None)
def _on_scrobbler_state_changed(self, klass, args):
state = self._lastfm_scrobbler.props.account_state
- if state <= GoaLastFM.State.NOT_CONFIGURED:
+
+ if state == GoaLastFM.State.NOT_AVAILABLE:
+ self._lastfm_configure_action.props.enabled = False
+ return
+
+ self._lastfm_configure_action.props.enabled = True
+
+ if state == GoaLastFM.State.NOT_CONFIGURED:
self._lastfm_box.props.sensitive = False
if self._lastfm_switcher_id is not None:
self._lastfm_switch.disconnect(self._lastfm_switcher_id)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]