#endif
static void _e_fileman_vscrollbar_drag_cb(Evas_Object *object, double value, void *data);
-static void _e_fileman_reconf_cb(void *data, int type, void *event);
-static void _e_fileman_dir_change_cb(void *data, int type, void *event);
+static int _e_fileman_reconf_cb(void *data, int type, void *event);
+static int _e_fileman_dir_change_cb(void *data, int type, void *event);
+static int _e_fileman_mouse_wheel_cb(void *data, int type, void *event);
static void _e_fileman_resize_cb(E_Win *win);
static void _e_fileman_delete_cb(E_Win *win);
static void _e_fileman_vscrollbar_show_cb(void *data, Evas_Object *obj, void *ev);
_e_fileman_dir_change_cb,
fileman));
+ fileman->event_handlers = evas_list_append(fileman->event_handlers,
+ ecore_event_handler_add(ECORE_X_EVENT_MOUSE_WHEEL,
+ _e_fileman_mouse_wheel_cb,
+ fileman));
+
evas_event_thaw(fileman->evas);
D(("e_fileman_new: ok\n"));
e_fm_scroll_vertical(fileman->smart, value);
}
-static void
+static int
_e_fileman_reconf_cb(void *data, int type, void *event)
{
E_Event_Fm_Reconfigure *ev;
D(("e_fileman_reconf_cb: hide (%p)\n", fileman));
edje_object_part_unswallow(fileman->main, fileman->vscrollbar);
evas_object_hide(fileman->vscrollbar);
- }
+ }
+ return 1;
}
-static void
+static int
_e_fileman_dir_change_cb(void *data, int type, void *event)
{
E_Event_Fm_Directory_Change *ev;
D(("_e_fileman_dir_change_cb:\n"));
e_scrollbar_value_set(fileman->vscrollbar, 0.0);
+ return 1;
+}
+
+static int
+_e_fileman_mouse_wheel_cb(void *data, int type, void *event)
+{
+ Ecore_X_Event_Mouse_Wheel *ev;
+ E_Fileman *fileman;
+ double pos;
+
+ ev = event;
+ fileman = data;
+
+ pos = e_scrollbar_value_get(fileman->vscrollbar);
+
+ if(ev->z < 0)
+ {
+ pos -= 0.05;
+ if(pos < 0.0)
+ pos = 0.0;
+ }
+
+ if(ev->z > 0)
+ {
+ pos += 0.05;
+ if(pos > 1.0)
+ pos = 1.0;
+ }
+
+ e_scrollbar_value_set(fileman->vscrollbar, pos);
+ e_fm_scroll_vertical(fileman->smart, pos);
+ return 1;
}
static void
if (file->name[0] == '.')
file->type |= E_FM_FILE_TYPE_HIDDEN;
+ file->preview_funcs = E_NEW(E_Fm_File_Preview_Function, 4);
+ file->preview_funcs[0] = e_fm_file_is_image;
+ file->preview_funcs[1] = e_fm_file_is_etheme;
+ file->preview_funcs[2] = e_fm_file_is_ebg;
+ file->preview_funcs[3] = e_fm_file_is_eap;
+
D(("e_fm_file_new: %s\n", filename));
return file;
}
int
+e_fm_file_can_preview(E_Fm_File *file)
+{
+ int i;
+
+ D(("e_fm_file_can_preview: (%s) (%p)\n", file->name, file));
+ for (i = 0; i < sizeof(file->preview_funcs); i++)
+ {
+ E_Fm_File_Preview_Function func;
+ func = file->preview_funcs[i];
+ if(func(file))
+ return 1;
+ }
+ return 0;
+}
+
+int
e_fm_file_is_image(E_Fm_File *file)
{
/* We need to check if it is a filetype supported by evas.
* canvas.
*/
char *ext;
+
+ if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
+
+ ext = strrchr(file->name, '.');
+ if (!ext) return 0;
- if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
+ D(("e_fm_file_is_image: (%p)\n", file));
+ return (!strcasecmp(ext, ".jpg")) || (!strcasecmp(ext, ".png"))
+ || (!strcasecmp(ext, ".jpeg"));
+}
+int
+e_fm_file_is_etheme(E_Fm_File *file)
+{
+ int val;
+ char *ext;
+ Evas_List *groups, *l;
+
+ if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
+
ext = strrchr(file->name, '.');
if (!ext) return 0;
- D(("e_fm_file_is_image: (%p)\n", file));
- return (!strcasecmp(ext, ".jpg")) || (!strcasecmp(ext, ".png"))
- || (!strcasecmp(ext, ".jpeg")) || (!strcasecmp(ext, ".eap"));
+ if(strcasecmp(ext, ".edj"))
+ return 0;
+
+ val = 0;
+ groups = edje_file_collection_list(file->path);
+ if(!groups)
+ return 0;
+
+ for (l = groups; l; l = l->next)
+ if(!strcmp(l->data, "widgets/border/default/border"))
+ {
+ val = 1;
+ break;
+ }
+ edje_file_collection_list_free(groups);
+ return val;
+}
+
+int
+e_fm_file_is_ebg(E_Fm_File *file)
+{
+ int val;
+ char *ext;
+ Evas_List *groups, *l;
+
+ if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
+
+ ext = strrchr(file->name, '.');
+ if (!ext) return 0;
+
+ if(strcasecmp(ext, ".edj"))
+ return 0;
+
+ val = 0;
+ groups = edje_file_collection_list(file->path);
+ if(!groups)
+ return 0;
+
+ for (l = groups; l; l = l->next)
+ if(!strcmp(l->data, "desktop/background"))
+ {
+ val = 1;
+ break;
+ }
+ edje_file_collection_list_free(groups);
+ return val;
+}
+
+int
+e_fm_file_is_eap(E_Fm_File *file)
+{
+ char *ext;
+ E_App *app;
+
+ if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0;
+
+ ext = strrchr(file->name, '.');
+ if (!ext) return 0;
+
+ if(strcasecmp(ext, ".eap"))
+ return 0;
+
+ app = e_app_new(file->path, 0);
+ if(!app)
+ {
+ e_object_unref(E_OBJECT(app));
+ return 0;
+ }
+ e_object_unref(E_OBJECT(app));
+ return 1;
}
int
_e_fm_file_free(E_Fm_File *file)
{
D(("_e_fm_file_free: (%p) (%s)\n", file, file->name));
+ free(file->preview_funcs);
if (file->path) free(file->path);
if (file->name) free(file->name);
free(file);
typedef struct _E_Fm_File E_Fm_File;
typedef struct _E_Fm_File_Attributes E_Fm_File_Attributes;
+typedef int(*E_Fm_File_Preview_Function) (E_Fm_File*);
#define E_FM_FILE_TYPE_FILE (1 << 8)
#define E_FM_FILE_TYPE_DIRECTORY (1 << 9)
time_t atime; /* time of last access */
time_t mtime; /* time of last modification */
time_t ctime; /* time of last status change */
+
+ E_Fm_File_Preview_Function *preview_funcs;
};
-EAPI E_Fm_File *e_fm_file_new (const char *filename);
-EAPI int e_fm_file_rename (E_Fm_File *file, const char *name);
-EAPI int e_fm_file_delete (E_Fm_File *file);
-EAPI int e_fm_file_copy (E_Fm_File *file, const char *name);
-EAPI int e_fm_file_is_image (E_Fm_File *file);
-EAPI int e_fm_file_exec (E_Fm_File *file);
-EAPI int e_fm_file_assoc_set (E_Fm_File *file, const char *assoc);
-EAPI int e_fm_file_assoc_exec (E_Fm_File *file);
+EAPI E_Fm_File *e_fm_file_new (const char *filename);
+EAPI int e_fm_file_rename (E_Fm_File *file, const char *name);
+EAPI int e_fm_file_delete (E_Fm_File *file);
+EAPI int e_fm_file_copy (E_Fm_File *file, const char *name);
+EAPI int e_fm_file_can_preview (E_Fm_File *file);
+EAPI int e_fm_file_is_image (E_Fm_File *file);
+EAPI int e_fm_file_is_etheme (E_Fm_File *file);
+EAPI int e_fm_file_is_ebg (E_Fm_File *file);
+EAPI int e_fm_file_is_eap (E_Fm_File *file);
+EAPI int e_fm_file_exec (E_Fm_File *file);
+EAPI int e_fm_file_assoc_set (E_Fm_File *file, const char *assoc);
+EAPI int e_fm_file_assoc_exec (E_Fm_File *file);
#endif
#endif
return 0;
}
+int *
+_e_thumb_image_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh, int *alpha, Evas_Object **im, Ecore_Evas **buf)
+{
+ Evas *evasbuf;
+ int size, iw, ih;
+
+ *buf = ecore_evas_buffer_new(1, 1);
+ evasbuf = ecore_evas_get(*buf);
+ *im = evas_object_image_add(evasbuf);
+ evas_object_image_file_set(*im, file, NULL);
+ iw = 0; ih = 0;
+ evas_object_image_size_get(*im, &iw, &ih);
+ *alpha = evas_object_image_alpha_get(im);
+ if ((iw > 0) && (ih > 0))
+ {
+ *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_move(*im, 0, 0);
+ evas_object_show(*im);
+
+ return ecore_evas_buffer_pixels_get(*buf);
+ }
+ return NULL;
+}
+
+/* thumbnail an e17 background and return pixel data */
+int *
+_e_thumb_ebg_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh, int *alpha, Evas_Object **im, Ecore_Evas **buf)
+{
+ Evas *evasbuf;
+ Evas_Object *wallpaper;
+ int *pixels;
+
+ *ww = 640;
+ *hh = 480;
+ *alpha = 0;
+
+ w = 640;
+ h = 480;
+
+ *buf = ecore_evas_buffer_new(w, h);
+ evasbuf = ecore_evas_get(*buf);
+
+ wallpaper = edje_object_add(evasbuf);
+
+
+ edje_object_file_set(wallpaper, file, "desktop/background");
+
+ /* wallpaper */
+ evas_object_move(wallpaper, 0, 0);
+ evas_object_resize(wallpaper, w, h);
+
+ evas_object_show(wallpaper);
+
+ pixels = ecore_evas_buffer_pixels_get(*buf);
+
+ evas_object_del(wallpaper);
+ return pixels;
+}
+
+/* thumbnail an e17 theme and return pixel data */
+int *
+_e_thumb_etheme_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh, int *alpha, Evas_Object **im, Ecore_Evas **buf)
+{
+ Evas *evasbuf;
+ Evas_Object *wallpaper, *window, *clock, *start, **pager;
+ int *pixels;
+
+ *ww = 640;
+ *hh = 480;
+ *alpha = 0;
+
+ w = 640;
+ h = 480;
+
+ *buf = ecore_evas_buffer_new(w, h);
+ evasbuf = ecore_evas_get(*buf);
+
+ wallpaper = edje_object_add(evasbuf);
+ window = edje_object_add(evasbuf);
+ clock = edje_object_add(evasbuf);
+ start = edje_object_add(evasbuf);
+ pager = E_NEW(Evas_Object*, 3);
+ pager[0] = edje_object_add(evasbuf);
+ pager[1] = edje_object_add(evasbuf);
+ pager[2] = edje_object_add(evasbuf);
+
+ edje_object_file_set(wallpaper, file, "desktop/background");
+ edje_object_file_set(window, file, "widgets/border/default/border");
+ edje_object_file_set(clock, file, "modules/clock/main");
+ edje_object_file_set(clock, file, "modules/clock/main");
+ edje_object_file_set(start, file, "modules/start/main");
+ edje_object_file_set(pager[0], file, "modules/pager/main");
+ edje_object_file_set(pager[1], file, "modules/pager/desk");
+ edje_object_file_set(pager[2], file, "modules/pager/window");
+ edje_object_part_text_set(window, "title_text", file);
+ edje_object_part_swallow(pager[0], "items", pager[1]);
+ edje_object_part_swallow(pager[1], "items", pager[2]);
+
+ /* wallpaper */
+ evas_object_move(wallpaper, 0, 0);
+ evas_object_resize(wallpaper, w, h);
+ /* main window */
+ evas_object_move(window, (w * 0.1), (h * 0.05));
+ evas_object_resize(window, w * 0.8, h * 0.75);
+ /* clock */
+ evas_object_move(clock, (w * 0.9), (h * 0.9));
+ evas_object_resize(clock, w * 0.1, h * 0.1);
+ /* start */
+ evas_object_move(start, (w * 0.9), (h * 0.9));
+ evas_object_resize(start, w * 0.1, h * 0.1);
+ /* pager */
+ evas_object_move(pager[0], (w * 0.3), (h * 0.9));
+ evas_object_resize(pager[0], w * 0.1, h * 0.1);
+
+ evas_object_show(wallpaper);
+ evas_object_show(window);
+ evas_object_show(clock);
+ evas_object_show(start);
+ evas_object_show(pager[0]);
+ evas_object_show(pager[1]);
+ evas_object_show(pager[2]);
+
+ pixels = ecore_evas_buffer_pixels_get(*buf);
+
+ evas_object_del(wallpaper);
+ evas_object_del(window);
+ evas_object_del(clock);
+ evas_object_del(start);
+ evas_object_del(pager[0]);
+ evas_object_del(pager[1]);
+ evas_object_del(pager[2]);
+ free(pager);
+
+ return pixels;
+}
+
/* create and save a thumb to disk */
int
e_thumb_create(char *file, Evas_Coord w, Evas_Coord h)
return -1;
}
- buf = ecore_evas_buffer_new(1, 1);
- evasbuf = ecore_evas_get(buf);
- im = evas_object_image_add(evasbuf);
- evas_object_image_file_set(im, file, NULL);
- iw = 0; ih = 0;
- evas_object_image_size_get(im, &iw, &ih);
- alpha = evas_object_image_alpha_get(im);
- if ((iw > 0) && (ih > 0))
+ if(ext)
+ {
+ if(!strcasecmp(ext, ".edj"))
+ {
+ /* for now, this function does both the bg and theme previews */
+ data = _e_thumb_etheme_create(file, w, h, &ww, &hh, &alpha, &im, &buf);
+ }
+ else
+ data = _e_thumb_image_create(file, w, h, &ww, &hh, &alpha, &im, &buf);
+ }
+ else
+ data = _e_thumb_image_create(file, w, h, &ww, &hh, &alpha, &im, &buf);
+
+ if (data)
{
ef = eet_open(thumbpath, EET_FILE_MODE_WRITE);
if (!ef)
return -1;
}
free(thumbpath);
-
- 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);
eet_write(ef, "/thumbnail/orig_path", file, strlen(file), 1);
if ((size = eet_data_image_write(ef, "/thumbnail/data",