[gnome-music/wip/cdavis/hdywindow-hdyviewswitcher: 8/9] emptyview: Use HdyStatusPage




commit fe2f00c35bd041435f91c53591a5ec8dc4764f70
Author: Christopher Davis <brainblasted disroot org>
Date:   Thu Feb 4 00:53:51 2021 -0800

    emptyview: Use HdyStatusPage
    
    HdyStatusPage is a built in widget for empty/status
    views. We want to use it here instead of implementing
    our own.

 data/ui/EmptyView.ui            | 51 ++---------------------------------------
 gnomemusic/views/artistsview.py |  2 +-
 gnomemusic/views/emptyview.py   | 42 +++++++++++----------------------
 meson.build                     |  2 +-
 4 files changed, 18 insertions(+), 79 deletions(-)
---
diff --git a/data/ui/EmptyView.ui b/data/ui/EmptyView.ui
index c5ddc8d93..1bd5ee0fb 100644
--- a/data/ui/EmptyView.ui
+++ b/data/ui/EmptyView.ui
@@ -5,58 +5,11 @@
     <property name="transition_type">crossfade</property>
     <property name="visible">False</property>
     <child>
-      <object class="GtkBox" id="_container">
+      <object class="HdyStatusPage" id="_status_page">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <property name="can_focus">False</property>
-        <property name="halign">center</property>
-        <property name="valign">center</property>
         <property name="hexpand">True</property>
         <property name="vexpand">True</property>
-        <child>
-          <object class="GtkImage" id="_icon">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="valign">center</property>
-            <property name="pixel_size">128</property>
-            <property name="icon_name">emblem-music-symbolic</property>
-            <property name="icon_size">0</property>
-            <property name="margin-bottom">18</property>
-            <style>
-              <class name="grey-image"/>
-            </style>
-          </object>
-        </child>
-        <child>
-          <object class="GtkBox" id="box">
-            <property name="orientation">vertical</property>
-            <property name="visible">True</property>
-            <child>
-              <object class="GtkLabel" id="_main_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="halign">center</property>
-                <property name="xalign">0</property>
-                <property name="margin-bottom">12</property>
-                <style>
-                  <class name="no-music-found-label"/>
-                  <class name="dim-label"/>
-                </style>
-              </object>
-            </child>
-            <child>
-              <object class="GtkLabel" id="_information_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="justify">left</property>
-                <property name="use_markup">true</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-              </object>
-            </child>
-          </object>
-        </child>
+        <property name="icon_name">emblem-music-symbolic</property>
       </object>
     </child>
   </template>
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index bdffdadda..afa006e93 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -42,7 +42,7 @@ class ArtistsView(Gtk.Box):
     title = GObject.Property(
         type=str, default=_("Artists"), flags=GObject.ParamFlags.READABLE)
     icon_name = GObject.Property(type=str, default="system-users-symbolic",
-        flags=GObject.ParamFlags.READABLE)
+                                 flags=GObject.ParamFlags.READABLE)
 
     _artist_container = Gtk.Template.Child()
     _artist_view = Gtk.Template.Child()
diff --git a/gnomemusic/views/emptyview.py b/gnomemusic/views/emptyview.py
index 10155e551..a196c2292 100644
--- a/gnomemusic/views/emptyview.py
+++ b/gnomemusic/views/emptyview.py
@@ -27,8 +27,6 @@ from enum import IntEnum
 from gettext import gettext as _
 from gi.repository import GLib, GObject, Gtk, Tracker
 
-from gnomemusic.utils import ArtSize
-
 
 @Gtk.Template(resource_path="/org/gnome/Music/ui/EmptyView.ui")
 class EmptyView(Gtk.Stack):
@@ -51,9 +49,7 @@ class EmptyView(Gtk.Stack):
 
     __gtype_name__ = "EmptyView"
 
-    _information_label = Gtk.Template.Child()
-    _main_label = Gtk.Template.Child()
-    _icon = Gtk.Template.Child()
+    _status_page = Gtk.Template.Child()
 
     def __init__(self):
         super().__init__()
@@ -108,44 +104,34 @@ class EmptyView(Gtk.Stack):
             self._set_tracker_outdated_state()
 
     def _set_initial_state(self):
-        self._information_label.props.label = self._content_text
-        self._main_label.props.label = _("Hey DJ")
-        self._main_label.props.margin_bottom = 18
+        self._status_page.props.title = _("Hey DJ")
+        self._status_page.props.description = self._content_text
 
-        self._icon.props.resource = "/org/gnome/Music/icons/initial-state.png"
-        self._icon.props.margin_bottom = 32
-        self._icon.props.height_request = ArtSize.LARGE.height
-        self._icon.props.width_request = ArtSize.LARGE.width
+        self._status_page.props.icon_name = "initial-state"
 
     def _set_empty_state(self):
-        self._main_label.props.label = _("No Music Found")
-        self._information_label.props.label = self._content_text
+        self._status_page.props.title = _("No Music Found")
+        self._status_page.props.description = self._content_text
 
     def _set_search_state(self):
-        self._main_label.props.margin_bottom = 12
-        self._main_label.props.label = _("No Music Found")
-        self._icon.props.margin_bottom = 18
-        self._information_label.props.label = _("Try a Different Search")
+        self._status_page.props.title = _("No Music Found")
+        self._status_page.props.description = _("Try a Different Search")
 
     def _set_no_tracker_state(self):
-        self._main_label.props.margin_bottom = 12
-        self._main_label.props.label = _(
+        self._status_page.props.title = _(
             "GNOME Music could not connect to Tracker.")
-        self._icon.props.margin_bottom = 18
-        self._information_label.props.label = _(
+        self._status_page.props.description = _(
             "Your music files cannot be indexed without Tracker running.")
 
-        self._icon.props.icon_name = "dialog-error-symbolic"
+        self._status_page.props.icon_name = "dialog-error-symbolic"
 
     def _set_tracker_outdated_state(self):
-        self._main_label.props.margin_bottom = 12
-        self._main_label.props.label = _(
+        self._status_page.props.title = _(
             "Your system Tracker version seems outdated.")
-        self._icon.props.margin_bottom = 18
-        self._information_label.props.label = _(
+        self._status_page.props.description = _(
             "Music needs Tracker version 3.0.0 or higher.")
 
-        self._icon.props.icon_name = "dialog-error-symbolic"
+        self._status_page.props.icon_name = "dialog-error-symbolic"
 
     def select_all(self):
         """Cannot select songs from EmptyView."""
diff --git a/meson.build b/meson.build
index 142590cc5..27f99b3fc 100644
--- a/meson.build
+++ b/meson.build
@@ -44,7 +44,7 @@ PKGLIB_DIR = join_paths(get_option('prefix'), get_option('libdir'), APPLICATION_
 dependency('goa-1.0', version: '>= 3.35.90')
 dependency('gobject-introspection-1.0', version: '>= 1.35.0')
 dependency('gtk+-3.0', version: '>= 3.24.13')
-dependency('libhandy-1', version: '>= 1.0.0')
+dependency('libhandy-1', version: '>= 1.2.0')
 dependency('libdazzle-1.0', version: '>= 3.28.0')
 dependency('libmediaart-2.0', version: '>= 1.9.1')
 dependency('libsoup-2.4')


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