diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index 867690b83..86b0101e8 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -75,7 +75,7 @@ struct _Evry_Plugin /* whether the plugin uses evry_async_update to add new items */ int async_fetch; - + /* run when plugin is activated. when return true plugin is added to the list of current plugins and queried for results */ int (*begin) (Evry_Plugin *p, const Evry_Item *item); @@ -159,7 +159,6 @@ struct _Evry_Action const char *type_in1; const char *type_in2; - const char *type_out; int (*action) (Evry_Action *act, const Evry_Item *it1, const Evry_Item *it2, const char *input); @@ -203,18 +202,30 @@ void evry_item_ref(Evry_Item *it); void evry_plugin_async_update(Evry_Plugin *plugin, int state); void evry_clear_input(void); -int evry_icon_theme_set(Evas_Object *obj, const char *icon); + +Evas_Object *evry_icon_mime_get(const char *mime, Evas *e); +Evas_Object *evry_icon_theme_get(const char *icon, Evas *e); int evry_fuzzy_match(const char *str, const char *match); Evry_Plugin *evry_plugin_new(const char *name, int type, const char *type_in, const char *type_out, - int async_fetch, const char *trigger, - int (*begin) (Evry_Plugin *p, const Evry_Item *item), + int async_fetch, const char *icon, const char *trigger, + int (*begin) (Evry_Plugin *p, const Evry_Item *item), void (*cleanup) (Evry_Plugin *p), - int (*fetch) (Evry_Plugin *p, const char *input), - int (*action) (Evry_Plugin *p, const Evry_Item *item, const char *input), - int (*browse) (Evry_Plugin *p, const Evry_Item *item), + int (*fetch) (Evry_Plugin *p, const char *input), + int (*action) (Evry_Plugin *p, const Evry_Item *item, const char *input), + int (*browse) (Evry_Plugin *p, const Evry_Item *item), Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e), Evas_Object *(*config_page) (Evry_Plugin *p), void (*config_apply) (Evry_Plugin *p)); + +void evry_plugin_free(Evry_Plugin *p); + + +Evry_Action *evry_action_new(const char *name, const char *type_in1, const char *type_in2, const char *icon, + int (*action) (Evry_Action *act, const Evry_Item *it1, const Evry_Item *it2, const char *input), + int (*check_item) (Evry_Action *act, const Evry_Item *it), + Evas_Object *(*icon_get) (Evry_Action *act, Evas *e)); + +void evry_action_free(Evry_Action *act); diff --git a/src/modules/everything/e_mod_main.c b/src/modules/everything/e_mod_main.c index 325948d83..4ba6bd456 100644 --- a/src/modules/everything/e_mod_main.c +++ b/src/modules/everything/e_mod_main.c @@ -252,7 +252,7 @@ _evry_cb_plugin_sort(const void *data1, const void *data2) Evry_Plugin * evry_plugin_new(const char *name, int type, const char *type_in, const char *type_out, - int async_fetch, const char *trigger, + int async_fetch, const char *icon, const char *trigger, int (*begin) (Evry_Plugin *p, const Evry_Item *item), void (*cleanup) (Evry_Plugin *p), int (*fetch) (Evry_Plugin *p, const char *input), @@ -263,11 +263,13 @@ evry_plugin_new(const char *name, int type, void (*config_apply) (Evry_Plugin *p)) { Evry_Plugin *p = E_NEW(Evry_Plugin, 1); - + p->name = eina_stringshare_add(name); p->type = type; - p->type_in = eina_stringshare_add(type_in); - p->type_out = eina_stringshare_add(type_out); + p->type_in = (type_in ? eina_stringshare_add(type_in) : NULL); + p->type_out = (type_out ? eina_stringshare_add(type_out) : NULL); + p->trigger = (trigger ? eina_stringshare_add(trigger) : NULL); + p->icon = (icon ? eina_stringshare_add(icon) : NULL); p->async_fetch = async_fetch; p->begin = begin; p->cleanup = cleanup; @@ -277,11 +279,56 @@ evry_plugin_new(const char *name, int type, p->browse = browse; p->config_page = config_page; p->config_apply = config_apply; - + return p; } - +void +evry_plugin_free(Evry_Plugin *p) +{ + evry_plugin_unregister(p); + + if (p->name) eina_stringshare_del(p->name); + if (p->type_in) eina_stringshare_del(p->type_in); + if (p->type_out) eina_stringshare_del(p->type_out); + if (p->trigger) eina_stringshare_del(p->trigger); + if (p->icon) eina_stringshare_del(p->icon); + + E_FREE(p); +} + + +Evry_Action * +evry_action_new(const char *name, const char *type_in1, const char *type_in2, const char *icon, + int (*action) (Evry_Action *act, const Evry_Item *it1, const Evry_Item *it2, const char *input), + int (*check_item) (Evry_Action *act, const Evry_Item *it), + Evas_Object *(*icon_get) (Evry_Action *act, Evas *e)) +{ + Evry_Action *act = E_NEW(Evry_Action, 1); + act->name = eina_stringshare_add(name); + act->type_in1 = (type_in1 ? eina_stringshare_add(type_in1) : NULL); + act->type_in2 = (type_in2 ? eina_stringshare_add(type_in2) : NULL); + act->action = action; + act->check_item = check_item; + act->icon = (icon ? eina_stringshare_add(icon) : NULL); + + return act; +} + + +void +evry_action_free(Evry_Action *act) +{ + evry_action_unregister(act); + + if (act->name) eina_stringshare_del(act->name); + if (act->type_in1) eina_stringshare_del(act->type_in1); + if (act->type_in2) eina_stringshare_del(act->type_in2); + if (act->icon) eina_stringshare_del(act->icon); + + E_FREE(act); +} + void evry_plugin_register(Evry_Plugin *plugin, int priority) { diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index 8e21da25c..4969be887 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -135,6 +135,7 @@ static Ecore_Timer *update_timer = NULL; static Evry_Selector *selectors[3]; static Evry_Selector *selector = NULL; static Evry_Plugin *action_selector = NULL; +static Eina_Hash *mime_hash = NULL; /* externally accessible functions */ int @@ -162,8 +163,9 @@ evry_show(E_Zone *zone) E_OBJECT_CHECK_RETURN(zone, 0); E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0); - input_window = ecore_x_window_input_new(zone->container->win, zone->x, - zone->y, zone->w, zone->h); + input_window = ecore_x_window_input_new(zone->container->win, + zone->x, zone->y, + zone->w, zone->h); ecore_x_window_show(input_window); if (!e_grabinput_get(input_window, 1, input_window)) goto error; @@ -183,6 +185,9 @@ evry_show(E_Zone *zone) _evry_selector_subjects_get(); _evry_selector_activate(selectors[0]); + + mime_hash = eina_hash_stringshared_new(NULL); + _evry_selector_update(selector); e_popup_layer_set(list->popup, 255); @@ -203,19 +208,6 @@ evry_show(E_Zone *zone) (ECORE_X_EVENT_SELECTION_NOTIFY, _evry_cb_selection_notify, win)); - /* handlers = eina_list_append - * (handlers, ecore_event_handler_add - * (ECORE_EVENT_MOUSE_BUTTON_DOWN, _evry_cb_mouse_down, NULL)); - * handlers = eina_list_append - * (handlers, ecore_event_handler_add - * (ECORE_EVENT_MOUSE_BUTTON_UP, _evry_cb_mouse_up, NULL)); - * handlers = eina_list_append - * (handlers, ecore_event_handler_add - * (ECORE_EVENT_MOUSE_MOVE, _evry_cb_mouse_move, NULL)); - * handlers = eina_list_append - * (handlers, ecore_event_handler_add - * (ECORE_EVENT_MOUSE_WHEEL, _evry_cb_mouse_wheel, NULL)); */ - return 1; error: @@ -266,6 +258,9 @@ evry_hide(void) _evry_window_free(win); win = NULL; + eina_hash_free(mime_hash); + mime_hash = NULL; + EINA_LIST_FREE(handlers, ev) ecore_event_handler_del(ev); @@ -532,7 +527,7 @@ evry_fuzzy_match(const char *str, const char *match) /* end of match: store min weight of match */ min += (cnt - m_cnt) > 0 ? (cnt - m_cnt) : 0; - + if (min < m_min[m_cnt]) m_min[m_cnt] = min; @@ -564,7 +559,7 @@ evry_fuzzy_match(const char *str, const char *match) for (m_cnt = 0; m_cnt < m_num; m_cnt++) { sum += m_min[m_cnt]; - + if (sum >= MAX_FUZZ) { sum = 0; @@ -882,11 +877,13 @@ _evry_selector_icon_set(Evry_Selector *sel) } else if (s->plugin && s->plugin->icon) { - o = e_icon_add(win->popup->evas); - evry_icon_theme_set(o, s->plugin->icon); - edje_object_part_swallow(sel->o_main, "e.swallow.icons", o); - evas_object_show(o); - sel->o_icon = o; + 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; + } } } @@ -991,16 +988,19 @@ _evry_selector_actions_get(Evry_Item *it) Eina_List *l, *plugins = NULL; Evry_Plugin *p; Evry_Selector *sel = selectors[1]; + const char *type_out; while (sel->state) _evry_state_pop(sel); if (!it) return 0; + type_out = it->plugin->type_out; + EINA_LIST_FOREACH(sel->plugins, l, p) { if ((p == action_selector) || (p == sel->aggregator) || - (strstr(p->type_in, it->plugin->type_out))) + (p->type_in && type_out && p->type_in == type_out)) { if (p->begin) { @@ -1112,17 +1112,24 @@ _evry_browse_item(Evry_Selector *sel) Evry_Item *it; Eina_List *l, *plugins = NULL; Evry_Plugin *p; + const char *type_out; it = s->sel_item; - if (!it || !it->browseable) return; + if (!it || !it->browseable) + return; _evry_view_clear(sel->state); + type_out = it->plugin->type_out; + + if (!type_out) + return; + EINA_LIST_FOREACH(sel->plugins, l, p) { - if (!p->browse) continue; - if (!strstr(p->type_in, it->plugin->type_out)) continue; + if (!p->browse || !p->type_in || p->type_in != type_out) + continue; if (p->browse(p, it)) plugins = eina_list_append(plugins, p); @@ -1146,7 +1153,8 @@ _evry_browse_back(Evry_Selector *sel) { Evry_State *s = sel->state; - if (!s || !sel->states->next) return; + if (!s || !sel->states->next) + return; /* _evry_view_clear(s); */ if (s->view) @@ -1531,7 +1539,7 @@ _evry_view_toggle(Evry_State *s) Eina_List *l; _evry_list_win_show(); - + if (s->view) { s->view->cleanup(s->view); @@ -1570,14 +1578,14 @@ _evry_matches_update(Evry_Selector *sel) Evry_Plugin *p; Eina_List *l; const char *input; - + EINA_LIST_FREE(s->cur_plugins, p); if (strlen(s->input) > 0) input = s->input; else input = NULL; - + if (input) { EINA_LIST_FOREACH(s->plugins, l, p) @@ -1608,7 +1616,7 @@ _evry_matches_update(Evry_Selector *sel) if (eina_list_count(s->cur_plugins) > 1) { - sel->aggregator->fetch(sel->aggregator, input); + sel->aggregator->fetch(sel->aggregator, s->input); s->cur_plugins = eina_list_prepend(s->cur_plugins, sel->aggregator); if (s->plugin_auto_selected) _evry_select_plugin(s, NULL); @@ -1918,15 +1926,15 @@ static int _evry_plug_actions_init(void) { Evry_Plugin *p; - - p = evry_plugin_new("Select Action", type_action, "", "", 0, NULL, + + p = evry_plugin_new("Select Action", type_action, "", "", 0, NULL, NULL, _evry_plug_actions_begin, _evry_plug_actions_cleanup, _evry_plug_actions_fetch, NULL, NULL, _evry_plug_actions_item_icon_get, NULL, NULL); - + action_selector = p; evry_plugin_register(p, 2); @@ -1957,9 +1965,11 @@ _evry_plug_actions_begin(Evry_Plugin *p, const Evry_Item *it) const char *type = it->plugin->type_out; + if (!type) return 0; + EINA_LIST_FOREACH(evry_conf->actions, l, act) { - if ((strstr(act->type_in1, type)) && + if (act->type_in1 && (act->type_in1 == type) && (!act->check_item || act->check_item(act, it))) { sel->actions = eina_list_append(sel->actions, act); @@ -2029,10 +2039,7 @@ _evry_plug_actions_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, if (act->icon_get) o = act->icon_get(act, e); else if (act->icon) - { - o = e_icon_add(e); - evry_icon_theme_set(o, act->icon); - } + o = evry_icon_theme_get(act->icon, e); return o; } @@ -2042,8 +2049,8 @@ _evry_plug_aggregator_new(void) { Evry_Plugin *p; Plugin_Config *pc; - - p = evry_plugin_new("All", 0, "", "", 0, NULL, + + p = evry_plugin_new("All", 0, "", "", 0, NULL, NULL, NULL, _evry_plug_aggregator_cleanup, _evry_plug_aggregator_fetch, @@ -2088,7 +2095,7 @@ _evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input) cnt += eina_list_count(plugin->items); - if (input) + if (input[0]) { EINA_LIST_FOREACH(s->cur_plugins, l, plugin) { @@ -2107,7 +2114,7 @@ _evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input) } } - if (!input || eina_list_count(items) < 20) + if (!input[0] || eina_list_count(items) < 20) { EINA_LIST_FOREACH(s->cur_plugins, l, plugin) { @@ -2127,7 +2134,7 @@ _evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input) eina_list_free(items); - if (input) + if (input[0]) p->items = eina_list_sort(p->items, eina_list_count(p->items), _evry_fuzzy_sort_cb); return 1; @@ -2179,6 +2186,34 @@ _evry_plugin_list_insert(Evry_State *s, Evry_Plugin *p) s->cur_plugins = eina_list_append(s->cur_plugins, p); } +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; +} /* taken from e_utils. just changed 48 to 72.. we need evry_icon_theme_set(Evas_Object *obj, const char *icon, @@ -2215,49 +2250,51 @@ _evry_icon_fdo_set(Evas_Object *obj, const char *icon) return 1; } -EAPI int -evry_icon_theme_set(Evas_Object *obj, const char *icon) +Evas_Object * +evry_icon_theme_get(const char *icon, Evas *e) { + Evas_Object *o = e_icon_add(e); + if (e_config->icon_theme_overrides) { - if (_evry_icon_fdo_set(obj, icon)) - return 1; - return _evry_icon_theme_set(obj, icon); + if (_evry_icon_fdo_set(o, icon) || + _evry_icon_theme_set(o, icon)) + return o; } else { - if (_evry_icon_theme_set(obj, icon)) - return 1; - return _evry_icon_fdo_set(obj, icon); + if (_evry_icon_theme_set(o, icon) || + _evry_icon_fdo_set(o, icon)) + return o; } + + evas_object_del(o); + + return NULL; } -static int -_evry_cb_selection_notify(void *data, int type, void *event) +Evas_Object * +evry_icon_mime_get(const char *mime, Evas *e) { - 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)) + char *file; + const char *icon = ""; + + if (!(icon = eina_hash_find(mime_hash, mime))) { - 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); - } + file = efreet_mime_type_icon_get(mime, e_config->icon_theme, 64); + if (file) + { + icon = eina_stringshare_add(file); + free (file); + } + eina_hash_add(mime_hash, mime, icon); } - return 1; + if (icon && icon[0]) + return e_util_icon_add(icon, e); + else + return evry_icon_theme_get("none", e); + + return NULL; } diff --git a/src/modules/everything/evry_plug_apps.c b/src/modules/everything/evry_plug_apps.c index 821f3f861..3b617658e 100644 --- a/src/modules/everything/evry_plug_apps.c +++ b/src/modules/everything/evry_plug_apps.c @@ -380,7 +380,7 @@ _fetch(Evry_Plugin *p, const char *input) } static Evas_Object * -_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) +_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) { Evas_Object *o = NULL; Evry_App *app = it->data[0]; @@ -389,10 +389,7 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) o = e_util_desktop_icon_add(app->desktop, 64, e); if (!o) - { - o = e_icon_add(e); - evry_icon_theme_set(o, "system-run"); - } + o = evry_icon_theme_get("system-run", e); return o; } @@ -652,70 +649,37 @@ _init(void) { char *path, *p, *last; - p1 = E_NEW(Evry_Plugin, 1); - p1->name = "Applications"; - p1->type = type_subject; - p1->type_in = "NONE"; - p1->type_out = "APPLICATION"; - p1->begin = &_begin; - p1->fetch = &_fetch; - p1->cleanup = &_cleanup; - p1->icon_get = &_item_icon_get; - evry_plugin_register(p1, 1); + p1 = evry_plugin_new("Applications", type_subject, "", "APPLICATION", 0, NULL, NULL, + _begin, _cleanup, _fetch, NULL, NULL, + _icon_get, NULL, NULL); + + p2 = evry_plugin_new("Open With...", type_action, "FILE", "", 0, NULL, NULL, + _begin, _cleanup, _fetch, _open_with_action, NULL, + _icon_get, NULL, NULL); - p2 = E_NEW(Evry_Plugin, 1); - p2->name = "Open With..."; - p2->type = type_action; - p2->type_in = "FILE"; - p2->type_out = "NONE"; - p2->begin = &_begin; - p2->fetch = &_fetch; - p2->action = &_open_with_action; - p2->cleanup = &_cleanup; - p2->icon_get = &_item_icon_get; + evry_plugin_register(p1, 1); evry_plugin_register(p2, 3); - act = E_NEW(Evry_Action, 1); - act->name = "Launch"; - act->is_default = EINA_TRUE; - act->type_in1 = "APPLICATION"; - act->action = &_exec_app_action; - act->check_item = &_exec_app_check_item; - act->icon = "everything-launch"; + act = evry_action_new("Launch", "APPLICATION", NULL, "everything-launch", + _exec_app_action, _exec_app_check_item, NULL); + + act1 = evry_action_new("Open File...", "APPLICATION", "FILE", "document-open", + _exec_app_action, _exec_app_check_item, NULL); + + act2 = evry_action_new("Edit Application Entry", "APPLICATION", NULL, "everything-launch", + _edit_app_action, _edit_app_check_item, NULL); + + act3 = evry_action_new("New Application Entry", "APPLICATION", NULL, "everything-launch", + _new_app_action, _new_app_check_item, NULL); + + act4 = evry_action_new("Open File...", "BORDER", NULL, "everything-launch", + _exec_border_action, _exec_border_check_item, NULL); + + evry_action_register(act); - - act1 = E_NEW(Evry_Action, 1); - act1->name = "Open File..."; - act1->type_in1 = "APPLICATION"; - act1->type_in2 = "FILE"; - act1->action = &_exec_app_action; - act1->check_item = &_exec_app_check_item; - act1->icon = "document-open"; evry_action_register(act1); - - act2 = E_NEW(Evry_Action, 1); - act2->name = "Edit Application Entry"; - act2->type_in1 = "APPLICATION"; - act2->action = &_edit_app_action; - act2->check_item = &_edit_app_check_item; - act2->icon = "everything-launch"; evry_action_register(act2); - - act3 = E_NEW(Evry_Action, 1); - act3->name = "New Application Entry"; - act3->type_in1 = "APPLICATION"; - act3->action = &_new_app_action; - act3->check_item = &_new_app_check_item; - act3->icon = "everything-launch"; evry_action_register(act3); - - act4 = E_NEW(Evry_Action, 1); - act4->name = "Open File..."; - act4->type_in1 = "BORDER"; - act4->type_in2 = "FILE"; - act4->action = &_exec_border_action; - act4->check_item = &_exec_border_check_item; - act4->icon = "everything-launch"; evry_action_register(act4); /* taken from e_exebuf.c */ @@ -746,19 +710,13 @@ _shutdown(void) { char *str; - evry_plugin_unregister(p1); - evry_plugin_unregister(p2); - evry_action_unregister(act); - evry_action_unregister(act1); - evry_action_unregister(act2); - evry_action_unregister(act3); - E_FREE(p1); - E_FREE(p2); - E_FREE(act); - E_FREE(act1); - E_FREE(act2); - E_FREE(act3); - E_FREE(act4); + evry_plugin_free(p1); + evry_plugin_free(p2); + evry_action_free(act); + evry_action_free(act1); + evry_action_free(act2); + evry_action_free(act3); + evry_action_free(act4); EINA_LIST_FREE(exe_path, str) free(str); diff --git a/src/modules/everything/evry_plug_aspell.c b/src/modules/everything/evry_plug_aspell.c index d1177abe1..396904277 100644 --- a/src/modules/everything/evry_plug_aspell.c +++ b/src/modules/everything/evry_plug_aspell.c @@ -333,8 +333,7 @@ _init(void) p = E_NEW(Plugin, 1); p->base.name = "Spell Checker"; p->base.type = type_subject; - p->base.type_in = "NONE"; - p->base.type_out = "TEXT"; + p->base.type_out = eina_stringshare_add("TEXT"); p->base.icon = "accessories-dictionary"; p->base.trigger = TRIGGER; p->base.begin = _begin; @@ -362,6 +361,8 @@ _shutdown(void) EINA_LIST_FREE(p->base.items, it) evry_item_free(it); + eina_stringshare_del(p->base.type_out); + evry_plugin_unregister(&p->base); E_FREE(p); } diff --git a/src/modules/everything/evry_plug_border.c b/src/modules/everything/evry_plug_border.c index 97d89e369..8487a92d5 100644 --- a/src/modules/everything/evry_plug_border.c +++ b/src/modules/everything/evry_plug_border.c @@ -111,7 +111,7 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) if (bd->internal) { o = edje_object_add(e); - if (!bd->internal_icon) + if (!bd->internal_icon) e_util_edje_icon_set(o, "enlightenment/e"); else { @@ -122,7 +122,7 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) if ((ext) && ((!strcmp(ext, ".edj")))) { if (!edje_object_file_set(o, bd->internal_icon, "icon")) - e_util_edje_icon_set(o, "enlightenment/e"); + e_util_edje_icon_set(o, "enlightenment/e"); } else if (ext) { @@ -130,10 +130,10 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) o = e_icon_add(e); e_icon_file_set(o, bd->internal_icon); } - else + else { if (!e_util_edje_icon_set(o, bd->internal_icon)) - e_util_edje_icon_set(o, "enlightenment/e"); + e_util_edje_icon_set(o, "enlightenment/e"); } } else @@ -144,7 +144,7 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) } return o; } - + if (!o && bd->desktop) o = e_util_desktop_icon_add(bd->desktop, 128, e); @@ -180,14 +180,9 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) static Eina_Bool _init(void) { - p = E_NEW(Evry_Plugin, 1); - p->name = "Windows"; - p->type = type_subject; - p->type_in = "NONE"; - p->type_out = "BORDER"; - p->fetch = &_fetch; - p->cleanup = &_cleanup; - p->icon_get = &_item_icon_get; + p = evry_plugin_new("Windows", type_subject, NULL, "BORDER", 0, NULL, NULL, + NULL, _cleanup, _fetch, NULL, NULL, _item_icon_get, NULL, NULL); + evry_plugin_register(p, 2); return EINA_TRUE; @@ -196,9 +191,9 @@ _init(void) static void _shutdown(void) { - evry_plugin_unregister(p); - E_FREE(p); + evry_plugin_free(p); } + EINA_MODULE_INIT(_init); EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/evry_plug_border_act.c b/src/modules/everything/evry_plug_border_act.c index 68452ae17..00d234176 100644 --- a/src/modules/everything/evry_plug_border_act.c +++ b/src/modules/everything/evry_plug_border_act.c @@ -204,8 +204,7 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) { Evas_Object *o; - o = e_icon_add(e); - evry_icon_theme_set(o, (const char *)it->data[1]); + o = evry_icon_theme_get((const char *)it->data[1], e); return o; } @@ -213,16 +212,8 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) static Eina_Bool _init(void) { - p = E_NEW(Evry_Plugin, 1); - p->name = "Window Action"; - p->type = type_action; - p->type_in = "BORDER"; - p->type_out = "NONE"; - p->begin = &_begin; - p->fetch = &_fetch; - p->action = &_action; - p->cleanup = &_cleanup; - p->icon_get = &_item_icon_get; + p = evry_plugin_new("Window Action", type_action, "BORDER", NULL, 0, NULL, NULL, + _begin, _cleanup, _fetch, _action, NULL, _item_icon_get, NULL, NULL); evry_plugin_register(p, 1); @@ -234,8 +225,7 @@ _init(void) static void _shutdown(void) { - evry_plugin_unregister(p); - E_FREE(p); + evry_plugin_free(p); E_FREE(inst); } diff --git a/src/modules/everything/evry_plug_calc.c b/src/modules/everything/evry_plug_calc.c index f8593b482..91f5fa949 100644 --- a/src/modules/everything/evry_plug_calc.c +++ b/src/modules/everything/evry_plug_calc.c @@ -188,17 +188,9 @@ _cb_del(void *data __UNUSED__, int type __UNUSED__, void *event) static Eina_Bool _init(void) { - p1 = E_NEW(Evry_Plugin, 1); - p1->name = "Calculator"; - p1->type = type_subject; - p1->type_in = "NONE"; - p1->type_out = "TEXT"; - p1->trigger = "="; - p1->icon = "accessories-calculator"; - p1->begin = &_begin; - p1->fetch = &_fetch; - p1->action = &_action; - p1->cleanup = &_cleanup; + p1 = evry_plugin_new("Calculator", type_subject, NULL, "TEXT", 1, "accessories-calculator", "=", + _begin, _cleanup, _fetch, _action, NULL, NULL, NULL, NULL); + evry_plugin_register(p1, 0); return EINA_TRUE; @@ -212,8 +204,7 @@ _shutdown(void) EINA_LIST_FREE(history, result) eina_stringshare_del(result); - evry_plugin_unregister(p1); - E_FREE(p1); + evry_plugin_free(p1); } diff --git a/src/modules/everything/evry_plug_clipboard.c b/src/modules/everything/evry_plug_clipboard.c index 99446ce10..d9ab1c479 100644 --- a/src/modules/everything/evry_plug_clipboard.c +++ b/src/modules/everything/evry_plug_clipboard.c @@ -25,13 +25,9 @@ _init(void) Ecore_X_Window win = ecore_x_window_new(0, 0, 0, 1, 1); if (!win) return EINA_FALSE; - act = E_NEW(Evry_Action, 1); - act->name = "Copy to Clipboard"; - act->is_default = EINA_TRUE; - act->type_in1 = "TEXT"; - act->action = &_action; - act->check_item = &_check_item; - act->icon = "edit-copy"; + act = evry_action_new("Copy to Clipboard", "TEXT", NULL, "edit-copy", + _action, _check_item, NULL); + evry_action_register(act); clipboard_win = win; @@ -43,8 +39,7 @@ static void _shutdown(void) { ecore_x_window_free(clipboard_win); - evry_action_unregister(act); - E_FREE(act); + evry_action_free(act); } EINA_MODULE_INIT(_init); diff --git a/src/modules/everything/evry_plug_config.c b/src/modules/everything/evry_plug_config.c index 37c754c30..8b10f7249 100644 --- a/src/modules/everything/evry_plug_config.c +++ b/src/modules/everything/evry_plug_config.c @@ -82,10 +82,8 @@ _item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) if (eci->icon) { - o = e_icon_add(e); - if (!evry_icon_theme_set(o, eci->icon)) + if (!(o = evry_icon_theme_get(eci->icon, e))) { - evas_object_del(o); o = e_util_icon_add(eci->icon, e); } } @@ -132,23 +130,13 @@ _action(Evry_Action *act, const Evry_Item *it, const Evry_Item *it2 __UNUSED__, static Eina_Bool _init(void) { - p = E_NEW(Evry_Plugin, 1); - p->name = "Settings"; - p->type = type_subject; - p->type_in = "NONE"; - p->type_out = "E_SETTINGS"; - p->fetch = &_fetch; - p->cleanup = &_cleanup; - p->icon_get = &_item_icon_get; + p = evry_plugin_new("Settings", type_subject, NULL, "E_SETTINGS", 0, NULL, NULL, + NULL, _cleanup, _fetch, NULL, NULL, _item_icon_get, NULL, NULL); + + act = evry_action_new("Show Dialog", "E_SETTINGS", NULL, "preferences-advanced", + _action, NULL, NULL); evry_plugin_register(p, 10); - - act = E_NEW(Evry_Action, 1); - act->name = "Show Dialog"; - act->is_default = EINA_TRUE; - act->type_in1 = "E_SETTINGS"; - act->action = &_action; - act->icon = "preferences-advanced"; evry_action_register(act); return EINA_TRUE; @@ -157,10 +145,8 @@ _init(void) static void _shutdown(void) { - evry_plugin_unregister(p); - evry_action_unregister(act); - E_FREE(p); - E_FREE(act); + evry_plugin_free(p); + evry_action_free(act); } EINA_MODULE_INIT(_init); diff --git a/src/modules/everything/evry_plug_dir_browse.c b/src/modules/everything/evry_plug_dir_browse.c index bd273cf3f..d43a51f4c 100644 --- a/src/modules/everything/evry_plug_dir_browse.c +++ b/src/modules/everything/evry_plug_dir_browse.c @@ -39,7 +39,7 @@ static void _item_fill(Evry_Item *it) { const char *mime; - + if (it->mime) return; if (ecore_file_is_dir(it->uri)) @@ -346,7 +346,6 @@ static Evas_Object * _icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) { Evas_Object *o = NULL; - char *icon_path; if (!it->mime) _item_fill((Evry_Item *)it); @@ -354,25 +353,10 @@ _icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) if (!it->mime) return NULL; if (it->browseable) - { - o = e_icon_add(e); - evry_icon_theme_set(o, "folder"); - } + o = evry_icon_theme_get("folder", e); else - { - icon_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 64); + o = evry_icon_mime_get(it->mime, e); - if (icon_path) - { - o = e_util_icon_add(icon_path, e); - free(icon_path); - } - if (!o) - { - o = e_icon_add(e); - evry_icon_theme_set(o, "none"); - } - } return o; } @@ -412,24 +396,20 @@ _open_folder_action(Evry_Action *act __UNUSED__, const Evry_Item *it, const Evry static Eina_Bool _init(void) { - p1 = evry_plugin_new("Files", type_subject, "FILE", "FILE", 0, NULL, + p1 = evry_plugin_new("Files", type_subject, "FILE", "FILE", 0, NULL, NULL, _begin, _cleanup, _fetch, NULL, _browse, _icon_get, NULL, NULL); - p2 = evry_plugin_new("Files", type_object, "FILE", "FILE", 0, NULL, + p2 = evry_plugin_new("Files", type_object, "FILE", "FILE", 0, NULL, NULL, _begin, _cleanup, _fetch, NULL, _browse, _icon_get, NULL, NULL); - + evry_plugin_register(p1, 3); evry_plugin_register(p2, 1); - act = E_NEW(Evry_Action, 1); - act->name = "Open Folder (EFM)"; - act->is_default = EINA_TRUE; - act->type_in1 = eina_stringshare_add("FILE"); - act->action = &_open_folder_action; - act->check_item = &_open_folder_check; - act->icon = "folder-open"; + act = evry_action_new("Open Folder (EFM)", "FILE", NULL, "folder-open", + _open_folder_action, _open_folder_check, NULL); + evry_action_register(act); return EINA_TRUE; @@ -438,13 +418,11 @@ _init(void) static void _shutdown(void) { - evry_plugin_unregister(p1); - evry_plugin_unregister(p2); - E_FREE(p1); - E_FREE(p2); - evry_action_unregister(act); - E_FREE(act); + evry_plugin_free(p1); + evry_plugin_free(p2); + evry_action_free(act); } + EINA_MODULE_INIT(_init); EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/evry_plug_preview.c b/src/modules/everything/evry_plug_preview.c index c1c300b08..c48a11192 100644 --- a/src/modules/everything/evry_plug_preview.c +++ b/src/modules/everything/evry_plug_preview.c @@ -10,15 +10,13 @@ static const char *view_types; static int _check_item(const Evry_Item *it) { - if (!it) return 0; - - if (it->plugin->type_out != view_types) return 0; - - if (!it->uri || !it->mime) return 0; + if ((!it || !it->uri || !it->mime) || + (it->plugin->type_out != view_types)) + return 0; if (!strncmp(it->mime, "image/", 6)) return 1; - + return 0; } diff --git a/src/modules/everything/evry_plug_tracker.c b/src/modules/everything/evry_plug_tracker.c index b1b63d8f1..2d61900ec 100644 --- a/src/modules/everything/evry_plug_tracker.c +++ b/src/modules/everything/evry_plug_tracker.c @@ -327,30 +327,12 @@ _fetch(Evry_Plugin *p, const char *input) static Evas_Object * _icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) { - char *icon_path; - Evas_Object *o = NULL; - if (it->browseable) - { - o = e_icon_add(e); - evry_icon_theme_set(o, "folder"); - } + return evry_icon_theme_get("folder", e); else - { - icon_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 64); + return evry_icon_mime_get(it->mime, e); - if (icon_path) - { - o = e_util_icon_add(icon_path, e); - free(icon_path); - } - else - { - o = e_icon_add(e); - evry_icon_theme_set(o, "none"); - } - } - return o; + return NULL; } static void @@ -359,7 +341,7 @@ _plugin_new(const char *name, int type, char *service, int max_hits, int begin) Evry_Plugin *p; Inst *inst; - p = evry_plugin_new(name, type, "", "FILE", 0, NULL, + p = evry_plugin_new(name, type, "", "FILE", 0, NULL, NULL, (begin ? _begin : NULL), _cleanup, _fetch, NULL, NULL, _icon_get, NULL, NULL); @@ -411,5 +393,6 @@ _shutdown(void) } } + EINA_MODULE_INIT(_init); EINA_MODULE_SHUTDOWN(_shutdown);