[gnome-music/wip/jfelder/playlist-improvements: 5/5] playlistsview: Add a separator before the first user playlist
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/playlist-improvements: 5/5] playlistsview: Add a separator before the first user playlist
- Date: Tue, 29 Jun 2021 11:30:32 +0000 (UTC)
commit 4f7668eeb51e3d37049bf5463793507d1c9266c8
Author: Jean Felder <jfelder src gnome org>
Date: Tue Jun 29 13:28:27 2021 +0200
playlistsview: Add a separator before the first user playlist
Related: #446
gnomemusic/views/playlistsview.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
diff --git a/gnomemusic/views/playlistsview.py b/gnomemusic/views/playlistsview.py
index 4a6ccf0b7..4c1a2f782 100644
--- a/gnomemusic/views/playlistsview.py
+++ b/gnomemusic/views/playlistsview.py
@@ -23,6 +23,7 @@
# delete this exception statement from your version.
from gettext import gettext as _
+from typing import Optional
from gi.repository import GObject, Gtk
@@ -64,6 +65,7 @@ class PlaylistsView(Gtk.Paned):
self._playlist_widget = PlaylistsWidget(application, self)
self.add(self._playlist_widget)
+ self._sidebar.set_header_func(self._sidebar_header_func)
self._sidebar.bind_model(self._model, self._add_playlist_to_sidebar)
self._coremodel.connect(
@@ -72,6 +74,20 @@ class PlaylistsView(Gtk.Paned):
self._model.connect("items-changed", self._on_playlists_model_changed)
self._on_playlists_model_changed(self._model, 0, 0, 0)
+ def _sidebar_header_func(
+ self, row: Gtk.ListBoxRow,
+ before: Optional[Gtk.ListBoxRow]) -> None:
+ if (before
+ and before.props.playlist.props.is_smart
+ and not row.props.playlist.props.is_smart):
+ separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
+ separator.props.height_request = 2
+ separator.props.margin_end = 16
+ separator.props.margin_start = 16
+ row.set_header(separator)
+ else:
+ row.set_header(None)
+
def _add_playlist_to_sidebar(self, playlist):
"""Add a playlist to sidebar
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]