def on_adapter_selected(self, menuitem, adapter_path): if menuitem.props.active: if adapter_path != self.blueman.List.Adapter.get_object_path(): dprint("selected", adapter_path) self.blueman.Config.props.last_adapter = adapter_path_to_name( adapter_path) self.blueman.List.SetAdapter(adapter_path)
def SetAdapter(self, adapter=None): self.clear() if self.discovering: self.emit("adapter-property-changed", self.Adapter, ("Discovering", False)) self.StopDiscovery() if adapter != None and not re.match("hci[0-9]*", adapter): adapter = adapter_path_to_name(adapter) dprint(adapter) if self.Adapter != None: self.adapter_signals.DisconnectAll() try: self.Adapter = self.Manager.GetAdapter(adapter) self.adapter_signals.Handle(self.Adapter, self.on_device_found, "DeviceFound") self.adapter_signals.Handle(self.Adapter, self.on_property_changed, "PropertyChanged") self.adapter_signals.Handle(self.Adapter, self.on_device_created, "DeviceCreated") self.adapter_signals.Handle(self.Adapter, self.on_device_removed, "DeviceRemoved") self.__adapter_path = self.Adapter.GetObjectPath() self.emit("adapter-changed", self.__adapter_path) except Bluez.errors.DBusNoSuchAdapterError, e: dprint(e) #try loading default adapter if len(self.Manager.ListAdapters()) > 0 and adapter != None: self.SetAdapter() else: self.Adapter = None self.emit("adapter-changed", None)
def SetAdapter(self, adapter=None): self.clear() if self.discovering: self.emit("adapter-property-changed", self.Adapter, ("Discovering", False)) self.StopDiscovery() if adapter is not None and adapter != "" and not re.match("hci[0-9]*", adapter): adapter = adapter_path_to_name(adapter) dprint(adapter) try: self.Adapter = self.manager.get_adapter(adapter) self.Adapter.connect_signal('property-changed', self._on_property_changed) self.manager.connect_signal('device-created', self._on_device_created) self.manager.connect_signal('device-removed', self._on_device_removed) self.__adapter_path = self.Adapter.get_object_path() self.emit("adapter-changed", self.__adapter_path) except Bluez.errors.DBusNoSuchAdapterError as e: dprint(e) #try loading default adapter if len(self.manager.list_adapters()) > 0 and adapter is not None: self.SetAdapter() else: self.Adapter = None self.emit("adapter-changed", None)
def SetAdapter(self, adapter=None): self.clear() if self.discovering: self.emit("adapter-property-changed", self.Adapter, ("Discovering", False)) self.StopDiscovery() if adapter is not None and adapter != "" and not re.match("hci[0-9]*", adapter): adapter = adapter_path_to_name(adapter) logging.debug(adapter) try: self.Adapter = self.manager.get_adapter(adapter) # The patern may be incorrect (ie removed adapter), see #590 if self.Adapter is None: self.Adapter = self.manager.get_adapter() self.Adapter.connect_signal('property-changed', self._on_property_changed) self.manager.connect_signal('device-created', self._on_device_created) self.manager.connect_signal('device-removed', self._on_device_removed) self.__adapter_path = self.Adapter.get_object_path() self.emit("adapter-changed", self.__adapter_path) except Bluez.errors.DBusNoSuchAdapterError as e: logging.exception(e) #try loading default adapter if len(self.manager.get_adapters()) > 0 and adapter is not None: self.SetAdapter() else: self.Adapter = None self.emit("adapter-changed", None)
def set_adapter(self, adapter=None): self.clear() if self.discovering: self.emit("adapter-property-changed", self.Adapter, ("Discovering", False)) self.stop_discovery() adapter = adapter_path_to_name(adapter) logging.debug(adapter) # The pattern may be incorrect (ie removed adapter), see #590 try: self.Adapter = self.manager.get_adapter(adapter) except bluez.errors.DBusNoSuchAdapterError: logging.info('Adapter pattern not valid, trying default adapter.') try: self.Adapter = self.manager.get_adapter() self.__adapter_path = self.Adapter.get_object_path() except bluez.errors.DBusNoSuchAdapterError as e: logging.exception(e) self.Adapter = None self.__adapter_path = None finally: self.emit("adapter-changed", None)
def on_adapter_selected(self, menuitem, adapter_path): if menuitem.props.active: if adapter_path != self.blueman.List.Adapter.get_object_path(): logging.info(f"selected {adapter_path}") self.blueman.Config["last-adapter"] = adapter_path_to_name( adapter_path) self.blueman.List.set_adapter(adapter_path)
def set_adapter(self, adapter=None): self.clear() if self.discovering: self.stop_discovery() self.emit("adapter-property-changed", self.Adapter, ("Discovering", False)) adapter = adapter_path_to_name(adapter) logging.debug(f"Setting adapter to: {adapter}") if adapter is not None: try: self.Adapter = self.manager.get_adapter(adapter) self.__adapter_path = self.Adapter.get_object_path() except DBusNoSuchAdapterError: logging.warning('Failed to set adapter, trying first available.') self.set_adapter(None) return else: adapters = self.manager.get_adapters() if len(adapters) > 0: self.Adapter = adapters[0] self.__adapter_path = self.Adapter.get_object_path() else: self.Adapter = None self.__adapter_path = None self.emit("adapter-changed", self.__adapter_path)
def SetAdapter(self, adapter=None): self.clear() if self.discovering: self.emit("adapter-property-changed", self.Adapter, ("Discovering", False)) self.StopDiscovery() if adapter is not None and not re.match("hci[0-9]*", adapter): adapter = adapter_path_to_name(adapter) dprint(adapter) if self.Adapter is not None: self.adapter_signals.DisconnectAll() try: self.Adapter = self.Manager.GetAdapter(adapter) self.adapter_signals.Handle(self.Adapter, self.on_device_found, "DeviceFound") self.adapter_signals.Handle(self.Adapter, self.on_property_changed, "PropertyChanged") self.adapter_signals.Handle(self.Adapter, self.on_device_created, "DeviceCreated") self.adapter_signals.Handle(self.Adapter, self.on_device_removed, "DeviceRemoved") self.__adapter_path = self.Adapter.GetObjectPath() self.emit("adapter-changed", self.__adapter_path) except Bluez.errors.DBusNoSuchAdapterError as e: dprint(e) #try loading default adapter if len(self.Manager.ListAdapters()) > 0 and adapter != None: self.SetAdapter() else: self.Adapter = None self.emit("adapter-changed", None) except dbus.DBusServiceUnknownError: dprint("Dbus error while trying to get adapter.") self.Adapter = None self.emit("adapter-changed", None)
def on_adapter_selected(self, menuitem: Gtk.CheckMenuItem, adapter_path: str) -> None: if menuitem.props.active: assert self.blueman.List.Adapter is not None if adapter_path != self.blueman.List.Adapter.get_object_path(): logging.info(f"selected {adapter_path}") self.blueman.Config["last-adapter"] = adapter_path_to_name(adapter_path) self.blueman.List.set_adapter(adapter_path)
def set_adapter(self, adapter=None): self.clear() if self.discovering: self.emit("adapter-property-changed", self.Adapter, ("Discovering", False)) self.stop_discovery() if adapter is not None and adapter != "" and not re.match( "hci[0-9]*", adapter): adapter = adapter_path_to_name(adapter) logging.debug(adapter) # The pattern may be incorrect (ie removed adapter), see #590 try: self.Adapter = self.manager.get_adapter(adapter) except bluez.errors.DBusNoSuchAdapterError as e: logging.info('Adapter pattern not valid, trying default adapter.') try: self.Adapter = self.manager.get_adapter() self.__adapter_path = self.Adapter.get_object_path() except bluez.errors.DBusNoSuchAdapterError as e: logging.exception(e) self.Adapter = None self.__adapter_path = None finally: self.emit("adapter-changed", None)
def on_adapter_changed(self, lst, adapter_path): self.hci = adapter_path_to_name(adapter_path) if self.hci is None: self.hbox.props.sensitive = False else: self.hbox.props.sensitive = True self.up_speed.reset() self.down_speed.reset()
def on_adapter_changed(self, _lst: ManagerDeviceList, adapter_path: Optional[str]) -> None: self.hci = adapter_path_to_name(adapter_path) if self.hci is None: self.hbox.props.sensitive = False else: self.hbox.props.sensitive = True self.up_speed.reset() self.down_speed.reset()
def on_adapter_changed(self, List, adapter_path): if adapter_path != None: self.hci = adapter_path_to_name(adapter_path) self.hbox.props.sensitive = True else: self.hci = None self.hbox.props.sensitive = False self.up_speed.reset() self.down_speed.reset()
def __init__(self, blueman): blueman.List.connect("adapter-changed", self.on_adapter_changed) if blueman.List.Adapter: self.hci = adapter_path_to_name(blueman.List.Adapter.get_object_path()) else: self.hci = None self.time = None self.up_speed = SpeedCalc() self.down_speed = SpeedCalc() self.im_upload = Gtk.Image(icon_name="blueman-up-inactive", pixel_size=16, halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Data activity indication")) self.im_download = Gtk.Image(icon_name="blueman-down-inactive", pixel_size=16, halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Data activity indication")) self.down_rate = Gtk.Label(halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Total data received and rate of transmission")) self.down_rate.show() self.up_rate = Gtk.Label(halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Total data sent and rate of transmission")) self.up_rate.show() self.uparrow = Gtk.Image(icon_name="go-up", pixel_size=16, halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Total data sent and rate of transmission")) self.downarrow = Gtk.Image(icon_name="go-down", pixel_size=16, halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Total data received and rate of transmission")) self.hbox = hbox = blueman.Builder.get_object("status_activity") hbox.pack_start(self.uparrow, False, False, 0) hbox.pack_start(self.up_rate, False, False, 0) hbox.pack_start(self.downarrow, False, False, 0) hbox.pack_start(self.down_rate, False, False, 0) hbox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), False, False, 0) hbox.pack_start(self.im_upload, False, False, 0) hbox.pack_start(self.im_download, False, False, 0) hbox.show_all() self.on_adapter_changed(blueman.List, blueman.List.GetAdapterPath()) self.up_blinker = Animation(self.im_upload, ["blueman-up-inactive","blueman-up-active"]) self.down_blinker = Animation(self.im_download, ["blueman-down-inactive", "blueman-down-active"]) self.start_update()
def __init__(self, blueman): blueman.List.connect("adapter-changed", self.on_adapter_changed) self.hci = adapter_path_to_name(blueman.List.Adapter.get_object_path()) self.time = None self.up_speed = SpeedCalc() self.down_speed = SpeedCalc() self.im_upload = Gtk.Image(icon_name="blueman-up-inactive", pixel_size=16, halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Data activity indication")) self.im_download = Gtk.Image(icon_name="blueman-down-inactive", pixel_size=16, halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Data activity indication")) self.down_rate = Gtk.Label(halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Total data received and rate of transmission")) self.down_rate.show() self.up_rate = Gtk.Label(halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Total data sent and rate of transmission")) self.up_rate.show() self.uparrow = Gtk.Image(icon_name="go-up", pixel_size=16, halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Total data sent and rate of transmission")) self.downarrow = Gtk.Image(icon_name="go-down", pixel_size=16, halign=Gtk.Align.END, valign=Gtk.Align.CENTER, tooltip_text=_("Total data received and rate of transmission")) self.hbox = hbox = blueman.Builder.get_object("status_activity") hbox.pack_start(self.uparrow, False, False, 0) hbox.pack_start(self.up_rate, False, False, 0) hbox.pack_start(self.downarrow, False, False, 0) hbox.pack_start(self.down_rate, False, False, 0) hbox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), False, False, 0) hbox.pack_start(self.im_upload, False, False, 0) hbox.pack_start(self.im_download, False, False, 0) hbox.show_all() self.on_adapter_changed(blueman.List, blueman.List.get_adapter_path()) self.up_blinker = Animation(self.im_upload, ["blueman-up-inactive", "blueman-up-active"]) self.down_blinker = Animation(self.im_download, ["blueman-down-inactive", "blueman-down-active"]) self.start_update()
def __init__(self, blueman): blueman.List.connect("adapter-changed", self.on_adapter_changed) if blueman.List.Adapter: self.hci = adapter_path_to_name(blueman.List.Adapter.get_object_path()) else: self.hci = None self.time = None self.up_speed = SpeedCalc() self.down_speed = SpeedCalc() up = get_icon("blueman-up-inactive", 15) down = get_icon("blueman-down-inactive", 15) self.im_upload = Gtk.Image() self.im_upload.set_tooltip_text(_("Data activity indication")) self.im_upload.set_from_pixbuf(up) self.im_download = Gtk.Image() self.im_download.set_tooltip_text(_("Data activity indication")) self.im_download.set_from_pixbuf(down) self.im_upload.props.halign = Gtk.Align.END self.im_upload.props.valign = Gtk.Align.CENTER self.im_download.props.halign = Gtk.Align.END self.im_download.props.valign = Gtk.Align.CENTER self.down_rate = Gtk.Label() self.down_rate.show() self.down_rate.props.halign = Gtk.Align.END self.down_rate.props.valign = Gtk.Align.CENTER self.down_rate.set_tooltip_text(_("Total data received and rate of transmission")) self.up_rate = Gtk.Label() self.up_rate.show() self.up_rate.props.halign = Gtk.Align.END self.up_rate.props.valign = Gtk.Align.CENTER self.up_rate.set_tooltip_text(_("Total data sent and rate of transmission")) self.uparrow = Gtk.Image() self.uparrow.set_tooltip_text(_("Total data sent and rate of transmission")) self.uparrow.set_from_icon_name("go-up", 1) self.uparrow.props.halign = Gtk.Align.END self.uparrow.props.valign = Gtk.Align.CENTER self.downarrow = Gtk.Image() self.downarrow.set_tooltip_text(_("Total data received and rate of transmission")) self.downarrow.set_from_icon_name("go-down", 1) self.hbox = hbox = blueman.Builder.get_object("status_activity") hbox.pack_start(self.uparrow, True, False, 0) hbox.pack_start(self.up_rate, False, False, 0) hbox.pack_start(self.downarrow, False, False, 0) hbox.pack_start(self.down_rate, False, False, 0) hbox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), False, False, 0) hbox.pack_start(self.im_upload, False, False, 0) hbox.pack_start(self.im_download, False, False, 0) hbox.show_all() self.on_adapter_changed(blueman.List, blueman.List.GetAdapterPath()) self.up_blinker = Animation(self.im_upload, [get_icon("blueman-up-inactive", 15), get_icon("blueman-up-active", 15)]) #self.down_blinker = Animation(self.im_download, ["/down_inactive.png", "/down_active.png"]) self.down_blinker = Animation(self.im_download, [get_icon("blueman-down-inactive", 16), get_icon("blueman-down-active", 16)]) self.start_update()
def on_adapter_selected(self, menuitem, adapter_path): if menuitem.props.active: if adapter_path != self.blueman.List.Adapter.GetObjectPath(): dprint("selected", adapter_path) self.blueman.Config.props.last_adapter = adapter_path_to_name(adapter_path) self.blueman.List.SetAdapter(adapter_path)
def __init__(self, blueman): blueman.List.connect("adapter-changed", self.on_adapter_changed) if blueman.List.Adapter: self.hci = adapter_path_to_name( blueman.List.Adapter.GetObjectPath()) else: self.hci = None self.time = None self.up_speed = SpeedCalc() self.down_speed = SpeedCalc() up = get_icon("blueman-up-inactive", 15) down = get_icon("blueman-down-inactive", 15) self.im_upload = gtk.Image() self.im_upload.set_tooltip_text(_("Data activity indication")) self.im_upload.set_from_pixbuf(up) self.im_download = gtk.Image() self.im_download.set_tooltip_text(_("Data activity indication")) self.im_download.set_from_pixbuf(down) self.im_upload.set_alignment(1, 0.5) self.im_download.set_alignment(1, 0.5) self.down_rate = gtk.Label() self.down_rate.show() self.down_rate.set_alignment(1, 0.5) self.down_rate.set_tooltip_text( _("Total data received and rate of transmission")) self.up_rate = gtk.Label() self.up_rate.show() self.up_rate.set_alignment(1, 0.5) self.up_rate.set_tooltip_text( _("Total data sent and rate of transmission")) self.uparrow = gtk.Image() self.uparrow.set_tooltip_text( _("Total data sent and rate of transmission")) self.uparrow.set_from_stock(gtk.STOCK_GO_UP, 1) self.uparrow.set_alignment(1, 0.5) self.downarrow = gtk.Image() self.downarrow.set_tooltip_text( _("Total data received and rate of transmission")) self.downarrow.set_from_stock(gtk.STOCK_GO_DOWN, 1) self.hbox = hbox = blueman.Builder.get_object("statusbar2") hbox.pack_start(self.uparrow, True, False) hbox.pack_start(self.up_rate, False, False) hbox.pack_start(self.downarrow, False, False) hbox.pack_start(self.down_rate, False, False) hbox.pack_start(gtk.VSeparator(), False, False) hbox.pack_start(self.im_upload, False, False) hbox.pack_start(self.im_download, False, False) hbox.show_all() self.on_adapter_changed(blueman.List, blueman.List.GetAdapterPath()) self.up_blinker = Animation(self.im_upload, [ get_icon("blueman-up-inactive", 15), get_icon("blueman-up-active", 15) ]) #self.down_blinker = Animation(self.im_download, ["/down_inactive.png", "/down_active.png"]) self.down_blinker = Animation(self.im_download, [ get_icon("blueman-down-inactive", 16), get_icon("blueman-down-active", 16) ]) self.start_update()
def on_adapter_selected(self, menuitem, adapter_path): if menuitem.props.active: if adapter_path != self.blueman.List.Adapter.get_object_path(): logging.info("selected %s", adapter_path) self.blueman.Config["last-adapter"] = adapter_path_to_name(adapter_path) self.blueman.List.set_adapter(adapter_path)
def __init__(self, blueman): blueman.List.connect("adapter-changed", self.on_adapter_changed) if blueman.List.Adapter: self.hci = adapter_path_to_name(blueman.List.Adapter.get_object_path()) else: self.hci = None self.time = None self.up_speed = SpeedCalc() self.down_speed = SpeedCalc() up = get_icon("blueman-up-inactive", 15) down = get_icon("blueman-down-inactive", 15) self.im_upload = Gtk.Image() self.im_upload.set_tooltip_text(_("Data activity indication")) self.im_upload.set_from_pixbuf(up) self.im_download = Gtk.Image() self.im_download.set_tooltip_text(_("Data activity indication")) self.im_download.set_from_pixbuf(down) self.im_upload.set_alignment(1, 0.5) self.im_download.set_alignment(1, 0.5) self.down_rate = Gtk.Label() self.down_rate.show() self.down_rate.set_alignment(1, 0.5) self.down_rate.set_tooltip_text(_("Total data received and rate of transmission")) self.up_rate = Gtk.Label() self.up_rate.show() self.up_rate.set_alignment(1, 0.5) self.up_rate.set_tooltip_text(_("Total data sent and rate of transmission")) self.uparrow = Gtk.Image() self.uparrow.set_tooltip_text(_("Total data sent and rate of transmission")) self.uparrow.set_from_icon_name("go-up", 1) self.uparrow.set_alignment(1, 0.5) self.downarrow = Gtk.Image() self.downarrow.set_tooltip_text(_("Total data received and rate of transmission")) self.downarrow.set_from_icon_name("go-down", 1) self.hbox = hbox = blueman.Builder.get_object("statusbar2") hbox.pack_start(self.uparrow, True, False, 0) hbox.pack_start(self.up_rate, False, False, 0) hbox.pack_start(self.downarrow, False, False, 0) hbox.pack_start(self.down_rate, False, False, 0) hbox.pack_start(Gtk.VSeparator(), False, False, 0) hbox.pack_start(self.im_upload, False, False, 0) hbox.pack_start(self.im_download, False, False, 0) hbox.show_all() self.on_adapter_changed(blueman.List, blueman.List.GetAdapterPath()) self.up_blinker = Animation(self.im_upload, [get_icon("blueman-up-inactive", 15), get_icon("blueman-up-active", 15)]) #self.down_blinker = Animation(self.im_download, ["/down_inactive.png", "/down_active.png"]) self.down_blinker = Animation(self.im_download, [get_icon("blueman-down-inactive", 16), get_icon("blueman-down-active", 16)]) self.start_update()