[gnome-control-center/gbsneto/wifi-behavior: 4/4] wi-fi: Add empty state for Airplane Mode



commit b9da351a3dec660e0de3d7e1673383ccd6d2d017
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Jul 22 19:56:57 2018 -0300

    wi-fi: Add empty state for Airplane Mode
    
    According to the most recent mockups [1], when Airplane
    Mode is switched on, the Wi-Fi connection will be turned
    off and the Wi-Fi panel should show an empty state for
    Airplane Mode. This is currently not implemented in the
    codebase.
    
    This commit adds an Airplane Mode empty state for the Wi-Fi
    panel, and a small logic adjustment to show it under these
    circumstances.

 panels/network/cc-wifi-panel.c  | 11 +++++++---
 panels/network/cc-wifi-panel.ui | 47 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 3 deletions(-)
---
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c
index fb77d2e1a..2448f87a2 100644
--- a/panels/network/cc-wifi-panel.c
+++ b/panels/network/cc-wifi-panel.c
@@ -183,17 +183,21 @@ static void
 check_main_stack_page (CcWifiPanel *self)
 {
   const gchar *nm_version;
+  gboolean airplane_mode_active;
+  gboolean wireless_enabled;
 
   nm_version = nm_client_get_version (self->client);
+  wireless_enabled = nm_client_wireless_get_enabled (self->client);
+  airplane_mode_active = gtk_switch_get_active (self->rfkill_switch);
 
   if (!nm_version)
     gtk_stack_set_visible_child_name (self->main_stack, "nm-not-running");
-  else if (self->devices->len == 0 ||
-           !nm_client_wireless_get_enabled (self->client))
+  else if (!wireless_enabled && airplane_mode_active)
+    gtk_stack_set_visible_child_name (self->main_stack, "airplane-mode");
+  else if (!wireless_enabled || self->devices->len == 0)
     gtk_stack_set_visible_child_name (self->main_stack, "no-wifi-devices");
   else
     gtk_stack_set_visible_child_name (self->main_stack, "wifi-connections");
-
 }
 
 static void
@@ -247,6 +251,7 @@ sync_airplane_mode_switch (CcWifiPanel *self)
                                        rfkill_switch_notify_activate_cb,
                                        self);
       gtk_switch_set_active (self->rfkill_switch, enabled);
+      check_main_stack_page (self);
       g_signal_handlers_unblock_by_func (self->rfkill_switch,
                                          rfkill_switch_notify_activate_cb,
                                          self);
diff --git a/panels/network/cc-wifi-panel.ui b/panels/network/cc-wifi-panel.ui
index b50f4eb71..ffc034a72 100644
--- a/panels/network/cc-wifi-panel.ui
+++ b/panels/network/cc-wifi-panel.ui
@@ -175,6 +175,53 @@
                       </packing>
                     </child>
 
+                    <!-- "Airplane Mode" page -->
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="expand">True</property>
+                        <property name="halign">center</property>
+                        <property name="valign">center</property>
+                        <property name="orientation">vertical</property>
+                        <child>
+                          <object class="GtkImage">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="icon_name">airplane-mode-symbolic</property>
+                            <property name="pixel_size">256</property>
+                            <property name="margin-bottom">18</property>
+                            <style>
+                              <class name="dim-label" />
+                            </style>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="wrap">True</property>
+                            <property name="label" translatable="yes">Airplane Mode On</property>
+                            <attributes>
+                              <attribute name="weight" value="bold" />
+                              <attribute name="scale" value="1.2" />
+                            </attributes>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="wrap">True</property>
+                            <property name="label" translatable="yes">Turn off to use Wi-Fi</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="name">airplane-mode</property>
+                      </packing>
+                    </child>
+
                     <!-- Wi-Fi connections and devices -->
                     <child>
                       <object class="GtkBox">


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]