Skip to content

Instantly share code, notes, and snippets.

@infirit
Created August 5, 2015 15:53
Show Gist options
  • Save infirit/8d54897d4a09d8091721 to your computer and use it in GitHub Desktop.
Save infirit/8d54897d4a09d8091721 to your computer and use it in GitHub Desktop.
blueman notification test
#!/usr/bin/python
from blueman.gui.Notification import Notification
from blueman.Functions import get_icon
from gi.repository import Gdk, Gtk
class StatusIconMock:
def get_geometry(self):
screen = Gdk.Screen.get_default()
rect = Gdk.Rectangle()
rect.x = rect.y = 100
rect.width = rect.height = 50
return (True, screen, rect, Gtk.Orientation.HORIZONTAL)
def ok():
print ("Ok")
def err():
print ("Err")
def RequestConfirmation(device, passkey, ok, err):
def on_confirm_action(n, action):
if action == "confirm":
ok()
else:
err()
alias = "Test alias"
notify_message = _("Pairing request for:") + "\n%s" % alias
if passkey:
notify_message += "\n" + _("Confirm value for authentication:") + " <b>%s</b>" % passkey
actions = [["confirm", _("Confirm")], ["deny", _("Deny")]]
Notification("Bluetooth", notify_message, 0,
actions, on_confirm_action, pixbuf=get_icon("blueman", 48), status_icon=StatusIconMock())
RequestConfirmation(None, "Test passkey", ok, err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment