Commit eaa46a8b authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko Committed by Sebastian Krzyszkowiak
Browse files

lockscreen: Follow finger when swiping

Pack the two pages into a PhoshPaginator. This also allows to swipe back
from keypad to the info screen.

Remove the GtkEventBox around the info page, as the paginator is already
a subclass of GtkEventBox.
parent fadb6a0c
......@@ -41,14 +41,12 @@ typedef struct _PhoshLockscreen
typedef struct {
GtkWidget *stack;
GtkWidget *paginator;
/* info page */
GtkWidget *ebox_info;
GtkWidget *grid_info;
GtkWidget *lbl_clock;
GtkWidget *lbl_date;
GtkGesture *ebox_pan_gesture;
/* unlock page */
GtkWidget *grid_unlock;
......@@ -92,9 +90,7 @@ show_info_page (PhoshLockscreen *self)
{
PhoshLockscreenPrivate *priv = phosh_lockscreen_get_instance_private (self);
hdy_dialer_clear_number (HDY_DIALER (priv->dialer_keypad));
keypad_update_labels (self);
gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->ebox_info);
hdy_paginator_scroll_to (HDY_PAGINATOR (priv->paginator), priv->grid_info);
}
......@@ -119,14 +115,7 @@ show_unlock_page (PhoshLockscreen *self)
{
PhoshLockscreenPrivate *priv = phosh_lockscreen_get_instance_private (self);
gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->grid_unlock);
gtk_widget_grab_focus (GTK_WIDGET (priv->dialer_keypad));
if (!priv->idle_timer) {
priv->last_input = g_get_monotonic_time ();
priv->idle_timer = g_timeout_add_seconds (LOCKSCREEN_IDLE_SECONDS,
(GSourceFunc) keypad_check_idle,
self);
}
hdy_paginator_scroll_to (HDY_PAGINATOR (priv->paginator), priv->grid_unlock);
/* skip signal on init */
if (signals[WAKEUP_OUTPUT])
......@@ -192,13 +181,6 @@ keypad_number_notified_cb (PhoshLockscreen *self)
}
static void
info_pan_cb (PhoshLockscreen *self, GtkPanDirection dir, gdouble offset, GtkGesturePan *pan)
{
if (dir == GTK_PAN_DIRECTION_UP)
show_unlock_page (self);
}
static gboolean
key_press_event_cb (PhoshLockscreen *self, GdkEventKey *event, gpointer data)
......@@ -207,7 +189,7 @@ key_press_event_cb (PhoshLockscreen *self, GdkEventKey *event, gpointer data)
gboolean handled = FALSE;
g_autofree gchar *number = NULL;
if (gtk_stack_get_visible_child (GTK_STACK (priv->stack)) == priv->ebox_info) {
if (hdy_paginator_get_position (HDY_PAGINATOR (priv->paginator)) <= 0) {
switch (event->keyval) {
case GDK_KEY_space:
show_unlock_page (self);
......@@ -223,7 +205,7 @@ key_press_event_cb (PhoshLockscreen *self, GdkEventKey *event, gpointer data)
/* nothing to do */
break;
}
} else if (gtk_stack_get_visible_child (GTK_STACK (priv->stack)) == priv->grid_unlock) {
} else {
switch (event->keyval) {
case GDK_KEY_Escape:
show_info_page (self);
......@@ -312,6 +294,42 @@ wall_clock_notify_cb (PhoshLockscreen *self,
}
static void
paginator_position_notified_cb (PhoshLockscreen *self,
GParamSpec *pspec,
HdyPaginator *paginator)
{
PhoshLockscreenPrivate *priv = phosh_lockscreen_get_instance_private (self);
double position;
position = hdy_paginator_get_position (HDY_PAGINATOR (priv->paginator));
if (position <= 0) {
hdy_dialer_clear_number (HDY_DIALER (priv->dialer_keypad));
keypad_update_labels (self);
return;
}
if (position >= 1) {
gtk_widget_grab_focus (GTK_WIDGET (priv->dialer_keypad));
if (!priv->idle_timer) {
priv->last_input = g_get_monotonic_time ();
priv->idle_timer = g_timeout_add_seconds (LOCKSCREEN_IDLE_SECONDS,
(GSourceFunc) keypad_check_idle,
self);
}
return;
}
if (priv->idle_timer) {
g_source_remove (priv->idle_timer);
priv->idle_timer = 0;
}
}
static void
phosh_lockscreen_constructed (GObject *object)
{
......@@ -329,15 +347,6 @@ phosh_lockscreen_constructed (GObject *object)
gtk_widget_get_style_context (GTK_WIDGET (self)),
"phosh-lockscreen");
gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->ebox_info);
priv->ebox_pan_gesture = gtk_gesture_pan_new (GTK_WIDGET (priv->ebox_info),
GTK_ORIENTATION_VERTICAL);
g_signal_connect_swapped (priv->ebox_pan_gesture,
"pan",
G_CALLBACK (info_pan_cb),
self);
gtk_widget_add_events (GTK_WIDGET (self), GDK_KEY_PRESS_MASK);
g_signal_connect (G_OBJECT (self),
"key_press_event",
......@@ -395,7 +404,10 @@ phosh_lockscreen_class_init (PhoshLockscreenClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/sm/puri/phosh/ui/lockscreen.ui");
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, stack);
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, paginator);
gtk_widget_class_bind_template_callback_full (widget_class,
"paginator_position_notified_cb",
G_CALLBACK(paginator_position_notified_cb));
/* unlock page */
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, grid_unlock);
......@@ -406,7 +418,6 @@ phosh_lockscreen_class_init (PhoshLockscreenClass *klass)
"keypad_number_notified_cb",
G_CALLBACK(keypad_number_notified_cb));
/* info page */
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, ebox_info);
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, grid_info);
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, lbl_clock);
gtk_widget_class_bind_template_child_private (widget_class, PhoshLockscreen, lbl_date);
......
......@@ -9,195 +9,186 @@
<placeholder/>
</child>
<child>
<object class="GtkStack" id="stack">
<object class="HdyPaginator" id="paginator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_duration">500</property>
<property name="transition_type">slide-up-down</property>
<child>
<object class="GtkEventBox" id="ebox_info">
<property name="orientation">vertical</property>
<property name="animation-duration">400</property>
<signal name="notify::position" handler="paginator_position_notified_cb" swapped="yes"/>
<child>
<object class="GtkGrid" id="grid_info">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="above_child">True</property>
<property name="expand">True</property>
<child>
<object class="GtkGrid" id="grid_info">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">end</property>
<property name="margin_top">6</property>
<property name="margin_bottom">32</property>
<property name="label" translatable="yes">Slide up to unlock</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lock-arrow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">24</property>
<property name="icon_name">swipe-arrow-symbolic</property>
<style>
<class name="phosh-lockscreen-arrow"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
<property name="valign">end</property>
<property name="margin_top">6</property>
<property name="margin_bottom">32</property>
<property name="label" translatable="yes">Slide up to unlock</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="lock-arrow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">24</property>
<property name="icon_name">swipe-arrow-symbolic</property>
<style>
<class name="phosh-lockscreen-arrow"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkLabel" id="lbl_clock">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">False</property>
<property name="label">00:00</property>
<property name="single_line_mode">True</property>
<property name="track_visited_links">False</property>
<style>
<class name="phosh-lockscreen-clock"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_date">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<property name="margin_top">24</property>
<child>
<object class="GtkLabel" id="lbl_clock">
<object class="PhoshWWanInfo" id="wwaninfo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">False</property>
<property name="label">00:00</property>
<property name="single_line_mode">True</property>
<property name="track_visited_links">False</property>
<style>
<class name="phosh-lockscreen-clock"/>
</style>
<property name="valign">start</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="use_fallback">True</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="size">24</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_date">
<property name="visible">True</property>
<object class="PhoshWifiInfo" id="wifiinfo">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="valign">start</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="pixel_size">24</property>
<property name="use_fallback">True</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="no_show_all">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<object class="PhoshBatteryInfo" id="batteryinfo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_top">24</property>
<child>
<object class="PhoshWWanInfo" id="wwaninfo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="use_fallback">True</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="size">24</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="PhoshWifiInfo" id="wifiinfo">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="pixel_size">24</property>
<property name="use_fallback">True</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="no_show_all">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="PhoshBatteryInfo" id="batteryinfo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="pixel_size">24</property>
<property name="use_fallback">True</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<property name="valign">start</property>
<property name="halign">end</property>
<property name="hexpand">False</property>
<property name="pixel_size">24</property>
<property name="use_fallback">True</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="name">info</property>
<property name="title">info</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid_unlock">
......@@ -256,11 +247,6 @@
</packing>
</child>
</object>
<packing>
<property name="name">unlock</property>
<property name="title">unlock</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="phosh-lockscreen"/>
......
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