[gnome-initial-setup/wip/oholy/account-offline-v2: 1/2] account: Add offline mode for account page
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/wip/oholy/account-offline-v2: 1/2] account: Add offline mode for account page
- Date: Tue, 5 Feb 2019 12:26:13 +0000 (UTC)
commit b79d8c0d9eea63887def721750cb5579ce97087c
Author: Ondrej Holy <oholy redhat com>
Date: Fri Nov 2 13:10:36 2018 +0100
account: Add offline mode for account page
Show "Go online to setup Enterprise Login" label instead of "Set Up
Enterprise Login" toggle if network is not available. This is based
on the following mockup:
https://gitlab.gnome.org/Teams/Design/os-mockups/blob/master/initial-setup/user-account.png
https://gitlab.gnome.org/GNOME/gnome-initial-setup/issues/63
.../pages/account/gis-account-page.c | 28 ++++++++++++++++++++--
.../pages/account/gis-account-page.ui | 26 ++++++++++++++++----
2 files changed, 48 insertions(+), 6 deletions(-)
---
diff --git a/gnome-initial-setup/pages/account/gis-account-page.c
b/gnome-initial-setup/pages/account/gis-account-page.c
index 4c41cb1..0d2c562 100644
--- a/gnome-initial-setup/pages/account/gis-account-page.c
+++ b/gnome-initial-setup/pages/account/gis-account-page.c
@@ -36,9 +36,11 @@ struct _GisAccountPagePrivate
{
GtkWidget *page_local;
GtkWidget *page_enterprise;
+ GtkWidget *stack;
GtkWidget *page_toggle;
- GtkWidget *stack;
+ GtkWidget *offline_label;
+ GtkWidget *offline_stack;
UmAccountMode mode;
};
@@ -203,11 +205,26 @@ on_local_user_cached (GtkWidget *page_local,
gis_driver_set_user_permissions (GIS_PAGE (page)->driver, user, password);
}
+void
+on_network_changed (GNetworkMonitor *monitor,
+ gboolean available,
+ GisAccountPage *page)
+{
+ GisAccountPagePrivate *priv = gis_account_page_get_instance_private (page);
+
+ if (!available && priv->mode != UM_ENTERPRISE)
+ gtk_stack_set_visible_child (GTK_STACK (priv->offline_stack), priv->offline_label);
+ else
+ gtk_stack_set_visible_child (GTK_STACK (priv->offline_stack), priv->page_toggle);
+}
+
static void
gis_account_page_constructed (GObject *object)
{
GisAccountPage *page = GIS_ACCOUNT_PAGE (object);
GisAccountPagePrivate *priv = gis_account_page_get_instance_private (page);
+ GNetworkMonitor *monitor;
+ gboolean available;
G_OBJECT_CLASS (gis_account_page_parent_class)->constructed (object);
@@ -233,6 +250,11 @@ gis_account_page_constructed (GObject *object)
priv->mode = NUM_MODES;
set_mode (page, UM_LOCAL);
+ monitor = g_network_monitor_get_default ();
+ available = g_network_monitor_get_network_available (monitor);
+ on_network_changed (monitor, available, page);
+ g_signal_connect (monitor, "network-changed", G_CALLBACK (on_network_changed), page);
+
gtk_widget_show (GTK_WIDGET (page));
}
@@ -252,9 +274,11 @@ gis_account_page_class_init (GisAccountPageClass *klass)
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPage, page_local);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPage, page_enterprise);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPage, stack);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPage, page_toggle);
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPage, stack);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPage, offline_label);
+ gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPage, offline_stack);
page_class->page_id = PAGE_ID;
page_class->locale_changed = gis_account_page_locale_changed;
diff --git a/gnome-initial-setup/pages/account/gis-account-page.ui
b/gnome-initial-setup/pages/account/gis-account-page.ui
index bf55701..c8297fb 100644
--- a/gnome-initial-setup/pages/account/gis-account-page.ui
+++ b/gnome-initial-setup/pages/account/gis-account-page.ui
@@ -31,16 +31,34 @@
</packing>
</child>
<child>
- <object class="GtkToggleButton" id="page_toggle">
+ <object class="GtkStack" id="offline_stack">
<property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="label" translatable="yes">Set Up _Enterprise Login</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="margin_bottom">18</property>
+ <child>
+ <object class="GtkToggleButton" id="page_toggle">
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="label" translatable="yes">Set Up _Enterprise Login</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="offline_label">
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="label" translatable="yes">Go online to set up Enterprise Login.</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
</template>
-</interface>
+</interface>
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]