forked from enlightenment/enlightenment
'everything' module: use macros for common stuff
- changed private data to inheritance of Evry_Item for Evry_Item_File and _App SVN revision: 41932
This commit is contained in:
parent
ad84ddfb3e
commit
aadf50f851
|
@ -8,13 +8,44 @@
|
|||
#define EVRY_ASYNC_UPDATE_CLEAR 1
|
||||
|
||||
|
||||
typedef struct _Evry_Plugin Evry_Plugin;
|
||||
typedef struct _Evry_Item Evry_Item;
|
||||
typedef struct _Evry_Action Evry_Action;
|
||||
typedef struct _Evry_State Evry_State;
|
||||
typedef struct _Evry_View Evry_View;
|
||||
typedef struct _Evry_App Evry_App;
|
||||
typedef struct _Plugin_Config Plugin_Config;
|
||||
typedef struct _Evry_Plugin Evry_Plugin;
|
||||
typedef struct _Evry_Item Evry_Item;
|
||||
typedef struct _Evry_Item_App Evry_Item_App;
|
||||
typedef struct _Evry_Item_File Evry_Item_File;
|
||||
typedef struct _Evry_Action Evry_Action;
|
||||
typedef struct _Evry_State Evry_State;
|
||||
typedef struct _Evry_View Evry_View;
|
||||
typedef struct _Plugin_Config Plugin_Config;
|
||||
|
||||
#define EVRY_ITEM(_item) ((Evry_Item *)_item)
|
||||
#define EVRY_PLUGIN(_plugin) ((Evry_Plugin *) _plugin)
|
||||
#define EVRY_VIEW(_view) ((Evry_View *) _view)
|
||||
#define ITEM_FILE(_file, _item) Evry_Item_File *_file = (Evry_Item_File *) _item
|
||||
#define ITEM_APP(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item
|
||||
#define PLUGIN(_p, _plugin) Plugin *_p = (Plugin*) _plugin
|
||||
|
||||
#define EVRY_PLUGIN_ITEMS_CLEAR(_p) \
|
||||
if (EVRY_PLUGIN(_p)->items) \
|
||||
eina_list_free(EVRY_PLUGIN(_p)->items); \
|
||||
EVRY_PLUGIN(_p)->items = NULL;
|
||||
|
||||
#define EVRY_PLUGIN_ITEMS_FREE(_p) \
|
||||
Evry_Item *evryitem; \
|
||||
EINA_LIST_FREE(EVRY_PLUGIN(_p)->items, evryitem) \
|
||||
evry_item_free(evryitem);
|
||||
|
||||
#define EVRY_PLUGIN_ITEMS_SORT(_p, _sortcb) \
|
||||
EVRY_PLUGIN(_p)->items = eina_list_sort \
|
||||
(EVRY_PLUGIN(_p)->items, \
|
||||
eina_list_count(EVRY_PLUGIN(_p)->items), _sortcb); \
|
||||
|
||||
#define EVRY_PLUGIN_ITEM_APPEND(_p, _item) \
|
||||
EVRY_PLUGIN(_p)->items = \
|
||||
eina_list_append(EVRY_PLUGIN(_p)->items, EVRY_ITEM(_item)) \
|
||||
|
||||
#define EVRY_PLUGIN_FREE(_p) \
|
||||
evry_plugin_free(EVRY_PLUGIN(_p), 0); \
|
||||
E_FREE(_p);
|
||||
|
||||
struct _Plugin_Config
|
||||
{
|
||||
|
@ -36,16 +67,14 @@ struct _Evry_Item
|
|||
{
|
||||
/* label to show for this item */
|
||||
const char *label;
|
||||
|
||||
const char *uri;
|
||||
const char *mime;
|
||||
const char *icon;
|
||||
|
||||
/* item can be browsed, e.g. folders */
|
||||
Eina_Bool browseable;
|
||||
|
||||
/* these are only for internally use by plugins */
|
||||
/* used e.g. as pointer for item data (Efreet_Desktop) */
|
||||
void *data[4];
|
||||
void *data;
|
||||
|
||||
/* priority hints for sorting */
|
||||
int priority;
|
||||
|
@ -61,6 +90,21 @@ struct _Evry_Item
|
|||
void (*free) (Evry_Item *item);
|
||||
};
|
||||
|
||||
struct _Evry_Item_App
|
||||
{
|
||||
Evry_Item base;
|
||||
const char *file;
|
||||
Efreet_Desktop *desktop;
|
||||
};
|
||||
|
||||
struct _Evry_Item_File
|
||||
{
|
||||
Evry_Item base;
|
||||
const char *uri;
|
||||
const char *mime;
|
||||
};
|
||||
|
||||
|
||||
struct _Evry_Plugin
|
||||
{
|
||||
const char *name;
|
||||
|
@ -156,7 +200,7 @@ struct _Evry_Action
|
|||
|
||||
const Evry_Item *item1;
|
||||
const Evry_Item *item2;
|
||||
|
||||
|
||||
int (*action) (Evry_Action *act);
|
||||
int (*check_item) (Evry_Action *act, const Evry_Item *it);
|
||||
int (*intercept) (Evry_Action *act);
|
||||
|
@ -170,11 +214,6 @@ struct _Evry_Action
|
|||
Evas_Object *o_icon;
|
||||
};
|
||||
|
||||
struct _Evry_App
|
||||
{
|
||||
const char *file;
|
||||
Efreet_Desktop *desktop;
|
||||
};
|
||||
|
||||
EAPI void evry_plugin_register(Evry_Plugin *p, int priority);
|
||||
EAPI void evry_plugin_unregister(Evry_Plugin *p);
|
||||
|
@ -189,7 +228,7 @@ EAPI int evry_list_win_show(void);
|
|||
EAPI void evry_list_win_hide(void);
|
||||
|
||||
|
||||
EAPI Evry_Item *evry_item_new(Evry_Plugin *p, const char *label, void (*cb_free) (Evry_Item *item));
|
||||
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);
|
||||
|
||||
|
@ -200,6 +239,7 @@ 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 Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, int type,
|
||||
const char *type_in, const char *type_out,
|
||||
|
@ -225,3 +265,4 @@ EAPI Evry_Action *evry_action_new(const char *name, const char *type_in1,
|
|||
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e));
|
||||
|
||||
EAPI void evry_action_free(Evry_Action *act);
|
||||
|
||||
|
|
|
@ -248,12 +248,18 @@ evry_clear_input(void)
|
|||
/* static int item_cnt = 0; */
|
||||
|
||||
EAPI Evry_Item *
|
||||
evry_item_new(Evry_Plugin *p, const char *label, void (*cb_free) (Evry_Item *item))
|
||||
evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label, void (*cb_free) (Evry_Item *item))
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
it = E_NEW(Evry_Item, 1);
|
||||
if (!it) return NULL;
|
||||
if (base)
|
||||
{
|
||||
it = base;
|
||||
}
|
||||
else
|
||||
{
|
||||
it = E_NEW(Evry_Item, 1);
|
||||
if (!it) return NULL;
|
||||
}
|
||||
|
||||
it->plugin = p;
|
||||
if (label) it->label = eina_stringshare_add(label);
|
||||
|
@ -280,16 +286,17 @@ evry_item_free(Evry_Item *it)
|
|||
* it->label);
|
||||
* item_cnt--; */
|
||||
|
||||
if (it->free) it->free(it);
|
||||
|
||||
if (it->label) eina_stringshare_del(it->label);
|
||||
if (it->uri) eina_stringshare_del(it->uri);
|
||||
if (it->mime) eina_stringshare_del(it->mime);
|
||||
/* if (it->uri) eina_stringshare_del(it->uri);
|
||||
* if (it->mime) eina_stringshare_del(it->mime); */
|
||||
|
||||
if (it->o_bg) evas_object_del(it->o_bg);
|
||||
if (it->o_icon) evas_object_del(it->o_icon);
|
||||
|
||||
E_FREE(it);
|
||||
if (it->free)
|
||||
it->free(it);
|
||||
else
|
||||
E_FREE(it);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -553,6 +560,35 @@ evry_fuzzy_match(const char *str, const char *match)
|
|||
return sum;
|
||||
}
|
||||
|
||||
static int
|
||||
_evry_fuzzy_match_sort_cb(const void *data1, const void *data2)
|
||||
{
|
||||
const Evry_Item *it1 = data1;
|
||||
const Evry_Item *it2 = data2;
|
||||
|
||||
if (it1->priority - it2->priority)
|
||||
return (it1->priority - it2->priority);
|
||||
|
||||
if (it1->fuzzy_match || it2->fuzzy_match)
|
||||
{
|
||||
if (it1->fuzzy_match && !it2->fuzzy_match)
|
||||
return -1;
|
||||
|
||||
if (!it1->fuzzy_match && it2->fuzzy_match)
|
||||
return 1;
|
||||
|
||||
if (it1->fuzzy_match - it2->fuzzy_match)
|
||||
return (it1->fuzzy_match - it2->fuzzy_match);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI Eina_List *
|
||||
evry_fuzzy_match_sort(Eina_List *items)
|
||||
{
|
||||
return eina_list_sort(items, eina_list_count(items), _evry_fuzzy_match_sort_cb);
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
|
||||
|
@ -1147,7 +1183,7 @@ _evry_selectors_switch(void)
|
|||
|
||||
if ((s->sel_item) &&
|
||||
(s->sel_item->plugin == action_selector) &&
|
||||
(act = s->sel_item->data[0]) &&
|
||||
(act = s->sel_item->data) &&
|
||||
(act->type_in2))
|
||||
{
|
||||
_evry_selector_objects_get(act);
|
||||
|
@ -1395,7 +1431,7 @@ _evry_plugin_action(Evry_Selector *sel, int finished)
|
|||
|
||||
if (s_action->sel_item->plugin == action_selector)
|
||||
{
|
||||
Evry_Action *act = s_action->sel_item->data[0];
|
||||
Evry_Action *act = s_action->sel_item->data;
|
||||
Evry_Item *it_object = NULL;
|
||||
|
||||
if (selectors[2] == selector)
|
||||
|
@ -1513,7 +1549,13 @@ _evry_view_toggle(Evry_State *s, const char *trigger)
|
|||
}
|
||||
else
|
||||
{
|
||||
l = eina_list_data_find_list(evry_conf->views, s->view->id);
|
||||
if (s->view)
|
||||
l = eina_list_data_find_list(evry_conf->views, s->view->id);
|
||||
else
|
||||
{
|
||||
v = evry_conf->views->data;
|
||||
goto found;
|
||||
}
|
||||
|
||||
if (l && l->next)
|
||||
l = l->next;
|
||||
|
|
|
@ -97,10 +97,10 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
|
||||
if (!input || match)
|
||||
{
|
||||
it = evry_item_new(p, act->name, NULL);
|
||||
it = evry_item_new(NULL, p, act->name, NULL);
|
||||
it->fuzzy_match = match;
|
||||
it->data[0] = act;
|
||||
p->items = eina_list_append(p->items, it);
|
||||
it->data = act;
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ static Evas_Object *
|
|||
_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||
{
|
||||
Evas_Object *o = NULL;
|
||||
Evry_Action *act = it->data[0];
|
||||
Evry_Action *act = it->data;
|
||||
|
||||
if (!act) return NULL;
|
||||
|
||||
|
|
|
@ -54,8 +54,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
|
||||
s = p->selector->state;
|
||||
|
||||
EINA_LIST_FREE(p->base.items, it)
|
||||
evry_item_free(it);
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
|
||||
EINA_LIST_FOREACH(s->cur_plugins, l, pp)
|
||||
cnt += eina_list_count(pp->items);
|
||||
|
@ -74,7 +73,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
{
|
||||
evry_item_ref(it);
|
||||
items = eina_list_append(items, it);
|
||||
p->base.items = eina_list_append(p->base.items, it);
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +91,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
|
||||
evry_item_ref(it);
|
||||
it->fuzzy_match = 0;
|
||||
p->base.items = eina_list_append(p->base.items, it);
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,8 +100,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
if (items) eina_list_free(items);
|
||||
|
||||
if (input[0])
|
||||
p->base.items = eina_list_sort
|
||||
(p->base.items, eina_list_count(p->base.items), _cb_sort);
|
||||
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -119,10 +117,7 @@ _action(Evry_Plugin *plugin, const Evry_Item *it)
|
|||
static void
|
||||
_cleanup(Evry_Plugin *plugin)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
EINA_LIST_FREE(plugin->items, it)
|
||||
evry_item_free(it);
|
||||
EVRY_PLUGIN_ITEMS_FREE(plugin);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
|
@ -141,25 +136,23 @@ evry_plug_aggregator_new(Evry_Selector *selector)
|
|||
Plugin_Config *pc;
|
||||
|
||||
p = E_NEW(Plugin, 1);
|
||||
evry_plugin_new(&p->base, "All", 0, "", "", 0, NULL, NULL,
|
||||
evry_plugin_new(EVRY_PLUGIN(p), "All", 0, "", "", 0, NULL, NULL,
|
||||
NULL, _cleanup, _fetch, _action, _icon_get,
|
||||
NULL, NULL);
|
||||
|
||||
pc = E_NEW(Plugin_Config, 1);
|
||||
pc->enabled = 1;
|
||||
pc->priority = -1;
|
||||
p->base.config = pc;
|
||||
EVRY_PLUGIN(p)->config = pc;
|
||||
|
||||
p->selector = selector;
|
||||
|
||||
return &p->base;
|
||||
return EVRY_PLUGIN(p);
|
||||
}
|
||||
|
||||
void
|
||||
evry_plug_aggregator_free(Evry_Plugin *plugin)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
|
||||
evry_plugin_free(&p->base, 0);
|
||||
E_FREE(p);
|
||||
PLUGIN(p, plugin);
|
||||
EVRY_PLUGIN_FREE(p);
|
||||
}
|
||||
|
|
|
@ -22,25 +22,28 @@ static Eina_List *exe_path = NULL;
|
|||
|
||||
|
||||
static Evry_Plugin *
|
||||
_begin(Evry_Plugin *plugin, const Evry_Item *it)
|
||||
_begin(Evry_Plugin *plugin, const Evry_Item *item)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
/* Plugin *p = (Plugin*) plugin; */
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
const char *mime;
|
||||
|
||||
if (it)
|
||||
if (item)
|
||||
{
|
||||
ITEM_FILE(file, item);
|
||||
Efreet_Desktop *desktop;
|
||||
|
||||
if (!it->uri) return NULL;
|
||||
if (!file->uri) return NULL;
|
||||
|
||||
if (!it->mime)
|
||||
mime = efreet_mime_type_get(it->uri);
|
||||
if (!file->mime)
|
||||
mime = efreet_mime_type_get(file->uri);
|
||||
else
|
||||
mime = it->mime;
|
||||
mime = file->mime;
|
||||
|
||||
if (!mime) return NULL;
|
||||
|
||||
p->candidate = it;
|
||||
p->candidate = EVRY_ITEM(file);
|
||||
p->apps_mime = efreet_util_desktop_mime_list(mime);
|
||||
desktop = e_exehist_mime_desktop_get(mime);
|
||||
if (desktop)
|
||||
|
@ -50,7 +53,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
|
|||
}
|
||||
}
|
||||
|
||||
return &p->base;
|
||||
return EVRY_PLUGIN(p);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -63,20 +66,21 @@ _list_free(Evry_Plugin *plugin)
|
|||
}
|
||||
|
||||
static void
|
||||
_item_free(Evry_Item *it)
|
||||
_item_free(Evry_Item *item)
|
||||
{
|
||||
Evry_App *app;
|
||||
ITEM_APP(app, item);
|
||||
|
||||
app = it->data[0];
|
||||
if (app->file) eina_stringshare_del(app->file);
|
||||
if (app->desktop) efreet_desktop_free(app->desktop);
|
||||
|
||||
E_FREE(app);
|
||||
}
|
||||
|
||||
static void
|
||||
_cleanup(Evry_Plugin *plugin)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
PLUGIN(p, plugin);
|
||||
/* Plugin *p = (Plugin*) plugin; */
|
||||
Efreet_Desktop *desktop;
|
||||
|
||||
_list_free(plugin);
|
||||
|
@ -91,8 +95,7 @@ _cleanup(Evry_Plugin *plugin)
|
|||
static int
|
||||
_item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match)
|
||||
{
|
||||
Evry_Item *it;
|
||||
Evry_App *app;
|
||||
Evry_Item_App *app;
|
||||
Efreet_Desktop *d2;
|
||||
int already_refd = 0;
|
||||
|
||||
|
@ -146,18 +149,18 @@ _item_add(Plugin *p, Efreet_Desktop *desktop, char *file, int match)
|
|||
file = NULL;
|
||||
}
|
||||
|
||||
if (desktop)
|
||||
it = evry_item_new(&p->base, desktop->name, _item_free);
|
||||
else
|
||||
it = evry_item_new(&p->base, file, _item_free);
|
||||
app = E_NEW(Evry_Item_App, 1);
|
||||
|
||||
if (desktop)
|
||||
evry_item_new(EVRY_ITEM(app), EVRY_PLUGIN(p), desktop->name, _item_free);
|
||||
else
|
||||
evry_item_new(EVRY_ITEM(app), EVRY_PLUGIN(p), file, _item_free);
|
||||
|
||||
app = E_NEW(Evry_App, 1);
|
||||
app->desktop = desktop;
|
||||
app->file = file;
|
||||
it->data[0] = app;
|
||||
it->fuzzy_match = match;
|
||||
EVRY_ITEM(app)->fuzzy_match = match;
|
||||
|
||||
p->base.items = eina_list_append(p->base.items, it);
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, app);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -171,7 +174,7 @@ _add_desktop_list(Plugin *p, Eina_List *apps, const char *input)
|
|||
|
||||
EINA_LIST_FOREACH(apps, l, desktop)
|
||||
{
|
||||
if (eina_list_count(p->base.items) > 199) continue;
|
||||
if (eina_list_count(EVRY_PLUGIN(p)->items) > 199) continue;
|
||||
if (!desktop->name || !desktop->exec) continue;
|
||||
|
||||
char *exec = strrchr(desktop->exec, '/');
|
||||
|
@ -192,12 +195,11 @@ _cb_sort(const void *data1, const void *data2)
|
|||
{
|
||||
const Evry_Item *it1 = data1;
|
||||
const Evry_Item *it2 = data2;
|
||||
Evry_App *app1, *app2;
|
||||
const char *e1, *e2;
|
||||
double t1, t2;
|
||||
|
||||
app1 = it1->data[0];
|
||||
app2 = it2->data[0];
|
||||
ITEM_APP(app1, it1);
|
||||
ITEM_APP(app2, it2);
|
||||
|
||||
if (app1->desktop)
|
||||
e1 = app1->desktop->exec;
|
||||
|
@ -233,19 +235,18 @@ _cb_sort(const void *data1, const void *data2)
|
|||
static int
|
||||
_fetch(Evry_Plugin *plugin, const char *input)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
PLUGIN(p, plugin);
|
||||
/* Plugin *p = (Plugin*) plugin; */
|
||||
Eina_List *l;
|
||||
Efreet_Desktop *desktop;
|
||||
char *file;
|
||||
Evry_Item *it;
|
||||
Evry_App *app;
|
||||
|
||||
p->added = eina_hash_string_small_new(NULL);
|
||||
|
||||
_list_free(plugin);
|
||||
|
||||
/* add apps for a given mimetype */
|
||||
if (p->base.type == type_action)
|
||||
if (plugin->type == type_action)
|
||||
{
|
||||
if (input)
|
||||
_add_desktop_list(p, p->apps_mime, input);
|
||||
|
@ -321,20 +322,19 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
|
||||
if (found)
|
||||
{
|
||||
it = evry_item_new(plugin, _("Run Command"), _item_free);
|
||||
app = E_NEW(Evry_App, 1);
|
||||
Evry_Item_App *app;
|
||||
app = E_NEW(Evry_Item_App, 1);
|
||||
evry_item_new(EVRY_ITEM(app), plugin, _("Run Command"), _item_free);
|
||||
app->file = eina_stringshare_add(input);
|
||||
it->data[0] = app;
|
||||
it->priority = 9999;
|
||||
plugin->items = eina_list_append(plugin->items, it);
|
||||
EVRY_ITEM(app)->priority = 9999;
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, app);
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "xterm -hold -e %s", input);
|
||||
it = evry_item_new(plugin, _("Run in Terminal"), _item_free);
|
||||
app = E_NEW(Evry_App, 1);
|
||||
app = E_NEW(Evry_Item_App, 1);
|
||||
evry_item_new(EVRY_ITEM(app), plugin, _("Run in Terminal"), _item_free);
|
||||
app->file = eina_stringshare_add(cmd);
|
||||
it->data[0] = app;
|
||||
it->priority = 1000;
|
||||
plugin->items = eina_list_append(plugin->items, it);
|
||||
EVRY_ITEM(app)->priority = 1000;
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, app);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,6 +343,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
if (plugin->items)
|
||||
{
|
||||
int prio = 0;
|
||||
Evry_Item *it;
|
||||
|
||||
l = plugin->items;
|
||||
plugin->items = eina_list_sort(l, eina_list_count(l), _cb_sort);
|
||||
|
@ -358,8 +359,10 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
static Evas_Object *
|
||||
_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||
{
|
||||
ITEM_APP(app, it);
|
||||
Evas_Object *o = NULL;
|
||||
Evry_App *app = it->data[0];
|
||||
|
||||
/* Evry_App *app = it->data[0]; */
|
||||
|
||||
if (app->desktop)
|
||||
o = e_util_desktop_icon_add(app->desktop, 64, e);
|
||||
|
@ -373,7 +376,8 @@ _icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
|||
static int
|
||||
_exec_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||
{
|
||||
Evry_App *app = it->data[0];
|
||||
ITEM_APP(app, it);
|
||||
|
||||
if (app->desktop)
|
||||
return 1;
|
||||
|
||||
|
@ -384,30 +388,33 @@ _exec_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
|||
}
|
||||
|
||||
static int
|
||||
_app_action(const Evry_Item *it_app, const Evry_Item *it_file)
|
||||
_app_action(const Evry_Item *it1, const Evry_Item *it2)
|
||||
{
|
||||
E_Zone *zone;
|
||||
Evry_App *app = NULL;
|
||||
/* Evry_App *app = NULL; */
|
||||
Eina_List *files = NULL;
|
||||
char *exe = NULL;
|
||||
|
||||
if (!it_app) return 0;
|
||||
if (!it1) return 0;
|
||||
/* app = it_app->data[0]; */
|
||||
ITEM_APP(app, it1);
|
||||
|
||||
app = it_app->data[0];
|
||||
if (!app) return 0;
|
||||
|
||||
zone = e_util_zone_current_get(e_manager_current_get());
|
||||
|
||||
if (app->desktop)
|
||||
{
|
||||
if (it_file)
|
||||
if (it2)
|
||||
{
|
||||
ITEM_FILE(file, it2);
|
||||
|
||||
Eina_List *l;
|
||||
char *mime;
|
||||
char *path = NULL;
|
||||
int open_folder = 0;
|
||||
|
||||
if (!it_file->browseable)
|
||||
if (!EVRY_ITEM(file)->browseable)
|
||||
{
|
||||
EINA_LIST_FOREACH(app->desktop->mime_types, l, mime)
|
||||
{
|
||||
|
@ -421,18 +428,18 @@ _app_action(const Evry_Item *it_app, const Evry_Item *it_file)
|
|||
|
||||
if (open_folder)
|
||||
{
|
||||
path = ecore_file_dir_get(it_file->uri);
|
||||
path = ecore_file_dir_get(file->uri);
|
||||
files = eina_list_append(files, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
files = eina_list_append(files, it_file->uri);
|
||||
files = eina_list_append(files, file->uri);
|
||||
}
|
||||
|
||||
e_exec(zone, app->desktop, NULL, files, NULL);
|
||||
|
||||
if (it_file && it_file->mime && !open_folder)
|
||||
e_exehist_mime_desktop_add(it_file->mime, app->desktop);
|
||||
if (file && file->mime && !open_folder)
|
||||
e_exehist_mime_desktop_add(file->mime, app->desktop);
|
||||
|
||||
if (files)
|
||||
eina_list_free(files);
|
||||
|
@ -445,20 +452,22 @@ _app_action(const Evry_Item *it_app, const Evry_Item *it_file)
|
|||
}
|
||||
else if (app->file)
|
||||
{
|
||||
if (it_file && it_file->uri)
|
||||
if (it2)
|
||||
{
|
||||
ITEM_FILE(file, it2);
|
||||
int len;
|
||||
|
||||
len = strlen(app->file) + strlen(it_file->uri) + 2;
|
||||
len = strlen(app->file) + strlen(file->uri) + 2;
|
||||
exe = malloc(len);
|
||||
snprintf(exe, len, "%s %s", app->file, it_file->uri);
|
||||
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);
|
||||
}
|
||||
else exe = (char *) app->file;
|
||||
|
||||
e_exec(zone, NULL, exe, NULL, NULL);
|
||||
|
||||
if (it_file && it_file->uri)
|
||||
free(exe);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -473,7 +482,8 @@ _exec_app_action(Evry_Action *act)
|
|||
static int
|
||||
_open_with_action(Evry_Plugin *plugin, const Evry_Item *it)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
PLUGIN(p, plugin);
|
||||
/* Plugin *p = (Plugin*) plugin; */
|
||||
|
||||
if (p->candidate)
|
||||
return _app_action(it, p->candidate);
|
||||
|
@ -484,7 +494,8 @@ _open_with_action(Evry_Plugin *plugin, const Evry_Item *it)
|
|||
static int
|
||||
_edit_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||
{
|
||||
Evry_App *app = it->data[0];
|
||||
ITEM_APP(app, it);
|
||||
/* Evry_App *app = it->data[0]; */
|
||||
if (app->desktop)
|
||||
return 1;
|
||||
|
||||
|
@ -494,10 +505,9 @@ _edit_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
|||
static int
|
||||
_edit_app_action(Evry_Action *act)
|
||||
{
|
||||
Evry_App *app;
|
||||
Efreet_Desktop *desktop;
|
||||
ITEM_APP(app, act->item1);
|
||||
|
||||
app = act->item1->data[0];
|
||||
if (app->desktop)
|
||||
desktop = app->desktop;
|
||||
else
|
||||
|
@ -518,7 +528,8 @@ _edit_app_action(Evry_Action *act)
|
|||
static int
|
||||
_new_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||
{
|
||||
Evry_App *app = it->data[0];
|
||||
ITEM_APP(app, it);
|
||||
/* Evry_App *app = it->data[0]; */
|
||||
if (app->desktop)
|
||||
return 1;
|
||||
|
||||
|
@ -531,14 +542,15 @@ _new_app_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
|||
static int
|
||||
_new_app_action(Evry_Action *act)
|
||||
{
|
||||
Evry_App *app;
|
||||
/* Evry_App *app; */
|
||||
char *name;
|
||||
char buf[4096];
|
||||
char *end;
|
||||
Efreet_Desktop *desktop;
|
||||
int i;
|
||||
|
||||
app = act->item1->data[0];
|
||||
ITEM_APP(app, act->item1);
|
||||
/* app = act->item1->data[0]; */
|
||||
|
||||
if (app->desktop)
|
||||
name = strdup(app->desktop->name);
|
||||
|
@ -587,7 +599,7 @@ _new_app_action(Evry_Action *act)
|
|||
static int
|
||||
_exec_border_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||
{
|
||||
E_Border *bd = it->data[0];
|
||||
E_Border *bd = it->data;
|
||||
E_OBJECT_CHECK_RETURN(bd, 0);
|
||||
E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, 0);
|
||||
|
||||
|
@ -610,14 +622,15 @@ _exec_border_action(Evry_Action *act)
|
|||
static int
|
||||
_exec_border_intercept(Evry_Action *act)
|
||||
{
|
||||
Evry_Item *it = E_NEW(Evry_Item, 1);
|
||||
Evry_App *app = E_NEW(Evry_App, 1);
|
||||
E_Border *bd = act->item1->data[0];
|
||||
/* Evry_Item *it = E_NEW(Evry_Item, 1); */
|
||||
Evry_Item_App *app = E_NEW(Evry_Item_App, 1);
|
||||
E_Border *bd = act->item1->data;
|
||||
|
||||
app->desktop = bd->desktop;
|
||||
it->data[0] = app;
|
||||
/* it->data[0] = app; */
|
||||
|
||||
act->item1 = it;
|
||||
/* act->item1 = it; */
|
||||
act->item1 = EVRY_ITEM(app);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -626,11 +639,12 @@ _exec_border_intercept(Evry_Action *act)
|
|||
static void
|
||||
_exec_border_cleanup(Evry_Action *act)
|
||||
{
|
||||
Evry_Item *it = (Evry_Item*) act->item1;
|
||||
Evry_App *app = it->data[0];
|
||||
|
||||
/* Evry_Item *it = (Evry_Item*) act->item1;
|
||||
* Evry_App *app = it->data[0]; */
|
||||
ITEM_APP(app, act->item1);
|
||||
|
||||
E_FREE(app);
|
||||
E_FREE(it);
|
||||
/* E_FREE(it); */
|
||||
}
|
||||
|
||||
|
||||
|
@ -640,16 +654,16 @@ _init(void)
|
|||
char *path, *p, *last;
|
||||
|
||||
p1 = E_NEW(Plugin, 1);
|
||||
evry_plugin_new(&p1->base, "Applications", type_subject, "", "APPLICATION", 0, NULL, NULL,
|
||||
evry_plugin_new(EVRY_PLUGIN(p1), "Applications", type_subject, "", "APPLICATION", 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch, NULL, _icon_get, NULL, NULL);
|
||||
|
||||
p2 = E_NEW(Plugin, 1);
|
||||
evry_plugin_new(&p2->base, "Open With...", type_action, "FILE", "", 0, NULL, NULL,
|
||||
evry_plugin_new(EVRY_PLUGIN(p2), "Open With...", type_action, "FILE", "", 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch, _open_with_action,
|
||||
_icon_get, NULL, NULL);
|
||||
|
||||
evry_plugin_register(&p1->base, 1);
|
||||
evry_plugin_register(&p2->base, 3);
|
||||
evry_plugin_register(EVRY_PLUGIN(p1), 1);
|
||||
evry_plugin_register(EVRY_PLUGIN(p2), 3);
|
||||
|
||||
act = evry_action_new("Launch", "APPLICATION", NULL, NULL,
|
||||
"everything-launch",
|
||||
|
@ -710,10 +724,8 @@ _shutdown(void)
|
|||
{
|
||||
char *str;
|
||||
|
||||
evry_plugin_free(&p1->base, 0);
|
||||
evry_plugin_free(&p2->base, 0);
|
||||
E_FREE(p1);
|
||||
E_FREE(p2);
|
||||
EVRY_PLUGIN_FREE(p1);
|
||||
EVRY_PLUGIN_FREE(p2);
|
||||
|
||||
evry_action_free(act);
|
||||
evry_action_free(act1);
|
||||
|
|
|
@ -77,19 +77,20 @@ _space_find(const char *line)
|
|||
}
|
||||
|
||||
static void
|
||||
_item_add(Evry_Plugin *p, const char *word, int word_size, int prio)
|
||||
_item_add(Plugin *p, const char *word, int word_size, int prio)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
it = evry_item_new(p, NULL, NULL);
|
||||
it = evry_item_new(NULL, EVRY_PLUGIN(p), NULL, NULL);
|
||||
if (!it) return;
|
||||
it->priority = prio;
|
||||
it->label = eina_stringshare_add_length(word, word_size);
|
||||
p->items = eina_list_append(p->items, it);
|
||||
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
||||
}
|
||||
|
||||
static void
|
||||
_suggestions_add(Evry_Plugin *p, const char *line)
|
||||
_suggestions_add(Plugin *p, const char *line)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
|
@ -123,18 +124,15 @@ _suggestions_add(Evry_Plugin *p, const char *line)
|
|||
}
|
||||
|
||||
static void
|
||||
_clear_list(Evry_Plugin *plugin)
|
||||
_clear_list(Plugin *p)
|
||||
{
|
||||
Evry_Item *it;
|
||||
EINA_LIST_FREE(plugin->items, it)
|
||||
evry_item_free(it);
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_data(void *data, int type __UNUSED__, void *event)
|
||||
{
|
||||
Plugin *p = data;
|
||||
Evry_Plugin *plugin = &p->base;
|
||||
PLUGIN(p, data);
|
||||
Ecore_Exe_Event_Data *e = event;
|
||||
Ecore_Exe_Event_Data_Line *l;
|
||||
const char *word;
|
||||
|
@ -142,7 +140,7 @@ _cb_data(void *data, int type __UNUSED__, void *event)
|
|||
if (e->exe != p->exe)
|
||||
return 1;
|
||||
|
||||
_clear_list(plugin);
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
|
||||
word = p->input;
|
||||
for (l = e->lines; l && l->line; l++)
|
||||
|
@ -181,12 +179,12 @@ _cb_data(void *data, int type __UNUSED__, void *event)
|
|||
word = _space_skip(word_end + 1);
|
||||
}
|
||||
|
||||
if (plugin->items)
|
||||
if (EVRY_PLUGIN(p)->items)
|
||||
{
|
||||
evry_list_win_show();
|
||||
}
|
||||
|
||||
evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_ADD);
|
||||
evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -207,7 +205,7 @@ _cb_del(void *data, int type __UNUSED__, void *event)
|
|||
static int
|
||||
_begin(Evry_Plugin *plugin, const Evry_Item *it __UNUSED__)
|
||||
{
|
||||
Plugin *p = (Plugin *)plugin;
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
if (!p->handler.data)
|
||||
p->handler.data = ecore_event_handler_add
|
||||
|
@ -222,7 +220,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it __UNUSED__)
|
|||
static int
|
||||
_fetch(Evry_Plugin *plugin, const char *input)
|
||||
{
|
||||
Plugin *p = (Plugin *)plugin;
|
||||
PLUGIN(p, plugin);
|
||||
const char *s;
|
||||
int len;
|
||||
|
||||
|
@ -235,7 +233,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
{
|
||||
const char *lang;
|
||||
|
||||
_clear_list(plugin);
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
|
||||
input += len;
|
||||
for (s = input; *s != '\0'; s++)
|
||||
|
@ -292,11 +290,9 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
static void
|
||||
_cleanup(Evry_Plugin *plugin)
|
||||
{
|
||||
Plugin *p = (Plugin *)plugin;
|
||||
Evry_Item *it;
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
EINA_LIST_FREE(p->base.items, it)
|
||||
evry_item_free(it);
|
||||
EVRY_PLUGIN_ITEMS_FREE(p)
|
||||
|
||||
if (p->handler.data)
|
||||
{
|
||||
|
@ -332,11 +328,11 @@ _init(void)
|
|||
Plugin *p;
|
||||
|
||||
p = E_NEW(Plugin, 1);
|
||||
evry_plugin_new(&p->base, "Spell Checker", type_subject, "", "TEXT", 1,
|
||||
evry_plugin_new(EVRY_PLUGIN(p), "Spell Checker", type_subject, "", "TEXT", 1,
|
||||
"accessories-dictionary", TRIGGER,
|
||||
NULL, _cleanup, _fetch, NULL, NULL, NULL, NULL);
|
||||
|
||||
evry_plugin_register(&p->base, 100);
|
||||
evry_plugin_register(EVRY_PLUGIN(p), 100);
|
||||
|
||||
plugin = p;
|
||||
return EINA_TRUE;
|
||||
|
@ -345,14 +341,7 @@ _init(void)
|
|||
static void
|
||||
_shutdown(void)
|
||||
{
|
||||
Plugin *p;
|
||||
|
||||
p = plugin;
|
||||
|
||||
_cleanup(&p->base);
|
||||
|
||||
evry_plugin_free(&p->base, 0);
|
||||
E_FREE(p);
|
||||
EVRY_PLUGIN_FREE(plugin);
|
||||
}
|
||||
|
||||
EINA_MODULE_INIT(_init);
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
static Evry_Plugin *p;
|
||||
static Evry_Plugin *plugin;
|
||||
static Eina_List *handlers = NULL;
|
||||
|
||||
|
||||
static int
|
||||
_cb_border_remove(void *data, int type, void *event)
|
||||
{
|
||||
Evry_Plugin *p = data;
|
||||
E_Event_Border_Remove *ev;
|
||||
Eina_List *l;
|
||||
Evry_Item *it;
|
||||
|
@ -16,7 +17,7 @@ _cb_border_remove(void *data, int type, void *event)
|
|||
|
||||
EINA_LIST_FOREACH(p->items, l, it)
|
||||
{
|
||||
if (it->data[0] == ev->border)
|
||||
if (it->data == ev->border)
|
||||
{
|
||||
p->items = eina_list_remove(p->items, it);
|
||||
evry_item_free(it);
|
||||
|
@ -33,7 +34,7 @@ _begin(Evry_Plugin *p, const Evry_Item *it)
|
|||
{
|
||||
handlers = eina_list_append
|
||||
(handlers, ecore_event_handler_add
|
||||
(E_EVENT_BORDER_REMOVE, _cb_border_remove, NULL));
|
||||
(E_EVENT_BORDER_REMOVE, _cb_border_remove, p));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
@ -55,7 +56,10 @@ _cleanup(Evry_Plugin *p)
|
|||
static void
|
||||
_item_free(Evry_Item *it)
|
||||
{
|
||||
if (it->data[0]) e_object_unref(E_OBJECT(it->data[0]));
|
||||
if (it->data)
|
||||
e_object_unref(E_OBJECT(it->data));
|
||||
|
||||
E_FREE(it);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -63,16 +67,16 @@ _item_add(Evry_Plugin *p, E_Border *bd, int match, int *prio)
|
|||
{
|
||||
Evry_Item *it;
|
||||
|
||||
it = evry_item_new(p, e_border_name_get(bd), _item_free);
|
||||
it = evry_item_new(NULL, p, e_border_name_get(bd), _item_free);
|
||||
|
||||
e_object_ref(E_OBJECT(bd));
|
||||
it->data[0] = bd;
|
||||
it->data = bd;
|
||||
it->fuzzy_match = match;
|
||||
it->priority = *prio;
|
||||
|
||||
*prio += 1;
|
||||
|
||||
p->items = eina_list_append(p->items, it);
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -144,7 +148,7 @@ static Evas_Object *
|
|||
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||
{
|
||||
Evas_Object *o = NULL;
|
||||
E_Border *bd = it->data[0];
|
||||
E_Border *bd = it->data;
|
||||
|
||||
if (bd->internal)
|
||||
{
|
||||
|
@ -218,10 +222,10 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
|||
static Eina_Bool
|
||||
_init(void)
|
||||
{
|
||||
p = evry_plugin_new(NULL, "Windows", type_subject, NULL, "BORDER", 0, NULL, NULL,
|
||||
plugin = evry_plugin_new(NULL, "Windows", type_subject, NULL, "BORDER", 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch, NULL, _item_icon_get, NULL, NULL);
|
||||
|
||||
evry_plugin_register(p, 2);
|
||||
evry_plugin_register(plugin, 2);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -229,7 +233,7 @@ _init(void)
|
|||
static void
|
||||
_shutdown(void)
|
||||
{
|
||||
evry_plugin_free(p, 1);
|
||||
EVRY_PLUGIN_FREE(plugin);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ struct _Inst
|
|||
E_Border *border;
|
||||
};
|
||||
|
||||
static Evry_Plugin *p;
|
||||
static Evry_Plugin *plugin;
|
||||
static Inst *inst;
|
||||
|
||||
|
||||
|
@ -88,7 +88,7 @@ _begin(Evry_Plugin *p __UNUSED__, const Evry_Item *item)
|
|||
{
|
||||
E_Border *bd;
|
||||
|
||||
bd = item->data[0];
|
||||
bd = item->data;
|
||||
/* e_object_ref(E_OBJECT(bd)); */
|
||||
inst->border = bd;
|
||||
|
||||
|
@ -104,12 +104,6 @@ _cb_sort(const void *data1, const void *data2)
|
|||
return (it1->fuzzy_match - it2->fuzzy_match);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_free(Evry_Item *it)
|
||||
{
|
||||
if (it->data[1]) eina_stringshare_del((const char *)it->data[1]);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon, const char *input)
|
||||
{
|
||||
|
@ -121,9 +115,9 @@ _item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), c
|
|||
|
||||
if (!match) return;
|
||||
|
||||
it = evry_item_new(p, label, _item_free);
|
||||
it->data[0] = action_cb;
|
||||
it->data[1] = (void *) eina_stringshare_add(icon);
|
||||
it = evry_item_new(NULL, p, label, NULL);
|
||||
it->icon = eina_stringshare_add(icon);
|
||||
it->data = action_cb;
|
||||
it->fuzzy_match = match;
|
||||
|
||||
p->items = eina_list_prepend(p->items, it);
|
||||
|
@ -132,10 +126,7 @@ _item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), c
|
|||
static void
|
||||
_cleanup(Evry_Plugin *p)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
evry_item_free(it);
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -193,7 +184,7 @@ static int
|
|||
_action(Evry_Plugin *p __UNUSED__, const Evry_Item *item)
|
||||
{
|
||||
void (*border_action) (E_Border *bd);
|
||||
border_action = item->data[0];
|
||||
border_action = item->data;
|
||||
border_action(inst->border);
|
||||
|
||||
return EVRY_ACTION_FINISHED;
|
||||
|
@ -204,7 +195,7 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
|||
{
|
||||
Evas_Object *o;
|
||||
|
||||
o = evry_icon_theme_get((const char *)it->data[1], e);
|
||||
o = evry_icon_theme_get(it->icon, e);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
@ -212,10 +203,10 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
|||
static Eina_Bool
|
||||
_init(void)
|
||||
{
|
||||
p = evry_plugin_new(NULL, "Window Action", type_action, "BORDER", NULL, 0, NULL, NULL,
|
||||
plugin = evry_plugin_new(NULL, "Window Action", type_action, "BORDER", NULL, 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch, _action, _item_icon_get, NULL, NULL);
|
||||
|
||||
evry_plugin_register(p, 1);
|
||||
evry_plugin_register(plugin, 1);
|
||||
|
||||
inst = E_NEW(Inst, 1);
|
||||
|
||||
|
@ -225,7 +216,7 @@ _init(void)
|
|||
static void
|
||||
_shutdown(void)
|
||||
{
|
||||
evry_plugin_free(p, 1);
|
||||
EVRY_PLUGIN_FREE(plugin);
|
||||
E_FREE(inst);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,13 +25,13 @@ _begin(Evry_Plugin *p, const Evry_Item *item __UNUSED__)
|
|||
|
||||
EINA_LIST_FREE(history, result)
|
||||
{
|
||||
it = evry_item_new(p, result, NULL);
|
||||
it = evry_item_new(NULL, p, result, NULL);
|
||||
p->items = eina_list_prepend(p->items, it);
|
||||
eina_stringshare_del(result);
|
||||
}
|
||||
}
|
||||
|
||||
it = evry_item_new(p, "0", NULL);
|
||||
it = evry_item_new(NULL, p, "0", NULL);
|
||||
p->items = eina_list_prepend(p->items, it);
|
||||
|
||||
return p;
|
||||
|
@ -120,7 +120,7 @@ _action(Evry_Plugin *p, const Evry_Item *it)
|
|||
|
||||
it = p->items->data;
|
||||
|
||||
it2 = evry_item_new(p, it->label, NULL);
|
||||
it2 = evry_item_new(NULL, p, it->label, NULL);
|
||||
p->items = eina_list_prepend(p->items, it2);
|
||||
|
||||
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
|
||||
|
@ -170,7 +170,7 @@ _cb_data(void *data, int type __UNUSED__, void *event)
|
|||
p->items = eina_list_remove(p->items, it);
|
||||
evry_item_free(it);
|
||||
|
||||
it = evry_item_new(p, ev->lines->line, NULL);
|
||||
it = evry_item_new(NULL, p, ev->lines->line, NULL);
|
||||
p->items = eina_list_prepend(p->items, it);
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ _shutdown(void)
|
|||
EINA_LIST_FREE(history, result)
|
||||
eina_stringshare_del(result);
|
||||
|
||||
evry_plugin_free(p1, 1);
|
||||
EVRY_PLUGIN_FREE(p1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,10 +7,7 @@ static Evry_Action *act;
|
|||
static void
|
||||
_cleanup(Evry_Plugin *p)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
evry_item_free(it);
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -18,24 +15,12 @@ _item_add(Evry_Plugin *p, E_Configure_It *eci, int match, int prio)
|
|||
{
|
||||
Evry_Item *it;
|
||||
|
||||
it = evry_item_new(p, eci->label, NULL);
|
||||
it->data[0] = eci;
|
||||
it = evry_item_new(NULL, p, eci->label, NULL);
|
||||
it->data = eci;
|
||||
it->priority = prio;
|
||||
it->fuzzy_match = match;
|
||||
|
||||
p->items = eina_list_append(p->items, it);
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_sort(const void *data1, const void *data2)
|
||||
{
|
||||
const Evry_Item *it1 = data1;
|
||||
const Evry_Item *it2 = data2;
|
||||
|
||||
if (it1->fuzzy_match - it2->fuzzy_match)
|
||||
return (it1->fuzzy_match - it2->fuzzy_match);
|
||||
|
||||
return (it1->priority - it2->priority);
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -67,7 +52,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
|
||||
if (eina_list_count(p->items) > 0)
|
||||
{
|
||||
p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
|
||||
p->items = evry_fuzzy_match_sort(p->items);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -78,7 +63,7 @@ static Evas_Object *
|
|||
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||
{
|
||||
Evas_Object *o = NULL;
|
||||
E_Configure_It *eci = it->data[0];
|
||||
E_Configure_It *eci = it->data;
|
||||
|
||||
if (eci->icon)
|
||||
{
|
||||
|
@ -101,7 +86,7 @@ _action(Evry_Action *act)
|
|||
char buf[1024];
|
||||
int found = 0;
|
||||
|
||||
eci = act->item1->data[0];
|
||||
eci = act->item1->data;
|
||||
con = e_container_current_get(e_manager_current_get());
|
||||
|
||||
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
||||
|
@ -145,9 +130,8 @@ _init(void)
|
|||
static void
|
||||
_shutdown(void)
|
||||
{
|
||||
evry_plugin_free(p, 1);
|
||||
EVRY_PLUGIN_FREE(p);
|
||||
|
||||
|
||||
evry_action_free(act);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ struct _Plugin
|
|||
|
||||
const char *directory;
|
||||
/* all files of directory */
|
||||
Eina_List *items;
|
||||
Eina_List *files;
|
||||
/* current list of files */
|
||||
Eina_List *cur;
|
||||
Eina_Bool command;
|
||||
|
@ -23,32 +23,19 @@ static Evry_Plugin *p2;
|
|||
static Evry_Action *act;
|
||||
|
||||
|
||||
static Evry_Item *
|
||||
_item_add(Plugin *p, const char *directory, const char *file)
|
||||
{
|
||||
Evry_Item *it = NULL;
|
||||
char buf[4096];
|
||||
|
||||
it = evry_item_new(&p->base, file, NULL);
|
||||
if (!it) return NULL;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/%s", directory, file);
|
||||
it->uri = eina_stringshare_add(buf);
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
static void
|
||||
_item_fill(Evry_Item *it)
|
||||
_item_fill(Evry_Item_File *file)
|
||||
{
|
||||
const char *mime;
|
||||
|
||||
if (it->mime) return;
|
||||
if (file->mime) return;
|
||||
|
||||
if (ecore_file_is_dir(it->uri))
|
||||
if (ecore_file_is_dir(file->uri))
|
||||
{
|
||||
it->mime = eina_stringshare_add("x-directory/normal");
|
||||
it->browseable = EINA_TRUE;
|
||||
file->mime = eina_stringshare_add("x-directory/normal");
|
||||
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -67,13 +54,13 @@ _item_fill(Evry_Item *it)
|
|||
* }
|
||||
* } */
|
||||
|
||||
if ((mime = efreet_mime_type_get(it->uri)))
|
||||
if ((mime = efreet_mime_type_get(file->uri)))
|
||||
{
|
||||
it->mime = eina_stringshare_add(mime);
|
||||
file->mime = eina_stringshare_add(mime);
|
||||
return;
|
||||
}
|
||||
|
||||
it->mime = eina_stringshare_add("None");
|
||||
file->mime = eina_stringshare_add("None");
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -99,23 +86,22 @@ _dirbrowse_idler(void *data)
|
|||
{
|
||||
Plugin *p = data;
|
||||
Eina_List *l;
|
||||
Evry_Item *it;
|
||||
Evry_Item_File *file;
|
||||
int cnt = 10;
|
||||
|
||||
EINA_LIST_FOREACH(p->items, l, it)
|
||||
EINA_LIST_FOREACH(p->files, l, file)
|
||||
{
|
||||
if (!it->mime)
|
||||
if (!file->mime)
|
||||
{
|
||||
_item_fill(it);
|
||||
_item_fill(file);
|
||||
cnt--;
|
||||
}
|
||||
if (cnt == 0) break;
|
||||
}
|
||||
|
||||
l = p->base.items;
|
||||
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
|
||||
|
||||
p->base.items = eina_list_sort(l, eina_list_count(l), _cb_sort);
|
||||
evry_plugin_async_update(&p->base, EVRY_ASYNC_UPDATE_ADD);
|
||||
evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD);
|
||||
|
||||
if (cnt > 0)
|
||||
{
|
||||
|
@ -126,31 +112,49 @@ _dirbrowse_idler(void *data)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_item_free(Evry_Item *it)
|
||||
{
|
||||
ITEM_FILE(file, it);
|
||||
if (file->uri) eina_stringshare_del(file->uri);
|
||||
if (file->mime) eina_stringshare_del(file->mime);
|
||||
|
||||
E_FREE(file);
|
||||
}
|
||||
|
||||
static void
|
||||
_read_directory(Plugin *p)
|
||||
{
|
||||
char *file;
|
||||
char *filename;
|
||||
Eina_List *files;
|
||||
Evry_Item *it;
|
||||
char buf[4096];
|
||||
Evry_Item_File *file;
|
||||
|
||||
files = ecore_file_ls(p->directory);
|
||||
|
||||
EINA_LIST_FREE(files, file)
|
||||
EINA_LIST_FREE(files, filename)
|
||||
{
|
||||
it = NULL;
|
||||
|
||||
if (file[0] == '.')
|
||||
if (filename[0] == '.')
|
||||
{
|
||||
free(file);
|
||||
free(filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
it = _item_add(p, p->directory, file);
|
||||
file = E_NEW(Evry_Item_File, 1);
|
||||
if (!file) return;
|
||||
|
||||
if (it)
|
||||
p->items = eina_list_append(p->items, it);
|
||||
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), filename, _item_free);
|
||||
|
||||
free(file);
|
||||
/* TODO one could have a function uri() instead that puts
|
||||
together dir and file name when needed */
|
||||
snprintf(buf, sizeof(buf), "%s/%s", p->directory, filename);
|
||||
file->uri = eina_stringshare_add(buf);
|
||||
|
||||
if (file)
|
||||
p->files = eina_list_append(p->files, file);
|
||||
|
||||
free(filename);
|
||||
}
|
||||
|
||||
p->idler = ecore_idler_add(_dirbrowse_idler, p);
|
||||
|
@ -159,50 +163,52 @@ _read_directory(Plugin *p)
|
|||
static Evry_Plugin *
|
||||
_begin(Evry_Plugin *plugin, const Evry_Item *it)
|
||||
{
|
||||
Plugin *p;
|
||||
Plugin *p = NULL;
|
||||
|
||||
/* is FILE ? */
|
||||
if (it && (it->plugin->type_out == plugin->type_in))
|
||||
{
|
||||
if (!it->uri || !ecore_file_is_dir(it->uri))
|
||||
ITEM_FILE(file, it);
|
||||
|
||||
if (!file->uri || !ecore_file_is_dir(file->uri))
|
||||
return NULL;
|
||||
|
||||
p = E_NEW(Plugin, 1);
|
||||
p->base = *plugin;
|
||||
p->base.items = NULL;
|
||||
|
||||
p->directory = eina_stringshare_add(it->uri);
|
||||
|
||||
p->directory = eina_stringshare_add(file->uri);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
p = E_NEW(Plugin, 1);
|
||||
p->base = *plugin;
|
||||
p->base.items = NULL;
|
||||
p->directory = eina_stringshare_add(e_user_homedir_get());
|
||||
}
|
||||
|
||||
|
||||
_read_directory(p);
|
||||
|
||||
return &p->base;
|
||||
return EVRY_PLUGIN(p);
|
||||
}
|
||||
|
||||
static void
|
||||
_cleanup(Evry_Plugin *plugin)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
Evry_Item *it;
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
Evry_Item_File *file;
|
||||
|
||||
if (p->directory)
|
||||
eina_stringshare_del(p->directory);
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
evry_item_free(it);
|
||||
EINA_LIST_FREE(p->files, file)
|
||||
evry_item_free(EVRY_ITEM(file));
|
||||
|
||||
if (p->idler)
|
||||
ecore_idler_del(p->idler);
|
||||
|
||||
if (plugin->items)
|
||||
eina_list_free(plugin->items);
|
||||
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
||||
|
||||
E_FREE(p);
|
||||
}
|
||||
|
@ -210,30 +216,31 @@ _cleanup(Evry_Plugin *plugin)
|
|||
static int
|
||||
_fetch(Evry_Plugin *plugin, const char *input)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
Evry_Item *it;
|
||||
PLUGIN(p, plugin);
|
||||
Evry_Item_File *file;
|
||||
Eina_List *l;
|
||||
int cnt = 0;
|
||||
int match;
|
||||
|
||||
if (!p->command)
|
||||
{
|
||||
if (p->base.items) eina_list_free(p->base.items);
|
||||
p->base.items = NULL;
|
||||
}
|
||||
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
||||
|
||||
/* input is command ? */
|
||||
if (input)
|
||||
{
|
||||
if (!strncmp(input, "/", 1))
|
||||
{
|
||||
if (p->command) return 1;
|
||||
if (p->command) return 1;
|
||||
|
||||
it = evry_item_new(&p->base, "/", NULL);
|
||||
if (!it) return 0;
|
||||
it->uri = eina_stringshare_add("/");
|
||||
p->base.items = eina_list_append(p->base.items, it);
|
||||
p->command = EINA_TRUE;
|
||||
return 1;
|
||||
file = E_NEW(Evry_Item_File, 1);
|
||||
if (file)
|
||||
{
|
||||
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), "/", _item_free);
|
||||
file->uri = eina_stringshare_add("/");
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
||||
p->command = EINA_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (!strncmp(input, "..", 2))
|
||||
{
|
||||
|
@ -253,21 +260,29 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
{
|
||||
tmp = strdup(dir);
|
||||
snprintf(dir, (end - dir) + 1, "%s", tmp);
|
||||
it = evry_item_new(&p->base, dir, NULL);
|
||||
if (!it) break;
|
||||
it->uri = eina_stringshare_add(dir);
|
||||
it->priority = prio;
|
||||
p->base.items = eina_list_append(p->base.items, it);
|
||||
|
||||
file = E_NEW(Evry_Item_File, 1);
|
||||
if (file)
|
||||
{
|
||||
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), dir, _item_free);
|
||||
file->uri = eina_stringshare_add(dir);
|
||||
EVRY_ITEM(file)->priority = prio;
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
||||
}
|
||||
end = strrchr(dir, '/');
|
||||
free(tmp);
|
||||
prio--;
|
||||
}
|
||||
|
||||
it = evry_item_new(&p->base, "/", NULL);
|
||||
if (!it) return 0;
|
||||
it->uri = eina_stringshare_add("/");
|
||||
it->priority = prio;
|
||||
p->base.items = eina_list_append(p->base.items, it);
|
||||
file = E_NEW(Evry_Item_File, 1);
|
||||
if (file)
|
||||
{
|
||||
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), "/", _item_free);
|
||||
file->uri = eina_stringshare_add("/");
|
||||
EVRY_ITEM(file)->priority = prio;
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
||||
}
|
||||
|
||||
p->command = EINA_TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
@ -276,53 +291,50 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
if (p->command)
|
||||
{
|
||||
p->command = EINA_FALSE;
|
||||
EINA_LIST_FREE(p->base.items, it)
|
||||
evry_item_free(it);
|
||||
EVRY_PLUGIN_ITEMS_FREE(p);
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(p->items, l, it)
|
||||
EINA_LIST_FOREACH(p->files, l, file)
|
||||
{
|
||||
if (input)
|
||||
{
|
||||
int match;
|
||||
if ((match = evry_fuzzy_match(it->label, input)))
|
||||
it->fuzzy_match = match;
|
||||
if ((match = evry_fuzzy_match(EVRY_ITEM(file)->label, input)))
|
||||
EVRY_ITEM(file)->fuzzy_match = match;
|
||||
else
|
||||
it = NULL;
|
||||
file = NULL;
|
||||
}
|
||||
|
||||
if (it)
|
||||
if (file)
|
||||
{
|
||||
p->base.items = eina_list_append(p->base.items, it);
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
||||
|
||||
if (cnt++ >= MAX_ITEMS) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (p->base.items)
|
||||
{
|
||||
p->base.items = eina_list_sort
|
||||
(p->base.items, eina_list_count(p->base.items), _cb_sort);
|
||||
if (!EVRY_PLUGIN(p)->items)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort);
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||
{
|
||||
Evas_Object *o = NULL;
|
||||
ITEM_FILE(file, it);
|
||||
|
||||
if (!it->mime)
|
||||
_item_fill((Evry_Item *)it);
|
||||
if (!file->mime)
|
||||
_item_fill(file);
|
||||
|
||||
if (!it->mime) return NULL;
|
||||
if (!file->mime) return NULL;
|
||||
|
||||
if (it->browseable)
|
||||
o = evry_icon_theme_get("folder", e);
|
||||
else
|
||||
o = evry_icon_mime_get(it->mime, e);
|
||||
o = evry_icon_mime_get(file->mime, e);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
@ -345,16 +357,18 @@ _open_folder_action(Evry_Action *act)
|
|||
|
||||
m = e_manager_list();
|
||||
|
||||
ITEM_FILE(file, act->item1);
|
||||
|
||||
if (!act->item1->browseable)
|
||||
{
|
||||
path = ecore_file_dir_get(act->item1->uri);
|
||||
path = ecore_file_dir_get(file->uri);
|
||||
if (!path) return 0;
|
||||
action->func.go(E_OBJECT(m->data), path);
|
||||
free(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
action->func.go(E_OBJECT(m->data), act->item1->uri);
|
||||
action->func.go(E_OBJECT(m->data), file->uri);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -386,8 +400,8 @@ _init(void)
|
|||
static void
|
||||
_shutdown(void)
|
||||
{
|
||||
evry_plugin_free(p1, 1);
|
||||
evry_plugin_free(p2, 1);
|
||||
EVRY_PLUGIN_FREE(p1);
|
||||
EVRY_PLUGIN_FREE(p2);
|
||||
|
||||
evry_action_free(act);
|
||||
}
|
||||
|
|
|
@ -23,11 +23,13 @@ static const char *view_types = NULL;
|
|||
static int
|
||||
_check_item(const Evry_Item *it)
|
||||
{
|
||||
if ((!it || !it->uri || !it->mime) ||
|
||||
(it->plugin->type_out != view_types))
|
||||
return 0;
|
||||
if (!it || it->plugin->type_out != view_types) return 0;
|
||||
|
||||
if (!strncmp(it->mime, "image/", 6))
|
||||
ITEM_FILE(file, it);
|
||||
|
||||
if (!file->uri || !file->mime) return 0;
|
||||
|
||||
if (!strncmp(file->mime, "image/", 6))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -46,7 +48,7 @@ _cb_preview_thumb_gen(void *data, Evas_Object *obj, void *event_info)
|
|||
}
|
||||
|
||||
void
|
||||
_show_item(Image_View *v, const Evry_Item *it, int dir)
|
||||
_show_item(Image_View *v, const Evry_Item_File *file, int dir)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
|
@ -75,7 +77,7 @@ _show_item(Image_View *v, const Evry_Item *it, int dir)
|
|||
}
|
||||
|
||||
v->o_thumb[1] = e_thumb_icon_add(v->evas);
|
||||
e_thumb_icon_file_set(v->o_thumb[1], it->uri, NULL);
|
||||
e_thumb_icon_file_set(v->o_thumb[1], file->uri, 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);
|
||||
|
@ -96,9 +98,9 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
|||
Image_View *v = (Image_View *) view;
|
||||
|
||||
Eina_List *l;
|
||||
Evry_Item *it = NULL, *cur_item;
|
||||
Evry_Item_File *file = NULL;
|
||||
|
||||
cur_item = v->state->sel_item;
|
||||
ITEM_FILE(cur_item, v->state->sel_item);
|
||||
|
||||
if (!strcmp(ev->key, "Down"))
|
||||
{
|
||||
|
@ -107,14 +109,14 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
|||
l = eina_list_data_find_list(v->items, cur_item);
|
||||
|
||||
if (l && l->next)
|
||||
it = l->next->data;
|
||||
file = l->next->data;
|
||||
else
|
||||
it = v->items->data;
|
||||
file = v->items->data;
|
||||
|
||||
if (it && (it != cur_item))
|
||||
if (file && (file != cur_item))
|
||||
{
|
||||
_show_item(v, it, 1);
|
||||
evry_item_select(v->state, it);
|
||||
_show_item(v, file, 1);
|
||||
evry_item_select(v->state, EVRY_ITEM(file));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -125,14 +127,14 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
|||
l = eina_list_data_find_list(v->items, cur_item);
|
||||
|
||||
if (l && l->prev)
|
||||
it = l->prev->data;
|
||||
file = l->prev->data;
|
||||
else
|
||||
it = eina_list_last(v->items)->data;
|
||||
file = eina_list_last(v->items)->data;
|
||||
|
||||
if (it && (it != cur_item))
|
||||
if (file && (file != cur_item))
|
||||
{
|
||||
_show_item(v, it, -1);
|
||||
evry_item_select(v->state, it);
|
||||
_show_item(v, file, -1);
|
||||
evry_item_select(v->state, EVRY_ITEM(file));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -172,19 +174,20 @@ static int
|
|||
_view_update(Evry_View *view)
|
||||
{
|
||||
Image_View *v = (Image_View *) view;
|
||||
Evry_Item *it;
|
||||
Evry_Item_File *file, se;
|
||||
Evry_Item *selected = v->state->sel_item;
|
||||
|
||||
v->items = _get_list(v->state);
|
||||
if (!v->items) return 0;
|
||||
|
||||
it = eina_list_data_find(v->items, v->state->sel_item);
|
||||
if (!it)
|
||||
file = eina_list_data_find(v->items, selected);
|
||||
if (!file)
|
||||
{
|
||||
it = v->items->data;
|
||||
evry_item_select(v->state, it);
|
||||
file = v->items->data;
|
||||
evry_item_select(v->state, EVRY_ITEM(file));
|
||||
}
|
||||
|
||||
_show_item(v, it, 0);
|
||||
_show_item(v, file, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -197,7 +200,7 @@ _view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow)
|
|||
|
||||
if (!s->plugin)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!_get_list(s))
|
||||
return NULL;
|
||||
|
||||
|
@ -213,9 +216,9 @@ _view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow)
|
|||
edje_extern_object_min_size_set(v->o_main, w * 3, 100);
|
||||
evas_object_resize(v->o_main, w * 3, h);
|
||||
|
||||
v->view.o_list = v->o_main;
|
||||
EVRY_VIEW(v)->o_list = v->o_main;
|
||||
|
||||
return &v->view;
|
||||
return EVRY_VIEW(v);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -15,7 +15,7 @@ struct _Plugin
|
|||
int max_hits;
|
||||
const char *input;
|
||||
const char *matched;
|
||||
Eina_List *items;
|
||||
Eina_List *files;
|
||||
};
|
||||
|
||||
static E_DBus_Connection *conn = NULL;
|
||||
|
@ -25,16 +25,16 @@ static int _prio = 5;
|
|||
static Evry_Plugin *
|
||||
_begin(Evry_Plugin *plugin, const Evry_Item *it)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
p->active = 0;
|
||||
|
||||
/* is APPLICATION ? */
|
||||
if (it && it->plugin->type_out == plugin->type_in)
|
||||
{
|
||||
ITEM_APP(app, it);
|
||||
Eina_List *l;
|
||||
const char *mime;
|
||||
Evry_App *app = it->data[0];
|
||||
char mime_entry[256];
|
||||
char rdf_query[32768];
|
||||
int len = 0;
|
||||
|
@ -72,45 +72,57 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it)
|
|||
return plugin;
|
||||
}
|
||||
|
||||
static Evry_Item *
|
||||
_item_add(Plugin *p, char *file, char *mime, int prio)
|
||||
static void
|
||||
_item_free(Evry_Item *it)
|
||||
{
|
||||
Evry_Item *it;
|
||||
ITEM_FILE(file, it);
|
||||
if (file->uri) eina_stringshare_del(file->uri);
|
||||
if (file->mime) eina_stringshare_del(file->mime);
|
||||
|
||||
E_FREE(file);
|
||||
}
|
||||
|
||||
static Evry_Item_File *
|
||||
_item_add(Plugin *p, char *path, char *mime, int prio)
|
||||
{
|
||||
Evry_Item_File *file;
|
||||
|
||||
const char *filename;
|
||||
int folder = (!strcmp(mime, "Folder"));
|
||||
|
||||
/* folders are specifically searched */
|
||||
if (folder && p->base.begin)
|
||||
if (folder && EVRY_PLUGIN(p)->begin)
|
||||
return NULL;
|
||||
|
||||
filename = ecore_file_file_get(file);
|
||||
filename = ecore_file_file_get(path);
|
||||
|
||||
if (!filename)
|
||||
return NULL;
|
||||
|
||||
it = evry_item_new(&p->base, filename, NULL);
|
||||
if (!it)
|
||||
return NULL;
|
||||
it->priority = prio;
|
||||
it->uri = eina_stringshare_add(file);
|
||||
file = E_NEW(Evry_Item_File, 1);
|
||||
if (!file) return NULL;
|
||||
|
||||
evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), filename, _item_free);
|
||||
file->uri = eina_stringshare_add(path);
|
||||
|
||||
EVRY_ITEM(file)->priority = prio;
|
||||
|
||||
if (folder)
|
||||
{
|
||||
it->browseable = EINA_TRUE;
|
||||
it->mime = eina_stringshare_add("x-directory/normal");
|
||||
it->priority = 1;
|
||||
EVRY_ITEM(file)->browseable = EINA_TRUE;
|
||||
file->mime = eina_stringshare_add("x-directory/normal");
|
||||
}
|
||||
else
|
||||
it->mime = eina_stringshare_add(mime);
|
||||
file->mime = eina_stringshare_add(mime);
|
||||
|
||||
return it;
|
||||
return file;
|
||||
}
|
||||
|
||||
static void
|
||||
_cleanup(Evry_Plugin *plugin)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
Evry_Item *it;
|
||||
PLUGIN(p, plugin);
|
||||
Evry_Item_File *file;
|
||||
|
||||
p->active = 0;
|
||||
|
||||
|
@ -122,12 +134,10 @@ _cleanup(Evry_Plugin *plugin)
|
|||
eina_stringshare_del(p->matched);
|
||||
p->matched = NULL;
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
evry_item_free(it);
|
||||
EINA_LIST_FREE(p->files, file)
|
||||
evry_item_free(EVRY_ITEM(file));
|
||||
|
||||
if (p->base.items)
|
||||
eina_list_free(p->base.items);
|
||||
p->base.items = NULL;
|
||||
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -146,15 +156,15 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
|||
{
|
||||
DBusMessageIter array, iter, item;
|
||||
char *uri, *mime, *date;
|
||||
Evry_Item *it;
|
||||
Eina_List *items = NULL;
|
||||
Evry_Item_File *file;
|
||||
Eina_List *files = NULL;
|
||||
Plugin *p = data;
|
||||
|
||||
if (p->active) p->active--;
|
||||
|
||||
if (dbus_error_is_set(error))
|
||||
{
|
||||
_cleanup(&p->base);
|
||||
_cleanup(EVRY_PLUGIN(p));
|
||||
printf("Error: %s - %s\n", error->name, error->message);
|
||||
return;
|
||||
}
|
||||
|
@ -182,31 +192,28 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
|||
|
||||
if (uri && mime && date)
|
||||
{
|
||||
it = _item_add(p, uri, mime, atoi(date));
|
||||
if (it)
|
||||
items = eina_list_append(items, it);
|
||||
file = _item_add(p, uri, mime, atoi(date));
|
||||
if (file) files = eina_list_append(files, file);
|
||||
}
|
||||
}
|
||||
dbus_message_iter_next(&item);
|
||||
}
|
||||
}
|
||||
|
||||
if (p->base.items)
|
||||
eina_list_free(p->base.items);
|
||||
p->base.items = NULL;
|
||||
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
||||
|
||||
if (items)
|
||||
if (files)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
evry_item_free(it);
|
||||
EINA_LIST_FREE(p->files, file)
|
||||
evry_item_free(EVRY_ITEM(file));
|
||||
|
||||
items = eina_list_sort(items, eina_list_count(items), _cb_sort);
|
||||
p->items = items;
|
||||
files = eina_list_sort(files, eina_list_count(files), _cb_sort);
|
||||
p->files = files;
|
||||
|
||||
EINA_LIST_FOREACH(p->items, l, it)
|
||||
p->base.items = eina_list_append(p->base.items, it);
|
||||
EINA_LIST_FOREACH(p->files, l, file)
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
||||
|
||||
if (p->matched)
|
||||
eina_stringshare_del(p->matched);
|
||||
|
@ -215,19 +222,19 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
|||
else
|
||||
p->matched = NULL;
|
||||
}
|
||||
else if (p->items && p->input && p->matched &&
|
||||
else if (p->files && p->input && p->matched &&
|
||||
(strlen(p->input) > strlen(p->matched)))
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
EINA_LIST_FOREACH(p->items, l, it)
|
||||
if (evry_fuzzy_match(it->label, (p->input + strlen(p->matched))))
|
||||
p->base.items = eina_list_append(p->base.items, it);
|
||||
EINA_LIST_FOREACH(p->files, l, file)
|
||||
if (evry_fuzzy_match(EVRY_ITEM(file)->label, (p->input + strlen(p->matched))))
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
evry_item_free(it);
|
||||
EINA_LIST_FREE(p->files, file)
|
||||
evry_item_free(EVRY_ITEM(file));
|
||||
|
||||
if (p->input)
|
||||
eina_stringshare_del(p->input);
|
||||
|
@ -238,13 +245,14 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
|||
p->matched = NULL;
|
||||
}
|
||||
|
||||
evry_plugin_async_update(&p->base, EVRY_ASYNC_UPDATE_ADD);
|
||||
evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD);
|
||||
}
|
||||
|
||||
static int
|
||||
_fetch(Evry_Plugin *plugin, const char *input)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
DBusMessage *msg;
|
||||
int live_query_id = 0;
|
||||
int max_hits = p->max_hits;
|
||||
|
@ -321,7 +329,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
if (input && (strlen(input) > 2))
|
||||
free(search_text);
|
||||
|
||||
if (p->items) return 1;
|
||||
if (p->files) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -329,10 +337,12 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
static Evas_Object *
|
||||
_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
||||
{
|
||||
ITEM_FILE(file, it);
|
||||
|
||||
if (it->browseable)
|
||||
return evry_icon_theme_get("folder", e);
|
||||
else
|
||||
return evry_icon_mime_get(it->mime, e);
|
||||
return evry_icon_mime_get(file->mime, e);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -349,17 +359,17 @@ _plugin_new(const char *name, int type, char *service, int max_hits, int begin)
|
|||
p->active = 0;
|
||||
|
||||
if (!begin)
|
||||
evry_plugin_new(&p->base, name, type, "", "FILE", 0, NULL, NULL,
|
||||
evry_plugin_new(EVRY_PLUGIN(p), name, type, "", "FILE", 0, NULL, NULL,
|
||||
NULL, _cleanup, _fetch,
|
||||
NULL, _icon_get, NULL, NULL);
|
||||
else
|
||||
evry_plugin_new(&p->base, name, type, "APPLICATION", "FILE", 0, NULL, NULL,
|
||||
evry_plugin_new(EVRY_PLUGIN(p), name, type, "APPLICATION", "FILE", 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch,
|
||||
NULL, _icon_get, NULL, NULL);
|
||||
|
||||
plugins = eina_list_append(plugins, p);
|
||||
|
||||
evry_plugin_register(&p->base, _prio++);
|
||||
evry_plugin_register(EVRY_PLUGIN(p), _prio++);
|
||||
}
|
||||
|
||||
|
||||
|
@ -391,11 +401,9 @@ _shutdown(void)
|
|||
|
||||
EINA_LIST_FREE(plugins, p)
|
||||
{
|
||||
evry_plugin_free(&p->base, 0);
|
||||
|
||||
if (p->condition[0]) free(p->condition);
|
||||
|
||||
E_FREE(p);
|
||||
EVRY_PLUGIN_FREE(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -582,7 +582,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
|||
else if (!strcmp(key, "Right"))
|
||||
_list_plugin_next(v);
|
||||
else return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)
|
||||
|
@ -593,7 +593,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
|||
_list_plugin_next(v);
|
||||
else if (ev->compose)
|
||||
_list_plugin_next_by_name(v, key);
|
||||
}
|
||||
}
|
||||
else return 0;
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
|
||||
typedef struct _Plugin Plugin;
|
||||
typedef struct _Import Import;
|
||||
typedef struct _Item_Data Item_Data;
|
||||
typedef struct _Item Item;
|
||||
|
||||
struct _Plugin
|
||||
{
|
||||
Evry_Plugin base;
|
||||
Plugin *prev;
|
||||
Eina_List *items;
|
||||
const Evry_Item *item;
|
||||
const Evry_Item_File *file;
|
||||
};
|
||||
|
||||
struct _Import
|
||||
|
@ -32,8 +32,9 @@ struct _Import
|
|||
Evas *evas;
|
||||
};
|
||||
|
||||
struct _Item_Data
|
||||
struct _Item
|
||||
{
|
||||
Evry_Item base;
|
||||
const char *icon;
|
||||
int method;
|
||||
};
|
||||
|
@ -46,55 +47,68 @@ static int _import_cb_edje_cc_exit(void *data, int type, void *event);
|
|||
static Evry_Plugin *plugin;
|
||||
|
||||
static void
|
||||
_item_free(Evry_Item *it)
|
||||
_item_free(Evry_Item *item)
|
||||
{
|
||||
Item_Data *id = it->data[0];
|
||||
E_FREE(id);
|
||||
Item *it = (Item*) item;
|
||||
E_FREE(it);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_add(Plugin *p, const char *name, int method, const char *icon)
|
||||
{
|
||||
Evry_Item *it;
|
||||
Item_Data *id;
|
||||
Item *item = E_NEW(Item, 1);
|
||||
evry_item_new(EVRY_ITEM(item), EVRY_PLUGIN(p), name, _item_free);
|
||||
|
||||
it = evry_item_new(&p->base, name, _item_free);
|
||||
id = E_NEW(Item_Data, 1);
|
||||
id->icon = icon;
|
||||
id->method = method;
|
||||
it->data[0] = id;
|
||||
p->items = eina_list_append(p->items, it);
|
||||
item->icon = icon;
|
||||
item->method = method;
|
||||
|
||||
p->items = eina_list_append(p->items, EVRY_ITEM(item));
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_item_icon_get(Evry_Plugin *plugin, const Evry_Item *item, Evas *e)
|
||||
{
|
||||
return evry_icon_theme_get(((Item*)item)->icon, e);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_icon_get(Evry_Plugin *plugin, const Evry_Item *it, Evas *e)
|
||||
{
|
||||
return evry_icon_theme_get("preferences-desktop-wallpaper", e);
|
||||
}
|
||||
|
||||
static Evry_Plugin *
|
||||
_begin(Evry_Plugin *plugin, const Evry_Item *item)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
Evry_Item *it;
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
/* is FILE ? */
|
||||
if (item && item->plugin->type_out == p->base.type_in)
|
||||
if (item && item->plugin->type_out == plugin->type_in)
|
||||
{
|
||||
if (!item->mime || (strncmp(item->mime, "image/", 6)))
|
||||
Evry_Item *it;
|
||||
ITEM_FILE(file, item);
|
||||
|
||||
if (!file->mime || (strncmp(file->mime, "image/", 6)))
|
||||
return NULL;
|
||||
|
||||
p = E_NEW(Plugin, 1);
|
||||
p->base = *plugin;
|
||||
p->base.items = NULL;
|
||||
p->item = item;
|
||||
|
||||
it = evry_item_new(&p->base, _("Set as Wallpaper"), NULL);
|
||||
p->file = file;
|
||||
|
||||
it = evry_item_new(NULL, plugin, _("Set as Wallpaper"), NULL);
|
||||
it->browseable = EINA_TRUE;
|
||||
|
||||
p->items = eina_list_append(p->items, it);
|
||||
|
||||
return &p->base;
|
||||
return EVRY_PLUGIN(p);
|
||||
}
|
||||
else if (item->plugin->type_out == plugin->type_out)
|
||||
{
|
||||
p = E_NEW(Plugin, 1);
|
||||
p->base = *plugin;
|
||||
p->base.items = NULL;
|
||||
p->base.icon_get = &_item_icon_get;
|
||||
p->prev = (Plugin*) item->plugin;
|
||||
|
||||
_item_add(p, _("Stretch"), IMPORT_STRETCH,
|
||||
|
@ -108,7 +122,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item)
|
|||
_item_add(p, _("Fill"), IMPORT_SCALE_ASPECT_OUT,
|
||||
"enlightenment/wallpaper_stretch");
|
||||
|
||||
return &p->base;
|
||||
return EVRY_PLUGIN(p);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -117,11 +131,10 @@ _begin(Evry_Plugin *plugin, const Evry_Item *item)
|
|||
static void
|
||||
_cleanup(Evry_Plugin *plugin)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
PLUGIN(p, plugin);
|
||||
Evry_Item *it;
|
||||
|
||||
if (p->base.items) eina_list_free(p->base.items);
|
||||
p->base.items = NULL;
|
||||
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
evry_item_free(it);
|
||||
|
@ -132,38 +145,41 @@ _cleanup(Evry_Plugin *plugin)
|
|||
static int
|
||||
_fetch(Evry_Plugin *plugin, const char *input)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
PLUGIN(p, plugin);
|
||||
Evry_Item *it = NULL;
|
||||
Eina_List *l;
|
||||
int match = 0;
|
||||
|
||||
if (p->base.items) eina_list_free(p->base.items);
|
||||
p->base.items = NULL;
|
||||
EVRY_PLUGIN_ITEMS_CLEAR(p);
|
||||
|
||||
EINA_LIST_FOREACH(p->items, l, it)
|
||||
plugin->items = eina_list_append(plugin->items, it);
|
||||
if (!input || (match = evry_fuzzy_match(it->label, input)))
|
||||
{
|
||||
it->fuzzy_match = match;
|
||||
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
||||
}
|
||||
|
||||
if (input)
|
||||
plugin->items = evry_fuzzy_match_sort(plugin->items);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_action(Evry_Plugin *plugin, const Evry_Item *it)
|
||||
_action(Evry_Plugin *plugin, const Evry_Item *item)
|
||||
{
|
||||
Plugin *p = (Plugin*) plugin;
|
||||
PLUGIN(p, plugin);
|
||||
|
||||
if (p->prev)
|
||||
{
|
||||
const Evry_Item *it_file;
|
||||
Item_Data *id;
|
||||
Import *import;
|
||||
|
||||
Item *it = (Item*) item;
|
||||
import = E_NEW(Import, 1);
|
||||
it_file = p->prev->item;
|
||||
id = it->data[0];
|
||||
import->method = id->method;
|
||||
import->file = it_file->uri;
|
||||
import->method = it->method;
|
||||
import->file = p->prev->file->uri;
|
||||
import->quality = 100;
|
||||
import->external = 0;
|
||||
import->evas = evas_object_evas_get(it->o_bg); /* Eeek! */
|
||||
import->evas = evas_object_evas_get(item->o_bg); /* Eeek! */
|
||||
_import_edj_gen(import);
|
||||
|
||||
return 1;
|
||||
|
@ -172,26 +188,6 @@ _action(Evry_Plugin *plugin, const Evry_Item *it)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_icon_get(Evry_Plugin *plugin, const Evry_Item *it, Evas *e)
|
||||
{
|
||||
/* Plugin *p = (Plugin*) plugin; */
|
||||
Evas_Object *o = NULL;
|
||||
|
||||
if (it->data[0])
|
||||
{
|
||||
const char *icon = ((Item_Data*) it->data[0])->icon;
|
||||
|
||||
o = evry_icon_theme_get(icon, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
o = evry_icon_theme_get("preferences-desktop-wallpaper", e);
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_init(void)
|
||||
{
|
||||
|
@ -208,7 +204,7 @@ _init(void)
|
|||
static void
|
||||
_shutdown(void)
|
||||
{
|
||||
evry_plugin_free(plugin, 1);
|
||||
EVRY_PLUGIN_FREE(plugin);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue