# Buggy code
def on_item_activated(self, item):
    logging.info("Connect %s %s" % (item["address"], item["uuid"]))

    item["mitem"]["sensitive"] = False
    self.parent.Plugins.Menu.on_menu_changed()

    def reply(*args):
        Notification(
            _("Connected"),
            _("Connected to %s") % item["mitem"]["text"],
            icon_name=item["icon"],
        ).show()
        item["mitem"]["sensitive"] = True
        self.parent.Plugins.Menu.on_menu_changed()

    def err(reason):
        Notification(
            _("Failed to connect"),
            str(reason).split(": ")[-1],
            icon_name="dialog-error",
        ).show()
        item["mitem"]["sensitive"] = True
        self.parent.Plugins.Menu.on_menu_changed()

    self.parent.DbusSvc.connect_service(item["device"], item["uuid"], reply, err)


# Traceback (gi.repository.GLib.Error)
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/blueman/main/indicators/GtkStatusIcon.py", line 19, in <lambda>
    gtk_item.connect('activate', lambda _, idx=index: activate(idx))
  File "/usr/lib/python3.7/site-packages/blueman/main/indicators/GtkStatusIcon.py", line 21, in <lambda>
    gtk_item.set_submenu(build_menu(item['submenu'], lambda subid, idx=index: activate(idx, subid)))
  File "/usr/lib/python3.7/site-packages/blueman/main/Tray.py", line 37, in _activate_menu_item
    return AppletService().ActivateMenuItem('(ai)', indexes)
  File "/usr/lib/python3.7/site-packages/gi/overrides/Gio.py", line 354, in __call__
    None)
gi.repository.GLib.Error: g-dbus-error-quark: GDBus.Error:org.freedesktop.DBus.Error.Failed: Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/blueman/main/DbusService.py", line 124, in _handle_method_call
    ok(method(*args))
  File "/usr/lib/python3.7/site-packages/blueman/plugins/applet/Menu.py", line 144, in _activate_menu_item
    node.callback()
  File "/usr/lib/python3.7/site-packages/blueman/plugins/applet/RecentConns.py", line 216, in <lambda>
    mitem = {"icon_name": item["icon"], "callback": lambda itm=item: self.on_item_activated(itm)}
  File "/usr/lib/python3.7/site-packages/blueman/plugins/applet/RecentConns.py", line 212, in on_item_activated
    self.parent.DbusSvc.connect_service(item["device"], item["uuid"], reply, err)
AttributeError: 'DbusService' object has no attribute 'connect_service'

# Fixed code
def on_item_activated(self, item):
    logging.info("Connect %s %s" % (item["address"], item["uuid"]))

    item["mitem"]["sensitive"] = False
    self.parent.Plugins.Menu.on_menu_changed()

    def reply(*args):
        Notification(
            _("Connected"),
            _("Connected to %s") % item["mitem"]["text"],
            icon_name=item["icon"],
        ).show()
        item["mitem"]["sensitive"] = True
        self.parent.Plugins.Menu.on_menu_changed()

    def err(reason):
        Notification(
            _("Failed to connect"),
            str(reason).split(": ")[-1],
            icon_name="dialog-error",
        ).show()
        item["mitem"]["sensitive"] = True
        self.parent.Plugins.Menu.on_menu_changed()

    self.parent.Plugins.DBusService.connect_service(
        item["device"], item["uuid"], reply, err
    )