[gnome-software/wip/rancell/ubuntu-ratings] details: Add an error state
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/rancell/ubuntu-ratings] details: Add an error state
- Date: Thu, 12 Nov 2015 02:27:53 +0000 (UTC)
commit abc543130081854bb8539b1e8c213c1f180fd710
Author: Kalev Lember <klember redhat com>
Date: Sat Oct 24 10:24:42 2015 +0200
details: Add an error state
Instead of showing a broken details page when an app fails to load, add
a proper error state that tells the user what went wrong.
src/gs-shell-details.c | 18 +++++++++++++++++-
src/gs-shell-details.ui | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index b682ed7..2edb0ca 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -38,7 +38,8 @@
typedef enum {
GS_SHELL_DETAILS_STATE_LOADING,
- GS_SHELL_DETAILS_STATE_READY
+ GS_SHELL_DETAILS_STATE_READY,
+ GS_SHELL_DETAILS_STATE_FAILED
} GsShellDetailsState;
struct _GsShellDetails
@@ -83,6 +84,7 @@ struct _GsShellDetails
GtkWidget *label_details_size_value;
GtkWidget *label_details_updated_value;
GtkWidget *label_details_version_value;
+ GtkWidget *label_failed;
GtkWidget *label_pending;
GtkWidget *list_box_addons;
GtkWidget *scrolledwindow_details;
@@ -107,6 +109,7 @@ gs_shell_details_set_state (GsShellDetails *self,
gtk_widget_show (self->spinner_details);
break;
case GS_SHELL_DETAILS_STATE_READY:
+ case GS_SHELL_DETAILS_STATE_FAILED:
gs_stop_spinner (GTK_SPINNER (self->spinner_details));
gtk_widget_hide (self->spinner_details);
break;
@@ -122,6 +125,9 @@ gs_shell_details_set_state (GsShellDetails *self,
case GS_SHELL_DETAILS_STATE_READY:
gtk_stack_set_visible_child_name (GTK_STACK (self->stack_details), "ready");
break;
+ case GS_SHELL_DETAILS_STATE_FAILED:
+ gtk_stack_set_visible_child_name (GTK_STACK (self->stack_details), "failed");
+ break;
default:
g_assert_not_reached ();
}
@@ -887,6 +893,15 @@ gs_shell_details_app_refine_cb (GObject *source,
g_warning ("failed to refine %s: %s",
gs_app_get_id (self->app),
error->message);
+ }
+
+ if (gs_app_get_kind (self->app) == GS_APP_KIND_UNKNOWN ||
+ gs_app_get_state (self->app) == AS_APP_STATE_UNKNOWN) {
+ g_autofree gchar *str = NULL;
+
+ str = g_strdup_printf (_("Could not find '%s'"), gs_app_get_id (self->app));
+ gtk_label_set_text (GTK_LABEL (self->label_failed), str);
+ gs_shell_details_set_state (self, GS_SHELL_DETAILS_STATE_FAILED);
return;
}
@@ -1346,6 +1361,7 @@ gs_shell_details_class_init (GsShellDetailsClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, label_details_size_value);
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, label_details_updated_value);
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, label_details_version_value);
+ gtk_widget_class_bind_template_child (widget_class, GsShellDetails, label_failed);
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, label_pending);
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, list_box_addons);
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, scrolledwindow_details);
diff --git a/src/gs-shell-details.ui b/src/gs-shell-details.ui
index 7999f35..15a27c6 100644
--- a/src/gs-shell-details.ui
+++ b/src/gs-shell-details.ui
@@ -1029,6 +1029,42 @@
<property name="name">ready</property>
</packing>
</child>
+ <child>
+ <object class="GtkBox" id="box_failed">
+ <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_failed">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixel_size">128</property>
+ <property name="icon_name">gnome-software-symbolic</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_failed">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="wrap">True</property>
+ <property name="max-width-chars">60</property>
+ <attributes>
+ <attribute name="scale" value="1.4"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">failed</property>
+ </packing>
+ </child>
</object>
</child>
</template>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]