[gnome-software: 1/2] updates-page: Use HdyStatusPage




commit fee4faf56ae29c2589d8d05db1011c871de1b133
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Mon Jun 14 11:46:10 2021 +0200

    updates-page: Use HdyStatusPage
    
    This simplifies the code and makes it more in line with modern GNOME.
    When it wasn't possible to use HdyStatusPage, a similar style was
    applied.

 src/gs-updates-page.c  |  24 ++++---
 src/gs-updates-page.ui | 190 +++++++------------------------------------------
 2 files changed, 40 insertions(+), 174 deletions(-)
---
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index 08476ae0e..0f1b2567a 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -68,8 +68,8 @@ struct _GsUpdatesPage
        GtkWidget               *updates_box;
        GtkWidget               *button_updates_mobile;
        GtkWidget               *button_updates_offline;
-       GtkWidget               *label_updates_failed;
-       GtkWidget               *label_updates_last_checked;
+       GtkWidget               *updates_failed_page;
+       GtkWidget               *updates_uptodate_page;
        GtkWidget               *label_updates_spinner;
        GtkWidget               *scrolledwindow_updates;
        GtkWidget               *spinner_updates;
@@ -364,10 +364,12 @@ gs_updates_page_update_ui_state (GsUpdatesPage *self)
 
                        /* TRANSLATORS: This is the time when we last checked for updates */
                        last_checked = g_strdup_printf (_("Last checked: %s"), checked_str);
-                       gtk_label_set_label (GTK_LABEL (self->label_updates_last_checked),
-                                            last_checked);
+                       hdy_status_page_set_description (HDY_STATUS_PAGE (self->updates_uptodate_page),
+                                                        last_checked);
+               } else {
+                       hdy_status_page_set_description (HDY_STATUS_PAGE (self->updates_uptodate_page),
+                                                        NULL);
                }
-               gtk_widget_set_visible (self->label_updates_last_checked, checked_str != NULL);
        }
 
        /* update the counter in headerbar */
@@ -425,8 +427,8 @@ gs_updates_page_get_updates_cb (GsPluginLoader *plugin_loader,
                gs_updates_page_clear_flag (self, GS_UPDATES_PAGE_FLAG_HAS_UPDATES);
                if (!g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED))
                        g_warning ("updates-shell: failed to get updates: %s", error->message);
-               gtk_label_set_label (GTK_LABEL (self->label_updates_failed),
-                                    error->message);
+               hdy_status_page_set_description (HDY_STATUS_PAGE (self->updates_failed_page),
+                                                error->message);
                gs_updates_page_set_state (self, GS_UPDATES_PAGE_STATE_FAILED);
                refresh_headerbar_updates_counter (self);
                return;
@@ -665,8 +667,8 @@ gs_updates_page_refresh_cb (GsPluginLoader *plugin_loader,
                        return;
                }
                g_warning ("failed to refresh: %s", error->message);
-               gtk_label_set_label (GTK_LABEL (self->label_updates_failed),
-                                    error->message);
+               hdy_status_page_set_description (HDY_STATUS_PAGE (self->updates_failed_page),
+                                                error->message);
                gs_updates_page_set_state (self, GS_UPDATES_PAGE_STATE_FAILED);
                return;
        }
@@ -1371,8 +1373,8 @@ gs_updates_page_class_init (GsUpdatesPageClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsUpdatesPage, updates_box);
        gtk_widget_class_bind_template_child (widget_class, GsUpdatesPage, button_updates_mobile);
        gtk_widget_class_bind_template_child (widget_class, GsUpdatesPage, button_updates_offline);
-       gtk_widget_class_bind_template_child (widget_class, GsUpdatesPage, label_updates_failed);
-       gtk_widget_class_bind_template_child (widget_class, GsUpdatesPage, label_updates_last_checked);
+       gtk_widget_class_bind_template_child (widget_class, GsUpdatesPage, updates_failed_page);
+       gtk_widget_class_bind_template_child (widget_class, GsUpdatesPage, updates_uptodate_page);
        gtk_widget_class_bind_template_child (widget_class, GsUpdatesPage, label_updates_spinner);
        gtk_widget_class_bind_template_child (widget_class, GsUpdatesPage, scrolledwindow_updates);
        gtk_widget_class_bind_template_child (widget_class, GsUpdatesPage, spinner_updates);
diff --git a/src/gs-updates-page.ui b/src/gs-updates-page.ui
index 48619a87c..39372edc0 100644
--- a/src/gs-updates-page.ui
+++ b/src/gs-updates-page.ui
@@ -69,19 +69,16 @@
               <object class="GtkBox" id="updates_spinner_box">
                 <property name="visible">True</property>
                 <property name="orientation">vertical</property>
-                <property name="spacing">12</property>
+                <property name="spacing">36</property>
                 <property name="halign">center</property>
                 <property name="valign">center</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
                 <child>
                   <object class="GtkSpinner" id="spinner_updates">
                     <property name="visible">True</property>
-                    <property name="width_request">32</property>
-                    <property name="height_request">32</property>
+                    <property name="width_request">128</property>
+                    <property name="height_request">128</property>
                     <property name="halign">center</property>
                     <property name="valign">center</property>
                     <property name="hexpand">True</property>
@@ -93,9 +90,9 @@
                     <property name="visible">True</property>
                     <property name="label"/>
                     <property name="justify">center</property>
-                    <attributes>
-                      <attribute name="scale" value="1.4"/>
-                    </attributes>
+                    <style>
+                      <class name="large-title"/>
+                    </style>
                   </object>
                 </child>
               </object>
@@ -156,43 +153,15 @@
                     <property name="vexpand">True</property>
                   </object>
                 </child>
-                <child type="center">
-                  <object class="GtkBox" id="updates_uptodate_centerbox">
-                    <property name="visible">True</property>
-                    <property name="orientation">vertical</property>
-                    <property name="spacing">12</property>
-                    <style>
-                      <class name="dim-label"/>
-                    </style>
-                    <child>
-                      <object class="GtkImage" id="image_updates">
-                        <property name="visible">True</property>
-                        <property name="pixel_size">128</property>
-                        <property name="icon_name">object-select-symbolic</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label10">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes" comments="TRANSLATORS: This means all 
software (plural) installed on this system is up to date.">Software is up to date</property>
-                        <attributes>
-                          <attribute name="scale" value="1.4"/>
-                        </attributes>
-                      </object>
-                    </child>
-                  </object>
-                </child>
                 <child>
-                  <object class="GtkLabel" id="label_updates_last_checked">
+                  <object class="HdyStatusPage" id="updates_uptodate_page">
                     <property name="visible">True</property>
-                    <property name="margin_bottom">32</property>
-                    <property name="label">Last checked: HH:MM</property>
-                    <style>
-                      <class name="dim-label"/>
-                    </style>
+                    <property name="icon_name">object-select-symbolic</property>
+                    <property name="title" translatable="yes" comments="TRANSLATORS: This means all software 
(plural) installed on this system is up to date.">Up To Date</property>
+                    <property name="description">Last checked: HH:MM</property>
                   </object>
                   <packing>
-                    <property name="pack_type">end</property>
+                    <property name="expand">True</property>
                   </packing>
                 </child>
               </object>
@@ -201,45 +170,16 @@
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="updates_mobile_box">
+              <object class="HdyStatusPage">
                 <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">12</property>
-                <property name="halign">center</property>
-                <property name="valign">center</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-                <child>
-                  <object class="GtkImage" id="image_updates_mobile">
-                    <property name="visible">True</property>
-                    <property name="pixel_size">128</property>
-                    <property name="icon_name">dialog-warning-symbolic</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label_updates_mobile">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">Checking for updates when using mobile 
broadband could cause you to incur charges</property>
-                    <property name="wrap">True</property>
-                    <property name="halign">center</property>
-                    <property name="max-width-chars">40</property>
-                    <property name="justify">center</property>
-                    <attributes>
-                      <attribute name="scale" value="1.4"/>
-                    </attributes>
-                  </object>
-                </child>
+                <property name="icon_name">dialog-warning-symbolic</property>
+                <property name="title" translatable="yes">Use Mobile Data?</property>
+                <property name="description" translatable="yes">Checking for updates when using mobile 
broadband could cause you to incur charges.</property>
                 <child>
                   <object class="GtkButton" id="button_updates_mobile">
                     <property name="label" translatable="yes">_Check Anyway</property>
-                    <property name="width_request">150</property>
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
                     <property name="use_underline">True</property>
-                    <property name="hexpand">False</property>
                     <property name="halign">center</property>
                   </object>
                 </child>
@@ -249,44 +189,16 @@
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="updates_offline_box">
+              <object class="HdyStatusPage">
                 <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">12</property>
-                <property name="halign">center</property>
-                <property name="valign">center</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-                <child>
-                  <object class="GtkImage" id="image_updates_offline">
-                    <property name="visible">True</property>
-                    <property name="pixel_size">128</property>
-                    <property name="icon_name">network-offline-symbolic</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label_updates_offline">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">Go online to check for updates</property>
-                    <property name="wrap">True</property>
-                    <property name="halign">center</property>
-                    <property name="justify">center</property>
-                    <attributes>
-                      <attribute name="scale" value="1.4"/>
-                    </attributes>
-                  </object>
-                </child>
+                <property name="icon_name">network-offline-symbolic</property>
+                <property name="title" translatable="yes">No Connection</property>
+                <property name="description" translatable="yes">Go online to check for updates.</property>
                 <child>
                   <object class="GtkButton" id="button_updates_offline">
                     <property name="label" translatable="yes">_Network Settings</property>
-                    <property name="width_request">150</property>
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
                     <property name="use_underline">True</property>
-                    <property name="hexpand">False</property>
                     <property name="halign">center</property>
                   </object>
                 </child>
@@ -296,70 +208,22 @@
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="updates_failed_box">
+              <object class="HdyStatusPage" id="updates_failed_page">
                 <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">12</property>
-                <property name="halign">center</property>
-                <property name="valign">center</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-                <child>
-                  <object class="GtkImage" id="image_updates_failed">
-                    <property name="visible">True</property>
-                    <property name="pixel_size">128</property>
-                    <property name="icon_name">action-unavailable-symbolic</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label_updates_failed">
-                    <property name="visible">True</property>
-                    <property name="wrap">True</property>
-                    <property name="max-width-chars">60</property>
-                    <property name="label" translatable="No">Failed to get updates</property>
-                    <attributes>
-                      <attribute name="scale" value="1.4"/>
-                    </attributes>
-                  </object>
-                </child>
+                <property name="icon_name">action-unavailable-symbolic</property>
+                <property name="title" translatable="No">Error</property>
+                <property name="description" translatable="No">Failed to get updates.</property>
               </object>
               <packing>
                 <property name="name">failed</property>
               </packing>
             </child>
             <child>
-              <object class="GtkBox">
+              <object class="HdyStatusPage">
                 <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">12</property>
-                <property name="halign">center</property>
-                <property name="valign">center</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-                <child>
-                  <object class="GtkImage">
-                    <property name="visible">True</property>
-                    <property name="pixel_size">128</property>
-                    <property name="icon_name">action-unavailable-symbolic</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="wrap">True</property>
-                    <property name="max-width-chars">60</property>
-                    <property name="label" translatable="yes">Updates are automatically managed</property>
-                    <attributes>
-                      <attribute name="scale" value="1.4"/>
-                    </attributes>
-                  </object>
-                </child>
+                <property name="icon_name">action-unavailable-symbolic</property>
+                <property name="title" translatable="yes">Error</property>
+                <property name="description" translatable="yes">Updates are automatically managed.</property>
               </object>
               <packing>
                 <property name="name">managed</property>


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