[network-manager-applet/dcbw/indicator: 1/2] applet: simplify NMNetworkMenuItem initialization



commit d558ea0c58c1adfd3d11d6c2a5bc960183347b13
Author: Dan Williams <dcbw redhat com>
Date:   Mon Feb 16 18:03:40 2015 -0600

    applet: simplify NMNetworkMenuItem initialization
    
    Collapse some of the setters into nm_network_menu_item_new() since
    these properties actually never change.  Add some ATK descriptions
    too.

 po/POTFILES.in           |    1 +
 src/ap-menu-item.c       |  334 +++++++++++++++++++++++++---------------------
 src/ap-menu-item.h       |   18 +--
 src/applet-device-wifi.c |   25 +---
 4 files changed, 197 insertions(+), 181 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f3c148e..95432b0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -5,6 +5,7 @@ nm-applet.desktop.in
 nm-connection-editor.desktop.in
 org.gnome.nm-applet.gschema.xml.in
 [type: gettext/glade]src/8021x.ui
+src/ap-menu-item.c
 src/applet.c
 src/applet-device-bond.c
 src/applet-device-bridge.c
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index ec0f181..2a30977 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -40,11 +40,12 @@ G_DEFINE_TYPE (NMNetworkMenuItem, nm_network_menu_item, GTK_TYPE_IMAGE_MENU_ITEM
 
 typedef struct {
        GtkWidget * ssid;
-       char      * ssid_string;
        GtkWidget * strength;
-       guint32     int_strength;
        GtkWidget * detail;
        GtkWidget * hbox;
+
+       char      * ssid_string;
+       guint32     int_strength;
        gchar *     hash;
        GSList *    dupes;
        gboolean    has_connections;
@@ -52,86 +53,7 @@ typedef struct {
        gboolean    is_encrypted;
 } NMNetworkMenuItemPrivate;
 
-static void
-nm_network_menu_item_init (NMNetworkMenuItem *item)
-{
-       NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
-
-       priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-       priv->ssid = gtk_label_new (NULL);
-       gtk_misc_set_alignment (GTK_MISC (priv->ssid), 0.0, 0.5);
-
-       priv->detail = gtk_image_new ();
-
-       gtk_container_add (GTK_CONTAINER (item), priv->hbox);
-       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->ssid, TRUE, TRUE, 0);
-       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->detail, FALSE, FALSE, 0);
-
-       priv->strength = gtk_image_new ();
-       gtk_box_pack_end (GTK_BOX (priv->hbox), priv->strength, FALSE, TRUE, 0);
-       gtk_widget_show (priv->strength);
-
-       gtk_widget_show (priv->ssid);
-       gtk_widget_show (priv->detail);
-       gtk_widget_show (priv->hbox);
-}
-
-GtkWidget*
-nm_network_menu_item_new (const char *hash, gboolean has_connections)
-{
-       NMNetworkMenuItem *item;
-
-       item = g_object_new (NM_TYPE_NETWORK_MENU_ITEM, NULL);
-       g_assert (item);
-       NM_NETWORK_MENU_ITEM_GET_PRIVATE (item)->has_connections = has_connections;
-       NM_NETWORK_MENU_ITEM_GET_PRIVATE (item)->hash = g_strdup (hash);
-       return GTK_WIDGET (item);
-}
-
-static void
-finalize (GObject *object)
-{
-       NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (object);
-
-       g_free (priv->hash);
-       g_free (priv->ssid_string);
-
-       g_slist_foreach (priv->dupes, (GFunc) g_free, NULL);
-       g_slist_free (priv->dupes);
-
-       G_OBJECT_CLASS (nm_network_menu_item_parent_class)->finalize (object);
-}
-
-static void
-nm_network_menu_item_class_init (NMNetworkMenuItemClass * klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-       g_type_class_add_private (klass, sizeof (NMNetworkMenuItemPrivate));
-
-       /* virtual methods */
-       object_class->finalize = finalize;
-}
-
-void
-nm_network_menu_item_set_ssid (NMNetworkMenuItem *item, GByteArray *ssid)
-{
-       NMNetworkMenuItemPrivate *priv;
-
-       g_return_if_fail (NM_IS_NETWORK_MENU_ITEM (item));
-       g_return_if_fail (ssid != NULL);
-
-       priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
-
-       g_free (priv->ssid_string);
-
-       priv->ssid_string = nm_utils_ssid_to_utf8 (ssid);
-       if (!priv->ssid_string) {
-               // FIXME: shouldn't happen; always coerce the SSID to _something_
-               priv->ssid_string = g_strdup ("<unknown>");
-       }
-       gtk_label_set_text (GTK_LABEL (priv->ssid), priv->ssid_string);
-}
+/******************************************************************/
 
 const char *
 nm_network_menu_item_get_ssid (NMNetworkMenuItem *item)
@@ -149,33 +71,42 @@ nm_network_menu_item_get_strength (NMNetworkMenuItem *item)
        return NM_NETWORK_MENU_ITEM_GET_PRIVATE (item)->int_strength;
 }
 
-void
-nm_network_menu_item_best_strength (NMNetworkMenuItem *item,
-                                    guint8 strength,
-                                    NMApplet *applet)
+static void
+update_atk_desc (NMNetworkMenuItem *item)
 {
-       NMNetworkMenuItemPrivate *priv;
-       GdkPixbuf *icon = NULL, *pixbuf, *top;
-
-       g_return_if_fail (NM_IS_NETWORK_MENU_ITEM (item));
-
-       priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
-
-       strength = MIN (strength, 100);
+       NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
+       GString *desc = NULL;
+
+       desc = g_string_new ("");
+       g_string_append_printf (desc, "%s: ", priv->ssid_string);
+
+       if (priv->is_adhoc)
+               g_string_append (desc, _("ad-hoc"));
+       else {
+               g_string_append_printf (desc, "%d%%", priv->int_strength);
+               if (priv->is_encrypted) {
+                       g_string_append (desc, ", ");
+                       g_string_append (desc, _("secure."));
+               }
+       }
 
-       /* Just do nothing if the new strength is less */
-       if (strength < priv->int_strength)
-               return;
+       atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (item)), desc->str);
+       g_string_free (desc, TRUE);
+}
 
-       priv->int_strength = strength;
+static void
+update_icon (NMNetworkMenuItem *item, NMApplet *applet)
+{
+       NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
+       GdkPixbuf *icon = NULL, *pixbuf, *top, *scaled;
 
-       if (strength > 80)
+       if (priv->int_strength > 80)
                icon = nma_icon_check_and_load ("nm-signal-100", applet);
-       else if (strength > 55)
+       else if (priv->int_strength > 55)
                icon = nma_icon_check_and_load ("nm-signal-75", applet);
-       else if (strength > 30)
+       else if (priv->int_strength > 30)
                icon = nma_icon_check_and_load ("nm-signal-50", applet);
-       else if (strength > 5)
+       else if (priv->int_strength > 5)
                icon = nma_icon_check_and_load ("nm-signal-25", applet);
        else
                icon = nma_icon_check_and_load ("nm-signal-00", applet);
@@ -193,8 +124,6 @@ nm_network_menu_item_best_strength (NMNetworkMenuItem *item,
 
        /* Scale to menu size if larger so the menu doesn't look awful */
        if (gdk_pixbuf_get_height (pixbuf) > 24 || gdk_pixbuf_get_width (pixbuf) > 24) {
-               GdkPixbuf *scaled;
-
                scaled = gdk_pixbuf_scale_simple (pixbuf, 24, 24, GDK_INTERP_BILINEAR);
                g_object_unref (pixbuf);
                pixbuf = scaled;
@@ -202,62 +131,42 @@ nm_network_menu_item_best_strength (NMNetworkMenuItem *item,
 
        gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength), pixbuf);
        g_object_unref (pixbuf);
-}
 
-const char *
-nm_network_menu_item_get_hash (NMNetworkMenuItem *item)
-{
-       g_return_val_if_fail (NM_IS_NETWORK_MENU_ITEM (item), NULL);
-
-       return NM_NETWORK_MENU_ITEM_GET_PRIVATE (item)->hash;
+       if (priv->is_adhoc && !gtk_image_get_pixbuf (GTK_IMAGE (priv->detail))) {
+               scaled = NULL;
+               pixbuf = nma_icon_check_and_load ("nm-adhoc", applet);
+               if (gdk_pixbuf_get_height (pixbuf) > 24 || gdk_pixbuf_get_width (pixbuf) > 24)
+                       scaled = gdk_pixbuf_scale_simple (pixbuf, 24, 24, GDK_INTERP_BILINEAR);
+               gtk_image_set_from_pixbuf (GTK_IMAGE (priv->detail), scaled ? scaled : pixbuf);
+               g_clear_object (&scaled);
+       }
 }
 
 void
-nm_network_menu_item_set_detail (NMNetworkMenuItem *item,
-                                 NMAccessPoint *ap,
-                                 GdkPixbuf *adhoc_icon,
-                                 guint32 dev_caps)
+nm_network_menu_item_set_strength (NMNetworkMenuItem *item,
+                                   guint8 strength,
+                                   NMApplet *applet)
 {
        NMNetworkMenuItemPrivate *priv;
-       gboolean is_adhoc = FALSE;
-       guint32 ap_flags, ap_wpa, ap_rsn;
 
        g_return_if_fail (NM_IS_NETWORK_MENU_ITEM (item));
 
        priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
 
-       ap_flags = nm_access_point_get_flags (ap);
-       ap_wpa = nm_access_point_get_wpa_flags (ap);
-       ap_rsn = nm_access_point_get_rsn_flags (ap);
-
-       if ((ap_flags & NM_802_11_AP_FLAGS_PRIVACY) || ap_wpa || ap_rsn)
-               priv->is_encrypted = TRUE;
-
-       if (nm_access_point_get_mode (ap) == NM_802_11_MODE_ADHOC) {
-               GdkPixbuf *scaled = NULL;
-
-               priv->is_adhoc = is_adhoc = TRUE;
-
-               if (gdk_pixbuf_get_height (adhoc_icon) > 24 || gdk_pixbuf_get_width (adhoc_icon) > 24)
-                       scaled = gdk_pixbuf_scale_simple (adhoc_icon, 24, 24, GDK_INTERP_BILINEAR);
-
-               gtk_image_set_from_pixbuf (GTK_IMAGE (priv->detail), scaled ? scaled : adhoc_icon);
+       strength = MIN (strength, 100);
+       if (strength > priv->int_strength) {
+               priv->int_strength = strength;
+               update_icon (item, applet);
+               update_atk_desc (item);
+       }
+}
 
-               g_clear_object (&scaled);
-       } else
-               gtk_image_set_from_stock (GTK_IMAGE (priv->detail), NULL, GTK_ICON_SIZE_MENU);
+const char *
+nm_network_menu_item_get_hash (NMNetworkMenuItem *item)
+{
+       g_return_val_if_fail (NM_IS_NETWORK_MENU_ITEM (item), NULL);
 
-       /* Don't enable the menu item the device can't even connect to the AP */
-       if (   !nm_utils_security_valid (NMU_SEC_NONE, dev_caps, TRUE, is_adhoc, ap_flags, ap_wpa, ap_rsn)
-        && !nm_utils_security_valid (NMU_SEC_STATIC_WEP, dev_caps, TRUE, is_adhoc, ap_flags, ap_wpa, ap_rsn)
-           && !nm_utils_security_valid (NMU_SEC_LEAP, dev_caps, TRUE, is_adhoc, ap_flags, ap_wpa, ap_rsn)
-           && !nm_utils_security_valid (NMU_SEC_DYNAMIC_WEP, dev_caps, TRUE, is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
-           && !nm_utils_security_valid (NMU_SEC_WPA_PSK, dev_caps, TRUE, is_adhoc, ap_flags, ap_wpa, ap_rsn)
-           && !nm_utils_security_valid (NMU_SEC_WPA2_PSK, dev_caps, TRUE, is_adhoc, ap_flags, ap_wpa, ap_rsn)
-           && !nm_utils_security_valid (NMU_SEC_WPA_ENTERPRISE, dev_caps, TRUE, is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
-           && !nm_utils_security_valid (NMU_SEC_WPA2_ENTERPRISE, dev_caps, TRUE, is_adhoc, ap_flags, ap_wpa, 
ap_rsn)) {
-               gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
-       }
+       return NM_NETWORK_MENU_ITEM_GET_PRIVATE (item)->hash;
 }
 
 gboolean
@@ -280,23 +189,32 @@ nm_network_menu_item_find_dupe (NMNetworkMenuItem *item, NMAccessPoint *ap)
        return FALSE;
 }
 
+static void
+set_label (NMNetworkMenuItem *item, const char *label, gboolean use_markup)
+{
+       NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
+
+       gtk_label_set_use_markup (GTK_LABEL (priv->ssid), use_markup);
+       if (use_markup)
+               gtk_label_set_markup (GTK_LABEL (priv->ssid), label);
+       else
+               gtk_label_set_text (GTK_LABEL (priv->ssid), label);
+}
+
 void
 nm_network_menu_item_set_active (NMNetworkMenuItem *item, gboolean active)
 {
        NMNetworkMenuItemPrivate *priv;
-       char *markup;
+       char *markup = NULL;
 
        g_return_if_fail (NM_IS_NETWORK_MENU_ITEM (item));
 
        priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
 
-       gtk_label_set_use_markup (GTK_LABEL (priv->ssid), active);
-       if (active) {
+       if (active)
                markup = g_markup_printf_escaped ("<b>%s</b>", priv->ssid_string);
-               gtk_label_set_markup (GTK_LABEL (priv->ssid), markup);
-               g_free (markup);
-       } else
-               gtk_label_set_text (GTK_LABEL (priv->ssid), priv->ssid_string);
+       set_label (item, markup ? markup : priv->ssid_string, !!markup);
+       g_free (markup);
 }
 
 void
@@ -337,3 +255,111 @@ nm_network_menu_item_get_is_encrypted (NMNetworkMenuItem *item)
        return NM_NETWORK_MENU_ITEM_GET_PRIVATE (item)->is_encrypted;
 }
 
+/******************************************************************/
+
+GtkWidget *
+nm_network_menu_item_new (NMAccessPoint *ap,
+                          guint32 dev_caps,
+                          const char *hash,
+                          gboolean has_connections,
+                          NMApplet *applet)
+{
+       NMNetworkMenuItem *item;
+       NMNetworkMenuItemPrivate *priv;
+       guint32 ap_flags, ap_wpa, ap_rsn;
+       const GByteArray *ssid;
+
+       item = g_object_new (NM_TYPE_NETWORK_MENU_ITEM, NULL);
+       g_assert (item);
+
+       priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
+
+       nm_network_menu_item_add_dupe (item, ap);
+
+       ssid = nm_access_point_get_ssid (ap);
+       if (ssid)
+               priv->ssid_string = nm_utils_ssid_to_utf8 (ssid);
+       if (!priv->ssid_string)
+               priv->ssid_string = g_strdup ("<unknown>");
+
+       priv->has_connections = has_connections;
+       priv->hash = g_strdup (hash);
+       priv->int_strength = nm_access_point_get_strength (ap);
+
+       if (nm_access_point_get_mode (ap) == NM_802_11_MODE_ADHOC)
+               priv->is_adhoc = TRUE;
+
+       ap_flags = nm_access_point_get_flags (ap);
+       ap_wpa = nm_access_point_get_wpa_flags (ap);
+       ap_rsn = nm_access_point_get_rsn_flags (ap);
+       if ((ap_flags & NM_802_11_AP_FLAGS_PRIVACY) || ap_wpa || ap_rsn)
+               priv->is_encrypted = TRUE;
+
+       /* Don't enable the menu item the device can't even connect to the AP */
+       if (   !nm_utils_security_valid (NMU_SEC_NONE, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
+        && !nm_utils_security_valid (NMU_SEC_STATIC_WEP, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
+           && !nm_utils_security_valid (NMU_SEC_LEAP, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
+           && !nm_utils_security_valid (NMU_SEC_DYNAMIC_WEP, dev_caps, TRUE, priv->is_adhoc, ap_flags, 
ap_wpa, ap_rsn)
+           && !nm_utils_security_valid (NMU_SEC_WPA_PSK, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
+           && !nm_utils_security_valid (NMU_SEC_WPA2_PSK, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
+           && !nm_utils_security_valid (NMU_SEC_WPA_ENTERPRISE, dev_caps, TRUE, priv->is_adhoc, ap_flags, 
ap_wpa, ap_rsn)
+           && !nm_utils_security_valid (NMU_SEC_WPA2_ENTERPRISE, dev_caps, TRUE, priv->is_adhoc, ap_flags, 
ap_wpa, ap_rsn)) {
+               gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
+       }
+
+       set_label (item, priv->ssid_string, FALSE);
+       update_icon (item, applet);
+       update_atk_desc (item);
+
+       return GTK_WIDGET (item);
+}
+
+static void
+nm_network_menu_item_init (NMNetworkMenuItem *item)
+{
+       NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
+
+       priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+       priv->ssid = gtk_label_new (NULL);
+       gtk_misc_set_alignment (GTK_MISC (priv->ssid), 0.0, 0.5);
+
+       priv->detail = gtk_image_new ();
+
+       gtk_container_add (GTK_CONTAINER (item), priv->hbox);
+       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->ssid, TRUE, TRUE, 0);
+       gtk_box_pack_start (GTK_BOX (priv->hbox), priv->detail, FALSE, FALSE, 0);
+
+       priv->strength = gtk_image_new ();
+       gtk_box_pack_end (GTK_BOX (priv->hbox), priv->strength, FALSE, TRUE, 0);
+       gtk_widget_show (priv->strength);
+
+       gtk_widget_show (priv->ssid);
+       gtk_widget_show (priv->detail);
+       gtk_widget_show (priv->hbox);
+}
+
+static void
+finalize (GObject *object)
+{
+       NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (object);
+
+       g_free (priv->hash);
+       g_free (priv->ssid_string);
+
+       g_slist_foreach (priv->dupes, (GFunc) g_free, NULL);
+       g_slist_free (priv->dupes);
+
+       G_OBJECT_CLASS (nm_network_menu_item_parent_class)->finalize (object);
+}
+
+static void
+nm_network_menu_item_class_init (NMNetworkMenuItemClass * klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (klass, sizeof (NMNetworkMenuItemPrivate));
+
+       /* virtual methods */
+       object_class->finalize = finalize;
+}
+
diff --git a/src/ap-menu-item.h b/src/ap-menu-item.h
index a8871d1..c538c36 100644
--- a/src/ap-menu-item.h
+++ b/src/ap-menu-item.h
@@ -49,24 +49,22 @@ struct _NMNetworkMenuItemClass {
 
 
 GType     nm_network_menu_item_get_type (void) G_GNUC_CONST;
-GtkWidget* nm_network_menu_item_new (const char *hash, gboolean has_connections);
+GtkWidget* nm_network_menu_item_new (NMAccessPoint *ap,
+                                     guint32 dev_caps,
+                                     const char *hash,
+                                     gboolean has_connections,
+                                     NMApplet *applet);
 
-void       nm_network_menu_item_set_ssid (NMNetworkMenuItem *item,
-                                          GByteArray *ssid);
 const char *nm_network_menu_item_get_ssid (NMNetworkMenuItem *item);
 
 gboolean   nm_network_menu_item_get_is_adhoc (NMNetworkMenuItem *item);
 gboolean   nm_network_menu_item_get_is_encrypted (NMNetworkMenuItem *item);
 
 guint32    nm_network_menu_item_get_strength (NMNetworkMenuItem *item);
-void       nm_network_menu_item_best_strength (NMNetworkMenuItem *item,
-                                               guint8 strength,
-                                               NMApplet *applet);
+void       nm_network_menu_item_set_strength (NMNetworkMenuItem *item,
+                                              guint8 strength,
+                                              NMApplet *applet);
 const char *nm_network_menu_item_get_hash (NMNetworkMenuItem * item);
-void       nm_network_menu_item_set_detail (NMNetworkMenuItem * item,
-                                            NMAccessPoint * ap,
-                                            GdkPixbuf * adhoc_icon,
-                                            guint32 dev_caps);
 
 gboolean   nm_network_menu_item_find_dupe (NMNetworkMenuItem *item,
                                            NMAccessPoint *ap);
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index d5a937a..2bcd42b 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -534,29 +534,20 @@ create_new_ap_item (NMDeviceWifi *device,
 {
        WifiMenuItemInfo *info;
        GSList *iter;
-       NMNetworkMenuItem *item = NULL;
+       GtkWidget *item;
        GSList *dev_connections = NULL;
        GSList *ap_connections = NULL;
-       const GByteArray *ssid;
-       guint32 dev_caps;
 
        dev_connections = nm_device_filter_connections (NM_DEVICE (device), connections);
        ap_connections = nm_access_point_filter_connections (ap, dev_connections);
        g_slist_free (dev_connections);
        dev_connections = NULL;
 
-       item = NM_NETWORK_MENU_ITEM (nm_network_menu_item_new (dup_data->hash,
-                                                              !!g_slist_length (ap_connections)));
-
-       ssid = nm_access_point_get_ssid (ap);
-       nm_network_menu_item_set_ssid (item, (GByteArray *) ssid);
-
-       dev_caps = nm_device_wifi_get_capabilities (device);
-       gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
-       nm_network_menu_item_set_detail (item, ap, nma_icon_check_and_load ("nm-adhoc", applet), dev_caps);
-       nm_network_menu_item_best_strength (item, nm_access_point_get_strength (ap), applet);
-       nm_network_menu_item_add_dupe (item, ap);
-
+       item = nm_network_menu_item_new (ap,
+                                        nm_device_wifi_get_capabilities (device),
+                                        dup_data->hash,
+                                        !!g_slist_length (ap_connections),
+                                        applet);
        g_object_set_data (G_OBJECT (item), "device", NM_DEVICE (device));
 
        /* If there's only one connection, don't show the submenu */
@@ -610,7 +601,7 @@ create_new_ap_item (NMDeviceWifi *device,
        }
 
        g_slist_free (ap_connections);
-       return item;
+       return NM_NETWORK_MENU_ITEM (item);
 }
 
 static NMNetworkMenuItem *
@@ -643,7 +634,7 @@ get_menu_item_for_ap (NMDeviceWifi *device,
        g_slist_foreach (menu_list, find_duplicate, &dup_data);
 
        if (dup_data.found) {
-               nm_network_menu_item_best_strength (dup_data.found, nm_access_point_get_strength (ap), 
applet);
+               nm_network_menu_item_set_strength (dup_data.found, nm_access_point_get_strength (ap), applet);
                nm_network_menu_item_add_dupe (dup_data.found, ap);
                return NULL;
        }


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