[gnome-music/wip/jfelder/playlistdialog-listbox: 3/3] playlistdialog: Update listbox's style



commit fbdc32d7ac981840bdde0aa132c57cfdd4c90334
Author: Jean Felder <jfelder src gnome org>
Date:   Tue May 21 11:04:38 2019 +0200

    playlistdialog: Update listbox's style
    
    This way the dialog style looks closer to the original mockups.
    
    See: 
https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/music/wire-add-to-playlist-dialog.png

 data/org.gnome.Music.css             | 14 ++++++++++++++
 data/ui/PlaylistDialog.ui            |  3 ++-
 gnomemusic/widgets/playlistdialog.py | 27 +++++++++++++++++++++++----
 3 files changed, 39 insertions(+), 5 deletions(-)
---
diff --git a/data/org.gnome.Music.css b/data/org.gnome.Music.css
index f5ea3b7b..6caaa519 100644
--- a/data/org.gnome.Music.css
+++ b/data/org.gnome.Music.css
@@ -94,3 +94,17 @@ box#ArtistAlbumsWidget .artist-label {
 .tooltip-title {
   font-weight: bold;
 }
+
+/* PlaylistDialog */
+.playlistdialog-row {
+    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
+}
+
+.playlistdialog-row:selected {
+    color: @theme_fg_color;
+    background-color: @theme_insensitive_bg_color;
+}
+
+.playlistdialog-row:selected label {
+    color: @theme_text_color;
+}
diff --git a/data/ui/PlaylistDialog.ui b/data/ui/PlaylistDialog.ui
index 8f8e8034..b9d90c76 100644
--- a/data/ui/PlaylistDialog.ui
+++ b/data/ui/PlaylistDialog.ui
@@ -205,7 +205,8 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="selection_mode">single</property>
-                        <signal name="row-selected" handler="_on_row_selected" swapped="no"/>
+                        <property name="valign">start</property>
+                        <signal name="selected-rows-changed" handler="_on_selected_rows_changed" 
swapped="no"/>
                       </object>
                     </child>
                   </object>
diff --git a/gnomemusic/widgets/playlistdialog.py b/gnomemusic/widgets/playlistdialog.py
index c0530947..8e8d287f 100644
--- a/gnomemusic/widgets/playlistdialog.py
+++ b/gnomemusic/widgets/playlistdialog.py
@@ -46,12 +46,27 @@ class PlaylistDialogRow(Gtk.ListBoxRow):
 
         self.props.playlist = playlist
 
+        hbox = Gtk.Box()
+        self.add(hbox)
+
         title = utils.get_media_title(playlist)
-        label = Gtk.Label(label=title, margin=8, xalign=0.0)
-        self.add(label)
+        label = Gtk.Label(label=title, margin=10, xalign=0.0)
+        hbox.pack_start(label, False, False, 0)
+
+        self._selection_icon = Gtk.Image.new_from_icon_name(
+            "object-select-symbolic", Gtk.IconSize.SMALL_TOOLBAR)
+        hbox.pack_start(self._selection_icon, False, False, 0)
 
         self.get_style_context().add_class("playlistdialog-row")
         self.show_all()
+        self._selection_icon.props.visible = False
+
+    def display_selection_icon(self, selected):
+        """Displays the selection icon if the row is selected
+
+        :param bool selected: Indicate if the row is selected
+        """
+        self._selection_icon.props.visible = selected
 
 
 @Gtk.Template(resource_path="/org/gnome/Music/ui/PlaylistDialog.ui")
@@ -152,10 +167,14 @@ class PlaylistDialog(Gtk.Dialog):
 
     @Gtk.Template.Callback()
     @log
-    def _on_row_selected(self, listbox, row):
+    def _on_selected_rows_changed(self, klass):
         self._add_playlist_entry.props.text = ""
         self._add_playlist_button.props.sensitive = False
-        self._select_button.props.sensitive = (row is not None)
+        selected_row = self._listbox.get_selected_row()
+        self._select_button.props.sensitive = (selected_row is not None)
+
+        for row in self._listbox:
+            row.display_selection_icon(row == selected_row)
 
     @Gtk.Template.Callback()
     @log


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]