forked from enlightenment/enlightenment
'everything'
- use item_changed event to update views and actions - Evry_File: rename uri to path SVN revision: 47807
This commit is contained in:
parent
f6820d53a6
commit
90f261fc04
|
@ -1,3 +1,6 @@
|
|||
#ifndef EVRY_H
|
||||
#define EVRY_H
|
||||
|
||||
#include "e.h"
|
||||
|
||||
#define EVRY_ACTION_OTHER 0
|
||||
|
@ -94,6 +97,8 @@ struct _Evry_Item
|
|||
/* item can be browsed, e.g. folders */
|
||||
Eina_Bool browseable;
|
||||
|
||||
Eina_Bool selected;
|
||||
|
||||
/* for internally use by plugins */
|
||||
void *data;
|
||||
|
||||
|
@ -129,7 +134,8 @@ struct _Evry_Item_App
|
|||
struct _Evry_Item_File
|
||||
{
|
||||
Evry_Item base;
|
||||
const char *uri;
|
||||
const char *url;
|
||||
const char *path;
|
||||
const char *mime;
|
||||
};
|
||||
|
||||
|
@ -169,6 +175,8 @@ struct _Evry_Plugin
|
|||
Evas_Object *(*config_page) (Evry_Plugin *p);
|
||||
void (*config_apply) (Evry_Plugin *p);
|
||||
|
||||
int (*cb_key_down) (Evry_Plugin *p, const Ecore_Event_Key *ev);
|
||||
|
||||
/* show in aggregator. default is TRUE */
|
||||
Eina_Bool aggregate;
|
||||
|
||||
|
@ -269,6 +277,8 @@ EAPI Evas_Object *evry_icon_theme_get(const char *icon, Evas *e);
|
|||
EAPI int evry_fuzzy_match(const char *str, const char *match);
|
||||
EAPI Eina_List *evry_fuzzy_match_sort(Eina_List *items);
|
||||
EAPI int evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file);
|
||||
EAPI char *evry_util_unescape(const char *string, int length);
|
||||
|
||||
|
||||
/* e_mod_main.c */
|
||||
EAPI void evry_plugin_register(Evry_Plugin *p, int priority);
|
||||
|
@ -303,3 +313,15 @@ EAPI Evry_Action *evry_action_new(const char *name, const char *type_in1,
|
|||
|
||||
EAPI void evry_action_free(Evry_Action *act);
|
||||
|
||||
typedef struct _Evry_Event_Item_Changed Evry_Event_Item_Changed;
|
||||
|
||||
struct _Evry_Event_Item_Changed
|
||||
{
|
||||
Evry_Item *item;
|
||||
};
|
||||
|
||||
extern EAPI int EVRY_EVENT_ITEM_SELECT;
|
||||
extern EAPI int EVRY_EVENT_ITEM_CHANGED;
|
||||
extern EAPI int EVRY_EVENT_ITEMS_UPDATE;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -183,7 +183,7 @@ _action(Evry_Plugin *plugin, const Evry_Item *item)
|
|||
Item *it = (Item*) item;
|
||||
import = E_NEW(Import, 1);
|
||||
import->method = it->method;
|
||||
import->file = p->prev->file->uri;
|
||||
import->file = p->prev->file->path;
|
||||
import->quality = 100;
|
||||
import->external = 0;
|
||||
_import_edj_gen(import);
|
||||
|
|
|
@ -31,6 +31,9 @@ int _e_module_evry_log_dom = -1;
|
|||
|
||||
EAPI Config *evry_conf = NULL;
|
||||
|
||||
EAPI int EVRY_EVENT_ITEM_SELECT;
|
||||
EAPI int EVRY_EVENT_ITEM_CHANGED;
|
||||
EAPI int EVRY_EVENT_ITEMS_UPDATE;
|
||||
|
||||
/* module setup */
|
||||
EAPI E_Module_Api e_modapi =
|
||||
|
@ -131,6 +134,13 @@ e_modapi_init(E_Module *m)
|
|||
evry_config_dialog);
|
||||
evry_init();
|
||||
|
||||
if (!EVRY_EVENT_ITEMS_UPDATE)
|
||||
EVRY_EVENT_ITEMS_UPDATE = ecore_event_type_new();
|
||||
if (!EVRY_EVENT_ITEM_SELECT)
|
||||
EVRY_EVENT_ITEM_SELECT = ecore_event_type_new();
|
||||
if (!EVRY_EVENT_ITEM_CHANGED)
|
||||
EVRY_EVENT_ITEM_CHANGED = ecore_event_type_new();
|
||||
|
||||
e_module_delayed_set(m, 1);
|
||||
|
||||
return m;
|
||||
|
|
|
@ -110,6 +110,27 @@ evry_shutdown(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_evry_cb_item_changed(void *data, int type, void *event)
|
||||
{
|
||||
Evry_Event_Item_Changed *ev = event;
|
||||
Evry_Selector *sel;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
sel = selectors[i];
|
||||
|
||||
if (sel->state && sel->state->cur_item == ev->item)
|
||||
{
|
||||
_evry_selector_update(sel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
evry_show(E_Zone *zone, const char *params)
|
||||
{
|
||||
|
@ -170,6 +191,10 @@ evry_show(E_Zone *zone, const char *params)
|
|||
(handlers, ecore_event_handler_add
|
||||
(ECORE_X_EVENT_SELECTION_NOTIFY,
|
||||
_evry_cb_selection_notify, win));
|
||||
handlers = eina_list_append
|
||||
(handlers, ecore_event_handler_add
|
||||
(EVRY_EVENT_ITEM_CHANGED,
|
||||
_evry_cb_item_changed, NULL));
|
||||
|
||||
e_popup_layer_set(list->popup, 255);
|
||||
e_popup_layer_set(win->popup, 255);
|
||||
|
@ -333,19 +358,29 @@ evry_item_select(const Evry_State *state, Evry_Item *it)
|
|||
Evry_State *s = (Evry_State *)state;
|
||||
Evry_Selector *sel = selector;
|
||||
|
||||
if (!s && it)
|
||||
{
|
||||
sel = _selector_for_plugin_get(it->plugin);
|
||||
if (sel && sel->state)
|
||||
s = sel->state;
|
||||
else return;
|
||||
}
|
||||
|
||||
/* if (!s && it)
|
||||
* {
|
||||
* sel = _selector_for_plugin_get(it->plugin);
|
||||
* if (sel && sel->state)
|
||||
* s = sel->state;
|
||||
* else return;
|
||||
*
|
||||
* if (s->plugin != it->plugin)
|
||||
* {
|
||||
* it->selected = EINA_TRUE;
|
||||
* return;
|
||||
* }
|
||||
* } */
|
||||
|
||||
s->plugin_auto_selected = EINA_FALSE;
|
||||
s->item_auto_selected = EINA_FALSE;
|
||||
|
||||
_evry_item_sel(s, it);
|
||||
_evry_selector_update(sel);
|
||||
|
||||
if (s == sel->state)
|
||||
{
|
||||
_evry_selector_update(sel);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -790,14 +825,14 @@ _evry_selector_thumb(Evry_Selector *sel, const Evry_Item *it)
|
|||
|
||||
ITEM_FILE(file, it);
|
||||
|
||||
if (!file->uri || !file->mime) return 0;
|
||||
if (!file->path || !file->mime) return 0;
|
||||
|
||||
if (!strncmp(file->mime, "image/", 6))
|
||||
{
|
||||
sel->o_thumb = e_thumb_icon_add(win->popup->evas);
|
||||
evas_object_smart_callback_add(sel->o_thumb, "e_thumb_gen", _evry_selector_thumb_gen, sel);
|
||||
edje_object_part_geometry_get(sel->o_main, "e.swallow.thumb", NULL, NULL, &w, &h);
|
||||
e_thumb_icon_file_set(sel->o_thumb, file->uri, NULL);
|
||||
e_thumb_icon_file_set(sel->o_thumb, file->path, NULL);
|
||||
e_thumb_icon_size_set(sel->o_thumb, w, h);
|
||||
e_thumb_icon_begin(sel->o_thumb);
|
||||
sel->do_thumb = EINA_TRUE;
|
||||
|
@ -900,10 +935,27 @@ _evry_selector_update(Evry_Selector *sel)
|
|||
|
||||
if (s->plugin && (!it || s->item_auto_selected))
|
||||
{
|
||||
Eina_List *l;
|
||||
it = NULL;
|
||||
|
||||
/* get first selected item */
|
||||
/* EINA_LIST_FOREACH(s->plugin->items, l, it)
|
||||
* {
|
||||
* if (it->selected)
|
||||
* {
|
||||
* s->item_auto_selected = EINA_FALSE;
|
||||
* break;
|
||||
* }
|
||||
* } */
|
||||
|
||||
/* get first item */
|
||||
if (s->plugin->items)
|
||||
if (!it && s->plugin->items)
|
||||
{
|
||||
it = s->plugin->items->data;
|
||||
}
|
||||
|
||||
if (it)
|
||||
{
|
||||
s->item_auto_selected = EINA_TRUE;
|
||||
_evry_item_sel(s, it);
|
||||
}
|
||||
|
@ -1309,6 +1361,11 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
|||
else if (_evry_view_key_press(s, ev))
|
||||
goto end;
|
||||
}
|
||||
/* let plugin intercept keypress */
|
||||
else if (s->plugin && s->plugin->cb_key_down &&
|
||||
s->plugin->cb_key_down(s->plugin, ev))
|
||||
goto end;
|
||||
/* let view intercept keypress */
|
||||
else if (_evry_view_key_press(s, ev))
|
||||
goto end;
|
||||
else if (!strcmp(key, "Right"))
|
||||
|
@ -1743,8 +1800,11 @@ static void
|
|||
_evry_item_desel(Evry_State *s, Evry_Item *it)
|
||||
{
|
||||
if (s->cur_item)
|
||||
evry_item_free(s->cur_item);
|
||||
|
||||
{
|
||||
s->cur_item->selected = EINA_FALSE;
|
||||
evry_item_free(s->cur_item);
|
||||
}
|
||||
|
||||
s->cur_item = NULL;
|
||||
}
|
||||
|
||||
|
@ -1756,6 +1816,9 @@ _evry_item_sel(Evry_State *s, Evry_Item *it)
|
|||
_evry_item_desel(s, NULL);
|
||||
|
||||
evry_item_ref(it);
|
||||
|
||||
it->selected = EINA_TRUE;
|
||||
|
||||
s->cur_item = it;
|
||||
}
|
||||
|
||||
|
@ -1772,7 +1835,16 @@ _evry_plugin_select(Evry_State *s, Evry_Plugin *p)
|
|||
else s->plugin_auto_selected = EINA_FALSE;
|
||||
|
||||
if (s->plugin != p)
|
||||
_evry_item_desel(s, NULL);
|
||||
{
|
||||
_evry_item_desel(s, NULL);
|
||||
/* if (s->cur_item)
|
||||
* {
|
||||
* /\* s->cur_item->selected = EINA_FALSE; *\/
|
||||
* evry_item_free(s->cur_item);
|
||||
* }
|
||||
*
|
||||
* s->cur_item = NULL; */
|
||||
}
|
||||
|
||||
s->plugin = p;
|
||||
}
|
||||
|
|
|
@ -42,10 +42,6 @@ _begin(Evry_Plugin *p, const Evry_Item *it)
|
|||
type = it->plugin->type_out;
|
||||
if (!type) return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("begin %s\n", p->name);
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(evry_conf->actions, l, act)
|
||||
{
|
||||
|
|
|
@ -313,12 +313,12 @@ evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
|
|||
|
||||
if (open_folder)
|
||||
{
|
||||
path = ecore_file_dir_get(file->uri);
|
||||
path = ecore_file_dir_get(file->path);
|
||||
files = eina_list_append(files, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
files = eina_list_append(files, file->uri);
|
||||
files = eina_list_append(files, file->path);
|
||||
}
|
||||
|
||||
e_exec(zone, app->desktop, NULL, files, NULL);
|
||||
|
@ -341,7 +341,7 @@ evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
|
|||
{
|
||||
ITEM_FILE(file, it_file);
|
||||
|
||||
/* files = eina_list_append(files, file->uri);
|
||||
/* files = eina_list_append(files, file->path);
|
||||
*
|
||||
* e_exec(zone, NULL, app->file, files, NULL);
|
||||
*
|
||||
|
@ -350,7 +350,7 @@ evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
|
|||
|
||||
char *tmp;
|
||||
int len;
|
||||
tmp = eina_str_escape(file->uri);
|
||||
tmp = eina_str_escape(file->path);
|
||||
len = strlen(app->file) + strlen(tmp) + 2;
|
||||
exe = malloc(len);
|
||||
snprintf(exe, len, "%s %s", app->file, tmp);
|
||||
|
@ -367,3 +367,55 @@ evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* taken from curl:
|
||||
*
|
||||
* Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et
|
||||
* al.
|
||||
*
|
||||
* Unescapes the given URL escaped string of given length. Returns a
|
||||
* pointer to a malloced string with length given in *olen.
|
||||
* If length == 0, the length is assumed to be strlen(string).
|
||||
* If olen == NULL, no output length is stored.
|
||||
*/
|
||||
#define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
|
||||
|
||||
EAPI char *
|
||||
evry_util_unescape(const char *string, int length)
|
||||
{
|
||||
int alloc = (length?length:(int)strlen(string))+1;
|
||||
char *ns = malloc(alloc);
|
||||
unsigned char in;
|
||||
int strindex=0;
|
||||
unsigned long hex;
|
||||
|
||||
if( !ns )
|
||||
return NULL;
|
||||
|
||||
while(--alloc > 0) {
|
||||
in = *string;
|
||||
if(('%' == in) && ISXDIGIT(string[1]) && ISXDIGIT(string[2])) {
|
||||
/* this is two hexadecimal digits following a '%' */
|
||||
char hexstr[3];
|
||||
char *ptr;
|
||||
hexstr[0] = string[1];
|
||||
hexstr[1] = string[2];
|
||||
hexstr[2] = 0;
|
||||
|
||||
hex = strtoul(hexstr, &ptr, 16);
|
||||
in = (unsigned char)(hex & (unsigned long) 0xFF);
|
||||
// in = ultouc(hex); /* this long is never bigger than 255 anyway */
|
||||
|
||||
string+=2;
|
||||
alloc-=2;
|
||||
}
|
||||
|
||||
ns[strindex++] = in;
|
||||
string++;
|
||||
}
|
||||
ns[strindex]=0; /* terminate it */
|
||||
|
||||
return ns;
|
||||
}
|
||||
|
||||
#undef ISXDIGIT
|
||||
|
|
|
@ -66,10 +66,10 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item)
|
|||
ITEM_FILE(file, item);
|
||||
Efreet_Desktop *desktop;
|
||||
|
||||
if (!file->uri) return NULL;
|
||||
if (!file->path) return NULL;
|
||||
|
||||
if (!file->mime)
|
||||
mime = efreet_mime_type_get(file->uri);
|
||||
mime = efreet_mime_type_get(file->path);
|
||||
else
|
||||
mime = file->mime;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "Evry.h"
|
||||
|
||||
// TODO - show error when input not parseable
|
||||
|
||||
static int _cb_data(void *data, int type, void *event);
|
||||
static int _cb_error(void *data, int type, void *event);
|
||||
|
@ -97,7 +97,7 @@ static int
|
|||
_action(Evry_Plugin *p, const Evry_Item *it)
|
||||
{
|
||||
Eina_List *l;
|
||||
Evry_Item *it2;
|
||||
Evry_Item *it2, *it_old;
|
||||
|
||||
/* remove duplicates */
|
||||
if (p->items->next)
|
||||
|
@ -118,9 +118,10 @@ _action(Evry_Plugin *p, const Evry_Item *it)
|
|||
}
|
||||
}
|
||||
|
||||
it = p->items->data;
|
||||
|
||||
it2 = evry_item_new(NULL, p, it->label, NULL);
|
||||
it_old = p->items->data;
|
||||
it_old->selected = EINA_FALSE;
|
||||
|
||||
it2 = evry_item_new(NULL, p, it_old->label, NULL);
|
||||
p->items = eina_list_prepend(p->items, it2);
|
||||
|
||||
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
|
||||
|
@ -155,27 +156,40 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_cb_free_item_changed(void *data, void *event)
|
||||
{
|
||||
Evry_Event_Item_Changed *ev = event;
|
||||
|
||||
evry_item_free(ev->item);
|
||||
E_FREE(ev);
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_data(void *data, int type __UNUSED__, void *event)
|
||||
{
|
||||
Ecore_Exe_Event_Data *ev = event;
|
||||
Evry_Plugin *p = data;
|
||||
Evry_Item *it;
|
||||
|
||||
|
||||
if (ev->exe != exe) return 1;
|
||||
|
||||
if (ev->lines)
|
||||
{
|
||||
{
|
||||
it = p->items->data;
|
||||
p->items = eina_list_remove(p->items, it);
|
||||
evry_item_free(it);
|
||||
|
||||
it = evry_item_new(NULL, p, ev->lines->line, NULL);
|
||||
p->items = eina_list_prepend(p->items, it);
|
||||
eina_stringshare_del(it->label);
|
||||
it->label = eina_stringshare_add(ev->lines->line);
|
||||
|
||||
if (it)
|
||||
{
|
||||
Evry_Event_Item_Changed *ev = E_NEW(Evry_Event_Item_Changed, 1);
|
||||
ev->item = it;
|
||||
evry_item_ref(it);
|
||||
ecore_event_add(EVRY_EVENT_ITEM_CHANGED, ev, _cb_free_item_changed, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ _item_fill(Evry_Item_File *file)
|
|||
|
||||
if (file->mime) return;
|
||||
|
||||
if ((mime = efreet_mime_type_get(file->uri)))
|
||||
if ((mime = efreet_mime_type_get(file->path)))
|
||||
{
|
||||
file->mime = eina_stringshare_add(mime);
|
||||
EVRY_ITEM(file)->context = eina_stringshare_ref(file->mime);
|
||||
|
@ -85,7 +85,7 @@ static void
|
|||
_item_free(Evry_Item *it)
|
||||
{
|
||||
ITEM_FILE(file, it);
|
||||
if (file->uri) eina_stringshare_del(file->uri);
|
||||
if (file->path) eina_stringshare_del(file->path);
|
||||
if (file->mime) eina_stringshare_del(file->mime);
|
||||
|
||||
E_FREE(file);
|
||||
|
@ -123,9 +123,9 @@ _scan_func(void *data)
|
|||
EVRY_ITEM(file)->data = filename;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/%s", p->directory, filename);
|
||||
file->uri = strdup(buf);
|
||||
file->path = strdup(buf);
|
||||
|
||||
if (ecore_file_is_dir(file->uri))
|
||||
if (ecore_file_is_dir(file->path))
|
||||
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||
|
||||
d->files = eina_list_append(d->files, file);
|
||||
|
@ -153,10 +153,10 @@ _append_file(Plugin *p, Evry_Item_File *file)
|
|||
}
|
||||
|
||||
static const char *
|
||||
_item_id(const char *uri)
|
||||
_item_id(const char *path)
|
||||
{
|
||||
const char *s1, *s2, *s3;
|
||||
s1 = s2 = s3 = uri;
|
||||
s1 = s2 = s3 = path;
|
||||
|
||||
while (s1 && ++s1 && (s1 = strchr(s1, '/')))
|
||||
{
|
||||
|
@ -174,7 +174,7 @@ _scan_end_func(void *data)
|
|||
Plugin *p = d->plugin;
|
||||
int cnt = 0;
|
||||
Evry_Item *item;
|
||||
char *filename, *uri;
|
||||
char *filename, *path;
|
||||
|
||||
if (d->id != thread_last)
|
||||
{
|
||||
|
@ -193,12 +193,12 @@ _scan_end_func(void *data)
|
|||
ITEM_FILE(file, item);
|
||||
|
||||
filename = item->data;
|
||||
uri = (char *) file->uri;
|
||||
file->uri = eina_stringshare_add(uri);
|
||||
item->id = eina_stringshare_add(_item_id(uri));
|
||||
path = (char *) file->path;
|
||||
file->path = eina_stringshare_add(path);
|
||||
item->id = eina_stringshare_add(_item_id(path));
|
||||
item->label = eina_stringshare_add(filename);
|
||||
free(filename);
|
||||
free(uri);
|
||||
free(path);
|
||||
|
||||
p->files = eina_list_append(p->files, file);
|
||||
|
||||
|
@ -242,14 +242,14 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
|
|||
{
|
||||
ITEM_FILE(file, it);
|
||||
|
||||
if (!file->uri || !ecore_file_is_dir(file->uri))
|
||||
if (!file->path || !ecore_file_is_dir(file->path))
|
||||
return NULL;
|
||||
|
||||
p = E_NEW(Plugin, 1);
|
||||
p->base = *plugin;
|
||||
p->base.items = NULL;
|
||||
|
||||
p->directory = eina_stringshare_add(file->uri);
|
||||
p->directory = eina_stringshare_add(file->path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -295,7 +295,7 @@ _folder_item_add(Plugin *p, const char *path)
|
|||
if (!file) return;
|
||||
|
||||
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), path, _item_free);
|
||||
file->uri = eina_stringshare_add(path);
|
||||
file->path = eina_stringshare_add(path);
|
||||
file->mime = eina_stringshare_ref(mime_folder);
|
||||
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
||||
|
@ -419,14 +419,14 @@ _open_folder_action(Evry_Action *act)
|
|||
|
||||
if (!act->item1->browseable)
|
||||
{
|
||||
path = ecore_file_dir_get(file->uri);
|
||||
path = ecore_file_dir_get(file->path);
|
||||
if (!path) return 0;
|
||||
action->func.go(E_OBJECT(m->data), path);
|
||||
free(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
action->func.go(E_OBJECT(m->data), file->uri);
|
||||
action->func.go(E_OBJECT(m->data), file->path);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -442,9 +442,9 @@ _open_term_action(Evry_Action *act)
|
|||
int ret = 0;
|
||||
|
||||
if (act->item1->browseable)
|
||||
dir = strdup(file->uri);
|
||||
dir = strdup(file->path);
|
||||
else
|
||||
dir = ecore_file_dir_get(file->uri);
|
||||
dir = ecore_file_dir_get(file->path);
|
||||
|
||||
if (dir)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ _check_item(const Evry_Item *it)
|
|||
|
||||
ITEM_FILE(file, it);
|
||||
|
||||
if (!file->uri || !file->mime) return 0;
|
||||
if (!file->path || !file->mime) return 0;
|
||||
|
||||
if (!strncmp(file->mime, "image/", 6))
|
||||
return 1;
|
||||
|
@ -77,7 +77,7 @@ _show_item(Image_View *v, const Evry_Item_File *file, int dir)
|
|||
}
|
||||
|
||||
v->o_thumb[1] = e_thumb_icon_add(v->evas);
|
||||
e_thumb_icon_file_set(v->o_thumb[1], file->uri, NULL);
|
||||
e_thumb_icon_file_set(v->o_thumb[1], file->path, NULL);
|
||||
evas_object_smart_callback_add(v->o_thumb[1], "e_thumb_gen", _cb_preview_thumb_gen, v);
|
||||
edje_object_part_geometry_get(v->o_main, "e.swallow.icon2", NULL, NULL, &w, &h);
|
||||
e_thumb_icon_size_set(v->o_thumb[1], w, h);
|
||||
|
|
|
@ -17,6 +17,8 @@ struct _View
|
|||
int iw, ih;
|
||||
int zoom;
|
||||
int list_mode;
|
||||
|
||||
Eina_List *handlers;
|
||||
};
|
||||
|
||||
/* smart object based on wallpaper module */
|
||||
|
@ -84,7 +86,7 @@ _check_item(const Evry_Item *it)
|
|||
|
||||
ITEM_FILE(file, it);
|
||||
|
||||
if (!file->uri || !file->mime) return 0;
|
||||
if (!file->path || !file->mime) return 0;
|
||||
|
||||
if (!strncmp(file->mime, "image/", 6))
|
||||
return 1;
|
||||
|
@ -127,7 +129,7 @@ _thumb_idler(void *data)
|
|||
|
||||
evas_object_smart_callback_add(it->thumb, "e_thumb_gen", _thumb_gen, it);
|
||||
|
||||
e_thumb_icon_file_set(it->thumb, file->uri, NULL);
|
||||
e_thumb_icon_file_set(it->thumb, file->path, NULL);
|
||||
e_thumb_icon_size_set(it->thumb, it->w, it->h);
|
||||
e_thumb_icon_begin(it->thumb);
|
||||
it->do_thumb = EINA_TRUE;
|
||||
|
@ -285,17 +287,20 @@ _e_smart_reconfigure_do(void *data)
|
|||
{
|
||||
if (!it->visible)
|
||||
{
|
||||
it->frame = edje_object_add(sd->view->evas);
|
||||
if (sd->view->list_mode)
|
||||
e_theme_edje_object_set(it->frame, "base/theme/widgets",
|
||||
"e/modules/everything/thumbview/item/list");
|
||||
else
|
||||
e_theme_edje_object_set(it->frame, "base/theme/widgets",
|
||||
"e/modules/everything/thumbview/item/thumb");
|
||||
|
||||
evas_object_smart_member_add(it->frame, obj);
|
||||
evas_object_clip_set(it->frame, evas_object_clip_get(obj));
|
||||
if (!it->frame)
|
||||
{
|
||||
it->frame = edje_object_add(sd->view->evas);
|
||||
if (sd->view->list_mode)
|
||||
e_theme_edje_object_set(it->frame, "base/theme/widgets",
|
||||
"e/modules/everything/thumbview/item/list");
|
||||
else
|
||||
e_theme_edje_object_set(it->frame, "base/theme/widgets",
|
||||
"e/modules/everything/thumbview/item/thumb");
|
||||
|
||||
evas_object_smart_member_add(it->frame, obj);
|
||||
evas_object_clip_set(it->frame, evas_object_clip_get(obj));
|
||||
}
|
||||
|
||||
edje_object_part_text_set(it->frame, "e.text.label", it->item->label);
|
||||
evas_object_show(it->frame);
|
||||
|
||||
|
@ -702,7 +707,8 @@ _view_update(Evry_View *view)
|
|||
v_it->pos = pos;
|
||||
|
||||
/* set selected state -> TODO remove*/
|
||||
if (p_it == v->state->cur_item)
|
||||
/* if (p_it == v->state->cur_item) */
|
||||
if (p_it->selected)
|
||||
{
|
||||
sd->cur_item = v_it;
|
||||
v_it->selected = EINA_TRUE;
|
||||
|
@ -760,7 +766,8 @@ _view_update(Evry_View *view)
|
|||
v_it->pos = pos;
|
||||
|
||||
/* TODO no needed */
|
||||
if (p_it == v->state->cur_item)
|
||||
/* if (p_it == v->state->cur_item) */
|
||||
if (p_it->selected)
|
||||
{
|
||||
sd->cur_item = v_it;
|
||||
v_it->selected = EINA_TRUE;
|
||||
|
@ -926,6 +933,41 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
|||
end:
|
||||
return 1;
|
||||
}
|
||||
static int
|
||||
_cb_item_changed(void *data, int type, void *event)
|
||||
{
|
||||
Evry_Event_Item_Changed *ev = event;
|
||||
View *v = data;
|
||||
Eina_List *l;
|
||||
Item *it;
|
||||
Smart_Data *sd = evas_object_smart_data_get(v->span);
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
if (it->item == ev->item)
|
||||
{
|
||||
if (!it->visible) break;
|
||||
|
||||
edje_object_part_text_set(it->frame, "e.text.label", it->item->label);
|
||||
|
||||
if (it->do_thumb) e_thumb_icon_end(it->thumb);
|
||||
if (it->thumb) evas_object_del(it->thumb);
|
||||
if (it->image) evas_object_del(it->image);
|
||||
|
||||
it->thumb = NULL;
|
||||
it->image = NULL;
|
||||
|
||||
it->have_thumb = EINA_FALSE;
|
||||
it->do_thumb = EINA_FALSE;
|
||||
|
||||
if (!eina_list_data_find(sd->queue, it))
|
||||
sd->queue = eina_list_append(sd->queue, it);
|
||||
|
||||
if (!sd->thumb_idler)
|
||||
sd->thumb_idler = ecore_idle_enterer_before_add(_thumb_idler, sd);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evry_View *
|
||||
_view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow)
|
||||
|
@ -933,6 +975,7 @@ _view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow)
|
|||
VIEW(parent, view);
|
||||
|
||||
View *v;
|
||||
Ecore_Event_Handler *h;
|
||||
|
||||
if (!s->plugin)
|
||||
return NULL;
|
||||
|
@ -972,6 +1015,9 @@ _view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow)
|
|||
v->tabs = evry_tab_view_new(s, v->evas);
|
||||
v->view.o_bar = v->tabs->o_tabs;
|
||||
|
||||
h = ecore_event_handler_add(EVRY_EVENT_ITEM_CHANGED, _cb_item_changed, v);
|
||||
v->handlers = eina_list_append(v->handlers, h);
|
||||
|
||||
return EVRY_VIEW(v);
|
||||
}
|
||||
|
||||
|
@ -980,12 +1026,18 @@ _view_destroy(Evry_View *view)
|
|||
{
|
||||
VIEW(v, view);
|
||||
|
||||
Ecore_Event_Handler *h;
|
||||
|
||||
evas_object_del(v->bg);
|
||||
evas_object_del(v->sframe);
|
||||
evas_object_del(v->span);
|
||||
|
||||
evry_tab_view_free(v->tabs);
|
||||
|
||||
EINA_LIST_FREE(v->handlers, h)
|
||||
ecore_event_handler_del(h);
|
||||
|
||||
|
||||
E_FREE(v);
|
||||
}
|
||||
|
||||
|
@ -1001,7 +1053,6 @@ _init(void)
|
|||
v->view.update = &_view_update;
|
||||
v->view.clear = &_view_clear;
|
||||
v->view.cb_key_down = &_cb_key_down;
|
||||
|
||||
v->list_mode = -1;
|
||||
|
||||
evry_view_register(EVRY_VIEW(v), 1);
|
||||
|
|
Loading…
Reference in New Issue