Commit 16a94bea authored by aviau's avatar aviau Committed by Alexandre Viau

Link to an existing account: split in two steps

There is now two steps when linking to an existing accounts. The first
page explains to the user how to generate the PIN on the other device.

Tuleap: #1296
Change-Id: If3fb24f0a5b2d7e733a2cc3d5640ff81997d1d5b
parent 8b75a4c1
......@@ -66,14 +66,19 @@ struct _AccountCreationWizardPrivate
GtkWidget *button_existing_account;
GtkWidget *button_wizard_cancel;
/* existing account */
GtkWidget *existing_account;
GtkWidget *button_existing_account_next;
GtkWidget *button_existing_account_previous;
/* existing account step1 */
GtkWidget *existing_account_step1;
GtkWidget *button_existing_account_step1_next;
GtkWidget *button_existing_account_step1_previous;
GtkWidget *entry_existing_account_pin;
GtkWidget *entry_existing_account_password;
GtkWidget *retrieving_account;
/* existing account step 2 */
GtkWidget *existing_account_step2;
GtkWidget *button_existing_account_step2_next;
GtkWidget *button_existing_account_step2_previous;
/* account creation */
GtkWidget *account_creation;
GtkWidget *vbox_account_creation_entry;
......@@ -162,10 +167,15 @@ account_creation_wizard_class_init(AccountCreationWizardClass *klass)
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_existing_account);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_wizard_cancel);
/* existing account */
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, existing_account);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_existing_account_next);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_existing_account_previous);
/* existing account step1 */
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, existing_account_step1);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_existing_account_step1_next);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_existing_account_step1_previous);
/* existing account step2 */
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, existing_account_step2);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_existing_account_step2_next);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_existing_account_step2_previous);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, entry_existing_account_pin);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, entry_existing_account_password);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, entry_existing_account_password);
......@@ -464,7 +474,7 @@ show_retrieving_account(AccountCreationWizard *win)
}
static void
existing_account_next_clicked(G_GNUC_UNUSED GtkButton *button, AccountCreationWizard *win)
existing_account_step2_next_clicked(AccountCreationWizard *win)
{
show_retrieving_account(win);
......@@ -483,10 +493,17 @@ show_choose_account_type(AccountCreationWizard *view)
}
static void
show_existing_account(AccountCreationWizard *view)
show_existing_account_step2(AccountCreationWizard *view)
{
AccountCreationWizardPrivate *priv = ACCOUNT_CREATION_WIZARD_GET_PRIVATE(view);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_account_creation), priv->existing_account_step2);
}
static void
show_existing_account_step1(AccountCreationWizard *view)
{
AccountCreationWizardPrivate *priv = ACCOUNT_CREATION_WIZARD_GET_PRIVATE(view);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_account_creation), priv->existing_account);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_account_creation), priv->existing_account_step1);
}
static void
......@@ -518,14 +535,10 @@ entries_existing_account_changed(G_GNUC_UNUSED GtkEntry *entry, AccountCreationW
const gchar *pin = gtk_entry_get_text(GTK_ENTRY(priv->entry_existing_account_pin));
const gchar *password = gtk_entry_get_text(GTK_ENTRY(priv->entry_existing_account_password));
if (strlen(pin) > 0 && strlen(password) > 0)
{
gtk_widget_set_sensitive(priv->button_existing_account_next, TRUE);
}
else
{
gtk_widget_set_sensitive(priv->button_existing_account_next, FALSE);
}
gtk_widget_set_sensitive(
priv->button_existing_account_step2_next,
(strlen(pin) > 0 && strlen(password) > 0)
);
}
static void
......@@ -635,7 +648,7 @@ build_creation_wizard_view(AccountCreationWizard *view, gboolean show_cancel_but
/* choose_account_type signals */
g_signal_connect_swapped(priv->button_new_account, "clicked", G_CALLBACK(show_account_creation), view);
g_signal_connect_swapped(priv->button_existing_account, "clicked", G_CALLBACK(show_existing_account), view);
g_signal_connect_swapped(priv->button_existing_account, "clicked", G_CALLBACK(show_existing_account_step1), view);
g_signal_connect(priv->button_wizard_cancel, "clicked", G_CALLBACK(wizard_cancel_clicked), view);
/* account_creation signals */
......@@ -649,9 +662,13 @@ build_creation_wizard_view(AccountCreationWizard *view, gboolean show_cancel_but
g_signal_connect(priv->checkbutton_sign_up_blockchain, "toggled", G_CALLBACK(checkbutton_sign_up_blockchain_toggled), view);
g_signal_connect_swapped(priv->username_registration_box, "username-availability-changed", G_CALLBACK(username_availability_changed), view);
/* existing_account singals */
g_signal_connect_swapped(priv->button_existing_account_previous, "clicked", G_CALLBACK(show_choose_account_type), view);
g_signal_connect(priv->button_existing_account_next, "clicked", G_CALLBACK(existing_account_next_clicked), view);
/* existing_account_step1 singals */
g_signal_connect_swapped(priv->button_existing_account_step1_previous, "clicked", G_CALLBACK(show_choose_account_type), view);
g_signal_connect_swapped(priv->button_existing_account_step1_next, "clicked", G_CALLBACK(show_existing_account_step2), view);
/* existing_account_step2 signals */
g_signal_connect_swapped(priv->button_existing_account_step2_previous, "clicked", G_CALLBACK(show_existing_account_step1), view);
g_signal_connect_swapped(priv->button_existing_account_step2_next, "clicked", G_CALLBACK(existing_account_step2_next_clicked), view);
g_signal_connect(priv->entry_existing_account_pin, "changed", G_CALLBACK(entries_existing_account_changed), view);
g_signal_connect(priv->entry_existing_account_password, "changed", G_CALLBACK(entries_existing_account_changed), view);
......
......@@ -89,14 +89,78 @@
</object>
</child>
<!-- End Choose account type wizard -->
<!-- Existing account wizard -->
<!-- Existing account wizard: step 1 -->
<child>
<object class="GtkBox" id="existing_account">
<object class="GtkBox" id="existing_account_step1">
<property name="visible">True</property>
<property name="valign">center</property>
<property name="border_width">10</property>
<property name="orientation">vertical</property>
<property name="spacing">15</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Link this device to an existing account</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="max-width-chars">80</property>
<property name="can_focus">True</property>
<property name="wrap">True</property>
<property name="justify">left</property>
<property name="label" translatable="yes">To link this device to another account, you first need to obtain a PIN code. To generate the pin code, go to the account management setting of a previous device, choose the Ring Account to use and select "Link another device to this account". You will get the necessary PIN to complete this form. The PIN is only valid for 10 minutes.</property>
</object>
</child>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="button_existing_account_step1_previous">
<property name="label" translatable="yes">Previous</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
</object>
</child>
<child>
<object class="GtkButton" id="button_existing_account_step1_next">
<property name="label" translatable="yes">Okay, I have the PIN!</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
</object>
</child>
</object>
</child>
</object>
</child>
<!-- End of Existing accoutn wizard: step2 -->
<!-- Existing account wizard: step 2 -->
<child>
<object class="GtkBox" id="existing_account_step2">
<property name="visible">True</property>
<property name="valign">center</property>
<property name="border_width">10</property>
<property name="orientation">vertical</property>
<property name="spacing">15</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Link this device to an existing account</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkBox" id="vbox_existing_account_entry">
<property name="visible">True</property>
......@@ -148,7 +212,7 @@
<object class="GtkButtonBox">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="button_existing_account_previous">
<object class="GtkButton" id="button_existing_account_step2_previous">
<property name="label" translatable="yes">Previous</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
......@@ -156,7 +220,7 @@
</object>
</child>
<child>
<object class="GtkButton" id="button_existing_account_next">
<object class="GtkButton" id="button_existing_account_step2_next">
<property name="label" translatable="yes">Next</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
......@@ -168,7 +232,7 @@
</child>
</object>
</child>
<!-- End existing account wizard -->
<!-- End existing account wizard: step 2 -->
<!-- account creation wizard -->
<child>
<object class="GtkBox" id="account_creation">
......
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