[network-manager-netbook] User interface updates
- From: Tambet Ingo <tambeti src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-netbook] User interface updates
- Date: Wed, 23 Dec 2009 09:08:22 +0000 (UTC)
commit c5ab454b30b2b7e546b9f37162b65a3f46693500
Author: Tambet Ingo <tambet gmail com>
Date: Tue Dec 22 15:42:06 2009 +0200
User interface updates
While connecting, set connect button text to Cancel.
Use "SSID - Available" for available APs.
Show device MAC address in advanced information.
Set the text on delete connection buttons: "No, save", "Yes, delete".
Show network item buttons on hover only.
If hardware for a particular connection type is not present, it should not be shown in the sidebar.
libnm-gtk/nm-bt-item.c | 12 +++++
libnm-gtk/nm-device-item.c | 11 +++++
libnm-gtk/nm-device-item.h | 4 +-
libnm-gtk/nm-ethernet-item.c | 12 +++++
libnm-gtk/nm-wifi-item.c | 11 +++++
src/nmn-applet.c | 96 ++++++++++++++++++++++++++++++++----------
src/nmn-connection-details.c | 15 ++++++-
src/nmn-connection-details.h | 3 +-
src/nmn-item-renderer.c | 25 ++++++++---
9 files changed, 155 insertions(+), 34 deletions(-)
---
diff --git a/libnm-gtk/nm-bt-item.c b/libnm-gtk/nm-bt-item.c
index 8b4b99e..2545c89 100644
--- a/libnm-gtk/nm-bt-item.c
+++ b/libnm-gtk/nm-bt-item.c
@@ -45,6 +45,16 @@ priority (NMListItem *item)
return NM_LIST_ITEM_PRIORITY_DEV_BT + NM_LIST_ITEM_CLASS (nm_bt_item_parent_class)->priority (item);
}
+static const char *
+bt_get_hw_address (NMDeviceItem *item)
+{
+ NMDeviceBt *device;
+
+ device = NM_DEVICE_BT (nm_device_item_get_device (NM_DEVICE_ITEM (item)));
+
+ return nm_device_bt_get_hw_address (device);
+}
+
/*****************************************************************************/
static void
@@ -68,8 +78,10 @@ nm_bt_item_class_init (NMBtItemClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMListItemClass *list_class = NM_LIST_ITEM_CLASS (klass);
+ NMDeviceItemClass *device_class = NM_DEVICE_ITEM_CLASS (klass);
object_class->notify = notify;
list_class->priority = priority;
+ device_class->get_hw_address = bt_get_hw_address;
}
diff --git a/libnm-gtk/nm-device-item.c b/libnm-gtk/nm-device-item.c
index dc134bb..cc29d10 100644
--- a/libnm-gtk/nm-device-item.c
+++ b/libnm-gtk/nm-device-item.c
@@ -44,6 +44,17 @@ nm_device_item_get_device (NMDeviceItem *self)
return GET_PRIVATE (self)->device;
}
+const char *
+nm_device_item_get_hw_address (NMDeviceItem *self)
+{
+ g_return_val_if_fail (NM_IS_DEVICE_ITEM (self), NULL);
+
+ if (NM_DEVICE_ITEM_GET_CLASS (self)->get_hw_address)
+ return NM_DEVICE_ITEM_GET_CLASS (self)->get_hw_address (self);
+
+ return NULL;
+}
+
static void
connect_cb (gpointer user_data, const char *object_path, GError *error)
{
diff --git a/libnm-gtk/nm-device-item.h b/libnm-gtk/nm-device-item.h
index be94b94..ea2c640 100644
--- a/libnm-gtk/nm-device-item.h
+++ b/libnm-gtk/nm-device-item.h
@@ -44,11 +44,13 @@ typedef struct {
/* Methods */
char *(*get_specific_object) (NMDeviceItem *self);
+ const char *(*get_hw_address) (NMDeviceItem *self);
} NMDeviceItemClass;
GType nm_device_item_get_type (void);
-NMDevice *nm_device_item_get_device (NMDeviceItem *self);
+NMDevice *nm_device_item_get_device (NMDeviceItem *self);
+const char *nm_device_item_get_hw_address (NMDeviceItem *self);
G_END_DECLS
diff --git a/libnm-gtk/nm-ethernet-item.c b/libnm-gtk/nm-ethernet-item.c
index 1e9a277..cd2a244 100644
--- a/libnm-gtk/nm-ethernet-item.c
+++ b/libnm-gtk/nm-ethernet-item.c
@@ -64,6 +64,16 @@ priority (NMListItem *item)
return NM_LIST_ITEM_PRIORITY_DEV_ETHERNET + NM_LIST_ITEM_CLASS (nm_ethernet_item_parent_class)->priority (item);
}
+static const char *
+ethernet_get_hw_address (NMDeviceItem *item)
+{
+ NMDeviceEthernet *device;
+
+ device = NM_DEVICE_ETHERNET (nm_device_item_get_device (NM_DEVICE_ITEM (item)));
+
+ return nm_device_ethernet_get_hw_address (device);
+}
+
/*****************************************************************************/
static void
@@ -108,9 +118,11 @@ nm_ethernet_item_class_init (NMEthernetItemClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMListItemClass *list_class = NM_LIST_ITEM_CLASS (klass);
+ NMDeviceItemClass *device_class = NM_DEVICE_ITEM_CLASS (klass);
object_class->constructed = constructed;
object_class->notify = notify;
list_class->priority = priority;
+ device_class->get_hw_address = ethernet_get_hw_address;
}
diff --git a/libnm-gtk/nm-wifi-item.c b/libnm-gtk/nm-wifi-item.c
index 1d6a780..9d05e1a 100644
--- a/libnm-gtk/nm-wifi-item.c
+++ b/libnm-gtk/nm-wifi-item.c
@@ -177,6 +177,16 @@ wifi_get_specific_object (NMDeviceItem *item)
return g_strdup (nm_object_get_path (NM_OBJECT (ap)));
}
+static const char *
+wifi_get_hw_address (NMDeviceItem *item)
+{
+ NMDeviceWifi *device;
+
+ device = NM_DEVICE_WIFI (nm_device_item_get_device (NM_DEVICE_ITEM (item)));
+
+ return nm_device_wifi_get_hw_address (device);
+}
+
static int
priority (NMListItem *item)
{
@@ -580,6 +590,7 @@ nm_wifi_item_class_init (NMWifiItemClass *klass)
list_class->connect = connect;
device_class->get_specific_object = wifi_get_specific_object;
+ device_class->get_hw_address = wifi_get_hw_address;
/* Properties */
g_object_class_install_property
diff --git a/src/nmn-applet.c b/src/nmn-applet.c
index b6229d5..c871b09 100644
--- a/src/nmn-applet.c
+++ b/src/nmn-applet.c
@@ -46,10 +46,17 @@ typedef struct {
GtkWidget *pane;
GtkWidget *list;
+
+ GtkWidget *switches_table;
+ GtkWidget *enable_wifi_label;
GtkWidget *enable_wifi;
+ GtkWidget *enable_ethernet_label;
GtkWidget *enable_ethernet;
+ GtkWidget *enable_3g_label;
GtkWidget *enable_3g;
+ GtkWidget *enable_wimax_label;
GtkWidget *enable_wimax;
+ GtkWidget *enable_bt_label;
GtkWidget *enable_bt;
GtkWidget *enable_network;
GtkWidget *add_new_connection;
@@ -66,6 +73,14 @@ enum {
PAGE_ADD_CONNECTION = 1,
};
+enum {
+ SWITCHES_ROW_WIFI = 0,
+ SWITCHES_ROW_ETHERNET = 1,
+ SWITCHES_ROW_3G = 2,
+ SWITCHES_ROW_WIMAX = 3,
+ SWITCHES_ROW_BT = 4
+};
+
static void add_new_connection_hide (GtkWidget *widget, gpointer user_data);
static void wifi_toggle_set_sensitive (NmnModel *model, GtkWidget *widget, gboolean suggested);
@@ -79,11 +94,12 @@ nmn_applet_new (NmnModel *model)
NULL));
}
-/* I know 'sensitize' isn't a real word. So? */
static void
-sensitize_switches (NmnApplet *applet)
+update_switches_visibility (NmnApplet *applet)
{
NmnAppletPrivate *priv = GET_PRIVATE (applet);
+ GtkTable *table;
+ gboolean visible;
int ethernet;
int wifi;
int modem;
@@ -111,11 +127,32 @@ sensitize_switches (NmnApplet *applet)
}
}
- gtk_widget_set_sensitive (priv->enable_ethernet, ethernet > 0);
- wifi_toggle_set_sensitive (priv->model, priv->enable_wifi, wifi > 0);
- gtk_widget_set_sensitive (priv->enable_3g, modem > 0);
- gtk_widget_set_sensitive (priv->enable_wimax, wimax > 0);
- gtk_widget_set_sensitive (priv->enable_bt, bt > 0);
+ table = GTK_TABLE (priv->switches_table);
+
+ visible = wifi > 0;
+ gtk_table_set_row_spacing (table, SWITCHES_ROW_WIFI, visible ? 6 : 0);
+ g_object_set (priv->enable_wifi_label, "visible", visible, NULL);
+ g_object_set (priv->enable_wifi, "visible", visible, NULL);
+
+ visible = ethernet > 0;
+ gtk_table_set_row_spacing (table, SWITCHES_ROW_ETHERNET, visible ? 6 : 0);
+ g_object_set (priv->enable_ethernet_label, "visible", visible, NULL);
+ g_object_set (priv->enable_ethernet, "visible", visible, NULL);
+
+ visible = modem > 0;
+ gtk_table_set_row_spacing (table, SWITCHES_ROW_3G, visible ? 6 : 0);
+ g_object_set (priv->enable_3g_label, "visible", visible, NULL);
+ g_object_set (priv->enable_3g, "visible", visible, NULL);
+
+ visible = wimax > 0;
+ gtk_table_set_row_spacing (table, SWITCHES_ROW_WIMAX, visible ? 6 : 0);
+ g_object_set (priv->enable_wimax_label, "visible", visible, NULL);
+ g_object_set (priv->enable_wimax, "visible", visible, NULL);
+
+ visible = bt > 0;
+ gtk_table_set_row_spacing (table, SWITCHES_ROW_BT, visible ? 6 : 0);
+ g_object_set (priv->enable_bt_label, "visible", visible, NULL);
+ g_object_set (priv->enable_bt, "visible", visible, NULL);
}
void
@@ -309,7 +346,7 @@ offline_toggled (NmnModel *model,
nbtk_gtk_light_switch_set_active (NBTK_GTK_LIGHT_SWITCH (priv->enable_network), active);
g_signal_handlers_unblock_by_func (priv->model, enable_network_toggled, user_data);
- sensitize_switches (NMN_APPLET (user_data));
+ update_switches_visibility (NMN_APPLET (user_data));
}
static void
@@ -355,7 +392,7 @@ add_new_connection_setup (NmnApplet *applet)
static gboolean
devices_changed_cb (gpointer user_data)
{
- sensitize_switches (NMN_APPLET (user_data));
+ update_switches_visibility (NMN_APPLET (user_data));
return FALSE;
}
@@ -420,41 +457,54 @@ nmn_applet_init (NmnApplet *applet)
frame = nbtk_gtk_frame_new ();
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
- table = gtk_table_new (5, 2, TRUE);
+ w = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (frame), w);
+
+ table = gtk_table_new (5, 2, FALSE);
+ priv->switches_table = table;
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
- gtk_container_add (GTK_CONTAINER (frame), table);
+ gtk_box_pack_start (GTK_BOX (w), table, FALSE, FALSE, 0);
w = gtk_label_new (_("WiFi"));
+ priv->enable_wifi_label = w;
gtk_misc_set_alignment (GTK_MISC (w), 0.2, 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), w, 0, 1, 0, 1);
+ gtk_table_attach_defaults (GTK_TABLE (table), w, 0, 1, SWITCHES_ROW_WIFI, SWITCHES_ROW_WIFI + 1);
priv->enable_wifi = nbtk_gtk_light_switch_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), priv->enable_wifi, 1, 2, 0, 1);
+ gtk_table_attach_defaults (GTK_TABLE (table), priv->enable_wifi, 1, 2,
+ SWITCHES_ROW_WIFI, SWITCHES_ROW_WIFI + 1);
w = gtk_label_new (_("Wired"));
+ priv->enable_ethernet_label = w;
gtk_misc_set_alignment (GTK_MISC (w), 0.2, 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), w, 0, 1, 1, 2);
+ gtk_table_attach_defaults (GTK_TABLE (table), w, 0, 1, SWITCHES_ROW_ETHERNET, SWITCHES_ROW_ETHERNET + 1);
priv->enable_ethernet = nbtk_gtk_light_switch_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), priv->enable_ethernet, 1, 2, 1, 2);
+ gtk_table_attach_defaults (GTK_TABLE (table), priv->enable_ethernet, 1, 2,
+ SWITCHES_ROW_ETHERNET, SWITCHES_ROW_ETHERNET + 1);
w = gtk_label_new (_("3G"));
+ priv->enable_3g_label = w;
gtk_misc_set_alignment (GTK_MISC (w), 0.2, 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), w, 0, 1, 2, 3);
+ gtk_table_attach_defaults (GTK_TABLE (table), w, 0, 1, SWITCHES_ROW_3G, SWITCHES_ROW_3G + 1);
priv->enable_3g = nbtk_gtk_light_switch_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), priv->enable_3g, 1, 2, 2, 3);
+ gtk_table_attach_defaults (GTK_TABLE (table), priv->enable_3g, 1, 2,
+ SWITCHES_ROW_3G, SWITCHES_ROW_3G + 1);
w = gtk_label_new (_("WiMAX"));
+ priv->enable_wimax_label = w;
gtk_misc_set_alignment (GTK_MISC (w), 0.2, 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), w, 0, 1, 3, 4);
+ gtk_table_attach_defaults (GTK_TABLE (table), w, 0, 1, SWITCHES_ROW_WIMAX, SWITCHES_ROW_WIMAX + 1);
priv->enable_wimax = nbtk_gtk_light_switch_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), priv->enable_wimax, 1, 2, 3, 4);
+ gtk_table_attach_defaults (GTK_TABLE (table), priv->enable_wimax, 1, 2,
+ SWITCHES_ROW_WIMAX, SWITCHES_ROW_WIMAX + 1);
w = gtk_label_new (_("Bluetooth"));
+ priv->enable_bt_label = w;
gtk_misc_set_alignment (GTK_MISC (w), 0.2, 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), w, 0, 1, 4, 5);
+ gtk_table_attach_defaults (GTK_TABLE (table), w, 0, 1, SWITCHES_ROW_BT, SWITCHES_ROW_BT + 1);
priv->enable_bt = nbtk_gtk_light_switch_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), priv->enable_bt, 1, 2, 4, 5);
-
+ gtk_table_attach_defaults (GTK_TABLE (table), priv->enable_bt, 1, 2,
+ SWITCHES_ROW_BT, SWITCHES_ROW_BT + 1);
frame = nbtk_gtk_frame_new ();
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
@@ -511,7 +561,7 @@ constructor (GType type,
client = nmn_model_get_client (priv->model);
g_signal_connect (client, "device-added", G_CALLBACK (devices_changed), applet);
g_signal_connect (client, "device-removed", G_CALLBACK (devices_changed), applet);
- sensitize_switches (applet);
+ update_switches_visibility (applet);
return object;
}
diff --git a/src/nmn-connection-details.c b/src/nmn-connection-details.c
index 4948aaa..5953b8c 100644
--- a/src/nmn-connection-details.c
+++ b/src/nmn-connection-details.c
@@ -46,6 +46,7 @@ typedef struct {
GtkWidget *netmask;
GtkWidget *gateway;
GtkWidget *dns;
+ GtkWidget *hw_address;
gboolean editable;
gboolean last_check_result;
@@ -109,7 +110,8 @@ ip4_address_as_string (guint32 ip)
void
nmn_connection_details_set_data (NmnConnectionDetails *self,
NMSettingIP4Config *setting,
- NMIP4Config *config)
+ NMIP4Config *config,
+ const char *hw_address)
{
NmnConnectionDetailsPrivate *priv;
GtkTextBuffer *buffer;
@@ -203,6 +205,8 @@ nmn_connection_details_set_data (NmnConnectionDetails *self,
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->dns));
gtk_text_buffer_set_text (buffer, str, -1);
g_free (str);
+
+ gtk_label_set_text (GTK_LABEL (priv->hw_address), hw_address);
}
@@ -462,7 +466,7 @@ nmn_connection_details_init (NmnConnectionDetails *details)
GtkTextBuffer *buffer;
g_object_set (details,
- "n-rows", 7,
+ "n-rows", 8,
"n-columns", 2,
"homogeneous", FALSE,
"row-spacing", 6,
@@ -529,6 +533,13 @@ nmn_connection_details_init (NmnConnectionDetails *details)
g_signal_connect (buffer, "insert-text", G_CALLBACK (dns_filter_cb), NULL);
g_signal_connect_swapped (buffer, "changed", G_CALLBACK (stuff_changed), details);
+ /* Hardware address */
+ w = aligned_label_new (_("Your MAC address:"));
+ gtk_table_attach_defaults (table, w, 0, 1, 7, 8);
+
+ priv->hw_address = aligned_label_new (NULL);
+ gtk_table_attach_defaults (table, priv->hw_address, 1, 2, 7, 8);
+
editable_changed (details, TRUE);
stuff_changed (details);
gtk_widget_show_all (GTK_WIDGET (details));
diff --git a/src/nmn-connection-details.h b/src/nmn-connection-details.h
index dd41779..e53622e 100644
--- a/src/nmn-connection-details.h
+++ b/src/nmn-connection-details.h
@@ -48,7 +48,8 @@ GType nmn_connection_details_get_type (void);
NmnConnectionDetails *nmn_connection_details_new (void);
void nmn_connection_details_set_data (NmnConnectionDetails *self,
NMSettingIP4Config *setting,
- NMIP4Config *config);
+ NMIP4Config *config,
+ const char *hw_address);
NMSettingIP4Config *nmn_connection_details_get_data (NmnConnectionDetails *self);
gboolean nmn_connection_details_verify (NmnConnectionDetails *self);
diff --git a/src/nmn-item-renderer.c b/src/nmn-item-renderer.c
index b7cb3cd..95b71b3 100644
--- a/src/nmn-item-renderer.c
+++ b/src/nmn-item-renderer.c
@@ -91,6 +91,9 @@ update_background (NmnItemRenderer *self)
}
gtk_widget_modify_bg (GTK_WIDGET (self), GTK_STATE_NORMAL, color);
+ g_object_set (priv->connect_button, "visible", priv->prelight, NULL);
+ g_object_set (priv->remove_button, "visible", priv->prelight, NULL);
+ g_object_set (priv->expander, "visible", priv->prelight, NULL);
}
static void
@@ -101,6 +104,7 @@ update_details (NmnItemRenderer *self)
NMDevice *device;
NMSettingIP4Config *setting;
NMIP4Config *config;
+ const char *hw_address;
if (!priv->details)
return;
@@ -117,7 +121,9 @@ update_details (NmnItemRenderer *self)
else
config = NULL;
- nmn_connection_details_set_data (priv->details, setting, config);
+ hw_address = nm_device_item_get_hw_address (NM_DEVICE_ITEM (priv->item));
+
+ nmn_connection_details_set_data (priv->details, setting, config, hw_address);
}
static void
@@ -142,8 +148,8 @@ item_changed (NMListItem *item,
button_label = _("Disconnect");
break;
case NM_LIST_ITEM_STATUS_CONNECTING:
- status_str = _("Connecting...");
- button_label = _("Disconnect");
+ status_str = _("Connecting");
+ button_label = _("Cancel");
break;
default:
status_str = _("Disconnected");
@@ -153,8 +159,13 @@ item_changed (NMListItem *item,
if (NM_IS_CONNECTION_ITEM (item) && nm_connection_item_get_connection (NM_CONNECTION_ITEM (item)))
str = g_strdup_printf ("<big><b>%s - %s</b></big>", nm_list_item_get_name (item), status_str);
- else
- str = g_strdup_printf ("<big><b>%s</b></big>", nm_list_item_get_name (item));
+ else {
+ const char *available_str = _("Available");
+
+ str = g_strdup_printf ("<big><b>%s - %s</b></big>",
+ nm_list_item_get_name (item),
+ available_str);
+ }
gtk_label_set_markup (priv->name_and_status, str);
g_free (str);
@@ -265,9 +276,9 @@ remove_button_clicked (GtkButton *button, gpointer user_data)
NULL,
GTK_DIALOG_MODAL |
GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL,
+ _("No, save"),
GTK_RESPONSE_REJECT,
- GTK_STOCK_OK,
+ _("Yes, delete"),
GTK_RESPONSE_ACCEPT,
NULL));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]