2009-05-06 07:20:45 -07:00
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
/* TODO */
|
|
|
|
/* - animations
|
2009-08-12 12:00:25 -07:00
|
|
|
* - mouse handlers
|
2009-08-10 04:36:37 -07:00
|
|
|
* - show item descriptions
|
|
|
|
* - keybinding configuration
|
|
|
|
* - shortcuts for plugins
|
|
|
|
*/
|
2010-03-15 06:10:43 -07:00
|
|
|
#define INPUTLEN 256
|
2010-04-12 09:31:40 -07:00
|
|
|
#define MATCH_LAG 0.15
|
2010-03-21 08:55:03 -07:00
|
|
|
#define INITIAL_MATCH_LAG 0.2
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2010-04-01 22:31:02 -07:00
|
|
|
/* #undef DBG
|
|
|
|
* #define DBG(...) ERR(__VA_ARGS__) */
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
typedef struct _Evry_Window Evry_Window;
|
|
|
|
typedef struct _Evry_List_Window Evry_List_Window;
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
struct _Evry_Window
|
|
|
|
{
|
|
|
|
E_Popup *popup;
|
|
|
|
Evas_Object *o_main;
|
|
|
|
|
2009-08-12 16:14:05 -07:00
|
|
|
Eina_Bool request_selection;
|
2009-08-18 17:27:41 -07:00
|
|
|
Eina_Bool plugin_dedicated;
|
2009-08-10 04:36:37 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Evry_List_Window
|
|
|
|
{
|
|
|
|
E_Popup *popup;
|
|
|
|
Evas_Object *o_main;
|
2009-08-21 15:42:06 -07:00
|
|
|
Eina_Bool visible;
|
2009-08-10 04:36:37 -07:00
|
|
|
};
|
|
|
|
|
2009-08-27 13:52:14 -07:00
|
|
|
static void _evry_matches_update(Evry_Selector *sel, int async);
|
2009-08-10 04:36:37 -07:00
|
|
|
static void _evry_plugin_action(Evry_Selector *sel, int finished);
|
2009-08-21 15:42:06 -07:00
|
|
|
static void _evry_plugin_select(Evry_State *s, Evry_Plugin *p);
|
|
|
|
static void _evry_plugin_list_insert(Evry_State *s, Evry_Plugin *p);
|
2010-04-04 07:11:35 -07:00
|
|
|
static int _evry_backspace(Evry_Selector *sel);
|
|
|
|
static void _evry_update(Evry_Selector *sel, int fetch);
|
2009-08-21 15:42:06 -07:00
|
|
|
static void _evry_update_text_label(Evry_State *s);
|
2010-04-04 07:11:35 -07:00
|
|
|
static int _evry_clear(Evry_Selector *sel);
|
|
|
|
static int _evry_cb_update_timer(void *data);
|
2009-08-21 15:42:06 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static Evry_State *_evry_state_new(Evry_Selector *sel, Eina_List *plugins);
|
|
|
|
static void _evry_state_pop(Evry_Selector *sel);
|
|
|
|
|
|
|
|
static Evry_Selector *_evry_selector_new(int type);
|
|
|
|
static void _evry_selector_free(Evry_Selector *sel);
|
|
|
|
static void _evry_selector_activate(Evry_Selector *sel);
|
2009-08-21 15:42:06 -07:00
|
|
|
static void _evry_selectors_switch(void);
|
2009-08-10 04:36:37 -07:00
|
|
|
static void _evry_selector_update(Evry_Selector *sel);
|
|
|
|
static void _evry_selector_icon_set(Evry_Selector *sel);
|
2009-08-18 17:27:41 -07:00
|
|
|
static int _evry_selector_subjects_get(const char *plugin_name);
|
2009-08-10 04:36:37 -07:00
|
|
|
static int _evry_selector_actions_get(Evry_Item *it);
|
2009-08-21 15:42:06 -07:00
|
|
|
static int _evry_selector_objects_get(Evry_Action *act);
|
|
|
|
|
|
|
|
static Evry_Window *_evry_window_new(E_Zone *zone);
|
|
|
|
static void _evry_window_free(Evry_Window *win);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
static Evry_List_Window *_evry_list_win_new(E_Zone *zone);
|
|
|
|
static void _evry_list_win_free(Evry_List_Window *win);
|
|
|
|
static void _evry_list_win_show(void);
|
2009-08-21 15:42:06 -07:00
|
|
|
static void _evry_list_win_update(Evry_State *s);
|
2009-08-16 20:30:04 -07:00
|
|
|
static void _evry_list_win_clear(int hide);
|
2009-08-17 16:54:16 -07:00
|
|
|
|
|
|
|
static void _evry_view_clear(Evry_State *s);
|
|
|
|
static void _evry_view_update(Evry_State *s, Evry_Plugin *plugin);
|
|
|
|
static int _evry_view_key_press(Evry_State *s, Ecore_Event_Key *ev);
|
2009-08-21 01:19:30 -07:00
|
|
|
static int _evry_view_toggle(Evry_State *s, const char *trigger);
|
2009-08-20 14:39:01 -07:00
|
|
|
static void _evry_view_show(Evry_View *v);
|
2010-04-17 12:13:01 -07:00
|
|
|
static void _evry_view_hide(Evry_View *v, int slide);
|
2009-08-17 16:54:16 -07:00
|
|
|
|
|
|
|
static void _evry_item_desel(Evry_State *s, Evry_Item *it);
|
|
|
|
static void _evry_item_sel(Evry_State *s, Evry_Item *it);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
static int _evry_cb_key_down(void *data, int type, void *event);
|
|
|
|
static int _evry_cb_selection_notify(void *data, int type, void *event);
|
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
/* local subsystem globals */
|
2009-08-10 04:36:37 -07:00
|
|
|
static Evry_Window *win = NULL;
|
|
|
|
static Evry_List_Window *list = NULL;
|
2009-06-08 09:01:27 -07:00
|
|
|
static Ecore_X_Window input_window = 0;
|
2009-06-24 13:02:37 -07:00
|
|
|
static Eina_List *handlers = NULL;
|
2009-08-27 19:25:13 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
static Evry_Selector *selector = NULL;
|
2009-08-25 13:52:40 -07:00
|
|
|
static const char *thumb_types = NULL;
|
2009-08-21 15:42:06 -07:00
|
|
|
|
2010-04-08 15:37:50 -07:00
|
|
|
Evry_Selector **selectors = NULL;
|
2010-04-04 07:11:35 -07:00
|
|
|
const char *action_selector;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
|
|
|
/* externally accessible functions */
|
2009-08-13 08:10:54 -07:00
|
|
|
int
|
2009-05-06 07:20:45 -07:00
|
|
|
evry_init(void)
|
|
|
|
{
|
2010-04-04 07:11:35 -07:00
|
|
|
action_selector = eina_stringshare_add(_("Select Action"));
|
2009-08-25 13:52:40 -07:00
|
|
|
thumb_types = eina_stringshare_add("FILE");
|
2009-05-06 07:20:45 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-13 08:10:54 -07:00
|
|
|
int
|
2009-05-06 07:20:45 -07:00
|
|
|
evry_shutdown(void)
|
|
|
|
{
|
|
|
|
evry_hide();
|
2009-08-21 15:42:06 -07:00
|
|
|
|
2009-08-25 13:52:40 -07:00
|
|
|
eina_stringshare_del(thumb_types);
|
2010-04-04 07:11:35 -07:00
|
|
|
eina_stringshare_del(action_selector);
|
2009-05-06 07:20:45 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-04-07 08:03:27 -07:00
|
|
|
static int
|
|
|
|
_evry_cb_item_changed(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Evry_Event_Item_Changed *ev = event;
|
|
|
|
Evry_Selector *sel;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
sel = selectors[i];
|
|
|
|
|
|
|
|
if (sel->state && sel->state->cur_item == ev->item)
|
|
|
|
{
|
2010-04-08 16:41:53 -07:00
|
|
|
_evry_selector_update(sel);
|
2010-04-07 08:03:27 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-04-08 16:29:35 -07:00
|
|
|
static Ecore_Timer *_show_timer = NULL;
|
|
|
|
|
|
|
|
static int
|
|
|
|
_cb_show_timer(void *data)
|
|
|
|
{
|
2010-04-08 16:41:53 -07:00
|
|
|
_show_timer = NULL;
|
|
|
|
|
2010-04-08 16:29:35 -07:00
|
|
|
if (evry_conf->views && selector->state)
|
|
|
|
{
|
2010-04-08 16:36:15 -07:00
|
|
|
Evry_View *view =evry_conf->views->data;
|
|
|
|
Evry_State *s = selector->state;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2010-04-20 11:49:42 -07:00
|
|
|
if (evry_conf->first_run)
|
|
|
|
{
|
|
|
|
_evry_view_toggle(s, "?");
|
|
|
|
evry_conf->first_run = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s->view = view->create(view, s, list->o_main);
|
|
|
|
|
|
|
|
_evry_view_show(s->view);
|
|
|
|
}
|
2010-04-08 16:29:35 -07:00
|
|
|
}
|
2010-04-22 11:15:59 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-08 16:29:35 -07:00
|
|
|
_evry_list_win_show();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-13 08:10:54 -07:00
|
|
|
int
|
2009-08-18 17:27:41 -07:00
|
|
|
evry_show(E_Zone *zone, const char *params)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
if (win) return 0;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
E_OBJECT_CHECK_RETURN(zone, 0);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
input_window = ecore_x_window_input_new(zone->container->win,
|
|
|
|
zone->x, zone->y,
|
|
|
|
zone->w, zone->h);
|
2009-08-10 04:36:37 -07:00
|
|
|
ecore_x_window_show(input_window);
|
|
|
|
if (!e_grabinput_get(input_window, 1, input_window))
|
2010-04-08 15:37:50 -07:00
|
|
|
goto error1;
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
win = _evry_window_new(zone);
|
2010-04-08 15:37:50 -07:00
|
|
|
if (!win) goto error2;
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
list = _evry_list_win_new(zone);
|
2010-04-08 15:37:50 -07:00
|
|
|
if (!list) goto error2;
|
2009-07-07 09:30:11 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
list->visible = EINA_FALSE;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-30 05:01:50 -07:00
|
|
|
evry_history_load();
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
selectors = E_NEW(Evry_Selector*, 3);
|
2009-08-10 04:36:37 -07:00
|
|
|
selectors[0] = _evry_selector_new(type_subject);
|
|
|
|
selectors[1] = _evry_selector_new(type_action);
|
|
|
|
selectors[2] = _evry_selector_new(type_object);
|
|
|
|
|
|
|
|
handlers = eina_list_append
|
|
|
|
(handlers, ecore_event_handler_add
|
|
|
|
(ECORE_EVENT_KEY_DOWN, _evry_cb_key_down, NULL));
|
2009-08-12 15:34:07 -07:00
|
|
|
handlers = eina_list_append
|
|
|
|
(handlers, ecore_event_handler_add
|
|
|
|
(ECORE_X_EVENT_SELECTION_NOTIFY,
|
|
|
|
_evry_cb_selection_notify, win));
|
2010-04-07 08:03:27 -07:00
|
|
|
handlers = eina_list_append
|
|
|
|
(handlers, ecore_event_handler_add
|
|
|
|
(EVRY_EVENT_ITEM_CHANGED,
|
|
|
|
_evry_cb_item_changed, NULL));
|
2009-08-12 15:34:07 -07:00
|
|
|
|
2009-08-25 17:36:59 -07:00
|
|
|
e_popup_layer_set(list->popup, 255);
|
|
|
|
e_popup_layer_set(win->popup, 255);
|
|
|
|
e_popup_show(win->popup);
|
|
|
|
e_popup_show(list->popup);
|
2009-08-25 20:12:00 -07:00
|
|
|
|
2010-04-08 22:35:07 -07:00
|
|
|
if (params)
|
|
|
|
win->plugin_dedicated = EINA_TRUE;
|
|
|
|
|
|
|
|
_evry_selector_subjects_get(params);
|
|
|
|
_evry_selector_update(selectors[0]);
|
|
|
|
_evry_selector_activate(selectors[0]);
|
|
|
|
|
2009-08-30 01:51:15 -07:00
|
|
|
if (!evry_conf->hide_input)
|
|
|
|
{
|
|
|
|
edje_object_part_text_set(win->o_main, "e.text.label", "Search:");
|
|
|
|
edje_object_part_text_set(list->o_main, "e.text.label", "Search:");
|
2010-04-08 22:35:07 -07:00
|
|
|
edje_object_signal_emit(list->o_main, "e,state,entry_show", "e");
|
2009-08-30 01:51:15 -07:00
|
|
|
}
|
2010-03-28 13:15:27 -07:00
|
|
|
|
|
|
|
if (!evry_conf->hide_list)
|
2010-04-22 11:15:59 -07:00
|
|
|
_show_timer = ecore_timer_add(0.01, _cb_show_timer, NULL);
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return 1;
|
2009-07-07 09:30:11 -07:00
|
|
|
|
2010-04-08 15:37:50 -07:00
|
|
|
error2:
|
2009-08-10 04:36:37 -07:00
|
|
|
if (win)
|
|
|
|
_evry_window_free(win);
|
|
|
|
if (list)
|
|
|
|
_evry_list_win_free(list);
|
|
|
|
win = NULL;
|
|
|
|
list = NULL;
|
2010-04-08 15:37:50 -07:00
|
|
|
|
|
|
|
error1:
|
2009-08-10 04:36:37 -07:00
|
|
|
ecore_x_window_free(input_window);
|
|
|
|
input_window = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-13 08:10:54 -07:00
|
|
|
void
|
2009-08-10 04:36:37 -07:00
|
|
|
evry_hide(void)
|
|
|
|
{
|
2009-12-23 13:46:39 -08:00
|
|
|
Ecore_Event_Handler *ev;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!win) return;
|
|
|
|
|
2010-04-08 15:37:50 -07:00
|
|
|
/* _evry_view_clear(selector->state); */
|
2010-04-08 16:29:35 -07:00
|
|
|
if (_show_timer)
|
2010-04-08 16:41:53 -07:00
|
|
|
ecore_timer_del(_show_timer);
|
2010-04-08 16:29:35 -07:00
|
|
|
_show_timer = NULL;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
list->visible = EINA_FALSE;
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_free(selectors[0]);
|
|
|
|
_evry_selector_free(selectors[1]);
|
|
|
|
_evry_selector_free(selectors[2]);
|
2009-08-21 15:42:06 -07:00
|
|
|
E_FREE(selectors);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2010-04-08 15:37:50 -07:00
|
|
|
selectors = NULL;
|
|
|
|
selector = NULL;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_list_win_free(list);
|
|
|
|
list = NULL;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_window_free(win);
|
|
|
|
win = NULL;
|
2009-07-07 09:30:11 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
EINA_LIST_FREE(handlers, ev)
|
|
|
|
ecore_event_handler_del(ev);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
ecore_x_window_free(input_window);
|
|
|
|
e_grabinput_release(input_window, input_window);
|
|
|
|
input_window = 0;
|
2009-08-30 05:01:50 -07:00
|
|
|
|
|
|
|
evry_history_unload();
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-22 14:22:38 -07:00
|
|
|
EAPI void
|
2009-08-10 04:36:37 -07:00
|
|
|
evry_clear_input(void)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_State *s = selector->state;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2010-04-22 16:03:47 -07:00
|
|
|
if (s->inp[0] != 0)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2010-04-22 16:03:47 -07:00
|
|
|
s->inp[0] = 0;
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2010-04-22 16:03:47 -07:00
|
|
|
s->input = s->inp;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2010-03-14 10:53:13 -07:00
|
|
|
//#define CHECK_REFS 1
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2010-03-14 10:53:13 -07:00
|
|
|
#ifdef CHECK_REFS
|
2009-08-27 03:35:32 -07:00
|
|
|
static int item_cnt = 0;
|
|
|
|
#endif
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2009-08-22 14:22:38 -07:00
|
|
|
EAPI Evry_Item *
|
2009-08-22 20:12:05 -07:00
|
|
|
evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label, void (*cb_free) (Evry_Item *item))
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Item *it;
|
2009-08-22 20:12:05 -07:00
|
|
|
if (base)
|
|
|
|
{
|
|
|
|
it = base;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
it = E_NEW(Evry_Item, 1);
|
|
|
|
if (!it) return NULL;
|
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
it->plugin = p;
|
|
|
|
if (label) it->label = eina_stringshare_add(label);
|
2009-08-21 19:11:35 -07:00
|
|
|
it->free = cb_free;
|
2009-08-19 05:07:37 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
it->ref = 1;
|
2010-04-19 00:26:56 -07:00
|
|
|
/* it->usage = -1; */
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2009-08-27 03:35:32 -07:00
|
|
|
#ifdef CHECK_REFS
|
|
|
|
item_cnt++;
|
|
|
|
#endif
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return it;
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
|
|
|
|
2009-08-22 14:22:38 -07:00
|
|
|
EAPI void
|
2009-08-10 04:36:37 -07:00
|
|
|
evry_item_free(Evry_Item *it)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-13 15:42:40 -07:00
|
|
|
if (!it) return;
|
|
|
|
|
|
|
|
it->ref--;
|
|
|
|
|
2009-08-27 03:35:32 -07:00
|
|
|
#ifdef CHECK_REFS
|
|
|
|
printf("%d, %d\t free: %s\n", it->ref, item_cnt - 1, it->label);
|
|
|
|
#endif
|
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
if (it->ref > 0) return;
|
|
|
|
|
2009-08-27 03:35:32 -07:00
|
|
|
#ifdef CHECK_REFS
|
|
|
|
item_cnt--;
|
|
|
|
#endif
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (it->label) eina_stringshare_del(it->label);
|
2009-08-30 06:35:06 -07:00
|
|
|
if (it->id) eina_stringshare_del(it->id);
|
2009-09-03 07:21:27 -07:00
|
|
|
if (it->context) eina_stringshare_del(it->context);
|
2010-04-13 15:15:56 -07:00
|
|
|
if (it->detail) eina_stringshare_del(it->detail);
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
if (it->free)
|
|
|
|
it->free(it);
|
|
|
|
else
|
|
|
|
E_FREE(it);
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
|
|
|
|
2010-04-17 21:41:08 -07:00
|
|
|
EAPI int
|
|
|
|
evry_item_type_check(const Evry_Item *it, const char *type)
|
|
|
|
{
|
|
|
|
if (it && it->plugin && it->plugin->type_out)
|
|
|
|
return (!strcmp(it->plugin->type_out, type));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-01 22:31:02 -07:00
|
|
|
static Evry_Selector *
|
2010-04-17 10:50:27 -07:00
|
|
|
_evry_selector_for_plugin_get(Evry_Plugin *p)
|
2010-04-01 22:31:02 -07:00
|
|
|
{
|
|
|
|
Evry_State *s;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
s = selectors[i]->state;
|
|
|
|
if (s && eina_list_data_find(s->plugins, p))
|
|
|
|
return selectors[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-08-22 14:22:38 -07:00
|
|
|
EAPI void
|
2009-08-17 16:54:16 -07:00
|
|
|
evry_item_select(const Evry_State *state, Evry_Item *it)
|
|
|
|
{
|
|
|
|
Evry_State *s = (Evry_State *)state;
|
2010-04-02 09:28:19 -07:00
|
|
|
Evry_Selector *sel = selector;
|
2009-08-17 16:54:16 -07:00
|
|
|
|
|
|
|
s->plugin_auto_selected = EINA_FALSE;
|
|
|
|
s->item_auto_selected = EINA_FALSE;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_item_sel(s, it);
|
2010-04-07 08:03:27 -07:00
|
|
|
|
|
|
|
if (s == sel->state)
|
2010-04-11 07:29:23 -07:00
|
|
|
_evry_selector_update(sel);
|
2009-08-17 16:54:16 -07:00
|
|
|
}
|
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
EAPI void
|
|
|
|
evry_item_mark(const Evry_State *state, Evry_Item *it, Eina_Bool mark)
|
|
|
|
{
|
|
|
|
Evry_State *s = (Evry_State *)state;
|
|
|
|
|
|
|
|
if (mark)
|
|
|
|
s->sel_items = eina_list_append(s->sel_items, it);
|
|
|
|
else
|
|
|
|
s->sel_items = eina_list_remove(s->sel_items, it);
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
/* s->plugin_auto_selected = EINA_FALSE;
|
|
|
|
* s->item_auto_selected = EINA_FALSE;
|
|
|
|
* _evry_item_sel(s, it);
|
|
|
|
* _evry_selector_update(selector); */
|
|
|
|
}
|
|
|
|
|
2009-08-22 14:22:38 -07:00
|
|
|
EAPI void
|
2009-08-17 16:54:16 -07:00
|
|
|
evry_item_ref(Evry_Item *it)
|
2009-08-13 15:42:40 -07:00
|
|
|
{
|
|
|
|
it->ref++;
|
|
|
|
}
|
|
|
|
|
2009-08-22 14:22:38 -07:00
|
|
|
EAPI int
|
2009-08-17 16:54:16 -07:00
|
|
|
evry_list_win_show(void)
|
|
|
|
{
|
|
|
|
if (list->visible) return 0;
|
|
|
|
|
|
|
|
_evry_list_win_show();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-22 14:22:38 -07:00
|
|
|
EAPI void
|
2009-08-17 16:54:16 -07:00
|
|
|
evry_list_win_hide(void)
|
|
|
|
{
|
|
|
|
_evry_list_win_clear(1);
|
|
|
|
}
|
|
|
|
|
2009-08-22 14:22:38 -07:00
|
|
|
EAPI void
|
2009-08-14 02:35:51 -07:00
|
|
|
evry_plugin_async_update(Evry_Plugin *p, int action)
|
|
|
|
{
|
|
|
|
Evry_State *s;
|
|
|
|
Evry_Plugin *agg;
|
2010-04-01 22:31:02 -07:00
|
|
|
Evry_Selector *sel;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-14 02:35:51 -07:00
|
|
|
if (!win) return;
|
|
|
|
|
2010-04-01 22:31:02 -07:00
|
|
|
DBG("plugin: %s", p->name);
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2010-04-17 10:50:27 -07:00
|
|
|
sel = _evry_selector_for_plugin_get(p);
|
2010-04-01 22:31:02 -07:00
|
|
|
if (!sel || !sel->state) return;
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2010-04-01 22:31:02 -07:00
|
|
|
s = sel->state;
|
|
|
|
agg = sel->aggregator;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-14 02:35:51 -07:00
|
|
|
if (action == EVRY_ASYNC_UPDATE_ADD)
|
|
|
|
{
|
|
|
|
if (!p->items)
|
|
|
|
{
|
|
|
|
/* remove plugin */
|
|
|
|
if (!eina_list_data_find(s->cur_plugins, p)) return;
|
|
|
|
|
|
|
|
s->cur_plugins = eina_list_remove(s->cur_plugins, p);
|
2010-04-17 10:50:27 -07:00
|
|
|
|
2009-08-14 02:35:51 -07:00
|
|
|
if (s->plugin == p)
|
2009-08-20 14:39:01 -07:00
|
|
|
_evry_plugin_select(s, NULL);
|
2009-08-14 02:35:51 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* add plugin to current plugins*/
|
|
|
|
_evry_plugin_list_insert(s, p);
|
|
|
|
|
|
|
|
if (!s->plugin || !eina_list_data_find_list(s->cur_plugins, s->plugin))
|
2009-08-20 14:39:01 -07:00
|
|
|
_evry_plugin_select(s, NULL);
|
2009-08-14 02:35:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* update aggregator */
|
2010-04-01 21:19:38 -07:00
|
|
|
if ((eina_list_count(s->cur_plugins) > 1 ) ||
|
|
|
|
/* add aggregator for actions */
|
2010-04-01 22:31:02 -07:00
|
|
|
(sel == selectors[1] &&
|
2010-04-01 21:19:38 -07:00
|
|
|
(eina_list_count(s->cur_plugins) > 0 )))
|
2009-08-14 02:35:51 -07:00
|
|
|
{
|
|
|
|
/* add aggregator */
|
|
|
|
if (!(s->cur_plugins->data == agg))
|
|
|
|
{
|
|
|
|
s->cur_plugins = eina_list_prepend(s->cur_plugins, agg);
|
|
|
|
|
|
|
|
if (s->plugin_auto_selected)
|
2010-04-11 07:29:23 -07:00
|
|
|
_evry_plugin_select(s, NULL);
|
2009-08-14 02:35:51 -07:00
|
|
|
}
|
2009-08-31 03:30:55 -07:00
|
|
|
agg->fetch(agg, s->input[0] ? s->input : NULL);
|
2009-08-14 02:35:51 -07:00
|
|
|
}
|
2009-08-20 16:43:56 -07:00
|
|
|
else
|
|
|
|
{
|
2009-08-20 17:15:29 -07:00
|
|
|
if (s->cur_plugins && s->cur_plugins->data == agg)
|
2009-08-20 16:43:56 -07:00
|
|
|
{
|
|
|
|
agg->cleanup(agg);
|
|
|
|
s->cur_plugins = eina_list_remove(s->cur_plugins, agg);
|
|
|
|
}
|
|
|
|
}
|
2009-08-14 02:35:51 -07:00
|
|
|
|
|
|
|
/* plugin is visible */
|
|
|
|
if ((s->plugin == p) || (s->plugin == agg))
|
2010-04-01 22:31:02 -07:00
|
|
|
{
|
|
|
|
_evry_selector_update(sel);
|
|
|
|
}
|
2010-04-17 10:50:27 -07:00
|
|
|
|
2009-08-20 14:39:01 -07:00
|
|
|
_evry_view_update(s, NULL);
|
2009-08-14 02:35:51 -07:00
|
|
|
}
|
2010-04-01 21:19:38 -07:00
|
|
|
else if (action == EVRY_ASYNC_UPDATE_REFRESH)
|
2010-03-14 10:53:13 -07:00
|
|
|
{
|
2010-04-08 16:41:53 -07:00
|
|
|
_evry_view_clear(s);
|
2010-04-01 21:19:38 -07:00
|
|
|
_evry_view_update(s, NULL);
|
2010-03-14 10:53:13 -07:00
|
|
|
}
|
2009-08-14 02:35:51 -07:00
|
|
|
}
|
|
|
|
|
2009-08-15 11:09:13 -07:00
|
|
|
|
2009-08-14 02:35:51 -07:00
|
|
|
/* local subsystem functions */
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static Evry_List_Window *
|
|
|
|
_evry_list_win_new(E_Zone *zone)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-30 11:34:39 -07:00
|
|
|
int x, y, w, mw, mh;
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_List_Window *list_win;
|
|
|
|
E_Popup *popup;
|
|
|
|
Evas_Object *o;
|
2010-04-16 10:24:35 -07:00
|
|
|
const char *tmp;
|
2010-04-20 14:20:30 -07:00
|
|
|
int offset_x, offset_y, offset_s = 0;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (!evry_conf->views) return NULL;
|
2009-08-16 10:12:18 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
popup = e_popup_new(zone, 0, 0, 1, 1);
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!popup) return NULL;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
list_win = E_NEW(Evry_List_Window, 1);
|
|
|
|
if (!list_win)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
e_object_del(E_OBJECT(popup));
|
|
|
|
return NULL;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
list_win->popup = popup;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
o = edje_object_add(popup->evas);
|
2009-08-10 04:36:37 -07:00
|
|
|
list_win->o_main = o;
|
2009-05-06 07:20:45 -07:00
|
|
|
e_theme_edje_object_set(o, "base/theme/everything",
|
2009-08-20 14:39:01 -07:00
|
|
|
"e/modules/everything/list");
|
2009-08-28 23:29:24 -07:00
|
|
|
|
2010-04-16 10:24:35 -07:00
|
|
|
tmp = edje_object_data_get(o, "offset_x");
|
|
|
|
offset_x = tmp ? atoi(tmp) : 0;
|
|
|
|
tmp = edje_object_data_get(o, "offset_y");
|
|
|
|
offset_y = tmp ? atoi(tmp) : 0;
|
|
|
|
|
2009-08-28 23:29:24 -07:00
|
|
|
if (e_config->use_composite)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(o, "e,state,composited", "e");
|
|
|
|
edje_object_message_signal_process(o);
|
|
|
|
edje_object_calc_force(o);
|
2010-04-16 10:24:35 -07:00
|
|
|
|
|
|
|
tmp = edje_object_data_get(o, "shadow_offset");
|
|
|
|
offset_s = tmp ? atoi(tmp) : 0;
|
|
|
|
offset_y -= offset_s;
|
2009-08-30 11:34:39 -07:00
|
|
|
}
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-28 22:08:06 -07:00
|
|
|
edje_object_size_min_calc(o, &mw, &mh);
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-16 10:12:18 -07:00
|
|
|
if (mh == 0) mh = 200;
|
|
|
|
if (mw == 0) mw = win->popup->w / 2;
|
|
|
|
|
2009-08-30 11:34:39 -07:00
|
|
|
evry_conf->min_h = mh;
|
2010-04-08 16:41:53 -07:00
|
|
|
if (evry_conf->height > mh)
|
2009-08-30 11:34:39 -07:00
|
|
|
mh = evry_conf->height;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2010-04-16 10:24:35 -07:00
|
|
|
x = win->popup->x + offset_x;
|
|
|
|
y = (win->popup->y + win->popup->h) + offset_y;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2010-04-16 10:24:35 -07:00
|
|
|
w = win->popup->w - offset_x*2;
|
|
|
|
mh += offset_s;
|
2009-08-30 11:34:39 -07:00
|
|
|
e_popup_move_resize(popup, x, y, w, mh);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
o = list_win->o_main;
|
2009-05-06 07:20:45 -07:00
|
|
|
evas_object_move(o, 0, 0);
|
2009-08-10 04:36:37 -07:00
|
|
|
evas_object_resize(o, list_win->popup->w, list_win->popup->h);
|
2009-05-06 07:20:45 -07:00
|
|
|
evas_object_show(o);
|
|
|
|
e_popup_edje_bg_object_set(popup, o);
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return list_win;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
|
|
|
_evry_list_win_free(Evry_List_Window *list_win)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
e_popup_hide(list_win->popup);
|
|
|
|
evas_event_freeze(list_win->popup->evas);
|
|
|
|
evas_object_del(list_win->o_main);
|
|
|
|
e_object_del(E_OBJECT(list_win->popup));
|
|
|
|
|
|
|
|
E_FREE(list_win);
|
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
|
|
|
_evry_list_win_show(void)
|
|
|
|
{
|
|
|
|
if (list->visible) return;
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
list->visible = EINA_TRUE;
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_list_win_update(selector->state);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
edje_object_signal_emit(list->o_main, "e,state,list_show", "e");
|
2009-08-25 17:36:59 -07:00
|
|
|
edje_object_signal_emit(list->o_main, "e,state,entry_show", "e");
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
2009-08-16 20:30:04 -07:00
|
|
|
_evry_list_win_clear(int hide)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
|
|
|
if (!list->visible) return;
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (selector->state)
|
|
|
|
_evry_view_clear(selector->state);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-16 20:30:04 -07:00
|
|
|
if (hide)
|
|
|
|
{
|
|
|
|
list->visible = EINA_FALSE;
|
|
|
|
edje_object_signal_emit(list->o_main, "e,state,list_hide", "e");
|
2009-08-25 17:36:59 -07:00
|
|
|
if (evry_conf->hide_input &&
|
|
|
|
(!selector->state || !selector->state->input ||
|
|
|
|
strlen(selector->state->input) == 0))
|
|
|
|
edje_object_signal_emit(list->o_main, "e,state,entry_hide", "e");
|
2009-08-16 20:30:04 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-07-29 13:43:09 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static Evry_Window *
|
|
|
|
_evry_window_new(E_Zone *zone)
|
|
|
|
{
|
|
|
|
int x, y, mw, mh;
|
|
|
|
Evry_Window *win;
|
|
|
|
E_Popup *popup;
|
|
|
|
Evas_Object *o;
|
2010-04-16 10:24:35 -07:00
|
|
|
const char *tmp;
|
|
|
|
int offset_s = 0;
|
|
|
|
|
2009-08-16 10:12:18 -07:00
|
|
|
popup = e_popup_new(zone, 0, 0, 1, 1);
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!popup) return NULL;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
win = E_NEW(Evry_Window, 1);
|
|
|
|
if (!win)
|
|
|
|
{
|
|
|
|
e_object_del(E_OBJECT(popup));
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
win->popup = popup;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
o = edje_object_add(popup->evas);
|
|
|
|
win->o_main = o;
|
|
|
|
e_theme_edje_object_set(o, "base/theme/everything",
|
2009-08-20 14:39:01 -07:00
|
|
|
"e/modules/everything/main");
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-28 23:29:24 -07:00
|
|
|
if (e_config->use_composite)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(o, "e,state,composited", "e");
|
|
|
|
edje_object_message_signal_process(o);
|
|
|
|
edje_object_calc_force(o);
|
2010-04-16 10:24:35 -07:00
|
|
|
|
|
|
|
tmp = edje_object_data_get(o, "shadow_offset");
|
|
|
|
offset_s = tmp ? atoi(tmp) : 0;
|
2009-08-28 23:29:24 -07:00
|
|
|
}
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-28 22:08:06 -07:00
|
|
|
edje_object_size_min_calc(o, &mw, &mh);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2010-04-08 16:41:53 -07:00
|
|
|
if (evry_conf->width > mw)
|
2009-08-30 11:34:39 -07:00
|
|
|
mw = evry_conf->width;
|
2010-04-17 10:50:27 -07:00
|
|
|
evry_conf->width = mw;
|
|
|
|
|
2010-04-16 10:24:35 -07:00
|
|
|
mw += offset_s*2;
|
|
|
|
mh += offset_s*2;
|
2009-09-17 23:33:33 -07:00
|
|
|
x = (zone->w * evry_conf->rel_x) - (mw / 2);
|
|
|
|
y = (zone->h * evry_conf->rel_y) - (mh / 2);
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
e_popup_move_resize(popup, x, y, mw, mh);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
o = win->o_main;
|
|
|
|
e_popup_edje_bg_object_set(win->popup, o);
|
|
|
|
evas_object_move(o, 0, 0);
|
|
|
|
evas_object_resize(o, mw, mh);
|
|
|
|
evas_object_show(o);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
ecore_x_netwm_window_type_set(popup->evas_win, ECORE_X_WINDOW_TYPE_UTILITY);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return win;
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
|
|
|
_evry_window_free(Evry_Window *win)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
e_popup_hide(win->popup);
|
|
|
|
evas_event_freeze(win->popup->evas);
|
|
|
|
evas_object_del(win->o_main);
|
2009-08-25 17:36:59 -07:00
|
|
|
/* evas_event_thaw(win->popup->evas); */
|
2009-08-10 04:36:37 -07:00
|
|
|
e_object_del(E_OBJECT(win->popup));
|
|
|
|
E_FREE(win);
|
|
|
|
}
|
2009-08-25 13:52:40 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static Evry_Selector *
|
|
|
|
_evry_selector_new(int type)
|
|
|
|
{
|
|
|
|
Evry_Plugin *p;
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Selector *sel = E_NEW(Evry_Selector, 1);
|
|
|
|
Evas_Object *o = edje_object_add(win->popup->evas);
|
|
|
|
sel->o_main = o;
|
|
|
|
e_theme_edje_object_set(o, "base/theme/everything",
|
2009-08-20 14:39:01 -07:00
|
|
|
"e/modules/everything/selector_item");
|
2009-08-10 04:36:37 -07:00
|
|
|
evas_object_show(o);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (type == type_subject)
|
2009-08-30 01:51:15 -07:00
|
|
|
{
|
|
|
|
sel->history = evry_hist->subjects;
|
2010-04-04 07:11:35 -07:00
|
|
|
sel->actions = evry_plug_actions_new(type_subject);
|
2009-08-30 01:51:15 -07:00
|
|
|
edje_object_part_swallow(win->o_main, "e.swallow.subject_selector", o);
|
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
else if (type == type_action)
|
2009-08-30 01:51:15 -07:00
|
|
|
{
|
|
|
|
sel->history = evry_hist->actions;
|
2010-04-04 07:11:35 -07:00
|
|
|
sel->actions = evry_plug_actions_new(type_action);
|
2009-08-30 01:51:15 -07:00
|
|
|
edje_object_part_swallow(win->o_main, "e.swallow.action_selector", o);
|
2010-04-08 16:41:53 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
else if (type == type_object)
|
2009-08-30 01:51:15 -07:00
|
|
|
{
|
|
|
|
sel->history = evry_hist->subjects;
|
|
|
|
edje_object_part_swallow(win->o_main, "e.swallow.object_selector", o);
|
|
|
|
}
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
p = evry_plug_aggregator_new(sel);
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
sel->plugins = eina_list_append(sel->plugins, p);
|
|
|
|
sel->aggregator = p;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
EINA_LIST_FOREACH(evry_conf->plugins, l, p)
|
2009-07-10 08:47:19 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!p->config->enabled) continue;
|
|
|
|
if (p->type != type) continue;
|
|
|
|
sel->plugins = eina_list_append(sel->plugins, p);
|
2009-07-10 08:47:19 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return sel;
|
2009-07-10 08:47:19 -07:00
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
|
|
|
_evry_selector_free(Evry_Selector *sel)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-25 22:14:08 -07:00
|
|
|
if (sel->do_thumb)
|
|
|
|
e_thumb_icon_end(sel->o_thumb);
|
|
|
|
if (sel->o_thumb)
|
|
|
|
evas_object_del(sel->o_thumb);
|
2009-08-10 04:36:37 -07:00
|
|
|
if (sel->o_icon)
|
|
|
|
evas_object_del(sel->o_icon);
|
2009-08-25 13:52:40 -07:00
|
|
|
if (sel->o_main)
|
|
|
|
evas_object_del(sel->o_main);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (list->visible && (sel == selector))
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_clear(sel->state);
|
2010-04-10 15:38:05 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
while (sel->states)
|
|
|
|
_evry_state_pop(sel);
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2010-04-11 06:40:10 -07:00
|
|
|
if (sel->aggregator)
|
|
|
|
evry_plugin_free(sel->aggregator, 1);
|
|
|
|
|
2010-04-04 07:11:35 -07:00
|
|
|
if (sel->actions)
|
2010-04-08 16:41:53 -07:00
|
|
|
evry_plug_actions_free(sel->actions);
|
2010-04-04 07:11:35 -07:00
|
|
|
|
2009-08-12 05:17:43 -07:00
|
|
|
if (sel->plugins) eina_list_free(sel->plugins);
|
2009-08-25 13:52:40 -07:00
|
|
|
|
2010-04-04 07:11:35 -07:00
|
|
|
if (sel->update_timer)
|
|
|
|
ecore_timer_del(sel->update_timer);
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
E_FREE(sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evry_selector_activate(Evry_Selector *sel)
|
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
Evry_State *s;
|
2009-08-16 19:06:41 -07:00
|
|
|
|
2009-08-12 13:26:27 -07:00
|
|
|
if (selector)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
s = selector->state;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-12 11:47:46 -07:00
|
|
|
edje_object_signal_emit(selector->o_main, "e,state,unselected", "e");
|
2009-08-10 04:36:37 -07:00
|
|
|
edje_object_part_text_set(selector->o_main, "e.text.plugin", "");
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (s && s->view)
|
2009-08-19 05:07:37 -07:00
|
|
|
{
|
2010-04-17 12:13:01 -07:00
|
|
|
/* s->view->clear(s->view, 0); */
|
|
|
|
_evry_view_hide(s->view, 0);
|
2009-08-19 05:07:37 -07:00
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
|
2009-08-16 20:30:04 -07:00
|
|
|
_evry_list_win_clear(evry_conf->hide_list);
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
selector = sel;
|
2009-08-17 16:54:16 -07:00
|
|
|
s = selector->state;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
edje_object_signal_emit(sel->o_main, "e,state,selected", "e");
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-16 19:06:41 -07:00
|
|
|
if (s)
|
2009-07-04 04:10:28 -07:00
|
|
|
{
|
2009-08-16 19:06:41 -07:00
|
|
|
_evry_update_text_label(s);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
if (sel->state->cur_item)
|
2009-08-10 04:36:37 -07:00
|
|
|
edje_object_part_text_set(sel->o_main, "e.text.plugin",
|
2010-04-15 14:42:30 -07:00
|
|
|
s->cur_item->plugin->label);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-20 14:39:01 -07:00
|
|
|
_evry_view_show(s->view);
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_list_win_update(s);
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-25 22:14:08 -07:00
|
|
|
static void
|
|
|
|
_evry_selector_thumb_gen(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Evas_Coord w, h;
|
|
|
|
Evry_Selector *sel = data;
|
|
|
|
|
|
|
|
if (sel->o_icon)
|
2010-04-22 11:15:59 -07:00
|
|
|
{
|
|
|
|
evas_object_del(sel->o_icon);
|
|
|
|
sel->o_icon = NULL;
|
|
|
|
}
|
|
|
|
|
2009-08-25 22:14:08 -07:00
|
|
|
e_icon_size_get(sel->o_thumb, &w, &h);
|
|
|
|
edje_extern_object_aspect_set(sel->o_thumb, EDJE_ASPECT_CONTROL_BOTH, w, h);
|
|
|
|
edje_object_part_swallow(sel->o_main, "e.swallow.thumb", sel->o_thumb);
|
|
|
|
evas_object_show(sel->o_thumb);
|
|
|
|
edje_object_signal_emit(sel->o_main, "e,action,thumb,show", "e");
|
|
|
|
sel->do_thumb = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_evry_selector_thumb(Evry_Selector *sel, const Evry_Item *it)
|
|
|
|
{
|
|
|
|
Evas_Coord w, h;
|
|
|
|
|
|
|
|
if (sel->do_thumb)
|
|
|
|
e_thumb_icon_end(sel->o_thumb);
|
|
|
|
|
|
|
|
if (sel->o_thumb)
|
|
|
|
evas_object_del(sel->o_thumb);
|
|
|
|
sel->o_thumb = NULL;
|
|
|
|
|
|
|
|
if (it->plugin->type_out != thumb_types) return 0;
|
|
|
|
|
|
|
|
ITEM_FILE(file, it);
|
|
|
|
|
2010-04-07 08:03:27 -07:00
|
|
|
if (!file->path || !file->mime) return 0;
|
2009-08-25 22:14:08 -07:00
|
|
|
|
|
|
|
if (!strncmp(file->mime, "image/", 6))
|
|
|
|
{
|
|
|
|
sel->o_thumb = e_thumb_icon_add(win->popup->evas);
|
|
|
|
evas_object_smart_callback_add(sel->o_thumb, "e_thumb_gen", _evry_selector_thumb_gen, sel);
|
|
|
|
edje_object_part_geometry_get(sel->o_main, "e.swallow.thumb", NULL, NULL, &w, &h);
|
2010-04-07 08:03:27 -07:00
|
|
|
e_thumb_icon_file_set(sel->o_thumb, file->path, NULL);
|
2009-08-25 22:14:08 -07:00
|
|
|
e_thumb_icon_size_set(sel->o_thumb, w, h);
|
|
|
|
e_thumb_icon_begin(sel->o_thumb);
|
|
|
|
sel->do_thumb = EINA_TRUE;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-08-25 13:52:40 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
|
|
|
_evry_selector_icon_set(Evry_Selector *sel)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_State *s = sel->state;
|
|
|
|
Evry_Item *it;
|
|
|
|
Evas_Object *o;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!edje_object_part_exists(sel->o_main, "e.swallow.icons")) return;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (sel->o_icon)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
evas_object_del(sel->o_icon);
|
|
|
|
sel->o_icon = NULL;
|
|
|
|
}
|
2009-06-24 13:02:37 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!s) return;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
it = s->cur_item;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2010-03-14 11:00:53 -07:00
|
|
|
if (it && s->plugin && s->plugin->icon_get)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-25 22:14:08 -07:00
|
|
|
if (!_evry_selector_thumb(sel, it))
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2010-03-14 10:53:13 -07:00
|
|
|
o = s->plugin->icon_get(it->plugin, it, win->popup->evas);
|
2009-08-25 13:52:40 -07:00
|
|
|
if (o)
|
|
|
|
{
|
|
|
|
edje_object_part_swallow(sel->o_main, "e.swallow.icons", o);
|
|
|
|
evas_object_show(o);
|
|
|
|
sel->o_icon = o;
|
|
|
|
}
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
2009-08-25 13:52:40 -07:00
|
|
|
}
|
2009-08-25 22:14:08 -07:00
|
|
|
else if (it)
|
|
|
|
{
|
|
|
|
_evry_selector_thumb(sel, it);
|
|
|
|
}
|
2009-08-22 14:22:38 -07:00
|
|
|
|
|
|
|
if (!sel->o_icon && s->plugin && s->plugin->icon)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-18 07:29:30 -07:00
|
|
|
o = evry_icon_theme_get(s->plugin->icon, win->popup->evas);
|
|
|
|
if (o)
|
|
|
|
{
|
|
|
|
edje_object_part_swallow(sel->o_main, "e.swallow.icons", o);
|
|
|
|
evas_object_show(o);
|
|
|
|
sel->o_icon = o;
|
|
|
|
}
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2010-04-04 07:11:35 -07:00
|
|
|
static int
|
|
|
|
_evry_timer_cb_actions_get(void *data)
|
|
|
|
{
|
|
|
|
Evry_Item *it = data;
|
|
|
|
Evry_Selector *sel = selectors[1];
|
|
|
|
Evry_State *s;
|
|
|
|
|
|
|
|
sel->update_timer = NULL;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2010-04-04 07:11:35 -07:00
|
|
|
_evry_selector_actions_get(it);
|
|
|
|
_evry_selector_update(sel);
|
|
|
|
|
|
|
|
if (selector == sel && selector->state)
|
|
|
|
{
|
|
|
|
s = sel->state;
|
|
|
|
if (s->view)
|
2010-04-17 10:50:27 -07:00
|
|
|
s->view->update(s->view, 0);
|
2010-04-04 07:11:35 -07:00
|
|
|
else
|
2010-04-08 16:41:53 -07:00
|
|
|
_evry_view_update(s, NULL);
|
2010-04-04 07:11:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
|
|
|
_evry_selector_update(Evry_Selector *sel)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_State *s = sel->state;
|
2009-08-14 16:30:54 -07:00
|
|
|
Evry_Item *it = NULL;
|
2009-08-11 10:03:36 -07:00
|
|
|
|
2009-08-14 16:30:54 -07:00
|
|
|
if (s)
|
|
|
|
{
|
2009-08-28 21:42:17 -07:00
|
|
|
it = s->cur_item;
|
2009-08-11 10:03:36 -07:00
|
|
|
|
2009-08-14 16:30:54 -07:00
|
|
|
if (!s->plugin && it)
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_item_desel(s, NULL);
|
2009-08-14 16:30:54 -07:00
|
|
|
else if (it && !eina_list_data_find_list(s->plugin->items, it))
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_item_desel(s, NULL);
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
it = s->cur_item;
|
2009-08-14 16:30:54 -07:00
|
|
|
|
|
|
|
if (s->plugin && (!it || s->item_auto_selected))
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2010-04-07 08:03:27 -07:00
|
|
|
it = NULL;
|
|
|
|
|
2009-08-14 16:30:54 -07:00
|
|
|
/* get first item */
|
2010-04-07 08:03:27 -07:00
|
|
|
if (!it && s->plugin->items)
|
2009-08-14 16:30:54 -07:00
|
|
|
{
|
|
|
|
it = s->plugin->items->data;
|
2010-04-07 08:03:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (it)
|
|
|
|
{
|
2009-08-14 16:30:54 -07:00
|
|
|
s->item_auto_selected = EINA_TRUE;
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_item_sel(s, it);
|
2009-08-14 16:30:54 -07:00
|
|
|
}
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_icon_set(sel);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (it)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
edje_object_part_text_set(sel->o_main, "e.text.label", it->label);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (sel == selector)
|
2010-04-15 14:42:30 -07:00
|
|
|
edje_object_part_text_set(sel->o_main, "e.text.plugin", it->plugin->label);
|
2009-08-10 04:36:37 -07:00
|
|
|
else
|
|
|
|
edje_object_part_text_set(sel->o_main, "e.text.plugin", "");
|
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
else
|
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
/* no items for this state - clear selector */
|
|
|
|
edje_object_part_text_set(sel->o_main, "e.text.label", "");
|
2009-08-12 12:00:25 -07:00
|
|
|
if (sel == selector && s && s->plugin)
|
2010-04-15 14:42:30 -07:00
|
|
|
edje_object_part_text_set(sel->o_main, "e.text.plugin", s->plugin->label);
|
2009-08-10 04:36:37 -07:00
|
|
|
else
|
|
|
|
edje_object_part_text_set(sel->o_main, "e.text.plugin", "");
|
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (sel == selectors[0])
|
|
|
|
{
|
2010-04-04 07:11:35 -07:00
|
|
|
sel = selectors[1];
|
|
|
|
if (sel->update_timer)
|
|
|
|
ecore_timer_del(sel->update_timer);
|
|
|
|
sel->update_timer = ecore_timer_add(0.1, _evry_timer_cb_actions_get, it);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_list_win_update(Evry_State *s)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
if (s != selector->state) return;
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!list->visible) return;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2010-04-17 05:40:28 -07:00
|
|
|
if (s->changed)
|
|
|
|
_evry_view_update(s, s->plugin);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static int
|
2009-08-18 17:27:41 -07:00
|
|
|
_evry_selector_subjects_get(const char *plugin_name)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
|
|
|
Eina_List *l, *plugins = NULL;
|
2009-08-21 15:42:06 -07:00
|
|
|
Evry_Plugin *p, *plugin;
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Selector *sel = selectors[0];
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
EINA_LIST_FOREACH(sel->plugins, l, plugin)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-21 15:42:06 -07:00
|
|
|
if (plugin_name && strcmp(plugin_name, plugin->name))
|
2009-08-18 17:27:41 -07:00
|
|
|
continue;
|
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
if (plugin->begin)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-21 15:42:06 -07:00
|
|
|
if ((p = plugin->begin(plugin, NULL)))
|
2009-08-10 04:36:37 -07:00
|
|
|
plugins = eina_list_append(plugins, p);
|
2009-07-04 04:10:28 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
else
|
2009-08-21 15:42:06 -07:00
|
|
|
plugins = eina_list_append(plugins, plugin);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!plugins) return 0;
|
|
|
|
|
|
|
|
_evry_state_new(sel, plugins);
|
2009-08-27 13:52:14 -07:00
|
|
|
_evry_matches_update(sel, 1);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_actions_get(Evry_Item *it)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Eina_List *l, *plugins = NULL;
|
2009-08-21 15:42:06 -07:00
|
|
|
Evry_Plugin *p, *plugin;
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Selector *sel = selectors[1];
|
2009-08-18 07:29:30 -07:00
|
|
|
const char *type_out;
|
2009-08-25 20:12:00 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
while (sel->state)
|
|
|
|
_evry_state_pop(sel);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-14 02:35:51 -07:00
|
|
|
if (!it) return 0;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
type_out = it->plugin->type_out;
|
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
EINA_LIST_FOREACH(sel->plugins, l, plugin)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2010-04-04 07:11:35 -07:00
|
|
|
if ((plugin == sel->actions) || (plugin == sel->aggregator) ||
|
|
|
|
(plugin->type_in && type_out && plugin->type_in == type_out))
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-21 15:42:06 -07:00
|
|
|
if (plugin->begin)
|
2009-08-17 20:15:36 -07:00
|
|
|
{
|
2009-08-21 15:42:06 -07:00
|
|
|
if ((p = plugin->begin(plugin, it)))
|
2009-08-17 20:15:36 -07:00
|
|
|
plugins = eina_list_append(plugins, p);
|
|
|
|
}
|
|
|
|
else
|
2009-08-21 15:42:06 -07:00
|
|
|
plugins = eina_list_append(plugins, plugin);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!plugins) return 0;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_state_new(sel, plugins);
|
2009-08-27 13:52:14 -07:00
|
|
|
_evry_matches_update(sel, 1);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-25 12:18:58 -07:00
|
|
|
/* find plugins that provide the second item required for an action */
|
2009-07-04 04:10:28 -07:00
|
|
|
static int
|
2009-08-21 15:42:06 -07:00
|
|
|
_evry_selector_objects_get(Evry_Action *act)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Eina_List *l, *plugins = NULL;
|
2009-08-21 15:42:06 -07:00
|
|
|
Evry_Plugin *p, *plugin;
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Selector *sel = selectors[2];
|
|
|
|
Evry_Item *it;
|
2009-08-25 12:18:58 -07:00
|
|
|
/* required type */
|
2009-08-21 15:42:06 -07:00
|
|
|
const char *type_in = act->type_in2;
|
2009-08-25 13:52:40 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
while (sel->state)
|
|
|
|
_evry_state_pop(sel);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
it = selectors[0]->state->cur_item;
|
2009-08-25 13:52:40 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
EINA_LIST_FOREACH(sel->plugins, l, plugin)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-25 12:18:58 -07:00
|
|
|
/* plugin doesnt provide reuired type */
|
2009-08-21 15:42:06 -07:00
|
|
|
if ((plugin->type_out != type_in) &&
|
2009-08-25 12:18:58 -07:00
|
|
|
(plugin != sel->aggregator))
|
|
|
|
continue;
|
2009-08-25 13:52:40 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
if (plugin->begin)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-25 12:18:58 -07:00
|
|
|
/* plugins' begin method might require an item */
|
|
|
|
/* like tracker searches files that match mimetype
|
|
|
|
* of an application (item1) */
|
|
|
|
if (((p = plugin->begin(plugin, it))) ||
|
|
|
|
((p = plugin->begin(plugin, NULL))))
|
2009-08-10 04:36:37 -07:00
|
|
|
plugins = eina_list_append(plugins, p);
|
|
|
|
}
|
|
|
|
else
|
2009-08-21 15:42:06 -07:00
|
|
|
plugins = eina_list_append(plugins, plugin);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-11 10:03:36 -07:00
|
|
|
if (!plugins) return 0;
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_state_new(sel, plugins);
|
2009-08-27 13:52:14 -07:00
|
|
|
_evry_matches_update(sel, 1);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static Evry_State *
|
|
|
|
_evry_state_new(Evry_Selector *sel, Eina_List *plugins)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_State *s = E_NEW(Evry_State, 1);
|
2010-04-22 16:03:47 -07:00
|
|
|
s->inp = malloc(INPUTLEN);
|
|
|
|
s->inp[0] = 0;
|
|
|
|
s->input = s->inp;
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
s->plugins = plugins;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
sel->states = eina_list_prepend(sel->states, s);
|
|
|
|
sel->state = s;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return s;
|
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
|
|
|
_evry_state_pop(Evry_Selector *sel)
|
|
|
|
{
|
|
|
|
Evry_Plugin *p;
|
2009-08-13 15:42:40 -07:00
|
|
|
Evry_State *s;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
s = sel->state;
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_item_desel(s, NULL);
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2010-04-22 16:03:47 -07:00
|
|
|
free(s->inp);
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (s->view)
|
2009-08-19 05:07:37 -07:00
|
|
|
s->view->destroy(s->view);
|
2009-08-16 19:06:41 -07:00
|
|
|
|
2009-08-27 03:35:32 -07:00
|
|
|
EINA_LIST_FREE(s->plugins, p)
|
|
|
|
p->cleanup(p);
|
|
|
|
|
2010-04-08 15:37:50 -07:00
|
|
|
if (sel->aggregator)
|
|
|
|
sel->aggregator->cleanup(sel->aggregator);
|
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
E_FREE(s);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
sel->states = eina_list_remove_list(sel->states, sel->states);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (sel->states)
|
|
|
|
sel->state = sel->states->data;
|
|
|
|
else
|
|
|
|
sel->state = NULL;
|
|
|
|
}
|
|
|
|
|
2009-08-31 06:04:53 -07:00
|
|
|
int
|
|
|
|
evry_browse_item(Evry_Selector *sel)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-31 06:04:53 -07:00
|
|
|
if (!sel) sel = selector;
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_State *s = sel->state;
|
|
|
|
Evry_Item *it;
|
|
|
|
Eina_List *l, *plugins = NULL;
|
2009-08-21 15:42:06 -07:00
|
|
|
Evry_Plugin *p, *plugin;
|
2009-08-24 21:23:11 -07:00
|
|
|
Evry_View *view = NULL;
|
2009-08-18 07:29:30 -07:00
|
|
|
const char *type_out;
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-31 06:04:53 -07:00
|
|
|
if (!s)
|
|
|
|
return 0;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
it = s->cur_item;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
if (!it || !it->browseable)
|
2009-08-24 21:23:11 -07:00
|
|
|
return 0;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
type_out = it->plugin->type_out;
|
|
|
|
|
|
|
|
if (!type_out)
|
2009-08-24 21:23:11 -07:00
|
|
|
return 1;
|
2009-08-18 07:29:30 -07:00
|
|
|
|
2009-08-22 14:22:38 -07:00
|
|
|
if (it->plugin->begin &&
|
|
|
|
(p = it->plugin->begin(it->plugin, it)))
|
|
|
|
plugins = eina_list_append(plugins, p);
|
|
|
|
|
|
|
|
if (!plugins)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-22 14:22:38 -07:00
|
|
|
EINA_LIST_FOREACH(sel->plugins, l, plugin)
|
|
|
|
{
|
|
|
|
if ((!plugin->begin || !plugin->type_in) ||
|
|
|
|
(plugin->type_in != type_out))
|
|
|
|
continue;
|
2009-08-12 05:17:43 -07:00
|
|
|
|
2009-08-22 14:22:38 -07:00
|
|
|
if ((p = plugin->begin(plugin, it)))
|
|
|
|
plugins = eina_list_append(plugins, p);
|
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-31 06:04:53 -07:00
|
|
|
if (!plugins)
|
|
|
|
return 1;
|
2009-08-24 21:23:11 -07:00
|
|
|
|
2010-04-20 17:50:30 -07:00
|
|
|
evry_history_add(sel->history, s->cur_item, NULL, s->input);
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-24 21:23:11 -07:00
|
|
|
if (s->view)
|
|
|
|
{
|
2010-04-17 12:13:01 -07:00
|
|
|
_evry_view_hide(s->view, 1);
|
2009-08-27 13:52:14 -07:00
|
|
|
view = s->view;
|
2009-08-24 21:23:11 -07:00
|
|
|
}
|
2009-08-25 13:52:40 -07:00
|
|
|
|
2009-08-19 05:07:37 -07:00
|
|
|
_evry_state_new(sel, plugins);
|
2009-08-27 13:52:14 -07:00
|
|
|
_evry_matches_update(sel, 1);
|
2009-08-19 05:07:37 -07:00
|
|
|
_evry_selector_update(sel);
|
2009-08-24 21:23:11 -07:00
|
|
|
s = sel->state;
|
|
|
|
|
|
|
|
if (view && list->visible && s)
|
|
|
|
{
|
|
|
|
s->view = view->create(view, s, list->o_main);
|
|
|
|
if (s->view)
|
|
|
|
{
|
|
|
|
_evry_view_show(s->view);
|
2010-04-17 10:50:27 -07:00
|
|
|
s->view->update(s->view, -1);
|
2009-08-24 21:23:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_update_text_label(sel->state);
|
2009-08-24 21:23:11 -07:00
|
|
|
|
|
|
|
return 1;
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
|
|
|
|
2009-08-31 06:04:53 -07:00
|
|
|
void
|
|
|
|
evry_browse_back(Evry_Selector *sel)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
|
|
|
Evry_State *s = sel->state;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
if (!s || !sel->states->next)
|
|
|
|
return;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_state_pop(sel);
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2009-08-19 05:07:37 -07:00
|
|
|
s = sel->state;
|
|
|
|
sel->aggregator->fetch(sel->aggregator, s->input);
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_update(sel);
|
2009-08-19 05:07:37 -07:00
|
|
|
_evry_update_text_label(s);
|
2009-08-21 15:42:06 -07:00
|
|
|
_evry_view_show(s->view);
|
2010-04-17 10:50:27 -07:00
|
|
|
s->view->update(s->view, 1);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-07-04 04:10:28 -07:00
|
|
|
static void
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selectors_switch(void)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_State *s = selector->state;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2010-04-08 16:41:53 -07:00
|
|
|
if (_show_timer)
|
|
|
|
_cb_show_timer(NULL);
|
|
|
|
|
2010-04-04 07:11:35 -07:00
|
|
|
if (selector->update_timer)
|
2009-08-12 13:26:27 -07:00
|
|
|
{
|
2009-08-27 13:52:14 -07:00
|
|
|
if ((selector == selectors[0]) ||
|
|
|
|
(selector == selectors[1]))
|
2009-08-12 13:26:27 -07:00
|
|
|
{
|
2009-08-27 13:52:14 -07:00
|
|
|
_evry_matches_update(selector, 0);
|
2009-08-12 13:26:27 -07:00
|
|
|
_evry_selector_update(selector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (selector == selectors[0])
|
|
|
|
{
|
2009-08-28 21:42:17 -07:00
|
|
|
if (s->cur_item)
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_activate(selectors[1]);
|
|
|
|
}
|
|
|
|
else if (selector == selectors[1])
|
|
|
|
{
|
|
|
|
int next_selector = 0;
|
2009-08-19 05:07:37 -07:00
|
|
|
Evry_Action *act;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
if ((s->cur_item) &&
|
2010-04-04 07:11:35 -07:00
|
|
|
(s->cur_item->plugin == selector->actions) &&
|
2009-08-28 21:42:17 -07:00
|
|
|
(act = s->cur_item->data) &&
|
2009-08-21 15:42:06 -07:00
|
|
|
(act->type_in2))
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-21 15:42:06 -07:00
|
|
|
_evry_selector_objects_get(act);
|
2009-08-19 05:07:37 -07:00
|
|
|
_evry_selector_update(selectors[2]);
|
|
|
|
edje_object_signal_emit(win->o_main,
|
|
|
|
"e,state,object_selector_show", "e");
|
|
|
|
next_selector = 2;
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
|
|
|
_evry_selector_activate(selectors[next_selector]);
|
|
|
|
}
|
|
|
|
else if (selector == selectors[2])
|
|
|
|
{
|
|
|
|
while (selector->states)
|
|
|
|
_evry_state_pop(selector);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-12 13:26:27 -07:00
|
|
|
edje_object_signal_emit(win->o_main,
|
|
|
|
"e,state,object_selector_hide", "e");
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_activate(selectors[0]);
|
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-21 01:19:30 -07:00
|
|
|
static int
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2010-04-20 08:22:01 -07:00
|
|
|
Ecore_Event_Key *ev = event;
|
|
|
|
Evry_State *s;
|
2009-08-17 16:54:16 -07:00
|
|
|
const char *key = NULL, *old;
|
|
|
|
|
2010-04-20 08:22:01 -07:00
|
|
|
if (ev->event_window != input_window)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (!strcmp(ev->key, "Escape"))
|
|
|
|
{
|
|
|
|
evry_hide();
|
|
|
|
return 1;
|
|
|
|
}
|
2010-04-20 00:40:21 -07:00
|
|
|
|
2010-04-20 08:22:01 -07:00
|
|
|
if (!selector || !selector->state)
|
|
|
|
return 1;
|
|
|
|
s = selector->state;
|
2009-08-12 16:14:05 -07:00
|
|
|
|
2010-04-20 08:22:01 -07:00
|
|
|
win->request_selection = EINA_FALSE;
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
old = ev->key;
|
|
|
|
|
2010-04-10 16:44:11 -07:00
|
|
|
if (((evry_conf->quick_nav == 1) && (ev->modifiers & ECORE_EVENT_MODIFIER_ALT)) ||
|
|
|
|
((evry_conf->quick_nav == 2) && (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)))
|
2009-08-17 16:54:16 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(ev->key, "k") || (!strcmp(ev->key, "K")))
|
|
|
|
key = eina_stringshare_add("Up");
|
|
|
|
else if (!strcmp(ev->key, "j") || (!strcmp(ev->key, "J")))
|
|
|
|
key = eina_stringshare_add("Down");
|
|
|
|
else if (!strcmp(ev->key, "n") || (!strcmp(ev->key, "N")))
|
|
|
|
key = eina_stringshare_add("Next");
|
|
|
|
else if (!strcmp(ev->key, "p") || (!strcmp(ev->key, "P")))
|
|
|
|
key = eina_stringshare_add("Prior");
|
|
|
|
else if (!strcmp(ev->key, "l") || (!strcmp(ev->key, "L")))
|
|
|
|
key = eina_stringshare_add("Right");
|
|
|
|
else if (!strcmp(ev->key, "h") || (!strcmp(ev->key, "H")))
|
|
|
|
key = eina_stringshare_add("Left");
|
|
|
|
else if (!strcmp(ev->key, "i") || (!strcmp(ev->key, "I")))
|
|
|
|
key = eina_stringshare_add("Tab");
|
|
|
|
else if (!strcmp(ev->key, "m") || (!strcmp(ev->key, "M")))
|
|
|
|
key = eina_stringshare_add("Return");
|
|
|
|
else
|
|
|
|
key = eina_stringshare_add(ev->key);
|
2009-08-16 02:43:38 -07:00
|
|
|
|
2010-04-10 16:44:11 -07:00
|
|
|
ev->key = key;
|
|
|
|
}
|
|
|
|
else if (((evry_conf->quick_nav == 3) && (ev->modifiers & ECORE_EVENT_MODIFIER_ALT)) ||
|
|
|
|
((evry_conf->quick_nav == 4) && (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)))
|
|
|
|
{
|
|
|
|
if (!strcmp(ev->key, "p") || (!strcmp(ev->key, "P")))
|
|
|
|
key = eina_stringshare_add("Up");
|
|
|
|
else if (!strcmp(ev->key, "n") || (!strcmp(ev->key, "N")))
|
|
|
|
key = eina_stringshare_add("Down");
|
|
|
|
/* else if (!strcmp(ev->key, "f") || (!strcmp(ev->key, "f")))
|
|
|
|
* key = eina_stringshare_add("Next");
|
|
|
|
* else if (!strcmp(ev->key, "b") || (!strcmp(ev->key, "B")))
|
|
|
|
* key = eina_stringshare_add("Prior"); */
|
|
|
|
else if (!strcmp(ev->key, "f") || (!strcmp(ev->key, "F")))
|
|
|
|
key = eina_stringshare_add("Right");
|
|
|
|
else if (!strcmp(ev->key, "b") || (!strcmp(ev->key, "B")))
|
|
|
|
key = eina_stringshare_add("Left");
|
|
|
|
else if (!strcmp(ev->key, "i") || (!strcmp(ev->key, "I")))
|
|
|
|
key = eina_stringshare_add("Tab");
|
|
|
|
else if (!strcmp(ev->key, "m") || (!strcmp(ev->key, "M")))
|
|
|
|
key = eina_stringshare_add("Return");
|
|
|
|
else
|
|
|
|
key = eina_stringshare_add(ev->key);
|
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
ev->key = key;
|
|
|
|
}
|
|
|
|
else
|
2010-04-10 16:44:11 -07:00
|
|
|
|
2009-08-16 02:43:38 -07:00
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
key = eina_stringshare_add(ev->key);
|
|
|
|
ev->key = key;
|
2009-08-16 02:43:38 -07:00
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
|
|
|
|
if (!list->visible && (!strcmp(key, "Down")))
|
2009-08-20 14:39:01 -07:00
|
|
|
_evry_list_win_show();
|
2010-04-15 06:58:44 -07:00
|
|
|
else if ((!strcmp(key, "ISO_Left_Tab") ||
|
|
|
|
(((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) ||
|
|
|
|
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)) &&
|
|
|
|
(!strcmp(key, "Tab")))))
|
|
|
|
{
|
2010-04-15 08:46:12 -07:00
|
|
|
int action = 0;
|
|
|
|
char *input = NULL;
|
|
|
|
Evry_Item *it = s->cur_item;
|
|
|
|
|
|
|
|
evry_item_ref(it);
|
2010-04-15 08:57:28 -07:00
|
|
|
|
|
|
|
s->item_auto_selected = EINA_FALSE;
|
2010-04-15 08:46:12 -07:00
|
|
|
|
|
|
|
if (it->plugin->complete)
|
|
|
|
action = it->plugin->complete(it->plugin, it, &input);
|
|
|
|
else
|
|
|
|
evry_browse_item(selector);
|
|
|
|
|
|
|
|
if (action == EVRY_COMPLETE_INPUT)
|
|
|
|
{
|
2010-04-22 16:03:47 -07:00
|
|
|
snprintf(s->inp, INPUTLEN, "%s", input);
|
2010-04-15 14:42:30 -07:00
|
|
|
_evry_update_text_label(s);
|
2010-04-15 08:46:12 -07:00
|
|
|
_evry_cb_update_timer(selector);
|
|
|
|
evry_item_select(s, it);
|
|
|
|
}
|
2010-04-15 06:58:44 -07:00
|
|
|
|
2010-04-15 08:46:12 -07:00
|
|
|
E_FREE(input);
|
|
|
|
|
|
|
|
evry_item_free(it);
|
2010-04-15 06:58:44 -07:00
|
|
|
}
|
2010-04-12 13:52:23 -07:00
|
|
|
else if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
|
|
|
|
(!strcmp(key, "Delete") || !strcmp(key, "Insert")))
|
|
|
|
{
|
|
|
|
if (!s || !s->cur_item)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
int delete = (!strcmp(key, "Delete") && (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT));
|
|
|
|
int promote = (!strcmp(key, "Insert"));
|
|
|
|
History_Entry *he;
|
|
|
|
History_Item *hi;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
Evry_Item *it = s->cur_item;
|
|
|
|
|
|
|
|
if (!(he = eina_hash_find
|
|
|
|
(selector->history, (it->id ? it->id : it->label))))
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH_SAFE(he->items, l, ll, hi)
|
|
|
|
{
|
|
|
|
if (hi->plugin != it->plugin->name)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (delete)
|
|
|
|
{
|
|
|
|
if (hi->input)
|
|
|
|
eina_stringshare_del(hi->input);
|
|
|
|
if (hi->plugin)
|
|
|
|
eina_stringshare_del(hi->plugin);
|
|
|
|
if (hi->context)
|
|
|
|
eina_stringshare_del(hi->context);
|
|
|
|
E_FREE(hi);
|
|
|
|
|
|
|
|
he->items = eina_list_remove_list(he->items, l);
|
|
|
|
}
|
|
|
|
else if (promote)
|
|
|
|
{
|
|
|
|
hi->count += 5;
|
2010-04-15 06:58:44 -07:00
|
|
|
hi->last_used = ecore_time_get();
|
2010-04-12 13:52:23 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hi->count -= 5;
|
|
|
|
if (hi->count < 0) hi->count = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (s->plugin == selector->aggregator)
|
|
|
|
selector->aggregator->fetch(selector->aggregator, s->input);
|
|
|
|
if (s->view)
|
2010-04-17 10:50:27 -07:00
|
|
|
s->view->update(s->view, 0);
|
2010-04-12 13:52:23 -07:00
|
|
|
}
|
2009-08-16 02:43:38 -07:00
|
|
|
else if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)
|
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
if (!strcmp(key, "u"))
|
2009-08-16 02:43:38 -07:00
|
|
|
{
|
2010-04-04 07:11:35 -07:00
|
|
|
if (!_evry_clear(selector))
|
2009-08-31 06:04:53 -07:00
|
|
|
evry_browse_back(selector);
|
2009-08-16 02:43:38 -07:00
|
|
|
}
|
2009-08-17 18:00:18 -07:00
|
|
|
else if (!strcmp(key, "1"))
|
2009-08-21 01:19:30 -07:00
|
|
|
_evry_view_toggle(s, NULL);
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "Return"))
|
2009-08-16 02:43:38 -07:00
|
|
|
_evry_plugin_action(selector, 0);
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "v"))
|
2009-08-16 02:43:38 -07:00
|
|
|
{
|
|
|
|
win->request_selection = EINA_TRUE;
|
|
|
|
ecore_x_selection_primary_request
|
|
|
|
(win->popup->evas_win, ECORE_X_SELECTION_TARGET_UTF8_STRING);
|
|
|
|
}
|
2009-08-20 14:39:01 -07:00
|
|
|
else if (_evry_view_key_press(s, ev))
|
|
|
|
goto end;
|
2009-08-16 02:43:38 -07:00
|
|
|
}
|
2010-04-07 08:03:27 -07:00
|
|
|
/* let plugin intercept keypress */
|
|
|
|
else if (s->plugin && s->plugin->cb_key_down &&
|
|
|
|
s->plugin->cb_key_down(s->plugin, ev))
|
|
|
|
goto end;
|
|
|
|
/* let view intercept keypress */
|
2009-08-20 17:07:27 -07:00
|
|
|
else if (_evry_view_key_press(s, ev))
|
|
|
|
goto end;
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "Right"))
|
2009-08-31 06:04:53 -07:00
|
|
|
evry_browse_item(selector);
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "Left"))
|
2009-08-31 06:04:53 -07:00
|
|
|
evry_browse_back(selector);
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "Return"))
|
2009-08-16 02:43:38 -07:00
|
|
|
{
|
|
|
|
if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
|
|
|
|
_evry_plugin_action(selector, 0);
|
2009-08-31 06:04:53 -07:00
|
|
|
else /*if (!_evry_browse_item(selector))*/
|
2009-08-16 02:43:38 -07:00
|
|
|
_evry_plugin_action(selector, 1);
|
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "Tab"))
|
2009-08-16 09:26:49 -07:00
|
|
|
_evry_selectors_switch();
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "BackSpace"))
|
2009-08-24 21:23:11 -07:00
|
|
|
{
|
2010-04-04 07:11:35 -07:00
|
|
|
if (!_evry_backspace(selector))
|
2009-08-31 06:04:53 -07:00
|
|
|
evry_browse_back(selector);
|
2009-08-24 21:23:11 -07:00
|
|
|
}
|
2009-08-20 14:39:01 -07:00
|
|
|
else if (_evry_view_key_press(s, ev))
|
|
|
|
goto end;
|
|
|
|
else if ((ev->compose && !(ev->modifiers & ECORE_EVENT_MODIFIER_ALT)))
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2010-04-22 16:03:47 -07:00
|
|
|
int len = strlen(s->inp);
|
2010-04-22 11:15:59 -07:00
|
|
|
|
|
|
|
if (len == 0 && (_evry_view_toggle(s, ev->compose)))
|
|
|
|
goto end;
|
|
|
|
|
2009-08-21 01:19:30 -07:00
|
|
|
if (len < (INPUTLEN - strlen(ev->compose)))
|
2009-08-12 15:34:07 -07:00
|
|
|
{
|
2010-04-22 16:03:47 -07:00
|
|
|
strcat(s->inp, ev->compose);
|
2010-04-20 11:49:42 -07:00
|
|
|
|
2010-04-22 14:10:16 -07:00
|
|
|
/* if (isspace(*ev->compose))
|
|
|
|
* {
|
|
|
|
* /\* do not update matches on space *\/
|
|
|
|
* _evry_update(selector, 0);
|
|
|
|
* }
|
|
|
|
* else */
|
|
|
|
_evry_update(selector, 1);
|
2009-08-12 15:34:07 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
|
2009-08-20 14:39:01 -07:00
|
|
|
end:
|
2009-08-17 16:54:16 -07:00
|
|
|
eina_stringshare_del(ev->key);
|
|
|
|
ev->key = old;
|
2009-08-10 04:36:37 -07:00
|
|
|
return 1;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-24 21:23:11 -07:00
|
|
|
static int
|
2010-04-04 07:11:35 -07:00
|
|
|
_evry_backspace(Evry_Selector *sel)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2010-04-04 07:11:35 -07:00
|
|
|
Evry_State *s = sel->state;
|
2009-05-06 07:20:45 -07:00
|
|
|
int len, val, pos;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2010-04-22 16:03:47 -07:00
|
|
|
len = strlen(s->inp);
|
2009-05-06 07:20:45 -07:00
|
|
|
if (len > 0)
|
|
|
|
{
|
2010-04-22 16:03:47 -07:00
|
|
|
pos = evas_string_char_prev_get(s->inp, len, &val);
|
2009-05-06 07:20:45 -07:00
|
|
|
if ((pos < len) && (pos >= 0))
|
|
|
|
{
|
2010-04-22 16:03:47 -07:00
|
|
|
val = *(s->inp + pos);
|
2009-08-20 16:43:56 -07:00
|
|
|
|
2010-04-22 16:03:47 -07:00
|
|
|
s->inp[pos] = 0;
|
|
|
|
s->input = s->inp;
|
2009-08-20 16:43:56 -07:00
|
|
|
|
|
|
|
if ((pos == 0) || !isspace(val))
|
2010-04-04 07:11:35 -07:00
|
|
|
_evry_update(sel, 1);
|
2009-08-24 21:23:11 -07:00
|
|
|
|
|
|
|
return 1;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
}
|
2009-08-24 21:23:11 -07:00
|
|
|
|
|
|
|
return 0;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_update_text_label(Evry_State *s)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-25 17:36:59 -07:00
|
|
|
if (!list->visible && evry_conf->hide_input)
|
2009-08-16 20:30:04 -07:00
|
|
|
{
|
2010-04-22 16:03:47 -07:00
|
|
|
if (strlen(s->inp) > 0)
|
2009-08-16 20:30:04 -07:00
|
|
|
edje_object_signal_emit(list->o_main, "e,state,entry_show", "e");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(list->o_main, "e,state,entry_hide", "e");
|
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
|
2010-04-22 16:03:47 -07:00
|
|
|
edje_object_part_text_set(win->o_main, "e.text.label", s->inp);
|
|
|
|
edje_object_part_text_set(list->o_main, "e.text.label", s->inp);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
2010-04-04 07:11:35 -07:00
|
|
|
_evry_update(Evry_Selector *sel, int fetch)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2010-04-04 07:11:35 -07:00
|
|
|
Evry_State *s = sel->state;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_update_text_label(s);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-15 13:12:04 -07:00
|
|
|
if (fetch)
|
|
|
|
{
|
2010-04-04 07:11:35 -07:00
|
|
|
if (sel->update_timer)
|
|
|
|
ecore_timer_del(sel->update_timer);
|
|
|
|
|
|
|
|
sel->update_timer = ecore_timer_add(MATCH_LAG, _evry_cb_update_timer, sel);
|
2009-08-20 07:45:47 -07:00
|
|
|
|
|
|
|
if (s->plugin && !s->plugin->trigger)
|
|
|
|
edje_object_signal_emit(list->o_main, "e,signal,update", "e");
|
2009-08-15 13:12:04 -07:00
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
static int
|
2010-04-04 07:11:35 -07:00
|
|
|
_evry_cb_update_timer(void *data)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2010-04-04 07:11:35 -07:00
|
|
|
Evry_Selector *sel = data;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2010-04-04 07:11:35 -07:00
|
|
|
_evry_matches_update(sel, 1);
|
|
|
|
_evry_selector_update(sel);
|
|
|
|
_evry_list_win_update(sel->state);
|
|
|
|
sel->update_timer = NULL;
|
2009-08-12 05:17:43 -07:00
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-16 02:43:38 -07:00
|
|
|
static int
|
2010-04-04 07:11:35 -07:00
|
|
|
_evry_clear(Evry_Selector *sel)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2010-04-04 07:11:35 -07:00
|
|
|
Evry_State *s = sel->state;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2010-04-22 16:03:47 -07:00
|
|
|
if ((s->plugin && s->plugin->trigger && s->inp) &&
|
|
|
|
(!strncmp(s->plugin->trigger, s->inp,
|
2010-04-04 07:11:35 -07:00
|
|
|
strlen(s->plugin->trigger))))
|
2009-08-12 15:34:07 -07:00
|
|
|
{
|
|
|
|
s->input[strlen(s->plugin->trigger)] = 0;
|
2010-04-04 07:11:35 -07:00
|
|
|
_evry_update(sel, 1);
|
2009-08-16 02:43:38 -07:00
|
|
|
return 1;
|
2009-08-12 15:34:07 -07:00
|
|
|
}
|
2010-04-22 16:03:47 -07:00
|
|
|
else if (s->inp && s->inp[0] != 0)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2010-04-22 16:03:47 -07:00
|
|
|
s->inp[0] = 0;
|
|
|
|
s->input = s->inp;
|
|
|
|
|
2010-04-04 07:11:35 -07:00
|
|
|
_evry_update(sel, 1);
|
2009-08-25 17:36:59 -07:00
|
|
|
if (!list->visible && evry_conf->hide_input)
|
2009-08-16 20:30:04 -07:00
|
|
|
edje_object_signal_emit(list->o_main, "e,state,entry_hide", "e");
|
2009-08-16 02:43:38 -07:00
|
|
|
return 1;
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
2009-08-16 02:43:38 -07:00
|
|
|
return 0;
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
static void
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_plugin_action(Evry_Selector *sel, int finished)
|
2009-08-12 12:00:25 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_State *s_subject, *s_action, *s_object;
|
|
|
|
|
2010-04-08 16:29:35 -07:00
|
|
|
if (selectors[0]->update_timer)
|
|
|
|
{
|
|
|
|
_evry_matches_update(selectors[0], 0);
|
|
|
|
_evry_selector_update(selectors[0]);
|
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2010-04-08 16:29:35 -07:00
|
|
|
s_subject = selectors[0]->state;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2010-04-08 16:29:35 -07:00
|
|
|
if (!s_subject || !s_subject->cur_item)
|
2009-08-30 01:51:15 -07:00
|
|
|
return;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2010-04-08 16:29:35 -07:00
|
|
|
if (selector == selectors[0] &&
|
|
|
|
selectors[1]->update_timer)
|
2009-07-10 08:47:19 -07:00
|
|
|
{
|
2010-04-08 16:29:35 -07:00
|
|
|
_evry_selector_actions_get(s_subject->cur_item);
|
|
|
|
|
|
|
|
if (!selectors[1]->state)
|
|
|
|
return;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2010-04-08 16:29:35 -07:00
|
|
|
_evry_selector_update(selectors[1]);
|
2009-07-10 08:47:19 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2010-04-08 16:29:35 -07:00
|
|
|
s_action = selectors[1]->state;
|
|
|
|
s_object = NULL;
|
|
|
|
|
|
|
|
if (!s_action || !s_action->cur_item)
|
2009-08-30 01:51:15 -07:00
|
|
|
return;
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2010-04-04 07:11:35 -07:00
|
|
|
/* FIXME */
|
|
|
|
if (s_action->cur_item->plugin == selectors[1]->actions)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-28 21:42:17 -07:00
|
|
|
Evry_Action *act = s_action->cur_item->data;
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Item *it_object = NULL;
|
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (selectors[2] == selector)
|
2009-08-28 21:42:17 -07:00
|
|
|
it_object = selector->state->cur_item;
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-30 01:51:15 -07:00
|
|
|
if (act->type_in2 && !it_object)
|
2009-08-31 06:04:53 -07:00
|
|
|
{
|
|
|
|
if (selectors[1] == selector)
|
|
|
|
_evry_selectors_switch();
|
|
|
|
return;
|
|
|
|
}
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-21 18:15:21 -07:00
|
|
|
act->item2 = it_object;
|
2009-08-22 14:22:38 -07:00
|
|
|
|
2009-08-27 13:52:14 -07:00
|
|
|
if (!act->action(act))
|
|
|
|
return;
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
2009-08-25 17:36:59 -07:00
|
|
|
else if (s_action->plugin->action)
|
2010-04-08 16:41:53 -07:00
|
|
|
{
|
2009-08-28 21:42:17 -07:00
|
|
|
Evry_Item *it = s_action->cur_item;
|
2009-08-27 13:52:14 -07:00
|
|
|
if (!s_action->plugin->action(s_action->plugin, it))
|
|
|
|
return;
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
2009-08-25 17:36:59 -07:00
|
|
|
else return;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2010-04-20 17:50:30 -07:00
|
|
|
evry_history_add(evry_hist->subjects, s_subject->cur_item, NULL, s_subject->input);
|
|
|
|
if (s_action)
|
|
|
|
evry_history_add(evry_hist->actions, s_action->cur_item, s_subject->cur_item->context, s_action->input);
|
|
|
|
if (s_object)
|
|
|
|
evry_history_add(evry_hist->subjects, s_object->cur_item, s_action->cur_item->context, s_object->input);
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-21 18:15:21 -07:00
|
|
|
/* let subject and object plugin know that an action was performed */
|
2009-08-10 04:36:37 -07:00
|
|
|
if (s_subject->plugin->action)
|
2009-08-28 21:42:17 -07:00
|
|
|
s_subject->plugin->action(s_subject->plugin, s_subject->cur_item);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (s_object && s_object->plugin->action)
|
2009-08-28 21:42:17 -07:00
|
|
|
s_object->plugin->action(s_object->plugin, s_object->cur_item);
|
2009-08-22 14:22:38 -07:00
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
if (finished)
|
|
|
|
evry_hide();
|
|
|
|
}
|
|
|
|
|
2009-08-20 14:39:01 -07:00
|
|
|
static void
|
|
|
|
_evry_view_show(Evry_View *v)
|
|
|
|
{
|
|
|
|
if (!v) return;
|
|
|
|
|
|
|
|
if (v->o_list)
|
|
|
|
{
|
|
|
|
edje_object_part_swallow(list->o_main, "e.swallow.list", v->o_list);
|
|
|
|
evas_object_show(v->o_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v->o_bar)
|
|
|
|
{
|
|
|
|
edje_object_part_swallow(list->o_main, "e.swallow.bar", v->o_bar);
|
|
|
|
evas_object_show(v->o_bar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-04-17 12:13:01 -07:00
|
|
|
_evry_view_hide(Evry_View *v, int slide)
|
2009-08-20 14:39:01 -07:00
|
|
|
{
|
|
|
|
if (!v) return;
|
|
|
|
|
2010-04-17 12:13:01 -07:00
|
|
|
v->clear(v, slide);
|
|
|
|
|
2009-08-20 14:39:01 -07:00
|
|
|
if (v->o_list)
|
|
|
|
{
|
|
|
|
edje_object_part_unswallow(list->o_main, v->o_list);
|
|
|
|
evas_object_hide(v->o_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v->o_bar)
|
|
|
|
{
|
|
|
|
edje_object_part_unswallow(list->o_main, v->o_bar);
|
|
|
|
evas_object_hide(v->o_bar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_update(Evry_State *s, Evry_Plugin *p)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!list->visible) return;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-19 05:07:37 -07:00
|
|
|
if (!s->view)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-19 05:07:37 -07:00
|
|
|
Evry_View *view = evry_conf->views->data;
|
|
|
|
s->view = view->create(view, s, list->o_main);
|
2009-08-20 14:39:01 -07:00
|
|
|
_evry_view_show(s->view);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-06-08 06:44:11 -07:00
|
|
|
|
2009-08-19 05:07:37 -07:00
|
|
|
if (s->view)
|
2010-04-17 10:50:27 -07:00
|
|
|
s->view->update(s->view, 0);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_clear(Evry_State *s)
|
2009-08-13 15:42:40 -07:00
|
|
|
{
|
2009-08-19 05:07:37 -07:00
|
|
|
if (!s || !s->view) return;
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2010-04-17 10:50:27 -07:00
|
|
|
s->view->clear(s->view, 0);
|
2009-08-17 16:54:16 -07:00
|
|
|
}
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
static int
|
|
|
|
_evry_view_key_press(Evry_State *s, Ecore_Event_Key *ev)
|
|
|
|
{
|
2009-08-21 01:19:30 -07:00
|
|
|
if (!s || !s->view || !s->view->cb_key_down) return 0;
|
2009-08-19 05:07:37 -07:00
|
|
|
|
|
|
|
return s->view->cb_key_down(s->view, ev);
|
2009-08-13 15:42:40 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
static int
|
2009-08-21 01:19:30 -07:00
|
|
|
_evry_view_toggle(Evry_State *s, const char *trigger)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-21 01:19:30 -07:00
|
|
|
Evry_View *view, *v = NULL;
|
2009-08-19 05:07:37 -07:00
|
|
|
Eina_List *l, *ll;
|
2010-04-20 11:49:42 -07:00
|
|
|
Eina_Bool triggered = FALSE;
|
|
|
|
|
2009-08-21 01:19:30 -07:00
|
|
|
if (trigger)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(evry_conf->views, ll, view)
|
|
|
|
{
|
|
|
|
if (view->trigger && !strncmp(trigger, view->trigger, 1) &&
|
|
|
|
(v = view->create(view, s, list->o_main)))
|
2010-04-20 11:49:42 -07:00
|
|
|
{
|
|
|
|
triggered = EINA_TRUE;
|
|
|
|
goto found;
|
|
|
|
}
|
2009-08-21 01:19:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
if (s->view)
|
|
|
|
l = eina_list_data_find_list(evry_conf->views, s->view->id);
|
|
|
|
else
|
|
|
|
{
|
2009-08-22 21:48:17 -07:00
|
|
|
view = evry_conf->views->data;
|
|
|
|
v = view->create(view, s, list->o_main);
|
2009-08-22 20:12:05 -07:00
|
|
|
goto found;
|
|
|
|
}
|
2009-08-18 07:29:30 -07:00
|
|
|
|
2009-08-21 01:19:30 -07:00
|
|
|
if (l && l->next)
|
|
|
|
l = l->next;
|
|
|
|
else
|
|
|
|
l = evry_conf->views;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-21 01:19:30 -07:00
|
|
|
EINA_LIST_FOREACH(l, ll, view)
|
|
|
|
{
|
|
|
|
if ((!view->trigger) &&
|
|
|
|
((view == s->view->id) ||
|
|
|
|
(v = view->create(view, s, list->o_main))))
|
|
|
|
goto found;
|
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-21 01:19:30 -07:00
|
|
|
EINA_LIST_FOREACH(evry_conf->views, ll, view)
|
|
|
|
{
|
|
|
|
if ((!view->trigger) &&
|
|
|
|
((view == s->view->id) ||
|
|
|
|
(v = view->create(view, s, list->o_main))))
|
|
|
|
goto found;
|
|
|
|
}
|
2009-08-19 05:07:37 -07:00
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
|
2009-08-21 01:19:30 -07:00
|
|
|
found:
|
2009-08-19 05:07:37 -07:00
|
|
|
if (!v) return 0;
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-21 01:19:30 -07:00
|
|
|
_evry_list_win_show();
|
|
|
|
|
2009-08-19 05:07:37 -07:00
|
|
|
if (s->view)
|
|
|
|
{
|
2010-04-17 12:13:01 -07:00
|
|
|
_evry_view_hide(s->view, 0);
|
2009-08-19 05:07:37 -07:00
|
|
|
s->view->destroy(s->view);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-07-03 06:37:54 -07:00
|
|
|
|
2009-08-19 05:07:37 -07:00
|
|
|
s->view = v;
|
2009-08-22 21:48:17 -07:00
|
|
|
_evry_view_show(s->view);
|
2010-04-17 10:50:27 -07:00
|
|
|
view->update(s->view, 0);
|
2009-08-19 05:07:37 -07:00
|
|
|
|
2010-04-20 11:49:42 -07:00
|
|
|
return triggered;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-27 13:52:14 -07:00
|
|
|
_evry_matches_update(Evry_Selector *sel, int async)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_State *s = sel->state;
|
2009-06-21 03:31:38 -07:00
|
|
|
Evry_Plugin *p;
|
2009-05-06 07:20:45 -07:00
|
|
|
Eina_List *l;
|
2009-08-17 20:15:36 -07:00
|
|
|
const char *input;
|
2010-04-22 17:49:29 -07:00
|
|
|
s->changed = 1;
|
|
|
|
|
2010-04-22 16:03:47 -07:00
|
|
|
if (s->inp[0])
|
|
|
|
input = s->inp;
|
2009-08-17 20:15:36 -07:00
|
|
|
else
|
|
|
|
input = NULL;
|
2009-08-18 07:29:30 -07:00
|
|
|
|
2010-04-22 17:49:29 -07:00
|
|
|
if (!input || !s->trigger_active)
|
|
|
|
{
|
|
|
|
EINA_LIST_FREE(s->cur_plugins, p);
|
|
|
|
s->trigger_active = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2010-04-22 17:49:29 -07:00
|
|
|
EINA_LIST_FOREACH(s->cur_plugins, l, p)
|
|
|
|
p->fetch(p, s->input);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!s->cur_plugins && input)
|
|
|
|
{
|
|
|
|
int len_trigger = 0;
|
|
|
|
|
2009-07-29 13:43:09 -07:00
|
|
|
EINA_LIST_FOREACH(s->plugins, l, p)
|
2009-07-09 15:58:40 -07:00
|
|
|
{
|
2009-07-29 13:43:09 -07:00
|
|
|
/* input matches plugin trigger? */
|
2009-08-14 02:35:51 -07:00
|
|
|
if (!p->trigger) continue;
|
2010-04-22 17:49:29 -07:00
|
|
|
int len = strlen(p->trigger);
|
|
|
|
|
|
|
|
if (len_trigger && len != len_trigger)
|
|
|
|
continue;
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2010-04-22 17:49:29 -07:00
|
|
|
if ((strlen(s->inp) >= len) &&
|
|
|
|
(!strncmp(s->inp, p->trigger, len)))
|
2009-07-15 07:37:01 -07:00
|
|
|
{
|
2010-04-22 17:49:29 -07:00
|
|
|
len_trigger = len;
|
2009-08-14 02:35:51 -07:00
|
|
|
s->cur_plugins = eina_list_append(s->cur_plugins, p);
|
2010-04-22 17:49:29 -07:00
|
|
|
p->fetch(p, s->input + len);
|
2009-07-15 07:37:01 -07:00
|
|
|
}
|
2009-07-09 15:58:40 -07:00
|
|
|
}
|
2010-04-22 17:49:29 -07:00
|
|
|
if (s->cur_plugins)
|
|
|
|
{
|
|
|
|
s->trigger_active = EINA_TRUE;
|
|
|
|
s->inp[0] = '>';
|
|
|
|
s->inp[1] = '\0';
|
|
|
|
s->input = s->inp + 1;
|
|
|
|
_evry_update_text_label(s);
|
|
|
|
}
|
2009-07-15 07:37:01 -07:00
|
|
|
}
|
2010-04-22 16:03:47 -07:00
|
|
|
|
2009-07-15 07:37:01 -07:00
|
|
|
if (!s->cur_plugins)
|
|
|
|
{
|
2010-04-22 16:03:47 -07:00
|
|
|
s->input = s->inp;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(s->plugins, l, p)
|
2009-07-29 13:43:09 -07:00
|
|
|
{
|
2010-04-17 05:40:28 -07:00
|
|
|
if (!win->plugin_dedicated && p->trigger)
|
|
|
|
continue;
|
|
|
|
if (p == sel->aggregator)
|
|
|
|
continue;
|
|
|
|
/* dont wait for async plugin. use their current items */
|
2010-04-08 16:41:53 -07:00
|
|
|
if (!async && p->async_fetch && p->items)
|
2009-08-27 13:52:14 -07:00
|
|
|
{
|
|
|
|
s->cur_plugins = eina_list_append(s->cur_plugins, p);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-17 05:40:28 -07:00
|
|
|
p->changed = EINA_TRUE;
|
|
|
|
|
|
|
|
if ((p->fetch(p, input)) ||
|
|
|
|
(sel->states->next) ||
|
|
|
|
(win->plugin_dedicated))
|
|
|
|
{
|
|
|
|
s->cur_plugins = eina_list_append(s->cur_plugins, p);
|
|
|
|
}
|
2009-08-27 13:52:14 -07:00
|
|
|
}
|
2009-07-29 13:43:09 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2010-04-02 09:28:19 -07:00
|
|
|
if ((eina_list_count(s->cur_plugins) > 0) &&
|
|
|
|
/* dont add aggregator when there is only one plugin
|
|
|
|
which wont show items in agrregator */
|
|
|
|
!(eina_list_count(s->cur_plugins) == 1 &&
|
|
|
|
!((Evry_Plugin *)s->cur_plugins->data)->aggregate))
|
2009-07-03 08:56:21 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
s->cur_plugins = eina_list_prepend(s->cur_plugins, sel->aggregator);
|
2009-08-31 03:30:55 -07:00
|
|
|
sel->aggregator->fetch(sel->aggregator, input);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-08-13 15:42:40 -07:00
|
|
|
else
|
|
|
|
sel->aggregator->cleanup(sel->aggregator);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2010-04-11 07:29:23 -07:00
|
|
|
if (s->plugin_auto_selected ||
|
|
|
|
(s->plugin && (!eina_list_data_find(s->cur_plugins, s->plugin))))
|
|
|
|
_evry_plugin_select(s, NULL);
|
|
|
|
else
|
|
|
|
_evry_plugin_select(s, s->plugin);
|
|
|
|
|
2010-04-04 07:11:35 -07:00
|
|
|
if (sel->update_timer)
|
|
|
|
ecore_timer_del(sel->update_timer);
|
|
|
|
sel->update_timer = NULL;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_item_desel(Evry_State *s, Evry_Item *it)
|
2009-08-14 02:35:51 -07:00
|
|
|
{
|
2010-04-08 15:37:50 -07:00
|
|
|
if (!it)
|
|
|
|
it = s->cur_item;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
if (s->cur_item)
|
2010-04-07 08:03:27 -07:00
|
|
|
{
|
2010-04-08 16:41:53 -07:00
|
|
|
it->selected = EINA_FALSE;
|
2010-04-08 15:37:50 -07:00
|
|
|
evry_item_free(it);
|
2010-04-07 08:03:27 -07:00
|
|
|
}
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
s->cur_item = NULL;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_item_sel(Evry_State *s, Evry_Item *it)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-28 21:42:17 -07:00
|
|
|
if (s->cur_item == it) return;
|
2009-08-12 11:47:46 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_item_desel(s, NULL);
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
evry_item_ref(it);
|
2010-04-07 08:03:27 -07:00
|
|
|
it->selected = EINA_TRUE;
|
2010-04-08 16:41:53 -07:00
|
|
|
|
2009-08-28 21:42:17 -07:00
|
|
|
s->cur_item = it;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-20 14:39:01 -07:00
|
|
|
_evry_plugin_select(Evry_State *s, Evry_Plugin *p)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-13 15:42:40 -07:00
|
|
|
if (!s || !s->cur_plugins) return;
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
if (!p && s->cur_plugins)
|
|
|
|
{
|
|
|
|
p = s->cur_plugins->data;
|
2009-08-14 02:35:51 -07:00
|
|
|
s->plugin_auto_selected = EINA_TRUE;
|
2009-08-13 15:42:40 -07:00
|
|
|
}
|
2010-04-11 07:29:23 -07:00
|
|
|
else if (p)
|
|
|
|
{
|
|
|
|
s->plugin_auto_selected = EINA_FALSE;
|
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-25 17:53:12 -07:00
|
|
|
if (s->plugin != p)
|
2010-04-07 08:03:27 -07:00
|
|
|
{
|
|
|
|
_evry_item_desel(s, NULL);
|
|
|
|
}
|
2009-08-25 17:36:59 -07:00
|
|
|
|
2009-08-25 17:53:12 -07:00
|
|
|
s->plugin = p;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-20 14:39:01 -07:00
|
|
|
void
|
|
|
|
evry_plugin_select(const Evry_State *s, Evry_Plugin *p)
|
2009-08-20 07:45:47 -07:00
|
|
|
{
|
2010-04-17 12:13:01 -07:00
|
|
|
Evry_Selector *sel;
|
|
|
|
|
2009-08-20 14:39:01 -07:00
|
|
|
_evry_plugin_select((Evry_State *) s, p);
|
2009-08-20 07:45:47 -07:00
|
|
|
|
2010-04-17 12:13:01 -07:00
|
|
|
sel = _evry_selector_for_plugin_get(p);
|
|
|
|
|
|
|
|
if (sel)
|
|
|
|
_evry_selector_update(sel);
|
2009-08-20 07:45:47 -07:00
|
|
|
}
|
|
|
|
|
2009-08-12 11:47:46 -07:00
|
|
|
static void
|
|
|
|
_evry_plugin_list_insert(Evry_State *s, Evry_Plugin *p)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Plugin *plugin;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-12 11:47:46 -07:00
|
|
|
EINA_LIST_FOREACH(s->cur_plugins, l, plugin)
|
|
|
|
if (p == plugin)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
if (p->config->priority < plugin->config->priority)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (l)
|
|
|
|
s->cur_plugins = eina_list_prepend_relative_list(s->cur_plugins, p, l);
|
|
|
|
else
|
|
|
|
s->cur_plugins = eina_list_append(s->cur_plugins, p);
|
|
|
|
}
|
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
static int
|
|
|
|
_evry_cb_selection_notify(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Ecore_X_Event_Selection_Notify *ev;
|
2010-04-04 07:11:35 -07:00
|
|
|
/* FIXME Evry_Selector *sel = data; */
|
2009-08-18 07:29:30 -07:00
|
|
|
Evry_State *s = selector->state;
|
|
|
|
|
|
|
|
if (!s || (data != win)) return 1;
|
|
|
|
if (!win->request_selection) return 1;
|
|
|
|
|
|
|
|
win->request_selection = EINA_FALSE;
|
|
|
|
|
|
|
|
ev = event;
|
|
|
|
if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
|
|
|
|
(ev->selection == ECORE_X_SELECTION_PRIMARY))
|
|
|
|
{
|
|
|
|
if (strcmp(ev->target, ECORE_X_SELECTION_TARGET_UTF8_STRING) == 0)
|
|
|
|
{
|
|
|
|
Ecore_X_Selection_Data_Text *text_data;
|
|
|
|
|
|
|
|
text_data = ev->data;
|
|
|
|
|
|
|
|
strncat(s->input, text_data->text, (INPUTLEN - strlen(s->input)) - 1);
|
2010-04-04 07:11:35 -07:00
|
|
|
_evry_update(selector, 1);
|
2009-08-18 07:29:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2009-08-13 15:42:40 -07:00
|
|
|
|