1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
4
* Dan Williams <dcbw@redhat.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License along
17
* with this program; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
* (C) Copyright 2010 Red Hat, Inc.
23
#include "mobile-helpers.h"
26
mobile_helper_get_status_pixbuf (guint32 quality,
27
gboolean quality_valid,
32
GdkPixbuf *pixbuf, *qual_pixbuf, *wwan_pixbuf, *tmp;
34
wwan_pixbuf = nma_icon_check_and_load ("nm-wwan-tower", &applet->wwan_tower_icon, applet);
38
qual_pixbuf = mobile_helper_get_quality_icon (quality, applet);
40
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
42
gdk_pixbuf_get_bits_per_sample (qual_pixbuf),
43
gdk_pixbuf_get_width (qual_pixbuf),
44
gdk_pixbuf_get_height (qual_pixbuf));
45
gdk_pixbuf_fill (pixbuf, 0xFFFFFF00);
47
/* Composite the tower icon into the final icon at the bottom layer */
48
gdk_pixbuf_composite (wwan_pixbuf, pixbuf,
50
gdk_pixbuf_get_width (wwan_pixbuf),
51
gdk_pixbuf_get_height (wwan_pixbuf),
53
GDK_INTERP_BILINEAR, 255);
55
/* Composite the signal quality onto the icon on top of the WWAN tower */
56
gdk_pixbuf_composite (qual_pixbuf, pixbuf,
58
gdk_pixbuf_get_width (qual_pixbuf),
59
gdk_pixbuf_get_height (qual_pixbuf),
61
GDK_INTERP_BILINEAR, 255);
63
/* And finally the roaming or technology icon */
64
if (state == MB_STATE_ROAMING) {
65
tmp = nma_icon_check_and_load ("nm-mb-roam", &applet->mb_roaming_icon, applet);
66
gdk_pixbuf_composite (tmp, pixbuf, 0, 0,
67
gdk_pixbuf_get_width (tmp),
68
gdk_pixbuf_get_height (tmp),
70
GDK_INTERP_BILINEAR, 255);
72
tmp = mobile_helper_get_tech_icon (access_tech, applet);
74
gdk_pixbuf_composite (tmp, pixbuf, 0, 0,
75
gdk_pixbuf_get_width (tmp),
76
gdk_pixbuf_get_height (tmp),
78
GDK_INTERP_BILINEAR, 255);
82
/* 'pixbuf' will be freed by the caller */
87
mobile_helper_get_quality_icon (guint32 quality, NMApplet *applet)
90
return nma_icon_check_and_load ("nm-signal-100", &applet->wireless_100_icon, applet);
91
else if (quality > 55)
92
return nma_icon_check_and_load ("nm-signal-75", &applet->wireless_75_icon, applet);
93
else if (quality > 30)
94
return nma_icon_check_and_load ("nm-signal-50", &applet->wireless_50_icon, applet);
96
return nma_icon_check_and_load ("nm-signal-25", &applet->wireless_25_icon, applet);
98
return nma_icon_check_and_load ("nm-signal-00", &applet->wireless_00_icon, applet);
102
mobile_helper_get_tech_icon (guint32 tech, NMApplet *applet)
106
return nma_icon_check_and_load ("nm-tech-cdma-1x", &applet->mb_tech_1x_icon, applet);
107
case MB_TECH_EVDO_REV0:
108
case MB_TECH_EVDO_REVA:
109
return nma_icon_check_and_load ("nm-tech-evdo", &applet->mb_tech_evdo_icon, applet);
112
return nma_icon_check_and_load ("nm-tech-gprs", &applet->mb_tech_gprs_icon, applet);
114
return nma_icon_check_and_load ("nm-tech-edge", &applet->mb_tech_edge_icon, applet);
116
return nma_icon_check_and_load ("nm-tech-umts", &applet->mb_tech_umts_icon, applet);
120
return nma_icon_check_and_load ("nm-tech-hspa", &applet->mb_tech_hspa_icon, applet);