Re: [PATCH] nm-applet for MBM (Show technology)
- From: Dan Williams <dcbw redhat com>
- To: bjornrun <bjorn runaker se>
- Cc: NetworkManager-list gnome org
- Subject: Re: [PATCH] nm-applet for MBM (Show technology)
- Date: Mon, 27 Oct 2008 16:35:34 -0400
On Mon, 2008-10-27 at 10:14 -0700, bjornrun wrote:
> Hello NetworkManager List!
>
> Here are some patches to networkmanager applet for MBM so technology used in
> connection is shown in applet.
> Note this uses the earlier patch in Modem-Manager.
Hang on for a bit with these patches, we'll be switching over to
ModemManager imminently and then we can start doing this sort of thing.
But, for the icons, don't create completely new ones. Just create small
badges (the same size as nm-vpn-active-lock.png) and then we'll just
composite them on top of the existing icon in another layer. There's
already a VPN layer, so we'll just add another for mobile broadband
speeds.
However, where would it go? The VPN lock already occupies the
lower-right corner, so that can't be used. We can't cover up too much
of the signal strength bars, otherwise it starts getting rediculous...
we may want to hold off on speed icons until we redesign the applet UI.
Dan
> Regards,
> Bjorn
>
> @@ -316,6 +347,7 @@
> char **tip,
> NMApplet *applet)
> {
> + NMAGsmModem *modem;
> GdkPixbuf *pixbuf = NULL;
> const char *iface;
> NMSettingConnection *s_con = NULL;
> @@ -335,16 +367,82 @@
> *tip = g_strdup_printf (_("Waiting for user authentication on device
> '%s'..."), iface);
> break;
> case NM_DEVICE_STATE_ACTIVATED:
> - if (s_con) {
> - const char *id;
> + modem = (NMAGsmModem *) g_object_get_data (G_OBJECT (device),
> "gsm-modem");
> + if (modem) {
> + char *oper_code;
> + char *oper_name;
> + guint32 reg_status;
> + guint32 quality;
> + guint32 network_mode;
> +
> +
> + quality = nma_gsm_modem_get_signal_quality (modem);
> + quality = CLAMP (quality, 0, 100);
> + network_mode = nma_gsm_modem_get_network_mode (modem);
> +
> + g_debug("quality = %d, net = %d", quality, network_mode);
> +
> + if (quality > 80) {
> + switch (network_mode) {
> + case MM_MODEM_GSM_NETWORK_MODE_HSDPA:
> + pixbuf = applet->wireless_100_H_icon; break;
> + case MM_MODEM_GSM_NETWORK_MODE_3G:
> + pixbuf = applet->wireless_100_U_icon; break;
> + case MM_MODEM_GSM_NETWORK_MODE_GPRS:
> + pixbuf = applet->wireless_100_E_icon; break;
> + default:
> + pixbuf = applet->wireless_100_icon;
> + }
> + } else if (quality > 55) {
> + switch (network_mode) {
> + case MM_MODEM_GSM_NETWORK_MODE_HSDPA:
> + pixbuf = applet->wireless_75_H_icon; break;
> + case MM_MODEM_GSM_NETWORK_MODE_3G:
> + pixbuf = applet->wireless_75_U_icon; break;
> + case MM_MODEM_GSM_NETWORK_MODE_GPRS:
> + pixbuf = applet->wireless_75_E_icon; break;
> + default:
> + pixbuf = applet->wireless_75_icon;
> + }
> + } else if (quality > 30) {
> + switch (network_mode) {
> + case MM_MODEM_GSM_NETWORK_MODE_HSDPA:
> + pixbuf = applet->wireless_50_H_icon; break;
> + case MM_MODEM_GSM_NETWORK_MODE_3G:
> + pixbuf = applet->wireless_50_U_icon; break;
> + case MM_MODEM_GSM_NETWORK_MODE_GPRS:
> + pixbuf = applet->wireless_50_E_icon; break;
> + default:
> + pixbuf = applet->wireless_50_icon;
> + }
> + } else if (quality > 5) {
> + switch (network_mode) {
> + case MM_MODEM_GSM_NETWORK_MODE_HSDPA:
> + pixbuf = applet->wireless_25_H_icon; break;
> + case MM_MODEM_GSM_NETWORK_MODE_3G:
> + pixbuf = applet->wireless_25_U_icon; break;
> + case MM_MODEM_GSM_NETWORK_MODE_GPRS:
> + pixbuf = applet->wireless_25_E_icon; break;
> + default:
> + pixbuf = applet->wireless_25_icon;
> + }
> + } else
> + pixbuf = applet->wireless_00_icon;
> +
> + reg_status = nma_gsm_modem_get_registration_info (modem, &oper_code,
> &oper_name);
> + *tip = g_strdup_printf (_("%s GSM connection '%s' (%d%%)"),
> + reg_status == MM_GSM_MODEM_REG_STATUS_ROAMING ? _("Roaming") :
> _("Home"),
> + oper_name, quality);
> +
> + g_free (oper_name);
> + g_free (oper_code);
> +
> + } else {
> + pixbuf = applet->wireless_00_icon;
> + *tip = g_strdup_printf (_("GSM connection"));
> + }
>
> - id = nm_setting_connection_get_id (s_con);
> - if (id)
> - *tip = g_strdup_printf (_("Mobile broadband connection '%s'"), id);
> - } else
> - *tip = g_strdup (_("Mobile broadband connection"));
> - pixbuf = applet->wwan_icon;
> break;
> default:
> break;
>
> @@ -1974,6 +1965,21 @@
> CLEAR_ICON(applet->wireless_50_icon);
> CLEAR_ICON(applet->wireless_75_icon);
> CLEAR_ICON(applet->wireless_100_icon);
> + CLEAR_ICON(applet->wireless_00_E_icon);
> + CLEAR_ICON(applet->wireless_25_E_icon);
> + CLEAR_ICON(applet->wireless_50_E_icon);
> + CLEAR_ICON(applet->wireless_75_E_icon);
> + CLEAR_ICON(applet->wireless_100_E_icon);
> + CLEAR_ICON(applet->wireless_00_U_icon);
> + CLEAR_ICON(applet->wireless_25_U_icon);
> + CLEAR_ICON(applet->wireless_50_U_icon);
> + CLEAR_ICON(applet->wireless_75_U_icon);
> + CLEAR_ICON(applet->wireless_100_U_icon);
> + CLEAR_ICON(applet->wireless_00_H_icon);
> + CLEAR_ICON(applet->wireless_25_H_icon);
> + CLEAR_ICON(applet->wireless_50_H_icon);
> + CLEAR_ICON(applet->wireless_75_H_icon);
> + CLEAR_ICON(applet->wireless_100_H_icon);
>
> for (i = 0; i < NUM_CONNECTING_STAGES; i++) {
> for (j = 0; j < NUM_CONNECTING_FRAMES; j++)
> @@ -2021,6 +2027,21 @@
> ICON_LOAD(applet->wireless_50_icon, "nm-signal-50");
> ICON_LOAD(applet->wireless_75_icon, "nm-signal-75");
> ICON_LOAD(applet->wireless_100_icon, "nm-signal-100");
> + ICON_LOAD(applet->wireless_00_E_icon, "nm-signal-00-E");
> + ICON_LOAD(applet->wireless_25_E_icon, "nm-signal-25-E");
> + ICON_LOAD(applet->wireless_50_E_icon, "nm-signal-50-E");
> + ICON_LOAD(applet->wireless_75_E_icon, "nm-signal-75-E");
> + ICON_LOAD(applet->wireless_100_E_icon, "nm-signal-100-E");
> + ICON_LOAD(applet->wireless_00_U_icon, "nm-signal-00-U");
> + ICON_LOAD(applet->wireless_25_U_icon, "nm-signal-25-U");
> + ICON_LOAD(applet->wireless_50_U_icon, "nm-signal-50-U");
> + ICON_LOAD(applet->wireless_75_U_icon, "nm-signal-75-U");
> + ICON_LOAD(applet->wireless_100_U_icon, "nm-signal-100-U");
> + ICON_LOAD(applet->wireless_00_H_icon, "nm-signal-00-H");
> + ICON_LOAD(applet->wireless_25_H_icon, "nm-signal-25-H");
> + ICON_LOAD(applet->wireless_50_H_icon, "nm-signal-50-H");
> + ICON_LOAD(applet->wireless_75_H_icon, "nm-signal-75-H");
> + ICON_LOAD(applet->wireless_100_H_icon, "nm-signal-100-H");
>
> for (i = 0; i < NUM_CONNECTING_STAGES; i++) {
> for (j = 0; j < NUM_CONNECTING_FRAMES; j++) {
>
>
>
> --- ../foss/network-manager-applet/svn/src/applet.h 2008-10-27
> 04:58:11.000000000 -0700
> +++ ../src/network-manager-applet/src/applet.h 2008-10-24 07:04:35.000000000
> -0700
> @@ -109,6 +109,21 @@
> GdkPixbuf * wireless_50_icon;
> GdkPixbuf * wireless_75_icon;
> GdkPixbuf * wireless_100_icon;
> + GdkPixbuf * wireless_00_E_icon;
> + GdkPixbuf * wireless_25_E_icon;
> + GdkPixbuf * wireless_50_E_icon;
> + GdkPixbuf * wireless_75_E_icon;
> + GdkPixbuf * wireless_100_E_icon;
> + GdkPixbuf * wireless_00_U_icon;
> + GdkPixbuf * wireless_25_U_icon;
> + GdkPixbuf * wireless_50_U_icon;
> + GdkPixbuf * wireless_75_U_icon;
> + GdkPixbuf * wireless_100_U_icon;
> + GdkPixbuf * wireless_00_H_icon;
> + GdkPixbuf * wireless_25_H_icon;
> + GdkPixbuf * wireless_50_H_icon;
> + GdkPixbuf * wireless_75_H_icon;
> + GdkPixbuf * wireless_100_H_icon;
> #define NUM_CONNECTING_STAGES 3
> #define NUM_CONNECTING_FRAMES 11
> GdkPixbuf *
> network_connecting_icons[NUM_CONNECTING_STAGES][NUM_CONNECTING_FRAMES];
> @@ -215,4 +230,17 @@
> NMApplet *applet,
> NMActiveConnection
> **out_active);
>
> +
> +typedef enum {
> + MM_MODEM_GSM_NETWORK_MODE_ANY = 0,
> + MM_MODEM_GSM_NETWORK_MODE_GPRS = 1,
> + MM_MODEM_GSM_NETWORK_MODE_EDGE = 2,
> + MM_MODEM_GSM_NETWORK_MODE_3G = 3,
> + MM_MODEM_GSM_NETWORK_MODE_HSDPA = 4,
> + MM_MODEM_GSM_NETWORK_MODE_PREFER_2G = 5,
> + MM_MODEM_GSM_NETWORK_MODE_PREFER_3G = 6,
> +
> + MM_MODEM_GSM_NETWORK_MODE_LAST = MM_MODEM_GSM_NETWORK_MODE_PREFER_3G
> +} MMModemGsmNetworkMode;
> +
> #endif
>
>
>
>
> http://www.nabble.com/file/p20192060/nm-signal-00-E.png nm-signal-00-E.png
> http://www.nabble.com/file/p20192060/nm-signal-00-U.png nm-signal-00-U.png
> http://www.nabble.com/file/p20192060/nm-signal-00-H.png nm-signal-00-H.png
> http://www.nabble.com/file/p20192060/nm-signal-25-E.png nm-signal-25-E.png
> http://www.nabble.com/file/p20192060/nm-signal-25-H.png nm-signal-25-H.png
> http://www.nabble.com/file/p20192060/nm-signal-25-U.png nm-signal-25-U.png
> http://www.nabble.com/file/p20192060/nm-signal-50-E.png nm-signal-50-E.png
> http://www.nabble.com/file/p20192060/nm-signal-50-H.png nm-signal-50-H.png
> http://www.nabble.com/file/p20192060/nm-signal-50-U.png nm-signal-50-U.png
> http://www.nabble.com/file/p20192060/nm-signal-75-E.png nm-signal-75-E.png
> http://www.nabble.com/file/p20192060/nm-signal-75-H.png nm-signal-75-H.png
> http://www.nabble.com/file/p20192060/nm-signal-75-U.png nm-signal-75-U.png
> http://www.nabble.com/file/p20192060/nm-signal-100-E.png nm-signal-100-E.png
> http://www.nabble.com/file/p20192060/nm-signal-100-H.png nm-signal-100-H.png
> http://www.nabble.com/file/p20192060/nm-signal-100-U.png nm-signal-100-U.png
>
>
> --
> View this message in context: http://www.nabble.com/-PATCH--nm-applet-for-MBM-%28Show-technology%29-tp20192060p20192060.html
> Sent from the Gnome - NetworkManager mailing list archive at Nabble.com.
>
> _______________________________________________
> NetworkManager-list mailing list
> NetworkManager-list gnome org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]