import gobject
import gtk

GTK_GRAB = 3
GTK_UNGRAB = 4
STATE_CHANGED = 5

def enter(b, event):
    if event.mode in [GTK_GRAB, GTK_UNGRAB, STATE_CHANGED]:
        return
    print b.get_name(), int(event.state), event.type.value_nick, event.detail.value_nick, event.mode.value_nick

def flash(widget):
    widget.set_sensitive(not widget.flags() & gtk.SENSITIVE)
    widget.set_sensitive(not widget.flags() & gtk.SENSITIVE)
    return True

w = gtk.Window()
w.set_name('W')
w.connect('delete-event', gtk.main_quit)
w.set_border_width(6)
hbox = gtk.HBox()
w.add(hbox)

b1 = gtk.Button("A")
b1.set_name('A')
hbox.add(b1)

l = gtk.Label("B")
l.set_name('B')
hbox.add(l)

b2 = gtk.Button("C")
b2.set_name('C')
hbox.add(b2)

w.connect('enter-notify-event', enter)
w.connect('leave-notify-event', enter)
b1.connect('enter-notify-event', enter)
b1.connect('leave-notify-event', enter)
b2.connect('enter-notify-event', enter)
b2.connect('leave-notify-event', enter)

gobject.timeout_add(100, flash, b2)
gobject.timeout_add(100, flash, b1)

w.show_all()

gtk.main()
