summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2016-01-03 18:50:33 +0100
committerDave Andreoli <dave@gurumeditation.it>2016-01-03 18:50:33 +0100
commit17df9e69aa34477574f80e1599eca1721a3e6dfd (patch)
tree5121497fff492eaee93e43cf2187d6ef456b88de
parent93d2c010025795923feff53317775910876bfd1d (diff)
Revamp old and broken EthumbClient module
This was not functional at all, so I broke the API "a bit"
-rw-r--r--doc/ethumb/class-ethumb_client.rst6
-rw-r--r--doc/ethumb/ethumb.rst1
-rw-r--r--doc/ethumb/module-ethumb.rst14
-rw-r--r--doc/ethumb/module-ethumb_client.rst3
-rw-r--r--efl/ethumb/efl.ethumb.pyx14
-rw-r--r--efl/ethumb/efl.ethumb_client.pyx835
-rwxr-xr-xexamples/ethumb/ethumb_client.py110
-rw-r--r--include/efl.ethumb_client.pxd52
-rwxr-xr-xsetup.py5
9 files changed, 651 insertions, 389 deletions
diff --git a/doc/ethumb/class-ethumb_client.rst b/doc/ethumb/class-ethumb_client.rst
new file mode 100644
index 0000000..71f4d60
--- /dev/null
+++ b/doc/ethumb/class-ethumb_client.rst
@@ -0,0 +1,6 @@
1.. currentmodule:: efl.ethumb_client
2
3:class:`efl.ethumb_client.EthumbClient` Class
4=============================================
5
6.. autoclass:: efl.ethumb_client.EthumbClient
diff --git a/doc/ethumb/ethumb.rst b/doc/ethumb/ethumb.rst
index 9f33fe0..35e19f8 100644
--- a/doc/ethumb/ethumb.rst
+++ b/doc/ethumb/ethumb.rst
@@ -44,6 +44,7 @@ API Reference
44 :titlesonly: 44 :titlesonly:
45 45
46 module-ethumb.rst 46 module-ethumb.rst
47 module-ethumb_client.rst
47 48
48 49
49Inheritance diagram 50Inheritance diagram
diff --git a/doc/ethumb/module-ethumb.rst b/doc/ethumb/module-ethumb.rst
index 2891d11..eb94bea 100644
--- a/doc/ethumb/module-ethumb.rst
+++ b/doc/ethumb/module-ethumb.rst
@@ -1,11 +1,3 @@
1diff --git doc/ethumb/ethumb_module.rst doc/ethumb/ethumb_module.rst 1
2deleted file mode 100644 2.. automodule:: efl.ethumb
3index a7189f9..0000000 3 :exclude-members: Ethumb
4--- doc/ethumb/ethumb_module.rst
5+++ /dev/null
6@@ -1,5 +0,0 @@
7-:mod:`efl.ethumb` Module
8-========================
9-
10-.. automodule:: efl.ethumb
11- :exclude-members: PyEthumb
diff --git a/doc/ethumb/module-ethumb_client.rst b/doc/ethumb/module-ethumb_client.rst
new file mode 100644
index 0000000..81f64c7
--- /dev/null
+++ b/doc/ethumb/module-ethumb_client.rst
@@ -0,0 +1,3 @@
1
2.. automodule:: efl.ethumb_client
3 :exclude-members: EthumbClient
diff --git a/efl/ethumb/efl.ethumb.pyx b/efl/ethumb/efl.ethumb.pyx
index d9f3d5b..6cc6ce8 100644
--- a/efl/ethumb/efl.ethumb.pyx
+++ b/efl/ethumb/efl.ethumb.pyx
@@ -338,7 +338,7 @@ cdef class Ethumb(object):
338 const char *group 338 const char *group
339 const char *swallow 339 const char *swallow
340 ethumb_frame_get(self.obj, &theme, &group, &swallow) 340 ethumb_frame_get(self.obj, &theme, &group, &swallow)
341 return tuple(_ctouni(theme), _ctouni(group), _ctouni(swallow)) 341 return _ctouni(theme), _ctouni(group), _ctouni(swallow)
342 342
343 # destination thumb properties 343 # destination thumb properties
344 property thumb_path: 344 property thumb_path:
@@ -412,9 +412,7 @@ cdef class Ethumb(object):
412 <const char *>cat if cat is not None else NULL) 412 <const char *>cat if cat is not None else NULL)
413 413
414 def __get__(self): 414 def __get__(self):
415 cdef const char *cat 415 return _ctouni(ethumb_thumb_category_get(self.obj))
416 cat = ethumb_thumb_category_get(self.obj)
417 return _ctouni(cat)
418 416
419 property thumb_fdo: 417 property thumb_fdo:
420 """ Set a standard FDO thumbnail size 418 """ Set a standard FDO thumbnail size
@@ -441,11 +439,9 @@ cdef class Ethumb(object):
441 ethumb_thumb_size_set(self.obj, w, h) 439 ethumb_thumb_size_set(self.obj, w, h)
442 440
443 def __get__(self): 441 def __get__(self):
444 cdef: 442 cdef int w, h
445 int w
446 int h
447 ethumb_thumb_size_get(self.obj, &w, &h) 443 ethumb_thumb_size_get(self.obj, &w, &h)
448 return tuple(w, h) 444 return w, h
449 445
450 property thumb_format: 446 property thumb_format:
451 """ The fileformat for the thumbnails. 447 """ The fileformat for the thumbnails.
@@ -511,7 +507,7 @@ cdef class Ethumb(object):
511 float x 507 float x
512 float y 508 float y
513 ethumb_thumb_crop_align_get(self.obj, &x, &y) 509 ethumb_thumb_crop_align_get(self.obj, &x, &y)
514 return tuple(x, y) 510 return x, y
515 511
516 property thumb_quality: 512 property thumb_quality:
517 """ The thumbnail compression quality. 513 """ The thumbnail compression quality.
diff --git a/efl/ethumb/efl.ethumb_client.pyx b/efl/ethumb/efl.ethumb_client.pyx
index 569a176..f36132c 100644
--- a/efl/ethumb/efl.ethumb_client.pyx
+++ b/efl/ethumb/efl.ethumb_client.pyx
@@ -14,19 +14,132 @@
14# 14#
15# You should have received a copy of the GNU Lesser General Public License 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/>. 16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
17"""
17 18
18from cpython cimport Py_INCREF, Py_DECREF 19:mod:`efl.ethumb_client` Module
20###############################
21
22
23Classes
24=======
25
26.. toctree::
27
28 class-ethumb_client.rst
29
30
31Enumerations
32============
33
34.. _Ethumb_Client_Thumb_FDO_Size:
35
36Ethumb_Thumb_FDO_Size
37---------------------
38
39.. data:: ETHUMB_THUMB_NORMAL
40
41 128x128 as defined by FreeDesktop.Org standard
42
43.. data:: ETHUMB_THUMB_LARGE
44
45 256x256 as defined by FreeDesktop.Org standard
46
47
48.. _Ethumb_Client_Thumb_Format:
49
50Ethumb_Thumb_Format
51-------------------
52
53.. data:: ETHUMB_THUMB_FDO
54
55 PNG as defined by FreeDesktop.Org standard.
56
57.. data:: ETHUMB_THUMB_JPEG
58
59 JPEGs are often smaller and faster to read/write.
60
61.. data:: ETHUMB_THUMB_EET
62
63 EFL's own storage system, supports key parameter.
64
65
66.. _Ethumb_Client_Thumb_Aspect:
67
68Ethumb_Thumb_Aspect
69-------------------
70
71.. data:: ETHUMB_THUMB_KEEP_ASPECT
72
73 Keep original proportion between width and height
74
75.. data:: ETHUMB_THUMB_IGNORE_ASPECT
76
77 Ignore aspect and foce it to match thumbnail's width and height
78
79.. data:: ETHUMB_THUMB_CROP
80
81 keep aspect but crop (cut) the largest dimension
82
83
84.. _Ethumb_Client_Thumb_Orientation:
85
86Ethumb_Thumb_Orientation
87------------------------
88
89.. data:: ETHUMB_THUMB_ORIENT_NONE
90
91 Keep orientation as pixel data is
92
93.. data:: ETHUMB_THUMB_ROTATE_90_CW
94
95 Rotate 90° clockwise
96
97.. data:: ETHUMB_THUMB_ROTATE_180
98
99 Rotate 180°
100
101.. data:: ETHUMB_THUMB_ROTATE_90_CCW
102
103 Rotate 90° counter-clockwise
104
105.. data:: ETHUMB_THUMB_FLIP_HORIZONTAL
106
107 Flip horizontally
108
109.. data:: ETHUMB_THUMB_FLIP_VERTICAL
110
111 Flip vertically
112
113.. data:: ETHUMB_THUMB_FLIP_TRANSPOSE
114
115 Transpose
116
117.. data:: ETHUMB_THUMB_FLIP_TRANSVERSE
118
119 Transverse
120
121.. data:: ETHUMB_THUMB_ORIENT_ORIGINAL
122
123 Use orientation from metadata (EXIF-only currently)
124
125
126Module level functions
127======================
128
129"""
130
131from cpython cimport Py_INCREF, Py_DECREF, PyUnicode_AsUTF8String
19from libc.stdint cimport uintptr_t 132from libc.stdint cimport uintptr_t
133
20import traceback 134import traceback
135import atexit
21 136
22def shutdown(): 137from efl.utils.conversions cimport _ctouni, _touni
23 ethumb_client_shutdown() 138from efl.ethumb_client cimport Ethumb_Thumb_Orientation
24 139
25def init():
26 return ethumb_client_init()
27 140
28cdef void _connect_cb(void *data, Ethumb_Client *client, Eina_Bool success) with gil: 141cdef void _connect_cb(void *data, Ethumb_Client *client, Eina_Bool success) with gil:
29 cdef Client self = <Client>data 142 cdef EthumbClient self = <EthumbClient>data
30 s = bool(success) 143 s = bool(success)
31 try: 144 try:
32 func, args, kargs = self._on_connect_callback 145 func, args, kargs = self._on_connect_callback
@@ -34,14 +147,8 @@ cdef void _connect_cb(void *data, Ethumb_Client *client, Eina_Bool success) with
34 except Exception: 147 except Exception:
35 traceback.print_exc() 148 traceback.print_exc()
36 149
37 if not s and self.obj != NULL:
38 ethumb_client_disconnect(self.obj)
39 self.obj = NULL
40 self._on_connect_callback = None
41
42
43cdef void _on_server_die_cb(void *data, Ethumb_Client *client) with gil: 150cdef void _on_server_die_cb(void *data, Ethumb_Client *client) with gil:
44 cdef Client self = <Client>data 151 cdef EthumbClient self = <EthumbClient>data
45 if self._on_server_die_callback is not None: 152 if self._on_server_die_callback is not None:
46 try: 153 try:
47 func, args, kargs = self._on_server_die_callback 154 func, args, kargs = self._on_server_die_callback
@@ -49,22 +156,15 @@ cdef void _on_server_die_cb(void *data, Ethumb_Client *client) with gil:
49 except Exception: 156 except Exception:
50 traceback.print_exc() 157 traceback.print_exc()
51 158
52 if self.obj != NULL: 159 self.disconnect()
53 ethumb_client_disconnect(self.obj)
54 self.obj = NULL
55 self._on_server_die_callback = None
56
57 160
58cdef void _generated_cb(void *data, Ethumb_Client *client, int id, const char *file, const char *key, const char *thumb_path, const char *thumb_key, Eina_Bool success) with gil: 161cdef void _generated_cb(void *data, Ethumb_Client *client, int id, const char *file, const char *key, const char *thumb_path, const char *thumb_key, Eina_Bool success) with gil:
59 obj = <object>data 162 obj = <object>data
60 (self, func, args, kargs) = obj 163 (self, func, args, kargs) = obj
61 f = str_from_c(file) 164 status = bool(success != 0)
62 k = str_from_c(key)
63 tp = str_from_c(thumb_path)
64 tk = str_from_c(thumb_key)
65 s = bool(success != 0)
66 try: 165 try:
67 func(self, id, f, k, tp, tk, s, *args, **kargs) 166 func(self, id, _ctouni(file), _ctouni(key), _ctouni(thumb_path),
167 _ctouni(thumb_key), status, *args, **kargs)
68 except Exception: 168 except Exception:
69 traceback.print_exc() 169 traceback.print_exc()
70 170
@@ -75,21 +175,28 @@ cdef void _generated_cb_free_data(void *data) with gil:
75cdef void _thumb_exists_cb(void *data, Ethumb_Client *client, Ethumb_Exists *thread, Eina_Bool exists) with gil: 175cdef void _thumb_exists_cb(void *data, Ethumb_Client *client, Ethumb_Exists *thread, Eina_Bool exists) with gil:
76 #TODO 176 #TODO
77 print("Not implemented") 177 print("Not implemented")
78 #pass
79 178
80cdef char *str_to_c(object s):
81 cdef char *mystr
82 if s is None:
83 mystr = NULL
84 else:
85 mystr = s
86 return mystr
87 179
88cdef object str_from_c(const char *mystr): 180def init():
89 if mystr != NULL: 181 """ Initialize the ethumb_client library.
90 return mystr 182
183 .. note:: You never need to call this function, it is automatically called
184 on module import.
185
186 """
187 return ethumb_client_init()
188
189def shutdown():
190 """ Shutdown the ethumb_client library.
191
192 .. note:: You never need to call this function, it is automatically called
193 at exit.
91 194
92cdef class Client: 195 """
196 ethumb_client_shutdown()
197
198
199cdef class EthumbClient:
93 """ 200 """
94 201
95 Client for Ethumbd server. 202 Client for Ethumbd server.
@@ -99,22 +206,20 @@ cdef class Client:
99 be connected to server, configure thumbnail parameters and then 206 be connected to server, configure thumbnail parameters and then
100 start feed it with file_set(), exists() generate(). Basic steps are: 207 start feed it with file_set(), exists() generate(). Basic steps are:
101 208
102 - instantiate Client, wait for func to be called with success. 209 - instantiate EthumbClient, wait for func to be called with success.
103 - set various parameters, like format and size. 210 - set various parameters, like format and size.
104 - loop on original files: 211 - loop on original files:
105 212
106 - ``c.file_set(file)`` 213 - ``c.file_set(file)``
107 - ``if not c.exists(): c.generate(generated_cb)`` 214 - ``if not c.exists(): c.generate(generated_cb)``
108 215
109 When the last reference to client is released, server is 216 It is recommended explicit call to :py:func:`disconnect` function when
110 automatically disconnected. Since callback may contain references 217 you don't need the thumbnailer anymore.
111 to server itself, it is recommended explicit call to
112 :py:func:`disconnect` function.
113 218
114 """ 219 """
115 220
116 def __init__(self, func, *args, **kargs): 221 def __init__(self, func, *args, **kargs):
117 """Client(...) 222 """ EthumbClient thumbnail generator.
118 223
119 :param func: function to call when connection with server is 224 :param func: function to call when connection with server is
120 established. 225 established.
@@ -147,15 +252,12 @@ cdef class Client:
147 ethumb_client_on_server_die_callback_set( 252 ethumb_client_on_server_die_callback_set(
148 self.obj, _on_server_die_cb, <void*>self, NULL) 253 self.obj, _on_server_die_cb, <void*>self, NULL)
149 254
150 def __dealloc__(self):
151 if self.obj != NULL:
152 ethumb_client_disconnect(self.obj)
153
154 def disconnect(self): 255 def disconnect(self):
155 """Explicitly request server disconnection. 256 """Explicitly request server disconnection.
156 257
157 After this call object becomes shallow, that is operations 258 After this call object becomes shallow, that is operations
158 will be void. 259 will be void.
260
159 """ 261 """
160 if self.obj != NULL: 262 if self.obj != NULL:
161 ethumb_client_disconnect(self.obj) 263 ethumb_client_disconnect(self.obj)
@@ -173,14 +275,13 @@ cdef class Client:
173 if self.aspect == 2: 275 if self.aspect == 2:
174 aspect = "CROP[%f, %f]" % self.crop 276 aspect = "CROP[%f, %f]" % self.crop
175 return ( 277 return (
176 "<%s(obj=%#x, file=(%r, %r), thumb=(%r, %r), exists=%s, " 278 "<%s(obj=%#x, file=(%r, %r), thumb=(%r, %r), "
177 "size=%dx%d, format=%s, aspect=%s, quality=%d, compress=%d, " 279 "size=%dx%d, format=%s, aspect=%s, quality=%d, compress=%d, "
178 "directory=%r, category=%r)>" 280 "dir_path=%r, category=%r)>"
179 ) % ( 281 ) % (
180 type(self).__name__, <uintptr_t><void *>self, f, k, 282 type(self).__name__, <uintptr_t><void *>self, f, k,
181 tf, tk, self.thumb_exists(), 283 tf, tk, w, h, format, aspect, self.quality, self.compress,
182 w, h, format, aspect, self.quality, self.compress, 284 self.dir_path, self.category
183 self.directory, self.category
184 ) 285 )
185 286
186 def on_server_die_callback_set(self, func, *args, **kargs): 287 def on_server_die_callback_set(self, func, *args, **kargs):
@@ -205,72 +306,221 @@ cdef class Client:
205 else: 306 else:
206 raise TypeError("Parameter 'func' must be callable or None") 307 raise TypeError("Parameter 'func' must be callable or None")
207 308
208 def fdo_set(self, int s): 309 def thumb_exists(self, callback=None, *args, **kwargs):
209 """Configure future requests to use FreeDesktop.Org preset. 310 """Checks if thumbnail already exists.
210 311
211 This is a preset to provide freedesktop.org (fdo) standard 312 If you want to avoid regenerating thumbnails, check if they
212 compliant thumbnails. That is, files are stored as JPEG under 313 already exist with this function.
213 ~/.thumbnails/SIZE, with size being either normal (128x128) or
214 large (256x256).
215 314
216 :param s: size identifier, either ETHUMB_THUMB_NORMAL (0) or 315 """
217 ETHUMB_THUMB_LARGE. 316 cdef Ethumb_Client_Thumb_Exists_Cb cb = NULL
317 cdef Ethumb_Exists *res
218 318
219 .. seealso:: :py:func:`size_set`, :py:func:`format_set`, :py:func:`aspect_set`, :py:func:`crop_set`, 319 if callback:
220 :py:func:`category_set`, :py:func:`directory_set`. 320 if not callable(callback):
321 raise TypeError("callback is not callable")
322 cb = _thumb_exists_cb
323
324 data = (args, kwargs)
325 res = ethumb_client_thumb_exists(self.obj, cb, <void *>data)
326
327 return False
328 #TODO: handle return value
329
330 def generate(self, func, *args, **kargs):
331 """Ask EThumb server to generate the specified thumbnail.
332
333 Thumbnail generation is asynchronous and depend on ecore main
334 loop running. Given function will be called back with
335 generation status if True is returned by this call. If False
336 is returned, given function will not be called.
337
338 Existing thumbnails will be overwritten with this call. Check
339 if they already exist with :py:func:`exists` before calling.
340
341 :param func: function to call on generation completion, even
342 if failed or succeeded. Signature is::
343
344 func(self, id, file, key, thumb_path, thumb_key, status, *args, **kargs)
345
346 with status being True for successful generation or
347 False on failure.
348
349 :return: request identifier. Request can be canceled calling
350 :py:func:`cancel` with given id. If an identifier is returned (>=
351 0), then func is guaranteed to be called unless it is
352 explicitly canceled.
353
354 :raise TypeError: if **func** is not callable.
355 :raise SystemError: if could not generate thumbnail, probably
356 no :py:func:`file_set`.
357
358 .. seealso:: :py:func:`cancel`, :py:func:`clear`, :py:func:`exists`
221 """ 359 """
222 ethumb_client_fdo_set(self.obj, s) 360 if not callable(func):
361 raise TypeError("func must be callable")
362
363 targs = (self, func, args, kargs)
364 r = ethumb_client_generate(self.obj, _generated_cb, <void*>targs,
365 _generated_cb_free_data)
366 if r >= 0:
367 Py_INCREF(targs)
368 return r
369 else:
370 raise SystemError("could not generate thumbnail. "
371 "Did you set the file?")
223 372
224 def size_set(self, int w, int h): 373 def generate_cancel(self, int id):
225 """Configure future request to use custom size. 374 """Cancel thumbnail request given its id.
226 375
227 :param w: width, default is 128. 376 Calling this function aborts thumbnail generation and **func**
228 :param h: height, default is 128. 377 given to :py:func:`generate` will not be called!
378
379 :param id: identifier returned by :py:func:`generate`
229 """ 380 """
230 ethumb_client_size_set(self.obj, w, h) 381 ethumb_client_generate_cancel(self.obj, id, NULL, NULL, NULL)
231 382
232 def size_get(self): 383 def generate_cancel_all(self):
233 """Get current size being used by requests. 384 """Clear request queue, canceling all generation requests.
385
386 This will abort all existing requests, no **func** given to
387 :py:func:`generate` will be called.
234 388
235 :rtype: tuple of int. 389 Same as calling :py:func:`cancel` in all exising requests.
236 """ 390 """
237 cdef int w, h 391 ethumb_client_generate_cancel_all(self.obj)
238 ethumb_client_size_get(self.obj, &w, &h)
239 return (w, h)
240 392
241 property size: 393 ## source file setup
394 property file:
395 """ The file to thumbnail.
396
397 This is a tuple of 2 strings: ``path`` and ``key``.
398
399 For convenience you can also assign a single string value (``path``),
400 ignoring the key.
401
402 :type: **str** or (**str**, **str**)
403
404 :param path: path to thumbnail subject.
405 :param key: path to key inside **path**, this is used to
406 generate thumbnail of edje groups or images inside EET.
407
408 :raise RuntimeError: on failure setting the property
409
410 .. note:: setting this property will reset other thumbnail
411 specifications. This is done to avoid one using the last thumb
412 path for new images.
413
414 """
242 def __set__(self, value): 415 def __set__(self, value):
243 cdef int w, h 416 if isinstance(value, tuple):
244 w, h = value 417 path, key = value
245 self.size_set(w, h) 418 else:
419 path, key = value, None
420 if isinstance(path, unicode): path = PyUnicode_AsUTF8String(path)
421 if isinstance(key, unicode): key = PyUnicode_AsUTF8String(key)
422 if ethumb_client_file_set(self.obj,
423 <const char *>path if path is not None else NULL,
424 <const char *>key if key is not None else NULL) == 0:
425 raise RuntimeError("Cannot set file")
246 426
247 def __get__(self): 427 def __get__(self):
248 return self.size_get() 428 cdef:
429 const char *path
430 const char *key
431 ethumb_client_file_get(self.obj, &path, &key)
432 return (_ctouni(path), _ctouni(key))
433
434 def file_free(self):
435 """Zero/Reset file parameters.
436
437 This call will reset file and thumb specifications.
438
439 .. seealso:: :py:func:`file_set` and :py:func:`thumb_set`
440 """
441 ethumb_client_file_free(self.obj)
442
443 property frame:
444 """ The optional edje file used to generate a frame around the thumbnail
445
446 This will create an edje object that will have image swallowed
447 in. This can be used to simulate Polaroid or wood frames in
448 the generated image. Remember it is bad to modify the original
449 contents of thumbnails, but sometimes it's useful to have it
450 composited and avoid runtime overhead.
249 451
250 def format_set(self, int f): 452 :type: (**str**, **str**, **str**) **writeonly**
251 """Configure format to use for future requests. 453
454 :param file: file path to edje.
455 :param group: group inside edje to use.
456 :param swallow: name of swallow part.
457
458 :raise RuntimeError: on failure setting the property
252 459
253 :param f: format identifier to use, either ETHUMB_THUMB_FDO (0),
254 ETHUMB_THUMB_JPEG (1) or ETHUMB_THUMB_EET (2). Default is FDO.
255 """ 460 """
256 ethumb_client_format_set(self.obj, f) 461 def __set__(self, tuple value):
462 theme, group, swallow = value
463 if isinstance(theme, unicode): theme = PyUnicode_AsUTF8String(theme)
464 if isinstance(group, unicode): group = PyUnicode_AsUTF8String(group)
465 if isinstance(swallow, unicode): swallow = PyUnicode_AsUTF8String(swallow)
466 if ethumb_client_frame_set(self.obj,
467 <const char *>theme if theme is not None else NULL,
468 <const char *>group if group is not None else NULL,
469 <const char *>swallow if swallow is not None else NULL) == 0:
470 raise RuntimeError("Cannot set frame")
471
472 ## fine tune setup
473 property fdo:
474 """ Configure future requests to use FreeDesktop.Org preset.
475
476 This is a preset to provide freedesktop.org (fdo) standard
477 compliant thumbnails. That is, files are stored as JPEG under
478 ~/.thumbnails/SIZE, with size being either normal (128x128) or
479 large (256x256).
480
481 :type: :ref:`Ethumb_Client_Thumb_FDO_Size` **writeonly**
257 482
258 def format_get(self): 483 .. seealso:: :attr:`size`, :attr:`format`, :attr:`aspect`,
259 """Get current format in use for requests. 484 :attr:`crop_align`, :attr:`category`, :attr:`dir_path`.
260 485
261 :rtype: int
262 """ 486 """
263 return ethumb_client_format_get(self.obj) 487 def __set__(self, Ethumb_Thumb_FDO_Size value):
488 ethumb_client_fdo_set(self.obj, value)
489
490 property size:
491 """ The (custom) size of thumbnails.
492
493 :type: (int **w**, int **w**)
494
495 :param w: width, default is 128.
496 :param h: height, default is 128.
497
498 """
499 def __set__(self, tuple value):
500 w, h = value
501 ethumb_client_size_set(self.obj, w, h)
502
503 def __get__(self):
504 cdef int w, h
505 ethumb_client_size_get(self.obj, &w, &h)
506 return w, h
264 507
265 property format: 508 property format:
266 def __set__(self, value): 509 """ The fileformat for the thumbnails.
267 self.format_set(value) 510
511 Thumbnails are compressed; possible formats are PNG, JPEG and EET.
512
513 :type: :ref:`Ethumb_Client_Thumb_Format`
514
515 """
516 def __set__(self, Ethumb_Thumb_Format value):
517 ethumb_client_format_set(self.obj, value)
268 518
269 def __get__(self): 519 def __get__(self):
270 return self.format_get() 520 return ethumb_client_format_get(self.obj)
271 521
272 def aspect_set(self, int a): 522 property aspect:
273 """Configure aspect mode to use. 523 """ The aspect ratio policy.
274 524
275 If aspect is kept (ETHUMB_THUMB_KEEP_ASPECT), then image will 525 If aspect is kept (ETHUMB_THUMB_KEEP_ASPECT), then image will
276 be rescaled so the largest dimension is not bigger than it's 526 be rescaled so the largest dimension is not bigger than it's
@@ -294,361 +544,216 @@ cdef class Client:
294 just the 500x500 central pixels of image will be considered 544 just the 500x500 central pixels of image will be considered
295 for scaling. 545 for scaling.
296 546
297 :param a: aspect mode identifier, either ETHUMB_THUMB_KEEP_ASPECT (0), 547 :type: :ref:`Ethumb_Client_Thumb_Aspect`
298 ETHUMB_THUMB_IGNORE_ASPECT (1) or ETHUMB_THUMB_CROP (2).
299 548
300 """ 549 """
301 ethumb_client_aspect_set(self.obj, a) 550 def __set__(self, Ethumb_Thumb_Aspect value):
551 ethumb_client_aspect_set(self.obj, value)
302 552
303 def aspect_get(self): 553 def __get__(self):
304 """Get current aspect in use for requests. 554 return ethumb_client_aspect_get(self.obj)
305 555
306 :rtype: int 556 property orientation:
307 """ 557 """ The thumbnail rotation or flip.
308 return ethumb_client_aspect_get(self.obj)
309 558
310 property aspect: 559 :type: :ref:`Ethumb_Client_Thumb_Orientation`
311 def __set__(self, value): 560
312 self.aspect_set(value) 561 """
562 def __set__(self, Ethumb_Thumb_Orientation value):
563 ethumb_client_orientation_set(self.obj, value)
313 564
314 def __get__(self): 565 def __get__(self):
315 return self.aspect_get() 566 return ethumb_client_orientation_get(self.obj)
316 567
317 def crop_set(self, float x, float y): 568 property crop_align:
318 """Configure crop alignment in use for future requests. 569 """ Crop alignment in use.
319 570
320 :param x: horizontal alignment. 0.0 means left side will be 571 :param x: horizontal alignment. 0.0 means left side will be
321 visible or right side is being lost. 1.0 means right 572 visible or right side is being lost. 1.0 means right side
322 side will be visible or left side is being lost. 0.5 573 will be visible or left side is being lost. 0.5 means just
323 means just center is visible, both sides will be lost. 574 center is visible, both sides will be lost. Default is 0.5.
324 Default is 0.5.
325 :param y: vertical alignment. 0.0 is top visible, 1.0 is 575 :param y: vertical alignment. 0.0 is top visible, 1.0 is
326 bottom visible, 0.5 is center visible. Default is 0.5 576 bottom visible, 0.5 is center visible. Default is 0.5
327 """
328 ethumb_client_crop_align_set(self.obj, x, y)
329 577
330 def crop_get(self): 578 :type: (float **x**, float **y**)
331 """Get current crop alignment in use for requests.
332 579
333 :rtype: tuple of float
334 """ 580 """
335 cdef float x, y 581 def __set__(self, tuple value):
336 ethumb_client_crop_align_get(self.obj, &x, &y)
337 return (x, y)
338
339 property crop:
340 def __set__(self, value):
341 cdef float x, y
342 x, y = value 582 x, y = value
343 self.crop_set(x, y) 583 ethumb_client_crop_align_set(self.obj, x, y)
344 584
345 def __get__(self): 585 def __get__(self):
346 return self.crop_get() 586 cdef float x, y
347 587 ethumb_client_crop_align_get(self.obj, &x, &y)
348 def quality_set(self, int quality): 588 return x, y
349 """Configure quality to be used in thumbnails.
350
351 :param quality: value from 0 to 100, default is 80. The
352 effect depends on the format being used, PNG will not
353 use it.
354 """
355 ethumb_client_quality_set(self.obj, quality)
356
357 def quality_get(self):
358 """Get current quality in use for requests.
359
360 :rtype: int
361 """
362 return ethumb_client_quality_get(self.obj)
363 589
364 property quality: 590 property quality:
365 def __set__(self, value): 591 """ The thumbnail compression quality.
366 self.quality_set(value)
367 592
368 def __get__(self): 593 Value from 0 to 100, default is 80. The effect depends on the format
369 return self.quality_get() 594 being used, PNG will not use it.
370 595
371 def compress_set(self, int compress): 596 :type: int
372 """Configure compression level used in requests.
373 597
374 :param compress: value from 0 to 9, default is 9. The effect
375 depends on the format being used, JPEG will not use it.
376 """ 598 """
377 ethumb_client_compress_set(self.obj, compress) 599 def __set__(self, int value):
378 600 ethumb_client_quality_set(self.obj, value)
379 def compress_get(self):
380 """Get current compression level in use for requests.
381
382 :rtype: int
383 """
384 return ethumb_client_compress_get(self.obj)
385
386 property compress:
387 def __set__(self, value):
388 self.compress_set(value)
389 601
390 def __get__(self): 602 def __get__(self):
391 return self.compress_get() 603 return ethumb_client_quality_get(self.obj)
392
393 def directory_set(self, path):
394 """Configure where to store thumbnails in future requests.
395 604
396 Note that this is the base, a category is added to this path 605 property compress:
397 as a sub directory. 606 """ The thumbnail compression rate.
398 607
399 :param path: base directory where to store 608 Value from 0 to 9, default is 9. The effect depends on the format being
400 thumbnails. Default is ~/.thumbnails 609 used, JPEG will not use it.
401 """
402 ethumb_client_dir_path_set(self.obj, str_to_c(path))
403 610
404 def directory_get(self): 611 :type: int
405 """Get current base directory to store thumbnails.
406 612
407 :rtype: str or None
408 """ 613 """
409 return str_from_c(ethumb_client_dir_path_get(self.obj)) 614 def __set__(self, int value):
410 615 ethumb_client_compress_set(self.obj, value)
411 property directory:
412 def __set__(self, value):
413 self.directory_set(value)
414 616
415 def __get__(self): 617 def __get__(self):
416 return self.directory_get() 618 return ethumb_client_compress_get(self.obj)
417 619
418 def category_set(self, category): 620 property dir_path:
419 """Category directory to store thumbnails. 621 """ Configure where to store thumbnails in future requests.
420 622
421 :param category: category sub directory to store 623 This is the base folder, a category folder is added to this path
422 thumbnail. Default is either "normal" or "large" for FDO 624 as a sub directory. Default is ``~/.thumbnails``
423 compliant thumbnails or
424 WIDTHxHEIGHT-ASPECT[-FRAMED]-FORMAT. It can be a string or
425 None to use auto generated names.
426 """
427 ethumb_client_category_set(self.obj, str_to_c(category))
428 625
429 def category_get(self): 626 :type: **str**
430 """Get current category sub directory to store thumbnails.
431 627
432 :rtype: str or None
433 """ 628 """
434 return str_from_c(ethumb_client_category_get(self.obj)) 629 def __set__(self, path):
435 630 if isinstance(path, unicode): path = PyUnicode_AsUTF8String(path)
436 property category: 631 ethumb_client_dir_path_set(self.obj,
437 def __set__(self, value): 632 <const char *>path if path is not None else NULL)
438 self.category_set(value)
439 633
440 def __get__(self): 634 def __get__(self):
441 return self.category_get() 635 cdef const char *path
636 path = ethumb_client_dir_path_get(self.obj)
637 return _ctouni(path)
442 638
443 def frame_set(self, file, group, swallow): 639 property category:
444 """Set frame to apply to future thumbnails. 640 """ Category directory to store thumbnails.
445 641
446 This will create an edje object that will have image swallowed 642 Category sub directory to store thumbnail. Default is either "normal"
447 in. This can be used to simulate Polaroid or wood frames in 643 or "large" for FDO compliant thumbnails or
448 the generated image. Remember it is bad to modify the original 644 ``WIDTHxHEIGHT-ASPECT[-FRAMED]-FORMAT``. It can be a string or None to
449 contents of thumbnails, but sometimes it's useful to have it 645 use auto generated names.
450 composited and avoid runtime overhead.
451 646
452 :param file: file path to edje. 647 :type: **str**
453 :param group: group inside edje to use.
454 :param swallow: name of swallow part.
455 """
456 cdef:
457 char *f
458 char *g
459 char *s
460 f = str_to_c(file)
461 g = str_to_c(group)
462 s = str_to_c(swallow)
463 return ethumb_client_frame_set(self.obj, f, g, s)
464
465 def file_set(self, path, key=None):
466 """Set file to thumbnail.
467
468 Calling this function will zero :py:func:`thumb_set`
469 specifications. This is done to avoid one using the last thumb
470 path for new images.
471 648
472 :param path: path to thumbnail subject.
473 :param key: path to key inside **path**, this is used to
474 generate thumbnail of edje groups or images inside EET.
475 """ 649 """
476 cdef: 650 def __set__(self, cat):
477 char *p 651 if isinstance(cat, unicode): cat = PyUnicode_AsUTF8String(cat)
478 char *k 652 ethumb_client_category_set(self.obj,
479 p = str_to_c(path) 653 <const char *>cat if cat is not None else NULL)
480 k = str_to_c(key)
481 ethumb_client_file_set(self.obj, p, k)
482
483 def file_get(self):
484 """Get current file to thumbnail.
485
486 :rtype: tuple of str
487 """
488 cdef:
489 const char *p
490 const char *k
491 ethumb_client_file_get(self.obj, &p, &k)
492 return (str_from_c(p), str_from_c(k))
493
494 property file:
495 def __set__(self, value):
496 p, k = value
497 self.file_set(p, k)
498 654
499 def __get__(self): 655 def __get__(self):
500 return self.file_get() 656 return _ctouni(ethumb_client_category_get(self.obj))
501 657
502 def file_free(self): 658 property thumb_path:
503 """Zero/Reset file parameters. 659 """ The complete path of the generated thumbnail.
504
505 This call will reset file and thumb specifications.
506 660
507 .. seealso:: :py:func:`file_set` and :py:func:`thumb_set` 661 This is a tuple of 2 strings: ``path`` and ``key``.
508 """
509 ethumb_client_file_free(self.obj)
510 662
511 def thumb_set(self, path, key=None): 663 For convenience you can also assign a single string value (``path``),
512 """Set thumbnail path and key. 664 ignoring the key.
513 665
514 Note that these parameters are forgotten (reset) after 666 :type: **str** or (**str**, **str**)
515 :py:func:`file_set`.
516 667
517 :param path: path to generated thumbnail to use, this is an 668 :param path: path to generated thumbnail to use, this is an
518 absolute path to file, overriding directory and category. 669 absolute path to file, overriding directory and category.
519 :param key: path to key inside **path**, this is used to 670 :param key: path to key inside **path**, this is used to
520 generate thumbnail inside EET files. 671 generate thumbnail inside EET files.
521 """
522 cdef:
523 const char *p
524 const char *k
525 p = str_to_c(path)
526 k = str_to_c(key)
527 ethumb_client_thumb_path_set(self.obj, p, k)
528 672
529 def thumb_get(self):
530 """Get current path and key of thumbnail.
531
532 Note that if no explicit :py:func:`thumb_set` was called, it will
533 auto generate path based on existing parameters such as
534 directory, category and others.
535
536 :rtype: tuple of str
537 """ 673 """
538 cdef:
539 const char *p
540 const char *k
541 ethumb_client_thumb_path_get(self.obj, &p, &k)
542 return (str_from_c(p), str_from_c(k))
543
544 property thumb_path:
545 def __set__(self, value): 674 def __set__(self, value):
546 p, k = value 675 if isinstance(value, tuple):
547 self.thumb_set(p, k) 676 path, key = value
548 def __get__(self): 677 else:
549 return self.thumb_get() 678 path, key = value, None
550 679 if isinstance(path, unicode): path = PyUnicode_AsUTF8String(path)
551 def video_time_set(self, float time): 680 if isinstance(key, unicode): key = PyUnicode_AsUTF8String(key)
552 ethumb_client_video_time_set(self.obj, time) 681 ethumb_client_thumb_path_set(self.obj,
553 682 <const char *>path if path is not None else NULL,
554 def video_start_set(self, float start): 683 <const char *>key if key is not None else NULL)
555 ethumb_client_video_start_set(self.obj, start)
556
557 def video_interval_set(self, float interval):
558 ethumb_client_video_interval_set(self.obj, interval)
559
560 def video_ntimes_set(self, int ntimes):
561 ethumb_client_video_ntimes_set(self.obj, ntimes)
562 684
563 def video_fps_set(self, int fps): 685 def __get__(self):
564 ethumb_client_video_fps_set(self.obj, fps) 686 cdef:
687 const char *path
688 const char *key
689 ethumb_client_thumb_path_get(self.obj, &path, &key)
690 return (_ctouni(path), _ctouni(key))
565 691
566 # document_page 692 ## video setup
567 def document_page_set(self, int page): 693 property video_time:
568 ethumb_client_document_page_set(self.obj, page) 694 """ The video time (duration) in seconds.
569 695
570 def thumb_exists(self, callback = None, *args, **kwargs): 696 :type: float (**readonly**)
571 """Checks if thumbnail already exists.
572
573 If you want to avoid regenerating thumbnails, check if they
574 already exist with this function.
575 697
576 """ 698 """
577 cdef Ethumb_Client_Thumb_Exists_Cb cb = NULL 699 def __set__(self, float value):
578 cdef Ethumb_Exists *res 700 ethumb_client_video_time_set(self.obj, value)
579
580 if callback:
581 if not callable(callback):
582 raise TypeError("callback is not callable")
583 cb = _thumb_exists_cb
584 701
585 data = (args, kwargs) 702 property video_start:
586 res = ethumb_client_thumb_exists(self.obj, cb, <void *>data) 703 """ The start point for video thumbnails.
587 704
588 return False 705 :type: float (from 0.0 to 1.0) (**readonly**)
589 #TODO: handle return value
590 706
591 def generate(self, func, *args, **kargs): 707 """
592 """Ask EThumb server to generate the specified thumbnail. 708 def __set__(self, float value):
593 709 ethumb_client_video_start_set(self.obj, value)
594 Thumbnail generation is asynchronous and depend on ecore main
595 loop running. Given function will be called back with
596 generation status if True is returned by this call. If False
597 is returned, given function will not be called.
598 710
599 Existing thumbnails will be overwritten with this call. Check 711 property video_interval:
600 if they already exist with :py:func:`exists` before calling. 712 """ The video frame interval, in seconds.
601 713
602 :param func: function to call on generation completion, even 714 This is useful for animated thumbnail and will define skip time before
603 if failed or succeeded. Signature is:: 715 going to the next frame.
604 716
605 func(self, id, file, key, thumb_path, thumb_key, status, *args, **kargs) 717 .. note:: that video backends might not be able to
718 precisely skip that amount as it will depend on various
719 factors, including video encoding.
720
721 :type: float (**readonly**)
606 722
607 with status being True for successful generation or 723 """
608 False on failure. 724 def __set__(self, float value):
725 ethumb_client_video_interval_set(self.obj, value)
609 726
610 :return: request identifier. Request can be canceled calling 727 property video_ntimes:
611 :py:func:`cancel` with given id. If an identifier is returned (>= 728 """ The number of times the video loops (if applicable).
612 0), then func is guaranteed to be called unless it is
613 explicitly canceled.
614 729
615 :raise TypeError: if **func** is not callable. 730 :type: int (**readonly**)
616 :raise SystemError: if could not generate thumbnail, probably
617 no :py:func:`file_set`.
618 731
619 .. seealso:: :py:func:`cancel`, :py:func:`clear`, :py:func:`exists`
620 """ 732 """
621 if not callable(func): 733 def __set__(self, int value):
622 raise TypeError("func must be callable") 734 ethumb_client_video_ntimes_set(self.obj, value)
623 735
624 targs = (self, func, args, kargs) 736 property video_fps:
625 r = ethumb_client_generate(self.obj, _generated_cb, <void*>targs, 737 """ The thumbnail framerate.
626 _generated_cb_free_data)
627 if r >= 0:
628 Py_INCREF(targs)
629 return r
630 else:
631 raise SystemError("could not generate thumbnail. "
632 "Did you set the file?")
633 738
634 def generate_cancel(self, int id): 739 Default to 10.
635 """Cancel thumbnail request given its id.
636 740
637 Calling this function aborts thumbnail generation and **func** 741 :type: int (**readonly**)
638 given to :py:func:`generate` will not be called!
639 742
640 :param id: identifier returned by :py:func:`generate`
641 """ 743 """
642 ethumb_client_generate_cancel(self.obj, id, NULL, NULL, NULL) 744 def __set__(self, int value):
745 ethumb_client_video_fps_set(self.obj, value)
643 746
644 def generate_cancel_all(self): 747 ## document setup
645 """Clear request queue, canceling all generation requests. 748 property document_page:
749 """ The page number to thumbnail in paged documents.
646 750
647 This will abort all existing requests, no **func** given to 751 :type: int
648 :py:func:`generate` will be called.
649 752
650 Same as calling :py:func:`cancel` in all exising requests.
651 """ 753 """
652 ethumb_client_generate_cancel_all(self.obj) 754 def __set__(self, int value):
755 ethumb_client_document_page_set(self.obj, value)
756
653 757
654init() 758init()
759atexit.register(shutdown)
diff --git a/examples/ethumb/ethumb_client.py b/examples/ethumb/ethumb_client.py
new file mode 100755
index 0000000..59b788a
--- /dev/null
+++ b/examples/ethumb/ethumb_client.py
@@ -0,0 +1,110 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4import os
5import sys
6import logging
7
8from efl import ecore
9from efl import ethumb_client as ethumb
10
11script_path = os.path.dirname(os.path.abspath(__file__))
12
13
14# parse command line arguments
15if len(sys.argv) != 2:
16 print("Python EthumbClient test application.\n\n" \
17 "usage: ethumb_client.py filename\n")
18 exit(1)
19filename = sys.argv[1]
20print("Original file: %s\n" % filename)
21
22
23# setup efl logging (you also need to set EINA_LOG_LEVEL=X)
24l = logging.getLogger("efl")
25h = logging.StreamHandler()
26h.setFormatter(logging.Formatter("EFL %(levelname)s %(message)s"))
27l.addHandler(h)
28l.setLevel(logging.DEBUG)
29
30complete_count = 0
31
32def generate_cb(client, id, file, key, thumb_path, thumb_key, success, num):
33 global complete_count
34
35 # thumbnail completed
36 if success is True:
37 print("Thumb #%d completed: '%s'" % (num, thumb_path))
38 complete_count += 1
39 if complete_count >= 6:
40 print("\nTest Complete!")
41 ecore.main_loop_quit()
42 else:
43 print(" ERROR! aborting.")
44 ecore.main_loop_quit()
45
46def connect_cb(client, success):
47 if success is False:
48 print("Connection Failed")
49 ecore.main_loop_quit()
50 return
51 else:
52 print("Connection Successfull")
53
54 # request some thumbnails
55 print("1. Request a standard FDO thumbnail (default)")
56 et.file = filename
57 et.generate(generate_cb, 1)
58
59 print("2. Request a large FDO thumbnail...")
60 et.file = filename
61 et.fdo = ethumb.ETHUMB_THUMB_LARGE
62 et.generate(generate_cb, 2)
63
64 print("3. Request a very large JPEG thumbnail...")
65 et.file = filename
66 et.format = ethumb.ETHUMB_THUMB_JPEG
67 et.size = 512, 512
68 et.generate(generate_cb, 3)
69
70 print("4. Request a cropped thumbnail...")
71 et.file = filename
72 et.aspect = ethumb.ETHUMB_THUMB_CROP
73 et.generate(generate_cb, 4)
74
75 print("5. Request a rotated thumbnail")
76 et.file = filename
77 et.orientation = ethumb.ETHUMB_THUMB_ROTATE_180
78 et.size = 256, 256
79 et.aspect = ethumb.ETHUMB_THUMB_KEEP_ASPECT
80 et.generate(generate_cb, 5)
81
82 print("6. Request a poor quality thumbnail in this folder\n")
83 et.file = filename
84 et.orientation = ethumb.ETHUMB_THUMB_ORIENT_NONE
85 et.thumb_path = os.path.join(script_path, 'big_poor2.jpg')
86 et.format = ethumb.ETHUMB_THUMB_JPEG
87 et.size = 512, 512
88 et.quality = 10
89 et.generate(generate_cb, 6)
90
91 # ...and now wait for the responses
92
93
94def server_die_cb(client):
95 print("Server die!")
96 ecore.main_loop_quit()
97
98
99# create a single Ethumb instance
100et = ethumb.EthumbClient(connect_cb)
101et.on_server_die_callback_set(server_die_cb)
102
103
104
105# enter the ecore the main loop
106ecore.main_loop_begin()
107
108# free used resource
109et.disconnect()
110
diff --git a/include/efl.ethumb_client.pxd b/include/efl.ethumb_client.pxd
index 70c7ec3..7f99043 100644
--- a/include/efl.ethumb_client.pxd
+++ b/include/efl.ethumb_client.pxd
@@ -16,17 +16,64 @@
16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>. 16# along with this Python-EFL. If not, see <http://www.gnu.org/licenses/>.
17 17
18from efl.eina cimport Eina_Bool, Eina_Free_Cb 18from efl.eina cimport Eina_Bool, Eina_Free_Cb
19from efl.ethumb cimport Ethumb_Thumb_Orientation 19
20 20
21cdef extern from "Ethumb_Client.h": 21cdef extern from "Ethumb_Client.h":
22
23 ####################################################################
24 # Enums
25 #
26 cpdef enum Ethumb_Thumb_Orientation:
27 ETHUMB_THUMB_ORIENT_NONE
28 ETHUMB_THUMB_ROTATE_90_CW
29 ETHUMB_THUMB_ROTATE_180
30 ETHUMB_THUMB_ROTATE_90_CCW
31 ETHUMB_THUMB_FLIP_HORIZONTAL
32 ETHUMB_THUMB_FLIP_VERTICAL
33 ETHUMB_THUMB_FLIP_TRANSPOSE
34 ETHUMB_THUMB_FLIP_TRANSVERSE
35 ETHUMB_THUMB_ORIENT_ORIGINAL
36 ctypedef enum Ethumb_Thumb_Orientation:
37 pass
38
39 cpdef enum Ethumb_Thumb_FDO_Size:
40 ETHUMB_THUMB_NORMAL
41 ETHUMB_THUMB_LARGE
42 ctypedef enum Ethumb_Thumb_FDO_Size:
43 pass
44
45 cpdef enum Ethumb_Thumb_Format:
46 ETHUMB_THUMB_FDO
47 ETHUMB_THUMB_JPEG
48 ETHUMB_THUMB_EET
49 ctypedef enum Ethumb_Thumb_Format:
50 pass
51
52 cpdef enum Ethumb_Thumb_Aspect:
53 ETHUMB_THUMB_KEEP_ASPECT
54 ETHUMB_THUMB_IGNORE_ASPECT
55 ETHUMB_THUMB_CROP
56 ctypedef enum Ethumb_Thumb_Aspect:
57 pass
58
59 ####################################################################
60 # Structs
61 #
22 ctypedef struct Ethumb_Client 62 ctypedef struct Ethumb_Client
23 ctypedef struct Ethumb_Exists 63 ctypedef struct Ethumb_Exists
64
65 ####################################################################
66 # Other typedefs
67 #
24 ctypedef void (*Ethumb_Client_Connect_Cb)(void *data, Ethumb_Client *client, Eina_Bool success) 68 ctypedef void (*Ethumb_Client_Connect_Cb)(void *data, Ethumb_Client *client, Eina_Bool success)
25 ctypedef void (*Ethumb_Client_Die_Cb)(void *data, Ethumb_Client *client) 69 ctypedef void (*Ethumb_Client_Die_Cb)(void *data, Ethumb_Client *client)
26 ctypedef void (*Ethumb_Client_Generate_Cb)(void *data, Ethumb_Client *client, int id, const char *file, const char *key, const char *thumb_path, const char *thumb_key, Eina_Bool success) 70 ctypedef void (*Ethumb_Client_Generate_Cb)(void *data, Ethumb_Client *client, int id, const char *file, const char *key, const char *thumb_path, const char *thumb_key, Eina_Bool success)
27 ctypedef void (*Ethumb_Client_Thumb_Exists_Cb)(void *data, Ethumb_Client *client, Ethumb_Exists *thread, Eina_Bool exists) 71 ctypedef void (*Ethumb_Client_Thumb_Exists_Cb)(void *data, Ethumb_Client *client, Ethumb_Exists *thread, Eina_Bool exists)
28 ctypedef void (*Ethumb_Client_Generate_Cancel_Cb)(void *data, Eina_Bool success) 72 ctypedef void (*Ethumb_Client_Generate_Cancel_Cb)(void *data, Eina_Bool success)
29 73
74 ####################################################################
75 # Functions
76 #
30 int ethumb_client_init() 77 int ethumb_client_init()
31 int ethumb_client_shutdown() 78 int ethumb_client_shutdown()
32 79
@@ -90,7 +137,8 @@ cdef extern from "Ethumb_Client.h":
90 137
91 void ethumb_client_thumb_async_cancel(Ethumb_Client *client, Ethumb_Client_Async *request) 138 void ethumb_client_thumb_async_cancel(Ethumb_Client *client, Ethumb_Client_Async *request)
92 139
93cdef class Client: 140
141cdef class EthumbClient:
94 cdef Ethumb_Client *obj 142 cdef Ethumb_Client *obj
95 cdef object _on_connect_callback 143 cdef object _on_connect_callback
96 cdef object _on_server_die_callback 144 cdef object _on_server_die_callback
diff --git a/setup.py b/setup.py
index 36a50ee..f29884e 100755
--- a/setup.py
+++ b/setup.py
@@ -351,8 +351,9 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
351 extra_link_args=ethumb_libs + eina_libs) 351 extra_link_args=ethumb_libs + eina_libs)
352 ext_modules.append(ethumb_ext) 352 ext_modules.append(ethumb_ext)
353 353
354 ethumb_client_cflags, ethumb_client_libs = pkg_config( 354 # === Ethumb Client ===
355 'Ethumb_Client', 'ethumb_client', EFL_MIN_VER) 355 ethumb_client_cflags, ethumb_client_libs = pkg_config('Ethumb_Client',
356 'ethumb_client', EFL_MIN_VER)
356 ethumb_client_ext = Extension("ethumb_client", 357 ethumb_client_ext = Extension("ethumb_client",
357 ["efl/ethumb/efl.ethumb_client" + module_suffix], 358 ["efl/ethumb/efl.ethumb_client" + module_suffix],
358 include_dirs=['include/'], 359 include_dirs=['include/'],