demo: Add UI for retry errors

This commit is contained in:
Benjamin Berg 2019-07-04 16:38:32 +02:00
parent b46d336d2b
commit 3f0a143037
2 changed files with 57 additions and 2 deletions

View file

@ -59,7 +59,8 @@ typedef enum {
NOIMAGING_MODE,
CAPTURE_MODE,
SPINNER_MODE,
ERROR_MODE
ERROR_MODE,
RETRY_MODE
} LibfprintDemoMode;
static void libfprint_demo_set_mode (LibfprintDemoWindow *win,
@ -221,6 +222,9 @@ dev_capture_start_cb (FpDevice *dev,
image = fp_device_capture_finish (dev, res, &error);
if (!image) {
g_warning ("Error capturing data: %s", error->message);
if (error->domain == FP_DEVICE_RETRY)
libfprint_demo_set_mode (win, RETRY_MODE);
else
libfprint_demo_set_mode (win, ERROR_MODE);
return;
}
@ -415,6 +419,11 @@ libfprint_demo_set_mode (LibfprintDemoWindow *win,
gtk_widget_set_sensitive (win->capture_button, FALSE);
gtk_spinner_stop (GTK_SPINNER (win->spinner));
break;
case RETRY_MODE:
gtk_stack_set_visible_child_name (GTK_STACK (win->mode_stack), "retry-mode");
gtk_widget_set_sensitive (win->capture_button, TRUE);
gtk_spinner_stop (GTK_SPINNER (win->spinner));
break;
default:
g_assert_not_reached ();
}

View file

@ -266,6 +266,52 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="retry-mode">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="row_spacing">12</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">9</property>
<property name="pixel_size">192</property>
<property name="icon_name">dialog-warning-symbolic</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">9</property>
<property name="label" translatable="yes">&lt;b&gt;&lt;span size="large"&gt;Device reported a recoverable error. Please retry!&lt;/span&gt;&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="name">retry-mode</property>
<property name="title">retry-mode</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="noimaging-mode">
<property name="visible">True</property>