[gnome-software] Show an error message if getting the historical update list failed



commit b847838740a82e1bbc8c15a0bda6bf210bf4539e
Author: Richard Hughes <richard hughsie com>
Date:   Tue Nov 19 15:42:10 2013 +0000

    Show an error message if getting the historical update list failed
    
    This can really only happen if we're using 'gnome-software --mode=updated'
    without a valid offline update, but it's misleading and confusing to show a
    'No updates available' message in this case.

 src/gnome-software.ui  |   35 +++++++++++++++++++++++++++++++++++
 src/gs-shell-updates.c |   21 +++++++++++++--------
 2 files changed, 48 insertions(+), 8 deletions(-)
---
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index 2401e80..57f2f9f 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -845,6 +845,41 @@
                     <property name="name">uptodate</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkBox" id="updates_failed_box">
+                    <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="can_focus">False</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="can_focus">False</property>
+                        <property name="label" translatable="No">Failed to get updates</property>
+                        <attributes>
+                          <attribute name="scale" value="1.4"/>
+                        </attributes>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="name">failed</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="name">updates</property>
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index b401ba8..303614d 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -89,14 +89,6 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
        /* get the results */
        list = gs_plugin_loader_get_updates_finish (plugin_loader, res, &error);
 
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stack_updates"));
-       if (list == NULL) {
-               gtk_stack_set_visible_child_name (GTK_STACK (widget), "uptodate");
-       }
-       else {
-               gtk_stack_set_visible_child_name (GTK_STACK (widget), "view");
-       }
-
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_updates_counter"));
        if (list != NULL) {
                gchar *text;
@@ -125,11 +117,24 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
                                     GS_PLUGIN_LOADER_ERROR,
                                     GS_PLUGIN_LOADER_ERROR_NO_RESULTS)) {
                        g_debug ("no updates to show");
+                       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+                                                                    "stack_updates"));
+                       gtk_stack_set_visible_child_name (GTK_STACK (widget), "uptodate");
                } else {
                        g_warning ("failed to get updates: %s", error->message);
+                       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+                                                                    "stack_updates"));
+                       gtk_stack_set_visible_child_name (GTK_STACK (widget), "failed");
+                       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+                                                                    "label_updates_failed"));
+                       gtk_label_set_label (GTK_LABEL (widget), error->message);
                }
                g_error_free (error);
                goto out;
+       } else {
+               widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
+                                                            "stack_updates"));
+               gtk_stack_set_visible_child_name (GTK_STACK (widget), "view");
        }
        for (l = list; l != NULL; l = l->next) {
                app = GS_APP (l->data);


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