Ejemplo n.º 1
0
    def __init__(self):
        self.__rmenu = None

        self.__bus = dbus.SystemBus()
        iface = self.__get_interface()
        devices = iface.EnumerateDevices()

        self.__batteries = {}
        for dev in devices:
            (prop_iface, dev_iface) = self.__get_battery(dev)
            type = prop_iface.Get(self.device_interface, 'type')
            if type == self.bat_type:
                power_bat = UPowerBattery(prop_iface, dev_iface)
                self.__batteries[dev] = power_bat
                power_bat.set_left_popup_menu_action(self.__mc_action)

        self.__bus.add_signal_receiver(self.__device_added, 'DeviceAdded',
                                       self.dbus_interface, self.dbus_service,
                                       self.dbus_object)
        self.__bus.add_signal_receiver(self.__device_removed, 'DeviceRemoved',
                                       self.dbus_interface, self.dbus_service,
                                       self.dbus_object)
        self.__mc_action = None

        properties = dbus.Interface(iface, 'org.freedesktop.DBus.Properties')

        if properties.Get(self.dbus_interface, 'CanSuspend'):
            self.__can_suspend = True
        else:
            self.__can_suspend = False

        if properties.Get(self.dbus_interface, 'CanHibernate'):
            self.__can_hibernate = True
        else:
            self.__can_hibernate = False
Ejemplo n.º 2
0
    def __init__(self):
        self.__rmenu = None
        
        self.__bus = dbus.SystemBus()
        iface = self.__get_interface()
        devices = iface.EnumerateDevices()
        
        self.__batteries = {}
        for dev in devices:
            (prop_iface, dev_iface) = self.__get_battery(dev)
            type = prop_iface.Get(self.device_interface, 'type')
            if type == self.bat_type:
                power_bat = UPowerBattery(prop_iface, dev_iface)
                self.__batteries[dev] = power_bat
                power_bat.set_left_popup_menu_action(self.__mc_action)
                
        
        self.__bus.add_signal_receiver(self.__device_added, 'DeviceAdded',
             self.dbus_interface, self.dbus_service, self.dbus_object)
        self.__bus.add_signal_receiver(self.__device_removed, 'DeviceRemoved',
             self.dbus_interface, self.dbus_service, self.dbus_object)
        self.__mc_action = None
        
        properties = dbus.Interface(iface, 'org.freedesktop.DBus.Properties')

        if properties.Get(self.dbus_interface, 'CanSuspend'):
            self.__can_suspend = True
        else:
            self.__can_suspend = False
        
        if properties.Get(self.dbus_interface, 'CanHibernate'):
            self.__can_hibernate = True
        else:
            self.__can_hibernate = False
Ejemplo n.º 3
0
 def __device_added(self, udi):
     (prop_iface, dev_iface) = self.__get_battery(udi)
     try:
         type = prop_iface.Get(self.device_interface, 'type')
         if type == self.bat_type:
             power_bat = UPowerBattery(prop_iface, dev_iface)
             power_bat.set_left_popup_menu_action(self.__mc_action)
             power_bat.update()
             self.__batteries[udi] = power_bat
     except DBusException:
         pass
Ejemplo n.º 4
0
 def __device_added(self, udi):
     (prop_iface, dev_iface) = self.__get_battery(udi)
     try:
         type = prop_iface.Get(self.device_interface, 'type')
         if type == self.bat_type:
             power_bat = UPowerBattery(prop_iface, dev_iface)
             power_bat.set_left_popup_menu_action(self.__mc_action)
             power_bat.update()
             self.__batteries[udi] = power_bat
     except DBusException:
         pass