[gnome-control-center] network: Improve the hotspot dialog



commit e76472c5483eec908f926a6fe9ec6012959978df
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Aug 7 23:40:47 2012 -0400

    network: Improve the hotspot dialog
    
    Change the hotspot dialog to match the mockups more closely.

 panels/network/net-device-wifi.c |   80 +++++++++---------------
 panels/network/network-wifi.ui   |  122 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 152 insertions(+), 50 deletions(-)
---
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index c933b27..ddc4db3 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -1390,83 +1390,63 @@ start_hotspot_response_cb (GtkWidget *dialog, gint response, NetDeviceWifi *devi
         if (response == GTK_RESPONSE_OK) {
                 start_shared_connection (device_wifi);
         }
-        gtk_widget_destroy (dialog);
+        gtk_widget_hide (dialog);
 }
 
 static void
 start_hotspot (GtkButton *button, NetDeviceWifi *device_wifi)
 {
         NMDevice *device;
-        gboolean is_default;
         const GPtrArray *connections;
-        const GPtrArray *devices;
-        NMActiveConnection *c;
-        NMAccessPoint *ap;
         gchar *active_ssid;
-        gchar *warning;
-        gint i;
         NMClient *client;
+        GtkWidget *dialog;
+        GtkWidget *window;
+        GtkWidget *widget;
+        GString *str;
 
-        warning = NULL;
+        active_ssid = NULL;
 
         client = net_object_get_client (NET_OBJECT (device_wifi));
         device = net_device_get_nm_device (NET_DEVICE (device_wifi));
         connections = nm_client_get_active_connections (client);
-        if (connections == NULL || connections->len == 0) {
-                warning = g_strdup_printf ("%s\n\n%s",
-                                           _("Not connected to the internet."),
-                                           _("Create the hotspot anyway?"));
-        } else {
-                is_default = FALSE;
-                active_ssid = NULL;
+        if (connections) {
+                gint i;
                 for (i = 0; i < connections->len; i++) {
+                        NMActiveConnection *c;
+                        const GPtrArray *devices;
                         c = (NMActiveConnection *)connections->pdata[i];
                         devices = nm_active_connection_get_devices (c);
                         if (devices && devices->pdata[0] == device) {
+                                NMAccessPoint *ap;
                                 ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (device));
                                 active_ssid = nm_utils_ssid_to_utf8 (nm_access_point_get_ssid (ap));
-                                is_default = nm_active_connection_get_default (c);
                                 break;
                         }
                 }
-
-                if (active_ssid != NULL) {
-                        GString *str;
-                        str = g_string_new ("");
-                        g_string_append_printf (str, _("Disconnect from %s and create a new hotspot?"), active_ssid);
-                        if (is_default) {
-                                g_string_append (str, "\n\n");
-                                g_string_append (str, _("This is your only connection to the internet."));
-                        }
-                        warning = g_string_free (str, FALSE);
-                }
         }
 
-        if (warning != NULL) {
-                GtkWidget *dialog;
-                GtkWidget *window;
-                CcNetworkPanel *panel;
-
-                panel = net_object_get_panel (NET_OBJECT (device_wifi));
-                window = gtk_widget_get_toplevel (GTK_WIDGET (panel));
-                dialog = gtk_message_dialog_new (GTK_WINDOW (window),
-                                                 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                 GTK_MESSAGE_OTHER,
-                                                 GTK_BUTTONS_NONE,
-                                                 "%s", warning);
-                gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-                                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                        _("Create _Hotspot"), GTK_RESPONSE_OK,
-                                        NULL);
-                g_signal_connect (dialog, "response",
-                                  G_CALLBACK (start_hotspot_response_cb), device_wifi);
-                gtk_window_present (GTK_WINDOW (dialog));
+        window = gtk_widget_get_toplevel (GTK_WIDGET (button));
 
-                return;
-          }
+        dialog = GTK_WIDGET (gtk_builder_get_object (device_wifi->priv->builder, "hotspot-dialog"));
+        gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
+
+        str = g_string_new (_("If you have a connection to the Internet other than wireless, you can use it to share your internet connection with others."));
+        g_string_append (str, "\n\n");
 
-        /* if we get here, things look good to go ahead */
-        start_shared_connection (device_wifi);
+        if (active_ssid)
+                g_string_append_printf (str, _("Switching on the wireless hotspot will disconnect you from <b>%s</b>."), active_ssid);
+
+        g_string_append (str, _("It is not possible to access the internet through your wireless while the hotspot is active."));
+
+        widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->priv->builder, "hotspot-dialog-content"));
+        gtk_label_set_markup (GTK_LABEL (widget), str->str);
+        g_string_free (str, TRUE);
+
+        g_signal_connect (dialog, "response",
+                          G_CALLBACK (start_hotspot_response_cb), device_wifi);
+        gtk_window_present (GTK_WINDOW (dialog));
+        g_free (active_ssid);
 }
 
 static void
diff --git a/panels/network/network-wifi.ui b/panels/network/network-wifi.ui
index 273bf63..b5e0406 100644
--- a/panels/network/network-wifi.ui
+++ b/panels/network/network-wifi.ui
@@ -23,6 +23,128 @@
       <column type="gboolean"/>
     </columns>
   </object>
+  <object class="GtkDialog" id="hotspot-dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="type_hint">dialog</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="modal">True</property>
+    <property name="border-width">5</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="hotspot-dialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">14</property>
+        <child>
+          <object class="GtkBox" id="hotspot-dialog-box1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">12</property>
+            <property name="border-width">5</property>
+            <child>
+              <object class="GtkImage" id="hotspot-dialog-image">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="icon_name">network-wireless</property>
+                <property name="icon-size">6</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="hotspot-dialog-title">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Wireless Hotspot</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                  <attribute name="scale" value="1.2"/>
+                </attributes>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="hotspot-dialog-content">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="wrap">True</property>
+            <property name="width_chars">60</property>
+            <property name="max_width_chars">60</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="hotspot-dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkButton" id="hotspot-cancel-button">
+                <property name="label">gtk-cancel</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="hotspot-turn-on-button">
+                <property name="label" translatable="yes">_Turn On</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">hotspot-cancel-button</action-widget>
+      <action-widget response="-5">hotspot-turn-on-button</action-widget>
+    </action-widgets>
+  </object>
   <object class="GtkWindow" id="window_tmp">
     <property name="can_focus">False</property>
     <child>



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