'everything'

- optimized view to update when required
- dirbrowse send asnyc upadte only when current list has changed
- ++ evry_action priorities, needs config option though
- moved _app_action to evry_util_app_exec


SVN revision: 42051
This commit is contained in:
Hannes Janetzek 2009-08-28 02:25:13 +00:00
parent a72325c9d3
commit f211ebb853
14 changed files with 398 additions and 342 deletions

View File

@ -28270,13 +28270,13 @@ MIMEBASE("application/x-font-bdf","icon_mime_font_generic.png", ".BDF", 128);
program { name: "thumb_show_delayed";
signal: "e,action,thumb,show_delayed";
source: "e";
action: STATE_SET "default" 0.2;
action: STATE_SET "default" 0.1;
target: "base";
after: "thumb_show_delayed2";
}
program { name: "thumb_show_delayed2";
action: STATE_SET "visible" 0.0;
transition: SINUSOIDAL 0.6;
transition: SINUSOIDAL 0.2;
target: "base";
}
program { name: "thumb_show";
@ -28335,7 +28335,7 @@ MIMEBASE("application/x-font-bdf","icon_mime_font_generic.png", ".BDF", 128);
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
visible: 0;
visible: 1;
color: 255 255 255 255;
}
}
@ -28389,7 +28389,7 @@ MIMEBASE("application/x-font-bdf","icon_mime_font_generic.png", ".BDF", 128);
}
part { name: "e.text.label";
type: TEXT;
/* clip_to: "base"; */
clip_to: "base";
effect: SOFT_SHADOW;
mouse_events: 0;
scale: 1;
@ -28452,13 +28452,13 @@ MIMEBASE("application/x-font-bdf","icon_mime_font_generic.png", ".BDF", 128);
program { name: "thumb_show_delayed";
signal: "e,action,thumb,show_delayed";
source: "e";
action: STATE_SET "default" 0.2;
action: STATE_SET "default" 0.1;
target: "base";
after: "thumb_show_delayed2";
}
program { name: "thumb_show_delayed2";
action: STATE_SET "visible" 0.0;
transition: SINUSOIDAL 0.3;
transition: SINUSOIDAL 0.2;
target: "base";
}
program { name: "thumb_show";

View File

@ -211,34 +211,35 @@ struct _Evry_Action
/* not to be set by plugin! */
Evas_Object *o_icon;
int priority;
};
EAPI void evry_plugin_register(Evry_Plugin *p, int priority);
EAPI void evry_plugin_unregister(Evry_Plugin *p);
EAPI void evry_action_register(Evry_Action *act);
EAPI void evry_action_unregister(Evry_Action *act);
EAPI void evry_view_register(Evry_View *view, int priority);
EAPI void evry_view_unregister(Evry_View *view);
/* evry.c */
EAPI void evry_item_select(const Evry_State *s, Evry_Item *it);
EAPI void evry_plugin_select(const Evry_State *s, Evry_Plugin *p);
EAPI int evry_list_win_show(void);
EAPI void evry_list_win_hide(void);
EAPI Evry_Item *evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label, void (*cb_free) (Evry_Item *item));
EAPI void evry_item_free(Evry_Item *it);
EAPI void evry_item_ref(Evry_Item *it);
EAPI void evry_plugin_async_update(Evry_Plugin *plugin, int state);
EAPI void evry_clear_input(void);
/* evry_util.c */
EAPI Evas_Object *evry_icon_mime_get(const char *mime, Evas *e);
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);
/* e_mod_main.c */
EAPI void evry_plugin_register(Evry_Plugin *p, int priority);
EAPI void evry_plugin_unregister(Evry_Plugin *p);
EAPI void evry_action_register(Evry_Action *act, int priority);
EAPI void evry_action_unregister(Evry_Action *act);
EAPI void evry_view_register(Evry_View *view, int priority);
EAPI void evry_view_unregister(Evry_View *view);
EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, int type,
const char *type_in, const char *type_out,

View File

@ -8,9 +8,9 @@ struct _Inst
E_Border *border;
};
static Evry_Plugin *plugin;
static Inst *inst;
static Evry_Plugin *plugin = NULL;
static Inst *inst = NULL;
static Evry_Action *act = NULL;
static void
_act_cb_border_switch_to(E_Border *bd)
@ -198,6 +198,52 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
return o;
}
static int
_exec_border_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
{
E_Border *bd = it->data;
E_OBJECT_CHECK_RETURN(bd, 0);
E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, 0);
if ((bd->desktop && bd->desktop->exec) &&
((strstr(bd->desktop->exec, "%u")) ||
(strstr(bd->desktop->exec, "%U")) ||
(strstr(bd->desktop->exec, "%f")) ||
(strstr(bd->desktop->exec, "%F"))))
return 1;
return 0;
}
static int
_exec_border_action(Evry_Action *act)
{
return evry_util_exec_app(act->item1, act->item2);
}
static int
_exec_border_intercept(Evry_Action *act)
{
Evry_Item_App *app = E_NEW(Evry_Item_App, 1);
E_Border *bd = act->item1->data;
app->desktop = bd->desktop;
act->item1 = EVRY_ITEM(app);
return 1;
}
static void
_exec_border_cleanup(Evry_Action *act)
{
ITEM_APP(app, act->item1);
E_FREE(app);
}
static Eina_Bool
_init(void)
{
@ -205,9 +251,14 @@ _init(void)
_begin, _cleanup, _fetch, _action, _item_icon_get, NULL, NULL);
evry_plugin_register(plugin, 1);
inst = E_NEW(Inst, 1);
act = evry_action_new("Open File...", "BORDER", "FILE", "APPLICATION",
"everything-launch",
_exec_border_action, _exec_border_check_item,
_exec_border_cleanup, _exec_border_intercept, NULL);
evry_action_register(act, 10);
return EINA_TRUE;
}
@ -216,6 +267,8 @@ _shutdown(void)
{
EVRY_PLUGIN_FREE(plugin);
E_FREE(inst);
evry_action_free(act);
}

View File

@ -30,7 +30,7 @@ _init(void)
act = evry_action_new("Copy to Clipboard", "TEXT", NULL, NULL, "edit-copy",
_action, _check_item, NULL, NULL, NULL);
evry_action_register(act);
evry_action_register(act, 10);
clipboard_win = win;

View File

@ -453,8 +453,9 @@ evry_plugin_unregister(Evry_Plugin *p)
}
void
evry_action_register(Evry_Action *action)
evry_action_register(Evry_Action *action, int priority)
{
action->priority = priority;
evry_conf->actions = eina_list_append(evry_conf->actions, action);
/* TODO sorting, initialization, etc */
}

View File

@ -105,5 +105,5 @@ EAPI void evry_tab_view_free(Tab_View *v);
extern Config *evry_conf;
extern Evry_Selector **selectors;
extern Evry_Plugin *action_selector;
#endif

View File

@ -89,11 +89,12 @@ static Evry_List_Window *list = NULL;
static Ecore_X_Window input_window = 0;
static Eina_List *handlers = NULL;
static Ecore_Timer *update_timer = NULL;
static Evry_Plugin *action_selector = NULL;
static Evry_Selector *selector = NULL;
static const char *thumb_types = NULL;
Evry_Selector **selectors;
Evry_Plugin *action_selector;
/* externally accessible functions */
int

View File

@ -58,10 +58,6 @@ _cb_sort(const void *data1, const void *data2)
const Evry_Item *it1 = data1;
const Evry_Item *it2 = data2;
if ((it1->plugin == it2->plugin) &&
(it1->priority - it2->priority))
return (it1->priority - it2->priority);
if (it1->fuzzy_match || it2->fuzzy_match)
{
if (it1->fuzzy_match && !it2->fuzzy_match)
@ -74,9 +70,6 @@ _cb_sort(const void *data1, const void *data2)
return (it1->fuzzy_match - it2->fuzzy_match);
}
if (it1->plugin->config->priority - it2->plugin->config->priority)
return (it1->plugin->config->priority - it2->plugin->config->priority);
if (it1->priority - it2->priority)
return (it1->priority - it2->priority);
@ -105,6 +98,7 @@ _fetch(Evry_Plugin *p, const char *input)
it = evry_item_new(NULL, p, act->name, NULL);
it->fuzzy_match = match;
it->data = act;
it->priority = act->priority;
EVRY_PLUGIN_ITEM_APPEND(p, it);
}
}

View File

@ -16,6 +16,18 @@ _cb_sort(const void *data1, const void *data2)
const Evry_Item *it1 = data1;
const Evry_Item *it2 = data2;
if ((it1->plugin == action_selector) ||
(it2->plugin == action_selector))
{
if ((it1->plugin == action_selector) &&
(it2->plugin == action_selector))
return (it1->priority - it2->priority);
else if (it1->plugin == action_selector)
return (it1->priority - it2->plugin->config->priority);
else
return (it1->plugin->config->priority - it2->priority);
}
if ((it1->plugin == it2->plugin) &&
(it1->priority - it2->priority))
return (it1->priority - it2->priority);

View File

@ -276,3 +276,84 @@ evry_icon_mime_get(const char *mime, Evas *e)
return o;
}
EAPI int
evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
{
E_Zone *zone;
Eina_List *files = NULL;
char *exe = NULL;
if (!it_app) return 0;
ITEM_APP(app, it_app);
zone = e_util_zone_current_get(e_manager_current_get());
if (app->desktop)
{
if (it_file)
{
ITEM_FILE(file, it_file);
Eina_List *l;
char *mime;
char *path = NULL;
int open_folder = 0;
if (!EVRY_ITEM(file)->browseable)
{
EINA_LIST_FOREACH(app->desktop->mime_types, l, mime)
{
if (!strcmp(mime, "x-directory/normal"))
{
open_folder = 1;
break;
}
}
}
if (open_folder)
{
path = ecore_file_dir_get(file->uri);
files = eina_list_append(files, path);
}
else
{
files = eina_list_append(files, file->uri);
}
e_exec(zone, app->desktop, NULL, files, NULL);
if (file && file->mime && !open_folder)
e_exehist_mime_desktop_add(file->mime, app->desktop);
if (files)
eina_list_free(files);
if (open_folder && path)
free(path);
}
else
e_exec(zone, app->desktop, NULL, NULL, "everything");
}
else if (app->file)
{
if (it_file)
{
ITEM_FILE(file, it_file);
int len;
len = strlen(app->file) + strlen(file->uri) + 2;
exe = malloc(len);
snprintf(exe, len, "%s %s", app->file, file->uri);
e_exec(zone, NULL, exe, NULL, NULL);
free(exe);
}
else
{
exe = (char *) app->file;
e_exec(zone, NULL, exe, NULL, NULL);
}
}
return 1;
}

View File

@ -1,7 +1,7 @@
#include "Evry.h"
#define TERM_ACTION_CMD "/usr/bin/xterm -hold -e '%s'"
#define TERM_ACTION_DIR "/usr/bin/xterm -e \'cd %s && /bin/bash\'"
typedef struct _Plugin Plugin;
@ -34,8 +34,6 @@ static Evry_Action *act1 = NULL;
static Evry_Action *act2 = NULL;
static Evry_Action *act3 = NULL;
static Evry_Action *act4 = NULL;
static Evry_Action *act5 = NULL;
static Evry_Action *act6 = NULL;
static Eina_List *exe_path = NULL;
static Ecore_Idler *exe_scan_idler = NULL;
@ -494,92 +492,10 @@ _exec_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
return 0;
}
static int
_app_action(const Evry_Item *it1, const Evry_Item *it2)
{
E_Zone *zone;
Eina_List *files = NULL;
char *exe = NULL;
if (!it1) return 0;
ITEM_APP(app, it1);
zone = e_util_zone_current_get(e_manager_current_get());
if (app->desktop)
{
if (it2)
{
ITEM_FILE(file, it2);
Eina_List *l;
char *mime;
char *path = NULL;
int open_folder = 0;
if (!EVRY_ITEM(file)->browseable)
{
EINA_LIST_FOREACH(app->desktop->mime_types, l, mime)
{
if (!strcmp(mime, "x-directory/normal"))
{
open_folder = 1;
break;
}
}
}
if (open_folder)
{
path = ecore_file_dir_get(file->uri);
files = eina_list_append(files, path);
}
else
{
files = eina_list_append(files, file->uri);
}
e_exec(zone, app->desktop, NULL, files, NULL);
if (file && file->mime && !open_folder)
e_exehist_mime_desktop_add(file->mime, app->desktop);
if (files)
eina_list_free(files);
if (open_folder && path)
free(path);
}
else
e_exec(zone, app->desktop, NULL, NULL, "everything");
}
else if (app->file)
{
if (it2)
{
ITEM_FILE(file, it2);
int len;
len = strlen(app->file) + strlen(file->uri) + 2;
exe = malloc(len);
snprintf(exe, len, "%s %s", app->file, file->uri);
e_exec(zone, NULL, exe, NULL, NULL);
free(exe);
}
else
{
exe = (char *) app->file;
e_exec(zone, NULL, exe, NULL, NULL);
}
}
return 1;
}
static int
_exec_app_action(Evry_Action *act)
{
return _app_action(act->item1, act->item2);
return evry_util_exec_app(act->item1, act->item2);
}
/* TODO config option for terminal and shell! */
@ -594,7 +510,7 @@ _exec_term_action(Evry_Action *act)
tmp = E_NEW(Evry_Item_App, 1);
snprintf(buf, sizeof(buf), TERM_ACTION_CMD, app->file);
tmp->file = buf;
ret = _app_action(EVRY_ITEM(tmp), NULL);
ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL);
E_FREE(tmp);
@ -618,45 +534,11 @@ _open_with_action(Evry_Plugin *plugin, const Evry_Item *it)
PLUGIN(p, plugin);
if (p->candidate)
return _app_action(it, p->candidate);
return evry_util_exec_app(it, p->candidate);
return 0;
}
static int
_open_term_action(Evry_Action *act)
{
ITEM_FILE(file, act->item1);
Evry_Item_App *tmp;
char buf[1024];
char *dir, *path;
int ret = 0;
if (act->item1->browseable)
{
path = ecore_file_escape_name(file->uri);
}
else
{
dir = ecore_file_dir_get(file->uri);
if (!dir) return 0;
path = ecore_file_escape_name(dir);
free(dir);
}
if (path)
{
tmp = E_NEW(Evry_Item_App, 1);
snprintf(buf, sizeof(buf), TERM_ACTION_DIR, path);
tmp->file = buf;
ret = _app_action(EVRY_ITEM(tmp), NULL);
E_FREE(tmp);
free(path);
}
return ret;
}
static int
@ -760,49 +642,6 @@ _new_app_action(Evry_Action *act)
return 1;
}
static int
_exec_border_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
{
E_Border *bd = it->data;
E_OBJECT_CHECK_RETURN(bd, 0);
E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, 0);
if ((bd->desktop && bd->desktop->exec) &&
((strstr(bd->desktop->exec, "%u")) ||
(strstr(bd->desktop->exec, "%U")) ||
(strstr(bd->desktop->exec, "%f")) ||
(strstr(bd->desktop->exec, "%F"))))
return 1;
return 0;
}
static int
_exec_border_action(Evry_Action *act)
{
return _app_action(act->item1, act->item2);
}
static int
_exec_border_intercept(Evry_Action *act)
{
Evry_Item_App *app = E_NEW(Evry_Item_App, 1);
E_Border *bd = act->item1->data;
app->desktop = bd->desktop;
act->item1 = EVRY_ITEM(app);
return 1;
}
static void
_exec_border_cleanup(Evry_Action *act)
{
ITEM_APP(app, act->item1);
E_FREE(app);
}
static Eina_Bool
_init(void)
@ -817,51 +656,43 @@ _init(void)
_icon_get, NULL, NULL);
evry_plugin_register(EVRY_PLUGIN(p1), 1);
evry_plugin_register(EVRY_PLUGIN(p2), 3);
evry_plugin_register(EVRY_PLUGIN(p2), 1);
act = evry_action_new("Launch", "APPLICATION", NULL, NULL,
"everything-launch",
_exec_app_action, _exec_app_check_item,
NULL, NULL,NULL);
act1 = evry_action_new("Open File...", "APPLICATION", "FILE", "APPLICATION",
"document-open",
_exec_app_action, _exec_app_check_item,
NULL, NULL, NULL);
act2 = evry_action_new("Edit Application Entry", "APPLICATION", NULL, NULL,
"everything-launch",
_edit_app_action, _edit_app_check_item,
NULL, NULL, NULL);
act3 = evry_action_new("New Application Entry", "APPLICATION", NULL, NULL,
"everything-launch",
_new_app_action, _new_app_check_item,
NULL, NULL, NULL);
act4 = evry_action_new("Open File...", "BORDER", "FILE", "APPLICATION",
"everything-launch",
_exec_border_action, _exec_border_check_item,
_exec_border_cleanup, _exec_border_intercept, NULL);
act5 = evry_action_new("Run in Terminal", "APPLICATION", NULL, NULL,
act2 = evry_action_new("Run in Terminal", "APPLICATION", NULL, NULL,
"system-run",
_exec_term_action, _exec_term_check_item,
NULL, NULL, NULL);
act6 = evry_action_new("Open Terminal here", "FILE", NULL, NULL,
"system-run",
_open_term_action, NULL, NULL, NULL, NULL);
act3 = evry_action_new("Edit Application Entry", "APPLICATION", NULL, NULL,
"everything-launch",
_edit_app_action, _edit_app_check_item,
NULL, NULL, NULL);
act4 = evry_action_new("New Application Entry", "APPLICATION", NULL, NULL,
"everything-launch",
_new_app_action, _new_app_check_item,
NULL, NULL, NULL);
evry_action_register(act, 0);
evry_action_register(act1, 1);
evry_action_register(act2, 2);
evry_action_register(act3, 3);
evry_action_register(act4, 4);
evry_action_register(act);
evry_action_register(act1);
evry_action_register(act5);
evry_action_register(act6);
evry_action_register(act2);
evry_action_register(act3);
evry_action_register(act4);
/* taken from e_exebuf.c */
exelist_exe_edd = E_CONFIG_DD_NEW("E_Exe", E_Exe);
#undef T
@ -891,8 +722,6 @@ _shutdown(void)
evry_action_free(act2);
evry_action_free(act3);
evry_action_free(act4);
evry_action_free(act5);
evry_action_free(act6);
E_CONFIG_DD_FREE(exelist_edd);
E_CONFIG_DD_FREE(exelist_exe_edd);

View File

@ -122,7 +122,8 @@ _init(void)
_action, NULL, NULL, NULL, NULL);
evry_plugin_register(p, 10);
evry_action_register(act);
evry_action_register(act, 0);
return EINA_TRUE;
}

View File

@ -1,7 +1,7 @@
#include "Evry.h"
#define MAX_ITEMS 100
#define TERM_ACTION_DIR "/usr/bin/xterm -e \'cd %s && /bin/bash\'"
typedef struct _Plugin Plugin;
typedef struct _Data Data;
@ -30,9 +30,10 @@ struct _Data
Eina_List *files;
};
static Evry_Plugin *p1;
static Evry_Plugin *p2;
static Evry_Action *act;
static Evry_Plugin *p1 = NULL;
static Evry_Plugin *p2 = NULL;
static Evry_Action *act1 = NULL;
static Evry_Action *act2 = NULL;
static long thread_cnt = 0;
static long thread_last = 0;
@ -86,6 +87,8 @@ _dirbrowse_idler(void *data)
Plugin *p = data;
Eina_List *l;
Evry_Item_File *file;
Eina_Bool update = EINA_FALSE;
int cnt = 20;
if (!p->idler) return 0;
@ -96,11 +99,15 @@ _dirbrowse_idler(void *data)
{
_item_fill(file);
cnt--;
if (eina_list_data_find_list(EVRY_PLUGIN(p)->items, file))
update = EINA_TRUE;
}
if (cnt == 0) break;
}
if (!p->command)
if (update && !p->command)
{
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD);
@ -456,6 +463,41 @@ _open_folder_action(Evry_Action *act)
return 1;
}
static int
_open_term_action(Evry_Action *act)
{
ITEM_FILE(file, act->item1);
Evry_Item_App *tmp;
char buf[1024];
char *dir, *path;
int ret = 0;
if (act->item1->browseable)
{
path = ecore_file_escape_name(file->uri);
}
else
{
dir = ecore_file_dir_get(file->uri);
if (!dir) return 0;
path = ecore_file_escape_name(dir);
free(dir);
}
if (path)
{
tmp = E_NEW(Evry_Item_App, 1);
snprintf(buf, sizeof(buf), TERM_ACTION_DIR, path);
tmp->file = buf;
ret = evry_util_exec_app(EVRY_ITEM(tmp), NULL);
E_FREE(tmp);
free(path);
}
return ret;
}
static Eina_Bool
_init(void)
{
@ -470,11 +512,18 @@ _init(void)
evry_plugin_register(p1, 3);
evry_plugin_register(p2, 1);
act = evry_action_new("Open Folder (EFM)", "FILE", NULL, NULL, "folder-open",
_open_folder_action, _open_folder_check, NULL, NULL, NULL);
act1 = evry_action_new("Open Folder (EFM)", "FILE", NULL, NULL, "folder-open",
_open_folder_action, _open_folder_check, NULL, NULL, NULL);
evry_action_register(act1, 0);
evry_action_register(act);
act2 = evry_action_new("Open Terminal here", "FILE", NULL, NULL,
"system-run",
_open_term_action, NULL, NULL, NULL, NULL);
evry_action_register(act2, 2);
mime_folder = eina_stringshare_add("inode/directory");
return EINA_TRUE;
@ -488,7 +537,8 @@ _shutdown(void)
eina_stringshare_del(mime_folder);
evry_action_free(act);
evry_action_free(act1);
evry_action_free(act2);
}

View File

@ -7,10 +7,12 @@ typedef struct _Item Item;
struct _View
{
Evry_View view;
Evas *evas;
const Evry_State *state;
Tab_View *tabs;
const Evry_State *state;
const Evry_Plugin *plugin;
Evas *evas;
Evas_Object *bg, *sframe, *span;
int iw, ih;
int zoom;
@ -25,13 +27,14 @@ struct _Smart_Data
Item *sel_item;
Ecore_Idle_Enterer *idle_enter;
Ecore_Idle_Enterer *thumb_idler;
Ecore_Idle_Enterer *update_idler;
Ecore_Animator *animator;
Evas_Coord x, y, w, h;
Evas_Coord cx, cy, cw, ch;
Evas_Coord sx, sy;
double selmove;
Eina_Bool update : 1;
Eina_Bool switch_mode : 1;
};
struct _Item
@ -118,7 +121,7 @@ _e_smart_reconfigure_do(void *data)
Item *it;
int iw, redo = 0, changed = 0;
static int recursion = 0;
Evas_Coord x, y, xx, yy, ww, hh, mw, mh, ox, oy; //, dd;
Evas_Coord x, y, xx, yy, ww, hh, mw, mh, ox = 0, oy = 0;
Evas_Coord aspect_w, aspect_h;
if (!sd) return 0;
@ -223,31 +226,25 @@ _e_smart_reconfigure_do(void *data)
changed = 1;
}
ox = 0;
oy = 0;
if (sd->switch_mode)
{
if (changed)
evas_object_smart_callback_call(obj, "changed", NULL);
sd->update = EINA_TRUE;
sd->switch_mode = EINA_FALSE;
if (recursion == 0)
sd->idle_enter = NULL;
return 0;
}
if (!sd->view->list_mode)
{
if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2;
if (sd->h > sd->ch) oy = (sd->h - sd->ch) / 2;
}
if (sd->sel_item)
{
int align = -1;
it = sd->sel_item;
if (sd->view->list_mode)
align = it->y - (double)it->y / (double)sd->ch * (sd->h - it->h);
else if ((it->y + it->h) - sd->cy > sd->h)
align = it->y - (2 - sd->view->zoom) * it->h;
else if (it->y < sd->cy)
align = it->y;
if (align >= 0)
e_scrollframe_child_pos_set(sd->view->sframe, 0, align);
}
EINA_LIST_FOREACH(sd->items, l, it)
{
xx = sd->x - sd->cx + it->x + ox;
@ -272,23 +269,18 @@ _e_smart_reconfigure_do(void *data)
edje_object_part_text_set(it->frame, "e.text.label", it->item->label);
evas_object_show(it->frame);
if (sd->update)
edje_object_signal_emit(it->frame, "e,action,thumb,show_delayed", "e");
if (it->changed)
{
edje_object_signal_emit(it->frame, "e,action,thumb,show_delayed", "e");
}
else
edje_object_signal_emit(it->frame, "e,action,thumb,show", "e");
{
edje_object_signal_emit(it->frame, "e,action,thumb,show", "e");
}
it->visible = EINA_TRUE;
}
/* hmmm somehow this should be moved up to !it->visible */
if (sd->update)
{
if (it->selected && sd->view->zoom < 2)
edje_object_signal_emit(it->frame, "e,state,selected", "e");
else
edje_object_signal_emit(it->frame, "e,state,unselected", "e");
}
if (!it->image && !it->have_thumb &&
it->item->plugin && it->item->plugin->icon_get)
{
@ -305,6 +297,14 @@ _e_smart_reconfigure_do(void *data)
evas_object_move(it->frame, xx, yy);
evas_object_resize(it->frame, it->w, it->h);
if (sd->update || it->changed)
{
if (it->selected && sd->view->zoom < 2)
edje_object_signal_emit(it->frame, "e,state,selected", "e");
else
edje_object_signal_emit(it->frame, "e,state,unselected", "e");
}
if (it->get_thumb && !it->thumb)
{
it->thumb = e_thumb_icon_add(sd->view->evas);
@ -312,6 +312,9 @@ _e_smart_reconfigure_do(void *data)
if (!sd->thumb_idler)
sd->thumb_idler = ecore_idle_enterer_before_add(_thumb_idler, sd);
}
it->changed = EINA_FALSE;
}
else if (it->visible)
{
@ -327,8 +330,8 @@ _e_smart_reconfigure_do(void *data)
it->have_thumb = EINA_FALSE;
it->do_thumb = EINA_FALSE;
it->visible = EINA_FALSE;
it->changed = TRUE;
}
it->changed = EINA_FALSE;
}
if (changed)
@ -406,39 +409,19 @@ _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
}
static void
_e_smart_show(Evas_Object *obj)
{
/* Smart_Data *sd = evas_object_smart_data_get(obj); */
// evas_object_show(sd->child_obj);
}
_e_smart_show(Evas_Object *obj){}
static void
_e_smart_hide(Evas_Object *obj)
{
/* Smart_Data *sd = evas_object_smart_data_get(obj); */
// evas_object_hide(sd->child_obj);
}
_e_smart_hide(Evas_Object *obj){}
static void
_e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
{
/* Smart_Data *sd = evas_object_smart_data_get(obj); */
// evas_object_color_set(sd->child_obj, r, g, b, a);
}
_e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a){}
static void
_e_smart_clip_set(Evas_Object *obj, Evas_Object * clip)
{
/* Smart_Data *sd = evas_object_smart_data_get(obj); */
// evas_object_clip_set(sd->child_obj, clip);
}
_e_smart_clip_set(Evas_Object *obj, Evas_Object * clip){}
static void
_e_smart_clip_unset(Evas_Object *obj)
{
/* Smart_Data *sd = evas_object_smart_data_get(obj); */
// evas_object_clip_unset(sd->child_obj);
}
_e_smart_clip_unset(Evas_Object *obj){}
static Evas_Object *
_pan_add(Evas *evas)
@ -546,6 +529,7 @@ _pan_item_add(Evas_Object *obj, Evry_Item *item)
sd->items = eina_list_append(sd->items, it);
it->obj = obj;
it->item = item;
it->changed = EINA_TRUE;
if (_check_item(item))
it->get_thumb = EINA_TRUE;
@ -578,18 +562,36 @@ static void
_pan_item_select(Evas_Object *obj, Item *it)
{
Smart_Data *sd = evas_object_smart_data_get(obj);
int align = -1;
sd->sel_item->selected = EINA_FALSE;
edje_object_signal_emit(sd->sel_item->frame, "e,state,unselected", "e");
sd->sel_item = it;
sd->sel_item->selected = EINA_TRUE;
if (sd->sel_item)
{
sd->sel_item->selected = EINA_FALSE;
edje_object_signal_emit(sd->sel_item->frame, "e,state,unselected", "e");
sd->sel_item = it;
sd->sel_item->selected = EINA_TRUE;
}
sd->update = EINA_FALSE;
if (sd->view->zoom < 2)
edje_object_signal_emit(sd->sel_item->frame, "e,state,selected", "e");
if (it)
{
sd->update = EINA_FALSE;
if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter);
sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj);
if (sd->view->list_mode)
align = it->y - (double)it->y / (double)sd->ch * (sd->h - it->h);
else if ((it->y + it->h) - sd->cy > sd->h)
align = it->y - (2 - sd->view->zoom) * it->h;
else if (it->y < sd->cy)
align = it->y;
if (align >= 0)
e_scrollframe_child_pos_set(sd->view->sframe, 0, align);
if (sd->view->zoom < 2)
edje_object_signal_emit(sd->sel_item->frame, "e,state,selected", "e");
if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter);
sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, obj);
}
}
static void
@ -624,6 +626,21 @@ _sort_cb(const void *data1, const void *data2)
return it1->pos - it2->pos;
}
static int
_update_frame(Evas_Object *obj)
{
Smart_Data *sd = evas_object_smart_data_get(obj);
sd->switch_mode = EINA_TRUE;
_e_smart_reconfigure_do(obj);
sd->switch_mode = EINA_FALSE;
_pan_item_select(obj, sd->sel_item);
return 0;
}
static int _view_update_do(void *data);
static int
_view_update(Evry_View *view)
{
@ -632,31 +649,35 @@ _view_update(Evry_View *view)
Item *v_it;
Evry_Item *p_it;
Eina_List *l, *ll, *p_items, *v_remove = NULL, *v_items = NULL;
int pos, last_pos;
int pos, last_pos, last_vis = 0, first_vis = 0;
Eina_Bool update = EINA_FALSE;
if (!v->state->plugin)
{
_view_clear(view);
return 1;
}
p_items = v->state->plugin->items;
/* go through current view items */
EINA_LIST_FOREACH(sd->items, l, v_it)
{
last_pos = v_it->pos;
v_it->pos = 0;
pos = 1;
pos = 1;
/* go through plugins current items */
EINA_LIST_FOREACH(p_items, ll, p_it)
{
if (v_it->item == p_it)
{
if (pos != last_pos)
v_it->changed = EINA_TRUE;
v_it->pos = pos;
/* set selected state -> TODO remove*/
if (p_it == v->state->sel_item)
{
sd->sel_item = v_it;
@ -670,59 +691,79 @@ _view_update(Evry_View *view)
pos++;
}
if(v_it->pos)
if (v_it->visible)
{
if (!first_vis)
first_vis = v_it->pos;
last_vis = v_it->pos;
}
/* view item is in list of current items */
if (v_it->pos)
{
v_items = eina_list_append(v_items, v_it->item);
if (_check_item(v_it->item))
v_it->get_thumb = EINA_TRUE;
if (v_it->visible && v_it->changed)
update = EINA_TRUE;
}
else
v_remove = eina_list_append(v_remove, v_it);
{
if (v_it->visible) update = EINA_TRUE;
v_remove = eina_list_append(v_remove, v_it);
}
}
if (v_remove)
sd->update = EINA_TRUE;
EINA_LIST_FREE(v_remove, v_it)
_pan_item_remove(v->span, v_it);
/* go through plugins current items */
pos = 1;
int added = 0;
EINA_LIST_FOREACH(p_items, l, p_it)
{
/* item is not already in view */
if (!eina_list_data_find_list(v_items, p_it))
{
added = 1;
v_it = _pan_item_add(v->span, p_it);
if (!v_it) continue;
v_it->pos = pos;
/* TODO no needed */
if (p_it == v->state->sel_item)
{
sd->sel_item = v_it;
v_it->selected = EINA_TRUE;
}
if (pos > first_vis && pos < last_vis)
update = EINA_TRUE;
}
pos++;
}
sd->items = eina_list_sort(sd->items, eina_list_count(sd->items), _sort_cb);
if (added) sd->update = EINA_TRUE;
if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter);
sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, v->span);
if (update || !last_vis || v->plugin != v->state->plugin)
{
v->plugin = v->state->plugin;
sd->update = EINA_TRUE;
_update_frame(v->span);
}
if (v_items) eina_list_free(v_items);
v->tabs->update(v->tabs);
return 1;
sd->update_idler = NULL;
return 0;
}
static void
_clear_items(Evas_Object *obj)
{
@ -761,27 +802,19 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
(!strcmp(ev->key, "2")))
{
v->list_mode = v->list_mode ? EINA_FALSE : EINA_TRUE;
e_scrollframe_child_pos_set(sd->view->sframe, 0, sd->h);
_clear_items(v->span);
if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter);
sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, v->span);
_update_frame(v->span);
}
else if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
((!strcmp(ev->key, "plus")) ||
(!strcmp(ev->key, "z"))))
(!strcmp(ev->key, "3"))))
{
v->zoom++;
if (v->zoom > 2) v->zoom = 0;
if (v->zoom == 2)
_clear_items(v->span);
if (sd->idle_enter) ecore_idle_enterer_del(sd->idle_enter);
sd->idle_enter = ecore_idle_enterer_before_add(_e_smart_reconfigure_do, v->span);
_update_frame(v->span);
goto end;
}