[gnome-music/wip/mschraal/artistsview-outlining: 4/5] songwidget: stack



commit d703375c53e7611054ddec172c2e5f787bc08b35
Author: Marinus Schraal <mschraal gnome org>
Date:   Mon Oct 1 00:55:22 2018 +0200

    songwidget: stack

 data/ui/SongWidget.ui            | 46 +++++++++++++++++++++++-----------------
 gnomemusic/widgets/songwidget.py | 18 ++++++++--------
 2 files changed, 35 insertions(+), 29 deletions(-)
---
diff --git a/data/ui/SongWidget.ui b/data/ui/SongWidget.ui
index 846f84b1..8ef6efb3 100644
--- a/data/ui/SongWidget.ui
+++ b/data/ui/SongWidget.ui
@@ -13,32 +13,38 @@
         <property name="spacing">3</property>
         <child>
           <object class="GtkBox" id="box3">
-            <property name="width_request">48</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="homogeneous">True</property>
             <child>
-              <object class="GtkImage" id="_play_icon">
-                <property name="can_focus">False</property>
-                <property name="icon_size">button</property>
-              </object>
-              <packing>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="_select_button">
+              <object class="GtkStack" id="_stack">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="receives_default">False</property>
-                <property name="no_show_all">True</property>
-                <property name="draw_indicator">True</property>
+                  <child>
+                    <object class="GtkImage" id="_play_icon">
+                      <property name="visible">True</property>
+                      <property name="can_focus">False</property>
+                    </object>
+                    <packing>
+                      <property name="name">icon</property>
+                      <property name="position">0</property>
+                    </packing>
+                  </child>
+                  <child>
+                    <object class="GtkCheckButton" id="_select_button">
+                      <property name="visible">True</property>
+                      <property name="can_focus">False</property>
+                      <property name="receives_default">False</property>
+                      <property name="draw_indicator">True</property>
+                      <property name="margin-start">6</property>
+                      <property name="margin-end">6</property>
+                    </object>
+                    <packing>
+                      <property name="name">check</property>
+                      <property name="position">1</property>
+                    </packing>
+                  </child>
+                <property name="visible-child">icon</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
             </child>
             <child>
               <object class="GtkLabel" id="_number_label">
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index 75bcaaa7..0cc6d61d 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -66,6 +66,7 @@ class SongWidget(Gtk.EventBox):
     _number_label = Gtk.Template.Child()
     _title_label = Gtk.Template.Child()
     _duration_label = Gtk.Template.Child()
+    _stack = Gtk.Template.Child()
     _star_eventbox = Gtk.Template.Child()
     _star_image = Gtk.Template.Child()
     _play_icon = Gtk.Template.Child()
@@ -103,11 +104,8 @@ class SongWidget(Gtk.EventBox):
 
         self._star_image.props.favorite = media.get_favourite()
 
-        self._select_button.set_visible(False)
-
-        self._play_icon.set_from_icon_name(
-            'media-playback-start-symbolic', Gtk.IconSize.SMALL_TOOLBAR)
-        self._play_icon.set_no_show_all(True)
+        self._play_icon.props.icon_name = None
+        self._play_icon.props.icon_size = Gtk.IconSize.SMALL_TOOLBAR
 
         self.bind_property(
             'selected', self._select_button, 'active',
@@ -173,9 +171,11 @@ class SongWidget(Gtk.EventBox):
         :param bool value: Selection mode
         """
         self._selection_mode = value
-        self._select_button.set_visible(value)
 
-        if not value:
+        if self._selection_mode:
+            self._stack.props.visible_child_name = "check"
+        else:
+            self._stack.props.visible_child_name = "icon"
             self.props.selected = False
 
     @GObject.Property
@@ -202,10 +202,10 @@ class SongWidget(Gtk.EventBox):
 
         style_ctx.remove_class('dim-label')
         style_ctx.remove_class('playing-song-label')
-        self._play_icon.set_visible(False)
+        self._play_icon.props.icon_name = ""
 
         if value == SongWidget.State.PLAYED:
             style_ctx.add_class('dim-label')
         elif value == SongWidget.State.PLAYING:
-            self._play_icon.set_visible(True)
+            self._play_icon.props.icon_name = "media-playback-start-symbolic"
             style_ctx.add_class('playing-song-label')


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