[epiphany/wip/cdavis/empty-page-styling: 1/4] data-view: Use HdyStatusPage for empty states




commit 14ee07ae106aaf0702a133f2e6a4ec013debd8a3
Author: Christopher Davis <brainblasted disroot org>
Date:   Wed Feb 10 21:52:21 2021 -0800

    data-view: Use HdyStatusPage for empty states
    
    libhandy now provides a built-in empty page widget.
    For consistency across apps, we should use it for our
    empty states.

 src/preferences/ephy-data-view.c |  14 ++--
 src/resources/gtk/data-view.ui   | 134 ++-------------------------------------
 2 files changed, 12 insertions(+), 136 deletions(-)
---
diff --git a/src/preferences/ephy-data-view.c b/src/preferences/ephy-data-view.c
index a01047e08..18a1a6daf 100644
--- a/src/preferences/ephy-data-view.c
+++ b/src/preferences/ephy-data-view.c
@@ -32,8 +32,7 @@ typedef struct {
   GtkWidget *search_entry;
   GtkWidget *search_button;
   GtkWidget *stack;
-  GtkWidget *empty_title_label;
-  GtkWidget *empty_description_label;
+  GtkWidget *empty_page;
   GtkWidget *spinner;
 
   gboolean is_loading : 1;
@@ -200,10 +199,10 @@ ephy_data_view_set_property (GObject      *object,
       atk_object_set_description (gtk_widget_get_accessible (GTK_WIDGET (self)), g_value_get_string (value));
       break;
     case PROP_EMPTY_TITLE:
-      gtk_label_set_text (GTK_LABEL (priv->empty_title_label), g_value_get_string (value));
+      hdy_status_page_set_title (HDY_STATUS_PAGE (priv->empty_page), g_value_get_string (value));
       break;
     case PROP_EMPTY_DESCRIPTION:
-      gtk_label_set_text (GTK_LABEL (priv->empty_description_label), g_value_get_string (value));
+      hdy_status_page_set_description (HDY_STATUS_PAGE (priv->empty_page), g_value_get_string (value));
       break;
     case PROP_IS_LOADING:
       ephy_data_view_set_is_loading (self, g_value_get_boolean (value));
@@ -252,10 +251,10 @@ ephy_data_view_get_property (GObject    *object,
       g_value_set_string (value, gtk_entry_get_placeholder_text (GTK_ENTRY (priv->search_entry)));
       break;
     case PROP_EMPTY_TITLE:
-      g_value_set_string (value, gtk_label_get_text (GTK_LABEL (priv->empty_title_label)));
+      g_value_set_string (value, hdy_status_page_get_title (HDY_STATUS_PAGE (priv->empty_page)));
       break;
     case PROP_EMPTY_DESCRIPTION:
-      g_value_set_string (value, gtk_label_get_text (GTK_LABEL (priv->empty_description_label)));
+      g_value_set_string (value, hdy_status_page_get_description (HDY_STATUS_PAGE (priv->empty_page)));
       break;
     case PROP_SEARCH_TEXT:
       g_value_set_string (value, ephy_data_view_get_search_text (self));
@@ -445,8 +444,7 @@ ephy_data_view_class_init (EphyDataViewClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, EphyDataView, header_bar);
   gtk_widget_class_bind_template_child_private (widget_class, EphyDataView, back_button);
   gtk_widget_class_bind_template_child_private (widget_class, EphyDataView, clear_button);
-  gtk_widget_class_bind_template_child_private (widget_class, EphyDataView, empty_title_label);
-  gtk_widget_class_bind_template_child_private (widget_class, EphyDataView, empty_description_label);
+  gtk_widget_class_bind_template_child_private (widget_class, EphyDataView, empty_page);
   gtk_widget_class_bind_template_child_private (widget_class, EphyDataView, search_bar);
   gtk_widget_class_bind_template_child_private (widget_class, EphyDataView, search_button);
   gtk_widget_class_bind_template_child_private (widget_class, EphyDataView, search_entry);
diff --git a/src/resources/gtk/data-view.ui b/src/resources/gtk/data-view.ui
index 5bfff6c07..23e8592f4 100644
--- a/src/resources/gtk/data-view.ui
+++ b/src/resources/gtk/data-view.ui
@@ -103,142 +103,20 @@
               </packing>
             </child>
             <child>
-              <object class="GtkScrolledWindow">
-                <property name="can_focus">False</property>
-                <property name="expand">True</property>
-                <property name="hscrollbar_policy">never</property>
+              <object class="HdyStatusPage" id="empty_page">
                 <property name="visible">True</property>
-                <child>
-                  <object class="GtkBox">
-                    <property name="can_focus">False</property>
-                    <property name="halign">center</property>
-                    <property name="orientation">vertical</property>
-                    <property name="valign">center</property>
-                    <property name="vexpand">True</property>
-                    <property name="visible">True</property>
-                    <child>
-                      <object class="GtkImage">
-                        <property name="can_focus">False</property>
-                        <property name="icon_name">web-browser-symbolic</property>
-                        <property name="icon_size">0</property>
-                        <property name="margin_bottom">18</property>
-                        <property name="pixel_size">128</property>
-                        <property name="valign">center</property>
-                        <property name="visible">True</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkBox">
-                        <property name="can_focus">False</property>
-                        <property name="margin_end">12</property>
-                        <property name="margin_start">12</property>
-                        <property name="orientation">vertical</property>
-                        <property name="visible">True</property>
-                        <child>
-                          <object class="GtkLabel" id="empty_title_label">
-                            <property name="can_focus">False</property>
-                            <property name="halign">center</property>
-                            <property name="justify">center</property>
-                            <property name="margin_bottom">12</property>
-                            <property name="opacity">0.5</property>
-                            <property name="visible">True</property>
-                            <property name="wrap">True</property>
-                            <attributes>
-                              <attribute name="scale" value="2"/>
-                              <attribute name="weight" value="bold"/>
-                            </attributes>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="empty_description_label">
-                            <property name="can_focus">False</property>
-                            <property name="justify">center</property>
-                            <property name="margin_bottom">6</property>
-                            <property name="opacity">0.5</property>
-                            <property name="use_markup">True</property>
-                            <property name="visible">True</property>
-                            <property name="wrap">True</property>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                </child>
+                <property name="icon_name">web-browser-symbolic</property>
               </object>
               <packing>
                 <property name="name">empty</property>
               </packing>
             </child>
             <child>
-              <object class="GtkScrolledWindow">
-                <property name="can_focus">False</property>
-                <property name="expand">True</property>
-                <property name="hscrollbar_policy">never</property>
+              <object class="HdyStatusPage">
                 <property name="visible">True</property>
-                <child>
-                  <object class="GtkBox">
-                    <property name="can_focus">False</property>
-                    <property name="halign">center</property>
-                    <property name="orientation">vertical</property>
-                    <property name="valign">center</property>
-                    <property name="vexpand">True</property>
-                    <property name="visible">True</property>
-                    <child>
-                      <object class="GtkImage">
-                        <property name="can_focus">False</property>
-                        <property name="icon_name">edit-find-symbolic</property>
-                        <property name="icon_size">0</property>
-                        <property name="margin_bottom">18</property>
-                        <property name="pixel_size">128</property>
-                        <property name="valign">center</property>
-                        <property name="visible">True</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkBox">
-                        <property name="can_focus">False</property>
-                        <property name="margin_end">12</property>
-                        <property name="margin_start">12</property>
-                        <property name="orientation">vertical</property>
-                        <property name="visible">True</property>
-                        <child>
-                          <object class="GtkLabel">
-                            <property name="can_focus">False</property>
-                            <property name="halign">center</property>
-                            <property name="justify">center</property>
-                            <property name="label" translatable="yes">No Results Found</property>
-                            <property name="margin_bottom">12</property>
-                            <property name="opacity">0.5</property>
-                            <property name="visible">True</property>
-                            <property name="wrap">True</property>
-                            <attributes>
-                              <attribute name="scale" value="2"/>
-                              <attribute name="weight" value="bold"/>
-                            </attributes>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkLabel">
-                            <property name="can_focus">False</property>
-                            <property name="justify">center</property>
-                            <property name="label" translatable="yes">Try a different search</property>
-                            <property name="margin_bottom">6</property>
-                            <property name="opacity">0.5</property>
-                            <property name="use_markup">True</property>
-                            <property name="visible">True</property>
-                            <property name="wrap">True</property>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                </child>
+                <property name="icon_name">edit-find-symbolic</property>
+                <property name="title" translatable="yes">No Results Found</property>
+                <property name="description" translatable="yes">Try a different search</property>
               </object>
               <packing>
                 <property name="name">no-results</property>


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