Re: [PATCH 1/4] applet: use the connection name as notification title



On Tue, 2013-03-05 at 12:57 -0500, Mathieu Trudel-Lapierre wrote:
... and thus the actual state we got to as the notification's text. The state
transition is also visible from the icon, so from a quick look what really
stands out is the icon for a connect/disconnect, and the actual connection
that transitioned.

As you said on IRC, this series should be dropped and you're sending new
ones.  Just to clarify :)

Dan

---
 src/applet-device-broadband.c | 11 +++--------
 src/applet-device-bt.c        | 10 +++-------
 src/applet-device-cdma.c      | 11 +++--------
 src/applet-device-ethernet.c  | 10 +++-------
 src/applet-device-gsm.c       | 15 +++++----------
 src/applet-device-wifi.c      |  9 ++++-----
 src/applet-device-wimax.c     | 11 +++--------
 7 files changed, 24 insertions(+), 53 deletions(-)

diff --git a/src/applet-device-broadband.c b/src/applet-device-broadband.c
index e021278..a7c69de 100644
--- a/src/applet-device-broadband.c
+++ b/src/applet-device-broadband.c
@@ -801,27 +801,22 @@ device_state_changed (NMDevice *device,
 {
      NMConnection *connection;
      NMSettingConnection *s_con = NULL;
-     char *str = NULL;
+     const 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);
+             str = s_con ? nm_setting_connection_get_id (s_con) : NULL;
      }
 
      applet_do_notify_with_pref (applet,
+                                 str ? str : _("Mobile Broadband network"),
                                  _("Connection Established"),
-                                 str ? str : _("You are now connected to the Mobile Broadband network."),
                                  "nm-device-wwan",
                                  PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-     g_free (str);
 }
 
 /********************************************************************/
diff --git a/src/applet-device-bt.c b/src/applet-device-bt.c
index 5a17846..168ce5d 100644
--- a/src/applet-device-bt.c
+++ b/src/applet-device-bt.c
@@ -184,23 +184,19 @@ bt_device_state_changed (NMDevice *device,
      if (new_state == NM_DEVICE_STATE_ACTIVATED) {
              NMConnection *connection;
              NMSettingConnection *s_con = NULL;
-             char *str = NULL;
+             const 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);
+                     str = s_con ? nm_setting_connection_get_id (s_con) : NULL;
              }
 
              applet_do_notify_with_pref (applet,
+                                         str ? str : _("Mobile Broadband network"),
                                          _("Connection Established"),
-                                         str ? str : _("You are now connected to the mobile broadband 
network."),
                                          "nm-device-wwan",
                                          PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-             g_free (str);
      }
 }
 
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index 91f71f6..a52ede7 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -333,24 +333,19 @@ cdma_device_state_changed (NMDevice *device,
      if (new_state == NM_DEVICE_STATE_ACTIVATED) {
              NMConnection *connection;
              NMSettingConnection *s_con = NULL;
-             char *str = NULL;
+             const 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);
+                        str = s_con ? nm_setting_connection_get_id (s_con) : NULL;
              }
 
              applet_do_notify_with_pref (applet,
+                                         str ? str : _("CDMA network"),
                                          _("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 */
diff --git a/src/applet-device-ethernet.c b/src/applet-device-ethernet.c
index 6e63dcb..c1cc8ea 100644
--- a/src/applet-device-ethernet.c
+++ b/src/applet-device-ethernet.c
@@ -255,23 +255,19 @@ ethernet_device_state_changed (NMDevice *device,
      if (new_state == NM_DEVICE_STATE_ACTIVATED) {
              NMConnection *connection;
              NMSettingConnection *s_con = NULL;
-             char *str = NULL;
+             const 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);
+                     str = s_con ? nm_setting_connection_get_id (s_con) : NULL;
              }
 
              applet_do_notify_with_pref (applet,
+                                         str ? str : _("Ethernet network"),
                                          _("Connection Established"),
-                                         str ? str : _("You are now connected to the ethernet network."),
                                          "nm-device-wired",
                                          PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-             g_free (str);
      }
 }
 
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 4575f39..77c8941 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -389,24 +389,19 @@ gsm_device_state_changed (NMDevice *device,
      if (new_state == NM_DEVICE_STATE_ACTIVATED) {
              NMConnection *connection;
              NMSettingConnection *s_con = NULL;
-             char *str = NULL;
+             const 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);
+                     str = s_con ? nm_setting_connection_get_id (s_con) : NULL;
              }
 
              applet_do_notify_with_pref (applet,
+                                         str ? str : _("GSM network"),
                                          _("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 */
@@ -674,13 +669,13 @@ notify_user_of_gsm_reg_change (GsmDeviceInfo *info)
 
      if (mb_state == MB_STATE_HOME) {
              applet_do_notify_with_pref (info->applet,
-                                         _("GSM network."),
+                                         _("GSM network"),
                                          _("You are now registered on the home network."),
                                          "nm-signal-100",
                                          PREF_DISABLE_CONNECTED_NOTIFICATIONS);
      } else if (mb_state == MB_STATE_ROAMING) {
              applet_do_notify_with_pref (info->applet,
-                                         _("GSM network."),
+                                         _("GSM network"),
                                          _("You are now registered on a roaming network."),
                                          "nm-signal-100",
                                          PREF_DISABLE_CONNECTED_NOTIFICATIONS);
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index fa3d618..d46dd61 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -1245,7 +1245,6 @@ wifi_device_state_changed (NMDevice *device,
                            NMApplet *applet)
 {
      NMAccessPoint *new = NULL;
-     char *msg;
      char *esc_ssid = NULL;
 
      new = update_active_ap (device, new_state, applet);
@@ -1257,11 +1256,11 @@ wifi_device_state_changed (NMDevice *device,
              return;
 
      esc_ssid = get_ssid_utf8 (new);
-     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",
+     applet_do_notify_with_pref (applet,
+                                 esc_ssid ? esc_ssid : _("(none)"),
+                                 _("Connection Established"),
+                                 "nm-device-wireless",
                                  PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-     g_free (msg);
      g_free (esc_ssid);
 }
 
diff --git a/src/applet-device-wimax.c b/src/applet-device-wimax.c
index a870c48..ca88b15 100644
--- a/src/applet-device-wimax.c
+++ b/src/applet-device-wimax.c
@@ -407,24 +407,19 @@ wimax_device_state_changed (NMDevice *device,
      if (new_state == NM_DEVICE_STATE_ACTIVATED) {
              NMConnection *connection;
              NMSettingConnection *s_con = NULL;
-             char *str = NULL;
+             const 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);
+                     str = s_con ? nm_setting_connection_get_id (s_con) : NULL;
              }
 
              applet_do_notify_with_pref (applet,
+                                         str ? str : _("WiMAX network"),
                                          _("Connection Established"),
-                                         str ? str : _("You are now connected to the WiMAX network."),
                                          "nm-device-wwan",
                                          PREF_DISABLE_CONNECTED_NOTIFICATIONS);
-             g_free (str);
      }
 }
 




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