4 refleak_bug_workaround
= []
6 class Arrow(g
.EventBox
):
7 def __init__(self
, arrow_type
, callback
, data
, time
= 50):
8 g
.EventBox
.__init
__(self
)
9 self
.add_events(g
.gdk
.BUTTON_PRESS_MASK
)
12 self
.callback
= callback
13 self
.arrow_type
= arrow_type
16 self
.arrow
= g
.Arrow(arrow_type
, g
.SHADOW_OUT
)
21 self
.connect('button-press-event', self
.button_press
)
22 self
.connect('button-release-event', self
.button_release
)
24 self
.connect('enter-notify-event',
25 lambda w
, e
: self
.set_state(g
.STATE_PRELIGHT
))
26 self
.connect('leave-notify-event',
27 lambda w
, e
: self
.set_state(g
.STATE_NORMAL
))
29 self
.connect('destroy', lambda w
: refleak_bug_workaround
.remove(self
))
30 refleak_bug_workaround
.append(self
)
32 def button_press(self
, box
, event
):
33 if self
.button
!= 0 or event
.type != g
.gdk
.BUTTON_PRESS
:
35 self
.button
= event
.button
37 self
.arrow
.set(self
.arrow_type
, g
.SHADOW_IN
)
38 self
.cb
= gobject
.timeout_add(self
.time
* 2 + 300, self
.incr
)
39 self
.incr(resched
= 0)
41 def button_release(self
, box
, event
):
42 if self
.button
!= event
.button
:
46 self
.arrow
.set(self
.arrow_type
, g
.SHADOW_OUT
)
47 gobject
.source_remove(self
.cb
)
49 def incr(self
, resched
= 1):
51 gobject
.source_remove(self
.cb
)
52 self
.cb
= gobject
.timeout_add(self
.time
, self
.incr
)
53 self
.callback(self
.data
)