diff options
author | Eugeni Dodonov <eugeni@mandriva.com> | 2009-10-14 15:36:27 -0300 |
---|---|---|
committer | Eugeni Dodonov <eugeni@mandriva.com> | 2009-10-14 15:36:27 -0300 |
commit | 9efce2a881a8a6275502a5dd74603188c10ddc37 (patch) | |
tree | 9d7ba3044c5295f846daac4b0b36a6c9cddc8424 /src | |
parent | 722ef01a4aa1263b64f704aa3797c8eb478b2f9b (diff) | |
download | net_monitor-9efce2a881a8a6275502a5dd74603188c10ddc37.tar net_monitor-9efce2a881a8a6275502a5dd74603188c10ddc37.tar.gz net_monitor-9efce2a881a8a6275502a5dd74603188c10ddc37.tar.bz2 net_monitor-9efce2a881a8a6275502a5dd74603188c10ddc37.tar.xz net_monitor-9efce2a881a8a6275502a5dd74603188c10ddc37.zip |
Show interface icons when available
Diffstat (limited to 'src')
-rwxr-xr-x | src/net_monitor | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/net_monitor b/src/net_monitor index bdb6417..b318acc 100755 --- a/src/net_monitor +++ b/src/net_monitor @@ -272,6 +272,8 @@ class LoadGraph: self.__colors[key] = value class MonitorGui: + # icon pattern - icons are pulled from drakx-net + ICON_PATTERN="/usr/share/libDrakX/pixmaps/%s-16.png" def __init__(self, default_iface=None): self.window = gtk.Window() self.window.set_title(_("Network monitor")) @@ -312,8 +314,8 @@ class MonitorGui: 'histogram': [], 'address': "", } - iface_stat = self.build_iface_stat(iface) - cur_page = self.notebook.append_page(iface_stat, gtk.Label(iface)) + iface_stat, iface_label = self.build_iface_stat(iface) + cur_page = self.notebook.append_page(iface_stat, iface_label) if default_iface and iface == default_iface: select_page = cur_page if self.check_network_accounting(iface): @@ -641,7 +643,35 @@ class MonitorGui: label = gtk.Label("\n".join(textwrap.wrap(_("Network accounting is not enabled for this interface. Please enable it in Mandriva network center in order to view detailed traffic statistics")))) traf_vbox.pack_start(label, False, False) - return traf_vbox + # building notebook label icons + traf_label = gtk.HBox(False, 2) + if iface in self.wireless_ifaces: + # wifi + self.__load_interface_icon(traf_label, 'wireless') + elif iface[:3] == 'ppp': + # modem or peer-to-peer connection + self.__load_interface_icon(traf_label, 'potsmodem-24') + elif iface[:3] == 'eth': + # ethernet + self.__load_interface_icon(traf_label, 'ethernet') + elif iface[:3] == 'pan': + # ethernet + self.__load_interface_icon(traf_label, 'bluetooth') + + traf_label.pack_start(gtk.Label(iface)) + traf_label.show_all() + + return traf_vbox, traf_label + + def __load_interface_icon(self, widget, icon_title): + """Loads interface icon""" + try: + icon = gtk.Image() + pixbuf = gtk.gdk.pixbuf_new_from_file(self.ICON_PATTERN % icon_title) + icon.set_from_pixbuf(pixbuf) + widget.pack_start(icon) + except: + traceback.print_exc() def __add_row(self, table, row, items, markup=False, wrap=False): cur_pos = 1 |