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



commit cb9378c212e6f86028d2242242c3dc3e693a446e
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 ++-
 data/ui/PlaylistDialogRow.ui            | 19 +++++++++++++++----
 gnomemusic/widgets/playlistdialog.py    |  8 ++++++--
 gnomemusic/widgets/playlistdialogrow.py |  6 ++++++
 5 files changed, 43 insertions(+), 7 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/data/ui/PlaylistDialogRow.ui b/data/ui/PlaylistDialogRow.ui
index 66eb8cf7..f52c3a88 100644
--- a/data/ui/PlaylistDialogRow.ui
+++ b/data/ui/PlaylistDialogRow.ui
@@ -6,11 +6,22 @@
       <class name="playlistdialog-row"/>
     </style>
     <child>
-      <object class="GtkLabel" id="_label">
-       <property name="ellipsize">end</property>
-        <property name="margin">8</property>
+      <object class="GtkBox" id="hbox">
         <property name="visible">True</property>
-        <property name="xalign">0.0</property>
+        <child>
+          <object class="GtkLabel" id="_label">
+            <property name="ellipsize">end</property>
+            <property name="margin">8</property>
+            <property name="visible">True</property>
+            <property name="xalign">0.0</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkImage" id="_selection_icon">
+            <property name="icon-name">object-select-symbolic</property>
+            <property name="icon-size">2</property>
+          </object>
+        </child>
       </object>
     </child>
   </template>
diff --git a/gnomemusic/widgets/playlistdialog.py b/gnomemusic/widgets/playlistdialog.py
index 15f6d4b6..46442120 100644
--- a/gnomemusic/widgets/playlistdialog.py
+++ b/gnomemusic/widgets/playlistdialog.py
@@ -128,10 +128,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.props.selected = (row == selected_row)
 
     @Gtk.Template.Callback()
     @log
diff --git a/gnomemusic/widgets/playlistdialogrow.py b/gnomemusic/widgets/playlistdialogrow.py
index c6df26a8..4de4d94d 100644
--- a/gnomemusic/widgets/playlistdialogrow.py
+++ b/gnomemusic/widgets/playlistdialogrow.py
@@ -33,8 +33,10 @@ class PlaylistDialogRow(Gtk.ListBoxRow):
     __gtype_name__ = "PlaylistDialogRow"
 
     playlist = GObject.Property(type=Grl.Media, default=None)
+    selected = GObject.Property(type=bool, default=False)
 
     _label = Gtk.Template.Child()
+    _selection_icon = Gtk.Template.Child()
 
     def __repr__(self):
         return "PlaylistDialogRow"
@@ -48,3 +50,7 @@ class PlaylistDialogRow(Gtk.ListBoxRow):
 
         self.props.playlist = playlist
         self._label.props.label = utils.get_media_title(playlist)
+
+        self.bind_property(
+            "selected", self._selection_icon, "visible",
+            GObject.BindingFlags.SYNC_CREATE)


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