[gnome-music/wip/mschraal/emptyview-new-initial-state: 61/62] emptyview: Workaround for icon sizing issue




commit e823300877a4e962211cfcd51454608c99d1c70d
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Aug 14 21:52:30 2021 +0200

    emptyview: Workaround for icon sizing issue
    
    HdyStatusPage does not scale the svg welcome image.
    
    Add a workaround that hides part of the status page and add a child
    widget that mimics the look of the HdyStatusPage.

 data/ui/EmptyView.ui          | 39 +++++++++++++++++++++++++++++++++++++++
 gnomemusic/views/emptyview.py | 18 +++++++++++++++---
 2 files changed, 54 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/EmptyView.ui b/data/ui/EmptyView.ui
index 1bd5ee0fb..08baf6d58 100644
--- a/data/ui/EmptyView.ui
+++ b/data/ui/EmptyView.ui
@@ -13,4 +13,43 @@
       </object>
     </child>
   </template>
+  <object class="GtkBox" id="_initial_state">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="valign">start</property>
+    <property name="orientation">vertical</property>
+    <child>
+      <object class="GtkImage">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="resource">/org/gnome/Music/icons/welcome-music.svg</property>
+        <property name="height-request">600</property>
+        <property name="width-request">800</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkLabel" id="_title_label">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="justify">center</property>
+        <property name="label" translatable="yes">Welcome to Music</property>
+        <style>
+          <class name="title"/>
+          <class name="large-title"/>
+        </style>
+      </object>
+    </child>
+    <child>
+      <object class="GtkLabel" id="_description_label">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="justify">center</property>
+        <property name="use-markup">True</property>
+        <style>
+          <class name="description"/>
+          <class name="body"/>
+        </style>
+      </object>
+    </child>
+  </object>
 </interface>
diff --git a/gnomemusic/views/emptyview.py b/gnomemusic/views/emptyview.py
index 187bdf3fb..3ba4e9471 100644
--- a/gnomemusic/views/emptyview.py
+++ b/gnomemusic/views/emptyview.py
@@ -49,6 +49,8 @@ class EmptyView(Gtk.Stack):
 
     __gtype_name__ = "EmptyView"
 
+    _description_label = Gtk.Template.Child()
+    _initial_state = Gtk.Template.Child()
     _status_page = Gtk.Template.Child()
 
     def __init__(self):
@@ -74,6 +76,11 @@ class EmptyView(Gtk.Stack):
         folder_text = _("The contents of your {} will appear here.")
         self._content_text = folder_text.format(href_text)
 
+        # Hack to get to HdyClamp, so it can be hidden for the
+        # initial state.
+        child_of_child = self._status_page.get_child().get_child()
+        self._hdy_clamp = child_of_child.get_child().get_children()[0]
+
         self._state = EmptyView.State.INITIAL
 
     @GObject.Property(type=int, default=0, minimum=0, maximum=4)
@@ -92,6 +99,11 @@ class EmptyView(Gtk.Stack):
         :param int value: new state
         """
         self._state = value
+
+        self._hdy_clamp.props.visible = True
+        if len(self._status_page.get_children()) == 2:
+            self._status_page.remove(self._initial_state)
+
         if self._state == EmptyView.State.INITIAL:
             self._set_initial_state()
         elif self._state == EmptyView.State.EMPTY:
@@ -110,9 +122,9 @@ class EmptyView(Gtk.Stack):
         self._status_page.props.icon_name = "initial-state"
 
     def _set_empty_state(self):
-        self._status_page.props.title = _("Welcome to Music")
-        self._status_page.props.description = self._content_text
-        self._status_page.props.icon_name = "welcome-music"
+        self._hdy_clamp.props.visible = False
+        self._status_page.add(self._initial_state)
+        self._description_label.props.label = self._content_text
 
     def _set_search_state(self):
         self._status_page.props.title = _("No Music Found")


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