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 set_blinker_by_speed(self, blinker: Animation, speed: float) -> None: if speed > 0 and not blinker.status(): blinker.start() if speed > 40 * 1024 and blinker.status(): blinker.set_rate(10) elif speed > (30 * 1024) and blinker.status(): blinker.set_rate(8) elif speed > (20 * 1024) and blinker.status(): blinker.set_rate(6) elif speed > (10 * 1024) and blinker.status(): blinker.set_rate(4) elif speed > 1024 and blinker.status(): blinker.set_rate(2) elif speed == 0 and blinker.status(): blinker.stop() else: blinker.set_rate(1)
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 __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()