===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_icon.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_fileman_icon.c 20 Oct 2005 13:08:51 -0000 1.1
+++ e_fileman_icon.c 20 Oct 2005 15:07:45 -0000 1.2
@@ -42,7 +42,7 @@
/* Create icons */
static void _e_fm_icon_icon_mime_get(E_Smart_Data *sd);
-static void _e_fm_icon_thumb_job_generate(void *data);
+static void _e_fm_icon_thumb_generate(void);
static int _e_fm_icon_thumb_cb_exe_exit(void *data, int type, void *event);
/* local subsystem globals */
@@ -50,7 +50,6 @@
static pid_t pid = -1;
static Evas_List *thumb_files = NULL;
-static Ecore_Job *thumb_job = NULL;
static Evas_List *event_handlers = NULL;
@@ -345,8 +344,7 @@
else
{
thumb_files = evas_list_append(thumb_files, sd);
- if (thumb_job) ecore_job_del(thumb_job);
- thumb_job = ecore_job_add(_e_fm_icon_thumb_job_generate, NULL);
+ if (pid == -1) _e_fm_icon_thumb_generate();
_e_fm_icon_icon_mime_get(sd);
}
}
@@ -460,67 +458,46 @@
}
static void
-_e_fm_icon_thumb_job_generate(void *data)
+_e_fm_icon_thumb_generate(void)
{
- if ((!thumb_files) || (pid != -1))return;
+ E_Smart_Data *sd;
+
+ if ((!thumb_files) || (pid != -1)) return;
pid = fork();
- thumb_job = NULL;
-
if (pid == 0)
- {
- /* child */
- Evas_List *l;
- for (l = thumb_files; l; l = l->next)
- {
- E_Smart_Data *sd;
- sd = l->data;
- if(!e_thumb_exists(sd->file->path))
- e_thumb_create(sd->file->path, sd->w, sd->h);
- }
+ {
+ sd = thumb_files->data;
+ if (!e_thumb_exists(sd->file->path))
+ e_thumb_create(sd->file->path, 48, 48); // thumbnail size
exit(0);
- }
+ }
}
static int
_e_fm_icon_thumb_cb_exe_exit(void *data, int type, void *event)
{
Ecore_Event_Exe_Exit *ev;
- Evas_List *l;
+ E_Smart_Data *sd;
ev = event;
if (ev->pid != pid) return 1;
- for (l = thumb_files; l;)
+ if (!thumb_files) return 1;
+
+ sd = thumb_files->data;
+ thumb_files = evas_list_remove_list(thumb_files, thumb_files);
+
+ if (ecore_file_exists(sd->thumb_path))
{
- E_Smart_Data *sd;
-
- sd = l->data;
- if (ecore_file_exists(sd->thumb_path))
- {
- Evas_List *tmp;
- if (sd->image_object) evas_object_del(sd->image_object);
- sd->image_object = NULL;
- sd->image_object = e_thumb_evas_object_get(sd->file->path,
- sd->evas,
- sd->w, sd->h);
- edje_object_part_swallow(sd->icon_object, "icon_swallow",
- sd->image_object);
- tmp = l;
- l = l->next;
- thumb_files = evas_list_remove_list(thumb_files, tmp);
- }
- else
- {
- l = l->next;
- }
+ if (sd->image_object) evas_object_del(sd->image_object);
+ sd->image_object = e_thumb_evas_object_get(sd->file->path,
+ sd->evas,
+ sd->w, sd->h);
+ edje_object_part_swallow(sd->icon_object, "icon_swallow",
+ sd->image_object);
}
pid = -1;
- if (thumb_files)
- {
- if (thumb_job) ecore_job_del(thumb_job);
- thumb_job = ecore_job_add(_e_fm_icon_thumb_job_generate, NULL);
- }
-
+ _e_fm_icon_thumb_generate();
return 1;
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_icon.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- e_icon.c 26 Sep 2005 09:13:44 -0000 1.4
+++ e_icon.c 20 Oct 2005 15:07:45 -0000 1.5
@@ -52,6 +52,17 @@
_e_icon_smart_reconfigure(sd);
}
+void
+e_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
+{
+ E_Smart_Data *sd;
+
+ sd = evas_object_smart_data_get(obj);
+ /* smart code here */
+ evas_object_image_file_set(sd->obj, file, key);
+ _e_icon_smart_reconfigure(sd);
+}
+
const char *
e_icon_file_get(Evas_Object *obj)
{
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_icon.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- e_icon.h 26 Sep 2005 09:13:44 -0000 1.6
+++ e_icon.h 20 Oct 2005 15:07:45 -0000 1.7
@@ -8,6 +8,7 @@
EAPI Evas_Object *e_icon_add (Evas *evas);
EAPI void e_icon_file_set (Evas_Object *obj, const char *file);
+EAPI void e_icon_file_key_set (Evas_Object *obj, const char *file,
const char *key);
EAPI const char *e_icon_file_get (Evas_Object *obj);
EAPI void e_icon_smooth_scale_set (Evas_Object *obj, int smooth);
EAPI int e_icon_smooth_scale_get (Evas_Object *obj);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_thumb.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- e_thumb.c 20 Oct 2005 13:08:51 -0000 1.3
+++ e_thumb.c 20 Oct 2005 15:07:45 -0000 1.4
@@ -78,19 +78,24 @@
char *thumbpath;
Evas_Object *im;
const int *data;
- int size;
+ int size, iw, ih, ww, hh;
Ecore_Evas *buf;
Evas *evasbuf;
+ int alpha;
thumbpath = e_thumb_file_get(file);
- if(!thumbpath) { free(thumbpath); return -1; }
+ if (!thumbpath)
+ {
+ free(thumbpath);
+ return -1;
+ }
ef = eet_open(thumbpath, EET_FILE_MODE_WRITE);
if (!ef)
- {
- free(thumbpath);
- return -1;
- }
+ {
+ free(thumbpath);
+ return -1;
+ }
free(thumbpath);
@@ -98,20 +103,32 @@
evasbuf = ecore_evas_get(buf);
im = evas_object_image_add(evasbuf);
evas_object_image_file_set(im, file, NULL);
- evas_object_image_fill_set(im, 0, 0, w, h);
- evas_object_resize(im, w, h);
+ iw = 0; ih = 0;
+ evas_object_image_size_get(im, &iw, &ih);
+ alpha = evas_object_image_alpha_get(im);
+ ww = w;
+ hh = (w * ih) / iw;
+ if (hh > h)
+ {
+ hh = h;
+ ww = (h * iw) / ih;
+ }
+ ecore_evas_resize(buf, ww, hh);
+ evas_object_image_fill_set(im, 0, 0, ww, hh);
+ evas_object_resize(im, ww, hh);
evas_object_show(im);
data = ecore_evas_buffer_pixels_get(buf);
- if ((size = eet_data_image_write(ef, "/thumbnail/data", (void *)data, w, h, 1, 0, 70, 1)) < 0)
+ eet_write(ef, "/thumbnail/orig_path", file, strlen(file), 1);
+ if ((size = eet_data_image_write(ef, "/thumbnail/data",
+ (void *)data, ww, hh, alpha,
+ 0, 91, 1)) <= 0)
{
- printf("e_thumb: BUG: Couldn't write thumb db\n");
eet_close(ef);
return -1;
}
-
+ evas_object_del(im);
eet_close(ef);
-
ecore_evas_free(buf);
return 1;
}
@@ -159,47 +176,32 @@
/* saved thumb */
/* TODO: add ability to fetch thumbs from freedesktop dirs */
if (!e_thumb_exists(file))
- {
- if(!e_thumb_create(file, width, height))
- {
- DEF_THUMB_RETURN;
- }
- }
-
+ {
+ if (!e_thumb_create(file, width, height))
+ {
+ DEF_THUMB_RETURN;
+ }
+ }
+
thumb = e_thumb_file_get(file);
- if(!thumb)
- {
- DEF_THUMB_RETURN;
- }
+ if (!thumb)
+ {
+ DEF_THUMB_RETURN;
+ }
ef = eet_open(thumb, EET_FILE_MODE_READ);
if (!ef)
- {
- free(thumb);
- DEF_THUMB_RETURN;
- }
+ {
+ eet_close(ef);
+ free(thumb);
+ DEF_THUMB_RETURN;
+ }
- free(thumb);
- data = eet_data_image_read(ef, "/thumbnail/data", &w, &h, &a, &c, &q, &l);
- if (data)
- {
- im = evas_object_image_add(evas);
- evas_object_image_alpha_set(im, 1);
- evas_object_image_size_set(im, w, h);
- evas_object_image_smooth_scale_set(im, 0);
- evas_object_image_data_copy_set(im, data);
- evas_object_image_data_update_add(im, 0, 0, w, h);
- evas_object_image_fill_set(im, 0, 0, w, h);
- evas_object_resize(im, w, h);
- free(data);
- }
- else
- {
- DEF_THUMB_RETURN;
- }
-
- eet_close(ef);
+ im = e_icon_add(evas);
+ e_icon_file_key_set(im, thumb, "/thumbnail/data");
+ e_icon_fill_inside_set(im, 1);
+ free(thumb);
return im;
}
@@ -207,10 +209,13 @@
static char *
_e_thumb_file_id(char *file)
{
- char s[256];
+ char s[256], *sp;
const char *chmap =
- "0123456789abcdefghijklmnopqrstuvwxyz€�‚ƒ„…†‡ˆŠ‹Œ�Ž��‘’“�-_";
- int id[2];
+ "0123456789abcdef"
+ "ghijklmnopqrstuv"
+ "[EMAIL PROTECTED]&*()"
+ "[];',.{}<>?-=_+|";
+ unsigned int id[6], i;
struct stat st;
if (stat(file, &st) < 0)
@@ -218,21 +223,28 @@
id[0] = (int)st.st_ino;
id[1] = (int)st.st_dev;
+ id[2] = (int)(st.st_size & 0xffffffff);
+ id[3] = (int)((st.st_size >> 32) & 0xffffffff);
+ id[4] = (int)(st.st_mtime & 0xffffffff);
+ id[5] = (int)((st.st_mtime >> 32) & 0xffffffff);
- sprintf(s,
- "%c%c%c%c%c%c"
- "%c%c%c%c%c%c",
- chmap[(id[0] >> 0) & 0x3f],
- chmap[(id[0] >> 6) & 0x3f],
- chmap[(id[0] >> 12) & 0x3f],
- chmap[(id[0] >> 18) & 0x3f],
- chmap[(id[0] >> 24) & 0x3f],
- chmap[(id[0] >> 28) & 0x3f],
- chmap[(id[1] >> 0) & 0x3f],
- chmap[(id[1] >> 6) & 0x3f],
- chmap[(id[1] >> 12) & 0x3f],
- chmap[(id[1] >> 18) & 0x3f],
- chmap[(id[1] >> 24) & 0x3f], chmap[(id[1] >> 28) & 0x3f]);
-
+ sp = s;
+ for (i = 0; i < 6; i++)
+ {
+ unsigned int t, tt;
+ int j;
+
+ t = id[i];
+ j = 32;
+ while (j > 0)
+ {
+ tt = t & ((1 << 6) - 1);
+ *sp = chmap[tt];
+ t >>= 6;
+ j -= 6;
+ sp++;
+ }
+ }
+ *sp = 0;
return strdup(s);
}
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs