forked from enlightenment/enlightenment
'everything' cleanups. added p->view_mode for plugins to request a view used for them
SVN revision: 48005
This commit is contained in:
parent
3cf05dd915
commit
1ac2bb559a
|
@ -343,6 +343,7 @@ module_init(void)
|
|||
NULL, _cleanup, _fetch, NULL, NULL, _free_plugin);
|
||||
|
||||
EVRY_PLUGIN(p)->aggregate = EINA_FALSE;
|
||||
EVRY_PLUGIN(p)->history = EINA_FALSE;
|
||||
|
||||
evry_plugin_register(EVRY_PLUGIN(p), 100);
|
||||
|
||||
|
|
|
@ -231,8 +231,10 @@ module_init(void)
|
|||
|
||||
p1 = evry_plugin_new(NULL, "Calculator", type_subject, NULL, "TEXT", 1, "accessories-calculator", "=",
|
||||
_begin, _cleanup, _fetch, _action, NULL, NULL);
|
||||
|
||||
|
||||
p1->view_mode = VIEW_MODE_LIST;
|
||||
p1->aggregate = EINA_FALSE;
|
||||
p1->history = EINA_FALSE;
|
||||
|
||||
evry_plugin_register(p1, 0);
|
||||
|
||||
|
|
|
@ -89,7 +89,6 @@ _item_add(Evry_Plugin *p, E_Border *bd, int match, int *prio)
|
|||
it->data = bd;
|
||||
it->fuzzy_match = match;
|
||||
it->priority = *prio;
|
||||
it->transient = EINA_TRUE;
|
||||
it->id = eina_stringshare_add(e_util_winid_str_get(bd->win));
|
||||
|
||||
*prio += 1;
|
||||
|
@ -490,6 +489,7 @@ module_init(void)
|
|||
|
||||
plugin = evry_plugin_new(NULL, "Windows", type_subject, NULL, "BORDER", 0, NULL, NULL,
|
||||
_begin, _cleanup, _fetch, NULL, _item_icon_get, NULL);
|
||||
plugin->transient = EINA_TRUE;
|
||||
evry_plugin_register(plugin, 2);
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
#define EVRY_ASYNC_UPDATE_CLEAR 1
|
||||
#define EVRY_ASYNC_UPDATE_REFRESH 2
|
||||
|
||||
#define VIEW_MODE_LIST 0
|
||||
#define VIEW_MODE_DETAIL 1
|
||||
#define VIEW_MODE_THUMB 2
|
||||
|
||||
extern int _e_module_evry_log_dom;
|
||||
|
||||
#ifndef EINA_LOG_DEFAULT_COLOR
|
||||
|
@ -99,44 +103,35 @@ struct _Evry_Item
|
|||
/* label to show for this item */
|
||||
const char *label;
|
||||
|
||||
/**/
|
||||
/* optional: more information to be shown */
|
||||
const char *detail;
|
||||
|
||||
/* for 'static' fdo icon name, otherwise use _icon_get */
|
||||
/* optional: for 'static' fdo icon name, otherwise use _icon_get */
|
||||
const char *icon;
|
||||
|
||||
/* context provided by item. e.g. to remember which action
|
||||
* was performed on a file with a specific mimetype */
|
||||
const char *context;
|
||||
|
||||
/* item can be browsed, e.g. folders */
|
||||
Eina_Bool browseable;
|
||||
|
||||
Eina_Bool selected;
|
||||
|
||||
/* for internally use by plugins */
|
||||
/* optional: for internally use by plugins */
|
||||
void *data;
|
||||
|
||||
/* priority hints for sorting */
|
||||
/* optional: priority hints for sorting */
|
||||
int priority;
|
||||
|
||||
/* store value of fuzzy match with input */
|
||||
/* optional: store value of fuzzy match with input */
|
||||
int fuzzy_match;
|
||||
|
||||
|
||||
/*** HISTORY
|
||||
* optional: plugin can set id to identify
|
||||
/* optional: plugin can set id to identify
|
||||
* it in history otherwise label is used */
|
||||
const char *id;
|
||||
|
||||
/* if transient item is removed from history on shutdown */
|
||||
Eina_Bool transient;
|
||||
|
||||
/* ignores completely from usage statistic */
|
||||
Eina_Bool no_history;
|
||||
|
||||
/* optional: context provided by item. e.g. to remember which action
|
||||
* was performed on a file with a specific mimetype */
|
||||
const char *context;
|
||||
|
||||
/* do not set by plugin! */
|
||||
Evry_Item *next;
|
||||
Eina_Bool selected;
|
||||
Evry_Plugin *plugin;
|
||||
int ref;
|
||||
void (*free) (Evry_Item *item);
|
||||
|
@ -158,7 +153,6 @@ struct _Evry_Item_File
|
|||
const char *mime;
|
||||
};
|
||||
|
||||
|
||||
struct _Evry_Plugin
|
||||
{
|
||||
const char *name;
|
||||
|
@ -184,27 +178,36 @@ struct _Evry_Plugin
|
|||
/* run when state is removed in which this plugin is active */
|
||||
void (*cleanup) (Evry_Plugin *p);
|
||||
|
||||
/* get an icon for an item. will be freed automatically */
|
||||
Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e);
|
||||
/* provide more information for a candidate */
|
||||
/* int (*candidate_info) (Evas *evas, Evry_Item *item); */
|
||||
|
||||
|
||||
/* only used when plugin is of type_action */
|
||||
int (*action) (Evry_Plugin *p, const Evry_Item *item);
|
||||
|
||||
/* handle key events: return 1 when key is handled by plugin */
|
||||
int (*cb_key_down) (Evry_Plugin *p, const Ecore_Event_Key *ev);
|
||||
|
||||
/* optional: use this when you extend the plugin struct */
|
||||
void (*free) (Evry_Plugin *p);
|
||||
|
||||
/* show in aggregator. default is TRUE */
|
||||
/* show in aggregator */
|
||||
/* default TRUE */
|
||||
Eina_Bool aggregate;
|
||||
|
||||
/* whether the plugin uses evry_async_update to add new
|
||||
items. default is FALSE */
|
||||
/* whether the plugin uses evry_async_update to add new items. */
|
||||
/* default FALSE */
|
||||
Eina_Bool async_fetch;
|
||||
|
||||
/* TODO request list-view */
|
||||
Eina_Bool show_list_view;
|
||||
/* request VIEW_MODE for plugin */
|
||||
int view_mode;
|
||||
|
||||
/* request items to be remembered for usage statistic */
|
||||
/* default TRUE */
|
||||
Eina_Bool history;
|
||||
|
||||
/* if transient, item is removed from history on shutdown */
|
||||
/* default FALSE */
|
||||
Eina_Bool transient;
|
||||
|
||||
/* not to be set by plugin! */
|
||||
Plugin_Config *config;
|
||||
|
|
|
@ -410,6 +410,9 @@ evry_plugin_new(Evry_Plugin *base, const char *name, int type,
|
|||
p->aggregate = EINA_TRUE;
|
||||
p->async_fetch = EINA_FALSE;
|
||||
p->free = cb_free;
|
||||
|
||||
p->history = EINA_TRUE;
|
||||
p->view_mode = -1;
|
||||
|
||||
DBG("%s", p->name);
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt)
|
|||
if (!s) return;
|
||||
|
||||
it = s->cur_item;
|
||||
if (!it || it->no_history) return;
|
||||
if (!it || !it->plugin->history) return;
|
||||
|
||||
id = (it->id ? it->id : it->label);
|
||||
|
||||
|
@ -246,7 +246,7 @@ evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt)
|
|||
hi->last_used = ecore_time_get();
|
||||
hi->usage /= 4.0;
|
||||
hi->usage += TIME_FACTOR(hi->last_used);
|
||||
hi->transient = it->transient;
|
||||
hi->transient = it->plugin->transient;
|
||||
hi->count += (hi->transient ? 2:1);
|
||||
if (ctxt && !hi->context)
|
||||
hi->context = eina_stringshare_ref(ctxt);
|
||||
|
@ -269,7 +269,7 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, c
|
|||
History_Item *hi;
|
||||
Eina_List *l;
|
||||
|
||||
if (it->no_history)
|
||||
if (!it->plugin->history)
|
||||
return 0;
|
||||
|
||||
it->usage = 0.0;
|
||||
|
@ -280,6 +280,7 @@ evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, c
|
|||
{
|
||||
if (hi->plugin != it->plugin->name)
|
||||
continue;
|
||||
|
||||
if (ctxt != hi->context)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "e_mod_main.h"
|
||||
|
||||
#define MAX_ITEMS 100
|
||||
|
||||
typedef struct _Plugin Plugin;
|
||||
|
||||
|
@ -162,12 +163,14 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
EINA_LIST_FOREACH(lp, l, pp)
|
||||
{
|
||||
if (!pp->aggregate) continue;
|
||||
cnt = 0;
|
||||
|
||||
for (cnt = 0, ll = pp->items; ll && cnt < 50; ll = ll->next, cnt++)
|
||||
EINA_LIST_FOREACH(pp->items, ll, it)
|
||||
{
|
||||
if (!eina_list_data_find_list(items, ll->data))
|
||||
if (cnt++ == MAX_ITEMS) break;
|
||||
|
||||
if (!eina_list_data_find_list(items, it))
|
||||
{
|
||||
it = ll->data;
|
||||
it->fuzzy_match = 0;
|
||||
items = _add_item(p, items, it);
|
||||
}
|
||||
|
@ -218,6 +221,14 @@ _fetch(Evry_Plugin *plugin, const char *input)
|
|||
EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort_recent);
|
||||
}
|
||||
|
||||
cnt = 0;
|
||||
EINA_LIST_FOREACH_SAFE(p->base.items, l, ll, it)
|
||||
{
|
||||
if (cnt++ < MAX_ITEMS) continue;
|
||||
evry_item_free(it);
|
||||
p->base.items = eina_list_remove_list(p->base.items, l);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,6 @@ typedef struct _View View;
|
|||
typedef struct _Smart_Data Smart_Data;
|
||||
typedef struct _Item Item;
|
||||
|
||||
#define MODE_LIST 0
|
||||
#define MODE_DETAIL 1
|
||||
#define MODE_THUMB 2
|
||||
|
||||
#define SIZE_LIST 30
|
||||
#define SIZE_DETAIL 38
|
||||
|
||||
|
@ -183,12 +179,12 @@ _e_smart_reconfigure_do(void *data)
|
|||
aspect_w = sd->w;
|
||||
aspect_h = sd->h;
|
||||
|
||||
if (sd->view->mode == MODE_LIST)
|
||||
if (sd->view->mode == VIEW_MODE_LIST)
|
||||
{
|
||||
iw = sd->w;
|
||||
hh = SIZE_LIST;
|
||||
}
|
||||
else if (sd->view->mode == MODE_DETAIL)
|
||||
else if (sd->view->mode == VIEW_MODE_DETAIL)
|
||||
{
|
||||
iw = sd->w;
|
||||
hh = SIZE_DETAIL;
|
||||
|
@ -228,7 +224,7 @@ _e_smart_reconfigure_do(void *data)
|
|||
y = 0;
|
||||
ww = iw;
|
||||
|
||||
if (sd->view->mode == MODE_THUMB)
|
||||
if (sd->view->mode == VIEW_MODE_THUMB)
|
||||
hh = (aspect_h * iw) / (aspect_w);
|
||||
|
||||
mw = mh = 0;
|
||||
|
@ -250,8 +246,8 @@ _e_smart_reconfigure_do(void *data)
|
|||
x += ww;
|
||||
}
|
||||
|
||||
if (sd->view->mode == MODE_LIST ||
|
||||
sd->view->mode == MODE_DETAIL)
|
||||
if (sd->view->mode == VIEW_MODE_LIST ||
|
||||
sd->view->mode == VIEW_MODE_DETAIL)
|
||||
mh += sd->h % hh;
|
||||
|
||||
if ((mw != sd->cw) || (mh != sd->ch))
|
||||
|
@ -301,7 +297,7 @@ _e_smart_reconfigure_do(void *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (sd->view->mode == MODE_THUMB)
|
||||
if (sd->view->mode == VIEW_MODE_THUMB)
|
||||
{
|
||||
if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2;
|
||||
if (sd->h > sd->ch) oy = (sd->h - sd->ch) / 2;
|
||||
|
@ -344,7 +340,7 @@ _e_smart_reconfigure_do(void *data)
|
|||
if (!it->frame)
|
||||
{
|
||||
it->frame = edje_object_add(sd->view->evas);
|
||||
if (sd->view->mode == MODE_THUMB)
|
||||
if (sd->view->mode == VIEW_MODE_THUMB)
|
||||
{
|
||||
e_theme_edje_object_set(it->frame, "base/theme/widgets",
|
||||
"e/modules/everything/thumbview/item/thumb");
|
||||
|
@ -354,7 +350,7 @@ _e_smart_reconfigure_do(void *data)
|
|||
e_theme_edje_object_set(it->frame, "base/theme/widgets",
|
||||
"e/modules/everything/thumbview/item/list");
|
||||
|
||||
if (sd->view->mode == MODE_DETAIL)
|
||||
if (sd->view->mode == VIEW_MODE_DETAIL)
|
||||
edje_object_signal_emit(it->frame, "e,state,detail,show", "e");
|
||||
}
|
||||
|
||||
|
@ -364,7 +360,7 @@ _e_smart_reconfigure_do(void *data)
|
|||
|
||||
edje_object_part_text_set(it->frame, "e.text.label", it->item->label);
|
||||
|
||||
if (sd->view->mode == MODE_DETAIL && it->item->detail)
|
||||
if (sd->view->mode == VIEW_MODE_DETAIL && it->item->detail)
|
||||
edje_object_part_text_set(it->frame, "e.text.detail", it->item->detail);
|
||||
|
||||
evas_object_show(it->frame);
|
||||
|
@ -708,8 +704,8 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll)
|
|||
}
|
||||
else scroll = 0;
|
||||
|
||||
if (sd->view->mode == MODE_LIST ||
|
||||
sd->view->mode == MODE_DETAIL)
|
||||
if (sd->view->mode == VIEW_MODE_LIST ||
|
||||
sd->view->mode == VIEW_MODE_DETAIL)
|
||||
{
|
||||
int all = sd->ch / it->h;
|
||||
int rows = (sd->h < sd->ch) ? (sd->h / it->h) : all;
|
||||
|
@ -1036,10 +1032,10 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
|||
if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
|
||||
(!strcmp(ev->key, "2")))
|
||||
{
|
||||
if (v->mode == MODE_LIST)
|
||||
v->mode = MODE_DETAIL;
|
||||
if (v->mode == VIEW_MODE_LIST)
|
||||
v->mode = VIEW_MODE_DETAIL;
|
||||
else
|
||||
v->mode = MODE_LIST;
|
||||
v->mode = VIEW_MODE_LIST;
|
||||
|
||||
v->zoom = 0;
|
||||
_clear_items(v->span);
|
||||
|
@ -1050,10 +1046,10 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
|||
((!strcmp(ev->key, "plus")) ||
|
||||
(!strcmp(ev->key, "3"))))
|
||||
{
|
||||
if (v->mode != MODE_THUMB)
|
||||
if (v->mode != VIEW_MODE_THUMB)
|
||||
{
|
||||
v->zoom = 0;
|
||||
v->mode = MODE_THUMB;
|
||||
v->mode = VIEW_MODE_THUMB;
|
||||
_clear_items(v->span);
|
||||
}
|
||||
else
|
||||
|
@ -1097,7 +1093,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
|||
if (sd->items)
|
||||
l = eina_list_data_find_list(sd->items, sd->cur_item);
|
||||
|
||||
if (v->mode == MODE_THUMB && !evry_conf->cycle_mode)
|
||||
if (v->mode == VIEW_MODE_THUMB && !evry_conf->cycle_mode)
|
||||
{
|
||||
if (!strcmp(ev->key, "Right"))
|
||||
{
|
||||
|
|
|
@ -362,8 +362,9 @@ evry_util_exec_app(const Evry_Item *it_app, const Evry_Item *it_file)
|
|||
}
|
||||
else if (app->file)
|
||||
{
|
||||
exe = (char *) app->file;
|
||||
e_exec(zone, NULL, exe, NULL, NULL);
|
||||
files = eina_list_append(files, app->file);
|
||||
e_exec(zone, app->desktop, NULL, files, NULL);
|
||||
eina_list_free(files);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue