4 __copyright__
= "Copyright (c) 2002-2005 Free Software Foundation, Inc."
6 Straw is free software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the Free Software
8 Foundation; either version 2 of the License, or (at your option) any later
11 Straw is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 Place - Suite 330, Boston, MA 02111-1307, USA. """
25 class ValueMonitor(object):
26 def __init__(self
, current
, timeout
, notify
, data
):
27 self
._previous
_value
= current
29 self
._timeout
= timeout
32 self
._connected
= True
33 self
._value
_changed
= False
38 def set_value(self
, value
):
40 if value
!= self
._value
:
41 self
._value
_changed
= True
42 gobject
.timeout_add(self
._timeout
, self
._check
_value
)
45 value
= property(get_value
, set_value
)
48 self
._connected
= True
52 self
._connected
= False
57 def _check_value(self
):
58 if (self
._connected
and self
._value
_changed
and self
.value
!= self
._previous
_value
):
59 self
._notify
(self
.value
, self
._data
)
60 self
._previous
_value
= self
.value
62 def create_for_gtkentry(widget
, timeout
, notify
):
63 vm
= ValueMonitor(widget
.get_text(), timeout
, notify
, widget
)
64 def changed(object, *data
):
65 vm
.value
= object.get_text()
66 widget
.connect("changed", changed
)
69 def create_for_gtkspin(widget
, timeout
, notify
):
70 vm
= ValueMonitor(widget
.get_value_as_int
, timeout
, notify
, widget
)
71 def changed(object, *data
):
72 vm
.value
= object.get_value_as_int()
73 widget
.connect("value-changed", changed
)