コード例 #1
0
ファイル: PowerBackend.py プロジェクト: pborky/batti-gtk
 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 = DeviceKitBattery(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
コード例 #2
0
ファイル: PowerBackend.py プロジェクト: dzeban/batti-gtk
    def __init__(self):
        self.__rmenu = None
        
        self.__bus = dbus.SystemBus()
        dkit_obj = self.__bus.get_object(self.dbus_service, self.dbus_object)
        self.dkit = dbus.Interface(dkit_obj, self.dbus_interface)
        devices = self.dkit.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 = DeviceKitBattery(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(dkit_obj, 'org.freedesktop.DBus.Properties')

        self.__can_suspend = False
        try:
            if properties.Get(self.dbus_interface, 'can-suspend'):
                self.__can_suspend = True
        except DBusException:
            pass

        self.__can_hibernate = False
        try:
            if properties.Get(self.dbus_interface, 'can-hibernate'):
                self.__can_hibernate = True
        except DBusException:
            pass
コード例 #3
0
ファイル: PowerBackend.py プロジェクト: alexschka/batti-gtk
    def __init__(self):
        self.__rmenu = None

        self.__bus = dbus.SystemBus()
        dkit_obj = self.__bus.get_object(self.dbus_service, self.dbus_object)
        self.dkit = dbus.Interface(dkit_obj, self.dbus_interface)
        devices = self.dkit.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 = DeviceKitBattery(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(dkit_obj,
                                    'org.freedesktop.DBus.Properties')

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

        if properties.Get(self.dbus_interface, 'can-hibernate'):
            self.__can_hibernate = True
        else:
            self.__can_hibernate = False
コード例 #4
0
ファイル: PowerBackend.py プロジェクト: alexschka/batti-gtk
 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 = DeviceKitBattery(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