12
12
# You should have received a copy of the GNU General Public License
13
13
# along with this program; if not, write to the Free Software
14
14
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
34
34
from os import unlink
35
35
from os.path import isfile
36
36
from distutils.spawn import find_executable
39
GObject as OriginalGObject, \
40
property as gproperty, \
44
37
from socket import gethostname
39
from gobject import GObject as OriginalGObject
40
from gobject import property as gproperty
41
from gobject import list_properties, GObjectMeta
46
43
_ = lambda message: gettext.dgettext("lottanzb", message)
48
45
# Initializes the use of Python threading in the gobject module
110
107
value = str(value)
112
OriginalGObject.set_property(self, key, value)
114
# Notify registered proxies that the model has changed.
115
if self._v_autonotify:
116
self.notify_proxies(key)
109
old_value = self.get_property(key)
111
if old_value != value:
112
OriginalGObject.set_property(self, key, value)
114
# Notify registered proxies that the model has changed.
115
if self._v_autonotify:
116
self.notify_proxies(key)
119
119
return [prop.name.replace("-", "_") for prop in list_properties(self)]
346
346
def setup_kiwi_conversion():
347
347
libgladeloader.LibgladeWidgetTree = KiwifiedLibgladeWidgetTree
349
class _TimerBase(GObject):
351
Helper class for Timer.
354
stopped = gproperty(type=bool, default=True)
358
def __init__(self, timeout):
359
GObject.__init__(self)
361
self.timeout = timeout
365
Stop the emission of the 'tick' signal.
373
Start the regulary emission of the 'tick' signal.
375
The Times class ensures thanks to the _TimerSequence helper class,
376
that it will exactly take the specific amount of time after this
377
method is invoked until the 'tick' signal is emitted.
383
class _TimerSequence(_TimerBase):
385
Helper class for Timer.
390
This is where the gobject.timeout_add is actually called.
393
_TimerBase.start(self)
395
gobject.timeout_add(self.timeout, self.on_gobject_timeout)
397
def on_gobject_timeout(self):
405
class Timer(_TimerBase):
407
Wrapper for gobject.timeout_add, which is more object-oriented and
408
which provides the two convenient methods 'start' and 'stop'.
410
The timeout is the number of milliseconds between two emissions of the
411
'tick' signal. Optionally, it's possible to directly specify a handler
412
like using gobject.timeout_add.
415
def __init__(self, timeout, handler=None, *args):
418
_TimerBase.__init__(self, timeout)
420
if callable(handler):
421
self.connect("tick", handler, *args)
423
self.connect("notify::stopped", self.on_state_changed)
425
def on_state_changed(self, *args):
426
for sequence in self._sequences:
430
sequence = _TimerSequence(self.timeout)
431
sequence.connect("tick", self.on_sequence_tick)
434
self._sequences.append(sequence)
436
def on_sequence_tick(self, *args):
349
439
# From http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/498171