network: Show hotspot details in a new sub-frame to match the mockup
This commit is contained in:
parent
14011dac11
commit
ae5acbe421
2 changed files with 285 additions and 142 deletions
|
@ -618,23 +618,54 @@ device_wifi_refresh_saved_connections (NetDeviceWifi *device_wifi)
|
|||
g_slist_free (filtered);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_device_wifi_refresh_hotspot (NetDeviceWifi *device_wifi)
|
||||
{
|
||||
const GByteArray *ssid;
|
||||
gchar *hotspot_secret = NULL;
|
||||
gchar *hotspot_security = NULL;
|
||||
gchar *hotspot_ssid = NULL;
|
||||
NMDevice *nm_device;
|
||||
|
||||
/* refresh hotspot ui */
|
||||
nm_device = net_device_get_nm_device (NET_DEVICE (device_wifi));
|
||||
ssid = device_get_hotspot_ssid (device_wifi, nm_device);
|
||||
if (ssid)
|
||||
hotspot_ssid = nm_utils_ssid_to_utf8 (ssid);
|
||||
device_get_hotspot_security_details (device_wifi,
|
||||
nm_device,
|
||||
&hotspot_secret,
|
||||
&hotspot_security);
|
||||
|
||||
panel_set_device_widget_details (device_wifi->priv->builder,
|
||||
"hotspot_network_name",
|
||||
hotspot_ssid);
|
||||
panel_set_device_widget_details (device_wifi->priv->builder,
|
||||
"hotspot_security_key",
|
||||
hotspot_secret);
|
||||
panel_set_device_widget_details (device_wifi->priv->builder,
|
||||
"hotspot_security",
|
||||
hotspot_security);
|
||||
panel_set_device_widget_details (device_wifi->priv->builder,
|
||||
"hotspot_connected",
|
||||
NULL);
|
||||
|
||||
g_free (hotspot_secret);
|
||||
g_free (hotspot_security);
|
||||
g_free (hotspot_ssid);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi)
|
||||
{
|
||||
const gchar *str;
|
||||
gboolean can_start_hotspot;
|
||||
gboolean is_connected;
|
||||
gboolean is_hotspot;
|
||||
gchar *hotspot_secret;
|
||||
gchar *hotspot_security;
|
||||
gchar *hotspot_ssid;
|
||||
gchar *str_tmp = NULL;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *widget;
|
||||
gint strength = 0;
|
||||
guint speed = 0;
|
||||
NMAccessPoint *active_ap;
|
||||
NMClientPermissionResult perm;
|
||||
NMDevice *nm_device;
|
||||
NMDeviceState state;
|
||||
NMClient *client;
|
||||
|
@ -643,6 +674,8 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi)
|
|||
nm_device = net_device_get_nm_device (NET_DEVICE (device_wifi));
|
||||
state = nm_device_get_state (nm_device);
|
||||
is_hotspot = device_is_hotspot (device_wifi);
|
||||
if (is_hotspot)
|
||||
nm_device_wifi_refresh_hotspot (device_wifi);
|
||||
|
||||
/* set device kind */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->priv->builder, "label_device"));
|
||||
|
@ -669,12 +702,8 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi)
|
|||
|
||||
/* set device state, with status and optionally speed */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->priv->builder, "label_status"));
|
||||
if (is_hotspot) {
|
||||
gtk_label_set_label (GTK_LABEL (widget), _("Hotspot"));
|
||||
} else {
|
||||
gtk_label_set_label (GTK_LABEL (widget),
|
||||
panel_device_state_to_localized_string (nm_device));
|
||||
}
|
||||
gtk_widget_set_tooltip_text (widget, panel_device_state_reason_to_localized_string (nm_device));
|
||||
|
||||
/* The options button is always enabled for wired connections,
|
||||
|
@ -684,46 +713,6 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi)
|
|||
is_connected = find_connection_for_device (device_wifi, nm_device) != NULL;
|
||||
gtk_widget_set_sensitive (widget, is_connected);
|
||||
|
||||
/* sort out hotspot ui */
|
||||
is_hotspot = device_is_hotspot (device_wifi);
|
||||
hotspot_ssid = NULL;
|
||||
hotspot_secret = NULL;
|
||||
hotspot_security = NULL;
|
||||
if (is_hotspot) {
|
||||
const GByteArray *ssid;
|
||||
ssid = device_get_hotspot_ssid (device_wifi, nm_device);
|
||||
if (ssid) {
|
||||
hotspot_ssid = nm_utils_ssid_to_utf8 (ssid);
|
||||
}
|
||||
device_get_hotspot_security_details (device_wifi, nm_device, &hotspot_secret, &hotspot_security);
|
||||
}
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->priv->builder,
|
||||
"start_hotspot_button"));
|
||||
gtk_widget_set_visible (widget, !is_hotspot);
|
||||
|
||||
sw = GTK_WIDGET (gtk_builder_get_object (device_wifi->priv->builder,
|
||||
"device_off_switch"));
|
||||
perm = nm_client_get_permission_result (client, NM_CLIENT_PERMISSION_WIFI_SHARE_OPEN);
|
||||
can_start_hotspot = gtk_switch_get_active (GTK_SWITCH (sw)) &&
|
||||
(perm == NM_CLIENT_PERMISSION_RESULT_YES ||
|
||||
perm == NM_CLIENT_PERMISSION_RESULT_AUTH);
|
||||
gtk_widget_set_sensitive (widget, can_start_hotspot);
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->priv->builder,
|
||||
"stop_hotspot_button"));
|
||||
gtk_widget_set_visible (widget, is_hotspot);
|
||||
|
||||
panel_set_device_widget_details (device_wifi->priv->builder,
|
||||
"hotspot_network_name",
|
||||
hotspot_ssid);
|
||||
g_free (hotspot_ssid);
|
||||
|
||||
panel_set_device_widget_details (device_wifi->priv->builder,
|
||||
"hotspot_security_key",
|
||||
hotspot_secret);
|
||||
g_free (hotspot_secret);
|
||||
|
||||
/* device MAC */
|
||||
str = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (nm_device));
|
||||
panel_set_device_widget_details (device_wifi->priv->builder,
|
||||
|
@ -733,8 +722,6 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *device_wifi)
|
|||
active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (nm_device));
|
||||
if (state == NM_DEVICE_STATE_UNAVAILABLE)
|
||||
str_tmp = NULL;
|
||||
else if (is_hotspot)
|
||||
str_tmp = hotspot_security;
|
||||
else if (active_ap != NULL)
|
||||
str_tmp = get_ap_security_string (active_ap);
|
||||
panel_set_device_widget_details (device_wifi->priv->builder,
|
||||
|
@ -1239,6 +1226,9 @@ activate_cb (NMClient *client,
|
|||
GError *error,
|
||||
NetDeviceWifi *device_wifi)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkSwitch *sw;
|
||||
|
||||
if (error) {
|
||||
g_warning ("Failed to add new connection: (%d) %s",
|
||||
error->code,
|
||||
|
@ -1246,7 +1236,18 @@ activate_cb (NMClient *client,
|
|||
return;
|
||||
}
|
||||
|
||||
/* show hotspot tab */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->priv->builder, "notebook_view"));
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 3);
|
||||
nm_device_wifi_refresh_ui (device_wifi);
|
||||
|
||||
/* force switch to on as this succeeded */
|
||||
sw = GTK_SWITCH (gtk_builder_get_object (device_wifi->priv->builder,
|
||||
"switch_hotspot_off"));
|
||||
device_wifi->priv->updating_device = TRUE;
|
||||
gtk_switch_set_active (sw, TRUE);
|
||||
device_wifi->priv->updating_device = FALSE;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1478,6 +1479,7 @@ stop_shared_connection (NetDeviceWifi *device_wifi)
|
|||
}
|
||||
|
||||
nm_device_wifi_refresh_ui (device_wifi);
|
||||
show_wifi_list (device_wifi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1490,12 +1492,17 @@ stop_hotspot_response_cb (GtkWidget *dialog, gint response, NetDeviceWifi *devic
|
|||
}
|
||||
|
||||
static void
|
||||
stop_hotspot (GtkButton *button, NetDeviceWifi *device_wifi)
|
||||
switch_hotspot_changed_cb (GtkSwitch *sw,
|
||||
GParamSpec *pspec,
|
||||
NetDeviceWifi *device_wifi)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *window;
|
||||
CcNetworkPanel *panel;
|
||||
|
||||
if (device_wifi->priv->updating_device)
|
||||
return;
|
||||
|
||||
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),
|
||||
|
@ -1969,7 +1976,7 @@ net_device_wifi_init (NetDeviceWifi *device_wifi)
|
|||
g_signal_connect (widget, "clicked",
|
||||
G_CALLBACK (start_hotspot), device_wifi);
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (device_wifi->priv->builder,
|
||||
"stop_hotspot_button"));
|
||||
g_signal_connect (widget, "clicked",
|
||||
G_CALLBACK (stop_hotspot), device_wifi);
|
||||
"switch_hotspot_off"));
|
||||
g_signal_connect (widget, "notify::active",
|
||||
G_CALLBACK (switch_hotspot_changed_cb), device_wifi);
|
||||
}
|
||||
|
|
|
@ -427,40 +427,6 @@
|
|||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="heading_hotspot_network_name">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Network Name</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">9</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="heading_hotspot_security_key">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Security Key</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">10</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_security">
|
||||
<property name="visible">True</property>
|
||||
|
@ -476,36 +442,6 @@
|
|||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_hotspot_network_name">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">My Hot Spot</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">9</property>
|
||||
<property name="width">2</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_hotspot_security_key">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">My Secret</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">10</property>
|
||||
<property name="width">2</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button_back">
|
||||
<property name="visible">True</property>
|
||||
|
@ -607,24 +543,6 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">12</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="stop_hotspot_button">
|
||||
<property name="label" translatable="yes">_Stop Hotspot...</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">1</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="button_options">
|
||||
<property name="label" translatable="yes">_Options...</property>
|
||||
|
@ -688,10 +606,228 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label35">
|
||||
<object class="GtkVBox" id="box_hotspot">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label">label</property>
|
||||
<property name="border_width">12</property>
|
||||
<property name="spacing">9</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box_hotspot_top">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="vbox345">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">3</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_hotspot_title">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</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">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_hotspot_explanation">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Switch off to connect to a wireless network</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="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="switch_hotspot_off">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</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="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid_hotspot">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="row_spacing">10</property>
|
||||
<property name="column_spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="heading_hotspot_network_name">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Network Name</property>
|
||||
<property name="mnemonic_widget">label_hotspot_name</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="heading_hotspot_connected">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Connected Devices</property>
|
||||
<property name="mnemonic_widget">label_hotspot_connected</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="heading_hotspot_security">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Security type</property>
|
||||
<property name="mnemonic_widget">label_hotspot_security</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_hotspot_network_name">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">networkname0</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_hotspot_connected">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">hughsie-dell-mini, hughsie-work</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_hotspot_security">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">WPA Enterprise</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="heading_hotspot_security_key">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Security key</property>
|
||||
<property name="mnemonic_widget">label_hotspot_security_key</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label_hotspot_security_key">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">0xdeadbeef</property>
|
||||
<property name="selectable">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">3</property>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue