[network-manager-applet/danw/virtual-devs: 2/5] applet: remove duplicated "you are now connected..." code



commit 4322e015d8da797eb831fc0077d610159b0b5d43
Author: Dan Winship <danw gnome org>
Date:   Fri May 17 07:48:22 2013 -0400

    applet: remove duplicated "you are now connected..." code
    
    Most devices types were doing exactly the same thing in their
    device_state_changed() method. Move the shared code into applet.c and
    add a new notify_connected() method for the non-shared bit. (And make
    device_state_changed() optional to implement.)

 src/applet-device-bond.c      |   36 +++++++++---------------------------
 src/applet-device-bridge.c    |   36 +++++++++---------------------------
 src/applet-device-broadband.c |   30 +++++-------------------------
 src/applet-device-bt.c        |   36 +++++++++---------------------------
 src/applet-device-cdma.c      |   36 +++++++++++++-----------------------
 src/applet-device-ethernet.c  |   36 +++++++++---------------------------
 src/applet-device-gsm.c       |   36 +++++++++++++-----------------------
 src/applet-device-vlan.c      |   36 +++++++++---------------------------
 src/applet-device-wifi.c      |   28 +++++++++++++++++-----------
 src/applet-device-wimax.c     |   37 +++++++++----------------------------
 src/applet.c                  |   22 +++++++++++++++++++++-
 src/applet.h                  |    3 +++
 12 files changed, 126 insertions(+), 246 deletions(-)
---
diff --git a/src/applet-device-bond.c b/src/applet-device-bond.c
index 5da6afb..210e46a 100644
--- a/src/applet-device-bond.c
+++ b/src/applet-device-bond.c
@@ -186,33 +186,15 @@ bond_add_menu_item (NMDevice *device,
 }
 
 static void
-bond_device_state_changed (NMDevice *device,
-                           NMDeviceState new_state,
-                           NMDeviceState old_state,
-                           NMDeviceStateReason reason,
-                           NMApplet *applet)
+bond_notify_connected (NMDevice *device,
+                       const char *msg,
+                       NMApplet *applet)
 {
-       if (new_state == NM_DEVICE_STATE_ACTIVATED) {
-               NMConnection *connection;
-               NMSettingConnection *s_con = NULL;
-               char *str = NULL;
-
-               connection = applet_find_active_connection_for_device (device, applet, NULL);
-               if (connection) {
-                       const char *id;
-                       s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, 
NM_TYPE_SETTING_CONNECTION));
-                       id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
-                       if (id)
-                               str = g_strdup_printf (_("You are now connected to '%s'."), id);
-               }
-
-               applet_do_notify_with_pref (applet,
-                                           _("Connection Established"),
-                                           str ? str : _("You are now connected to the VLAN."),
-                                           "nm-device-wired",
-                                           PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-               g_free (str);
-       }
+       applet_do_notify_with_pref (applet,
+                                   _("Connection Established"),
+                                   msg ? msg : _("You are now connected to the bonded network."),
+                                   "nm-device-wired",
+                                   PREF_DISABLE_CONNECTED_NOTIFICATIONS);
 }
 
 static GdkPixbuf *
@@ -285,7 +267,7 @@ applet_device_bond_get_class (NMApplet *applet)
 
        dclass->new_auto_connection = bond_new_auto_connection;
        dclass->add_menu_item = bond_add_menu_item;
-       dclass->device_state_changed = bond_device_state_changed;
+       dclass->notify_connected = bond_notify_connected;
        dclass->get_icon = bond_get_icon;
        dclass->get_secrets = bond_get_secrets;
 
diff --git a/src/applet-device-bridge.c b/src/applet-device-bridge.c
index e6633d9..656a4f2 100644
--- a/src/applet-device-bridge.c
+++ b/src/applet-device-bridge.c
@@ -186,33 +186,15 @@ bridge_add_menu_item (NMDevice *device,
 }
 
 static void
-bridge_device_state_changed (NMDevice *device,
-                             NMDeviceState new_state,
-                             NMDeviceState old_state,
-                             NMDeviceStateReason reason,
-                             NMApplet *applet)
+bridge_notify_connected (NMDevice *device,
+                         const char *msg,
+                         NMApplet *applet)
 {
-       if (new_state == NM_DEVICE_STATE_ACTIVATED) {
-               NMConnection *connection;
-               NMSettingConnection *s_con = NULL;
-               char *str = NULL;
-
-               connection = applet_find_active_connection_for_device (device, applet, NULL);
-               if (connection) {
-                       const char *id;
-                       s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, 
NM_TYPE_SETTING_CONNECTION));
-                       id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
-                       if (id)
-                               str = g_strdup_printf (_("You are now connected to '%s'."), id);
-               }
-
-               applet_do_notify_with_pref (applet,
-                                           _("Connection Established"),
-                                           str ? str : _("You are now connected to the VLAN."),
-                                           "nm-device-wired",
-                                           PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-               g_free (str);
-       }
+       applet_do_notify_with_pref (applet,
+                                   _("Connection Established"),
+                                   msg ? msg : _("You are now connected to the bridged network."),
+                                   "nm-device-wired",
+                                   PREF_DISABLE_CONNECTED_NOTIFICATIONS);
 }
 
 static GdkPixbuf *
@@ -284,7 +266,7 @@ applet_device_bridge_get_class (NMApplet *applet)
 
        dclass->new_auto_connection = bridge_new_auto_connection;
        dclass->add_menu_item = bridge_add_menu_item;
-       dclass->device_state_changed = bridge_device_state_changed;
+       dclass->notify_connected = bridge_notify_connected;
        dclass->get_icon = bridge_get_icon;
        dclass->get_secrets = bridge_get_secrets;
 
diff --git a/src/applet-device-broadband.c b/src/applet-device-broadband.c
index e021278..be5c8e0 100644
--- a/src/applet-device-broadband.c
+++ b/src/applet-device-broadband.c
@@ -793,35 +793,15 @@ add_menu_item (NMDevice *device,
 /********************************************************************/
 
 static void
-device_state_changed (NMDevice *device,
-                      NMDeviceState new_state,
-                      NMDeviceState old_state,
-                      NMDeviceStateReason reason,
-                      NMApplet *applet)
+notify_connected (NMDevice *device,
+                  const char *msg,
+                  NMApplet *applet)
 {
-       NMConnection *connection;
-       NMSettingConnection *s_con = NULL;
-       char *str = NULL;
-
-       if (new_state != NM_DEVICE_STATE_ACTIVATED)
-               return;
-
-       connection = applet_find_active_connection_for_device (device, applet, NULL);
-       if (connection) {
-               const char *id;
-
-               s_con = nm_connection_get_setting_connection (connection);
-               id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
-               if (id)
-                       str = g_strdup_printf (_("You are now connected to '%s'."), id);
-       }
-
        applet_do_notify_with_pref (applet,
                                    _("Connection Established"),
-                                   str ? str : _("You are now connected to the Mobile Broadband network."),
+                                   msg ? msg : _("You are now connected to the Mobile Broadband network."),
                                    "nm-device-wwan",
                                    PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-       g_free (str);
 }
 
 /********************************************************************/
@@ -1075,7 +1055,7 @@ applet_device_broadband_get_class (NMApplet *applet)
        dclass->new_auto_connection = new_auto_connection;
        dclass->add_menu_item = add_menu_item;
        dclass->device_added = device_added;
-       dclass->device_state_changed = device_state_changed;
+       dclass->notify_connected = notify_connected;
        dclass->get_icon = get_icon;
        dclass->get_secrets = get_secrets;
        dclass->secrets_request_size = sizeof (MobileHelperSecretsInfo);
diff --git a/src/applet-device-bt.c b/src/applet-device-bt.c
index 5a17846..811a637 100644
--- a/src/applet-device-bt.c
+++ b/src/applet-device-bt.c
@@ -175,33 +175,15 @@ bt_add_menu_item (NMDevice *device,
 }
 
 static void
-bt_device_state_changed (NMDevice *device,
-                         NMDeviceState new_state,
-                         NMDeviceState old_state,
-                         NMDeviceStateReason reason,
-                         NMApplet *applet)
+bt_notify_connected (NMDevice *device,
+                     const char *msg,
+                     NMApplet *applet)
 {
-       if (new_state == NM_DEVICE_STATE_ACTIVATED) {
-               NMConnection *connection;
-               NMSettingConnection *s_con = NULL;
-               char *str = NULL;
-
-               connection = applet_find_active_connection_for_device (device, applet, NULL);
-               if (connection) {
-                       const char *id;
-                       s_con = nm_connection_get_setting_connection (connection);
-                       id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
-                       if (id)
-                               str = g_strdup_printf (_("You are now connected to '%s'."), id);
-               }
-
-               applet_do_notify_with_pref (applet,
-                                           _("Connection Established"),
-                                           str ? str : _("You are now connected to the mobile broadband 
network."),
-                                           "nm-device-wwan",
-                                           PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-               g_free (str);
-       }
+       applet_do_notify_with_pref (applet,
+                                   _("Connection Established"),
+                                   msg ? msg : _("You are now connected to the mobile broadband network."),
+                                   "nm-device-wwan",
+                                   PREF_DISABLE_CONNECTED_NOTIFICATIONS);
 }
 
 static GdkPixbuf *
@@ -370,7 +352,7 @@ applet_device_bt_get_class (NMApplet *applet)
 
        dclass->new_auto_connection = bt_new_auto_connection;
        dclass->add_menu_item = bt_add_menu_item;
-       dclass->device_state_changed = bt_device_state_changed;
+       dclass->notify_connected = bt_notify_connected;
        dclass->get_icon = bt_get_icon;
        dclass->get_secrets = bt_get_secrets;
        dclass->secrets_request_size = sizeof (NMBtSecretsInfo);
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index f45ad33..bee9a5e 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -331,34 +331,23 @@ cdma_device_state_changed (NMDevice *device,
 {
        CdmaDeviceInfo *info;
 
-       if (new_state == NM_DEVICE_STATE_ACTIVATED) {
-               NMConnection *connection;
-               NMSettingConnection *s_con = NULL;
-               char *str = NULL;
-
-               connection = applet_find_active_connection_for_device (device, applet, NULL);
-               if (connection) {
-                       const char *id;
-
-                       s_con = nm_connection_get_setting_connection (connection);
-                       id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
-                       if (id)
-                               str = g_strdup_printf (_("You are now connected to '%s'."), id);
-               }
-
-               applet_do_notify_with_pref (applet,
-                                           _("Connection Established"),
-                                           str ? str : _("You are now connected to the CDMA network."),
-                                           "nm-device-wwan",
-                                           PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-               g_free (str);
-       }
-
        /* Start/stop polling of quality and registration when device state changes */
        info = g_object_get_data (G_OBJECT (device), "devinfo");
        check_start_polling (info);
 }
 
+static void
+cdma_notify_connected (NMDevice *device,
+                       const char *msg,
+                       NMApplet *applet)
+{
+       applet_do_notify_with_pref (applet,
+                                   _("Connection Established"),
+                                   msg ? msg : _("You are now connected to the CDMA network."),
+                                   "nm-device-wwan",
+                                   PREF_DISABLE_CONNECTED_NOTIFICATIONS);
+}
+
 static GdkPixbuf *
 cdma_get_icon (NMDevice *device,
                NMDeviceState state,
@@ -748,6 +737,7 @@ applet_device_cdma_get_class (NMApplet *applet)
        dclass->new_auto_connection = cdma_new_auto_connection;
        dclass->add_menu_item = cdma_add_menu_item;
        dclass->device_state_changed = cdma_device_state_changed;
+       dclass->notify_connected = cdma_notify_connected;
        dclass->get_icon = cdma_get_icon;
        dclass->get_secrets = cdma_get_secrets;
        dclass->secrets_request_size = sizeof (MobileHelperSecretsInfo);
diff --git a/src/applet-device-ethernet.c b/src/applet-device-ethernet.c
index 6e63dcb..fecad17 100644
--- a/src/applet-device-ethernet.c
+++ b/src/applet-device-ethernet.c
@@ -246,33 +246,15 @@ ethernet_add_menu_item (NMDevice *device,
 }
 
 static void
-ethernet_device_state_changed (NMDevice *device,
-                               NMDeviceState new_state,
-                               NMDeviceState old_state,
-                               NMDeviceStateReason reason,
-                               NMApplet *applet)
+ethernet_notify_connected (NMDevice *device,
+                           const char *msg,
+                           NMApplet *applet)
 {
-       if (new_state == NM_DEVICE_STATE_ACTIVATED) {
-               NMConnection *connection;
-               NMSettingConnection *s_con = NULL;
-               char *str = NULL;
-
-               connection = applet_find_active_connection_for_device (device, applet, NULL);
-               if (connection) {
-                       const char *id;
-                       s_con = nm_connection_get_setting_connection (connection);
-                       id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
-                       if (id)
-                               str = g_strdup_printf (_("You are now connected to '%s'."), id);
-               }
-
-               applet_do_notify_with_pref (applet,
-                                           _("Connection Established"),
-                                           str ? str : _("You are now connected to the ethernet network."),
-                                           "nm-device-wired",
-                                           PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-               g_free (str);
-       }
+       applet_do_notify_with_pref (applet,
+                                   _("Connection Established"),
+                                   msg ? msg : _("You are now connected to the ethernet network."),
+                                   "nm-device-wired",
+                                   PREF_DISABLE_CONNECTED_NOTIFICATIONS);
 }
 
 static GdkPixbuf *
@@ -646,7 +628,7 @@ applet_device_ethernet_get_class (NMApplet *applet)
 
        dclass->new_auto_connection = ethernet_new_auto_connection;
        dclass->add_menu_item = ethernet_add_menu_item;
-       dclass->device_state_changed = ethernet_device_state_changed;
+       dclass->notify_connected = ethernet_notify_connected;
        dclass->get_icon = ethernet_get_icon;
        dclass->get_secrets = ethernet_get_secrets;
        dclass->secrets_request_size = MAX (sizeof (NM8021xInfo), sizeof (NMPppoeInfo));
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index a647fca..ebc7e5f 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -387,34 +387,23 @@ gsm_device_state_changed (NMDevice *device,
 {
        GsmDeviceInfo *info;
 
-       if (new_state == NM_DEVICE_STATE_ACTIVATED) {
-               NMConnection *connection;
-               NMSettingConnection *s_con = NULL;
-               char *str = NULL;
-
-               connection = applet_find_active_connection_for_device (device, applet, NULL);
-               if (connection) {
-                       const char *id;
-
-                       s_con = nm_connection_get_setting_connection (connection);
-                       id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
-                       if (id)
-                               str = g_strdup_printf (_("You are now connected to '%s'."), id);
-               }
-
-               applet_do_notify_with_pref (applet,
-                                           _("Connection Established"),
-                                           str ? str : _("You are now connected to the GSM network."),
-                                           "nm-device-wwan",
-                                           PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-               g_free (str);
-       }
-
        /* Start/stop polling of quality and registration when device state changes */
        info = g_object_get_data (G_OBJECT (device), "devinfo");
        check_start_polling (info);
 }
 
+static void
+gsm_notify_connected (NMDevice *device,
+                      const char *msg,
+                      NMApplet *applet)
+{
+       applet_do_notify_with_pref (applet,
+                                   _("Connection Established"),
+                                   msg ? msg : _("You are now connected to the GSM network."),
+                                   "nm-device-wwan",
+                                   PREF_DISABLE_CONNECTED_NOTIFICATIONS);
+}
+
 static GdkPixbuf *
 gsm_get_icon (NMDevice *device,
               NMDeviceState state,
@@ -1224,6 +1213,7 @@ applet_device_gsm_get_class (NMApplet *applet)
        dclass->new_auto_connection = gsm_new_auto_connection;
        dclass->add_menu_item = gsm_add_menu_item;
        dclass->device_state_changed = gsm_device_state_changed;
+       dclass->notify_connected = gsm_notify_connected;
        dclass->get_icon = gsm_get_icon;
        dclass->get_secrets = gsm_get_secrets;
        dclass->secrets_request_size = sizeof (MobileHelperSecretsInfo);
diff --git a/src/applet-device-vlan.c b/src/applet-device-vlan.c
index 8c7325a..a01358d 100644
--- a/src/applet-device-vlan.c
+++ b/src/applet-device-vlan.c
@@ -210,33 +210,15 @@ vlan_add_menu_item (NMDevice *device,
 }
 
 static void
-vlan_device_state_changed (NMDevice *device,
-                           NMDeviceState new_state,
-                           NMDeviceState old_state,
-                           NMDeviceStateReason reason,
-                           NMApplet *applet)
+vlan_notify_connected (NMDevice *device,
+                       const char *msg,
+                       NMApplet *applet)
 {
-       if (new_state == NM_DEVICE_STATE_ACTIVATED) {
-               NMConnection *connection;
-               NMSettingConnection *s_con = NULL;
-               char *str = NULL;
-
-               connection = applet_find_active_connection_for_device (device, applet, NULL);
-               if (connection) {
-                       const char *id;
-                       s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, 
NM_TYPE_SETTING_CONNECTION));
-                       id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
-                       if (id)
-                               str = g_strdup_printf (_("You are now connected to '%s'."), id);
-               }
-
-               applet_do_notify_with_pref (applet,
-                                           _("Connection Established"),
-                                           str ? str : _("You are now connected to the VLAN."),
-                                           "nm-device-wired",
-                                           PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-               g_free (str);
-       }
+       applet_do_notify_with_pref (applet,
+                                   _("Connection Established"),
+                                   msg ? msg : _("You are now connected to the VLAN."),
+                                   "nm-device-wired",
+                                   PREF_DISABLE_CONNECTED_NOTIFICATIONS);
 }
 
 static GdkPixbuf *
@@ -308,7 +290,7 @@ applet_device_vlan_get_class (NMApplet *applet)
 
        dclass->new_auto_connection = vlan_new_auto_connection;
        dclass->add_menu_item = vlan_add_menu_item;
-       dclass->device_state_changed = vlan_device_state_changed;
+       dclass->notify_connected = vlan_notify_connected;
        dclass->get_icon = vlan_get_icon;
        dclass->get_secrets = vlan_get_secrets;
 
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index fa3d618..9710c6c 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -1244,24 +1244,29 @@ wifi_device_state_changed (NMDevice *device,
                            NMDeviceStateReason reason,
                            NMApplet *applet)
 {
-       NMAccessPoint *new = NULL;
-       char *msg;
-       char *esc_ssid = NULL;
-
-       new = update_active_ap (device, new_state, applet);
+       update_active_ap (device, new_state, applet);
 
        if (new_state == NM_DEVICE_STATE_DISCONNECTED)
                queue_avail_access_point_notification (device);
+}
 
-       if (new_state != NM_DEVICE_STATE_ACTIVATED)
-               return;
+static void
+wifi_notify_connected (NMDevice *device,
+                       const char *msg,
+                       NMApplet *applet)
+{
+       NMAccessPoint *ap;
+       char *esc_ssid;
+       char *ssid_msg;
+
+       ap = g_object_get_data (G_OBJECT (device), ACTIVE_AP_TAG);
 
-       esc_ssid = get_ssid_utf8 (new);
-       msg = g_strdup_printf (_("You are now connected to the Wi-Fi network '%s'."), esc_ssid);
+       esc_ssid = get_ssid_utf8 (ap);
+       ssid_msg = g_strdup_printf (_("You are now connected to the Wi-Fi network '%s'."), esc_ssid);
        applet_do_notify_with_pref (applet, _("Connection Established"),
-                                   msg, "nm-device-wireless",
+                                   ssid_msg, "nm-device-wireless",
                                    PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-       g_free (msg);
+       g_free (ssid_msg);
        g_free (esc_ssid);
 }
 
@@ -1697,6 +1702,7 @@ applet_device_wifi_get_class (NMApplet *applet)
        dclass->add_menu_item = wifi_add_menu_item;
        dclass->device_added = wifi_device_added;
        dclass->device_state_changed = wifi_device_state_changed;
+       dclass->notify_connected = wifi_notify_connected;
        dclass->get_icon = wifi_get_icon;
        dclass->get_secrets = wifi_get_secrets;
        dclass->secrets_request_size = sizeof (NMWifiInfo);
diff --git a/src/applet-device-wimax.c b/src/applet-device-wimax.c
index a870c48..df6cca9 100644
--- a/src/applet-device-wimax.c
+++ b/src/applet-device-wimax.c
@@ -398,34 +398,15 @@ wimax_device_added (NMDevice *device, NMApplet *applet)
 }
 
 static void
-wimax_device_state_changed (NMDevice *device,
-                            NMDeviceState new_state,
-                            NMDeviceState old_state,
-                            NMDeviceStateReason reason,
-                            NMApplet *applet)
+wimax_notify_connected (NMDevice *device,
+                        const char *msg,
+                        NMApplet *applet)
 {
-       if (new_state == NM_DEVICE_STATE_ACTIVATED) {
-               NMConnection *connection;
-               NMSettingConnection *s_con = NULL;
-               char *str = NULL;
-
-               connection = applet_find_active_connection_for_device (device, applet, NULL);
-               if (connection) {
-                       const char *id;
-
-                       s_con = nm_connection_get_setting_connection (connection);
-                       id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
-                       if (id)
-                               str = g_strdup_printf (_("You are now connected to '%s'."), id);
-               }
-
-               applet_do_notify_with_pref (applet,
-                                           _("Connection Established"),
-                                           str ? str : _("You are now connected to the WiMAX network."),
-                                           "nm-device-wwan",
-                                           PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-               g_free (str);
-       }
+       applet_do_notify_with_pref (applet,
+                                   _("Connection Established"),
+                                   msg ? msg : _("You are now connected to the WiMAX network."),
+                                   "nm-device-wwan",
+                                   PREF_DISABLE_CONNECTED_NOTIFICATIONS);
 }
 
 static GdkPixbuf *
@@ -510,7 +491,7 @@ applet_device_wimax_get_class (NMApplet *applet)
        dclass->new_auto_connection = wimax_new_auto_connection;
        dclass->add_menu_item = wimax_add_menu_item;
        dclass->device_added = wimax_device_added;
-       dclass->device_state_changed = wimax_device_state_changed;
+       dclass->notify_connected = wimax_notify_connected;
        dclass->get_icon = wimax_get_icon;
        dclass->get_secrets = wimax_get_secrets;
 
diff --git a/src/applet.c b/src/applet.c
index 164dad3..ba7364c 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -2286,9 +2286,29 @@ foo_device_state_changed_cb (NMDevice *device,
        dclass = get_device_class (device, applet);
        g_assert (dclass);
 
-       dclass->device_state_changed (device, new_state, old_state, reason, applet);
+       if (dclass->device_state_changed)
+               dclass->device_state_changed (device, new_state, old_state, reason, applet);
        applet_common_device_state_changed (device, new_state, old_state, reason, applet);
 
+       if (   new_state == NM_DEVICE_STATE_ACTIVATED
+           && !g_settings_get_boolean (applet->gsettings, PREF_DISABLE_CONNECTED_NOTIFICATIONS)) {
+               NMConnection *connection;
+               NMSettingConnection *s_con = NULL;
+               char *str = NULL;
+
+               connection = applet_find_active_connection_for_device (device, applet, NULL);
+               if (connection) {
+                       const char *id;
+                       s_con = nm_connection_get_setting_connection (connection);
+                       id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
+                       if (id)
+                               str = g_strdup_printf (_("You are now connected to '%s'."), id);
+               }
+
+               dclass->notify_connected (device, str, applet);
+               g_free (str);
+       }
+
        applet_schedule_update_icon (applet);
 }
 
diff --git a/src/applet.h b/src/applet.h
index 1bb32b8..a0bd271 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -244,6 +244,9 @@ struct NMADeviceClass {
                                                NMDeviceState old_state,
                                                NMDeviceStateReason reason,
                                                NMApplet *applet);
+       void           (*notify_connected)     (NMDevice *device,
+                                               const char *msg,
+                                               NMApplet *applet);
 
        /* Device class is expected to return a *referenced* pixbuf, which will
         * be unrefed by the icon code.  This allows the device class to create


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