'everything' module: added image preview plugin

SVN revision: 41828
This commit is contained in:
Hannes Janetzek 2009-08-17 02:11:33 +00:00
parent 533ce81495
commit 16623102f0
3 changed files with 460 additions and 0 deletions

View File

@ -27603,5 +27603,220 @@ MIMEBASE("application/x-font-bdf","icon_mime_font_generic.png", ".BDF", 128);
}
}
group { name: "e/widgets/everything/preview";
parts {
part { name: "bg";
type: RECT;
mouse_events: 0;
description { state: "default" 0.0;
color: 64 64 63 255;
rel1 {
relative: 0.0 0.0;
offset: -4 -4;
to: "frame";
}
rel2 {
relative: 1.0 1.0;
offset: 4 4;
to: "frame";
}
}
}
part { name: "clip";
type: RECT;
mouse_events: 0;
description { state: "default" 0.0;
}
}
part { name: "frame";
type: RECT;
mouse_events: 0;
description { state: "default" 0.0;
visible: 0;
align: 0 0;
rel1 {
relative: 0.0 0.0;
}
rel2 {
relative: 1.0 1.0;
}
}
}
part { name: "clip1";
type: RECT;
clip_to: "clip";
description { state: "default" 0.0;
rel1.to: "e.swallow.icon1";
rel2.to: "e.swallow.icon1";
color: 200 200 200 0;
}
description { state: "right" 0.0;
inherit: "default" 0.0;
color: 255 255 255 255;
}
}
part { name: "e.swallow.icon1";
type: SWALLOW;
clip_to: "clip1";
description { state: "default" 0.0;
rel1 {
relative: 0.0 0.0;
to: "frame";
offset: 2 2;
}
rel2 {
relative: 0.3333 1.0;
to: "frame";
offset: -3 -3;
}
}
description { state: "right" 0.0;
rel1 {
relative: 0.3333 0.0;
to: "frame";
offset: 2 2;
}
rel2 {
relative: 0.6666 1.0;
to: "frame";
offset: -3 -3;
}
}
}
part { name: "clip2";
type: RECT;
clip_to: "clip";
description { state: "default" 0.0;
rel1.to: "e.swallow.icon2";
rel2.to: "e.swallow.icon2";
color: 255 255 255 255;
}
description { state: "left" 0.0;
inherit: "default" 0.0;
color: 200 200 200 0;
}
description { state: "right" 0.0;
inherit: "left" 0.0;
}
}
part { name: "e.swallow.icon2";
type: SWALLOW;
clip_to: "clip2";
description { state: "default" 0.0;
rel1 {
relative: 0.3333 0.0;
to: "frame";
offset: 2 2;
}
rel2 {
relative: 0.6666 1.0;
to: "frame";
offset: -3 -3;
}
}
description { state: "left" 0.0;
rel1 {
relative: 0.00 0.0;
to: "frame";
offset: 2 2;
}
rel2 {
relative: 0.3333 1.0;
to: "frame";
offset: -3 -3;
}
}
description { state: "right" 0.0;
rel1 {
relative: 0.6666 0.0;
to: "frame";
offset: 2 2;
}
rel2 {
relative: 1.0 1.0;
to: "frame";
offset: -3 -3;
}
}
}
part { name: "clip3";
type: RECT;
clip_to: "clip";
description { state: "default" 0.0;
rel1.to: "e.swallow.icon3";
rel2.to: "e.swallow.icon3";
color: 200 200 200 0;
}
description { state: "left" 0.0;
inherit: "default" 0.0;
color: 255 255 255 255;
}
}
part { name: "e.swallow.icon3";
type: SWALLOW;
clip_to: "clip3";
description { state: "default" 0.0;
rel1 {
relative: 0.6666 0.0;
to: "frame";
offset: 2 2;
}
rel2 {
relative: 1.0 1.0;
to: "frame";
offset: -3 -3;
}
}
description { state: "left" 0.0;
rel1 {
relative: 0.3333 0.0;
to: "frame";
offset: 2 2;
}
rel2 {
relative: 0.6666 1.0;
to: "frame";
offset: -3 -3;
}
}
}
}
programs {
program { name: "slide_left";
signal: "e,signal,slide_left";
source: "e";
action: STATE_SET "right" 0.0;
target: "e.swallow.icon1";
target: "e.swallow.icon2";
target: "clip1";
target: "clip2";
after: "slide_middle";
}
program { name: "slide_right";
signal: "e,signal,slide_right";
source: "e";
action: STATE_SET "left" 0.0;
target: "e.swallow.icon2";
target: "e.swallow.icon3";
target: "clip2";
target: "clip3";
after: "slide_middle";
}
program { name: "slide_middle";
action: STATE_SET "default" 0.0;
target: "e.swallow.icon1";
target: "e.swallow.icon2";
target: "e.swallow.icon3";
target: "clip1";
target: "clip2";
target: "clip3";
transition: SINUSOIDAL 0.2;
}
}
}

View File

@ -105,6 +105,12 @@ evry_plug_clipboard_la_LIBADD = @e_libs@
evry_plug_clipboard_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_clipboard_la_LIBTOOLFLAGS = --tag=disable-static
evry_plug_previewdir = $(plugindir)
evry_plug_preview_LTLIBRARIES = evry_plug_preview.la
evry_plug_preview_la_SOURCES = evry_plug_preview.c
evry_plug_preview_la_LIBADD = @e_libs@
evry_plug_preview_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_preview_la_LIBTOOLFLAGS = --tag=disable-static
uninstall:
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)

View File

@ -0,0 +1,239 @@
#include "Evry.h"
static Evry_Plugin *p1;
static Evas_Object *o_thumb[5];
static const Evry_Item *cur_item = NULL;
static Evas_Object *o_main = NULL;
static Evas_Object *o_swallow = NULL;
static Eina_List *cur_items = NULL;
static int
_check_item(const Evry_Item *it)
{
if (strcmp(it->plugin->type_out, "FILE")) return 0;
if (!it->uri || !it->mime) return 0;
if (e_util_glob_case_match(it->mime, "*image/*"))
return 1;
return 0;
}
static void
_cb_preview_thumb_gen(void *data, Evas_Object *obj, void *event_info)
{
Evas_Coord w, h;
if (!o_main) return;
e_icon_size_get(o_thumb[1], &w, &h);
edje_extern_object_min_size_set(o_thumb[1], w, h);
edje_object_part_swallow(o_main, "e.swallow.icon2", o_thumb[1]);
evas_object_show(o_thumb[1]);
}
void
_show_item(const Evry_Item *it, int dir)
{
int w, h, x, y;
if (o_thumb[1 + dir])
{
e_thumb_icon_end(o_thumb[1+dir]);
edje_object_part_unswallow(o_main, o_thumb[1+dir]);
evas_object_hide(o_thumb[1+dir]);
evas_object_del(o_thumb[1+dir]);
}
if (dir && o_thumb[1])
{
edje_object_part_unswallow(o_main, o_thumb[1]);
if (dir > 0)
{
o_thumb[2] = o_thumb[1];
edje_object_part_swallow(o_main, "e.swallow.icon1", o_thumb[2]);
}
else
{
o_thumb[0] = o_thumb[1];
edje_object_part_swallow(o_main, "e.swallow.icon3", o_thumb[0]);
}
}
o_thumb[1] = e_thumb_icon_add(evas_object_evas_get(o_main));
e_thumb_icon_file_set(o_thumb[1], it->uri, NULL);
evas_object_smart_callback_add(o_thumb[1], "e_thumb_gen", _cb_preview_thumb_gen, NULL);
evas_object_geometry_get(o_main, &x, &y, &w, &h);
e_thumb_icon_size_set(o_thumb[1], w, h);
e_thumb_icon_begin(o_thumb[1]);
if (dir)
{
if (dir > 0)
edje_object_signal_emit(o_main, "e,signal,slide_left", "e");
else
edje_object_signal_emit(o_main, "e,signal,slide_right", "e");
}
}
static Evas_Object *
_show(Evry_Plugin *p, Evas_Object *swallow, Eina_List *items)
{
int w, h, x, y;
o_main = edje_object_add(evas_object_evas_get(swallow));
e_theme_edje_object_set(o_main, "base/theme/everything",
"e/widgets/everything/preview");
edje_object_part_geometry_get(swallow, "e.swallow.list", &x, &y, &w, &h);
edje_extern_object_min_size_set(o_main, w * 3, 100);
evas_object_resize(o_main, w * 3, h);
if (!o_main) return NULL;
o_swallow = swallow;
_show_item(cur_item, 0);
cur_items = items;
return o_main;
}
static int
_cb_key_down(Evry_Plugin *p, Ecore_Event_Key *ev)
{
Eina_List *l, *ll;
const Evry_Item *found = NULL, *it;
if (!strcmp(ev->key, "Right") ||
!strcmp(ev->key, "Down"))
{
l = eina_list_data_find_list(cur_items, cur_item);
if (l && l->next)
{
EINA_LIST_FOREACH(l->next, ll, it)
{
if (!_check_item(it)) continue;
found = it;
break;
}
}
if (!found)
{
EINA_LIST_FOREACH(cur_items, ll, it)
{
if (!_check_item(it)) continue;
found = it;
break;
}
}
if (found && (found != cur_item))
{
_show_item(found, 1);
cur_item = found;
}
return 1;
}
else if (!strcmp(ev->key, "Left") ||
!strcmp(ev->key, "Up"))
{
EINA_LIST_FOREACH(cur_items, ll, it)
{
if (it == cur_item)
break;
if (_check_item(it))
found = it;
}
if (!found && ll)
{
EINA_LIST_FOREACH(ll->next, l, it)
{
if (_check_item(it))
found = it;
}
}
if (found && (found != cur_item))
{
_show_item(found, -1);
cur_item = found;
}
return 1;
}
return 0;
}
static int
_begin(Evry_Plugin *p, const Evry_Item *it)
{
if (_check_item(it))
{
cur_item = it;
return 1;
}
return 0;
}
static void
_cleanup(Evry_Plugin *p)
{
if (o_thumb[0]) evas_object_del(o_thumb[0]);
if (o_thumb[1]) evas_object_del(o_thumb[1]);
if (o_thumb[2]) evas_object_del(o_thumb[2]);
if (o_main) evas_object_del(o_main);
o_thumb[0] = NULL;
o_thumb[1] = NULL;
o_thumb[2] = NULL;
o_main = NULL;
cur_items = NULL;
}
static int
_action(Evry_Plugin *p, const Evry_Item *it, const char *input __UNUSED__)
{
return 0;
}
static int
_fetch(Evry_Plugin *p, const char *input __UNUSED__)
{
return 1;
}
static Eina_Bool
_init(void)
{
p1 = E_NEW(Evry_Plugin, 1);
p1->name = "Preview";
p1->type = type_action;
p1->type_in = "FILE";
p1->type_out = "NONE";
p1->icon = "preferences-desktop-wallpaper";
p1->need_query = 0;
p1->async_query = 1;
p1->begin = &_begin;
p1->fetch = &_fetch;
p1->show = &_show;
p1->cb_key_down = &_cb_key_down;
p1->action = &_action;
p1->cleanup = &_cleanup;
evry_plugin_register(p1, 3);
return EINA_TRUE;
}
static void
_shutdown(void)
{
evry_plugin_unregister(p1);
E_FREE(p1);
}
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);