1858c93ecda0a8407bd70a55f638f8f065004d97
[maemo-efl] / trunk / python-epsilon / debian / patches / 01-python-epsilon-thumb-canola.diff
1 From 71e5febf2f353efd9bff187c94d737760ba01b12 Mon Sep 17 00:00:00 2001
2 From: Leonardo Sobral Cunha <leonardo.cunha@openbossa.org>
3 Date: Sat, 24 Nov 2007 18:50:54 -0300
4 Subject: [PATCH] Support for epsilon api for creating custom sized thumbs
5
6 ---
7  epsilon/epsilon.c_epsilon.pyx |   11 +++++++++--
8  epsilon/epsilon.request.pyx   |    6 ++++--
9  include/epsilon/c_epsilon.pxd |    1 +
10  3 files changed, 14 insertions(+), 4 deletions(-)
11
12 diff --git a/epsilon/epsilon.c_epsilon.pyx b/epsilon/epsilon.c_epsilon.pyx
13 index cfd58ca..8550884 100644
14 --- a/epsilon/epsilon.c_epsilon.pyx
15 +++ b/epsilon/epsilon.c_epsilon.pyx
16 @@ -21,7 +21,7 @@ cdef class Epsilon:
17          """Epsilon constructor.
18  
19          @parm path: full path of image to process.
20 -        @parm thumb_size: one of EPSILON_THUMB_NORMAL or EPSILON_THUMB_LARGE
21 +        @parm thumb_size: one of EPSILON_THUMB_NORMAL, EPSILON_THUMB_LARGE
22          @parm key: just used by edje to specify the part to process.
23          @parm resolution: just used by edje to specify render size.
24          """
25 @@ -114,7 +114,7 @@ cdef class Epsilon:
26             EPSILON_THUMB_LARGE (256x256).
27          """
28          if value != EPSILON_THUMB_NORMAL and value != EPSILON_THUMB_LARGE:
29 -            raise ValueError("value must be either EPSILON_THUMB_NORMAL or "
30 +            raise ValueError("value must be either EPSILON_THUMB_NORMAL, "
31                               "EPSILON_THUMB_LARGE")
32          epsilon_thumb_size(self.obj, value)
33  
34 @@ -133,6 +133,13 @@ cdef class Epsilon:
35          def __get__(self):
36              return self.thumb_size_get()
37  
38 +    def thumb_custom_size_set(self, int w, int h, char *dir):
39 +        """Specify a custom thumbnail size.
40 +        """
41 +        if w <= 0 and h <= 0:
42 +            raise ValueError("either dimension value must be positive.")
43 +        epsilon_custom_thumb_size(self.obj, w, h, dir)
44 +
45      def file_get(self):
46          "@rtype: str"
47          cdef char *s
48 diff --git a/epsilon/epsilon.request.pyx b/epsilon/epsilon.request.pyx
49 index c9a9fad..eea60da 100644
50 --- a/epsilon/epsilon.request.pyx
51 +++ b/epsilon/epsilon.request.pyx
52 @@ -13,6 +13,7 @@ def init():
53  
54  EPSILON_THUMB_NORMAL = 0
55  EPSILON_THUMB_LARGE = 1
56 +EPSILON_THUMB_CANOLA = 2
57  
58  cdef class Request:
59      """Request epsilon_thumbd the thumbnail for the given image at given size.
60 @@ -37,9 +38,10 @@ cdef class Request:
61          if not callable(func):
62              raise TypeError("Parameter 'func' must be callable")
63  
64 -        if size != EPSILON_THUMB_NORMAL and size != EPSILON_THUMB_LARGE:
65 +        if size != EPSILON_THUMB_NORMAL and size != EPSILON_THUMB_LARGE and \
66 +           size != EPSILON_THUMB_CANOLA:
67              raise ValueError("Invalid size, must be EPSILON_THUMB_NORMAL or "
68 -                             "EPSILON_THUMB_LARGE")
69 +                             "EPSILON_THUMB_LARGE or EPSILON_THUMB_CANOLA")
70  
71          if self.obj == NULL:
72              self.func = func
73 diff --git a/include/epsilon/c_epsilon.pxd b/include/epsilon/c_epsilon.pxd
74 index 6c4a44a..1838d7f 100644
75 --- a/include/epsilon/c_epsilon.pxd
76 +++ b/include/epsilon/c_epsilon.pxd
77 @@ -40,6 +40,7 @@ cdef extern from "Epsilon.h":
78      int epsilon_exists(_Epsilon *e)
79      int epsilon_generate(_Epsilon *e)
80      void epsilon_thumb_size(_Epsilon *e, int size)
81 +    void epsilon_custom_thumb_size(_Epsilon *e, int w, int h, char *dir)
82  
83      _Epsilon_Info *epsilon_info_get (_Epsilon *e)
84  
85 -- 
86 1.5.4.3
87