[PATCH] nm-applet - fix long menu entries by using ellipsize and tooltip
- From: Alexander Sack <asac ubuntu com>
- To: networkmanager-list gnome org
- Subject: [PATCH] nm-applet - fix long menu entries by using ellipsize and tooltip
- Date: Tue, 7 Apr 2009 17:50:03 +0200
Fix for http://bugs.launchpad.net/bugs/341940; using ellipsizing and tooltip so that long APs / device
names can still be read properly on hovering
=== modified file 'ChangeLog'
--- a/ChangeLog 2009-04-04 21:08:22 +0000
+++ b/ChangeLog 2009-04-07 15:43:05 +0000
@@ -1,8 +1,20 @@
+2009-04-07 Alexander Sack <asac ubuntu com>
+
+ Fix long applet menu items - see LP: #341940
+
+ * src/ap-menu-item.c (nm_network_menu_item_init, nm_network_menu_item_set_ssid)
+ src/applet-device-cdma.ca (add_connection_items, cdma_add_menu_item)
+ src/applet-device-gsm.c (add_connection_items, gsm_add_menu_item)
+ src/applet-device-wifi.c (wireless_add_menu_item)
+ src/applet-device-wired.c (add_connection_items, wired_add_menu_item): use
+ ellipsized labels for menu entries; in turn we set a tooltip for APs so
+ users can still read the complete SSID
+
2009-04-04 Dan Williams <dcbw redhat com>
* Tag 0.7.1-rc4 (0.7.0.100)
2009-04-04 Dan Williams <dcbw redhat com>
* src/connection-editor/helpers.c
src/connection-editor/helpers.h
=== modified file 'src/ap-menu-item.c'
--- a/src/ap-menu-item.c 2008-12-11 22:52:35 +0000
+++ b/src/ap-menu-item.c 2009-04-07 15:28:37 +0000
@@ -46,16 +46,19 @@ nm_network_menu_item_init (NMNetworkMenu
PangoLanguage * lang;
int ascent;
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
item->hbox = gtk_hbox_new (FALSE, 6);
item->ssid = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (item->ssid), 0.0, 0.5);
+ gtk_label_set_max_width_chars (GTK_LABEL (item->ssid), 5);
+ gtk_label_set_ellipsize (GTK_LABEL (item->ssid), PANGO_ELLIPSIZE_END);
+
item->detail = gtk_image_new ();
gtk_container_add (GTK_CONTAINER (item), item->hbox);
gtk_box_pack_start (GTK_BOX (item->hbox), item->ssid, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (item->hbox), item->detail, FALSE, FALSE, 0);
item->strength = gtk_progress_bar_new ();
@@ -142,18 +145,20 @@ nm_network_menu_item_set_ssid (NMNetwork
g_return_if_fail (item != NULL);
g_return_if_fail (ssid != NULL);
display_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
if (!display_ssid) {
// FIXME: shouldn't happen; always coerce the SSID to _something_
gtk_label_set_text (GTK_LABEL (item->ssid), "<unknown>");
+ gtk_widget_set_tooltip_text (GTK_WIDGET (item->ssid), "<unknown>");
} else {
gtk_label_set_text (GTK_LABEL (item->ssid), display_ssid);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (item->ssid), display_ssid);
g_free (display_ssid);
}
}
guint32
nm_network_menu_item_get_strength (NMNetworkMenuItem * item)
{
g_return_val_if_fail (item != NULL, 0);
=== modified file 'src/applet-device-cdma.c'
--- a/src/applet-device-cdma.c 2009-02-05 19:02:55 +0000
+++ b/src/applet-device-cdma.c 2009-04-07 15:44:13 +0000
@@ -120,22 +120,27 @@ add_connection_items (NMDevice *device,
NMApplet *applet)
{
GSList *iter;
CdmaMenuItemInfo *info;
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item;
+ GtkWidget *item, *label;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
+ label = gtk_bin_get_child (GTK_BIN (item));
+ gtk_label_set_ellipsize (GTK_LABEL (label), TRUE);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), 30);
+ gtk_widget_set_tooltip_text (item, gtk_label_get_text (GTK_LABEL (label)));
+
if (connection == active)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
info = g_slice_new0 (CdmaMenuItemInfo);
info->applet = applet;
info->device = g_object_ref (G_OBJECT (device));
info->connection = g_object_ref (connection);
@@ -249,16 +254,20 @@ cdma_add_menu_item (NMDevice *device,
g_free (text);
label = gtk_bin_get_child (GTK_BIN (item));
bold_text = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
gtk_label_get_text (GTK_LABEL (label)));
gtk_label_set_markup (GTK_LABEL (label), bold_text);
g_free (bold_text);
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), 30);
+ gtk_widget_set_tooltip_text (item, gtk_label_get_text (GTK_LABEL (label)));
+
gtk_widget_set_sensitive (item, FALSE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* Notify user of unmanaged or unavailable device */
item = nma_menu_device_check_unusable (device, NULL);
if (item) {
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
=== modified file 'src/applet-device-gsm.c'
--- a/src/applet-device-gsm.c 2009-02-05 19:02:55 +0000
+++ b/src/applet-device-gsm.c 2009-04-07 15:39:46 +0000
@@ -121,22 +121,27 @@ add_connection_items (NMDevice *device,
NMApplet *applet)
{
GSList *iter;
GSMMenuItemInfo *info;
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item;
+ GtkWidget *item, *label;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
+ label = gtk_bin_get_child (GTK_BIN (item));
+ gtk_label_set_ellipsize (GTK_LABEL (label), TRUE);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), 30);
+ gtk_widget_set_tooltip_text (item, gtk_label_get_text (GTK_LABEL (label)));
+
if (connection == active)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
info = g_slice_new0 (GSMMenuItemInfo);
info->applet = applet;
info->device = g_object_ref (G_OBJECT (device));
info->connection = g_object_ref (connection);
@@ -250,16 +255,20 @@ gsm_add_menu_item (NMDevice *device,
g_free (text);
label = gtk_bin_get_child (GTK_BIN (item));
bold_text = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
gtk_label_get_text (GTK_LABEL (label)));
gtk_label_set_markup (GTK_LABEL (label), bold_text);
g_free (bold_text);
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), 30);
+ gtk_widget_set_tooltip_text (item, gtk_label_get_text (GTK_LABEL (label)));
+
gtk_widget_set_sensitive (item, FALSE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* Notify user of unmanaged or unavailable device */
item = nma_menu_device_check_unusable (device, NULL);
if (item) {
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
=== modified file 'src/applet-device-wifi.c'
--- a/src/applet-device-wifi.c 2009-02-17 21:54:50 +0000
+++ b/src/applet-device-wifi.c 2009-04-07 15:36:23 +0000
@@ -700,16 +700,20 @@ wireless_add_menu_item (NMDevice *device
g_free (text);
label = gtk_bin_get_child (GTK_BIN (item));
bold_text = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
gtk_label_get_text (GTK_LABEL (label)));
gtk_label_set_markup (GTK_LABEL (label), bold_text);
g_free (bold_text);
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), 30);
+ gtk_widget_set_tooltip_text (item, gtk_label_get_text (GTK_LABEL (label)));
+
gtk_widget_set_sensitive (item, FALSE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* Notify user of unmanaged or unavailable device */
wireless_enabled = nm_client_wireless_get_enabled (applet->nm_client);
item = nma_menu_device_check_unusable (device, wireless_enabled ? NULL : _("wireless is disabled"));
if (item) {
=== modified file 'src/applet-device-wired.c'
--- a/src/applet-device-wired.c 2009-02-05 19:02:55 +0000
+++ b/src/applet-device-wired.c 2009-04-07 15:38:58 +0000
@@ -113,23 +113,28 @@ add_connection_items (NMDevice *device,
NMApplet *applet)
{
GSList *iter;
WiredMenuItemInfo *info;
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item;
+ GtkWidget *item, *label;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
gtk_widget_set_sensitive (GTK_WIDGET (item), carrier);
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
+ label = gtk_bin_get_child (GTK_BIN (item));
+ gtk_label_set_ellipsize (GTK_LABEL (label), TRUE);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), 30);
+ gtk_widget_set_tooltip_text (item, gtk_label_get_text (GTK_LABEL (label)));
+
if (connection == active)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
info = g_slice_new0 (WiredMenuItemInfo);
info->applet = applet;
info->device = g_object_ref (G_OBJECT (device));
info->connection = g_object_ref (connection);
@@ -214,16 +219,20 @@ wired_add_menu_item (NMDevice *device,
carrier = nm_device_ethernet_get_carrier (NM_DEVICE_ETHERNET (device));
label = gtk_bin_get_child (GTK_BIN (item));
bold_text = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
gtk_label_get_text (GTK_LABEL (label)));
gtk_label_set_markup (GTK_LABEL (label), bold_text);
g_free (bold_text);
+ gtk_label_set_ellipsize (GTK_LABEL (label), TRUE);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), 30);
+ gtk_widget_set_tooltip_text (item, gtk_label_get_text (GTK_LABEL (label)));
+
gtk_widget_set_sensitive (item, FALSE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
/* Notify user of unmanaged or unavailable device */
item = nma_menu_device_check_unusable (device, carrier ? NULL : _("disconnected"));
if (item) {
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- Alexander
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]