Commit 395931ba authored by Hugo Lefeuvre's avatar Hugo Lefeuvre Committed by Sébastien Blin

accountcreation: improve small screens support

Switch AccountCreationWizard type to GtkScrolledWindow to make it
resizable.

Change-Id: I964a92f2b1b7918193b71895b35f0d4b5f3198a1
Gitlab: #885Reviewed-by: Sébastien Blin's avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent 2ae7f2ae
......@@ -38,12 +38,12 @@
struct _AccountCreationWizard
{
GtkBox parent;
GtkScrolledWindow parent;
};
struct _AccountCreationWizardClass
{
GtkBoxClass parent_class;
GtkScrolledWindowClass parent_class;
};
typedef struct _AccountCreationWizardPrivate AccountCreationWizardPrivate;
......@@ -106,7 +106,7 @@ struct _AccountCreationWizardPrivate
};
G_DEFINE_TYPE_WITH_PRIVATE(AccountCreationWizard, account_creation_wizard, GTK_TYPE_BOX);
G_DEFINE_TYPE_WITH_PRIVATE(AccountCreationWizard, account_creation_wizard, GTK_TYPE_SCROLLED_WINDOW);
#define ACCOUNT_CREATION_WIZARD_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ACCOUNT_CREATION_WIZARD_TYPE, AccountCreationWizardPrivate))
......@@ -387,6 +387,12 @@ static void
show_choose_account_type(AccountCreationWizard *view)
{
AccountCreationWizardPrivate *priv = ACCOUNT_CREATION_WIZARD_GET_PRIVATE(view);
/* Make sure other stack elements are hidden, otherwise their width will prevent
the window to be correctly resized at this stage. */
gtk_widget_hide(priv->account_creation);
gtk_widget_hide(priv->existing_account);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_account_creation), priv->choose_account_type_vbox);
}
......@@ -402,6 +408,8 @@ static void
show_existing_account(AccountCreationWizard *view)
{
AccountCreationWizardPrivate *priv = ACCOUNT_CREATION_WIZARD_GET_PRIVATE(view);
gtk_widget_show(priv->existing_account);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_account_creation), priv->existing_account);
}
......@@ -605,7 +613,14 @@ account_creation_wizard_show_preview(AccountCreationWizard *win, gboolean show_p
{
AccountCreationWizardPrivate *priv = ACCOUNT_CREATION_WIZARD_GET_PRIVATE(win);
/* Similarly to general settings view, we construct and destroy the avatar manipulation widget
if (priv->account_creation) {
if (show_preview)
gtk_widget_show(priv->account_creation);
else
gtk_widget_hide(priv->account_creation);
}
/* Similarily to general settings view, we construct and destroy the avatar manipulation widget
each time the profile is made visible / hidden. While not the most elegant solution, this
allows us to run the preview if and only if it is displayed, and always stop it when hidden. */
if (show_preview && !priv->avatar_manipulation) {
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.10"/>
<template class="AccountCreationWizard" parent="GtkBox">
<template class="AccountCreationWizard" parent="GtkScrolledWindow">
<child>
<object class="GtkBox">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">15</property>
<property name="valign">center</property>
<property name="halign">center</property>
<child>
<object class="GtkStack" id="stack_account_creation">
<property name="visible">True</property>
......@@ -111,7 +107,7 @@
<!-- Existing account wizard -->
<child>
<object class="GtkBox" id="existing_account">
<property name="visible">True</property>
<property name="visible">False</property>
<property name="valign">center</property>
<property name="border_width">10</property>
<property name="orientation">vertical</property>
......@@ -142,12 +138,14 @@
<object class="GtkBox" id="vbox_existing_account_entry">
<property name="visible">True</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkBox" id="import_hbox">
<property name="visible">True</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="border_width">10</property>
<property name="orientation">horizontal</property>
<property name="spacing">15</property>
......@@ -225,26 +223,26 @@
<property name="visibility">False</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="button_existing_account_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_next">
<property name="label" translatable="yes">Next</property>
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<child>
<object class="GtkButton" id="button_existing_account_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_next">
<property name="label" translatable="yes">Next</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
</object>
</child>
</object>
</child>
</object>
......@@ -255,7 +253,7 @@
<!-- account creation wizard -->
<child>
<object class="GtkBox" id="account_creation">
<property name="visible">True</property>
<property name="visible">False</property>
<property name="valign">center</property>
<property name="halign">center</property>
<property name="border_width">10</property>
......
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