'everything' module: formatting, whitespace cleanup

SVN revision: 41248
This commit is contained in:
Hannes Janetzek 2009-07-04 11:10:28 +00:00
parent 406acced00
commit 0236fd2006
8 changed files with 266 additions and 261 deletions

View File

@ -29,7 +29,7 @@ EAPI void *
e_modapi_init(E_Module *m) e_modapi_init(E_Module *m)
{ {
char buf[4096]; char buf[4096];
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/module.everything", snprintf(buf, sizeof(buf), "%s/.e/e/config/%s/module.everything",
e_user_homedir_get(), e_config_profile_get()); e_user_homedir_get(), e_config_profile_get());
ecore_file_mkdir(buf); ecore_file_mkdir(buf);
@ -66,7 +66,7 @@ e_modapi_init(E_Module *m)
evry_conf->scroll_animate = 1; evry_conf->scroll_animate = 1;
evry_conf->scroll_speed = 0.5; evry_conf->scroll_speed = 0.5;
} }
conf_module = m; conf_module = m;
evry_init(); evry_init();
@ -155,7 +155,7 @@ _e_mod_action_exebuf_cb(E_Object *obj, const char *params)
if (!zone) zone = e_util_zone_current_get(e_manager_current_get()); if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
printf("zone %d %d\n", zone->x, zone->y); printf("zone %d %d\n", zone->x, zone->y);
if (zone) evry_show(zone); if (zone) evry_show(zone);
} }

View File

@ -22,14 +22,14 @@ struct _Evry_State
/* Eina_List *sel_items; */ /* Eina_List *sel_items; */
char *input; char *input;
const char *request_type; const char *request_type;
Eina_Bool initial; Eina_Bool initial;
/* this is for the case when the current plugin was not selected /* this is for the case when the current plugin was not selected
manually and a higher priority (async) plugin retrieves manually and a higher priority (async) plugin retrieves
candidates, the higher priority plugin is made current */ candidates, the higher priority plugin is made current */
Eina_Bool plugin_auto_selected; Eina_Bool plugin_auto_selected;
}; };
static int _evry_cb_key_down(void *data, int type, void *event); static int _evry_cb_key_down(void *data, int type, void *event);
@ -72,8 +72,6 @@ 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_cleanup(void);
static void _evry_plug_act_select_item_icon_get(Evry_Item *it, Evas *e); static void _evry_plug_act_select_item_icon_get(Evry_Item *it, Evas *e);
/* local subsystem globals */ /* local subsystem globals */
static E_Popup *popup = NULL; static E_Popup *popup = NULL;
static Ecore_X_Window input_window = 0; static Ecore_X_Window input_window = 0;
@ -100,7 +98,7 @@ EAPI int
evry_init(void) evry_init(void)
{ {
_evry_plug_act_select_init(); _evry_plug_act_select_init();
return 1; return 1;
} }
@ -167,7 +165,7 @@ evry_show(E_Zone *zone)
if (!popup) return 0; if (!popup) return 0;
ecore_x_netwm_window_type_set(popup->evas_win, ECORE_X_WINDOW_TYPE_UTILITY); ecore_x_netwm_window_type_set(popup->evas_win, ECORE_X_WINDOW_TYPE_UTILITY);
e_popup_layer_set(popup, 255); e_popup_layer_set(popup, 255);
evas_event_freeze(popup->evas); evas_event_freeze(popup->evas);
evas_event_feed_mouse_in(popup->evas, ecore_x_current_time_get(), NULL); evas_event_feed_mouse_in(popup->evas, ecore_x_current_time_get(), NULL);
@ -196,7 +194,7 @@ evry_show(E_Zone *zone)
edje_object_part_swallow(o_main, "e.swallow.bar", o); edje_object_part_swallow(o_main, "e.swallow.bar", o);
evas_object_show(o); evas_object_show(o);
o_selector = o; o_selector = o;
evas_event_thaw(popup->evas); evas_event_thaw(popup->evas);
handlers = eina_list_append handlers = eina_list_append
@ -216,7 +214,7 @@ evry_show(E_Zone *zone)
(ECORE_EVENT_MOUSE_WHEEL, _evry_cb_mouse_wheel, NULL)); (ECORE_EVENT_MOUSE_WHEEL, _evry_cb_mouse_wheel, NULL));
_evry_push_state(); _evry_push_state();
e_popup_show(popup); e_popup_show(popup);
return 1; return 1;
} }
@ -229,17 +227,17 @@ evry_hide(void)
Evry_Plugin *plugin; Evry_Plugin *plugin;
Eina_List *l; Eina_List *l;
Evry_State *s; Evry_State *s;
if (!popup) return; if (!popup) return;
evas_event_freeze(popup->evas); evas_event_freeze(popup->evas);
_evry_list_clear(); _evry_list_clear();
EINA_LIST_FREE(stack, s) EINA_LIST_FREE(stack, s)
{ {
Evry_Plugin *p; Evry_Plugin *p;
free(s->input); free(s->input);
EINA_LIST_FREE(s->plugins, p) EINA_LIST_FREE(s->plugins, p)
@ -255,7 +253,7 @@ evry_hide(void)
} }
stack = NULL; stack = NULL;
cur_state = NULL; cur_state = NULL;
if (update_timer) if (update_timer)
{ {
ecore_timer_del(update_timer); ecore_timer_del(update_timer);
@ -271,9 +269,9 @@ evry_hide(void)
ecore_animator_del(scroll_animator); ecore_animator_del(scroll_animator);
scroll_animator = NULL; scroll_animator = NULL;
} }
e_popup_hide(popup); e_popup_hide(popup);
evas_object_del(o_list); evas_object_del(o_list);
o_list = NULL; o_list = NULL;
@ -295,7 +293,6 @@ evry_hide(void)
input_window = 0; input_window = 0;
} }
EAPI void EAPI void
evry_plugin_async_update(Evry_Plugin *p, int action) evry_plugin_async_update(Evry_Plugin *p, int action)
{ {
@ -317,17 +314,17 @@ evry_plugin_async_update(Evry_Plugin *p, int action)
} }
else else
{ {
char buf[64]; char buf[64];
snprintf(buf, 64, "%s (%d)", p->name, eina_list_count(p->items)); snprintf(buf, 64, "%s (%d)", p->name, eina_list_count(p->items));
edje_object_part_text_set(p->tab, "e.text.label", buf); edje_object_part_text_set(p->tab, "e.text.label", buf);
} }
if ((!s->cur_plugin && s->cur_plugins) || (s->cur_plugin == p) || if ((!s->cur_plugin && s->cur_plugins) || (s->cur_plugin == p) ||
(s->plugin_auto_selected && (s->cur_plugin->prio > p->prio))) (s->plugin_auto_selected && (s->cur_plugin->prio > p->prio)))
{ {
if (!s->cur_plugin) if (!s->cur_plugin)
s->plugin_auto_selected = 1; s->plugin_auto_selected = 1;
_evry_list_clear(); _evry_list_clear();
_evry_show_items(s->cur_plugins->data); _evry_show_items(s->cur_plugins->data);
} }
@ -335,6 +332,8 @@ evry_plugin_async_update(Evry_Plugin *p, int action)
else if ((action == EVRY_ASYNC_UPDATE_CLEAR) && (s->cur_plugin == p)) else if ((action == EVRY_ASYNC_UPDATE_CLEAR) && (s->cur_plugin == p))
{ {
_evry_list_clear(); _evry_list_clear();
/*XXX move this into list clear?*/
s->cur_items = NULL;
} }
} }
@ -347,22 +346,21 @@ _evry_cb_plugin_sort(const void *data1, const void *data2)
return p1->prio - p2->prio; return p1->prio - p2->prio;
} }
static int static int
_evry_push_state(void) _evry_push_state(void)
{ {
Evry_State *s; Evry_State *s;
Eina_List *l, *list = NULL; Eina_List *l, *list = NULL;
const char *cur_type = "NONE"; const char *cur_type = "NONE";
Evry_Plugin *p; Evry_Plugin *p;
s = cur_state; s = cur_state;
if (s) if (s)
{ {
if (!s->cur_plugin || !s->sel_item) if (!s->cur_plugin || !s->sel_item)
return 0; return 0;
cur_type = s->cur_plugin->type_out; cur_type = s->cur_plugin->type_out;
/* current plugin provides no candidates to act on by others */ /* current plugin provides no candidates to act on by others */
if (!s->cur_action && !strcmp(cur_type, "NONE")) if (!s->cur_action && !strcmp(cur_type, "NONE"))
@ -380,13 +378,13 @@ _evry_push_state(void)
} }
} }
} }
EINA_LIST_FOREACH(plugins, l, p) EINA_LIST_FOREACH(plugins, l, p)
{ {
if (strstr(p->type_in, cur_type)) if (strstr(p->type_in, cur_type))
{ {
/* printf("%s- in:%s out:%s\n", p->name, p->type_in, p->type_out); */ /* printf("%s- in:%s out:%s\n", p->name, p->type_in, p->type_out); */
if (s && s->cur_action) if (s && s->cur_action)
{ {
/* filter out plugins that dont provide the type /* filter out plugins that dont provide the type
@ -397,19 +395,19 @@ _evry_push_state(void)
if (p->begin) if (p->begin)
{ {
Evry_Item *sel_item = NULL; Evry_Item *it = NULL;
if (s && (s->cur_plugin != action_selector)) if (s && (s->cur_plugin != action_selector))
sel_item = s->sel_item; it = s->sel_item;
if (p->begin(sel_item)) if (p->begin(it))
list = eina_list_append(list, p); list = eina_list_append(list, p);
} }
else else
list = eina_list_append(list, p); list = eina_list_append(list, p);
} }
} }
if (s && !s->cur_action) if (s && !s->cur_action)
{ {
if (_evry_plug_act_select_actions_set()) if (_evry_plug_act_select_actions_set())
@ -417,7 +415,7 @@ _evry_push_state(void)
list = eina_list_append(list, action_selector); list = eina_list_append(list, action_selector);
} }
} }
if (!list) return 0; if (!list) return 0;
list = eina_list_sort(list, eina_list_count(list), _evry_cb_plugin_sort); list = eina_list_sort(list, eina_list_count(list), _evry_cb_plugin_sort);
@ -480,7 +478,7 @@ _evry_pop_state(void)
{ {
Evry_Item *it = NULL; Evry_Item *it = NULL;
int i = 0; int i = 0;
s = stack->data; s = stack->data;
cur_state = s; cur_state = s;
@ -489,7 +487,7 @@ _evry_pop_state(void)
_evry_pop_state(); _evry_pop_state();
return 0; return 0;
} }
edje_object_part_text_set(o_main, "e.text.label", s->input); edje_object_part_text_set(o_main, "e.text.label", s->input);
if (s->sel_item) if (s->sel_item)
@ -500,21 +498,21 @@ _evry_pop_state(void)
break; break;
else i++; else i++;
} }
if (stack->next) if (stack->next)
{ {
Evry_State *prev = stack->next->data; Evry_State *prev = stack->next->data;
it = prev->sel_item; it = prev->sel_item;
} }
EINA_LIST_FOREACH(s->plugins, l, p) EINA_LIST_FOREACH(s->plugins, l, p)
if (p != s->cur_plugin && p->begin) if (p != s->cur_plugin && p->begin)
p->begin(it); p->begin(it);
_evry_matches_update(); _evry_matches_update();
it = eina_list_nth(s->cur_plugin->items, i); it = eina_list_nth(s->cur_plugin->items, i);
if (it) if (it)
{ {
if (s->sel_item) _evry_item_desel(s->sel_item); if (s->sel_item) _evry_item_desel(s->sel_item);
@ -559,24 +557,24 @@ _evry_cb_key_down(void *data, int type, void *event)
if (s->sel_item) if (s->sel_item)
{ {
if (!_evry_push_state()) if (!_evry_push_state())
_evry_plugin_action(0); _evry_plugin_action(0);
} }
} }
/* _evry_plugin_next(); */ /* _evry_plugin_next(); */
else if (!strcmp(ev->key, "Left") && else if (!strcmp(ev->key, "Left") &&
((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) || ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) ||
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT))) (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)))
_evry_pop_state(); _evry_pop_state();
/* _evry_plugin_prev(); */ /* _evry_plugin_prev(); */
else if (!strcmp(ev->key, "Right")) else if (!strcmp(ev->key, "Right"))
_evry_plugin_next(); _evry_plugin_next();
/* { /* {
* if (s->sel_item) * if (s->sel_item)
* { * {
* if (!_evry_push_state()) * if (!_evry_push_state())
* _evry_plugin_action(0); * _evry_plugin_action(0);
* } * }
* } */ * } */
else if (!strcmp(ev->key, "Left")) else if (!strcmp(ev->key, "Left"))
_evry_plugin_prev(); _evry_plugin_prev();
/* _evry_pop_state(); */ /* _evry_pop_state(); */
@ -594,10 +592,10 @@ _evry_cb_key_down(void *data, int type, void *event)
if (s->sel_item) if (s->sel_item)
{ {
if (!_evry_push_state()) if (!_evry_push_state())
_evry_plugin_action(0); _evry_plugin_action(0);
} }
} }
/* _evry_plugin_next(); */ /* _evry_plugin_next(); */
else if (!strcmp(ev->key, "u") && else if (!strcmp(ev->key, "u") &&
(ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)) (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL))
_evry_clear(); _evry_clear();
@ -608,7 +606,7 @@ _evry_cb_key_down(void *data, int type, void *event)
if (!_evry_pop_state()) if (!_evry_pop_state())
evry_hide(); evry_hide();
} }
else if (!strcmp(ev->key, "BackSpace")) else if (!strcmp(ev->key, "BackSpace"))
_evry_backspace(); _evry_backspace();
else if (!strcmp(ev->key, "Delete")) else if (!strcmp(ev->key, "Delete"))
@ -632,7 +630,7 @@ _evry_cb_mouse_down(void *data, int type, void *event)
{ {
Ecore_Event_Mouse_Button *ev; Ecore_Event_Mouse_Button *ev;
Evry_State *s =cur_state; Evry_State *s =cur_state;
ev = event; ev = event;
if (ev->event_window != input_window) return 1; if (ev->event_window != input_window) return 1;
@ -642,8 +640,8 @@ _evry_cb_mouse_down(void *data, int type, void *event)
{ {
if (s->sel_item) _evry_item_desel(s->sel_item); if (s->sel_item) _evry_item_desel(s->sel_item);
s->sel_item = item_mouseover; s->sel_item = item_mouseover;
_evry_item_sel(s->sel_item); _evry_item_sel(s->sel_item);
} }
} }
else else
{ {
@ -657,31 +655,31 @@ static int
_evry_cb_mouse_up(void *data, int type, void *event) _evry_cb_mouse_up(void *data, int type, void *event)
{ {
Ecore_Event_Mouse_Button *ev; Ecore_Event_Mouse_Button *ev;
ev = event; ev = event;
if (ev->event_window != input_window) return 1; if (ev->event_window != input_window) return 1;
if (item_mouseover) if (item_mouseover)
{ {
if (ev->buttons == 1) if (ev->buttons == 1)
_evry_plugin_action(1); _evry_plugin_action(1);
else if (ev->buttons == 3) else if (ev->buttons == 3)
_evry_plugin_action(0); _evry_plugin_action(0);
} }
else else
{ {
evas_event_feed_mouse_up(popup->evas, ev->buttons, 0, ev->timestamp, NULL); evas_event_feed_mouse_up(popup->evas, ev->buttons, 0, ev->timestamp, NULL);
} }
return 1; return 1;
} }
static int static int
_evry_cb_mouse_move(void *data, int type, void *event) _evry_cb_mouse_move(void *data, int type, void *event)
{ {
Ecore_Event_Mouse_Move *ev; Ecore_Event_Mouse_Move *ev;
Evry_State *s =cur_state; Evry_State *s =cur_state;
ev = event; ev = event;
if (ev->event_window != input_window) return 1; if (ev->event_window != input_window) return 1;
@ -695,7 +693,7 @@ _evry_cb_mouse_move(void *data, int type, void *event)
if (!s->sel_item || (s->sel_item != item_mouseover)) if (!s->sel_item || (s->sel_item != item_mouseover))
{ {
s->sel_item = item_mouseover; s->sel_item = item_mouseover;
_evry_item_sel(s->sel_item); _evry_item_sel(s->sel_item);
} }
} }
} }
@ -710,7 +708,7 @@ static int
_evry_cb_mouse_wheel(void *data, int type, void *event) _evry_cb_mouse_wheel(void *data, int type, void *event)
{ {
Ecore_Event_Mouse_Wheel *ev; Ecore_Event_Mouse_Wheel *ev;
ev = event; ev = event;
if (ev->event_window != input_window) return 1; if (ev->event_window != input_window) return 1;
@ -719,35 +717,35 @@ _evry_cb_mouse_wheel(void *data, int type, void *event)
if (ev->z < 0) /* up */ if (ev->z < 0) /* up */
{ {
int i; int i;
for (i = ev->z; i < 0; i++) _evry_item_prev(); for (i = ev->z; i < 0; i++) _evry_item_prev();
} }
else if (ev->z > 0) /* down */ else if (ev->z > 0) /* down */
{ {
int i; int i;
for (i = ev->z; i > 0; i--) _evry_item_next(); for (i = ev->z; i > 0; i--) _evry_item_next();
} }
return 1; return 1;
} }
static void static void
_evry_cb_item_mouse_in(void *data, Evas *evas, Evas_Object *obj, _evry_cb_item_mouse_in(void *data, Evas *evas, Evas_Object *obj,
void *event_info) void *event_info)
{ {
Evry_State *s =cur_state; Evry_State *s =cur_state;
if (!ev_last_is_mouse) return; if (!ev_last_is_mouse) return;
item_mouseover = data; item_mouseover = data;
if (s->sel_item) _evry_item_desel(s->sel_item); if (s->sel_item) _evry_item_desel(s->sel_item);
if (!(s->sel_item = data)) return; if (!(s->sel_item = data)) return;
_evry_item_sel(s->sel_item); _evry_item_sel(s->sel_item);
} }
static void static void
_evry_cb_item_mouse_out(void *data, Evas *evas, Evas_Object *obj, _evry_cb_item_mouse_out(void *data, Evas *evas, Evas_Object *obj,
void *event_info) void *event_info)
{ {
item_mouseover = NULL; item_mouseover = NULL;
@ -758,7 +756,7 @@ _evry_backspace(void)
{ {
int len, val, pos; int len, val, pos;
Evry_State *s = cur_state; Evry_State *s = cur_state;
len = strlen(s->input); len = strlen(s->input);
if (len > 0) if (len > 0)
{ {
@ -776,7 +774,7 @@ _evry_update(void)
{ {
Efreet_Desktop *desktop; Efreet_Desktop *desktop;
Evas_Object *o; Evas_Object *o;
edje_object_part_text_set(o_main, "e.text.label", cur_state->input); edje_object_part_text_set(o_main, "e.text.label", cur_state->input);
if (update_timer) ecore_timer_del(update_timer); if (update_timer) ecore_timer_del(update_timer);
@ -810,7 +808,7 @@ _evry_plugin_action(int finished)
{ {
/* set cur_action and start plugins for second parameter (if required)*/ /* 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); if (s->sel_item) _evry_plug_act_select_action(s->sel_item, s->input);
finished = 0; finished = 0;
} }
else if (s->cur_action) else if (s->cur_action)
@ -826,7 +824,7 @@ _evry_plugin_action(int finished)
{ {
/* XXX use flags for return values */ /* XXX use flags for return values */
int ret = 0; int ret = 0;
if (s->cur_plugin->action) if (s->cur_plugin->action)
{ {
ret = s->cur_plugin->action(s->sel_item, s->input); ret = s->cur_plugin->action(s->sel_item, s->input);
@ -854,8 +852,8 @@ _evry_show_items(Evry_Plugin *p)
int mw, mh, h; int mw, mh, h;
Evas_Object *o; Evas_Object *o;
Evry_State *s = cur_state; Evry_State *s = cur_state;
if (s->cur_plugin) if (s->cur_plugin)
{ {
if (s->cur_plugin != p) if (s->cur_plugin != p)
{ {
@ -865,14 +863,14 @@ _evry_show_items(Evry_Plugin *p)
} }
else else
edje_object_signal_emit(p->tab, "e,state,selected", "e"); edje_object_signal_emit(p->tab, "e,state,selected", "e");
if (s->cur_plugin != p) if (s->cur_plugin != p)
s->sel_item = NULL; s->sel_item = NULL;
s->cur_plugin = p; s->cur_plugin = p;
s->cur_items = p->items; s->cur_items = p->items;
evas_event_freeze(popup->evas); evas_event_freeze(popup->evas);
e_box_freeze(o_list); e_box_freeze(o_list);
EINA_LIST_FOREACH(p->items, l, it) EINA_LIST_FOREACH(p->items, l, it)
@ -885,9 +883,9 @@ _evry_show_items(Evry_Plugin *p)
edje_object_part_text_set(o, "e.text.title", it->label); edje_object_part_text_set(o, "e.text.title", it->label);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN,
_evry_cb_item_mouse_in, it); _evry_cb_item_mouse_in, it);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT,
_evry_cb_item_mouse_out, it); _evry_cb_item_mouse_out, it);
evas_object_show(o); evas_object_show(o);
p->icon_get(it, popup->evas); p->icon_get(it, popup->evas);
@ -913,11 +911,11 @@ _evry_show_items(Evry_Plugin *p)
/* if (!s->sel_item && p->items) /* if (!s->sel_item && p->items)
* { * {
* s->sel_item = p->items->data; * s->sel_item = p->items->data;
* _evry_item_sel(s->sel_item); * _evry_item_sel(s->sel_item);
* _evry_scroll_to(0); * _evry_scroll_to(0);
* } */ * } */
evas_event_thaw(popup->evas); evas_event_thaw(popup->evas);
_evry_tab_scroll_to(p); _evry_tab_scroll_to(p);
@ -930,20 +928,20 @@ _evry_matches_update(void)
Eina_List *l; Eina_List *l;
int items; int items;
Evry_State *s = cur_state; Evry_State *s = cur_state;
_evry_list_clear(); _evry_list_clear();
eina_list_free(s->cur_plugins); eina_list_free(s->cur_plugins);
s->cur_plugins = NULL; s->cur_plugins = NULL;
s->sel_item = NULL; s->sel_item = NULL;
EINA_LIST_FOREACH(s->plugins, l, p) EINA_LIST_FOREACH(s->plugins, l, p)
{ {
if (strlen(s->input) == 0) if (strlen(s->input) == 0)
items = !p->need_query ? p->fetch(NULL) : 0; items = !p->need_query ? p->fetch(NULL) : 0;
else else
items = p->fetch(s->input); items = p->fetch(s->input);
if (!s->initial || (items && eina_list_count(p->items) > 0)) if (!s->initial || (items && eina_list_count(p->items) > 0))
{ {
s->cur_plugins = eina_list_append(s->cur_plugins, p); s->cur_plugins = eina_list_append(s->cur_plugins, p);
@ -954,10 +952,10 @@ _evry_matches_update(void)
p->tab = NULL; p->tab = NULL;
} }
} }
EINA_LIST_FOREACH(s->cur_plugins, l, p) EINA_LIST_FOREACH(s->cur_plugins, l, p)
_evry_plugin_selector_show(p); _evry_plugin_selector_show(p);
if (s->cur_plugins) if (s->cur_plugins)
{ {
if (s->cur_plugin && eina_list_data_find(s->cur_plugins, s->cur_plugin)) if (s->cur_plugin && eina_list_data_find(s->cur_plugins, s->cur_plugin))
@ -978,7 +976,7 @@ _evry_list_clear(void)
Evry_State *s = cur_state; Evry_State *s = cur_state;
Evry_Item *it; Evry_Item *it;
Eina_List *l; Eina_List *l;
if (s && s->cur_items) if (s && s->cur_items)
{ {
evas_event_freeze(popup->evas); evas_event_freeze(popup->evas);
@ -1036,7 +1034,7 @@ _evry_tab_scroll_to(Evry_Plugin *p)
for(i = 0, l = cur_state->cur_plugins; l; l = l->next, i++) for(i = 0, l = cur_state->cur_plugins; l; l = l->next, i++)
if (l->data == p) break; if (l->data == p) break;
n = eina_list_count(cur_state->cur_plugins); n = eina_list_count(cur_state->cur_plugins);
e_box_min_size_get(o_selector, &mw, NULL); e_box_min_size_get(o_selector, &mw, NULL);
@ -1047,7 +1045,7 @@ _evry_tab_scroll_to(Evry_Plugin *p)
e_box_align_set(o_selector, 0.0, 0.5); e_box_align_set(o_selector, 0.0, 0.5);
return; return;
} }
if (n > 1) if (n > 1)
{ {
align = (double)i / (double)(n - 1); align = (double)i / (double)(n - 1);
@ -1059,9 +1057,9 @@ _evry_tab_scroll_to(Evry_Plugin *p)
* scroll_animator = ecore_animator_add(_evry_animator, NULL); * scroll_animator = ecore_animator_add(_evry_animator, NULL);
* } * }
* else */ * else */
{ {
e_box_align_set(o_selector, 1.0 - align, 0.5); e_box_align_set(o_selector, 1.0 - align, 0.5);
} }
} }
else else
e_box_align_set(o_selector, 1.0, 0.5); e_box_align_set(o_selector, 1.0, 0.5);
@ -1091,7 +1089,7 @@ _evry_item_next(void)
Evry_State *s = cur_state; Evry_State *s = cur_state;
s->plugin_auto_selected = 0; s->plugin_auto_selected = 0;
if (s->sel_item) if (s->sel_item)
{ {
for (i = 0, l = s->cur_plugin->items; l; l = l->next, i++) for (i = 0, l = s->cur_plugin->items; l; l = l->next, i++)
@ -1128,9 +1126,9 @@ _evry_item_prev(void)
Evry_State *s = cur_state; Evry_State *s = cur_state;
s->plugin_auto_selected = 0; s->plugin_auto_selected = 0;
if (s->sel_item) if (s->sel_item)
{ {
_evry_item_desel(s->sel_item); _evry_item_desel(s->sel_item);
for (i = 0, l = s->cur_plugin->items; l; l = l->next, i++) for (i = 0, l = s->cur_plugin->items; l; l = l->next, i++)
@ -1160,9 +1158,9 @@ _evry_plugin_next(void)
{ {
Eina_List *l; Eina_List *l;
Evry_State *s = cur_state; Evry_State *s = cur_state;
if (!s->cur_plugin) return; if (!s->cur_plugin) return;
l = eina_list_data_find_list(s->cur_plugins, s->cur_plugin); l = eina_list_data_find_list(s->cur_plugins, s->cur_plugin);
if (l && l->next) if (l && l->next)
@ -1179,14 +1177,13 @@ _evry_plugin_next(void)
} }
} }
static void static void
_evry_plugin_prev(void) _evry_plugin_prev(void)
{ {
Eina_List *l; Eina_List *l;
Evry_Plugin *plugin; Evry_Plugin *plugin;
Evry_State *s = cur_state; Evry_State *s = cur_state;
if (!s->cur_plugin) return; if (!s->cur_plugin) return;
l = eina_list_data_find_list(s->cur_plugins, s->cur_plugin); l = eina_list_data_find_list(s->cur_plugins, s->cur_plugin);
@ -1198,9 +1195,9 @@ _evry_plugin_prev(void)
_evry_show_items(l->prev->data); _evry_show_items(l->prev->data);
} }
else else
{ {
l = eina_list_last(s->cur_plugins); l = eina_list_last(s->cur_plugins);
if (s->cur_plugin != l->data) if (s->cur_plugin != l->data)
{ {
s->plugin_auto_selected = 0; s->plugin_auto_selected = 0;
@ -1230,7 +1227,7 @@ _evry_animator(void *data)
{ {
double da; double da;
int scroll_to = 1; int scroll_to = 1;
da = scroll_align - scroll_align_to; da = scroll_align - scroll_align_to;
if (da < 0.0) da = -da; if (da < 0.0) da = -da;
if (da < 0.01) if (da < 0.01)
@ -1265,11 +1262,11 @@ _evry_plugin_selector_show(Evry_Plugin *p)
o = edje_object_add(popup->evas); o = edje_object_add(popup->evas);
/* TODO move this to everything theme group !*/ /* TODO move this to everything theme group !*/
e_theme_edje_object_set(o, "base/theme/widgets", e_theme_edje_object_set(o, "base/theme/widgets",
"e/widgets/toolbar/item"); "e/widgets/toolbar/item");
} }
snprintf(buf, 64, "%s (%d)", p->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_part_text_set(o, "e.text.label", buf);
edje_object_size_min_calc(o, &mw, &mh); edje_object_size_min_calc(o, &mw, &mh);
@ -1282,15 +1279,13 @@ _evry_plugin_selector_show(Evry_Plugin *p)
} }
else else
e_box_pack_end(o_selector, o); e_box_pack_end(o_selector, o);
evas_object_show(o); evas_object_show(o);
e_box_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5, mw, mh, 9999, 9999); e_box_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5, mw, mh, 9999, 9999);
e_box_thaw(o_selector); e_box_thaw(o_selector);
p->tab = o; p->tab = o;
} }
static int static int
_evry_plug_act_select_init(void) _evry_plug_act_select_init(void)
{ {
@ -1312,11 +1307,11 @@ _evry_plug_act_select_actions_set(void)
Eina_List *l; Eina_List *l;
Evry_State *s = cur_state; Evry_State *s = cur_state;
Evry_Plugin *p = action_selector; Evry_Plugin *p = action_selector;
_evry_plug_act_select_cleanup(); _evry_plug_act_select_cleanup();
const char *type = s->cur_plugin->type_out; const char *type = s->cur_plugin->type_out;
EINA_LIST_FOREACH(actions, l, act) EINA_LIST_FOREACH(actions, l, act)
{ {
if (strstr(act->type_in1, type)) if (strstr(act->type_in1, type))
@ -1345,7 +1340,7 @@ _evry_plug_act_select_fetch(const char *input)
it = E_NEW(Evry_Item, 1); it = E_NEW(Evry_Item, 1);
it->label = eina_stringshare_add(act->name); it->label = eina_stringshare_add(act->name);
it->data[0] = act; it->data[0] = act;
p->items = eina_list_append(p->items, it); p->items = eina_list_append(p->items, it);
} }
@ -1368,7 +1363,7 @@ _evry_plug_act_select_action(Evry_Item *it, const char *input)
static void static void
_evry_plug_act_select_cleanup(void) _evry_plug_act_select_cleanup(void)
{ {
Evry_Item *it; Evry_Item *it;
Evry_Plugin *p = action_selector; Evry_Plugin *p = action_selector;
@ -1377,10 +1372,10 @@ _evry_plug_act_select_cleanup(void)
eina_stringshare_del(it->label); eina_stringshare_del(it->label);
E_FREE(it); E_FREE(it);
} }
eina_list_free(cur_state->cur_actions); eina_list_free(cur_state->cur_actions);
cur_state->cur_actions = NULL; cur_state->cur_actions = NULL;
p->items = NULL; p->items = NULL;
} }
@ -1388,10 +1383,8 @@ static void
_evry_plug_act_select_item_icon_get(Evry_Item *it, Evas *e) _evry_plug_act_select_item_icon_get(Evry_Item *it, Evas *e)
{ {
Evry_Action *act = it->data[0]; Evry_Action *act = it->data[0];
/* if (act->icon_get) /* if (act->icon_get)
* it->o_icon = act->icon_get(act, e); */ * it->o_icon = act->icon_get(act, e); */
} }

View File

@ -24,7 +24,6 @@ static Evry_Action *act;
static Inst *inst; static Inst *inst;
EAPI int EAPI int
evry_plug_apps_init(void) evry_plug_apps_init(void)
{ {
@ -48,7 +47,7 @@ evry_plug_apps_init(void)
evry_action_register(act); evry_action_register(act);
inst = NULL; inst = NULL;
return 1; return 1;
} }
@ -65,7 +64,7 @@ static int
_begin(Evry_Item *it) _begin(Evry_Item *it)
{ {
const char *mime; const char *mime;
if (inst) return 0; if (inst) return 0;
if (it) if (it)
@ -75,14 +74,14 @@ _begin(Evry_Item *it)
p->prio = 3; p->prio = 3;
if (!it->uri) return 0; if (!it->uri) return 0;
if (!it->mime) if (!it->mime)
mime = efreet_mime_type_get(it->uri); mime = efreet_mime_type_get(it->uri);
else else
mime = it->mime; mime = it->mime;
if (!mime) return 0; if (!mime) return 0;
inst = E_NEW(Inst, 1); inst = E_NEW(Inst, 1);
inst->candidate = it; inst->candidate = it;
inst->apps = efreet_util_desktop_mime_list(mime); inst->apps = efreet_util_desktop_mime_list(mime);
@ -92,24 +91,23 @@ _begin(Evry_Item *it)
p->name = "Applications"; p->name = "Applications";
p->type_out = "APPLICATION"; p->type_out = "APPLICATION";
p->prio = 1; p->prio = 1;
inst = E_NEW(Inst, 1); inst = E_NEW(Inst, 1);
} }
return 1; return 1;
} }
static int static int
_action(Evry_Item *it, const char *input) _action(Evry_Item *it, const char *input)
{ {
E_Zone *zone; E_Zone *zone;
Evry_App *app = NULL; Evry_App *app = NULL;
Efreet_Desktop *desktop = NULL; Efreet_Desktop *desktop = NULL;
Eina_List *files = NULL; Eina_List *files = NULL;
if (it) app = it->data[0]; if (it) app = it->data[0];
if (app && app->desktop) if (app && app->desktop)
{ {
desktop = app->desktop; desktop = app->desktop;
@ -118,7 +116,7 @@ _action(Evry_Item *it, const char *input)
{ {
if (app && app->file) if (app && app->file)
input = app->file; input = app->file;
desktop = efreet_desktop_empty_new(""); desktop = efreet_desktop_empty_new("");
if (strchr(input, '%')) if (strchr(input, '%'))
{ {
@ -148,17 +146,16 @@ _action(Evry_Item *it, const char *input)
return EVRY_ACTION_FINISHED; return EVRY_ACTION_FINISHED;
} }
return EVRY_ACTION_CONTINUE; return EVRY_ACTION_CONTINUE;
} }
static void static void
_list_free(void) _list_free(void)
{ {
Evry_Item *it; Evry_Item *it;
Evry_App *app; Evry_App *app;
EINA_LIST_FREE(p->items, it) EINA_LIST_FREE(p->items, it)
{ {
if (it->label) eina_stringshare_del(it->label); if (it->label) eina_stringshare_del(it->label);
@ -178,11 +175,10 @@ _cleanup(void)
eina_list_free(inst->apps); eina_list_free(inst->apps);
E_FREE(inst); E_FREE(inst);
} }
inst = NULL; inst = NULL;
} }
static int static int
_fetch(const char *input) _fetch(const char *input)
{ {
@ -191,8 +187,8 @@ _fetch(const char *input)
char *file; char *file;
char match1[4096]; char match1[4096];
char match2[4096]; char match2[4096];
_list_free(); _list_free();
if (inst->apps) if (inst->apps)
{ {
@ -226,24 +222,24 @@ _fetch(const char *input)
} }
} }
} }
if (!p->items && input) if (!p->items && input)
{ {
snprintf(match1, sizeof(match1), "%s*", input); snprintf(match1, sizeof(match1), "%s*", input);
l = efreet_util_desktop_exec_glob_list(match1); l = efreet_util_desktop_exec_glob_list(match1);
EINA_LIST_FREE(l, desktop) EINA_LIST_FREE(l, desktop)
_item_add(desktop, NULL, 1); _item_add(desktop, NULL, 1);
snprintf(match1, sizeof(match1), "*%s*", input); snprintf(match1, sizeof(match1), "*%s*", input);
l = efreet_util_desktop_name_glob_list(match1); l = efreet_util_desktop_name_glob_list(match1);
EINA_LIST_FREE(l, desktop) EINA_LIST_FREE(l, desktop)
_item_add(desktop, NULL, 2); _item_add(desktop, NULL, 2);
// TODO make these optional/configurable // TODO make these optional/configurable
l = efreet_util_desktop_generic_name_glob_list(match1); l = efreet_util_desktop_generic_name_glob_list(match1);
EINA_LIST_FREE(l, desktop) EINA_LIST_FREE(l, desktop)
_item_add(desktop, NULL, 3); _item_add(desktop, NULL, 3);
l = efreet_util_desktop_comment_glob_list(match1); l = efreet_util_desktop_comment_glob_list(match1);
EINA_LIST_FREE(l, desktop) EINA_LIST_FREE(l, desktop)
@ -256,20 +252,20 @@ _fetch(const char *input)
EINA_LIST_FREE(l, file) EINA_LIST_FREE(l, file)
_item_add(NULL, file, 1); _item_add(NULL, file, 1);
} }
if (inst->added) if (inst->added)
{ {
eina_hash_free(inst->added); eina_hash_free(inst->added);
inst->added = NULL; inst->added = NULL;
} }
if (p->items) if (p->items)
{ {
if (input) 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; return 1;
} }
return 0; return 0;
} }
@ -291,10 +287,10 @@ _item_add(Efreet_Desktop *desktop, char *file, int prio)
if (cat && !strcmp(cat, "Screensaver")) if (cat && !strcmp(cat, "Screensaver"))
return; return;
} }
file = desktop->exec; file = desktop->exec;
} }
if (!file) return; if (!file) return;
if (!inst->added) if (!inst->added)
@ -308,13 +304,13 @@ _item_add(Efreet_Desktop *desktop, char *file, int prio)
int len; int len;
char *tmp; char *tmp;
int found = 0; int found = 0;
if (eina_hash_find(inst->added, file)) if (eina_hash_find(inst->added, file))
return; return;
len = strlen(file); len = strlen(file);
tmp = ecore_file_app_exe_get(file); tmp = ecore_file_app_exe_get(file);
snprintf(match, sizeof(match), "%s*", tmp); snprintf(match, sizeof(match), "%s*", tmp);
l = efreet_util_desktop_exec_glob_list(match); l = efreet_util_desktop_exec_glob_list(match);
EINA_LIST_FREE(l, desktop) EINA_LIST_FREE(l, desktop)
@ -342,7 +338,7 @@ _item_add(Efreet_Desktop *desktop, char *file, int prio)
eina_hash_add(inst->added, file, desktop); eina_hash_add(inst->added, file, desktop);
file = NULL; file = NULL;
} }
it = E_NEW(Evry_Item, 1); it = E_NEW(Evry_Item, 1);
app = E_NEW(Evry_App, 1); app = E_NEW(Evry_App, 1);
app->desktop = desktop; app->desktop = desktop;
@ -362,7 +358,7 @@ static void
_item_icon_get(Evry_Item *it, Evas *e) _item_icon_get(Evry_Item *it, Evas *e)
{ {
Evry_App *app = it->data[0]; Evry_App *app = it->data[0];
if (app->desktop) if (app->desktop)
it->o_icon = e_util_desktop_icon_add(app->desktop, 24, e); it->o_icon = e_util_desktop_icon_add(app->desktop, 24, e);
@ -381,7 +377,7 @@ _cb_sort(const void *data1, const void *data2)
Evry_App *app1, *app2; Evry_App *app1, *app2;
const char *e1, *e2; const char *e1, *e2;
double t1, t2; double t1, t2;
it1 = data1; it1 = data1;
it2 = data2; it2 = data2;
app1 = it1->data[0]; app1 = it1->data[0];
@ -397,7 +393,6 @@ _cb_sort(const void *data1, const void *data2)
return (it1->priority - it2->priority); return (it1->priority - it2->priority);
// TODO compare exe strings? // TODO compare exe strings?
else return 0; else return 0;
} }
static int static int
@ -409,12 +404,12 @@ _exec_action(void)
inst->candidate = act->thing2; inst->candidate = act->thing2;
_action(act->thing1, NULL); _action(act->thing1, NULL);
E_FREE(inst); E_FREE(inst);
inst = NULL; inst = NULL;
return 1; return 1;
} }
return 0; return 0;
} }

View File

@ -1,13 +1,6 @@
#include "e.h" #include "e.h"
#include "e_mod_main.h" #include "e_mod_main.h"
typedef struct _Inst Inst;
struct _Inst
{
E_Border *border;
};
static int _fetch(const char *input); static int _fetch(const char *input);
static int _action(Evry_Item *item, const char *input); static int _action(Evry_Item *item, const char *input);
static void _cleanup(void); static void _cleanup(void);
@ -17,6 +10,7 @@ static void _item_icon_get(Evry_Item *it, Evas *e);
static Evry_Plugin *p; static Evry_Plugin *p;
EAPI int EAPI int
evry_plug_border_init(void) evry_plug_border_init(void)
{ {
@ -31,7 +25,7 @@ evry_plug_border_init(void)
p->cleanup = &_cleanup; p->cleanup = &_cleanup;
p->icon_get = &_item_icon_get; p->icon_get = &_item_icon_get;
evry_plugin_register(p); evry_plugin_register(p);
return 1; return 1;
} }
@ -39,7 +33,7 @@ EAPI int
evry_plug_border_shutdown(void) evry_plug_border_shutdown(void)
{ {
evry_plugin_unregister(p); evry_plugin_unregister(p);
E_FREE(p); E_FREE(p);
return 1; return 1;
} }
@ -51,13 +45,13 @@ _action(Evry_Item *it, const char *input)
E_Zone *zone; E_Zone *zone;
if (!it) return EVRY_ACTION_CONTINUE; if (!it) return EVRY_ACTION_CONTINUE;
bd = (E_Border *)it->data[0]; bd = (E_Border *)it->data[0];
zone = e_util_zone_current_get(e_manager_current_get()); zone = e_util_zone_current_get(e_manager_current_get());
if (bd->desk != (e_desk_current_get(zone))) if (bd->desk != (e_desk_current_get(zone)))
e_desk_show(bd->desk); e_desk_show(bd->desk);
if (bd->shaded) if (bd->shaded)
e_border_unshade(bd, E_DIRECTION_UP); e_border_unshade(bd, E_DIRECTION_UP);
@ -68,7 +62,7 @@ _action(Evry_Item *it, const char *input)
/* e_border_focus_set(bd, 1, 1); */ /* e_border_focus_set(bd, 1, 1); */
e_border_focus_set_with_pointer(bd); e_border_focus_set_with_pointer(bd);
return EVRY_ACTION_FINISHED; return EVRY_ACTION_FINISHED;
} }
@ -90,24 +84,24 @@ _fetch(const char *input)
{ {
E_Manager *man; E_Manager *man;
E_Zone *zone; E_Zone *zone;
char match1[4096]; char match1[4096];
char match2[4096]; char match2[4096];
Eina_List *list; Eina_List *list;
E_Border *bd; E_Border *bd;
E_Border_List *bl; E_Border_List *bl;
_cleanup(); _cleanup();
man = e_manager_current_get(); man = e_manager_current_get();
zone = e_util_zone_current_get(man); zone = e_util_zone_current_get(man);
if (input) if (input)
{ {
snprintf(match1, sizeof(match1), "%s*", input); snprintf(match1, sizeof(match1), "%s*", input);
snprintf(match2, sizeof(match2), "*%s*", input); snprintf(match2, sizeof(match2), "*%s*", input);
} }
bl = e_container_border_list_first(e_container_current_get(man)); bl = e_container_border_list_first(e_container_current_get(man));
while ((bd = e_container_border_list_next(bl))) while ((bd = e_container_border_list_next(bl)))
{ {
@ -140,21 +134,21 @@ _fetch(const char *input)
static void static void
_item_icon_get(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); it->o_icon = e_border_icon_add(((E_Border *)it->data[0]), e);
} }
static void static void
_item_add(E_Border *bd, int prio) _item_add(E_Border *bd, int prio)
{ {
Evry_Item *it; Evry_Item *it;
it = E_NEW(Evry_Item, 1); it = E_NEW(Evry_Item, 1);
/* e_object_ref(E_OBJECT(bd)); */ /* e_object_ref(E_OBJECT(bd)); */
it->data[0] = bd; it->data[0] = bd;
it->priority = prio; it->priority = prio;
it->label = eina_stringshare_add(e_border_name_get(bd)); it->label = eina_stringshare_add(e_border_name_get(bd));
p->items = eina_list_append(p->items, it); p->items = eina_list_append(p->items, it);
} }
@ -163,7 +157,7 @@ static int
_cb_sort(const void *data1, const void *data2) _cb_sort(const void *data1, const void *data2)
{ {
const Evry_Item *it1, *it2; const Evry_Item *it1, *it2;
it1 = data1; it1 = data1;
it2 = data2; it2 = data2;

View File

@ -15,10 +15,10 @@ static void _cleanup(void);
static void _item_icon_get(Evry_Item *it, Evas *e); 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 void _item_add(const char *label, void (*action_cb) (E_Border *bd), const char *icon);
static Evry_Plugin *p; static Evry_Plugin *p;
static Inst *inst; static Inst *inst;
EAPI int EAPI int
evry_plug_border_act_init(void) evry_plug_border_act_init(void)
{ {
@ -45,9 +45,9 @@ EAPI int
evry_plug_border_act_shutdown(void) evry_plug_border_act_shutdown(void)
{ {
evry_plugin_unregister(p); evry_plugin_unregister(p);
E_FREE(p); E_FREE(p);
E_FREE(inst); E_FREE(inst);
return 1; return 1;
} }
@ -81,10 +81,10 @@ _fetch(const char *input)
_cleanup(); _cleanup();
_item_add(_("Iconify"), _act_cb_border_minimize, _item_add(_("Iconify"), _act_cb_border_minimize,
"e/widgets/border/default/minimize"); "e/widgets/border/default/minimize");
_item_add(_("Close"), _act_cb_border_close, _item_add(_("Close"), _act_cb_border_close,
"e/widgets/border/default/close"); "e/widgets/border/default/close");
return 1; return 1;
} }
@ -114,13 +114,13 @@ _cleanup(void)
static void static void
_item_add(const char *label, void (*action_cb) (E_Border *bd), const char *icon) _item_add(const char *label, void (*action_cb) (E_Border *bd), const char *icon)
{ {
Evry_Item *it; Evry_Item *it;
it = E_NEW(Evry_Item, 1); it = E_NEW(Evry_Item, 1);
it->data[0] = action_cb; it->data[0] = action_cb;
it->data[1] = (void *) eina_stringshare_add(icon); it->data[1] = (void *) eina_stringshare_add(icon);
it->label = eina_stringshare_add(label); it->label = eina_stringshare_add(label);
p->items = eina_list_append(p->items, it); p->items = eina_list_append(p->items, it);
} }
static void static void

View File

@ -1,10 +1,10 @@
#include "e.h"
#include "e_mod_main.h"
/* TODO /* TODO
* - dc support? * - dc support?
*/ */
#include "e.h"
#include "e_mod_main.h"
static int _begin(Evry_Item *it); static int _begin(Evry_Item *it);
static int _fetch(const char *input); static int _fetch(const char *input);
static int _action(Evry_Item *item, const char *input); static int _action(Evry_Item *item, const char *input);
@ -12,12 +12,9 @@ static void _cleanup(void);
static void _item_add(char *output, int prio); static void _item_add(char *output, int prio);
static int _cb_sort(const void *data1, const void *data2); static int _cb_sort(const void *data1, const void *data2);
static void _item_icon_get(Evry_Item *it, Evas *e); static void _item_icon_get(Evry_Item *it, Evas *e);
static int _cb_data(void *data, int type, void *event); static int _cb_data(void *data, int type, void *event);
static Evry_Plugin *p; static Evry_Plugin *p;
static Ecore_Exe *exe = NULL; static Ecore_Exe *exe = NULL;
static Eina_List *history = NULL; static Eina_List *history = NULL;
static Ecore_Event_Handler *data_handler = NULL; static Ecore_Event_Handler *data_handler = NULL;
@ -40,7 +37,7 @@ evry_plug_calc_init(void)
p->cleanup = &_cleanup; p->cleanup = &_cleanup;
p->icon_get = &_item_icon_get; p->icon_get = &_item_icon_get;
evry_plugin_register(p); evry_plugin_register(p);
return 1; return 1;
} }
@ -48,15 +45,15 @@ EAPI int
evry_plug_calc_shutdown(void) evry_plug_calc_shutdown(void)
{ {
Evry_Item *it; Evry_Item *it;
EINA_LIST_FREE(p->items, it) EINA_LIST_FREE(p->items, it)
{ {
if (it->label) eina_stringshare_del(it->label); if (it->label) eina_stringshare_del(it->label);
free(it); free(it);
} }
evry_plugin_unregister(p); evry_plugin_unregister(p);
E_FREE(p); E_FREE(p);
return 1; return 1;
} }
@ -66,7 +63,7 @@ _begin(Evry_Item *it)
{ {
data_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _cb_data, p); data_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _cb_data, p);
exe = ecore_exe_pipe_run("bc", exe = ecore_exe_pipe_run("bc",
ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_READ |
ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_READ_LINE_BUFFERED |
@ -77,9 +74,10 @@ _begin(Evry_Item *it)
static void static void
_cleanup() _cleanup()
{ {
Evry_Item *it; Evry_Item *it, *it2;
int i = 0; int i = 0;
Eina_List *l, *ll;
EINA_LIST_FREE(p->items, it) EINA_LIST_FREE(p->items, it)
{ {
if (i < 10) if (i < 10)
@ -95,7 +93,7 @@ _cleanup()
ecore_event_handler_del(data_handler); ecore_event_handler_del(data_handler);
data_handler = NULL; data_handler = NULL;
ecore_exe_quit(exe); ecore_exe_quit(exe);
exe = NULL; exe = NULL;
} }
@ -116,12 +114,36 @@ _action(Evry_Item *it, const char *input)
{ {
if (p->items) if (p->items)
{ {
Evry_Item *it2 = p->items->data; Eina_List *l;
Evry_Item *it2;
_item_add((char *) it2->label, 1);
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_CLEAR);
/* remove duplicates */
if (p->items->next)
{
EINA_LIST_FOREACH(p->items->next, l, it2)
{
if (!strcmp(it->label, it2->label))
break;
it2 = NULL;
}
if (it2)
{
p->items = eina_list_remove(p->items, it2);
eina_stringshare_del(it2->label);
E_FREE(it2);
}
}
it = p->items->data;
_item_add((char *) it->label, 1);
} }
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
return EVRY_ACTION_CONTINUE; return EVRY_ACTION_CONTINUE;
} }
else else
@ -150,28 +172,28 @@ _fetch(const char *input)
p->items = history; p->items = history;
history = NULL; history = NULL;
} }
_send_input(input); _send_input(input);
return 1; return 1;
} }
static void static void
_item_icon_get(Evry_Item *it, Evas *e) _item_icon_get(Evry_Item *it, Evas *e)
{ {
it->o_icon = NULL; it->o_icon = NULL;
} }
static void static void
_item_add(char *output, int prio) _item_add(char *output, int prio)
{ {
Evry_Item *it; Evry_Item *it;
it = E_NEW(Evry_Item, 1); it = E_NEW(Evry_Item, 1);
it->priority = prio; it->priority = prio;
it->label = eina_stringshare_add(output); it->label = eina_stringshare_add(output);
p->items = eina_list_prepend(p->items, it); p->items = eina_list_prepend(p->items, it);
} }
@ -180,7 +202,7 @@ _cb_data(void *data, int type, void *event)
{ {
Ecore_Exe_Event_Data *ev = event; Ecore_Exe_Event_Data *ev = event;
Ecore_Exe_Event_Data_Line *l; Ecore_Exe_Event_Data_Line *l;
if (data != p) return 1; if (data != p) return 1;
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_CLEAR); evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_CLEAR);
@ -199,6 +221,6 @@ _cb_data(void *data, int type, void *event)
} }
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
return 1; return 1;
} }

View File

@ -10,6 +10,7 @@ static int _cb_sort(const void *data1, const void *data2);
static Evry_Plugin *p; static Evry_Plugin *p;
EAPI int EAPI int
evry_plug_config_init(void) evry_plug_config_init(void)
{ {
@ -32,7 +33,7 @@ evry_plug_config_shutdown(void)
{ {
evry_plugin_unregister(p); evry_plugin_unregister(p);
E_FREE(p); E_FREE(p);
return 1; return 1;
} }
@ -47,7 +48,7 @@ _action(Evry_Item *it, const char *input)
int found = 0; int found = 0;
if (!it) return EVRY_ACTION_CONTINUE; if (!it) return EVRY_ACTION_CONTINUE;
eci = it->data[0]; eci = it->data[0];
con = e_container_current_get(e_manager_current_get()); con = e_container_current_get(e_manager_current_get());
@ -61,15 +62,15 @@ _action(Evry_Item *it, const char *input)
{ {
found = 1; found = 1;
snprintf(buf, sizeof(buf), "%s/%s", snprintf(buf, sizeof(buf), "%s/%s",
ecat->cat, ecat->cat,
eci->item); eci->item);
} }
} }
} }
if (found) if (found)
e_configure_registry_call(buf, con, NULL); e_configure_registry_call(buf, con, NULL);
return EVRY_ACTION_FINISHED; return EVRY_ACTION_FINISHED;
} }
@ -90,14 +91,14 @@ _fetch(const char *input)
{ {
E_Manager *man; E_Manager *man;
E_Zone *zone; E_Zone *zone;
char match1[4096]; char match1[4096];
char match2[4096]; char match2[4096];
Eina_List *l, *ll; Eina_List *l, *ll;
E_Configure_Cat *ecat; E_Configure_Cat *ecat;
E_Configure_It *eci; E_Configure_It *eci;
_cleanup(); _cleanup();
snprintf(match1, sizeof(match1), "%s*", input); snprintf(match1, sizeof(match1), "%s*", input);
snprintf(match2, sizeof(match2), "*%s*", input); snprintf(match2, sizeof(match2), "*%s*", input);
@ -124,7 +125,7 @@ _fetch(const char *input)
} }
} }
} }
if (eina_list_count(p->items) > 0) 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);
@ -139,8 +140,8 @@ _item_icon_get(Evry_Item *it, Evas *e)
{ {
E_Configure_It *eci = it->data[0]; E_Configure_It *eci = it->data[0];
Evas_Object *o = NULL; Evas_Object *o = NULL;
if (eci->icon) if (eci->icon)
{ {
o = e_icon_add(e); o = e_icon_add(e);
if (!e_util_icon_theme_set(o, eci->icon)) if (!e_util_icon_theme_set(o, eci->icon))
@ -156,14 +157,14 @@ _item_icon_get(Evry_Item *it, Evas *e)
static void static void
_item_add(E_Configure_It *eci, int prio) _item_add(E_Configure_It *eci, int prio)
{ {
Evry_Item *it; Evry_Item *it;
it = E_NEW(Evry_Item, 1); it = E_NEW(Evry_Item, 1);
it->data[0] = eci; it->data[0] = eci;
it->priority = prio; it->priority = prio;
it->label = eina_stringshare_add(eci->label); it->label = eina_stringshare_add(eci->label);
it->o_icon = NULL; it->o_icon = NULL;
p->items = eina_list_append(p->items, it); p->items = eina_list_append(p->items, it);
} }
@ -171,11 +172,11 @@ static int
_cb_sort(const void *data1, const void *data2) _cb_sort(const void *data1, const void *data2)
{ {
const Evry_Item *it1, *it2; const Evry_Item *it1, *it2;
it1 = data1; it1 = data1;
it2 = data2; it2 = data2;
/* TODO sort by name? */ /* TODO sort by name? */
return (it1->priority - it2->priority); return (it1->priority - it2->priority);
} }

View File

@ -21,6 +21,7 @@ static Evry_Item *_item_fill(const char *directory, const char *file);
static Evry_Plugin *p; static Evry_Plugin *p;
static Eina_List *stack = NULL; static Eina_List *stack = NULL;
EAPI int EAPI int
evry_plug_dir_browse_init(void) evry_plug_dir_browse_init(void)
{ {
@ -45,7 +46,7 @@ evry_plug_dir_browse_shutdown(void)
{ {
evry_plugin_unregister(p); evry_plugin_unregister(p);
E_FREE(p); E_FREE(p);
return 1; return 1;
} }
@ -53,30 +54,30 @@ static int
_begin(Evry_Item *it) _begin(Evry_Item *it)
{ {
State *s; State *s;
if (it) if (it)
{ {
if (!it->uri || !ecore_file_is_dir(it->uri)) if (!it->uri || !ecore_file_is_dir(it->uri))
return 0; return 0;
s = E_NEW(State, 1); s = E_NEW(State, 1);
s->directory = eina_stringshare_add(it->uri); s->directory = eina_stringshare_add(it->uri);
} }
else else
{ {
s = E_NEW(State, 1); s = E_NEW(State, 1);
s->directory = eina_stringshare_add(e_user_homedir_get()); s->directory = eina_stringshare_add(e_user_homedir_get());
} }
stack = eina_list_prepend(stack, s); stack = eina_list_prepend(stack, s);
p->items = NULL; p->items = NULL;
return 1; return 1;
} }
static int static int
_action(Evry_Item *it, const char *input) _action(Evry_Item *it, const char *input)
{ {
return EVRY_ACTION_OTHER; return EVRY_ACTION_OTHER;
} }
@ -95,20 +96,19 @@ _list_free()
} }
} }
static void static void
_cleanup() _cleanup()
{ {
State *s; State *s;
if (!stack) return; if (!stack) return;
s = stack->data; s = stack->data;
_list_free(); _list_free();
eina_stringshare_del(s->directory); eina_stringshare_del(s->directory);
E_FREE(s); E_FREE(s);
stack = eina_list_remove_list(stack, stack); stack = eina_list_remove_list(stack, stack);
@ -130,9 +130,9 @@ _fetch(const char *input)
char match1[4096]; char match1[4096];
char match2[4096]; char match2[4096];
State *s = stack->data; State *s = stack->data;
_list_free(); _list_free();
files = ecore_file_ls(s->directory); files = ecore_file_ls(s->directory);
if (input) if (input)
@ -144,13 +144,13 @@ _fetch(const char *input)
EINA_LIST_FREE(files, file) EINA_LIST_FREE(files, file)
{ {
it = NULL; it = NULL;
if (file[0] == '.') if (file[0] == '.')
{ {
free(file); free(file);
continue; continue;
} }
if (input) if (input)
{ {
if (e_util_glob_case_match(file, match1)) if (e_util_glob_case_match(file, match1))
@ -167,7 +167,7 @@ _fetch(const char *input)
{ {
it = _item_fill(s->directory, file); it = _item_fill(s->directory, file);
} }
if (it) if (it)
p->items = eina_list_append(p->items, it); p->items = eina_list_append(p->items, it);
@ -179,7 +179,7 @@ _fetch(const char *input)
p->items = eina_list_sort(p->items, eina_list_count(p->items), p->items = eina_list_sort(p->items, eina_list_count(p->items),
_cb_sort); _cb_sort);
s->items = p->items; s->items = p->items;
return 1; return 1;
} }
@ -197,7 +197,7 @@ _item_fill(const char *directory, const char *file)
it = E_NEW(Evry_Item, 1); it = E_NEW(Evry_Item, 1);
snprintf(buf, sizeof(buf), "%s/%s", directory, file); snprintf(buf, sizeof(buf), "%s/%s", directory, file);
if ((e_util_glob_case_match(file, "*.desktop")) || if ((e_util_glob_case_match(file, "*.desktop")) ||
(e_util_glob_case_match(file, "*.directory"))) (e_util_glob_case_match(file, "*.directory")))
{ {
@ -214,7 +214,7 @@ _item_fill(const char *directory, const char *file)
file_path = eina_stringshare_add(buf); file_path = eina_stringshare_add(buf);
it->uri = file_path; it->uri = file_path;
mime = efreet_mime_globs_type_get(file_path); mime = efreet_mime_globs_type_get(file_path);
if (mime) if (mime)
{ {
@ -231,12 +231,12 @@ _item_fill(const char *directory, const char *file)
it->mime = eina_stringshare_add(mime); it->mime = eina_stringshare_add(mime);
it->priority = 0; it->priority = 0;
} }
else else
{ {
it->mime = eina_stringshare_add("None"); it->mime = eina_stringshare_add("None");
it->priority = 0; it->priority = 0;
} }
return it; return it;
} }
@ -246,7 +246,7 @@ _item_icon_get(Evry_Item *it, Evas *e)
char *item_path; char *item_path;
if (!it->mime) return; if (!it->mime) return;
if (!strcmp(it->mime, "Folder")) if (!strcmp(it->mime, "Folder"))
{ {
it->o_icon = edje_object_add(e); it->o_icon = edje_object_add(e);
@ -270,11 +270,11 @@ static int
_cb_sort(const void *data1, const void *data2) _cb_sort(const void *data1, const void *data2)
{ {
const Evry_Item *it1, *it2; const Evry_Item *it1, *it2;
it1 = data1; it1 = data1;
it2 = data2; it2 = data2;
if (it2->priority - it1->priority) if (it2->priority - it1->priority)
return (it2->priority - it1->priority); return (it2->priority - it1->priority);
else else
return strcasecmp(it1->label, it2->label); return strcasecmp(it1->label, it2->label);