Updated patch for EPSILON_THUMB_CANOLA
[maemo-efl] / trunk / epsilon / debian / patches / 02_epsilon_thumb_canola.diff
1 diff --git a/src/lib/Epsilon.c b/src/lib/Epsilon.c
2 index c1d769e..e01f714 100644
3 --- a/src/lib/Epsilon.c
4 +++ b/src/lib/Epsilon.c
5 @@ -23,6 +23,9 @@
6  #ifdef HAVE_EPEG_H
7  #include <Epeg.h>
8  #endif
9 +#define THUMB_HEIGHT_CANOLA 96
10 +#define THUMB_WIDTH_CANOLA 192
11 +#define THUMB_SIZE_CANOLA 192
12  #define THUMB_SIZE_NORMAL 128
13  #define THUMB_SIZE_LARGE 256
14  #define THUMB_SIZE_FAIL -1
15 @@ -38,9 +41,11 @@
16  
17  static char *PATH_DIR_LARGE = NULL;
18  static char *PATH_DIR_NORMAL = NULL;
19 +static char *PATH_DIR_CANOLA = NULL;
20  static char *PATH_DIR_FAIL = NULL;
21  static unsigned LEN_DIR_LARGE = 0;
22  static unsigned LEN_DIR_NORMAL = 0;
23 +static unsigned LEN_DIR_CANOLA = 0;
24  static unsigned LEN_DIR_FAIL = 0;
25  
26  
27 @@ -153,6 +158,11 @@ epsilon_init (void)
28       PATH_DIR_NORMAL = strdup(buf);
29       LEN_DIR_NORMAL = strlen(buf);
30    }
31 +  if (!PATH_DIR_CANOLA) {
32 +     strncpy(buf + base_len, "/canola", PATH_MAX - base_len);
33 +     PATH_DIR_CANOLA = strdup(buf);
34 +     LEN_DIR_CANOLA = strlen(buf);
35 +  }
36    if (!PATH_DIR_FAIL) {
37       strncpy(buf + base_len, "/fail/epsilon", PATH_MAX - base_len);
38       PATH_DIR_FAIL = strdup(buf);
39 @@ -161,6 +171,7 @@ epsilon_init (void)
40  
41    ecore_file_mkpath(PATH_DIR_LARGE);
42    ecore_file_mkpath(PATH_DIR_NORMAL);
43 +  ecore_file_mkpath(PATH_DIR_CANOLA);
44    ecore_file_mkpath(PATH_DIR_FAIL);
45  
46    plugins_mime = ecore_hash_new(ecore_str_hash, ecore_str_compare);
47 @@ -446,6 +457,11 @@ _epsilon_file_name(unsigned thumb_size, const char *hash, const char *ext, char
48         dir = PATH_DIR_NORMAL;
49         dir_len = LEN_DIR_NORMAL;
50       }
51 +   else if (thumb_size == THUMB_SIZE_CANOLA)
52 +     {
53 +       dir = PATH_DIR_CANOLA;
54 +       dir_len = LEN_DIR_CANOLA;
55 +     }
56     else
57       {
58         dir = PATH_DIR_FAIL;
59 @@ -563,10 +579,10 @@ epsilon_generate (Epsilon * e)
60  
61    if (!e || !e->src || !e->hash)
62      return (EPSILON_FAIL);
63 -   
64 +
65    tw = e->tw;
66    th = e->th;
67 -   
68 +
69  #ifdef HAVE_EPEG_H
70    len = strlen (e->src);
71    if ((len > 4) &&
72 @@ -575,7 +591,8 @@ epsilon_generate (Epsilon * e)
73        _epsilon_file_name(e->tw, e->hash, "jpg", outfile, sizeof(outfile));
74        epeg_thumbnail_comments_get (im, &info);
75        epeg_size_get (im, &iw, &ih);
76 -      if (iw > ih)
77 +      /* XXX - hack to force fixed height in case of tw != th (canola) */
78 +      if (iw > ih && tw == th)
79         {
80           th = ((unsigned long) e->tw * ih) / iw;
81           if (th < 1) th = 1;
82 @@ -697,7 +714,8 @@ epsilon_generate (Epsilon * e)
83        {
84         iw = imlib_image_get_width ();
85         ih = imlib_image_get_height ();
86 -       if (iw > ih)
87 +       /* XXX - hack to force fixed height in case of tw != th (canola) */
88 +       if (iw > ih && tw == th)
89           {
90              th = ((unsigned long) e->tw * ih) / iw;
91              if (th < 1) th = 1;
92 @@ -738,7 +756,7 @@ void
93  epsilon_thumb_size(Epsilon *e, Epsilon_Thumb_Size size)
94  {
95     if (!e) return;
96 -   
97 +
98     switch (size)
99       {
100        case EPSILON_THUMB_NORMAL:
101 @@ -749,7 +767,11 @@ epsilon_thumb_size(Epsilon *e, Epsilon_Thumb_Size size)
102         e->tw = THUMB_SIZE_LARGE;
103         e->th = THUMB_SIZE_LARGE;
104         break;
105 -     }   
106 +      case EPSILON_THUMB_CANOLA:
107 +       e->tw = THUMB_WIDTH_CANOLA;
108 +       e->th = THUMB_HEIGHT_CANOLA;
109 +    break;
110 +     }
111  }
112  
113  
114 diff --git a/src/lib/Epsilon.h b/src/lib/Epsilon.h
115 index 90a51b3..05ff2f7 100644
116 --- a/src/lib/Epsilon.h
117 +++ b/src/lib/Epsilon.h
118 @@ -58,7 +58,8 @@ typedef struct _Epsilon_Info Epsilon_Info;
119  enum _Epsilon_Thumb_Size
120  {
121     EPSILON_THUMB_NORMAL,
122 -   EPSILON_THUMB_LARGE
123 +   EPSILON_THUMB_LARGE,
124 +   EPSILON_THUMB_CANOLA
125  };
126  
127  typedef enum _Epsilon_Thumb_Size Epsilon_Thumb_Size;
128 -- 
129 1.5.3.6
130