summaryrefslogtreecommitdiff
path: root/efl/edje/efl.edje_edit_program.pxi
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2013-04-14 13:08:15 +0200
committerdavemds <dave@gurumeditation.it>2013-04-14 13:08:15 +0200
commit9d85805b13151206df7f285109f71ba272e445a9 (patch)
tree201cb495c8ceeae9b431ceb4d81c8cbf8945652f /efl/edje/efl.edje_edit_program.pxi
parent9c8405ee0ccd5153807b9adf96297ee1994ee8fc (diff)
Python-EFL: Implemented EdjeEdit API, with full unit tests.
Some stuff is not working on the C side, the unit test is full of FIXME and TODO. The biggest problem is the PartState that do not work at all, I will give a short look at this, but I'm not so much intrested atm...If you want/need to help please let me know.
Diffstat (limited to '')
-rw-r--r--efl/edje/efl.edje_edit_program.pxi260
1 files changed, 260 insertions, 0 deletions
diff --git a/efl/edje/efl.edje_edit_program.pxi b/efl/edje/efl.edje_edit_program.pxi
new file mode 100644
index 0000000..acca7e4
--- /dev/null
+++ b/efl/edje/efl.edje_edit_program.pxi
@@ -0,0 +1,260 @@
1# Copyright (C) 2007-2013 various contributors (see AUTHORS)
2#
3# This file is part of Python-EFL.
4#
5# Python-EFL 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-EFL 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-EFL. If not, see <http://www.gnu.org/licenses/>.
17
18
19cdef class Program(object):
20 cdef EdjeEdit edje
21 cdef object name
22
23 def __init__(self, EdjeEdit e, name):
24 if isinstance(name, unicode): name = name.encode("UTF-8")
25 self.edje = e
26 self.name = name
27
28 property name:
29 def __get__(self):
30 return self.name.decode('UTF-8', 'strict')
31
32 def __set__(self, newname):
33 self.rename(newname)
34
35 def rename(self, newname):
36 cdef Eina_Bool ret
37 if isinstance(newname, unicode): newname = newname.encode("UTF-8")
38 ret = edje_edit_program_name_set(self.edje.obj,
39 <const_char *>self.name if self.name is not None else NULL,
40 <const_char *>newname if newname is not None else NULL)
41 if ret == 0:
42 return False
43 self.name = newname
44 return True
45
46 def edje_get(self):
47 return self.edje
48
49 def run(self):
50 return bool(edje_edit_program_run(self.edje.obj,
51 <const_char *>self.name if self.name is not None else NULL))
52
53 # XXX TODO: add (or better convert) all this to properties
54 # like is done in Part()
55 def source_get(self):
56 cdef const_char *s
57 s = edje_edit_program_source_get(self.edje.obj,
58 <const_char *>self.name if self.name is not None else NULL)
59 ret = _ctouni(s)
60 edje_edit_string_free(s)
61 return ret
62
63 def source_set(self, source):
64 if isinstance(source, unicode): source = source.encode("UTF-8")
65 return bool(edje_edit_program_source_set(self.edje.obj,
66 <const_char *>self.name if self.name is not None else NULL,
67 <const_char *>source if source is not None else NULL))
68
69 def signal_get(self):
70 cdef const_char *s
71 s = edje_edit_program_signal_get(self.edje.obj,
72 <const_char *>self.name if self.name is not None else NULL)
73 ret = _ctouni(s)
74 edje_edit_string_free(s)
75 return ret
76
77 def signal_set(self, signal):
78 if isinstance(signal, unicode): signal = signal.encode("UTF-8")
79 return bool(edje_edit_program_signal_set(self.edje.obj,
80 <const_char *>self.name if self.name is not None else NULL,
81 <const_char *>signal if signal is not None else NULL))
82
83 def in_from_get(self):
84 return edje_edit_program_in_from_get(self.edje.obj,
85 <const_char *>self.name if self.name is not None else NULL)
86
87 def in_from_set(self, double f):
88 return bool(edje_edit_program_in_from_set(self.edje.obj,
89 <const_char *>self.name if self.name is not None else NULL, f))
90
91 def in_range_get(self):
92 return edje_edit_program_in_range_get(self.edje.obj,
93 <const_char *>self.name if self.name is not None else NULL)
94
95 def in_range_set(self, double r):
96 return bool(edje_edit_program_in_range_set(self.edje.obj,
97 <const_char *>self.name if self.name is not None else NULL, r))
98
99 def action_get(self):
100 return edje_edit_program_action_get(self.edje.obj,
101 <const_char *>self.name if self.name is not None else NULL)
102
103 def action_set(self, action):
104 if isinstance(action, unicode): action = action.encode("UTF-8")
105 return bool(edje_edit_program_action_set(self.edje.obj,
106 <const_char *>self.name if self.name is not None else NULL,
107 action))
108
109 def targets_get(self):
110 cdef Eina_List *lst
111 lst = edje_edit_program_targets_get(self.edje.obj,
112 <const_char *>self.name if self.name is not None else NULL)
113 ret = convert_eina_list_strings_to_python_list(lst)
114 edje_edit_string_list_free(lst)
115 return ret
116
117 def target_add(self, target):
118 if isinstance(target, unicode): target = target.encode("UTF-8")
119 return bool(edje_edit_program_target_add(self.edje.obj,
120 <const_char *>self.name if self.name is not None else NULL,
121 <const_char *>target if target is not None else NULL))
122
123 def target_del(self, target):
124 if isinstance(target, unicode): target = target.encode("UTF-8")
125 return bool(edje_edit_program_target_del(self.edje.obj,
126 <const_char *>self.name if self.name is not None else NULL,
127 <const_char *>target if target is not None else NULL))
128
129 def targets_clear(self):
130 return bool(edje_edit_program_targets_clear(self.edje.obj,
131 <const_char *>self.name if self.name is not None else NULL))
132
133 def afters_get(self):
134 cdef Eina_List *lst
135 lst = edje_edit_program_afters_get(self.edje.obj, self.name)
136 ret = convert_eina_list_strings_to_python_list(lst)
137 edje_edit_string_list_free(lst)
138 return ret
139
140 def after_add(self, after):
141 if isinstance(after, unicode): after = after.encode("UTF-8")
142 return bool(edje_edit_program_after_add(self.edje.obj,
143 <const_char *>self.name if self.name is not None else NULL,
144 <const_char *>after if after is not None else NULL))
145
146 def after_del(self, after):
147 if isinstance(after, unicode): after = after.encode("UTF-8")
148 return bool(edje_edit_program_after_del(self.edje.obj,
149 <const_char *>self.name if self.name is not None else NULL,
150 <const_char *>after if after is not None else NULL))
151
152 def afters_clear(self):
153 return bool(edje_edit_program_afters_clear(self.edje.obj,
154 <const_char *>self.name if self.name is not None else NULL))
155
156 def state_get(self):
157 cdef const_char *s
158 s = edje_edit_program_state_get(self.edje.obj,
159 <const_char *>self.name if self.name is not None else NULL)
160 ret = _ctouni(s)
161 edje_edit_string_free(s)
162 return ret
163
164 def state_set(self, state):
165 if isinstance(state, unicode): state = state.encode("UTF-8")
166 return bool(edje_edit_program_state_set(self.edje.obj,
167 <const_char *>self.name if self.name is not None else NULL,
168 <const_char *>state if state is not None else NULL))
169
170 def value_get(self):
171 return edje_edit_program_value_get(self.edje.obj,
172 <const_char *>self.name if self.name is not None else NULL)
173
174 def value_set(self, double v):
175 return bool(edje_edit_program_value_set(self.edje.obj,
176 <const_char *>self.name if self.name is not None else NULL, v))
177
178 def state2_get(self):
179 cdef const_char *s
180 s = edje_edit_program_state2_get(self.edje.obj,
181 <const_char *>self.name if self.name is not None else NULL)
182 ret = _ctouni(s)
183 edje_edit_string_free(s)
184 return ret
185
186 def state2_set(self, state):
187 if isinstance(state, unicode): state = state.encode("UTF-8")
188 return bool(edje_edit_program_state2_set(self.edje.obj,
189 <const_char *>self.name if self.name is not None else NULL,
190 <const_char *>state if state is not None else NULL))
191
192 def value2_get(self):
193 return edje_edit_program_value2_get(self.edje.obj,
194 <const_char *>self.name if self.name is not None else NULL)
195
196 def value2_set(self, double v):
197 return bool(edje_edit_program_value2_set(self.edje.obj,
198 <const_char *>self.name if self.name is not None else NULL, v))
199
200 def transition_get(self):
201 return edje_edit_program_transition_get(self.edje.obj,
202 <const_char *>self.name if self.name is not None else NULL)
203
204 def transition_set(self, t):
205 return bool(edje_edit_program_transition_set(self.edje.obj,
206 <const_char *>self.name if self.name is not None else NULL, t))
207
208 def transition_time_get(self):
209 return edje_edit_program_transition_time_get(self.edje.obj,
210 <const_char *>self.name if self.name is not None else NULL)
211
212 def transition_time_set(self, double t):
213 return bool(edje_edit_program_transition_time_set(self.edje.obj,
214 <const_char *>self.name if self.name is not None else NULL, t))
215
216 property api:
217 def __get__(self):
218 cdef:
219 const_char *name
220 const_char *desc
221 name = edje_edit_program_api_name_get(self.edje.obj,
222 <const_char *>self.name if self.name is not None else NULL)
223 desc = edje_edit_program_api_description_get(self.edje.obj,
224 <const_char *>self.name if self.name is not None else NULL)
225 n, d = _ctouni(name), _ctouni(desc)
226 edje_edit_string_free(name)
227 edje_edit_string_free(desc)
228 return (n, d)
229
230 def __set__(self, value):
231 cdef object name, desc
232 name, desc = value
233 if isinstance(name, unicode): name = name.encode("UTF-8")
234 if isinstance(desc, unicode): desc = desc.encode("UTF-8")
235 edje_edit_program_api_name_set(self.edje.obj,
236 <const_char *>self.name if self.name is not None else NULL,
237 <const_char *>name if name is not None else NULL)
238 edje_edit_program_api_description_set(self.edje.obj,
239 <const_char *>self.name if self.name is not None else NULL,
240 <const_char *>desc if desc is not None else NULL)
241
242 property script:
243 def __get__(self):
244 cdef char *code
245 code = edje_edit_script_program_get(self.edje.obj,
246 <const_char *>self.name if self.name is not None else NULL)
247 ret = _touni(code)
248 free(code)
249 return ret
250
251 def __set__(self, code):
252 if isinstance(code, unicode): code = code.encode("UTF-8")
253 edje_edit_script_program_set(self.edje.obj,
254 <const_char *>self.name if self.name is not None else NULL,
255 <const_char *>code if code is not None else NULL)
256
257 def __del__(self):
258 edje_edit_script_program_set(self.edje.obj,
259 <const_char *>self.name if self.name is not None else NULL, NULL)
260