[gnome-music/wip/mschraal/core] sidebarrow: Switch to a playlist usage
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/core] sidebarrow: Switch to a playlist usage
- Date: Sat, 13 Jul 2019 22:42:52 +0000 (UTC)
commit f189e83277284088271fa2fe27bd23509b43fb83
Author: Jean Felder <jfelder src gnome org>
Date: Fri Jul 12 14:41:32 2019 +0200
sidebarrow: Switch to a playlist usage
SidebarRow is now used by ArtistsView anymore. It uses ArtistTile
instead.
Rename it to PlaylistTile
data/org.gnome.Music.gresource.xml | 2 +-
data/ui/PlaylistTile.ui | 16 +++++++++
data/ui/SidebarRow.ui | 38 ----------------------
gnomemusic/views/playlistsview.py | 23 ++++++-------
.../widgets/{sidebarrow.py => playlisttile.py} | 37 ++++++++-------------
5 files changed, 40 insertions(+), 76 deletions(-)
---
diff --git a/data/org.gnome.Music.gresource.xml b/data/org.gnome.Music.gresource.xml
index 62b6fcbd..7b64dd1f 100644
--- a/data/org.gnome.Music.gresource.xml
+++ b/data/org.gnome.Music.gresource.xml
@@ -20,10 +20,10 @@
<file preprocess="xml-stripblanks">ui/PlaylistControls.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistDialog.ui</file>
<file preprocess="xml-stripblanks">ui/PlaylistDialogRow.ui</file>
+ <file preprocess="xml-stripblanks">ui/PlaylistTile.ui</file>
<file preprocess="xml-stripblanks">ui/SearchBar.ui</file>
<file preprocess="xml-stripblanks">ui/SelectionBarMenuButton.ui</file>
<file preprocess="xml-stripblanks">ui/SelectionToolbar.ui</file>
- <file preprocess="xml-stripblanks">ui/SidebarRow.ui</file>
<file preprocess="xml-stripblanks">ui/SongWidget.ui</file>
<file preprocess="xml-stripblanks">ui/TwoLineTip.ui</file>
<file preprocess="xml-stripblanks">ui/Window.ui</file>
diff --git a/data/ui/PlaylistTile.ui b/data/ui/PlaylistTile.ui
new file mode 100644
index 00000000..dceea3c9
--- /dev/null
+++ b/data/ui/PlaylistTile.ui
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="PlaylistTile" parent="GtkListBoxRow">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLabel" id="_label">
+ <property name="can_focus">False</property>
+ <property name="ellipsize">end</property>
+ <property name="halign">start</property>
+ <property name="hexpand">False</property>
+ <property name="margin">16</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/gnomemusic/views/playlistsview.py b/gnomemusic/views/playlistsview.py
index 08af3cd2..b521dd82 100644
--- a/gnomemusic/views/playlistsview.py
+++ b/gnomemusic/views/playlistsview.py
@@ -33,7 +33,7 @@ from gnomemusic.widgets.notificationspopup import PlaylistNotification
from gnomemusic.widgets.playlistcontextmenu import PlaylistContextMenu
from gnomemusic.widgets.playlistcontrols import PlaylistControls
from gnomemusic.widgets.playlistdialog import PlaylistDialog
-from gnomemusic.widgets.sidebarrow import SidebarRow
+from gnomemusic.widgets.playlisttile import PlaylistTile
from gnomemusic.widgets.songwidget import SongWidget
@@ -152,10 +152,7 @@ class PlaylistsView(BaseView):
:param GrlMedia playlist: playlist to add
:param int index: position
"""
- row = SidebarRow()
- row.props.text = playlist.props.title
- row.playlist = playlist
-
+ row = PlaylistTile(playlist)
return row
def _on_playlists_loaded(self, klass):
@@ -211,7 +208,8 @@ class PlaylistsView(BaseView):
song_widget = selected_row.get_child()
coresong = song_widget.props.coresong
- selected_playlist = self._sidebar.get_selected_row().playlist
+ selection = self._sidebar.get_selected_row()
+ selected_playlist = selection.props.playlist
notification = PlaylistNotification( # noqa: F841
self._window.notifications_popup, self._coremodel,
@@ -221,7 +219,7 @@ class PlaylistsView(BaseView):
@log
def _on_playlist_activated(self, sidebar, row, data=None):
"""Update view with content from selected playlist"""
- playlist = row.playlist
+ playlist = row.props.playlist
playlist_name = playlist.props.title
if self.rename_active:
@@ -274,21 +272,19 @@ class PlaylistsView(BaseView):
@log
def _stage_playlist_for_renaming(self, menuitem, data=None):
selection = self._sidebar.get_selected_row()
- pl_torename = selection.playlist
+ pl_torename = selection.props.playlist
self._pl_ctrls.enable_rename_playlist(pl_torename)
@log
def _on_playlist_renamed(self, arguments, new_name):
selection = self._sidebar.get_selected_row()
- selection.props.text = new_name
-
- pl_torename = selection.playlist
+ pl_torename = selection.props.playlist
pl_torename.rename(new_name)
@log
def _stage_playlist_for_deletion(self, menutime, data=None):
selected_row = self._sidebar.get_selected_row()
- selected_playlist = selected_row.playlist
+ selected_playlist = selected_row.props.playlist
notification = PlaylistNotification( # noqa: F841
self._window.notifications_popup, self._coremodel,
@@ -303,7 +299,8 @@ class PlaylistsView(BaseView):
def _on_song_widget_moved(self, target, source_position):
target_position = target.get_parent().get_index()
- current_playlist = self._sidebar.get_selected_row().playlist
+ selection = self._sidebar.get_selected_row()
+ current_playlist = selection.props.playlist
current_playlist.reorder(source_position, target_position)
@log
diff --git a/gnomemusic/widgets/sidebarrow.py b/gnomemusic/widgets/playlisttile.py
similarity index 59%
rename from gnomemusic/widgets/sidebarrow.py
rename to gnomemusic/widgets/playlisttile.py
index 06342df8..827f025e 100644
--- a/gnomemusic/widgets/sidebarrow.py
+++ b/gnomemusic/widgets/playlisttile.py
@@ -25,45 +25,34 @@
from gi.repository import GObject, Gtk
from gnomemusic import log
-from gnomemusic.coreartist import CoreArtist
+from gnomemusic.grilowrappers.grltrackerplaylists import Playlist
-@Gtk.Template(resource_path='/org/gnome/Music/ui/SidebarRow.ui')
-class SidebarRow(Gtk.ListBoxRow):
+@Gtk.Template(resource_path="/org/gnome/Music/ui/PlaylistTile.ui")
+class PlaylistTile(Gtk.ListBoxRow):
"""Row for sidebars
Contains a label and an optional checkbox.
"""
- __gtype_name__ = 'SidebarRow'
+ __gtype_name__ = "PlaylistTile"
- _check = Gtk.Template.Child()
_label = Gtk.Template.Child()
- _revealer = Gtk.Template.Child()
- coreartist = GObject.Property(type=CoreArtist, default=None)
- selected = GObject.Property(type=bool, default=False)
- selection_mode = GObject.Property(type=bool, default=False)
+ playlist = GObject.Property(type=Playlist, default=None)
text = GObject.Property(type=str, default='')
def __repr__(self):
- return '<SidebarRow>'
+ return "<PlaylistTile>"
@log
- def __init__(self, coreartist=None):
+ def __init__(self, playlist):
super().__init__()
- self.props.coreartist = coreartist
+ self.props.playlist = playlist
- self.bind_property(
- 'selected', self._check, 'active',
- GObject.BindingFlags.BIDIRECTIONAL)
- if coreartist:
- self.bind_property(
- "selected", coreartist, "selected",
- GObject.BindingFlags.BIDIRECTIONAL)
- self.bind_property('selection-mode', self._revealer, 'reveal-child')
- self.bind_property('text', self._label, 'label')
- self.bind_property('text', self._label, 'tooltip-text')
-
- self.show()
+ self.props.playlist.bind_property(
+ "title", self._label, "label", GObject.BindingFlags.SYNC_CREATE)
+ self.props.playlist.bind_property(
+ "title", self._label, "tooltip-text",
+ GObject.BindingFlags.SYNC_CREATE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]