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
|
|
|
|
*/
|
2009-05-06 07:20:45 -07:00
|
|
|
#define INPUTLEN 40
|
|
|
|
#define MATCH_LAG 0.33
|
2009-08-14 16:30:54 -07:00
|
|
|
#define MAX_FUZZ 150
|
2009-08-17 17:47:09 -07:00
|
|
|
#define MAX_WORDS 5
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
typedef struct _Evry_Window Evry_Window;
|
|
|
|
typedef struct _Evry_List_Window Evry_List_Window;
|
|
|
|
typedef struct _Evry_Selector Evry_Selector;
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
/* */
|
|
|
|
struct _Evry_Selector
|
|
|
|
{
|
|
|
|
Evas_Object *o_main;
|
|
|
|
Evas_Object *o_icon;
|
|
|
|
|
|
|
|
/* current state */
|
|
|
|
Evry_State *state;
|
|
|
|
|
|
|
|
/* stack of states (for browseable plugins) */
|
|
|
|
Eina_List *states;
|
|
|
|
|
|
|
|
/* provides collection of items from other plugins */
|
|
|
|
Evry_Plugin *aggregator;
|
|
|
|
|
|
|
|
/* */
|
|
|
|
Eina_List *actions;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
/* all plugins that belong to this selector*/
|
|
|
|
Eina_List *plugins;
|
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-10 04:36:37 -07:00
|
|
|
/* E_Popup *input_win; */
|
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;
|
|
|
|
Evas_Object *o_list;
|
|
|
|
Evas_Object *o_tabs;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
Evry_View *view;
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
Eina_Bool visible;
|
|
|
|
};
|
|
|
|
|
2009-08-12 15:34:07 -07:00
|
|
|
|
2009-08-12 05:17:43 -07:00
|
|
|
static void _evry_matches_update(Evry_Selector *sel);
|
2009-08-10 04:36:37 -07:00
|
|
|
static void _evry_plugin_action(Evry_Selector *sel, int finished);
|
|
|
|
static void _evry_backspace(Evry_State *s);
|
2009-08-15 13:12:04 -07:00
|
|
|
static void _evry_update(Evry_State *s, int fetch);
|
2009-08-16 02:43:38 -07:00
|
|
|
static int _evry_clear(Evry_State *s);
|
2009-05-06 07:20:45 -07:00
|
|
|
static int _evry_update_timer(void *data);
|
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 void _evry_select_plugin(Evry_State *s, Evry_Plugin *p);
|
|
|
|
static void _evry_update_text_label(Evry_State *s);
|
|
|
|
static void _evry_browse_item(Evry_Selector *sel);
|
|
|
|
static void _evry_browse_back(Evry_Selector *sel);
|
|
|
|
static void _evry_selectors_switch(void);
|
2009-08-14 02:35:51 -07:00
|
|
|
static void _evry_plugin_list_insert(Evry_State *s, Evry_Plugin *p);
|
2009-08-17 16:54:16 -07:00
|
|
|
static void _evry_plugin_next(Evry_State *s);
|
|
|
|
static void _evry_plugin_prev(Evry_State *s);
|
|
|
|
static void _evry_plugin_next_by_name(Evry_State *s, const char *key);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
static Evry_Window *_evry_window_new(E_Zone *zone);
|
|
|
|
static void _evry_window_free(Evry_Window *win);
|
|
|
|
static Evry_Selector *_evry_selector_new(int type);
|
|
|
|
static void _evry_selector_free(Evry_Selector *sel);
|
|
|
|
static void _evry_selector_activate(Evry_Selector *sel);
|
|
|
|
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);
|
|
|
|
static int _evry_selector_objects_get(const char *type);
|
|
|
|
|
|
|
|
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-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_list_win_update(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);
|
|
|
|
static int _evry_view_toggle(Evry_State *s);
|
|
|
|
|
|
|
|
static void _evry_item_desel(Evry_State *s, Evry_Item *it);
|
|
|
|
static void _evry_item_sel(Evry_State *s, Evry_Item *it);
|
|
|
|
static void _evry_tab_scroll_to(Evry_State *s, Evry_Plugin *p);
|
|
|
|
static void _evry_tab_show(Evry_State *s, Evry_Plugin *p);
|
|
|
|
static void _evry_tabs_update(Evry_State *s);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
static int _evry_plug_actions_init(void);
|
2009-08-14 02:35:51 -07:00
|
|
|
static void _evry_plug_actions_free(void);
|
2009-08-12 05:17:43 -07:00
|
|
|
static int _evry_plug_actions_begin(Evry_Plugin *p, const Evry_Item *it);
|
2009-08-10 04:36:37 -07:00
|
|
|
static int _evry_plug_actions_fetch(Evry_Plugin *p, const char *input);
|
|
|
|
static void _evry_plug_actions_cleanup(Evry_Plugin *p);
|
2009-08-12 05:17:43 -07:00
|
|
|
static Evas_Object *_evry_plug_actions_item_icon_get(Evry_Plugin *p, const Evry_Item *it, Evas *e);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
static Evry_Plugin *_evry_plug_aggregator_new(void);
|
|
|
|
static void _evry_plug_aggregator_free(Evry_Plugin *p);
|
|
|
|
static int _evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input);
|
2009-08-12 05:17:43 -07:00
|
|
|
static int _evry_plug_aggregator_action(Evry_Plugin *p, const Evry_Item *item, const char *input);
|
2009-08-10 04:36:37 -07:00
|
|
|
static void _evry_plug_aggregator_cleanup(Evry_Plugin *p);
|
2009-08-12 05:17:43 -07:00
|
|
|
static Evas_Object *_evry_plug_aggregator_item_icon_get(Evry_Plugin *p, const Evry_Item *it, Evas *e);
|
2009-06-21 14:16:02 -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;
|
|
|
|
static Ecore_Timer *update_timer = NULL;
|
2009-08-10 04:36:37 -07:00
|
|
|
static Evry_Selector *selectors[3];
|
|
|
|
static Evry_Selector *selector = NULL;
|
2009-06-24 13:02:37 -07:00
|
|
|
static Evry_Plugin *action_selector = NULL;
|
2009-08-18 07:29:30 -07:00
|
|
|
static Eina_Hash *mime_hash = NULL;
|
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)
|
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_plug_actions_init();
|
2009-08-16 02:43:38 -07:00
|
|
|
|
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-14 02:35:51 -07:00
|
|
|
_evry_plug_actions_free();
|
2009-08-16 01:36:56 -07:00
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
win = _evry_window_new(zone);
|
|
|
|
if (!win) goto error;
|
|
|
|
|
|
|
|
list = _evry_list_win_new(zone);
|
|
|
|
if (!list) goto error;
|
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-10 04:36:37 -07:00
|
|
|
/* TODO check NULL */
|
|
|
|
selectors[0] = _evry_selector_new(type_subject);
|
|
|
|
selectors[1] = _evry_selector_new(type_action);
|
|
|
|
selectors[2] = _evry_selector_new(type_object);
|
|
|
|
|
2009-08-18 17:27:41 -07:00
|
|
|
if (params)
|
|
|
|
win->plugin_dedicated = EINA_TRUE;
|
2009-08-18 07:29:30 -07:00
|
|
|
|
|
|
|
mime_hash = eina_hash_stringshared_new(NULL);
|
|
|
|
|
2009-08-18 17:27:41 -07:00
|
|
|
_evry_selector_subjects_get(params);
|
|
|
|
_evry_selector_activate(selectors[0]);
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_update(selector);
|
|
|
|
|
|
|
|
e_popup_layer_set(list->popup, 255);
|
2009-08-12 12:00:25 -07:00
|
|
|
e_popup_layer_set(win->popup, 255);
|
|
|
|
e_popup_show(win->popup);
|
2009-08-10 04:36:37 -07:00
|
|
|
e_popup_show(list->popup);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
e_box_align_set(list->o_tabs, 0.0, 0.5);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-16 20:30:04 -07:00
|
|
|
if (!evry_conf->hide_input)
|
|
|
|
edje_object_signal_emit(list->o_main, "e,state,entry_show", "e");
|
2009-08-17 16:54:16 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
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));
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return 1;
|
2009-07-07 09:30:11 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
error:
|
|
|
|
if (win && selectors[0])
|
|
|
|
_evry_selector_free(selectors[0]);
|
|
|
|
if (win && selectors[1])
|
|
|
|
_evry_selector_free(selectors[1]);
|
|
|
|
if (win && selectors[2])
|
|
|
|
_evry_selector_free(selectors[2]);
|
|
|
|
|
|
|
|
if (win)
|
|
|
|
_evry_window_free(win);
|
|
|
|
if (list)
|
|
|
|
_evry_list_win_free(list);
|
|
|
|
win = NULL;
|
|
|
|
list = NULL;
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
Ecore_Event *ev;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!win) return;
|
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_clear(selector->state);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
if (update_timer)
|
|
|
|
ecore_timer_del(update_timer);
|
|
|
|
update_timer = NULL;
|
2009-07-07 09:30:11 -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]);
|
|
|
|
selectors[0] = NULL;
|
|
|
|
selectors[1] = NULL;
|
|
|
|
selectors[2] = NULL;
|
|
|
|
selector = NULL;
|
2009-08-12 12:00:25 -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-18 07:29:30 -07:00
|
|
|
eina_hash_free(mime_hash);
|
|
|
|
mime_hash = NULL;
|
|
|
|
|
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-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-13 08:10:54 -07:00
|
|
|
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
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (s->input[0] != 0)
|
|
|
|
{
|
|
|
|
s->input[0] = 0;
|
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
|
|
|
|
/* static int item_cnt = 0; */
|
|
|
|
|
2009-08-13 08:10:54 -07:00
|
|
|
Evry_Item *
|
2009-08-13 15:42:40 -07:00
|
|
|
evry_item_new(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-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
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-18 12:10:13 -07:00
|
|
|
if (cb_free) it->cb_free = cb_free;
|
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
it->ref = 1;
|
|
|
|
|
|
|
|
/* item_cnt++; */
|
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-13 08:10:54 -07:00
|
|
|
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--;
|
|
|
|
|
|
|
|
if (it->ref > 0) return;
|
|
|
|
|
2009-08-16 09:26:49 -07:00
|
|
|
/* printf("%d, %d\t free: %s\n",
|
2009-08-13 15:42:40 -07:00
|
|
|
* it->ref, item_cnt - 1,
|
2009-08-16 09:26:49 -07:00
|
|
|
* it->label);
|
|
|
|
* item_cnt--; */
|
2009-08-13 15:42:40 -07:00
|
|
|
|
|
|
|
if (it->cb_free) it->cb_free(it);
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (it->label) eina_stringshare_del(it->label);
|
2009-08-13 15:42:40 -07:00
|
|
|
if (it->uri) eina_stringshare_del(it->uri);
|
|
|
|
if (it->mime) eina_stringshare_del(it->mime);
|
|
|
|
|
2009-08-13 07:01:29 -07:00
|
|
|
if (it->o_bg) evas_object_del(it->o_bg);
|
|
|
|
if (it->o_icon) evas_object_del(it->o_icon);
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
E_FREE(it);
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
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;
|
|
|
|
|
|
|
|
s->plugin_auto_selected = EINA_FALSE;
|
|
|
|
s->item_auto_selected = EINA_FALSE;
|
|
|
|
_evry_item_sel(s, it);
|
|
|
|
_evry_selector_update(selector);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evry_item_ref(Evry_Item *it)
|
2009-08-13 15:42:40 -07:00
|
|
|
{
|
|
|
|
it->ref++;
|
|
|
|
}
|
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
int
|
|
|
|
evry_list_win_show(void)
|
|
|
|
{
|
|
|
|
if (list->visible) return 0;
|
|
|
|
|
|
|
|
_evry_list_win_show();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
evry_list_win_hide(void)
|
|
|
|
{
|
|
|
|
_evry_list_win_clear(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-08-14 02:35:51 -07:00
|
|
|
void
|
|
|
|
evry_plugin_async_update(Evry_Plugin *p, int action)
|
|
|
|
{
|
|
|
|
Evry_State *s;
|
|
|
|
Evry_Plugin *agg;
|
|
|
|
|
|
|
|
if (!win) return;
|
|
|
|
|
|
|
|
s = selector->state;
|
|
|
|
agg = selector->aggregator;
|
|
|
|
|
|
|
|
/* received data from a plugin of the current selector ? */
|
2009-08-18 17:27:41 -07:00
|
|
|
if (!s || !eina_list_data_find(s->plugins, p))
|
|
|
|
{
|
|
|
|
if (p->type == type_action)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
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);
|
|
|
|
|
|
|
|
if (s->plugin == p)
|
|
|
|
_evry_select_plugin(s, NULL);
|
|
|
|
}
|
|
|
|
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))
|
|
|
|
_evry_select_plugin(s, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update aggregator */
|
|
|
|
if (eina_list_count(s->cur_plugins) > 1)
|
|
|
|
{
|
2009-08-14 07:44:18 -07:00
|
|
|
agg->fetch(agg, s->input);
|
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)
|
|
|
|
_evry_select_plugin(s, agg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* plugin is visible */
|
|
|
|
if ((s->plugin == p) || (s->plugin == agg))
|
|
|
|
{
|
|
|
|
_evry_selector_update(selector);
|
|
|
|
p = s->plugin;
|
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
/* _evry_view_clear(s); */
|
|
|
|
_evry_view_update(s, p);
|
|
|
|
/* _evry_list_scroll_to(s, s->sel_item); */
|
2009-08-14 02:35:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* plugin box was updated: realign */
|
|
|
|
if (s->plugin)
|
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_tabs_update(s);
|
|
|
|
/* _evry_tab_scroll_to(s, s->plugin); */
|
2009-08-14 02:35:51 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-14 07:44:18 -07:00
|
|
|
int
|
|
|
|
evry_fuzzy_match(const char *str, const char *match)
|
|
|
|
{
|
2009-08-15 11:09:13 -07:00
|
|
|
const char *p, *m, *next;
|
|
|
|
int sum = 0;
|
|
|
|
|
2009-08-14 07:44:18 -07:00
|
|
|
unsigned int last = 0;
|
2009-08-15 11:09:13 -07:00
|
|
|
unsigned int offset = 0;
|
2009-08-14 16:30:54 -07:00
|
|
|
unsigned int min = 0;
|
2009-08-15 11:09:13 -07:00
|
|
|
unsigned char first = 0;
|
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
unsigned int cnt = 0;
|
2009-08-15 11:09:13 -07:00
|
|
|
/* words in match */
|
2009-08-17 17:47:09 -07:00
|
|
|
unsigned int m_num = 1;
|
|
|
|
unsigned int m_cnt = 0;
|
|
|
|
unsigned int m_min[MAX_WORDS];
|
2009-08-14 16:30:54 -07:00
|
|
|
|
2009-08-14 09:28:00 -07:00
|
|
|
if (!match || !str) return 0;
|
2009-08-14 07:44:18 -07:00
|
|
|
|
2009-08-15 11:18:27 -07:00
|
|
|
/* remove white spaces at the beginning */
|
|
|
|
for (; (*match != 0) && isspace(*match); match++);
|
|
|
|
for (; (*str != 0) && isspace(*str); str++);
|
2009-08-15 13:12:04 -07:00
|
|
|
|
|
|
|
/* count words in match */
|
2009-08-17 17:47:09 -07:00
|
|
|
m_min[0] = MAX_FUZZ;
|
|
|
|
for (m = match; (*m != 0) && (*(m+1) != 0) && (m_num < MAX_WORDS); m++)
|
2009-08-17 16:54:16 -07:00
|
|
|
if (isspace(*m) && !isspace(*(m+1)))
|
2009-08-17 17:47:09 -07:00
|
|
|
m_min[m_num++] = MAX_FUZZ;
|
2009-08-15 11:09:13 -07:00
|
|
|
|
2009-08-15 13:12:04 -07:00
|
|
|
next = str;
|
2009-08-15 11:09:13 -07:00
|
|
|
m = match;
|
|
|
|
|
2009-08-17 20:15:36 -07:00
|
|
|
while((m_cnt < m_num) && (*next != 0))
|
2009-08-14 07:44:18 -07:00
|
|
|
{
|
2009-08-15 11:09:13 -07:00
|
|
|
/* reset match */
|
2009-08-17 17:47:09 -07:00
|
|
|
if (m_cnt == 0) m = match;
|
2009-08-15 11:09:13 -07:00
|
|
|
|
|
|
|
/* end of matching */
|
|
|
|
if (*m == 0) break;
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
last = 0;
|
|
|
|
min = 1;
|
2009-08-14 09:18:25 -07:00
|
|
|
first = 0;
|
|
|
|
|
2009-08-15 11:09:13 -07:00
|
|
|
/* match current word of string against current match */
|
2009-08-15 13:12:04 -07:00
|
|
|
for (p = next; *next != 0; p++)
|
2009-08-14 07:44:18 -07:00
|
|
|
{
|
2009-08-14 16:30:54 -07:00
|
|
|
/* new word of string begins */
|
2009-08-16 01:36:56 -07:00
|
|
|
if ((*p == 0) || isspace(*p))
|
2009-08-14 16:30:54 -07:00
|
|
|
{
|
2009-08-17 17:47:09 -07:00
|
|
|
if (m_cnt < m_num - 1)
|
2009-08-15 11:09:13 -07:00
|
|
|
{
|
|
|
|
/* test next match */
|
|
|
|
for (; (*m != 0) && !isspace(*m); m++);
|
|
|
|
for (; (*m != 0) && isspace(*m); m++);
|
2009-08-17 17:47:09 -07:00
|
|
|
m_cnt++;
|
2009-08-15 11:09:13 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
2009-08-14 16:30:54 -07:00
|
|
|
{
|
2009-08-15 11:09:13 -07:00
|
|
|
/* go to next word */
|
|
|
|
for (; (*p != 0) && isspace(*p); p++);
|
2009-08-17 16:54:16 -07:00
|
|
|
cnt++;
|
2009-08-15 11:09:13 -07:00
|
|
|
next = p;
|
2009-08-17 17:47:09 -07:00
|
|
|
m_cnt = 0;
|
2009-08-15 11:09:13 -07:00
|
|
|
break;
|
2009-08-14 16:30:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-15 11:09:13 -07:00
|
|
|
/* current char matches? */
|
2009-08-16 01:36:56 -07:00
|
|
|
if (tolower(*p) != tolower(*m))
|
2009-08-14 07:44:18 -07:00
|
|
|
{
|
2009-08-18 17:27:41 -07:00
|
|
|
if (!first)
|
|
|
|
offset += 1;
|
|
|
|
else
|
|
|
|
offset += 3;
|
|
|
|
|
|
|
|
if (offset < 10)
|
|
|
|
continue;
|
2009-08-14 07:44:18 -07:00
|
|
|
}
|
2009-08-18 17:27:41 -07:00
|
|
|
|
|
|
|
if (min < MAX_FUZZ && offset < 10)
|
2009-08-15 11:09:13 -07:00
|
|
|
{
|
2009-08-18 17:27:41 -07:00
|
|
|
/* first offset of match in word */
|
|
|
|
if (!first)
|
|
|
|
{
|
|
|
|
first = 1;
|
|
|
|
last = offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
min += offset + (offset - last) * 5;
|
2009-08-15 11:09:13 -07:00
|
|
|
last = offset;
|
2009-08-18 17:27:41 -07:00
|
|
|
|
|
|
|
/* try next char of match */
|
|
|
|
if (*(++m) != 0 && !isspace(*m))
|
|
|
|
continue;
|
2009-08-14 07:44:18 -07:00
|
|
|
|
2009-08-18 17:27:41 -07:00
|
|
|
/* end of match: store min weight of match */
|
|
|
|
min += (cnt - m_cnt) > 0 ? (cnt - m_cnt) : 0;
|
2009-08-14 11:55:35 -07:00
|
|
|
|
2009-08-18 17:27:41 -07:00
|
|
|
if (min < m_min[m_cnt])
|
|
|
|
m_min[m_cnt] = min;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* go to next match */
|
|
|
|
for (; (*m != 0) && !isspace(*m); m++);
|
|
|
|
}
|
|
|
|
|
2009-08-17 17:47:09 -07:00
|
|
|
if (m_cnt < m_num - 1)
|
2009-08-15 11:09:13 -07:00
|
|
|
{
|
|
|
|
/* test next match */
|
|
|
|
for (; (*m != 0) && isspace(*m); m++);
|
2009-08-17 17:47:09 -07:00
|
|
|
m_cnt++;
|
2009-08-15 11:09:13 -07:00
|
|
|
break;
|
|
|
|
}
|
2009-08-15 13:12:04 -07:00
|
|
|
else if(*p != 0)
|
2009-08-15 11:09:13 -07:00
|
|
|
{
|
|
|
|
/* go to next word */
|
|
|
|
for (; (*p != 0) && !isspace(*p); p++);
|
|
|
|
for (; (*p != 0) && isspace(*p); p++);
|
2009-08-17 16:54:16 -07:00
|
|
|
cnt++;
|
2009-08-15 11:09:13 -07:00
|
|
|
next = p;
|
2009-08-17 17:47:09 -07:00
|
|
|
m_cnt = 0;
|
2009-08-15 11:09:13 -07:00
|
|
|
break;
|
|
|
|
}
|
2009-08-15 13:12:04 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
next = p;
|
|
|
|
break;
|
|
|
|
}
|
2009-08-14 07:44:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-17 17:47:09 -07:00
|
|
|
for (m_cnt = 0; m_cnt < m_num; m_cnt++)
|
2009-08-15 11:09:13 -07:00
|
|
|
{
|
2009-08-17 20:15:36 -07:00
|
|
|
sum += m_min[m_cnt];
|
2009-08-18 07:29:30 -07:00
|
|
|
|
2009-08-17 20:15:36 -07:00
|
|
|
if (sum >= MAX_FUZZ)
|
2009-08-15 11:09:13 -07:00
|
|
|
{
|
|
|
|
sum = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-08-14 16:30:54 -07:00
|
|
|
|
2009-08-15 11:09:13 -07:00
|
|
|
return sum;
|
2009-08-14 07:44:18 -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-16 10:12:18 -07:00
|
|
|
int x, y, mw, mh;
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_List_Window *list_win;
|
|
|
|
E_Popup *popup;
|
|
|
|
Evas_Object *o;
|
2009-08-16 10:12:18 -07:00
|
|
|
const char *offset_y;
|
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;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
|
|
|
evas_event_freeze(popup->evas);
|
|
|
|
evas_event_feed_mouse_in(popup->evas, ecore_x_current_time_get(), NULL);
|
|
|
|
evas_event_feed_mouse_move(popup->evas, -1000000, -1000000, ecore_x_current_time_get(), NULL);
|
|
|
|
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-10 04:36:37 -07:00
|
|
|
"e/widgets/everything/list");
|
2009-08-16 10:12:18 -07:00
|
|
|
offset_y = edje_object_data_get(o, "offset_y");
|
|
|
|
edje_object_size_min_get(o, &mw, &mh);
|
|
|
|
if (mh == 0) mh = 200;
|
|
|
|
if (mw == 0) mw = win->popup->w / 2;
|
|
|
|
|
|
|
|
x = (win->popup->x + win->popup->w / 2) - (mw / 2);
|
|
|
|
y = (win->popup->y + win->popup->h) + (offset_y ? atoi(offset_y) : 0);
|
|
|
|
|
|
|
|
e_popup_move_resize(popup, x, y, mw, mh);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
list_win->view = evry_conf->views->data;
|
|
|
|
o = list_win->view->begin(list_win->view, NULL, list_win->o_main);
|
2009-08-10 04:36:37 -07:00
|
|
|
edje_object_part_swallow(list_win->o_main, "e.swallow.list", o);
|
2009-05-06 07:20:45 -07:00
|
|
|
evas_object_show(o);
|
2009-08-17 16:54:16 -07:00
|
|
|
list_win->o_list = o;
|
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);
|
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
o = e_box_add(popup->evas);
|
|
|
|
e_box_orientation_set(o, 1);
|
2009-08-10 04:36:37 -07:00
|
|
|
/* e_box_homogenous_set(o, 1); */
|
|
|
|
edje_object_part_swallow(list_win->o_main, "e.swallow.bar", o);
|
2009-05-06 07:20:45 -07:00
|
|
|
evas_object_show(o);
|
2009-08-10 04:36:37 -07:00
|
|
|
list_win->o_tabs = o;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
evas_event_thaw(popup->evas);
|
2009-07-09 17:05:01 -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-17 16:54:16 -07:00
|
|
|
list_win->view->cleanup(list_win->view);
|
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_tabs);
|
|
|
|
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-12 12:00:25 -07:00
|
|
|
|
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-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
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Plugin *p;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!list->visible) return;
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
EINA_LIST_FOREACH(selector->plugins, l, p)
|
|
|
|
{
|
2009-08-12 12:00:25 -07:00
|
|
|
e_box_unpack(p->tab);
|
2009-08-10 04:36:37 -07:00
|
|
|
evas_object_del(p->tab);
|
|
|
|
p->tab = NULL;
|
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-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;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
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",
|
|
|
|
"e/widgets/everything/main");
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
edje_object_size_min_get(o, &mw, &mh);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
x = (zone->w / 2) - (mw / 2);
|
|
|
|
y = (zone->h / 2) - mh;
|
2009-05-06 07:20:45 -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);
|
|
|
|
/* evas_event_thaw(win->popup->evas); */
|
|
|
|
e_object_del(E_OBJECT(win->popup));
|
|
|
|
E_FREE(win);
|
|
|
|
}
|
|
|
|
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",
|
|
|
|
"e/widgets/everything/selector_item");
|
|
|
|
evas_object_show(o);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (type == type_subject)
|
|
|
|
edje_object_part_swallow(win->o_main, "e.swallow.subject_selector", o);
|
|
|
|
else if (type == type_action)
|
|
|
|
edje_object_part_swallow(win->o_main, "e.swallow.action_selector", o);
|
|
|
|
else if (type == type_object)
|
|
|
|
edje_object_part_swallow(win->o_main, "e.swallow.object_selector", o);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
p = _evry_plug_aggregator_new();
|
|
|
|
p->private = sel;
|
|
|
|
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
|
|
|
{
|
|
|
|
Evry_Plugin *p;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (sel->o_icon)
|
|
|
|
evas_object_del(sel->o_icon);
|
|
|
|
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);
|
2009-08-12 12:00:25 -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
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
EINA_LIST_FREE(sel->plugins, p)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-13 15:42:40 -07:00
|
|
|
if (p->tab) evas_object_del(p->tab);
|
|
|
|
p->tab = NULL;
|
2009-07-10 08:47:19 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_plug_aggregator_free(sel->aggregator);
|
|
|
|
|
2009-08-12 05:17:43 -07:00
|
|
|
if (sel->plugins) eina_list_free(sel->plugins);
|
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-12 11:47:46 -07:00
|
|
|
Evry_Plugin *p;
|
|
|
|
Eina_List *l;
|
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-12 11:47:46 -07:00
|
|
|
EINA_LIST_FOREACH(selector->plugins, l, p)
|
|
|
|
{
|
2009-08-12 12:00:25 -07:00
|
|
|
e_box_unpack(p->tab);
|
2009-08-12 11:47:46 -07:00
|
|
|
evas_object_del(p->tab);
|
|
|
|
p->tab = NULL;
|
|
|
|
}
|
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (s && s->view)
|
|
|
|
_evry_view_toggle(s);
|
|
|
|
|
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
|
|
|
|
|
|
|
if (sel->state->sel_item)
|
|
|
|
edje_object_part_text_set(sel->o_main, "e.text.plugin",
|
2009-08-16 19:06:41 -07:00
|
|
|
s->sel_item->plugin->name);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_list_win_update(s);
|
2009-06-21 03:31:38 -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-10 04:36:37 -07:00
|
|
|
it = s->sel_item;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (it && it->plugin && it->plugin->icon_get)
|
|
|
|
{
|
|
|
|
o = it->plugin->icon_get(it->plugin, it, win->popup->evas);
|
|
|
|
if (o)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
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-12 12:00:25 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
else if (s->plugin && s->plugin->icon)
|
|
|
|
{
|
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
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
it = s->sel_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-14 16:30:54 -07:00
|
|
|
it = s->sel_item;
|
|
|
|
|
|
|
|
if (s->plugin && (!it || s->item_auto_selected))
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-14 16:30:54 -07:00
|
|
|
/* get first item */
|
|
|
|
if (s->plugin->items)
|
|
|
|
{
|
|
|
|
it = s->plugin->items->data;
|
|
|
|
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)
|
|
|
|
edje_object_part_text_set(sel->o_main, "e.text.plugin", it->plugin->name);
|
|
|
|
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)
|
2009-08-10 04:36:37 -07:00
|
|
|
edje_object_part_text_set(sel->o_main, "e.text.plugin", s->plugin->name);
|
|
|
|
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])
|
|
|
|
{
|
2009-08-14 16:30:54 -07:00
|
|
|
_evry_selector_actions_get(it);
|
|
|
|
_evry_selector_update(selectors[1]);
|
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
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
/* if (!s->plugin) return; */
|
|
|
|
_evry_view_update(s, s->plugin);
|
|
|
|
_evry_tabs_update(s);
|
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;
|
|
|
|
Evry_Plugin *p;
|
|
|
|
Evry_Selector *sel = selectors[0];
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
EINA_LIST_FOREACH(sel->plugins, l, p)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-18 17:27:41 -07:00
|
|
|
if (plugin_name && strcmp(plugin_name, p->name))
|
|
|
|
continue;
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (p->begin)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
if (p->begin(p, NULL))
|
|
|
|
plugins = eina_list_append(plugins, p);
|
2009-07-04 04:10:28 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
else
|
|
|
|
plugins = eina_list_append(plugins, p);
|
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-12 12:00:25 -07:00
|
|
|
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_matches_update(sel);
|
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;
|
|
|
|
Evry_Plugin *p;
|
|
|
|
Evry_Selector *sel = selectors[1];
|
2009-08-18 07:29:30 -07:00
|
|
|
const char *type_out;
|
2009-07-04 04:10:28 -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-10 04:36:37 -07:00
|
|
|
EINA_LIST_FOREACH(sel->plugins, l, p)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-17 20:15:36 -07:00
|
|
|
if ((p == action_selector) || (p == sel->aggregator) ||
|
2009-08-18 07:29:30 -07:00
|
|
|
(p->type_in && type_out && p->type_in == type_out))
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-17 20:15:36 -07:00
|
|
|
if (p->begin)
|
|
|
|
{
|
|
|
|
if (p->begin(p, it))
|
|
|
|
plugins = eina_list_append(plugins, p);
|
|
|
|
}
|
|
|
|
else
|
2009-08-10 04:36:37 -07:00
|
|
|
plugins = eina_list_append(plugins, p);
|
|
|
|
}
|
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-12 12:00:25 -07:00
|
|
|
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_matches_update(sel);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-07-04 04:10:28 -07:00
|
|
|
static int
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_objects_get(const char *type)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Eina_List *l, *plugins = NULL;
|
|
|
|
Evry_Plugin *p;
|
|
|
|
Evry_Selector *sel = selectors[2];
|
|
|
|
Evry_Item *it;
|
2009-08-12 12:00:25 -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-12 05:17:43 -07:00
|
|
|
it = selectors[0]->state->sel_item;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
EINA_LIST_FOREACH(sel->plugins, l, p)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
if (strcmp(p->type_out, type) &&
|
|
|
|
(p != sel->aggregator)) continue;
|
|
|
|
|
|
|
|
if (p->begin)
|
|
|
|
{
|
|
|
|
if (p->begin(p, it))
|
|
|
|
plugins = eina_list_append(plugins, p);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
plugins = eina_list_append(plugins, p);
|
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-11 10:03:36 -07:00
|
|
|
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_matches_update(sel);
|
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);
|
|
|
|
s->input = malloc(INPUTLEN);
|
|
|
|
s->input[0] = 0;
|
|
|
|
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
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
free(s->input);
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
EINA_LIST_FREE(s->plugins, p)
|
2009-08-10 04:36:37 -07:00
|
|
|
p->cleanup(p);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (s->view)
|
|
|
|
{
|
|
|
|
s->view->cleanup(s->view);
|
|
|
|
s->view = NULL;
|
|
|
|
s->o_view = NULL;
|
|
|
|
/* if (s->o_view) evas_object_del(s->o_view); */
|
|
|
|
}
|
2009-08-16 19:06:41 -07:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evry_browse_item(Evry_Selector *sel)
|
|
|
|
{
|
|
|
|
Evry_State *s = sel->state;
|
|
|
|
Evry_Item *it;
|
|
|
|
Eina_List *l, *plugins = NULL;
|
|
|
|
Evry_Plugin *p;
|
2009-08-18 07:29:30 -07:00
|
|
|
const char *type_out;
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
it = s->sel_item;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
if (!it || !it->browseable)
|
|
|
|
return;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_clear(sel->state);
|
2009-08-12 05:17:43 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
type_out = it->plugin->type_out;
|
|
|
|
|
|
|
|
if (!type_out)
|
|
|
|
return;
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
EINA_LIST_FOREACH(sel->plugins, l, p)
|
|
|
|
{
|
2009-08-18 07:29:30 -07:00
|
|
|
if (!p->browse || !p->type_in || p->type_in != type_out)
|
|
|
|
continue;
|
2009-08-12 05:17:43 -07:00
|
|
|
|
|
|
|
if (p->browse(p, it))
|
2009-08-10 04:36:37 -07:00
|
|
|
plugins = eina_list_append(plugins, p);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (plugins)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-16 19:06:41 -07:00
|
|
|
/* _evry_list_win_show(); */
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_state_new(sel, plugins);
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_matches_update(sel);
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_update(sel);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_list_win_update(sel->state);
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_update_text_label(sel->state);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evry_browse_back(Evry_Selector *sel)
|
|
|
|
{
|
|
|
|
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-17 16:54:16 -07:00
|
|
|
/* _evry_view_clear(s); */
|
|
|
|
if (s->view)
|
|
|
|
{
|
|
|
|
_evry_view_toggle(s);
|
|
|
|
|
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_state_pop(sel);
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2009-08-14 07:44:18 -07:00
|
|
|
sel->aggregator->fetch(sel->aggregator, sel->state->input);
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_update(sel);
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_list_win_update(sel->state);
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_update_text_label(sel->state);
|
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
|
|
|
|
2009-08-12 13:26:27 -07:00
|
|
|
if (update_timer)
|
|
|
|
{
|
2009-08-17 20:15:36 -07:00
|
|
|
if ((s && !s->plugin->async_fetch) &&
|
2009-08-12 13:26:27 -07:00
|
|
|
((selector == selectors[0]) ||
|
|
|
|
(selector == selectors[1])))
|
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_clear(s);
|
2009-08-12 13:26:27 -07:00
|
|
|
_evry_matches_update(selector);
|
|
|
|
_evry_selector_update(selector);
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_timer_del(update_timer);
|
|
|
|
update_timer = NULL;
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (selector == selectors[0])
|
|
|
|
{
|
|
|
|
if (s->sel_item)
|
|
|
|
_evry_selector_activate(selectors[1]);
|
|
|
|
}
|
|
|
|
else if (selector == selectors[1])
|
|
|
|
{
|
|
|
|
int next_selector = 0;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-14 11:55:35 -07:00
|
|
|
if (s->sel_item && s->sel_item->plugin == action_selector)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-12 13:26:27 -07:00
|
|
|
Evry_Action *act = s->sel_item->data[0];
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (act && act->type_in2)
|
|
|
|
{
|
|
|
|
_evry_selector_objects_get(act->type_in2);
|
2009-08-12 13:26:27 -07:00
|
|
|
_evry_selector_update(selectors[2]);
|
2009-08-10 04:36:37 -07:00
|
|
|
edje_object_signal_emit(win->o_main,
|
|
|
|
"e,state,object_selector_show", "e");
|
|
|
|
next_selector = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_evry_selector_activate(selectors[next_selector]);
|
|
|
|
}
|
|
|
|
else if (selector == selectors[2])
|
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_clear(s);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
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-10 04:36:37 -07:00
|
|
|
static int
|
|
|
|
_evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Ecore_Event_Key *ev;
|
|
|
|
Evry_State *s = selector->state;
|
2009-08-17 16:54:16 -07:00
|
|
|
const char *key = NULL, *old;
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
/* ev_last_is_mouse = 0;
|
|
|
|
* item_mouseover = NULL; */
|
|
|
|
|
2009-08-12 16:14:05 -07:00
|
|
|
win->request_selection = EINA_FALSE;
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
ev = event;
|
|
|
|
if (ev->event_window != input_window) return 1;
|
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
old = ev->key;
|
|
|
|
|
|
|
|
if (evry_conf->quick_nav && (ev->modifiers & ECORE_EVENT_MODIFIER_ALT))
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
ev->key = key;
|
|
|
|
}
|
|
|
|
else
|
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")))
|
|
|
|
evry_list_win_show();
|
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
|
|
|
{
|
|
|
|
if (!_evry_clear(s))
|
|
|
|
_evry_browse_back(selector);
|
|
|
|
}
|
2009-08-17 18:00:18 -07:00
|
|
|
else if (!strcmp(key, "1"))
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_toggle(s);
|
|
|
|
else if (!strcmp(key, "Tab"))
|
|
|
|
_evry_plugin_next(s);
|
|
|
|
else if (!strcmp(key, "Right"))
|
|
|
|
_evry_plugin_next(s);
|
|
|
|
else if (!strcmp(key, "Left"))
|
|
|
|
_evry_plugin_prev(s);
|
|
|
|
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-17 16:54:16 -07:00
|
|
|
else _evry_plugin_next_by_name(s, key);
|
2009-08-16 02:43:38 -07:00
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "Right"))
|
2009-08-16 02:43:38 -07:00
|
|
|
{
|
|
|
|
if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_plugin_next(s);
|
2009-08-16 02:43:38 -07:00
|
|
|
else
|
|
|
|
_evry_browse_item(selector);
|
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "Left"))
|
2009-08-16 02:43:38 -07:00
|
|
|
{
|
|
|
|
if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_plugin_prev(s);
|
2009-08-16 02:43:38 -07:00
|
|
|
else
|
|
|
|
_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);
|
|
|
|
else
|
|
|
|
_evry_plugin_action(selector, 1);
|
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "Escape"))
|
2009-08-10 04:36:37 -07:00
|
|
|
evry_hide();
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "Next"))
|
|
|
|
_evry_plugin_next(s);
|
|
|
|
else if (!strcmp(key, "Prior"))
|
|
|
|
_evry_plugin_prev(s);
|
|
|
|
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-16 09:26:49 -07:00
|
|
|
_evry_backspace(s);
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!strcmp(key, "Delete"))
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_backspace(s);
|
2009-08-17 16:54:16 -07:00
|
|
|
else if (!(_evry_view_key_press(s, ev)) &&
|
|
|
|
(ev->compose && !(ev->modifiers & ECORE_EVENT_MODIFIER_ALT)))
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-12 15:34:07 -07:00
|
|
|
if (strlen(s->input) < (INPUTLEN - strlen(ev->compose)))
|
|
|
|
{
|
|
|
|
strcat(s->input, ev->compose);
|
2009-08-15 13:12:04 -07:00
|
|
|
if (isspace(*ev->compose))
|
|
|
|
_evry_update(s, 0);
|
|
|
|
else
|
|
|
|
_evry_update(s, 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
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_backspace(Evry_State *s)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
int len, val, pos;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
len = strlen(s->input);
|
2009-05-06 07:20:45 -07:00
|
|
|
if (len > 0)
|
|
|
|
{
|
2009-06-21 03:31:38 -07:00
|
|
|
pos = evas_string_char_prev_get(s->input, len, &val);
|
2009-05-06 07:20:45 -07:00
|
|
|
if ((pos < len) && (pos >= 0))
|
|
|
|
{
|
2009-06-21 03:31:38 -07:00
|
|
|
s->input[pos] = 0;
|
2009-08-15 13:12:04 -07:00
|
|
|
_evry_update(s, 1);
|
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-16 20:30:04 -07:00
|
|
|
if (evry_conf->hide_input)
|
|
|
|
{
|
|
|
|
if (strlen(s->input) > 0)
|
|
|
|
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
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
edje_object_part_text_set(win->o_main, "e.text.label", s->input);
|
|
|
|
edje_object_part_text_set(list->o_main, "e.text.label", s->input);
|
|
|
|
|
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
2009-08-15 13:12:04 -07:00
|
|
|
_evry_update(Evry_State *s, int fetch)
|
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)
|
|
|
|
{
|
|
|
|
if (update_timer) ecore_timer_del(update_timer);
|
|
|
|
update_timer = ecore_timer_add(MATCH_LAG, _evry_update_timer, s);
|
|
|
|
}
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
static int
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_update_timer(void *data)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_matches_update(selector);
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_selector_update(selector);
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_list_win_update(selector->state);
|
2009-06-21 03:31:38 -07:00
|
|
|
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
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_clear(Evry_State *s)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-12 19:45:01 -07:00
|
|
|
if ((s->plugin && s->plugin->trigger && s->input) &&
|
2009-08-12 15:34:07 -07:00
|
|
|
(!strncmp(s->plugin->trigger, s->input, strlen(s->plugin->trigger))))
|
|
|
|
{
|
|
|
|
s->input[strlen(s->plugin->trigger)] = 0;
|
2009-08-15 13:12:04 -07:00
|
|
|
_evry_update(s, 1);
|
2009-08-16 02:43:38 -07:00
|
|
|
return 1;
|
2009-08-12 15:34:07 -07:00
|
|
|
}
|
|
|
|
else if (s->input[0] != 0)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
s->input[0] = 0;
|
2009-08-15 13:12:04 -07:00
|
|
|
_evry_update(s, 1);
|
2009-08-16 20:30:04 -07:00
|
|
|
if (evry_conf->hide_input)
|
|
|
|
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;
|
|
|
|
|
|
|
|
s_subject = selectors[0]->state;
|
|
|
|
s_action = selectors[1]->state;
|
|
|
|
s_object = NULL;
|
|
|
|
|
|
|
|
if (!s_subject || !s_action) return;
|
2009-06-21 14:16:02 -07:00
|
|
|
|
2009-07-10 08:47:19 -07:00
|
|
|
if (update_timer)
|
|
|
|
{
|
2009-08-12 13:26:27 -07:00
|
|
|
if ((selector->state->plugin) &&
|
2009-08-17 20:15:36 -07:00
|
|
|
(!selector->state->plugin->async_fetch))
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_matches_update(selector);
|
2009-08-12 12:00:25 -07:00
|
|
|
_evry_selector_update(selector);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-07-10 08:47:19 -07:00
|
|
|
ecore_timer_del(update_timer);
|
|
|
|
update_timer = NULL;
|
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
if (!s_subject->sel_item || !s_action->sel_item) return;
|
|
|
|
|
2009-08-14 11:55:35 -07:00
|
|
|
if (s_action->sel_item->plugin == action_selector)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Action *act = s_action->sel_item->data[0];
|
|
|
|
Evry_Item *it_object = NULL;
|
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (selectors[2] == selector)
|
2009-08-10 04:36:37 -07:00
|
|
|
it_object = selector->state->sel_item;
|
|
|
|
|
|
|
|
if (act->type_in2 && !it_object) return;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
act->action(act, s_subject->sel_item, it_object, NULL);
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
else
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Item *it = s_action->sel_item;
|
|
|
|
s_action->plugin->action(s_action->plugin, it, selector->state->input);
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (s_subject->plugin->action)
|
|
|
|
s_subject->plugin->action(s_subject->plugin,
|
|
|
|
s_subject->sel_item,
|
|
|
|
s_subject->input);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (s_object && s_object->plugin->action)
|
|
|
|
s_object->plugin->action(s_object->plugin,
|
|
|
|
s_object->sel_item,
|
2009-08-12 12:00:25 -07:00
|
|
|
s_object->input);
|
2009-05-06 07:20:45 -07:00
|
|
|
if (finished)
|
|
|
|
evry_hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
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-17 16:54:16 -07:00
|
|
|
if (s->plugin)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
if (s->view)
|
2009-08-12 12:00:25 -07:00
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
if (!s->view->update(s->view, s))
|
|
|
|
_evry_view_toggle(s);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
else
|
|
|
|
list->view->update(list->view, s);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
else
|
2009-08-17 16:54:16 -07:00
|
|
|
{
|
|
|
|
if (s->view)
|
|
|
|
_evry_view_toggle(s);
|
2009-06-08 06:44:11 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
list->view->clear(list->view, s);
|
|
|
|
}
|
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-17 16:54:16 -07:00
|
|
|
if (!s) return;
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (s->view)
|
|
|
|
s->view->clear(s->view, s);
|
|
|
|
else
|
|
|
|
list->view->clear(list->view, s);
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
if (s->view)
|
|
|
|
return s->view->cb_key_down(s->view, ev);
|
|
|
|
else
|
|
|
|
return list->view->cb_key_down(list->view, ev);
|
2009-08-13 15:42:40 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static int
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_toggle(Evry_State *s)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
Evry_View *v;
|
|
|
|
Evas_Object *o;
|
2009-08-10 04:36:37 -07:00
|
|
|
Eina_List *l;
|
|
|
|
|
2009-08-17 18:00:18 -07:00
|
|
|
_evry_list_win_show();
|
2009-08-18 07:29:30 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (s->view)
|
|
|
|
{
|
|
|
|
s->view->cleanup(s->view);
|
|
|
|
s->view = NULL;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
edje_object_part_swallow(list->o_main, "e.swallow.list", list->o_list);
|
|
|
|
evas_object_show(list->o_list);
|
|
|
|
_evry_view_update(s, s->plugin);
|
|
|
|
}
|
|
|
|
else
|
2009-07-29 13:43:09 -07:00
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
EINA_LIST_FOREACH(evry_conf->views, l, v)
|
|
|
|
if (v != list->view) break;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (!v) return 0;
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
o = v->begin(v, s, list->o_main);
|
|
|
|
if (!o) return 0;
|
|
|
|
|
|
|
|
edje_object_part_unswallow(list->o_main, list->o_list);
|
|
|
|
evas_object_hide(list->o_list);
|
|
|
|
_evry_view_clear(s);
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
s->view = v;
|
|
|
|
edje_object_part_swallow(list->o_main, "e.swallow.list", o);
|
|
|
|
evas_object_show(o);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-07-03 06:37:54 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
return 1;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_matches_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-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;
|
2009-08-18 07:29:30 -07:00
|
|
|
|
2009-08-14 02:35:51 -07:00
|
|
|
EINA_LIST_FREE(s->cur_plugins, p);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-17 20:15:36 -07:00
|
|
|
if (strlen(s->input) > 0)
|
|
|
|
input = s->input;
|
|
|
|
else
|
|
|
|
input = NULL;
|
2009-08-18 07:29:30 -07:00
|
|
|
|
2009-08-17 20:15:36 -07:00
|
|
|
if (input)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
if ((strlen(s->input) >= strlen(p->trigger)) &&
|
|
|
|
(!strncmp(s->input, p->trigger, strlen(p->trigger))))
|
2009-07-15 07:37:01 -07:00
|
|
|
{
|
2009-08-14 02:35:51 -07:00
|
|
|
s->cur_plugins = eina_list_append(s->cur_plugins, p);
|
2009-08-18 17:27:41 -07:00
|
|
|
p->fetch(p, s->input + strlen(p->trigger));
|
2009-08-14 02:35:51 -07:00
|
|
|
break;
|
2009-07-15 07:37:01 -07:00
|
|
|
}
|
2009-07-09 15:58:40 -07:00
|
|
|
}
|
2009-07-15 07:37:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!s->cur_plugins)
|
|
|
|
{
|
2009-07-29 13:43:09 -07:00
|
|
|
EINA_LIST_FOREACH(s->plugins, l, p)
|
|
|
|
{
|
2009-08-18 17:27:41 -07:00
|
|
|
if (!win->plugin_dedicated && p->trigger) continue;
|
2009-08-10 04:36:37 -07:00
|
|
|
if (p == sel->aggregator) continue;
|
|
|
|
|
2009-08-18 17:27:41 -07:00
|
|
|
if (p->fetch(p, input) ||
|
|
|
|
(sel->states->next) ||
|
|
|
|
(win->plugin_dedicated))
|
2009-08-11 10:03:36 -07:00
|
|
|
s->cur_plugins = eina_list_append(s->cur_plugins, p);
|
2009-07-29 13:43:09 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
if (eina_list_count(s->cur_plugins) > 1)
|
2009-07-03 08:56:21 -07:00
|
|
|
{
|
2009-08-18 07:29:30 -07:00
|
|
|
sel->aggregator->fetch(sel->aggregator, s->input);
|
2009-08-10 04:36:37 -07:00
|
|
|
s->cur_plugins = eina_list_prepend(s->cur_plugins, sel->aggregator);
|
2009-08-16 09:26:49 -07:00
|
|
|
if (s->plugin_auto_selected)
|
|
|
|
_evry_select_plugin(s, NULL);
|
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
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
if (s->plugin && !eina_list_data_find_list(s->cur_plugins, s->plugin))
|
|
|
|
s->plugin = NULL;
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
_evry_select_plugin(s, s->plugin);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_tab_scroll_to(Evry_State *s, Evry_Plugin *p)
|
2009-07-03 06:37:54 -07:00
|
|
|
{
|
|
|
|
int n, w, mw, i;
|
|
|
|
double align;
|
|
|
|
|
|
|
|
Eina_List *l;
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
for(i = 0, l = s->cur_plugins; l; l = l->next, i++)
|
2009-07-03 06:37:54 -07:00
|
|
|
if (l->data == p) break;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
n = eina_list_count(s->cur_plugins);
|
2009-07-03 06:37:54 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
e_box_min_size_get(list->o_tabs, &mw, NULL);
|
|
|
|
evas_object_geometry_get(list->o_tabs, NULL, NULL, &w, NULL);
|
2009-07-03 06:37:54 -07:00
|
|
|
|
2009-07-03 08:56:21 -07:00
|
|
|
if (mw <= w)
|
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
e_box_align_set(list->o_tabs, 0.0, 0.5);
|
2009-07-03 08:56:21 -07:00
|
|
|
return;
|
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-07-03 06:37:54 -07:00
|
|
|
if (n > 1)
|
|
|
|
{
|
|
|
|
align = (double)i / (double)(n - 1);
|
|
|
|
/* if (evry_conf->scroll_animate)
|
|
|
|
* {
|
|
|
|
* if (!scroll_timer)
|
2009-08-10 04:36:37 -07:00
|
|
|
* scroll_timer = ecore_timer_add(0.01, _evry_list_scroll_timer, NULL);
|
2009-07-03 06:37:54 -07:00
|
|
|
* if (!scroll_animator)
|
2009-08-10 04:36:37 -07:00
|
|
|
* scroll_animator = ecore_animator_add(_evry_list_animator, NULL);
|
2009-07-03 06:37:54 -07:00
|
|
|
* }
|
|
|
|
* else */
|
2009-08-17 16:54:16 -07:00
|
|
|
e_box_align_set(list->o_tabs, 1.0 - align, 0.5);
|
2009-07-03 06:37:54 -07:00
|
|
|
}
|
|
|
|
else
|
2009-08-10 04:36:37 -07:00
|
|
|
e_box_align_set(list->o_tabs, 1.0, 0.5);
|
2009-07-03 06:37:54 -07:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2009-08-13 15:42:40 -07:00
|
|
|
if (s->sel_item)
|
2009-08-17 16:54:16 -07:00
|
|
|
evry_item_free(s->sel_item);
|
2009-08-14 02:35:51 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
s->sel_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-12 11:47:46 -07:00
|
|
|
if (s->sel_item == it) return;
|
|
|
|
|
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);
|
2009-08-10 04:36:37 -07:00
|
|
|
s->sel_item = it;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_select_plugin(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
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
if (p && list->visible && s == selector->state)
|
2009-08-12 12:00:25 -07:00
|
|
|
{
|
2009-08-13 15:42:40 -07:00
|
|
|
if (s->plugin && s->plugin != p)
|
|
|
|
edje_object_signal_emit(s->plugin->tab, "e,state,unselected", "e");
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
edje_object_signal_emit(p->tab, "e,state,selected", "e");
|
2009-08-17 16:54:16 -07:00
|
|
|
|
|
|
|
_evry_tab_scroll_to(s, p);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
if ((p || !s->plugin) && s->plugin != p)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_item_desel(s, NULL);
|
2009-08-10 04:36:37 -07:00
|
|
|
s->plugin = p;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_plugin_next(Evry_State *s)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Plugin *p = NULL;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!s->plugin) return;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
l = eina_list_data_find_list(s->cur_plugins, s->plugin);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (l && l->next)
|
|
|
|
p = l->next->data;
|
|
|
|
else if (s->plugin != s->cur_plugins->data)
|
|
|
|
p = s->cur_plugins->data;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (p)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-14 02:35:51 -07:00
|
|
|
s->plugin_auto_selected = EINA_FALSE;
|
2009-08-17 16:54:16 -07:00
|
|
|
/* _evry_view_clear(s); */
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_select_plugin(s, p);
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_update(s, p);
|
|
|
|
_evry_tab_scroll_to(s, p);
|
2009-08-12 12:00:25 -07:00
|
|
|
_evry_selector_update(selector);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
|
|
|
|
2009-08-11 06:31:38 -07:00
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_plugin_next_by_name(Evry_State *s, const char *key)
|
2009-08-12 12:00:25 -07:00
|
|
|
{
|
2009-08-11 06:31:38 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Evry_Plugin *p, *first = NULL, *next = NULL;
|
|
|
|
int found = 0;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-11 06:31:38 -07:00
|
|
|
if (!s->plugin) return;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(s->cur_plugins, l, p)
|
|
|
|
{
|
|
|
|
if (p->name && (!strncasecmp(p->name, key, 1)))
|
|
|
|
{
|
|
|
|
if (!first) first = p;
|
|
|
|
|
|
|
|
if (found && !next)
|
|
|
|
next = p;
|
|
|
|
}
|
|
|
|
if (p == s->plugin) found = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (next)
|
|
|
|
p = next;
|
|
|
|
else if (first != s->plugin)
|
|
|
|
p = first;
|
|
|
|
else
|
|
|
|
p = NULL;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-11 06:31:38 -07:00
|
|
|
if (p)
|
|
|
|
{
|
2009-08-14 02:35:51 -07:00
|
|
|
s->plugin_auto_selected = EINA_FALSE;
|
2009-08-17 16:54:16 -07:00
|
|
|
/* _evry_view_clear(s); */
|
2009-08-11 06:31:38 -07:00
|
|
|
_evry_select_plugin(s, p);
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_update(s, p);
|
|
|
|
_evry_tab_scroll_to(s, p);
|
2009-08-12 12:00:25 -07:00
|
|
|
_evry_selector_update(selector);
|
2009-08-11 06:31:38 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_plugin_prev(Evry_State *s)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evry_Plugin *p = NULL;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!s->plugin) return;
|
|
|
|
|
|
|
|
l = eina_list_data_find_list(s->cur_plugins, s->plugin);
|
|
|
|
|
|
|
|
if (l && l->prev)
|
|
|
|
p = l->prev->data;
|
2009-06-08 09:01:27 -07:00
|
|
|
else
|
2009-07-04 04:10:28 -07:00
|
|
|
{
|
2009-06-21 03:31:38 -07:00
|
|
|
l = eina_list_last(s->cur_plugins);
|
2009-08-10 04:36:37 -07:00
|
|
|
if (s->plugin != l->data)
|
|
|
|
p = l->data;
|
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (p)
|
|
|
|
{
|
2009-08-14 02:35:51 -07:00
|
|
|
s->plugin_auto_selected = EINA_FALSE;
|
2009-08-17 16:54:16 -07:00
|
|
|
/* _evry_view_clear(s); */
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_select_plugin(s, p);
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_view_update(s, p);
|
2009-08-12 12:00:25 -07:00
|
|
|
_evry_selector_update(selector);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
}
|
2009-06-08 06:44:11 -07:00
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_tabs_update(Evry_State *s)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-12 11:47:46 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Evry_Plugin *p;
|
2009-08-12 11:47:46 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
/* remove tabs for not active plugins */
|
|
|
|
EINA_LIST_FOREACH(selector->plugins, l, p)
|
|
|
|
{
|
|
|
|
if (p->tab && !eina_list_data_find(s->cur_plugins, p))
|
|
|
|
{
|
2009-08-12 12:00:25 -07:00
|
|
|
e_box_unpack(p->tab);
|
2009-08-10 04:36:37 -07:00
|
|
|
evas_object_del(p->tab);
|
|
|
|
p->tab = NULL;
|
|
|
|
}
|
|
|
|
}
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
/* show/update tabs of active plugins */
|
|
|
|
EINA_LIST_FOREACH(s->cur_plugins, l, p)
|
2009-08-12 12:00:25 -07:00
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_tab_show(s, p);
|
2009-08-10 04:36:37 -07:00
|
|
|
if (s->plugin == p)
|
|
|
|
edje_object_signal_emit(p->tab, "e,state,selected", "e");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(p->tab, "e,state,unselected", "e");
|
|
|
|
}
|
2009-08-17 16:54:16 -07:00
|
|
|
|
|
|
|
if (s->plugin)
|
|
|
|
_evry_tab_scroll_to(s, s->plugin);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-17 16:54:16 -07:00
|
|
|
_evry_tab_show(Evry_State *s, Evry_Plugin *p)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
Evas_Coord mw = 0, mh = 0;
|
2009-06-21 14:16:02 -07:00
|
|
|
char buf[64];
|
2009-07-03 06:37:54 -07:00
|
|
|
Eina_List *l;
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
e_box_freeze(list->o_tabs);
|
2009-07-03 08:56:21 -07:00
|
|
|
|
|
|
|
if (p->tab)
|
|
|
|
{
|
|
|
|
o = p->tab;
|
|
|
|
e_box_unpack(p->tab);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
o = edje_object_add(list->popup->evas);
|
|
|
|
|
|
|
|
e_theme_edje_object_set(o, "base/theme/everything",
|
|
|
|
"e/widgets/everything/tab_item");
|
2009-07-03 08:56:21 -07:00
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
snprintf(buf, 64, "%s (%d)", p->name, eina_list_count(p->items));
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-06-21 14:16:02 -07:00
|
|
|
edje_object_part_text_set(o, "e.text.label", buf);
|
2009-06-21 03:31:38 -07:00
|
|
|
|
|
|
|
edje_object_size_min_calc(o, &mw, &mh);
|
|
|
|
|
2009-07-03 06:37:54 -07:00
|
|
|
l = eina_list_data_find_list(s->cur_plugins, p);
|
2009-07-03 08:56:21 -07:00
|
|
|
if (l && l->prev)
|
2009-07-03 06:37:54 -07:00
|
|
|
{
|
2009-07-03 08:56:21 -07:00
|
|
|
Evry_Plugin *p2 = l->prev->data;
|
2009-08-10 04:36:37 -07:00
|
|
|
e_box_pack_after(list->o_tabs, o, p2->tab);
|
2009-07-03 06:37:54 -07:00
|
|
|
}
|
|
|
|
else
|
2009-08-10 04:36:37 -07:00
|
|
|
e_box_pack_end(list->o_tabs, o);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
evas_object_show(o);
|
2009-06-24 13:02:37 -07:00
|
|
|
e_box_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5, mw, mh, 9999, 9999);
|
2009-08-10 04:36:37 -07:00
|
|
|
e_box_thaw(list->o_tabs);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
p->tab = o;
|
|
|
|
}
|
2009-06-21 14:16:02 -07:00
|
|
|
|
2009-08-14 07:44:18 -07:00
|
|
|
static int
|
|
|
|
_evry_fuzzy_sort_cb(const void *data1, const void *data2)
|
|
|
|
{
|
|
|
|
const Evry_Item *it1 = data1;
|
|
|
|
const Evry_Item *it2 = data2;
|
|
|
|
|
2009-08-14 16:30:54 -07:00
|
|
|
if ((it1->plugin == it2->plugin) &&
|
|
|
|
(it1->priority - it2->priority))
|
|
|
|
return (it1->priority - it2->priority);
|
|
|
|
|
2009-08-16 09:26:49 -07:00
|
|
|
if (it1->fuzzy_match || it2->fuzzy_match)
|
|
|
|
{
|
|
|
|
if (it1->fuzzy_match && !it2->fuzzy_match)
|
|
|
|
return -1;
|
2009-08-14 07:44:18 -07:00
|
|
|
|
2009-08-16 09:26:49 -07:00
|
|
|
if (!it1->fuzzy_match && it2->fuzzy_match)
|
|
|
|
return 1;
|
2009-08-14 07:44:18 -07:00
|
|
|
|
2009-08-16 09:26:49 -07:00
|
|
|
if (it1->fuzzy_match - it2->fuzzy_match)
|
|
|
|
return (it1->fuzzy_match - it2->fuzzy_match);
|
|
|
|
}
|
2009-08-14 07:44:18 -07:00
|
|
|
|
|
|
|
if (it1->plugin->config->priority - it2->plugin->config->priority)
|
|
|
|
return (it1->plugin->config->priority - it2->plugin->config->priority);
|
|
|
|
|
2009-08-16 09:26:49 -07:00
|
|
|
if (it1->priority - it2->priority)
|
|
|
|
return (it1->priority - it2->priority);
|
|
|
|
|
|
|
|
return 0;
|
2009-08-14 07:44:18 -07:00
|
|
|
}
|
2009-07-15 05:22:42 -07:00
|
|
|
|
|
|
|
/* action selector plugin: provides list of actions registered for
|
|
|
|
candidate types provided by current plugin */
|
2009-06-24 13:02:37 -07:00
|
|
|
static int
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_plug_actions_init(void)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-17 20:15:36 -07:00
|
|
|
Evry_Plugin *p;
|
2009-08-18 07:29:30 -07:00
|
|
|
|
|
|
|
p = evry_plugin_new("Select Action", type_action, "", "", 0, NULL, NULL,
|
2009-08-17 20:15:36 -07:00
|
|
|
_evry_plug_actions_begin,
|
|
|
|
_evry_plug_actions_cleanup,
|
|
|
|
_evry_plug_actions_fetch,
|
|
|
|
NULL, NULL,
|
|
|
|
_evry_plug_actions_item_icon_get,
|
|
|
|
NULL, NULL);
|
2009-08-18 07:29:30 -07:00
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
action_selector = p;
|
2009-08-16 09:26:49 -07:00
|
|
|
evry_plugin_register(p, 2);
|
2009-07-24 22:53:01 -07:00
|
|
|
|
|
|
|
return 1;
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
|
|
|
|
2009-08-14 02:35:51 -07:00
|
|
|
static void
|
|
|
|
_evry_plug_actions_free(void)
|
|
|
|
{
|
|
|
|
Evry_Plugin *p = action_selector;
|
|
|
|
|
2009-08-16 09:26:49 -07:00
|
|
|
evry_plugin_unregister(p);
|
2009-08-14 02:35:51 -07:00
|
|
|
eina_stringshare_del(p->config->name);
|
|
|
|
E_FREE(p->config);
|
2009-08-18 12:10:13 -07:00
|
|
|
evry_plugin_free(p);
|
2009-08-14 02:35:51 -07:00
|
|
|
}
|
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
static int
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_plug_actions_begin(Evry_Plugin *p, const Evry_Item *it)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
|
|
|
Evry_Action *act;
|
|
|
|
Eina_List *l;
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Selector *sel = selectors[1];
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_plug_actions_cleanup(p);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!it) return 0;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
const char *type = it->plugin->type_out;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
if (!type) return 0;
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
EINA_LIST_FOREACH(evry_conf->actions, l, act)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-18 07:29:30 -07:00
|
|
|
if (act->type_in1 && (act->type_in1 == type) &&
|
2009-08-10 04:36:37 -07:00
|
|
|
(!act->check_item || act->check_item(act, it)))
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
sel->actions = eina_list_append(sel->actions, act);
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (sel->actions) return 1;
|
2009-06-24 13:02:37 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_plug_actions_fetch(Evry_Plugin *p, const char *input)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
|
|
|
Evry_Action *act;
|
|
|
|
Eina_List *l;
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Item *it;
|
|
|
|
Evry_Selector *sel = selectors[1];
|
2009-08-14 11:55:35 -07:00
|
|
|
int match = 0;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-14 07:44:18 -07:00
|
|
|
EINA_LIST_FREE(p->items, it)
|
|
|
|
evry_item_free(it);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
EINA_LIST_FOREACH(sel->actions, l, act)
|
|
|
|
{
|
|
|
|
if (input)
|
2009-08-14 11:55:35 -07:00
|
|
|
match = evry_fuzzy_match(act->name, input);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-14 11:55:35 -07:00
|
|
|
if (!input || match)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-13 15:42:40 -07:00
|
|
|
it = evry_item_new(p, act->name, NULL);
|
2009-08-14 11:55:35 -07:00
|
|
|
it->fuzzy_match = match;
|
2009-08-10 04:36:37 -07:00
|
|
|
it->data[0] = act;
|
|
|
|
p->items = eina_list_append(p->items, it);
|
|
|
|
}
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
|
|
|
|
2009-08-14 07:44:18 -07:00
|
|
|
if (input)
|
|
|
|
p->items = eina_list_sort(p->items, eina_list_count(p->items), _evry_fuzzy_sort_cb);
|
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
if (p->items) return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
|
|
|
_evry_plug_actions_cleanup(Evry_Plugin *p)
|
|
|
|
{
|
|
|
|
Evry_Item *it;
|
|
|
|
Evry_Selector *sel = selectors[1];
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
EINA_LIST_FREE(p->items, it)
|
2009-08-12 12:00:25 -07:00
|
|
|
evry_item_free(it);
|
|
|
|
|
2009-08-12 05:17:43 -07:00
|
|
|
if (sel->actions) eina_list_free(sel->actions);
|
2009-08-10 04:36:37 -07:00
|
|
|
sel->actions = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_plug_actions_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-15 17:13:56 -07:00
|
|
|
Evas_Object *o = NULL;
|
2009-06-24 13:02:37 -07:00
|
|
|
Evry_Action *act = it->data[0];
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (!act) return NULL;
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
if (act->icon_get)
|
|
|
|
o = act->icon_get(act, e);
|
|
|
|
else if (act->icon)
|
2009-08-18 07:29:30 -07:00
|
|
|
o = evry_icon_theme_get(act->icon, e);
|
2009-08-12 12:00:25 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evry_Plugin *
|
|
|
|
_evry_plug_aggregator_new(void)
|
|
|
|
{
|
2009-08-17 20:15:36 -07:00
|
|
|
Evry_Plugin *p;
|
2009-08-10 04:36:37 -07:00
|
|
|
Plugin_Config *pc;
|
2009-08-18 07:29:30 -07:00
|
|
|
|
|
|
|
p = evry_plugin_new("All", 0, "", "", 0, NULL, NULL,
|
2009-08-17 20:15:36 -07:00
|
|
|
NULL,
|
|
|
|
_evry_plug_aggregator_cleanup,
|
|
|
|
_evry_plug_aggregator_fetch,
|
|
|
|
_evry_plug_aggregator_action,
|
|
|
|
NULL,
|
|
|
|
_evry_plug_aggregator_item_icon_get,
|
|
|
|
NULL, NULL);
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
pc = E_NEW(Plugin_Config, 1);
|
|
|
|
pc->name = eina_stringshare_add(p->name);
|
|
|
|
pc->enabled = 1;
|
2009-08-12 11:47:46 -07:00
|
|
|
pc->priority = -1;
|
2009-08-10 04:36:37 -07:00
|
|
|
p->config = pc;
|
|
|
|
|
|
|
|
return p;
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_plug_aggregator_free(Evry_Plugin *p)
|
|
|
|
{
|
|
|
|
if (p->config->name) eina_stringshare_del(p->config->name);
|
|
|
|
E_FREE(p->config);
|
2009-08-18 12:10:13 -07:00
|
|
|
evry_plugin_free(p);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
|
|
|
|
2009-08-14 07:44:18 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static int
|
2009-08-14 07:44:18 -07:00
|
|
|
_evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input)
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Selector *selector = p->private;
|
|
|
|
Evry_State *s = selector->state;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
Evry_Plugin *plugin;
|
2009-06-24 13:02:37 -07:00
|
|
|
Evry_Item *it;
|
2009-08-12 15:34:07 -07:00
|
|
|
int cnt = 0;
|
2009-08-14 07:44:18 -07:00
|
|
|
Eina_List *items = NULL;
|
2009-06-24 13:02:37 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
EINA_LIST_FREE(p->items, it)
|
|
|
|
evry_item_free(it);
|
2009-08-12 05:17:43 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
EINA_LIST_FOREACH(s->cur_plugins, l, plugin)
|
2009-08-12 15:34:07 -07:00
|
|
|
cnt += eina_list_count(plugin->items);
|
|
|
|
|
2009-08-14 07:44:18 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
if (input[0])
|
2009-06-24 13:02:37 -07:00
|
|
|
{
|
2009-08-12 15:34:07 -07:00
|
|
|
EINA_LIST_FOREACH(s->cur_plugins, l, plugin)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-12 15:34:07 -07:00
|
|
|
EINA_LIST_FOREACH(plugin->items, ll, it)
|
2009-08-13 15:42:40 -07:00
|
|
|
{
|
2009-08-14 07:44:18 -07:00
|
|
|
if (!it->fuzzy_match)
|
|
|
|
it->fuzzy_match = evry_fuzzy_match(it->label, input);
|
|
|
|
|
2009-08-18 12:10:13 -07:00
|
|
|
if (it->fuzzy_match || selector == selectors[2])
|
2009-08-14 07:44:18 -07:00
|
|
|
{
|
2009-08-17 16:54:16 -07:00
|
|
|
evry_item_ref(it);
|
2009-08-14 07:44:18 -07:00
|
|
|
items = eina_list_append(items, it);
|
|
|
|
p->items = eina_list_append(p->items, it);
|
|
|
|
}
|
2009-08-13 15:42:40 -07:00
|
|
|
}
|
2009-08-12 15:34:07 -07:00
|
|
|
}
|
|
|
|
}
|
2009-08-14 07:44:18 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
if (!input[0] || eina_list_count(items) < 20)
|
2009-08-12 15:34:07 -07:00
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(s->cur_plugins, l, plugin)
|
2009-08-14 07:44:18 -07:00
|
|
|
{
|
|
|
|
for (cnt = 0, ll = plugin->items; ll && cnt < 15; ll = ll->next, cnt++)
|
|
|
|
{
|
|
|
|
if (!items || !eina_list_data_find_list(items, ll->data))
|
|
|
|
{
|
|
|
|
it = ll->data;
|
2009-08-14 16:30:54 -07:00
|
|
|
|
2009-08-17 16:54:16 -07:00
|
|
|
evry_item_ref(it);
|
2009-08-14 07:44:18 -07:00
|
|
|
it->fuzzy_match = 0;
|
|
|
|
p->items = eina_list_append(p->items, it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eina_list_free(items);
|
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
if (input[0])
|
2009-08-14 07:44:18 -07:00
|
|
|
p->items = eina_list_sort(p->items, eina_list_count(p->items), _evry_fuzzy_sort_cb);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_plug_aggregator_action(Evry_Plugin *p, const Evry_Item *it, const char *input)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
|
|
|
if (it->plugin && it->plugin->action)
|
|
|
|
return it->plugin->action(it->plugin, it, input);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return 0;
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-10 04:36:37 -07:00
|
|
|
_evry_plug_aggregator_cleanup(Evry_Plugin *p)
|
|
|
|
{
|
2009-08-13 15:42:40 -07:00
|
|
|
Evry_Item *it;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(p->items, it)
|
|
|
|
evry_item_free(it);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2009-08-12 05:17:43 -07:00
|
|
|
_evry_plug_aggregator_item_icon_get(Evry_Plugin *p, const Evry_Item *it, Evas *e)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
|
|
|
if (it->plugin && it->plugin->icon_get)
|
|
|
|
return it->plugin->icon_get(it->plugin, it, e);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
_evry_update(s, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2009-08-13 15:42:40 -07:00
|
|
|
|
|
|
|
/* taken from e_utils. just changed 48 to 72.. we need
|
|
|
|
evry_icon_theme_set(Evas_Object *obj, const char *icon,
|
|
|
|
size:small, mid, large) imo */
|
|
|
|
static int
|
|
|
|
_evry_icon_theme_set(Evas_Object *obj, const char *icon)
|
|
|
|
{
|
|
|
|
const char *file;
|
|
|
|
char buf[4096];
|
|
|
|
|
|
|
|
if ((!icon) || (!icon[0])) return 0;
|
|
|
|
snprintf(buf, sizeof(buf), "e/icons/%s", icon);
|
|
|
|
file = e_theme_edje_file_get("base/theme/icons", buf);
|
|
|
|
if (file[0])
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-13 15:42:40 -07:00
|
|
|
e_icon_file_edje_set(obj, file, buf);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2009-08-12 11:47:46 -07:00
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
static int
|
|
|
|
_evry_icon_fdo_set(Evas_Object *obj, const char *icon)
|
|
|
|
{
|
|
|
|
char *path = NULL;
|
|
|
|
unsigned int size;
|
|
|
|
|
|
|
|
if ((!icon) || (!icon[0])) return 0;
|
|
|
|
size = e_util_icon_size_normalize(72 * e_scale);
|
|
|
|
path = efreet_icon_path_find(e_config->icon_theme, icon, size);
|
|
|
|
if (!path) return 0;
|
|
|
|
e_icon_file_set(obj, path);
|
|
|
|
E_FREE(path);
|
|
|
|
return 1;
|
|
|
|
}
|
2009-08-12 11:47:46 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
Evas_Object *
|
|
|
|
evry_icon_theme_get(const char *icon, Evas *e)
|
2009-08-13 15:42:40 -07:00
|
|
|
{
|
2009-08-18 07:29:30 -07:00
|
|
|
Evas_Object *o = e_icon_add(e);
|
|
|
|
|
2009-08-13 15:42:40 -07:00
|
|
|
if (e_config->icon_theme_overrides)
|
|
|
|
{
|
2009-08-18 07:29:30 -07:00
|
|
|
if (_evry_icon_fdo_set(o, icon) ||
|
|
|
|
_evry_icon_theme_set(o, icon))
|
|
|
|
return o;
|
2009-08-13 15:42:40 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-18 07:29:30 -07:00
|
|
|
if (_evry_icon_theme_set(o, icon) ||
|
|
|
|
_evry_icon_fdo_set(o, icon))
|
|
|
|
return o;
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
evas_object_del(o);
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-08-13 15:42:40 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
Evas_Object *
|
|
|
|
evry_icon_mime_get(const char *mime, Evas *e)
|
|
|
|
{
|
|
|
|
char *file;
|
2009-08-18 17:27:41 -07:00
|
|
|
const char *icon;
|
2009-08-18 07:29:30 -07:00
|
|
|
|
|
|
|
if (!(icon = eina_hash_find(mime_hash, mime)))
|
2009-08-13 15:42:40 -07:00
|
|
|
{
|
2009-08-18 07:29:30 -07:00
|
|
|
file = efreet_mime_type_icon_get(mime, e_config->icon_theme, 64);
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
icon = eina_stringshare_add(file);
|
|
|
|
free (file);
|
2009-08-18 17:27:41 -07:00
|
|
|
eina_hash_add(mime_hash, mime, icon);
|
2009-08-18 07:29:30 -07:00
|
|
|
}
|
2009-08-13 15:42:40 -07:00
|
|
|
}
|
|
|
|
|
2009-08-18 17:27:41 -07:00
|
|
|
if (icon)
|
2009-08-18 07:29:30 -07:00
|
|
|
return e_util_icon_add(icon, e);
|
|
|
|
else
|
|
|
|
return evry_icon_theme_get("none", e);
|
|
|
|
|
|
|
|
return NULL;
|
2009-08-13 15:42:40 -07:00
|
|
|
}
|
|
|
|
|