[network-manager-applet] applet: fix status icon when a VPN has the default route



commit b82db07d652df24e9286d0328462f94183d406c1
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Thu Aug 10 17:00:16 2017 +0200

    applet: fix status icon when a VPN has the default route
    
    After commit 35736dd2dfe0 ("applet: use default active interface, even
    if it is of unsupported class") when a VPN with default route is
    active, applet_get_default_active_connection() returns the VPN
    connection, and no icon would be set because the tun device doesn't
    have a NMADeviceClass.
    
    Require a device class only when we need to determine the status icon,
    otherwise accept any connection.
    
    Fixes: 35736dd2dfe05534e5e45d9e3cdddf3cabec840c
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785775
    https://bugzilla.redhat.com/show_bug.cgi?id=1471510

 src/applet.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/applet.c b/src/applet.c
index 6b9eb4a..3f87165 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -225,7 +225,8 @@ applet_get_best_activating_connection (NMApplet *applet, NMDevice **device)
 }
 
 static NMActiveConnection *
-applet_get_default_active_connection (NMApplet *applet, NMDevice **device)
+applet_get_default_active_connection (NMApplet *applet, NMDevice **device,
+                                      gboolean only_known_devices)
 {
        NMActiveConnection *default_ac = NULL;
        NMDevice *non_default_device = NULL;
@@ -249,6 +250,10 @@ applet_get_default_active_connection (NMApplet *applet, NMDevice **device)
 
                candidate_dev = g_ptr_array_index (devices, 0);
 
+               if (   only_known_devices
+                   && !get_device_class (candidate_dev, applet))
+                       continue;
+
                /* We have to return default connection/device even if they are of an
                 * unknown class - otherwise we may end up returning non
                 * default interface which has nothing to do with our default
@@ -1038,7 +1043,7 @@ nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
                return;
        }
 
-       active = applet_get_default_active_connection (applet, &device);
+       active = applet_get_default_active_connection (applet, &device, FALSE);
        if (!active || !device) {
                g_warning ("%s: no active connection or device.", __func__);
                return;
@@ -2582,7 +2587,7 @@ applet_get_device_icon_for_state (NMApplet *applet,
                /* If there aren't any activating devices, then show the state of
                 * the default active connection instead.
                 */
-               active = applet_get_default_active_connection (applet, &device);
+               active = applet_get_default_active_connection (applet, &device, TRUE);
                if (!active || !device)
                        goto out;
        }


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