summaryrefslogtreecommitdiff
path: root/efl/ecore/efl.ecore_timer.pxi
diff options
context:
space:
mode:
Diffstat (limited to 'efl/ecore/efl.ecore_timer.pxi')
-rw-r--r--efl/ecore/efl.ecore_timer.pxi91
1 files changed, 91 insertions, 0 deletions
diff --git a/efl/ecore/efl.ecore_timer.pxi b/efl/ecore/efl.ecore_timer.pxi
new file mode 100644
index 0000000..5c2b701
--- /dev/null
+++ b/efl/ecore/efl.ecore_timer.pxi
@@ -0,0 +1,91 @@
1# Copyright (C) 2007-2013 Gustavo Sverzut Barbieri, Ulisses Furquim
2#
3# This file is part of Python-Ecore.
4#
5# Python-Ecore is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# Python-Ecore is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-Ecore. If not, see <http://www.gnu.org/licenses/>.
17
18# This file is included verbatim by efl.ecore.pyx
19
20
21cdef class Timer(Eo):
22 def __init__(self, double interval, func, *args, **kargs):
23 if not callable(func):
24 raise TypeError("Parameter 'func' must be callable")
25 self.func = func
26 self.args = args
27 self.kargs = kargs
28 self._set_obj(ecore_timer_add(interval, _ecore_task_cb, <void *>self))
29
30 def __str__(self):
31 return "%s Timer(func=%s, args=%s, kargs=%s)" % (Eo.__str__(self),
32 self.func, self.args, self.kargs)
33
34 def __repr__(self):
35 return "%s Timer(interval=%f, func=%s, args=%s, kargs=%s)" % (Eo.__repr__(self),
36 self.interval if self.obj else -1.0,
37 self.func, self.args, self.kargs)
38
39 cpdef object _task_exec(self):
40 return self.func(*self.args, **self.kargs)
41
42 def delete(self):
43 ecore_timer_del(self.obj)
44
45 def stop(self):
46 self.delete()
47
48 def freeze(self):
49 ecore_timer_freeze(self.obj)
50
51 def thaw(self):
52 ecore_timer_thaw(self.obj)
53
54 def interval_set(self, double t):
55 ecore_timer_interval_set(self.obj, t)
56
57 def interval_get(self):
58 return ecore_timer_interval_get(self.obj)
59
60 property interval:
61 def __get__(self):
62 return ecore_timer_interval_get(self.obj)
63
64 def __set__(self, double t):
65 ecore_timer_interval_set(self.obj, t)
66
67 def delay(self, double add):
68 ecore_timer_delay(self.obj, add)
69
70 def reset(self):
71 ecore_timer_reset(self.obj)
72
73 def ecore_timer_pending_get(self):
74 ecore_timer_pending_get(self.obj)
75
76 property pending:
77 def __get__(self):
78 return ecore_timer_pending_get(self.obj)
79
80
81def timer_add(double t, func, *args, **kargs):
82 return Timer(t, func, *args, **kargs)
83
84
85def timer_precision_get():
86 return ecore_timer_precision_get()
87
88
89def timer_precision_set(double value):
90 ecore_timer_precision_set(value)
91