forked from enlightenment/enlightenment
'everything' module: added open-file sub action for apps (try tab on an app)
- added Evry_Action which allows to add actions to item types that are provided by other source plugins. The action can act on two items, e.g. select an app -> chose action 'open file' -> all plugins which provide FILE are queried -> select file -> enter executes app with given file - moved back to static plugin instances, plugin that can be instantiated recursively must thandle this in begin/cleanup functions (see dir_browse) SVN revision: 41189
This commit is contained in:
parent
6efe302d22
commit
9f2914ffe4
|
@ -23,10 +23,12 @@ module_la_SOURCES = e_mod_main.c \
|
|||
evry.c \
|
||||
evry.h \
|
||||
evry_plug_config.c \
|
||||
evry_plug_dir_browse.c \
|
||||
evry_plug_apps.c \
|
||||
evry_plug_tracker.c \
|
||||
evry_plug_border.c \
|
||||
evry_plug_dir_browse.c
|
||||
evry_plug_border_act.c
|
||||
|
||||
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
|
|
|
@ -70,11 +70,12 @@ e_modapi_init(E_Module *m)
|
|||
conf_module = m;
|
||||
evry_init();
|
||||
|
||||
evry_plug_border_init();
|
||||
evry_plug_apps_init();
|
||||
evry_plug_config_init();
|
||||
evry_plug_dir_browse_init();
|
||||
evry_plug_apps_init();
|
||||
evry_plug_tracker_init();
|
||||
evry_plug_border_init();
|
||||
evry_plug_border_act_init();
|
||||
|
||||
/* add module supplied action */
|
||||
act = e_action_add("everything");
|
||||
|
@ -109,11 +110,12 @@ e_modapi_shutdown(E_Module *m)
|
|||
act = NULL;
|
||||
}
|
||||
|
||||
evry_plug_border_shutdown();
|
||||
evry_plug_apps_shutdown();
|
||||
evry_plug_config_shutdown();
|
||||
evry_plug_dir_browse_shutdown();
|
||||
evry_plug_apps_shutdown();
|
||||
evry_plug_tracker_shutdown();
|
||||
evry_plug_border_shutdown();
|
||||
evry_plug_border_act_shutdown();
|
||||
|
||||
evry_shutdown();
|
||||
conf_module = NULL;
|
||||
|
|
|
@ -51,6 +51,9 @@ EAPI int evry_plug_apps_shutdown(void);
|
|||
EAPI int evry_plug_border_init(void);
|
||||
EAPI int evry_plug_border_shutdown(void);
|
||||
|
||||
EAPI int evry_plug_border_act_init(void);
|
||||
EAPI int evry_plug_border_act_shutdown(void);
|
||||
|
||||
EAPI int evry_plug_config_init(void);
|
||||
EAPI int evry_plug_config_shutdown(void);
|
||||
|
||||
|
|
|
@ -10,15 +10,20 @@ typedef struct _Evry_State Evry_State;
|
|||
|
||||
struct _Evry_State
|
||||
{
|
||||
Eina_List *cur_items;
|
||||
Eina_List *cur_plugins;
|
||||
Eina_List *plugins;
|
||||
Evry_Plugin *cur_plugin;
|
||||
Evry_Item *sel_item;
|
||||
|
||||
Eina_List *cur_actions;
|
||||
Evry_Action *cur_action;
|
||||
|
||||
/* Eina_List *sel_items; */
|
||||
char *input;
|
||||
const char *request_type;
|
||||
|
||||
Eina_Bool initial;
|
||||
Eina_Bool get_parameter; /* TODO better name !*/
|
||||
};
|
||||
|
||||
static int _evry_cb_key_down(void *data, int type, void *event);
|
||||
|
@ -53,34 +58,42 @@ static int _evry_pop_state(void);
|
|||
static void _evry_plugin_selector_append(Evry_Plugin *p);
|
||||
static int _evry_cb_plugin_sort(const void *data1, const void *data2);
|
||||
|
||||
static int _evry_plug_act_select_init(void);
|
||||
static int _evry_plug_act_select_actions_set(void);
|
||||
static int _evry_plug_act_select_fetch(const char *input);
|
||||
static int _evry_plug_act_select_action(Evry_Item *item, const char *input);
|
||||
static void _evry_plug_act_select_cleanup(void);
|
||||
static void _evry_plug_act_select_item_icon_get(Evry_Item *it, Evas *e);
|
||||
|
||||
|
||||
|
||||
/* local subsystem globals */
|
||||
static E_Popup *popup = NULL;
|
||||
static Ecore_X_Window input_window = 0;
|
||||
static Eina_List *handlers = NULL;
|
||||
static Ecore_Timer *update_timer = NULL;
|
||||
static Evas_Object *o_list = NULL;
|
||||
static Evas_Object *o_main = NULL;
|
||||
static Evas_Object *o_selector = NULL;
|
||||
static Evas_Object *o_selector_frame = NULL;
|
||||
static Eina_List *handlers = NULL;
|
||||
static Ecore_Timer *update_timer = NULL;
|
||||
|
||||
static Eina_List *plugins = NULL;
|
||||
static Evry_State *cur_state = NULL;
|
||||
static Eina_List *stack = NULL;
|
||||
|
||||
static int ev_last_is_mouse;
|
||||
static int ev_last_is_mouse;
|
||||
static Evry_Item *item_mouseover = NULL;
|
||||
|
||||
static Ecore_Animator *scroll_animator = NULL;
|
||||
static Ecore_Timer *scroll_timer = NULL;
|
||||
static double scroll_align_to;
|
||||
static double scroll_align;
|
||||
|
||||
static Eina_List *plugins = NULL;
|
||||
static Eina_List *actions = NULL;
|
||||
static Evry_State *cur_state = NULL;
|
||||
static Eina_List *stack = NULL;
|
||||
static Evry_Plugin *action_selector = NULL;
|
||||
|
||||
/* externally accessible functions */
|
||||
EAPI int
|
||||
evry_init(void)
|
||||
{
|
||||
_evry_plug_act_select_init();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -92,19 +105,33 @@ evry_shutdown(void)
|
|||
}
|
||||
|
||||
EAPI void
|
||||
evry_plugin_register(Evry_Plugin_Class *plugin)
|
||||
evry_plugin_register(Evry_Plugin *plugin)
|
||||
{
|
||||
plugins = eina_list_append(plugins, plugin);
|
||||
/* TODO sorting, initialization, etc */
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evry_plugin_unregister(Evry_Plugin_Class *plugin)
|
||||
evry_plugin_unregister(Evry_Plugin *plugin)
|
||||
{
|
||||
plugins = eina_list_remove(plugins, plugin);
|
||||
/* cleanup */
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evry_action_register(Evry_Action *action)
|
||||
{
|
||||
actions = eina_list_append(actions, action);
|
||||
/* TODO sorting, initialization, etc */
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evry_action_unregister(Evry_Action *action)
|
||||
{
|
||||
actions = eina_list_remove(actions, action);
|
||||
/* cleanup */
|
||||
}
|
||||
|
||||
EAPI int
|
||||
evry_show(E_Zone *zone)
|
||||
{
|
||||
|
@ -209,7 +236,7 @@ evry_hide(void)
|
|||
free(s->input);
|
||||
|
||||
EINA_LIST_FREE(s->plugins, p)
|
||||
p->class->free(p);
|
||||
p->cleanup();
|
||||
}
|
||||
stack = NULL;
|
||||
cur_state = NULL;
|
||||
|
@ -255,7 +282,7 @@ evry_hide(void)
|
|||
|
||||
|
||||
EAPI void
|
||||
evry_plugin_async_update(Evry_Plugin *plugin, int state)
|
||||
evry_plugin_async_update(Evry_Plugin *p, int state)
|
||||
{
|
||||
Evry_State *s;
|
||||
|
||||
|
@ -263,18 +290,23 @@ evry_plugin_async_update(Evry_Plugin *plugin, int state)
|
|||
|
||||
s = cur_state;
|
||||
|
||||
if (!eina_list_data_find(s->cur_plugins, plugin))
|
||||
if (!eina_list_data_find(s->cur_plugins, p))
|
||||
{
|
||||
s->cur_plugins = eina_list_append(s->cur_plugins, plugin);
|
||||
_evry_plugin_selector_append(plugin);
|
||||
s->cur_plugins = eina_list_append(s->cur_plugins, p);
|
||||
_evry_plugin_selector_append(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
char buf[64];
|
||||
snprintf(buf, 64, "%s (%d)", p->name, eina_list_count(p->items));
|
||||
edje_object_part_text_set(p->tab, "e.text.label", buf);
|
||||
}
|
||||
|
||||
if (s->cur_plugin && eina_list_data_find(s->cur_plugins, s->cur_plugin))
|
||||
_evry_show_items(s->cur_plugin);
|
||||
else if (!s->cur_plugin && s->cur_plugins)
|
||||
_evry_show_items(s->cur_plugins->data);
|
||||
else if (s->cur_plugins && !eina_list_data_find(s->cur_plugins, s->cur_plugin))
|
||||
_evry_show_items(s->cur_plugins->data);
|
||||
if (!s->cur_plugin && s->cur_plugins)
|
||||
{
|
||||
_evry_list_clear();
|
||||
_evry_show_items(s->cur_plugins->data);
|
||||
}
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
|
@ -283,7 +315,7 @@ _evry_cb_plugin_sort(const void *data1, const void *data2)
|
|||
{
|
||||
const Evry_Plugin *p1 = data1;
|
||||
const Evry_Plugin *p2 = data2;
|
||||
return p1->class->prio - p2->class->prio;
|
||||
return p1->prio - p2->prio;
|
||||
}
|
||||
|
||||
|
||||
|
@ -292,39 +324,63 @@ _evry_push_state(void)
|
|||
{
|
||||
Evry_State *s;
|
||||
Eina_List *l, *list = NULL;
|
||||
Evry_Plugin_Class *pc;
|
||||
const char *expect_type = "NONE";
|
||||
const char *cur_type = "NONE";
|
||||
Evry_Plugin *p;
|
||||
|
||||
s = cur_state;
|
||||
|
||||
if (s)
|
||||
{
|
||||
expect_type = s->cur_plugin->class->type_out;
|
||||
if (!strcmp(expect_type, "NONE") || !s->sel_item)
|
||||
if (!s->cur_plugin || !s->sel_item)
|
||||
return 0;
|
||||
|
||||
cur_type = s->cur_plugin->type_out;
|
||||
/* current plugin provides no candidates to act on by others */
|
||||
if (!s->cur_action && !strcmp(cur_type, "NONE"))
|
||||
return 0;
|
||||
|
||||
EINA_LIST_FOREACH(s->plugins, l, p)
|
||||
if (p != s->cur_plugin)
|
||||
p->cleanup();
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(plugins, l, pc)
|
||||
EINA_LIST_FOREACH(plugins, l, p)
|
||||
{
|
||||
if (strstr(pc->type_in, expect_type))
|
||||
if (strstr(p->type_in, cur_type))
|
||||
{
|
||||
p = pc->new();
|
||||
/* printf("%s- in:%s out:%s\n", p->name, p->type_in, p->type_out); */
|
||||
|
||||
if (!p) continue;
|
||||
|
||||
if (cur_state && p->begin)
|
||||
if (s && s->cur_action)
|
||||
{
|
||||
if (p->begin(p, cur_state->sel_item))
|
||||
/* filter out plugins that dont provide the type
|
||||
requested by current action */
|
||||
if (strcmp(p->type_out, s->request_type))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p->begin)
|
||||
{
|
||||
Evry_Item *sel_item = NULL;
|
||||
|
||||
if (s && (s->cur_plugin != action_selector))
|
||||
sel_item = s->sel_item;
|
||||
|
||||
if (p->begin(sel_item))
|
||||
list = eina_list_append(list, p);
|
||||
else
|
||||
p->class->free(p);
|
||||
}
|
||||
else
|
||||
list = eina_list_append(list, p);
|
||||
}
|
||||
}
|
||||
|
||||
if (s && !s->cur_action)
|
||||
{
|
||||
if (_evry_plug_act_select_actions_set())
|
||||
{
|
||||
list = eina_list_append(list, action_selector);
|
||||
}
|
||||
}
|
||||
|
||||
if (!list) return 0;
|
||||
|
||||
list = eina_list_sort(list, eina_list_count(list), _evry_cb_plugin_sort);
|
||||
|
@ -346,7 +402,17 @@ _evry_push_state(void)
|
|||
s->plugins = list;
|
||||
s->cur_plugins = NULL;
|
||||
s->sel_item = NULL;
|
||||
s->initial = (cur_state ? 0 : 1);
|
||||
if (cur_state)
|
||||
{
|
||||
s->request_type = cur_state->request_type;
|
||||
s->cur_action = cur_state->cur_action;
|
||||
s->initial = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
s->initial = 1;
|
||||
}
|
||||
|
||||
cur_state = s;
|
||||
stack = eina_list_prepend(stack, s);
|
||||
|
||||
|
@ -367,6 +433,8 @@ _evry_pop_state(void)
|
|||
Evry_Plugin *p;
|
||||
Eina_List *l;
|
||||
|
||||
if (!stack || !stack->next) return 0;
|
||||
|
||||
_evry_list_clear();
|
||||
|
||||
EINA_LIST_FREE(s->cur_plugins, p)
|
||||
|
@ -378,7 +446,7 @@ _evry_pop_state(void)
|
|||
free(s->input);
|
||||
|
||||
EINA_LIST_FOREACH(s->plugins, l, p)
|
||||
p->class->free(p);
|
||||
p->cleanup();
|
||||
|
||||
E_FREE(s);
|
||||
|
||||
|
@ -386,42 +454,65 @@ _evry_pop_state(void)
|
|||
|
||||
if (stack)
|
||||
{
|
||||
Evry_Item *it = NULL;
|
||||
int i = 0;
|
||||
|
||||
s = stack->data;
|
||||
cur_state = s;
|
||||
|
||||
if (s->cur_plugin && s->cur_plugin == action_selector)
|
||||
{
|
||||
_evry_pop_state();
|
||||
return 0;
|
||||
}
|
||||
|
||||
edje_object_part_text_set(o_main, "e.text.label", s->input);
|
||||
|
||||
EINA_LIST_FOREACH(s->cur_plugins, l, p)
|
||||
_evry_plugin_selector_append(p);
|
||||
|
||||
_evry_show_items(s->cur_plugin);
|
||||
|
||||
if (s->sel_item)
|
||||
{
|
||||
Evry_Item *it;
|
||||
int i = 0;
|
||||
|
||||
_evry_item_sel(s->sel_item);
|
||||
|
||||
EINA_LIST_FOREACH(s->cur_plugin->items, l, it)
|
||||
if (it == s->sel_item)
|
||||
break;
|
||||
else i++;
|
||||
}
|
||||
|
||||
if (stack->next)
|
||||
{
|
||||
Evry_State *prev = stack->next->data;
|
||||
it = prev->sel_item;
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(s->plugins, l, p)
|
||||
if (p != s->cur_plugin && p->begin)
|
||||
p->begin(it);
|
||||
|
||||
_evry_matches_update();
|
||||
|
||||
it = eina_list_nth(s->cur_plugin->items, i);
|
||||
|
||||
if (it)
|
||||
{
|
||||
_evry_item_desel(s->sel_item);
|
||||
s->sel_item = it;
|
||||
_evry_item_sel(s->sel_item);
|
||||
_evry_scroll_to(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cur_state = NULL;
|
||||
evry_hide();
|
||||
}
|
||||
|
||||
/* else
|
||||
* {
|
||||
* cur_state = NULL;
|
||||
* evry_hide();
|
||||
* } */
|
||||
|
||||
ev_last_is_mouse = 0;
|
||||
item_mouseover = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* TODO config options for users preferred keys */
|
||||
static int
|
||||
_evry_cb_key_down(void *data, int type, void *event)
|
||||
{
|
||||
|
@ -437,27 +528,63 @@ _evry_cb_key_down(void *data, int type, void *event)
|
|||
_evry_item_prev();
|
||||
else if (!strcmp(ev->key, "Down"))
|
||||
_evry_item_next();
|
||||
else if (!strcmp(ev->key, "Right") &&
|
||||
((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) ||
|
||||
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)))
|
||||
{
|
||||
if (s->sel_item)
|
||||
{
|
||||
if (!_evry_push_state())
|
||||
_evry_action(0);
|
||||
}
|
||||
}
|
||||
/* _evry_plugin_next(); */
|
||||
else if (!strcmp(ev->key, "Left") &&
|
||||
((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) ||
|
||||
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)))
|
||||
_evry_pop_state();
|
||||
/* _evry_plugin_prev(); */
|
||||
else if (!strcmp(ev->key, "Right"))
|
||||
_evry_plugin_next();
|
||||
/* {
|
||||
* if (s->sel_item)
|
||||
* {
|
||||
* if (!_evry_push_state())
|
||||
* _evry_action(0);
|
||||
* }
|
||||
* } */
|
||||
else if (!strcmp(ev->key, "Left"))
|
||||
_evry_plugin_prev();
|
||||
/* _evry_pop_state(); */
|
||||
else if (!strcmp(ev->key, "Return") &&
|
||||
(ev->modifiers & ECORE_EVENT_MODIFIER_CTRL))
|
||||
_evry_action(0);
|
||||
else if (!strcmp(ev->key, "Return"))
|
||||
_evry_action(1);
|
||||
else if (!strcmp(ev->key, "Tab") &&
|
||||
((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) ||
|
||||
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)))
|
||||
_evry_plugin_prev();
|
||||
else if (!strcmp(ev->key, "Tab"))
|
||||
{
|
||||
if (s->sel_item)
|
||||
_evry_push_state();
|
||||
if (s->sel_item)
|
||||
{
|
||||
if (!_evry_push_state())
|
||||
_evry_action(0);
|
||||
}
|
||||
}
|
||||
/* _evry_plugin_next(); */
|
||||
else if (!strcmp(ev->key, "u") &&
|
||||
(ev->modifiers & ECORE_EVENT_MODIFIER_CTRL))
|
||||
_evry_clear();
|
||||
else if ((!strcmp(ev->key, "Escape")) ||
|
||||
(!strcmp(ev->key, "g") &&
|
||||
(ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)))
|
||||
_evry_pop_state();
|
||||
{
|
||||
if (!_evry_pop_state())
|
||||
evry_hide();
|
||||
}
|
||||
|
||||
else if (!strcmp(ev->key, "BackSpace"))
|
||||
_evry_backspace();
|
||||
else if (!strcmp(ev->key, "Delete"))
|
||||
|
@ -640,18 +767,43 @@ _evry_update_timer(void *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_evry_clear(void)
|
||||
{
|
||||
if (cur_state->input[0] != 0)
|
||||
{
|
||||
cur_state->input[0] = 0;
|
||||
_evry_update();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_evry_action(int finished)
|
||||
{
|
||||
Evry_State *s = cur_state;
|
||||
|
||||
if (s->cur_plugin && (s->sel_item || s->input))
|
||||
if (s->cur_plugin == action_selector)
|
||||
{
|
||||
/* set cur_action and start plugins for second parameter (if required)*/
|
||||
if (s->sel_item) _evry_plug_act_select_action(s->sel_item, s->input);
|
||||
|
||||
finished = 0;
|
||||
}
|
||||
else if (s->cur_action)
|
||||
{
|
||||
if (s->sel_item && (!strcmp(s->cur_plugin->type_out, s->request_type)))
|
||||
{
|
||||
s->cur_action->thing2 = s->sel_item;
|
||||
s->cur_action->action();
|
||||
}
|
||||
}
|
||||
else if (s->cur_plugin && (s->sel_item || s->input))
|
||||
{
|
||||
if (!s->cur_plugin->action ||
|
||||
!s->cur_plugin->action(s->cur_plugin, s->sel_item, s->input))
|
||||
!s->cur_plugin->action(s->sel_item, s->input))
|
||||
{
|
||||
_evry_push_state();
|
||||
finished = 0;
|
||||
finished = 0;
|
||||
}
|
||||
}
|
||||
else if (s->initial)
|
||||
|
@ -661,18 +813,6 @@ _evry_action(int finished)
|
|||
evry_hide();
|
||||
}
|
||||
|
||||
static void
|
||||
_evry_clear(void)
|
||||
{
|
||||
if (cur_state->input[0] != 0)
|
||||
{
|
||||
cur_state->input[0] = 0;
|
||||
_evry_update();
|
||||
if (!update_timer)
|
||||
update_timer = ecore_timer_add(MATCH_LAG, _evry_update_timer, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_evry_show_items(Evry_Plugin *p)
|
||||
{
|
||||
|
@ -682,8 +822,6 @@ _evry_show_items(Evry_Plugin *p)
|
|||
Evas_Object *o;
|
||||
Evry_State *s = cur_state;
|
||||
|
||||
_evry_list_clear();
|
||||
|
||||
if (s->cur_plugin)
|
||||
edje_object_signal_emit(s->cur_plugin->tab, "e,state,unselected", "e");
|
||||
|
||||
|
@ -691,9 +829,7 @@ _evry_show_items(Evry_Plugin *p)
|
|||
s->sel_item = NULL;
|
||||
|
||||
s->cur_plugin = p;
|
||||
|
||||
/* XXX remove this */
|
||||
if (!s->cur_plugin) return;
|
||||
s->cur_items = p->items;
|
||||
|
||||
edje_object_signal_emit(p->tab, "e,state,selected", "e");
|
||||
|
||||
|
@ -715,7 +851,7 @@ _evry_show_items(Evry_Plugin *p)
|
|||
_evry_cb_item_mouse_out, it);
|
||||
evas_object_show(o);
|
||||
|
||||
p->icon_get(p, it, popup->evas);
|
||||
p->icon_get(it, popup->evas);
|
||||
if (edje_object_part_exists(o, "e.swallow.icons") && it->o_icon)
|
||||
{
|
||||
edje_object_part_swallow(o, "e.swallow.icons", it->o_icon);
|
||||
|
@ -768,9 +904,9 @@ _evry_matches_update(void)
|
|||
EINA_LIST_FOREACH(s->plugins, l, p)
|
||||
{
|
||||
if (strlen(s->input) == 0)
|
||||
items = !p->class->need_query ? p->fetch(p, NULL) : 0;
|
||||
items = !p->need_query ? p->fetch(NULL) : 0;
|
||||
else
|
||||
items = p->fetch(p, s->input);
|
||||
items = p->fetch(s->input);
|
||||
|
||||
if (!s->initial || (items && eina_list_count(p->items) > 0))
|
||||
{
|
||||
|
@ -782,30 +918,29 @@ _evry_matches_update(void)
|
|||
if (s->cur_plugins)
|
||||
{
|
||||
if (s->cur_plugin && eina_list_data_find(s->cur_plugins, s->cur_plugin))
|
||||
{
|
||||
_evry_show_items(s->cur_plugin);
|
||||
}
|
||||
_evry_show_items(s->cur_plugin);
|
||||
else
|
||||
{
|
||||
_evry_show_items(s->cur_plugins->data);
|
||||
}
|
||||
_evry_show_items(s->cur_plugins->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
s->cur_plugin = NULL;
|
||||
s->cur_items = NULL;
|
||||
}
|
||||
else s->cur_plugin = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_evry_list_clear(void)
|
||||
{
|
||||
Evry_State *s = cur_state;
|
||||
Evry_Item *it;
|
||||
Eina_List *l;
|
||||
|
||||
if (s && s->cur_plugin)
|
||||
if (s && s->cur_items)
|
||||
{
|
||||
Evry_Item *it;
|
||||
Eina_List *l;
|
||||
|
||||
evas_event_freeze(popup->evas);
|
||||
e_box_freeze(o_list);
|
||||
EINA_LIST_FOREACH(s->cur_plugin->items, l, it)
|
||||
EINA_LIST_FOREACH(s->cur_items, l, it)
|
||||
{
|
||||
evas_object_del(it->o_bg);
|
||||
if (it->o_icon) evas_object_del(it->o_icon);
|
||||
|
@ -945,10 +1080,12 @@ _evry_plugin_next(void)
|
|||
|
||||
if (l && l->next)
|
||||
{
|
||||
_evry_list_clear();
|
||||
_evry_show_items(l->next->data);
|
||||
}
|
||||
else if (s->cur_plugin != s->cur_plugins->data)
|
||||
{
|
||||
_evry_list_clear();
|
||||
_evry_show_items(s->cur_plugins->data);
|
||||
}
|
||||
}
|
||||
|
@ -967,6 +1104,7 @@ _evry_plugin_prev(void)
|
|||
|
||||
if (l && l->prev)
|
||||
{
|
||||
_evry_list_clear();
|
||||
_evry_show_items(l->prev->data);
|
||||
}
|
||||
else
|
||||
|
@ -975,6 +1113,7 @@ _evry_plugin_prev(void)
|
|||
|
||||
if (s->cur_plugin != l->data)
|
||||
{
|
||||
_evry_list_clear();
|
||||
_evry_show_items(l->data);
|
||||
}
|
||||
}
|
||||
|
@ -1026,23 +1165,123 @@ _evry_plugin_selector_append(Evry_Plugin *p)
|
|||
e_theme_edje_object_set(o, "base/theme/widgets",
|
||||
"e/widgets/toolbar/item");
|
||||
|
||||
snprintf(buf, 64, "%s (%d)", p->class->name, eina_list_count(p->items));
|
||||
snprintf(buf, 64, "%s (%d)", p->name, eina_list_count(p->items));
|
||||
|
||||
edje_object_part_text_set(o, "e.text.label", buf);
|
||||
|
||||
edje_object_size_min_calc(o, &mw, &mh);
|
||||
e_box_freeze(o_selector);
|
||||
e_box_pack_end(o_selector, o);
|
||||
|
||||
evas_object_show(o);
|
||||
e_box_pack_options_set(o,
|
||||
1, 1, /* fill */
|
||||
0, 0, /* expand */
|
||||
0.5, 0.5, /* align */
|
||||
mw, mh, /* min */
|
||||
9999, 9999 /* max */
|
||||
);
|
||||
|
||||
e_box_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5, mw, mh, 9999, 9999);
|
||||
e_box_thaw(o_selector);
|
||||
p->tab = o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
_evry_plug_act_select_init(void)
|
||||
{
|
||||
Evry_Plugin *p = E_NEW(Evry_Plugin, 1);
|
||||
p->name = "Select Action";
|
||||
p->type_in = "ANY";
|
||||
p->type_out = "NONE";
|
||||
p->cleanup = &_evry_plug_act_select_cleanup;
|
||||
p->fetch = &_evry_plug_act_select_fetch;
|
||||
p->action = &_evry_plug_act_select_action;
|
||||
p->icon_get = &_evry_plug_act_select_item_icon_get;
|
||||
action_selector = p;
|
||||
}
|
||||
|
||||
static int
|
||||
_evry_plug_act_select_actions_set(void)
|
||||
{
|
||||
Evry_Action *act;
|
||||
Eina_List *l;
|
||||
Evry_State *s = cur_state;
|
||||
Evry_Plugin *p = action_selector;
|
||||
|
||||
_evry_plug_act_select_cleanup();
|
||||
|
||||
const char *type = s->cur_plugin->type_out;
|
||||
|
||||
EINA_LIST_FOREACH(actions, l, act)
|
||||
{
|
||||
if (strstr(act->type_in1, type))
|
||||
{
|
||||
act->thing1 = s->sel_item;
|
||||
s->cur_actions = eina_list_append(s->cur_actions, act);
|
||||
}
|
||||
}
|
||||
|
||||
if (s->cur_actions) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_evry_plug_act_select_fetch(const char *input)
|
||||
{
|
||||
Evry_Plugin *p = action_selector;
|
||||
Evry_Action *act;
|
||||
Eina_List *l;
|
||||
|
||||
EINA_LIST_FOREACH(actions, l, act)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
it = E_NEW(Evry_Item, 1);
|
||||
it->label = eina_stringshare_add(act->name);
|
||||
it->data[0] = act;
|
||||
|
||||
p->items = eina_list_append(p->items, it);
|
||||
}
|
||||
|
||||
if (p->items) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_evry_plug_act_select_action(Evry_Item *it, const char *input)
|
||||
{
|
||||
Evry_Action *act = it->data[0];
|
||||
cur_state->cur_action = act;
|
||||
|
||||
cur_state->request_type = act->type_in2;
|
||||
|
||||
return _evry_push_state();
|
||||
}
|
||||
|
||||
static void
|
||||
_evry_plug_act_select_cleanup(void)
|
||||
{
|
||||
|
||||
Evry_Item *it;
|
||||
Evry_Plugin *p = action_selector;
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
{
|
||||
eina_stringshare_del(it->label);
|
||||
E_FREE(it);
|
||||
}
|
||||
|
||||
eina_list_free(cur_state->cur_actions);
|
||||
cur_state->cur_actions = NULL;
|
||||
|
||||
p->items = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_evry_plug_act_select_item_icon_get(Evry_Item *it, Evas *e)
|
||||
{
|
||||
Evry_Action *act = it->data[0];
|
||||
|
||||
/* if (act->icon_get)
|
||||
* it->o_icon = act->icon_get(act, e); */
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef struct _Evry_Plugin Evry_Plugin;
|
||||
/* TODO find a better name - Registry ? */
|
||||
typedef struct _Evry_Plugin_Class Evry_Plugin_Class;
|
||||
typedef struct _Evry_Item Evry_Item;
|
||||
typedef struct _Evry_Action Evry_Action;
|
||||
typedef struct _Evry_Config Evry_Config;
|
||||
|
@ -35,20 +33,18 @@ struct _Evry_Item
|
|||
const char *uri;
|
||||
const char *mime;
|
||||
|
||||
/* set by icon_get plugin method */
|
||||
Evas_Object *o_icon;
|
||||
|
||||
/* used by 'everything' for display */
|
||||
Evas_Object *o_bg;
|
||||
|
||||
/* these are only for internally use by plugins */
|
||||
/* used e.g. as pointer for item data (Efreet_Desktop) or */
|
||||
/* for internal stuff, like priority hints for sorting, etc */
|
||||
void *data[4];
|
||||
int priority;
|
||||
|
||||
/* not to be set by plugin! */
|
||||
Evas_Object *o_icon;
|
||||
Evas_Object *o_bg;
|
||||
};
|
||||
|
||||
struct _Evry_Plugin_Class
|
||||
struct _Evry_Plugin
|
||||
{
|
||||
const char *name;
|
||||
|
||||
|
@ -61,46 +57,59 @@ struct _Evry_Plugin_Class
|
|||
/* sync/async ?*/
|
||||
unsigned char async_query : 1;
|
||||
|
||||
/* whether candidates can be shown without input: e.g. borders, history */
|
||||
/* if 0 fetch MUST provide all candidates when string is NULL */
|
||||
/* whether candidates can be shown without input
|
||||
* e.g. borders, app history */
|
||||
unsigned char need_query : 1;
|
||||
|
||||
Evry_Plugin *(*new) (void);
|
||||
void (*free) (Evry_Plugin *p);
|
||||
|
||||
Evas_Object *(*config_page) (void);
|
||||
void (*config_apply) (void);
|
||||
|
||||
Eina_List *instances;
|
||||
};
|
||||
|
||||
|
||||
struct _Evry_Plugin
|
||||
{
|
||||
Evry_Plugin_Class *class;
|
||||
|
||||
/* run when plugin is activated. */
|
||||
int (*begin) (Evry_Plugin *p, Evry_Item *item);
|
||||
int (*begin) (Evry_Item *item);
|
||||
|
||||
/* get candidates matching string, fills 'candidates' list */
|
||||
int (*fetch) (Evry_Plugin *p, const char *input);
|
||||
int (*fetch) (const char *input);
|
||||
|
||||
/* run action with a given candidate - TODO register actions per
|
||||
candidate type */
|
||||
int (*action) (Evry_Plugin *p, Evry_Item *item, const char *input);
|
||||
/* default action for this plugins items */
|
||||
int (*action) (Evry_Item *item, const char *input);
|
||||
|
||||
/* run before new query and when hiding 'everything' */
|
||||
void (*cleanup) (Evry_Plugin *p);
|
||||
void (*cleanup) (void);
|
||||
|
||||
void (*icon_get) (Evry_Plugin *p, Evry_Item *it, Evas *e);
|
||||
/* TODO return icon */
|
||||
void (*icon_get) (Evry_Item *it, Evas *e);
|
||||
/* provide more information for a candidate */
|
||||
/* int (*candidate_info) (Evas *evas, Evry_Item *item); */
|
||||
|
||||
Eina_List *items;
|
||||
|
||||
Evas_Object *(*config_page) (void);
|
||||
void (*config_apply) (void);
|
||||
|
||||
/* for internal use by plugin */
|
||||
Eina_List *states;
|
||||
void *priv;
|
||||
|
||||
/* not to be set by plugin! */
|
||||
Evas_Object *tab;
|
||||
};
|
||||
|
||||
struct _Evry_Action
|
||||
{
|
||||
const char *name;
|
||||
|
||||
const char *type_in1;
|
||||
const char *type_in2;
|
||||
const char *type_out;
|
||||
|
||||
Evry_Item *thing1;
|
||||
Evry_Item *thing2;
|
||||
|
||||
int (*action) (void);
|
||||
|
||||
void (*icon_get) (Evry_Plugin *p, Evry_Item *it, Evas *e);
|
||||
|
||||
void *priv;
|
||||
|
||||
/* not to be set by plugin! */
|
||||
Evas_Object *o_icon;
|
||||
};
|
||||
|
||||
struct _Evry_Config
|
||||
|
@ -123,8 +132,10 @@ EAPI int evry_shutdown(void);
|
|||
EAPI int evry_show(E_Zone *zone);
|
||||
EAPI void evry_hide(void);
|
||||
|
||||
EAPI void evry_plugin_register(Evry_Plugin_Class *pc);
|
||||
EAPI void evry_plugin_unregister(Evry_Plugin_Class *pc);
|
||||
EAPI void evry_plugin_register(Evry_Plugin *p);
|
||||
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_plugin_async_update(Evry_Plugin *plugin, int state);
|
||||
|
||||
|
|
|
@ -6,45 +6,48 @@ typedef struct _Inst Inst;
|
|||
struct _Inst
|
||||
{
|
||||
Eina_Hash *added;
|
||||
|
||||
Eina_List *apps;
|
||||
Evry_Item *candidate;
|
||||
};
|
||||
|
||||
static Evry_Plugin *_plug_new();
|
||||
static Evry_Plugin *_plug_new2();
|
||||
static void _plug_free(Evry_Plugin *p);
|
||||
static int _begin(Evry_Plugin *p, Evry_Item *item);
|
||||
static int _fetch(Evry_Plugin *p, const char *input);
|
||||
static int _action(Evry_Plugin *p, Evry_Item *item, const char *input);
|
||||
static void _cleanup(Evry_Plugin *p);
|
||||
static void _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio);
|
||||
static int _begin(Evry_Item *item);
|
||||
static int _fetch(const char *input);
|
||||
static int _action(Evry_Item *item, const char *input);
|
||||
static void _cleanup(void);
|
||||
static void _item_add(Efreet_Desktop *desktop, char *file, int prio);
|
||||
static int _cb_sort(const void *data1, const void *data2);
|
||||
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
|
||||
static void _item_icon_get(Evry_Item *it, Evas *e);
|
||||
static int _exec_action(void);
|
||||
|
||||
static Evry_Plugin *p;
|
||||
static Evry_Action *act;
|
||||
static Inst *inst;
|
||||
|
||||
|
||||
static Evry_Plugin_Class class;
|
||||
static Evry_Plugin_Class class2;
|
||||
|
||||
EAPI int
|
||||
evry_plug_apps_init(void)
|
||||
{
|
||||
class.name = "Applications";
|
||||
class.type_in = "NONE";
|
||||
class.type_out = "APPLICATION";
|
||||
class.need_query = 0;
|
||||
class.new = &_plug_new;
|
||||
class.free = &_plug_free;
|
||||
class.prio = 1;
|
||||
evry_plugin_register(&class);
|
||||
p = E_NEW(Evry_Plugin, 1);
|
||||
p->type_in = "NONE|FILE";
|
||||
p->type_out = "NONE";
|
||||
p->need_query = 0;
|
||||
p->begin = &_begin;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
evry_plugin_register(p);
|
||||
|
||||
class2.name = "Open With..";
|
||||
class2.type_in = "FILE";
|
||||
class2.type_out = "APPLICATION";
|
||||
class2.need_query = 0;
|
||||
class2.new = &_plug_new2;
|
||||
class2.free = &_plug_free;
|
||||
class2.prio = 3;
|
||||
evry_plugin_register(&class2);
|
||||
act = E_NEW(Evry_Action, 1);
|
||||
act->name = "Open File...";
|
||||
act->type_in1 = "APPLICATION";
|
||||
act->type_in2 = "FILE";
|
||||
act->type_out = "NONE";
|
||||
act->action =_exec_action;
|
||||
evry_action_register(act);
|
||||
|
||||
inst = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -52,107 +55,61 @@ evry_plug_apps_init(void)
|
|||
EAPI int
|
||||
evry_plug_apps_shutdown(void)
|
||||
{
|
||||
evry_plugin_unregister(&class);
|
||||
evry_plugin_unregister(&class2);
|
||||
evry_plugin_unregister(p);
|
||||
evry_action_unregister(act);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evry_Plugin *
|
||||
_plug_new()
|
||||
{
|
||||
Evry_Plugin *p = E_NEW(Evry_Plugin, 1);
|
||||
p->class = &class;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
p->items = NULL;
|
||||
|
||||
Inst *inst = E_NEW(Inst, 1);
|
||||
inst->added = NULL;
|
||||
p->priv = inst;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static Evry_Plugin *
|
||||
_plug_new2()
|
||||
{
|
||||
Evry_Plugin *p = E_NEW(Evry_Plugin, 1);
|
||||
p->class = &class2;
|
||||
p->begin = &_begin;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
p->items = NULL;
|
||||
|
||||
Inst *inst = E_NEW(Inst, 1);
|
||||
inst->added = NULL;
|
||||
p->priv = inst;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static void
|
||||
_plug_free(Evry_Plugin *p)
|
||||
{
|
||||
Inst *inst = p->priv;
|
||||
|
||||
_cleanup(p);
|
||||
if (inst->apps) eina_list_free(inst->apps);
|
||||
|
||||
E_FREE(inst);
|
||||
E_FREE(p);
|
||||
}
|
||||
|
||||
static int
|
||||
_begin(Evry_Plugin *p, Evry_Item *it)
|
||||
_begin(Evry_Item *it)
|
||||
{
|
||||
Inst *inst;
|
||||
const char *mime;
|
||||
|
||||
_cleanup(p);
|
||||
if (inst) return 0;
|
||||
|
||||
if (!it || !it->uri) return 0;
|
||||
inst = p->priv;
|
||||
inst->candidate = it;
|
||||
if (it)
|
||||
{
|
||||
p->name = "Open With...";
|
||||
p->type_out = "NONE";
|
||||
p->prio = 3;
|
||||
|
||||
if (!it->mime)
|
||||
mime = efreet_mime_type_get(it->uri);
|
||||
if (!it->uri) return 0;
|
||||
|
||||
if (!it->mime)
|
||||
mime = efreet_mime_type_get(it->uri);
|
||||
else
|
||||
mime = it->mime;
|
||||
|
||||
if (!mime) return 0;
|
||||
|
||||
inst = E_NEW(Inst, 1);
|
||||
inst->candidate = it;
|
||||
inst->apps = efreet_util_desktop_mime_list(mime);
|
||||
}
|
||||
else
|
||||
mime = it->mime;
|
||||
{
|
||||
p->name = "Applications";
|
||||
p->type_out = "APPLICATION";
|
||||
p->prio = 1;
|
||||
|
||||
if (!mime) return 0;
|
||||
|
||||
/* if (!strcmp(mime, "Folder"))
|
||||
* {
|
||||
* apps =
|
||||
* }
|
||||
* else */
|
||||
|
||||
inst->apps = efreet_util_desktop_mime_list(mime);
|
||||
inst = E_NEW(Inst, 1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_action(Evry_Plugin *p, Evry_Item *it, const char *input)
|
||||
_action(Evry_Item *it, const char *input)
|
||||
{
|
||||
E_Zone *zone;
|
||||
Evry_App *app = NULL;
|
||||
Efreet_Desktop *desktop = NULL;
|
||||
Eina_List *files = NULL;
|
||||
Inst *inst = p->priv;
|
||||
int ret = 0;
|
||||
|
||||
if (it) app = it->data[0];
|
||||
|
||||
if (inst->candidate)
|
||||
files = eina_list_append(files, inst->candidate->uri);
|
||||
|
||||
if (app && app->desktop)
|
||||
{
|
||||
desktop = app->desktop;
|
||||
|
@ -178,22 +135,26 @@ _action(Evry_Plugin *p, Evry_Item *it, const char *input)
|
|||
|
||||
if (desktop)
|
||||
{
|
||||
if (inst->candidate)
|
||||
files = eina_list_append(files, inst->candidate->uri);
|
||||
|
||||
zone = e_util_zone_current_get(e_manager_current_get());
|
||||
e_exec(zone, desktop, NULL, files, NULL /*"everything"*/);
|
||||
|
||||
if (!it)
|
||||
efreet_desktop_free(desktop);
|
||||
|
||||
ret = 1;
|
||||
eina_list_free(files);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
eina_list_free(files);
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_cleanup(Evry_Plugin *p)
|
||||
_list_free(void)
|
||||
{
|
||||
Evry_Item *it;
|
||||
Evry_App *app;
|
||||
|
@ -201,15 +162,29 @@ _cleanup(Evry_Plugin *p)
|
|||
EINA_LIST_FREE(p->items, it)
|
||||
{
|
||||
if (it->label) eina_stringshare_del(it->label);
|
||||
if (it->o_icon) evas_object_del(it->o_icon);
|
||||
app = it->data[0];
|
||||
free(app);
|
||||
free(it);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cleanup(void)
|
||||
{
|
||||
_list_free();
|
||||
|
||||
if (inst)
|
||||
{
|
||||
eina_list_free(inst->apps);
|
||||
E_FREE(inst);
|
||||
}
|
||||
|
||||
inst = NULL;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_fetch(Evry_Plugin *p, const char *input)
|
||||
_fetch(const char *input)
|
||||
{
|
||||
Eina_List *l;
|
||||
Efreet_Desktop *desktop;
|
||||
|
@ -217,16 +192,14 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
char match1[4096];
|
||||
char match2[4096];
|
||||
|
||||
Inst *inst = p->priv;
|
||||
|
||||
_cleanup(p);
|
||||
_list_free();
|
||||
|
||||
if (inst->apps)
|
||||
{
|
||||
if (!input)
|
||||
{
|
||||
EINA_LIST_FOREACH(inst->apps, l, desktop)
|
||||
_item_add(p, desktop, NULL, 1);
|
||||
_item_add(desktop, NULL, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -235,19 +208,20 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
|
||||
EINA_LIST_FOREACH(inst->apps, l, desktop)
|
||||
{
|
||||
if (desktop->name)
|
||||
if (e_util_glob_case_match(desktop->exec, match1))
|
||||
_item_add(desktop, NULL, 1);
|
||||
else if (e_util_glob_case_match(desktop->exec, match2))
|
||||
_item_add(desktop, NULL, 2);
|
||||
else if (e_util_glob_case_match(desktop->name, match1))
|
||||
_item_add(desktop, NULL, 1);
|
||||
else if (e_util_glob_case_match(desktop->name, match2))
|
||||
_item_add(desktop, NULL, 2);
|
||||
else if (desktop->comment)
|
||||
{
|
||||
if (e_util_glob_case_match(desktop->name, match1))
|
||||
_item_add(p, desktop, NULL, 1);
|
||||
else if (e_util_glob_case_match(desktop->name, match2))
|
||||
_item_add(p, desktop, NULL, 2);
|
||||
else if (desktop->comment)
|
||||
{
|
||||
if (e_util_glob_case_match(desktop->comment, match1))
|
||||
_item_add(p, desktop, NULL, 3);
|
||||
else if (e_util_glob_case_match(desktop->comment, match2))
|
||||
_item_add(p, desktop, NULL, 4);
|
||||
}
|
||||
if (e_util_glob_case_match(desktop->comment, match1))
|
||||
_item_add(desktop, NULL, 3);
|
||||
else if (e_util_glob_case_match(desktop->comment, match2))
|
||||
_item_add(desktop, NULL, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,28 +233,28 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
snprintf(match1, sizeof(match1), "%s*", input);
|
||||
l = efreet_util_desktop_exec_glob_list(match1);
|
||||
EINA_LIST_FREE(l, desktop)
|
||||
_item_add(p, desktop, NULL, 1);
|
||||
_item_add(desktop, NULL, 1);
|
||||
|
||||
snprintf(match1, sizeof(match1), "*%s*", input);
|
||||
l = efreet_util_desktop_name_glob_list(match1);
|
||||
EINA_LIST_FREE(l, desktop)
|
||||
_item_add(p, desktop, NULL, 2);
|
||||
_item_add(desktop, NULL, 2);
|
||||
|
||||
// TODO make these optional/configurable
|
||||
l = efreet_util_desktop_generic_name_glob_list(match1);
|
||||
EINA_LIST_FREE(l, desktop)
|
||||
_item_add(p, desktop, NULL, 3);
|
||||
_item_add(desktop, NULL, 3);
|
||||
|
||||
l = efreet_util_desktop_comment_glob_list(match1);
|
||||
EINA_LIST_FREE(l, desktop)
|
||||
_item_add(p, desktop, NULL, 3);
|
||||
_item_add(desktop, NULL, 3);
|
||||
}
|
||||
else if (!p->items)
|
||||
{
|
||||
// TODO option for popular/recent
|
||||
l = e_exehist_list_get();
|
||||
EINA_LIST_FREE(l, file)
|
||||
_item_add(p, NULL, file, 1);
|
||||
_item_add(NULL, file, 1);
|
||||
}
|
||||
|
||||
if (inst->added)
|
||||
|
@ -292,9 +266,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
if (p->items)
|
||||
{
|
||||
if (input)
|
||||
p->items = eina_list_sort(p->items,
|
||||
eina_list_count(p->items),
|
||||
_cb_sort);
|
||||
p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -302,15 +274,26 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
}
|
||||
|
||||
static void
|
||||
_item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio)
|
||||
_item_add(Efreet_Desktop *desktop, char *file, int prio)
|
||||
{
|
||||
Evry_Item *it;
|
||||
Evry_App *app;
|
||||
Inst *inst = p->priv;
|
||||
Efreet_Desktop *desktop2;
|
||||
|
||||
if (desktop)
|
||||
file = desktop->exec;
|
||||
{
|
||||
Eina_List *l;
|
||||
char *cat;
|
||||
|
||||
/* ignore screensaver.. */
|
||||
EINA_LIST_FOREACH(desktop->categories, l, cat)
|
||||
{
|
||||
if (cat && !strcmp(cat, "Screensaver"))
|
||||
return;
|
||||
}
|
||||
|
||||
file = desktop->exec;
|
||||
}
|
||||
|
||||
if (!file) return;
|
||||
|
||||
|
@ -376,7 +359,7 @@ _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio)
|
|||
}
|
||||
|
||||
static void
|
||||
_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e)
|
||||
_item_icon_get(Evry_Item *it, Evas *e)
|
||||
{
|
||||
Evry_App *app = it->data[0];
|
||||
|
||||
|
@ -416,3 +399,22 @@ _cb_sort(const void *data1, const void *data2)
|
|||
else return 0;
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
_exec_action(void)
|
||||
{
|
||||
if (act->thing1 && act->thing2)
|
||||
{
|
||||
inst = E_NEW(Inst, 1);
|
||||
inst->candidate = act->thing2;
|
||||
|
||||
_action(act->thing1, NULL);
|
||||
|
||||
E_FREE(inst);
|
||||
inst = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -8,48 +8,29 @@ struct _Inst
|
|||
E_Border *border;
|
||||
};
|
||||
|
||||
static Evry_Plugin * _src_border_new(void);
|
||||
static void _src_border_free(Evry_Plugin *p);
|
||||
static int _src_border_fetch(Evry_Plugin *p, const char *input);
|
||||
static int _src_border_action(Evry_Plugin *p, Evry_Item *item, const char *input);
|
||||
static void _src_border_cleanup(Evry_Plugin *p);
|
||||
static void _src_border_item_add(Evry_Plugin *p, E_Border *bd, int prio);
|
||||
static int _src_border_cb_sort(const void *data1, const void *data2);
|
||||
static void _src_border_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
|
||||
|
||||
static Evry_Plugin * _act_border_new(void);
|
||||
static void _act_border_free(Evry_Plugin *p);
|
||||
static int _act_border_begin(Evry_Plugin *p, Evry_Item *item);
|
||||
static int _act_border_fetch(Evry_Plugin *p, const char *input);
|
||||
static int _act_border_action(Evry_Plugin *p, Evry_Item *item, const char *input);
|
||||
static void _act_border_cleanup(Evry_Plugin *p);
|
||||
static void _act_border_item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon);
|
||||
static void _act_border_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
|
||||
|
||||
static Evry_Plugin_Class source;
|
||||
static Evry_Plugin_Class action;
|
||||
static int _fetch(const char *input);
|
||||
static int _action(Evry_Item *item, const char *input);
|
||||
static void _cleanup(void);
|
||||
static void _item_add(E_Border *bd, int prio);
|
||||
static int _cb_sort(const void *data1, const void *data2);
|
||||
static void _item_icon_get(Evry_Item *it, Evas *e);
|
||||
|
||||
static Evry_Plugin *p;
|
||||
|
||||
EAPI int
|
||||
evry_plug_border_init(void)
|
||||
{
|
||||
source.name = "Windows";
|
||||
source.type_in = "NONE";
|
||||
source.type_out = "BORDER";
|
||||
source.need_query = 0;
|
||||
source.prio = 0;
|
||||
source.new = &_src_border_new;
|
||||
source.free = &_src_border_free;
|
||||
evry_plugin_register(&source);
|
||||
|
||||
action.name = "Window Action";
|
||||
action.type_in = "BORDER";
|
||||
action.type_out = "NONE";
|
||||
action.need_query = 0;
|
||||
action.prio = 0;
|
||||
action.new = &_act_border_new;
|
||||
action.free = &_act_border_free;
|
||||
evry_plugin_register(&action);
|
||||
p = E_NEW(Evry_Plugin, 1);
|
||||
p->name = "Windows";
|
||||
p->type_in = "NONE";
|
||||
p->type_out = "BORDER";
|
||||
p->need_query = 0;
|
||||
p->prio = 0;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
evry_plugin_register(p);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -57,38 +38,14 @@ evry_plug_border_init(void)
|
|||
EAPI int
|
||||
evry_plug_border_shutdown(void)
|
||||
{
|
||||
evry_plugin_unregister(&source);
|
||||
evry_plugin_unregister(&action);
|
||||
evry_plugin_unregister(p);
|
||||
E_FREE(p);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evry_Plugin *
|
||||
_src_border_new()
|
||||
{
|
||||
Evry_Plugin *p;
|
||||
|
||||
p = E_NEW(Evry_Plugin, 1);
|
||||
p->class = &source;
|
||||
p->fetch = &_src_border_fetch;
|
||||
p->action = &_src_border_action;
|
||||
p->cleanup = &_src_border_cleanup;
|
||||
p->icon_get = &_src_border_item_icon_get;
|
||||
p->items = NULL;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static void
|
||||
_src_border_free(Evry_Plugin *p)
|
||||
{
|
||||
_src_border_cleanup(p);
|
||||
E_FREE(p);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_src_border_action(Evry_Plugin *p, Evry_Item *it, const char *input)
|
||||
_action(Evry_Item *it, const char *input)
|
||||
{
|
||||
E_Border *bd;
|
||||
E_Zone *zone;
|
||||
|
@ -116,7 +73,7 @@ _src_border_action(Evry_Plugin *p, Evry_Item *it, const char *input)
|
|||
}
|
||||
|
||||
static void
|
||||
_src_border_cleanup(Evry_Plugin *p)
|
||||
_cleanup()
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
|
@ -124,13 +81,12 @@ _src_border_cleanup(Evry_Plugin *p)
|
|||
{
|
||||
/* if (it->data[0]) e_object_unref(E_OBJECT(it->data[0])); */
|
||||
if (it->label) eina_stringshare_del(it->label);
|
||||
if (it->o_icon) evas_object_del(it->o_icon);
|
||||
free(it);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_src_border_fetch(Evry_Plugin *p, const char *input)
|
||||
_fetch(const char *input)
|
||||
{
|
||||
E_Manager *man;
|
||||
E_Zone *zone;
|
||||
|
@ -141,7 +97,7 @@ _src_border_fetch(Evry_Plugin *p, const char *input)
|
|||
E_Border *bd;
|
||||
E_Border_List *bl;
|
||||
|
||||
_src_border_cleanup(p);
|
||||
_cleanup();
|
||||
|
||||
man = e_manager_current_get();
|
||||
zone = e_util_zone_current_get(man);
|
||||
|
@ -158,25 +114,24 @@ _src_border_fetch(Evry_Plugin *p, const char *input)
|
|||
if (zone == bd->zone)
|
||||
{
|
||||
if (!input)
|
||||
_src_border_item_add(p, bd, 1);
|
||||
_item_add(bd, 1);
|
||||
else if (bd->client.icccm.name &&
|
||||
e_util_glob_case_match(bd->client.icccm.name, match1))
|
||||
_src_border_item_add(p, bd, 1);
|
||||
_item_add(bd, 1);
|
||||
else if (e_util_glob_case_match(e_border_name_get(bd), match1))
|
||||
_src_border_item_add(p, bd, 1);
|
||||
_item_add(bd, 1);
|
||||
else if (bd->client.icccm.name &&
|
||||
e_util_glob_case_match(bd->client.icccm.name, match2))
|
||||
_src_border_item_add(p, bd, 2);
|
||||
_item_add(bd, 2);
|
||||
else if (e_util_glob_case_match(e_border_name_get(bd), match2))
|
||||
_src_border_item_add(p, bd, 2);
|
||||
_item_add(bd, 2);
|
||||
}
|
||||
}
|
||||
e_container_border_list_free(bl);
|
||||
|
||||
if (eina_list_count(p->items) > 0)
|
||||
{
|
||||
p->items = eina_list_sort(p->items, eina_list_count(p->items),
|
||||
_src_border_cb_sort);
|
||||
p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -184,13 +139,13 @@ _src_border_fetch(Evry_Plugin *p, const char *input)
|
|||
}
|
||||
|
||||
static void
|
||||
_src_border_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e)
|
||||
_item_icon_get(Evry_Item *it, Evas *e)
|
||||
{
|
||||
it->o_icon = e_border_icon_add(((E_Border *)it->data[0]), e);
|
||||
}
|
||||
|
||||
static void
|
||||
_src_border_item_add(Evry_Plugin *p, E_Border *bd, int prio)
|
||||
_item_add(E_Border *bd, int prio)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
|
@ -205,7 +160,7 @@ _src_border_item_add(Evry_Plugin *p, E_Border *bd, int prio)
|
|||
|
||||
/* TODO sort by focus history and name? */
|
||||
static int
|
||||
_src_border_cb_sort(const void *data1, const void *data2)
|
||||
_cb_sort(const void *data1, const void *data2)
|
||||
{
|
||||
const Evry_Item *it1, *it2;
|
||||
|
||||
|
@ -215,121 +170,3 @@ _src_border_cb_sort(const void *data1, const void *data2)
|
|||
return (it1->priority - it2->priority);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Evry_Plugin *
|
||||
_act_border_new()
|
||||
{
|
||||
Evry_Plugin *p;
|
||||
Inst *inst;
|
||||
|
||||
p = E_NEW(Evry_Plugin, 1);
|
||||
p->class = &source;
|
||||
p->begin = &_act_border_begin;
|
||||
p->fetch = &_act_border_fetch;
|
||||
p->action = &_act_border_action;
|
||||
p->cleanup = &_act_border_cleanup;
|
||||
p->icon_get = &_act_border_item_icon_get;
|
||||
p->items = NULL;
|
||||
|
||||
inst = E_NEW(Inst, 1);
|
||||
p->priv = inst;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static void
|
||||
_act_border_free(Evry_Plugin *p)
|
||||
{
|
||||
Inst *inst = p->priv;
|
||||
|
||||
/* if (inst->border) e_object_unref(E_OBJECT(inst->border)); */
|
||||
|
||||
_act_border_cleanup(p);
|
||||
|
||||
E_FREE(p);
|
||||
E_FREE(inst);
|
||||
}
|
||||
|
||||
static void
|
||||
_act_cb_border_close(E_Border *bd)
|
||||
{
|
||||
if (!bd->lock_close) e_border_act_close_begin(bd);
|
||||
}
|
||||
|
||||
static void
|
||||
_act_cb_border_minimize(E_Border *bd)
|
||||
{
|
||||
if (!bd->lock_user_iconify) e_border_iconify(bd);
|
||||
}
|
||||
|
||||
static int
|
||||
_act_border_begin(Evry_Plugin *p, Evry_Item *item)
|
||||
{
|
||||
Inst *inst = p->priv;
|
||||
E_Border *bd;
|
||||
|
||||
bd = item->data[0];
|
||||
/* e_object_ref(E_OBJECT(bd)); */
|
||||
inst->border = bd;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_act_border_fetch(Evry_Plugin *p, const char *input)
|
||||
{
|
||||
_act_border_cleanup(p);
|
||||
|
||||
_act_border_item_add(p, _("Iconify"), _act_cb_border_minimize,
|
||||
"e/widgets/border/default/minimize");
|
||||
|
||||
_act_border_item_add(p, _("Close"), _act_cb_border_close,
|
||||
"e/widgets/border/default/close");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_act_border_action(Evry_Plugin *p, Evry_Item *item, const char *input)
|
||||
{
|
||||
Inst *inst = p->priv;
|
||||
|
||||
void (*border_action) (E_Border *bd);
|
||||
border_action = item->data[0];
|
||||
border_action(inst->border);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_act_border_cleanup(Evry_Plugin *p)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
{
|
||||
if (it->data[1]) eina_stringshare_del(it->data[1]);
|
||||
if (it->label) eina_stringshare_del(it->label);
|
||||
if (it->o_icon) evas_object_del(it->o_icon);
|
||||
free(it);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_act_border_item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
it = calloc(1, sizeof(Evry_Item));
|
||||
it->data[0] = action_cb;
|
||||
it->data[1] = (void *) eina_stringshare_add(icon);
|
||||
it->label = eina_stringshare_add(label);
|
||||
p->items = eina_list_append(p->items, it);
|
||||
}
|
||||
|
||||
static void
|
||||
_act_border_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e)
|
||||
{
|
||||
it->o_icon = edje_object_add(e);
|
||||
e_theme_edje_object_set(it->o_icon, "base/theme/borders", (const char *)it->data[1]);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
typedef struct _Inst Inst;
|
||||
|
||||
struct _Inst
|
||||
{
|
||||
E_Border *border;
|
||||
};
|
||||
|
||||
static int _begin(Evry_Item *item);
|
||||
static int _fetch(const char *input);
|
||||
static int _action(Evry_Item *item, const char *input);
|
||||
static void _cleanup(void);
|
||||
static void _item_icon_get(Evry_Item *it, Evas *e);
|
||||
static void _item_add(const char *label, void (*action_cb) (E_Border *bd), const char *icon);
|
||||
|
||||
|
||||
static Evry_Plugin *p;
|
||||
static Inst *inst;
|
||||
|
||||
EAPI int
|
||||
evry_plug_border_act_init(void)
|
||||
{
|
||||
p = E_NEW(Evry_Plugin, 1);
|
||||
p->name = "Window Action";
|
||||
p->type_in = "BORDER";
|
||||
p->type_out = "NONE";
|
||||
p->need_query = 0;
|
||||
p->prio = 0;
|
||||
p->begin = &_begin;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
|
||||
evry_plugin_register(p);
|
||||
|
||||
inst = E_NEW(Inst, 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
evry_plug_border_act_shutdown(void)
|
||||
{
|
||||
evry_plugin_unregister(p);
|
||||
E_FREE(p);
|
||||
E_FREE(inst);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_act_cb_border_close(E_Border *bd)
|
||||
{
|
||||
if (!bd->lock_close) e_border_act_close_begin(bd);
|
||||
}
|
||||
|
||||
static void
|
||||
_act_cb_border_minimize(E_Border *bd)
|
||||
{
|
||||
if (!bd->lock_user_iconify) e_border_iconify(bd);
|
||||
}
|
||||
|
||||
static int
|
||||
_begin(Evry_Item *item)
|
||||
{
|
||||
E_Border *bd;
|
||||
|
||||
bd = item->data[0];
|
||||
/* e_object_ref(E_OBJECT(bd)); */
|
||||
inst->border = bd;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_fetch(const char *input)
|
||||
{
|
||||
_cleanup();
|
||||
|
||||
_item_add(_("Iconify"), _act_cb_border_minimize,
|
||||
"e/widgets/border/default/minimize");
|
||||
|
||||
_item_add(_("Close"), _act_cb_border_close,
|
||||
"e/widgets/border/default/close");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_action(Evry_Item *item, const char *input)
|
||||
{
|
||||
void (*border_action) (E_Border *bd);
|
||||
border_action = item->data[0];
|
||||
border_action(inst->border);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_cleanup(void)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
{
|
||||
if (it->data[1]) eina_stringshare_del(it->data[1]);
|
||||
if (it->label) eina_stringshare_del(it->label);
|
||||
free(it);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_item_add(const char *label, void (*action_cb) (E_Border *bd), const char *icon)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
it = calloc(1, sizeof(Evry_Item));
|
||||
it->data[0] = action_cb;
|
||||
it->data[1] = (void *) eina_stringshare_add(icon);
|
||||
it->label = eina_stringshare_add(label);
|
||||
p->items = eina_list_append(p->items, it);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_icon_get(Evry_Item *it, Evas *e)
|
||||
{
|
||||
it->o_icon = edje_object_add(e);
|
||||
e_theme_edje_object_set(it->o_icon, "base/theme/borders", (const char *)it->data[1]);
|
||||
}
|
||||
|
|
@ -1,59 +1,43 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
static Evry_Plugin_Class class;
|
||||
static Evry_Plugin *_plug_new();
|
||||
static void _plug_free(Evry_Plugin *p);
|
||||
static int _fetch(Evry_Plugin *p, const char *input);
|
||||
static int _action(Evry_Plugin *p, Evry_Item *item, const char *input);
|
||||
static void _cleanup(Evry_Plugin *p);
|
||||
static void _item_add(Evry_Plugin *p, E_Configure_It *eci, int prio);
|
||||
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
|
||||
static int _fetch(const char *input);
|
||||
static int _action(Evry_Item *item, const char *input);
|
||||
static void _cleanup(void);
|
||||
static void _item_add(E_Configure_It *eci, int prio);
|
||||
static void _item_icon_get(Evry_Item *it, Evas *e);
|
||||
static int _cb_sort(const void *data1, const void *data2);
|
||||
|
||||
static Evry_Plugin *p;
|
||||
|
||||
EAPI int
|
||||
evry_plug_config_init(void)
|
||||
{
|
||||
class.name = "Settings";
|
||||
class.type_in = "NONE";
|
||||
class.type_out = "NONE";
|
||||
class.instances = NULL;
|
||||
class.new = &_plug_new;
|
||||
class.free = &_plug_free;
|
||||
evry_plugin_register(&class);
|
||||
p = E_NEW(Evry_Plugin, 1);
|
||||
p->name = "Settings";
|
||||
p->type_in = "NONE";
|
||||
p->type_out = "NONE";
|
||||
p->prio = 4;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
|
||||
evry_plugin_register(p);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
evry_plug_config_shutdown(void)
|
||||
{
|
||||
evry_plugin_unregister(&class);
|
||||
evry_plugin_unregister(p);
|
||||
E_FREE(p);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evry_Plugin *
|
||||
_plug_new()
|
||||
{
|
||||
Evry_Plugin *p = E_NEW(Evry_Plugin, 1);
|
||||
p->class = &class;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
p->items = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_plug_free(Evry_Plugin *p)
|
||||
{
|
||||
_cleanup(p);
|
||||
E_FREE(p);
|
||||
}
|
||||
|
||||
static int
|
||||
_action(Evry_Plugin *p, Evry_Item *it, const char *input)
|
||||
_action(Evry_Item *it, const char *input)
|
||||
{
|
||||
E_Configure_It *eci, *eci2;
|
||||
E_Container *con;
|
||||
|
@ -90,20 +74,19 @@ _action(Evry_Plugin *p, Evry_Item *it, const char *input)
|
|||
}
|
||||
|
||||
static void
|
||||
_cleanup(Evry_Plugin *p)
|
||||
_cleanup(void)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
EINA_LIST_FREE(p->items, it)
|
||||
{
|
||||
if (it->label) eina_stringshare_del(it->label);
|
||||
if (it->o_icon) evas_object_del(it->o_icon);
|
||||
free(it);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_fetch(Evry_Plugin *p, const char *input)
|
||||
_fetch(const char *input)
|
||||
{
|
||||
E_Manager *man;
|
||||
E_Zone *zone;
|
||||
|
@ -114,7 +97,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
E_Configure_Cat *ecat;
|
||||
E_Configure_It *eci;
|
||||
|
||||
_cleanup(p);
|
||||
_cleanup();
|
||||
|
||||
snprintf(match1, sizeof(match1), "%s*", input);
|
||||
snprintf(match2, sizeof(match2), "*%s*", input);
|
||||
|
@ -130,13 +113,13 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
if (eci->pri >= 0)
|
||||
{
|
||||
if (e_util_glob_case_match(eci->label, match1))
|
||||
_item_add(p, eci, 1);
|
||||
_item_add(eci, 1);
|
||||
else if (e_util_glob_case_match(eci->label, match2))
|
||||
_item_add(p, eci, 2);
|
||||
_item_add(eci, 2);
|
||||
else if (e_util_glob_case_match(ecat->label, match1))
|
||||
_item_add(p, eci, 3);
|
||||
_item_add(eci, 3);
|
||||
else if (e_util_glob_case_match(ecat->label, match2))
|
||||
_item_add(p, eci, 4);
|
||||
_item_add(eci, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,9 +127,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 = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -154,7 +135,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
}
|
||||
|
||||
static void
|
||||
_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e)
|
||||
_item_icon_get(Evry_Item *it, Evas *e)
|
||||
{
|
||||
E_Configure_It *eci = it->data[0];
|
||||
Evas_Object *o = NULL;
|
||||
|
@ -173,7 +154,7 @@ _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e)
|
|||
}
|
||||
|
||||
static void
|
||||
_item_add(Evry_Plugin *p, E_Configure_It *eci, int prio)
|
||||
_item_add(E_Configure_It *eci, int prio)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
|
@ -186,8 +167,6 @@ _item_add(Evry_Plugin *p, E_Configure_It *eci, int prio)
|
|||
p->items = eina_list_append(p->items, it);
|
||||
}
|
||||
|
||||
|
||||
// TODO sort name?
|
||||
static int
|
||||
_cb_sort(const void *data1, const void *data2)
|
||||
{
|
||||
|
@ -196,5 +175,7 @@ _cb_sort(const void *data1, const void *data2)
|
|||
it1 = data1;
|
||||
it2 = data2;
|
||||
|
||||
/* TODO sort by name? */
|
||||
|
||||
return (it1->priority - it2->priority);
|
||||
}
|
||||
|
|
|
@ -1,36 +1,40 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
typedef struct _Inst Inst;
|
||||
typedef struct _State State;
|
||||
|
||||
struct _Inst
|
||||
struct _State
|
||||
{
|
||||
const char *directory;
|
||||
Eina_List *items;
|
||||
};
|
||||
|
||||
static Evry_Plugin *_plug_new();
|
||||
static void _plug_free(Evry_Plugin *p);
|
||||
static int _begin(Evry_Plugin *p, Evry_Item *item);
|
||||
static int _fetch(Evry_Plugin *p, const char *input);
|
||||
static int _action(Evry_Plugin *p, Evry_Item *item, const char *input);
|
||||
static void _cleanup(Evry_Plugin *p);
|
||||
static int _begin(Evry_Item *it);
|
||||
static int _fetch(const char *input);
|
||||
static int _action(Evry_Item *it, const char *input);
|
||||
static void _cleanup(void);
|
||||
static int _cb_sort(const void *data1, const void *data2);
|
||||
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
|
||||
static void _list_free(Evry_Plugin *p);
|
||||
static void _item_icon_get(Evry_Item *it, Evas *e);
|
||||
static void _list_free(void);
|
||||
static Evry_Item *_item_fill(const char *directory, const char *file);
|
||||
|
||||
static Evry_Plugin_Class class;
|
||||
static Evry_Plugin *p;
|
||||
|
||||
EAPI int
|
||||
evry_plug_dir_browse_init(void)
|
||||
{
|
||||
class.name = "Browse Files";
|
||||
class.type_in = "NONE|FILE";
|
||||
class.type_out = "FILE";
|
||||
class.prio = 2;
|
||||
class.new = &_plug_new;
|
||||
class.free = &_plug_free;
|
||||
evry_plugin_register(&class);
|
||||
p = E_NEW(Evry_Plugin, 1);
|
||||
p->name = "Browse Files";
|
||||
p->type_in = "NONE|FILE";
|
||||
p->type_out = "FILE";
|
||||
p->prio = 2;
|
||||
p->begin = &_begin;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
|
||||
evry_plugin_register(p);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -38,50 +42,45 @@ evry_plug_dir_browse_init(void)
|
|||
EAPI int
|
||||
evry_plug_dir_browse_shutdown(void)
|
||||
{
|
||||
evry_plugin_unregister(&class);
|
||||
evry_plugin_unregister(p);
|
||||
E_FREE(p);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evry_Plugin *
|
||||
_plug_new()
|
||||
static int
|
||||
_begin(Evry_Item *it)
|
||||
{
|
||||
Evry_Plugin *p = E_NEW(Evry_Plugin, 1);
|
||||
p->class = &class;
|
||||
p->begin = &_begin;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
State *s;
|
||||
|
||||
if (it)
|
||||
{
|
||||
if (!it->uri || !ecore_file_is_dir(it->uri))
|
||||
return 0;
|
||||
|
||||
s = E_NEW(State, 1);
|
||||
s->directory = eina_stringshare_add(it->uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
s = E_NEW(State, 1);
|
||||
s->directory = eina_stringshare_add(e_user_homedir_get());
|
||||
}
|
||||
|
||||
p->states = eina_list_prepend(p->states, s);
|
||||
p->items = NULL;
|
||||
|
||||
Inst *inst = E_NEW(Inst, 1);
|
||||
inst->directory = eina_stringshare_add(e_user_homedir_get());
|
||||
p->priv = inst;
|
||||
|
||||
return p;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_plug_free(Evry_Plugin *p)
|
||||
{
|
||||
_cleanup(p);
|
||||
|
||||
Inst *inst = p->priv;
|
||||
eina_stringshare_del(inst->directory);
|
||||
E_FREE(inst);
|
||||
E_FREE(p);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_action(Evry_Plugin *p, Evry_Item *item, const char *input)
|
||||
_action(Evry_Item *it, const char *input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_list_free(Evry_Plugin *p)
|
||||
_list_free()
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
|
@ -90,7 +89,6 @@ _list_free(Evry_Plugin *p)
|
|||
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->o_icon) evas_object_del(it->o_icon);
|
||||
|
||||
free(it);
|
||||
}
|
||||
|
@ -98,41 +96,43 @@ _list_free(Evry_Plugin *p)
|
|||
|
||||
|
||||
static void
|
||||
_cleanup(Evry_Plugin *p)
|
||||
_cleanup()
|
||||
{
|
||||
_list_free(p);
|
||||
}
|
||||
State *s;
|
||||
|
||||
static int
|
||||
_begin(Evry_Plugin *p, Evry_Item *item)
|
||||
{
|
||||
Inst *inst = p->priv;
|
||||
if (!p->states) return;
|
||||
|
||||
if (item->uri && ecore_file_is_dir(item->uri))
|
||||
s = p->states->data;
|
||||
|
||||
_list_free();
|
||||
|
||||
eina_stringshare_del(s->directory);
|
||||
|
||||
E_FREE(s);
|
||||
|
||||
p->states = eina_list_remove_list(p->states, p->states);
|
||||
|
||||
if (p->states)
|
||||
{
|
||||
eina_stringshare_del(inst->directory);
|
||||
inst->directory = eina_stringshare_add(item->uri);
|
||||
|
||||
return 1;
|
||||
s = p->states->data;
|
||||
p->items = s->items;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* based on directory-watcher from drawer module */
|
||||
static int
|
||||
_fetch(Evry_Plugin *p, const char *input)
|
||||
_fetch(const char *input)
|
||||
{
|
||||
Eina_List *files;
|
||||
char *file;
|
||||
Evry_Item *it;
|
||||
char match1[4096];
|
||||
char match2[4096];
|
||||
Inst *inst = p->priv;
|
||||
State *s = p->states->data;
|
||||
|
||||
_list_free(p);
|
||||
_list_free();
|
||||
|
||||
files = ecore_file_ls(inst->directory);
|
||||
files = ecore_file_ls(s->directory);
|
||||
|
||||
if (input)
|
||||
{
|
||||
|
@ -144,37 +144,41 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
{
|
||||
it = NULL;
|
||||
|
||||
if (file[0] == '.') goto end;
|
||||
if (file[0] == '.')
|
||||
{
|
||||
free(file);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (input)
|
||||
{
|
||||
if (e_util_glob_case_match(file, match1))
|
||||
{
|
||||
it = _item_fill(inst->directory, file);
|
||||
it = _item_fill(s->directory, file);
|
||||
it->priority += 1;
|
||||
}
|
||||
else if (e_util_glob_case_match(file, match2))
|
||||
{
|
||||
it = _item_fill(inst->directory, file);
|
||||
it = _item_fill(s->directory, file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
it = _item_fill(inst->directory, file);
|
||||
it = _item_fill(s->directory, file);
|
||||
}
|
||||
|
||||
if (it)
|
||||
p->items = eina_list_append(p->items, it);
|
||||
|
||||
end:
|
||||
free(file);
|
||||
|
||||
}
|
||||
|
||||
if (eina_list_count(p->items) > 0)
|
||||
{
|
||||
p->items = eina_list_sort(p->items, eina_list_count(p->items),
|
||||
_cb_sort);
|
||||
s->items = p->items;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -236,7 +240,7 @@ _item_fill(const char *directory, const char *file)
|
|||
}
|
||||
|
||||
static void
|
||||
_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e)
|
||||
_item_icon_get(Evry_Item *it, Evas *e)
|
||||
{
|
||||
char *item_path;
|
||||
|
||||
|
|
|
@ -10,27 +10,38 @@ struct _Inst
|
|||
E_DBus_Connection *conn;
|
||||
};
|
||||
|
||||
static Evry_Plugin *_plug_new();
|
||||
static void _plug_free(Evry_Plugin *p);
|
||||
static int _fetch(Evry_Plugin *p, const char *input);
|
||||
static int _action(Evry_Plugin *p, Evry_Item *item, const char *input);
|
||||
static void _cleanup(Evry_Plugin *p);
|
||||
static void _item_add(Evry_Plugin *p, char *file, char *service, char *mime, int prio);
|
||||
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
|
||||
static int _fetch(const char *input);
|
||||
static int _action(Evry_Item *it, const char *input);
|
||||
static void _cleanup(void);
|
||||
static void _item_add(char *file, char *service, char *mime, int prio);
|
||||
static void _item_icon_get(Evry_Item *it, Evas *e);
|
||||
static void _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error);
|
||||
|
||||
static Evry_Plugin_Class class;
|
||||
static Evry_Plugin *p;
|
||||
static Inst *inst;
|
||||
|
||||
EAPI int
|
||||
evry_plug_tracker_init(void)
|
||||
{
|
||||
class.name = "Search Files";
|
||||
class.type_in = "NONE";
|
||||
class.type_out = "FILE";
|
||||
class.need_query = 1;
|
||||
class.new = &_plug_new;
|
||||
class.free = &_plug_free;
|
||||
evry_plugin_register(&class);
|
||||
E_DBus_Connection *conn = e_dbus_bus_get(DBUS_BUS_SESSION);
|
||||
|
||||
if (!conn) return 0;
|
||||
|
||||
p = E_NEW(Evry_Plugin, 1);
|
||||
p->name = "Search Files";
|
||||
p->type_in = "NONE";
|
||||
p->type_out = "FILE";
|
||||
p->need_query = 1;
|
||||
p->prio = 3;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
|
||||
inst = E_NEW(Inst, 1);
|
||||
inst->conn = conn;
|
||||
|
||||
evry_plugin_register(p);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -38,55 +49,28 @@ evry_plug_tracker_init(void)
|
|||
EAPI int
|
||||
evry_plug_tracker_shutdown(void)
|
||||
{
|
||||
evry_plugin_unregister(&class);
|
||||
evry_plugin_unregister(p);
|
||||
|
||||
if (inst)
|
||||
{
|
||||
if (inst->conn)
|
||||
e_dbus_connection_close(inst->conn);
|
||||
E_FREE(inst);
|
||||
}
|
||||
|
||||
if (p) E_FREE(p);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evry_Plugin *
|
||||
_plug_new()
|
||||
{
|
||||
Evry_Plugin *p;
|
||||
Inst *inst;
|
||||
E_DBus_Connection *conn = e_dbus_bus_get(DBUS_BUS_SESSION);
|
||||
|
||||
if (!conn) return NULL;
|
||||
|
||||
p = E_NEW(Evry_Plugin, 1);
|
||||
p->class = &class;
|
||||
p->fetch = &_fetch;
|
||||
p->action = &_action;
|
||||
p->cleanup = &_cleanup;
|
||||
p->icon_get = &_item_icon_get;
|
||||
p->items = NULL;
|
||||
|
||||
inst = E_NEW(Inst, 1);
|
||||
inst->conn = conn;
|
||||
p->priv = inst;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static void
|
||||
_plug_free(Evry_Plugin *p)
|
||||
{
|
||||
Inst *inst = p->priv;
|
||||
|
||||
_cleanup(p);
|
||||
e_dbus_connection_close(inst->conn);
|
||||
|
||||
E_FREE(inst);
|
||||
E_FREE(p);
|
||||
}
|
||||
|
||||
static int
|
||||
_action(Evry_Plugin *p, Evry_Item *it, const char *input)
|
||||
_action(Evry_Item *it, const char *input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_cleanup(Evry_Plugin *p)
|
||||
_cleanup(void)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
|
@ -95,13 +79,12 @@ _cleanup(Evry_Plugin *p)
|
|||
if (it->mime) eina_stringshare_del(it->mime);
|
||||
if (it->uri) eina_stringshare_del(it->uri);
|
||||
if (it->label) eina_stringshare_del(it->label);
|
||||
if (it->o_icon) evas_object_del(it->o_icon);
|
||||
free(it);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_fetch(Evry_Plugin *p, const char *input)
|
||||
_fetch(const char *input)
|
||||
{
|
||||
Eina_List *list;
|
||||
DBusMessage *msg;
|
||||
|
@ -111,9 +94,8 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
int max_hits = 50;
|
||||
char *service = "Files";
|
||||
char *match;
|
||||
Inst *inst = p->priv;
|
||||
|
||||
_cleanup(p);
|
||||
_cleanup();
|
||||
|
||||
match = malloc(sizeof(char) * strlen(input) + 2);
|
||||
sprintf(match, "%s*", input);
|
||||
|
@ -129,7 +111,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &match);
|
||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &offset);
|
||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &max_hits);
|
||||
e_dbus_message_send(inst->conn, msg, _dbus_cb_reply, -1, p);
|
||||
e_dbus_message_send(inst->conn, msg, _dbus_cb_reply, -1, NULL);
|
||||
dbus_message_unref(msg);
|
||||
|
||||
free(match);
|
||||
|
@ -138,7 +120,7 @@ _fetch(Evry_Plugin *p, const char *input)
|
|||
}
|
||||
|
||||
static void
|
||||
_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e)
|
||||
_item_icon_get(Evry_Item *it, Evas *e)
|
||||
{
|
||||
char *item_path;
|
||||
|
||||
|
@ -164,7 +146,7 @@ _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e)
|
|||
}
|
||||
|
||||
static void
|
||||
_item_add(Evry_Plugin *p, char *file, char *service, char *mime, int prio)
|
||||
_item_add(char *file, char *service, char *mime, int prio)
|
||||
{
|
||||
Evry_Item *it;
|
||||
|
||||
|
@ -183,7 +165,6 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
|||
{
|
||||
DBusMessageIter array, iter, item;
|
||||
char *val;
|
||||
Evry_Plugin *p = data;
|
||||
|
||||
if (dbus_error_is_set(error))
|
||||
{
|
||||
|
@ -213,7 +194,7 @@ _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error)
|
|||
|
||||
if (uri && service && mime)
|
||||
{
|
||||
_item_add(p, uri, service, mime, 1);
|
||||
_item_add(uri, service, mime, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue