[gnome-music/wip/jfelder/lastfm-ui-part-2: 8/9] appmenu: Add a menu to configure Last.fm scrobbler
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/lastfm-ui-part-2: 8/9] appmenu: Add a menu to configure Last.fm scrobbler
- Date: Thu, 16 Jan 2020 21:55:46 +0000 (UTC)
commit 368669ea2990c13dd6ad35e26eabdbea6e92ded6
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 | 3 ++-
gnomemusic/application.py | 7 +++++++
gnomemusic/widgets/appmenu.py | 10 +++++++++-
3 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/AppMenu.ui b/data/ui/AppMenu.ui
index ae301568..c2d57db3 100644
--- a/data/ui/AppMenu.ui
+++ b/data/ui/AppMenu.ui
@@ -11,12 +11,13 @@
<property name="margin">6</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkModelButton" id="lastfm_account_button">
+ <object class="GtkModelButton" id="_lastfm_configure_button">
<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 cec31d2c..ba970f2e 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -44,6 +44,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
@@ -145,6 +146,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"]))
]
@@ -162,6 +164,11 @@ class Application(Gtk.Application):
except GLib.Error:
logging.warning("Help handler not available.")
+ def _lastfm_account(self, action, param):
+ lastfm_dialog = LastfmDialog(self._window, self._lastfm_scrobbler)
+ lastfm_dialog.run()
+ lastfm_dialog.destroy()
+
@log
def _about(self, action, param):
about = AboutDialog()
diff --git a/gnomemusic/widgets/appmenu.py b/gnomemusic/widgets/appmenu.py
index 837f4318..4bbaa417 100644
--- a/gnomemusic/widgets/appmenu.py
+++ b/gnomemusic/widgets/appmenu.py
@@ -34,6 +34,7 @@ class AppMenu(Gtk.PopoverMenu):
__gtype_name__ = "AppMenu"
_lastfm_box = Gtk.Template.Child()
+ _lastfm_configure_button = Gtk.Template.Child()
_lastfm_switch = Gtk.Template.Child()
def __repr__(self):
@@ -54,7 +55,14 @@ class AppMenu(Gtk.PopoverMenu):
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_ENABLED:
+ self._lastfm_configure_button.props.sensitive = False
+ return
+
+ self._lastfm_configure_button.props.sensitive = 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]