[gnome-music/wip/jfelder/songwidget-menu-v3: 3/5] songwidgetmenu: Add support for corealbum
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/songwidget-menu-v3: 3/5] songwidgetmenu: Add support for corealbum
- Date: Thu, 29 Jul 2021 15:23:05 +0000 (UTC)
commit 1e680603e0f8ff2a54b64d4f415bbcf8e8325969
Author: Jean Felder <jfelder src gnome org>
Date: Sun May 9 16:08:23 2021 +0200
songwidgetmenu: Add support for corealbum
With this change it will be possible to display this menu in the
SongWidgets from AlbumsView and ArtistsView in the next commit.
gnomemusic/widgets/songwidgetmenu.py | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/gnomemusic/widgets/songwidgetmenu.py b/gnomemusic/widgets/songwidgetmenu.py
index c6ba374e9..1de410cff 100644
--- a/gnomemusic/widgets/songwidgetmenu.py
+++ b/gnomemusic/widgets/songwidgetmenu.py
@@ -23,15 +23,17 @@
# delete this exception statement from your version.
from __future__ import annotations
+from typing import Union
import typing
from gi.repository import Gtk
+from gnomemusic.grilowrappers.grltrackerplaylists import Playlist
from gnomemusic.widgets.notificationspopup import PlaylistNotification
from gnomemusic.widgets.playlistdialog import PlaylistDialog
if typing.TYPE_CHECKING:
from gnomemusic.application import Application
- from gnomemusic.grilowrappers.grltrackerplaylists import Playlist
+ from gnomemusic.corealbum import CoreAlbum
from gnomemusic.widgets.songwidget import SongWidget
@@ -44,7 +46,7 @@ class SongWidgetMenu(Gtk.PopoverMenu):
def __init__(
self, application: Application, song_widget: SongWidget,
- playlist: Playlist) -> None:
+ coreobject: Union[CoreAlbum, Playlist]) -> None:
"""Menu to interact with the song of a SongWidget.
:param Application application: The application object
@@ -58,12 +60,16 @@ class SongWidgetMenu(Gtk.PopoverMenu):
self._player = application.props.player
self._window = application.props.window
- self._playlist = playlist
+ self._coreobject = coreobject
self._song_widget = song_widget
self._coresong = song_widget.props.coresong
- self._remove_from_playlist_button.props.sensitive = (
- not playlist.props.is_smart)
+ if isinstance(self._coreobject, Playlist):
+ self._remove_from_playlist_button.props.visible = True
+ self._remove_from_playlist_button.props.sensitive = (
+ not self._coreobject.props.is_smart)
+ else:
+ self._remove_from_playlist_button.props.visible = False
@Gtk.Template.Callback()
def _on_play_clicked(self, widget: Gtk.Button) -> None:
@@ -76,7 +82,7 @@ class SongWidgetMenu(Gtk.PopoverMenu):
signal_id = self._coremodel.connect(
"playlist-loaded", _on_playlist_loaded)
- self._coremodel.props.active_core_object = self._playlist
+ self._coremodel.props.active_core_object = self._coreobject
@Gtk.Template.Callback()
def _on_add_to_playlist_clicked(self, widget: Gtk.Button) -> None:
@@ -95,5 +101,5 @@ class SongWidgetMenu(Gtk.PopoverMenu):
position = self._song_widget.get_index()
notification = PlaylistNotification( # noqa: F841
self._window.notifications_popup, self._application,
- PlaylistNotification.Type.SONG, self._playlist, position,
+ PlaylistNotification.Type.SONG, self._coreobject, position,
self._coresong)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]