#!/usr/bin/python
import gobject
from gi.repository import Gio, GLib

name = 'de.piware.example'

def on_bus_acquired(con, name, user_data):
    print 'on_bus_acquired', con, name, user_data

def on_name_acquired(con, name, user_data):
    print 'on_name_acquired', con, name, user_data

def on_name_lost(con, name, user_data):
    print 'on_name_lost', con, name, user_data

owner_id = Gio.bus_own_name(Gio.BusType.SESSION, name,
        Gio.BusNameOwnerFlags.ALLOW_REPLACEMENT, on_bus_acquired,
        on_name_acquired, on_name_lost)

mainloop = gobject.MainLoop()
mainloop.run()
Gio.bus_unown_name(owner_id)
