Beispiel #1
0
 def state_check(self):
     """Determine if interface is still connected"""
     active = netcfg.get_active_profiles()
     for profile in active:
         # Return codes are the reverse of True/False, hence a true here is actually a fail from grep.
         if subprocess.call("ip link show "+profile["INTERFACE"]+"|grep -q 'state UP'",shell=True):
             msg = profile.name + " appears to have been disconnected!"
             self.notify(msg)
Beispiel #2
0
 def menu_active(self, menu):
     """Append active profile menu items to the passed menu"""
     
     item = gtk.MenuItem(label="Active profiles - click to disconnect")
     item.set_sensitive(False)
     menu.append(item)
     
     for prof in netcfg.get_active_profiles():
         item = gtk.MenuItem(label=prof.name+": "+prof["INTERFACE"]+" connected")
         item.connect('activate', self.profile_action, prof, "down")
         menu.append(item)
Beispiel #3
0
 def menu_inactive(self, menu):
     """Append all inactive profiles to the menu so that they may be connected"""
     
     item = gtk.MenuItem(label="Inactive profiles - click to connect")
     item.set_sensitive(False)
     menu.append(item)
        
     for prof in netcfg.get_profiles():
         if not prof in netcfg.get_active_profiles():
             item = gtk.MenuItem(label=prof.name)
             item.connect('activate', self.profile_action, prof, "up")
             menu.append(item)
Beispiel #4
0
 def update_status_icon(self):
     """Update network profile status icon to reflect connectivity"""
     
     if self.action: # If icon has already been set by something else...
         return
     
     profiles = netcfg.get_active_profiles()
     if profiles:
         names = [ n.name for n in profiles ]
         self.statusIcon.set_tooltip("Active profiles: "+",".join(names))
         self.statusIcon.set_from_stock(gtk.STOCK_NETWORK)
     else:
         self.statusIcon.set_tooltip("No profiles active")
         self.statusIcon.set_from_stock(gtk.STOCK_DISCONNECT)