def __init__(self): setup_icon_path() check_single_instance("blueman-applet") self.plugin_run_state_changed = False self.Manager = Bluez.Manager() self.Manager.connect_signal('adapter-added', self.on_adapter_added) self.Manager.connect_signal('adapter-removed', self.on_adapter_removed) self.Manager.connect_signal('device-created', self.on_device_created) self.Manager.connect_signal('device-removed', self.on_device_removed) self.DbusSvc = DbusService("org.blueman.Applet", "/") self.Plugins = PersistentPluginManager(AppletPlugin, blueman.plugins.applet, self) self.Plugins.Load() self.Plugins.Run("on_plugins_loaded") self.Manager.watch_name_owner(self._on_dbus_name_appeared, self._on_dbus_name_vanished) self._any_adapter = Bluez.AnyAdapter() self._any_adapter.connect_signal('property-changed', self._on_adapter_property_changed) self._any_device = Bluez.AnyDevice() self._any_device.connect_signal('property-changed', self._on_device_property_changed) Gtk.main()
def __init__(self, adapter_name=None, tabledata=None, **kwargs): if not tabledata: tabledata = [] def on_adapter_removed(_manager, path): self.emit("adapter-removed", path) if path == self.__adapter_path: self.clear() self.Adapter = None self.set_adapter() def on_adapter_added(_manager, path): if self.Adapter is None: self.set_adapter(path) self.emit("adapter-added", path) # cache for fast lookup in the list self.path_to_row = {} self.monitored_devices = [] self.manager = bluez.Manager() self.manager.connect_signal('adapter-removed', on_adapter_removed) self.manager.connect_signal('adapter-added', on_adapter_added) any_device = bluez.AnyDevice() any_device.connect_signal("property-changed", self._on_device_property_changed) self.__discovery_time = 0 self.__adapter_path = None self.Adapter = None self.discovering = False data = tabledata + [{ "id": "device", "type": object }, { "id": "dbus_path", "type": str }, { "id": "timestamp", "type": float }] super(DeviceList, self).__init__(data, **kwargs) self.set_name("DeviceList") self.set_adapter(adapter_name) self._any_adapter = bluez.AnyAdapter() self._any_adapter.connect_signal("property-changed", self._on_property_changed) self.selection.connect('changed', self.on_selection_changed) self.icon_theme = Gtk.IconTheme.get_default() self.icon_theme.prepend_search_path(ICON_PATH) # handle icon theme changes self.icon_theme.connect("changed", self.on_icon_theme_changed)
def __init__(self, adapter_name=None, tabledata=None, **kwargs): if not tabledata: tabledata = [] # cache for fast lookup in the list self.path_to_row: Dict[str, Gtk.TreeRowReference] = {} self.monitored_devices: List[str] = [] self.manager = bluez.Manager() self.manager.connect_signal('adapter-removed', self.__on_manager_signal, 'adapter-removed') self.manager.connect_signal('adapter-added', self.__on_manager_signal, 'adapter-added') self.manager.connect_signal('device-created', self.__on_manager_signal, 'device-created') self.manager.connect_signal('device-removed', self.__on_manager_signal, 'device-removed') self.any_device = bluez.AnyDevice() self.any_device.connect_signal("property-changed", self._on_device_property_changed) self.__discovery_time = 0 self.__adapter_path = None self.Adapter = None self.discovering = False data = tabledata + [{ "id": "device", "type": object }, { "id": "dbus_path", "type": str }, { "id": "timestamp", "type": float }] super().__init__(data, **kwargs) self.set_name("DeviceList") self.set_adapter(adapter_name) self._any_adapter = bluez.AnyAdapter() self._any_adapter.connect_signal("property-changed", self._on_property_changed) self.selection.connect('changed', self.on_selection_changed) self.icon_theme = Gtk.IconTheme.get_default() self.icon_theme.prepend_search_path(ICON_PATH) # handle icon theme changes self.icon_theme.connect("changed", self.on_icon_theme_changed)