[gnome-control-center/wip/cdavis/40-consistency] applications: Use HdyStatusPage for empty state



commit f7b6582fc329778e4e01e8c5996f95748dbafd25
Author: Christopher Davis <brainblasted disroot org>
Date:   Thu Feb 11 21:46:28 2021 -0800

    applications: Use HdyStatusPage for empty state
    
    libhandy provides a pre-built widget for empty states.
    Instead of rolling our own, we should make use of that.

 meson.build                                  |  2 +-
 panels/applications/cc-applications-panel.c  |  7 +++--
 panels/applications/cc-applications-panel.ui | 44 ++++------------------------
 3 files changed, 10 insertions(+), 43 deletions(-)
---
diff --git a/meson.build b/meson.build
index 22b9f8241..ddad09f42 100644
--- a/meson.build
+++ b/meson.build
@@ -99,7 +99,7 @@ libgvc = subproject(
 )
 libgvc_dep = libgvc.get_variable('libgvc_dep')
 
-libhandy_dep = dependency('libhandy-1', version: '>= 1.0.0', required: false)
+libhandy_dep = dependency('libhandy-1', version: '>= 1.1.0', required: false)
 if not libhandy_dep.found()
   libhandy = subproject(
     'libhandy',
diff --git a/panels/applications/cc-applications-panel.c b/panels/applications/cc-applications-panel.c
index 42e655df3..2ec2841d8 100644
--- a/panels/applications/cc-applications-panel.c
+++ b/panels/applications/cc-applications-panel.c
@@ -23,6 +23,7 @@
 
 #include <config.h>
 #include <glib/gi18n.h>
+#include <handy.h>
 #ifdef HAVE_SNAP
 #include <snapd-glib/snapd-glib.h>
 #endif
@@ -85,7 +86,7 @@ struct _CcApplicationsPanel
   GSettings         *search_settings;
 
   GtkStack          *stack;
-  GtkBox            *empty_box;
+  HdyStatusPage     *empty_page;
   GtkScrolledWindow *settings_page;
   GtkButton         *install_button;
 
@@ -1658,7 +1659,7 @@ update_panel (CcApplicationsPanel *self,
   if (row == NULL)
     {
       gtk_label_set_label (self->title_label, _("Applications"));
-      gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->empty_box));
+      gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->empty_page));
       gtk_widget_hide (GTK_WIDGET (GTK_WIDGET (self->header_button)));
       return;
     }
@@ -1978,7 +1979,7 @@ cc_applications_panel_class_init (CcApplicationsPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, camera);
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, clear_cache_button);
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, data);
-  gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, empty_box);
+  gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, empty_page);
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, header_button);
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, handler_section);
   gtk_widget_class_bind_template_child (widget_class, CcApplicationsPanel, handler_reset);
diff --git a/panels/applications/cc-applications-panel.ui b/panels/applications/cc-applications-panel.ui
index 5260461c6..1b25ead42 100644
--- a/panels/applications/cc-applications-panel.ui
+++ b/panels/applications/cc-applications-panel.ui
@@ -7,53 +7,19 @@
       <object class="GtkStack" id="stack">
         <property name="visible">1</property>
         <child>
-          <object class="GtkBox" id="empty_box">
-            <property name="visible">1</property>
-            <property name="orientation">vertical</property>
-            <property name="valign">center</property>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">1</property>
-                <property name="valign">start</property>
-                <property name="pixel-size">80</property>
-                <property name="icon-name">org.gnome.Software-symbolic</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-              </object>
-              <packing>
-                <property name="fill">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="margin-bottom">15</property>
-                <property name="label" translatable="yes">No applications</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-                <attributes>
-                  <attribute name="scale" value="1.2"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
+          <object class="HdyStatusPage" id="empty_page">
+            <property name="visible">True</property>
+            <property name="icon-name">org.gnome.Software-symbolic</property>
+            <property name="title" translatable="yes">No Applications</property>
             <child>
               <object class="GtkButton" id="install_button">
-                <property name="label" translatable="yes">Install some…</property>
+                <property name="label" translatable="yes">Install Some…</property>
                 <property name="visible">1</property>
                 <property name="can-focus">1</property>
                 <property name="receives-default">1</property>
                 <property name="halign">center</property>
                 <signal name="clicked" handler="open_software_cb" object="CcApplicationsPanel" 
swapped="yes"/>
               </object>
-              <packing>
-                <property name="fill">0</property>
-                <property name="position">2</property>
-              </packing>
             </child>
           </object>
         </child>


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