[network-manager-applet/bg/bgo776384: 2/3] applet: re-add broadband devices when MM becomes available



commit c488835354e00c1e84f9d1b243ef70011d0d9875
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Thu Dec 29 23:58:39 2016 +0100

    applet: re-add broadband devices when MM becomes available
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776384

 src/applet-device-broadband.c |    2 +-
 src/applet-device-broadband.h |    2 ++
 src/applet.c                  |   22 ++++++++++++++++++++++
 3 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/src/applet-device-broadband.c b/src/applet-device-broadband.c
index 6e7952c..bffc893 100644
--- a/src/applet-device-broadband.c
+++ b/src/applet-device-broadband.c
@@ -1057,7 +1057,7 @@ device_added (NMDevice *device,
 
        /* Store device info */
        g_object_set_data_full (G_OBJECT (modem),
-                               "devinfo",
+                               APPLET_DEVICE_BROADBAND_INFO,
                                info,
                                (GDestroyNotify)broadband_device_info_free);
 }
diff --git a/src/applet-device-broadband.h b/src/applet-device-broadband.h
index 1d3f2da..9a1efd6 100644
--- a/src/applet-device-broadband.h
+++ b/src/applet-device-broadband.h
@@ -28,4 +28,6 @@ NMADeviceClass *applet_device_broadband_get_class (NMApplet *applet);
 void applet_broadband_connect_network (NMApplet *applet,
                                        NMDevice *device);
 
+#define APPLET_DEVICE_BROADBAND_INFO "devinfo"
+
 #endif /* __APPLET_DEVICE_BROADBAND_H__ */
diff --git a/src/applet.c b/src/applet.c
index 5b013d1..992b4cb 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -2372,6 +2372,28 @@ mm1_name_owner_changed_cb (GDBusObjectManagerClient *mm1,
        name_owner = g_dbus_object_manager_client_get_name_owner (mm1);
        applet->mm1_running = !!name_owner;
        g_free (name_owner);
+
+       if (applet->mm1_running) {
+               const GPtrArray *devices;
+               gboolean changed = FALSE;
+               int i;
+
+               devices = nm_client_get_devices (applet->nm_client);
+               for (i = 0; devices && (i < devices->len); i++) {
+                       NMDevice *device = NM_DEVICE (g_ptr_array_index (devices, i));
+
+                       if (   NM_IS_DEVICE_MODEM (device)
+                           && !g_object_get_data ((GObject *) device, APPLET_DEVICE_BROADBAND_INFO)) {
+                               foo_device_added_cb (applet->nm_client, device, applet);
+                               changed = TRUE;
+                       }
+               }
+
+               if (changed) {
+                       foo_active_connections_changed_cb (applet->nm_client, NULL, applet);
+                       applet_schedule_update_icon (applet);
+               }
+       }
 }
 
 static void


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