Commit 7cf37830 authored by Julian Sparber's avatar Julian Sparber Committed by Guido Gunther

Lockscreen: add submit button, allows arbitrary pin lengths

This also adds the emergency button but for now it is hidden, because
emergency calls don't work yet.
parent e4b2cc06
......@@ -56,6 +56,8 @@ typedef struct {
GtkWidget *entry_pin;
GtkGesture *long_press_del_gesture;
GtkWidget *lbl_unlock_status;
GtkWidget *btn_submit;
GtkWidget *btn_emergency;
GtkWidget *wwaninfo;
GtkWidget *batteryinfo;
guint idle_timer;
......@@ -220,27 +222,49 @@ long_press_del_cb (PhoshLockscreen *self,
static void
input_changed_cb (PhoshLockscreen *self)
{
PhoshLockscreenPrivate *priv;
guint16 length;
g_assert (PHOSH_IS_LOCKSCREEN (self));
priv = phosh_lockscreen_get_instance_private (self);
priv->last_input = g_get_monotonic_time ();
length = gtk_entry_get_text_length (GTK_ENTRY (priv->entry_pin));
gtk_widget_set_sensitive (priv->btn_submit, length != 0);
}
static void
submit_cb (PhoshLockscreen *self)
{
PhoshLockscreenPrivate *priv;
const gchar *input;
guint16 length;
g_assert (PHOSH_IS_LOCKSCREEN (self));
priv = phosh_lockscreen_get_instance_private (self);
priv->last_input = g_get_monotonic_time ();
input = gtk_entry_get_text (GTK_ENTRY (priv->entry_pin));
if (strlen (input) == phosh_auth_get_pin_length()) {
gtk_label_set_label (GTK_LABEL (priv->lbl_unlock_status), _("Checking…"));
gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
if (priv->auth == NULL)
priv->auth = PHOSH_AUTH (phosh_auth_new ());
phosh_auth_authenticate_async_start (priv->auth,
input,
NULL,
(GAsyncReadyCallback)auth_async_cb,
self);
length = gtk_entry_get_text_length (GTK_ENTRY (priv->entry_pin));
if (length == 0) {
return;
}
input = gtk_entry_get_text (GTK_ENTRY (priv->entry_pin));
gtk_label_set_label (GTK_LABEL (priv->lbl_unlock_status), _("Checking…"));
gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
if (priv->auth == NULL)
priv->auth = PHOSH_AUTH (phosh_auth_new ());
phosh_auth_authenticate_async_start (priv->auth,
input,
NULL,
(GAsyncReadyCallback)auth_async_cb,
self);
}
......@@ -272,6 +296,12 @@ key_press_event_cb (PhoshLockscreen *self, GdkEventKey *event, gpointer data)
clear_input (self, FALSE);
handled = TRUE;
break;
case GDK_KEY_Return:
case GDK_KEY_ISO_Enter:
case GDK_KEY_KP_Enter:
submit_cb (self),
handled = TRUE;
break;
default:
/* nothing to do */
break;
......@@ -475,8 +505,13 @@ phosh_lockscreen_class_init (PhoshLockscreenClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, entry_pin);
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, lbl_unlock_status);
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, long_press_del_gesture);
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, btn_submit);
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, btn_emergency);
gtk_widget_class_bind_template_callback (widget_class, long_press_del_cb);
gtk_widget_class_bind_template_callback (widget_class, delete_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, submit_cb);
gtk_widget_class_bind_template_callback (widget_class, input_changed_cb);
/* info page */
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, grid_info);
......@@ -490,14 +525,7 @@ phosh_lockscreen_class_init (PhoshLockscreenClass *klass)
static void
phosh_lockscreen_init (PhoshLockscreen *self)
{
PhoshLockscreenPrivate *priv = phosh_lockscreen_get_instance_private (self);
gtk_widget_init_template (GTK_WIDGET (self));
g_signal_connect_swapped (G_OBJECT (priv->entry_pin),
"changed",
G_CALLBACK (input_changed_cb),
self);
}
......
......@@ -243,10 +243,20 @@ hdykeypad > button {
border: 0;
}
hdykeypad > button:active {
hdykeypad > button:active, .text-only-button:active {
background: rgba(255, 255, 255, 0.3);
}
hdykeypad > button:focus {
hdykeypad > button:focus, .text-only-button:focus {
outline-style: none;
}
.text-only-button {
font-size: 16px;
font-weight: bold;
padding: 16px;
border: 0;
box-shadow: none;
background: 0;
border: 0;
}
......@@ -191,13 +191,25 @@
</object>
</child>
<child>
<object class="GtkGrid" id="grid_unlock">
<object class="GtkBox" id="grid_unlock">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="lbl_unlock_status">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Enter Passcode</property>
<attributes>
<attribute name="font-desc" value="Cantarell 16"/>
</attributes>
</object>
</child>
<child>
<object class="GtkEntry" id="entry_pin">
<property name="visible">True</property>
......@@ -212,11 +224,8 @@
<style>
<class name="phosh-lockscreen-pin"/>
</style>
<signal name="changed" handler="input_changed_cb" swapped="yes"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="HdyKeypad" id="keypad">
......@@ -231,26 +240,41 @@
<property name="entry">entry_pin</property>
<property name="right-action">delete_btn</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_unlock_status">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="label" translatable="yes">Enter Passcode</property>
<attributes>
<attribute name="font-desc" value="Cantarell 16"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
<child>
<object class="GtkButton" id="btn_emergency">
<property name="visible">False</property>
<property name="label" translatable="yes">Emergency</property>
<style>
<class name="text-only-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">start</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_submit">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="label" translatable="yes">Submit</property>
<signal name="clicked" handler="submit_cb" swapped="yes"/>
<style>
<class name="text-only-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
</packing>
</child>
</object>>
</child>
</object>
</child>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment