From 7aa6e09f48d9234915b1853a52d2266b0c0e6689 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Wed, 28 Apr 2010 16:39:50 +0000 Subject: [PATCH] clean up the mess with stringshared/refd types: use int to identify item type, add function to register new types. SVN revision: 48396 --- src/modules/everything-apps/e_mod_main.c | 14 ++--- src/modules/everything-aspell/e_mod_main.c | 6 +- src/modules/everything-calc/e_mod_main.c | 4 +- src/modules/everything-files/e_mod_main.c | 14 ++--- src/modules/everything-settings/e_mod_main.c | 4 +- src/modules/everything-wallpaper/e_mod_main.c | 8 +-- src/modules/everything-windows/e_mod_main.c | 12 ++-- src/modules/everything/Evry.h | 79 +++++++++++++----------- src/modules/everything/e_mod_main.c | 83 ++++++++++++++++++-------- src/modules/everything/evry.c | 34 ++--------- src/modules/everything/evry_config.c | 6 +- src/modules/everything/evry_history.c | 6 +- src/modules/everything/evry_plug_actions.c | 21 +++---- src/modules/everything/evry_plug_aggregator.c | 2 +- src/modules/everything/evry_plug_clipboard.c | 6 +- src/modules/everything/evry_util.c | 2 +- src/modules/everything/evry_view_plugin_tabs.c | 2 +- 17 files changed, 158 insertions(+), 145 deletions(-) diff --git a/src/modules/everything-apps/e_mod_main.c b/src/modules/everything-apps/e_mod_main.c index ba4f676..f40115e 100644 --- a/src/modules/everything-apps/e_mod_main.c +++ b/src/modules/everything-apps/e_mod_main.c @@ -75,7 +75,7 @@ _begin_open_with(Evry_Plugin *plugin, const Evry_Item *item) const char *mime; - if (!evry_item_type_check(item, EVRY_TYPE_FILE, NULL)) + if (!CHECK_TYPE(item, EVRY_TYPE_FILE)) return 0; GET_FILE(file, item); @@ -746,7 +746,7 @@ _complete(Evry_Plugin *plugin, const Evry_Item *it, char **input) static int _exec_app_check_item(Evry_Action *act, const Evry_Item *it) { - /* if (!evry_item_type_check(it, EVRY_TYPE_APP, NULL)) return 0; */ + /* if (!CHECK_TYPE(it, EVRY_TYPE_APP, NULL)) return 0; */ /* ITEM_APP(app, it); */ @@ -958,7 +958,7 @@ _plugins_init(void) plug_action = p; act = EVRY_ACTION_NEW(N_("Launch"), - EVRY_TYPE_APP, NULL, + EVRY_TYPE_APP, 0, "everything-launch", _exec_app_action, _exec_app_check_item); @@ -972,28 +972,28 @@ _plugins_init(void) _actions = eina_list_append(_actions, act); act = EVRY_ACTION_NEW(N_("Run in Terminal"), - EVRY_TYPE_APP, NULL, + EVRY_TYPE_APP, 0, "system-run", _exec_term_action, _exec_term_check_item); _actions = eina_list_append(_actions, act); act = EVRY_ACTION_NEW(N_("Edit Application Entry"), - EVRY_TYPE_APP, NULL, + EVRY_TYPE_APP, 0, "everything-launch", _edit_app_action, _edit_app_check_item); _actions = eina_list_append(_actions, act); act = EVRY_ACTION_NEW(N_("New Application Entry"), - EVRY_TYPE_APP, NULL, + EVRY_TYPE_APP, 0, "everything-launch", _new_app_action, _new_app_check_item); _actions = eina_list_append(_actions, act); act = EVRY_ACTION_NEW(N_("Run with Sudo"), - EVRY_TYPE_APP, NULL, + EVRY_TYPE_APP, 0, "system-run", _exec_sudo_action, NULL); _actions = eina_list_append(_actions, act); diff --git a/src/modules/everything-aspell/e_mod_main.c b/src/modules/everything-aspell/e_mod_main.c index a9d84e4..f052b87 100644 --- a/src/modules/everything-aspell/e_mod_main.c +++ b/src/modules/everything-aspell/e_mod_main.c @@ -329,8 +329,10 @@ _plugins_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p = EVRY_PLUGIN_NEW(Plugin, N_("Spell Checker"),"accessories-dictionary", - EVRY_TYPE_TEXT, NULL, _cleanup, _fetch, NULL); + p = EVRY_PLUGIN_NEW(Plugin, N_("Spell Checker"), + "accessories-dictionary", + EVRY_TYPE_TEXT, + NULL, _cleanup, _fetch, NULL); p->aggregate = EINA_FALSE; p->history = EINA_FALSE; diff --git a/src/modules/everything-calc/e_mod_main.c b/src/modules/everything-calc/e_mod_main.c index 5661ee6..eeb6f24 100644 --- a/src/modules/everything-calc/e_mod_main.c +++ b/src/modules/everything-calc/e_mod_main.c @@ -232,7 +232,9 @@ _plugins_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Calculator"), "accessories-calculator", EVRY_TYPE_TEXT, + p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Calculator"), + "accessories-calculator", + EVRY_TYPE_TEXT, _begin, _cleanup, _fetch, NULL); p1->view_mode = VIEW_MODE_LIST; diff --git a/src/modules/everything-files/e_mod_main.c b/src/modules/everything-files/e_mod_main.c index 1b35806..3119ac5 100644 --- a/src/modules/everything-files/e_mod_main.c +++ b/src/modules/everything-files/e_mod_main.c @@ -439,7 +439,7 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it) Plugin *p = NULL; /* is FILE ? */ - if (it && evry_item_type_check(it, EVRY_TYPE_FILE, NULL)) + if (it && CHECK_TYPE(it, EVRY_TYPE_FILE)) { GET_FILE(file, it); @@ -486,7 +486,7 @@ _hist_add(Evry_Plugin *plugin, Evry_Item_File *file) EINA_LIST_FOREACH(he->items, l, hi) { - if (hi->type != EVRY_TYPE_FILE) + if (hi->type != evry_type_get(EVRY_TYPE_FILE)) continue; if (hi->data) @@ -620,7 +620,7 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda EINA_LIST_FOREACH(he->items, l, hi) { - if (hi->type != EVRY_TYPE_FILE) + if (hi->type != evry_type_get(EVRY_TYPE_FILE)) continue; /* filter out files that we already have from history */ @@ -998,23 +998,23 @@ _plugins_init(void) p2->config_path = "extensions/everything-files"; evry_plugin_register(p2, EVRY_PLUGIN_OBJECT, 1); - act = EVRY_ACTION_NEW(N_("Open Folder (EFM)"), EVRY_TYPE_FILE, NULL, "folder-open", + act = EVRY_ACTION_NEW(N_("Open Folder (EFM)"), EVRY_TYPE_FILE, 0, "folder-open", _open_folder_action, _open_folder_check); evry_action_register(act, 0); _actions = eina_list_append(_actions, act); - act = EVRY_ACTION_NEW(N_("Open Terminal here"), EVRY_TYPE_FILE, NULL, "system-run", + act = EVRY_ACTION_NEW(N_("Open Terminal here"), EVRY_TYPE_FILE, 0, "system-run", _open_term_action, NULL); evry_action_register(act, 2); _actions = eina_list_append(_actions, act); - act = EVRY_ACTION_NEW(N_("Move to Trash"), EVRY_TYPE_FILE, NULL, "edit-delete", + act = EVRY_ACTION_NEW(N_("Move to Trash"), EVRY_TYPE_FILE, 0, "edit-delete", _file_trash_action, NULL); EVRY_ITEM_DATA_INT_SET(act, ACT_TRASH); evry_action_register(act, 2); _actions = eina_list_append(_actions, act); - act = EVRY_ACTION_NEW(N_("Delete"), EVRY_TYPE_FILE, NULL, "list-remove", + act = EVRY_ACTION_NEW(N_("Delete"), EVRY_TYPE_FILE, 0, "list-remove", _file_trash_action, NULL); EVRY_ITEM_DATA_INT_SET(act, ACT_DELETE); evry_action_register(act, 2); diff --git a/src/modules/everything-settings/e_mod_main.c b/src/modules/everything-settings/e_mod_main.c index b050c6e..92f55ee 100644 --- a/src/modules/everything-settings/e_mod_main.c +++ b/src/modules/everything-settings/e_mod_main.c @@ -123,12 +123,12 @@ _plugins_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Settings"), NULL, "E_SETTINGS", + p = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Settings"), NULL, evry_type_register("E_SETTINGS"), NULL, _cleanup, _fetch, NULL); evry_plugin_register(p, EVRY_PLUGIN_SUBJECT, 10); - act = EVRY_ACTION_NEW(N_("Show Dialog"), "E_SETTINGS", NULL, + act = EVRY_ACTION_NEW(N_("Show Dialog"), evry_type_register("E_SETTINGS"), 0, "preferences-advanced", _action, NULL); evry_action_register(act, 0); diff --git a/src/modules/everything-wallpaper/e_mod_main.c b/src/modules/everything-wallpaper/e_mod_main.c index b9c0671..3559cdc 100644 --- a/src/modules/everything-wallpaper/e_mod_main.c +++ b/src/modules/everything-wallpaper/e_mod_main.c @@ -36,7 +36,7 @@ static Evry_Action *_act; static int _action(Evry_Action *act) { - if (!evry_item_type_check(act->it1.item, EVRY_TYPE_FILE, NULL)) + if (!CHECK_TYPE(act->it1.item, EVRY_TYPE_FILE)) return 0; GET_FILE(file, act->it1.item); @@ -73,10 +73,8 @@ static void _item_add(Evry_Item *it, const char *name, int method, const char *icon) { Evry_Action *act; - act = EVRY_ACTION_NEW(name, EVRY_TYPE_FILE, NULL, icon, _action, NULL); - + act = EVRY_ACTION_NEW(name, EVRY_TYPE_FILE, 0, icon, _action, NULL); EVRY_ITEM_DATA_INT_SET(act, method); - EVRY_ITEM(act)->subtype = eina_stringshare_add("WALLPAPER"); it->items = eina_list_append(it->items, act); } @@ -104,7 +102,7 @@ _plugins_init(void) return EINA_FALSE; _act = EVRY_ACTION_NEW(_("Set as Wallpaper"), - EVRY_TYPE_FILE, NULL, + EVRY_TYPE_FILE, 0, "preferences-desktop-wallpaper", NULL, _check); _act->fetch = _fetch; diff --git a/src/modules/everything-windows/e_mod_main.c b/src/modules/everything-windows/e_mod_main.c index bd3e683..3c47c6b 100644 --- a/src/modules/everything-windows/e_mod_main.c +++ b/src/modules/everything-windows/e_mod_main.c @@ -343,7 +343,7 @@ _plugins_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Windows"), NULL, "BORDER", + p1 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Windows"), NULL, EVRY_TYPE_BORDER, _begin, _cleanup, _fetch, NULL); p1->transient = EINA_TRUE; @@ -351,7 +351,7 @@ _plugins_init(void) act = EVRY_ACTION_NEW(_("Switch to Window"), - "BORDER", NULL, "go-next", + EVRY_TYPE_BORDER, 0, "go-next", _act_border, _check_border); EVRY_ITEM_DATA_INT_SET(act, BORDER_SHOW); evry_action_register(act, 1); @@ -359,28 +359,28 @@ _plugins_init(void) _actions = eina_list_append(_actions, act); act = EVRY_ACTION_NEW(_("Iconify"), - "BORDER", NULL, "iconic", + EVRY_TYPE_BORDER, 0, "iconic", _act_border, _check_border); EVRY_ITEM_DATA_INT_SET(act, BORDER_HIDE); _actions = eina_list_append(_actions, act); evry_action_register(act, 2); act = EVRY_ACTION_NEW(_("Toggle Fullscreen"), - "BORDER", NULL, "view-fullscreen", + EVRY_TYPE_BORDER, 0, "view-fullscreen", _act_border, _check_border); EVRY_ITEM_DATA_INT_SET(act, BORDER_FULLSCREEN); _actions = eina_list_append(_actions, act); evry_action_register(act, 4); act = EVRY_ACTION_NEW(_("Close"), - "BORDER", NULL, "view-fullscreen", + EVRY_TYPE_BORDER, 0, "view-fullscreen", _act_border, _check_border); EVRY_ITEM_DATA_INT_SET(act, BORDER_CLOSE); _actions = eina_list_append(_actions, act); evry_action_register(act, 3); act = EVRY_ACTION_NEW(_("Send to Desktop"), - "BORDER", NULL, "go-previous", + EVRY_TYPE_BORDER, 0, "go-previous", _act_border, _check_border); EVRY_ITEM_DATA_INT_SET(act, BORDER_TODESK); _actions = eina_list_append(_actions, act); diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index 4f7e021..2d2c3e0 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -3,7 +3,7 @@ #include "e.h" -#define EVRY_API_VERSION 8 +#define EVRY_API_VERSION 9 #define EVRY_ACTION_OTHER 0 #define EVRY_ACTION_FINISHED 1 @@ -43,25 +43,31 @@ extern int _e_module_evry_log_dom; #define WRN(...) EINA_LOG_DOM_WARN(_e_module_evry_log_dom , __VA_ARGS__) #define ERR(...) EINA_LOG_DOM_ERR(_e_module_evry_log_dom , __VA_ARGS__) -typedef struct _Evry_Plugin Evry_Plugin; -typedef struct _Evry_Item Evry_Item; -typedef struct _Evry_Item_App Evry_Item_App; -typedef struct _Evry_Item_File Evry_Item_File; -typedef struct _Evry_Action Evry_Action; -typedef struct _Evry_State Evry_State; -typedef struct _Evry_View Evry_View; -typedef struct _History Evry_History; -typedef struct _History_Entry History_Entry; -typedef struct _History_Item History_Item; -typedef struct _Config Evry_Config; -typedef struct _Plugin_Config Plugin_Config; -typedef struct _Plugin_Setting Plugin_Setting; +typedef struct _Evry_Plugin Evry_Plugin; +typedef struct _Evry_Item Evry_Item; +typedef struct _Evry_Item_App Evry_Item_App; +typedef struct _Evry_Item_File Evry_Item_File; +typedef struct _Evry_Action Evry_Action; +typedef struct _Evry_State Evry_State; +typedef struct _Evry_View Evry_View; +typedef struct _History Evry_History; +typedef struct _History_Entry History_Entry; +typedef struct _History_Item History_Item; +typedef struct _Config Evry_Config; +typedef struct _Plugin_Config Plugin_Config; +typedef struct _Plugin_Setting Plugin_Setting; +typedef struct _Evry_Event_Item_Changed Evry_Event_Item_Changed; + +typedef int Evry_Type; #define EVRY_ITEM(_item) ((Evry_Item *)_item) #define EVRY_ACTN(_item) ((Evry_Action *) _item) #define EVRY_PLUGIN(_plugin) ((Evry_Plugin *) _plugin) #define EVRY_VIEW(_view) ((Evry_View *) _view) +#define CHECK_TYPE(_item, _type) (((Evry_Item *)_item)->type == _type) +#define CHECK_SUBTYPE(_item, _type) (((Evry_Item *)_item)->subtype == _type) + #define GET_APP(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item #define GET_FILE(_file, _item) Evry_Item_File *_file = (Evry_Item_File *) _item #define GET_EVRY_PLUGIN(_p, _plugin) Evry_Plugin *_p = (Evry_Plugin*) _plugin @@ -142,10 +148,11 @@ struct _Evry_Item * was performed on a file with a specific mimetype */ const char *context; - const char *type; + /* is set to type of Evry_Plugin by default */ + Evry_Type type; /* optional */ - const char *subtype; + Evry_Type subtype; Eina_List *items; @@ -170,15 +177,15 @@ struct _Evry_Action struct { const Evry_Item *item; - const char *type; - const char *subtype; + Evry_Type type; + Evry_Type subtype; } it1; struct { const Evry_Item *item; - const char *type; - const char *subtype; + Evry_Type type; + Evry_Type subtype; } it2; int (*action) (Evry_Action *act); @@ -310,6 +317,10 @@ struct _Evry_View int priority; }; +struct _Evry_Event_Item_Changed +{ + Evry_Item *item; +}; /* FIXME this should be exposed. - add functions to retrieve this stuff */ @@ -409,7 +420,7 @@ EAPI Evry_Item *evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label void (*cb_free) (Evry_Item *item)); EAPI void evry_item_free(Evry_Item *it); EAPI void evry_item_ref(Evry_Item *it); -EAPI int evry_item_type_check(const Evry_Item *it, const char *type, const char *subtype); + EAPI void evry_plugin_async_update(Evry_Plugin *plugin, int state); EAPI void evry_clear_input(Evry_Plugin *p); @@ -440,7 +451,7 @@ EAPI History_Item *evry_history_add(Eina_Hash *hist, Evry_Item *it, const char * EAPI int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt); EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, const char *icon, - const char *item_type, + Evry_Type item_type, Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item), void (*cleanup) (Evry_Plugin *p), int (*fetch) (Evry_Plugin *p, const char *input), @@ -449,7 +460,7 @@ EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const cha EAPI void evry_plugin_free(Evry_Plugin *p); EAPI Evry_Action *evry_action_new(const char *name, const char *label, - const char *type_in1, const char *type_in2, + Evry_Type type1, Evry_Type type2, const char *icon, int (*action) (Evry_Action *act), int (*check_item) (Evry_Action *act, const Evry_Item *it)); @@ -458,24 +469,20 @@ EAPI void evry_action_free(Evry_Action *act); EAPI int evry_api_version_check(int version); -typedef struct _Evry_Event_Item_Changed Evry_Event_Item_Changed; - -struct _Evry_Event_Item_Changed -{ - Evry_Item *item; -}; +EAPI Evry_Type evry_type_register(const char *type); +EAPI const char *evry_type_get(Evry_Type type); EAPI extern int EVRY_EVENT_ITEM_SELECT; EAPI extern int EVRY_EVENT_ITEM_CHANGED; EAPI extern int EVRY_EVENT_ITEMS_UPDATE; -EAPI extern const char *EVRY_TYPE_FILE; -EAPI extern const char *EVRY_TYPE_APP; -EAPI extern const char *EVRY_TYPE_ACTION; -EAPI extern const char *EVRY_TYPE_PLUGIN; -EAPI extern const char *EVRY_TYPE_NONE; -EAPI extern const char *EVRY_TYPE_BORDER; -EAPI extern const char *EVRY_TYPE_TEXT; +EAPI extern Evry_Type EVRY_TYPE_NONE; +EAPI extern Evry_Type EVRY_TYPE_FILE; +EAPI extern Evry_Type EVRY_TYPE_APP; +EAPI extern Evry_Type EVRY_TYPE_ACTION; +EAPI extern Evry_Type EVRY_TYPE_PLUGIN; +EAPI extern Evry_Type EVRY_TYPE_BORDER; +EAPI extern Evry_Type EVRY_TYPE_TEXT; EAPI extern Evry_History *evry_hist; EAPI extern Evry_Config *evry_conf; diff --git a/src/modules/everything/e_mod_main.c b/src/modules/everything/e_mod_main.c index 0542bf1..1e45dd9 100644 --- a/src/modules/everything/e_mod_main.c +++ b/src/modules/everything/e_mod_main.c @@ -39,13 +39,13 @@ EAPI int EVRY_EVENT_ITEM_SELECT; EAPI int EVRY_EVENT_ITEM_CHANGED; EAPI int EVRY_EVENT_ITEMS_UPDATE; -EAPI const char *EVRY_TYPE_FILE; -EAPI const char *EVRY_TYPE_APP; -EAPI const char *EVRY_TYPE_ACTION; -EAPI const char *EVRY_TYPE_PLUGIN; -EAPI const char *EVRY_TYPE_NONE; -EAPI const char *EVRY_TYPE_BORDER; -EAPI const char *EVRY_TYPE_TEXT; +EAPI Evry_Type EVRY_TYPE_FILE; +EAPI Evry_Type EVRY_TYPE_APP; +EAPI Evry_Type EVRY_TYPE_ACTION; +EAPI Evry_Type EVRY_TYPE_PLUGIN; +EAPI Evry_Type EVRY_TYPE_NONE; +EAPI Evry_Type EVRY_TYPE_BORDER; +EAPI Evry_Type EVRY_TYPE_TEXT; /* module setup */ EAPI E_Module_Api e_modapi = @@ -54,6 +54,42 @@ EAPI E_Module_Api e_modapi = "Everything" }; +static Eina_List *_evry_types = NULL; + +EAPI Evry_Type +evry_type_register(const char *type) +{ + const char *t = eina_stringshare_add(type); + Evry_Type ret = 0; + const char *i; + Eina_List *l; + + EINA_LIST_FOREACH(_evry_types, l, i) + { + if (i == t) break; + ret++; + } + + if(!l) + { + _evry_types = eina_list_append(_evry_types, t); + return ret; + } + eina_stringshare_del(t); + + return ret; +} + +EAPI const char * +evry_type_get(Evry_Type type) +{ + const char *ret = eina_list_nth(_evry_types, type - 1); + if (!ret) + return eina_stringshare_add(""); + + return ret; +} + EAPI void * e_modapi_init(E_Module *m) { @@ -67,6 +103,14 @@ e_modapi_init(E_Module *m) return NULL; } + EVRY_TYPE_NONE = evry_type_register("NONE"); + EVRY_TYPE_FILE = evry_type_register("FILE"); + EVRY_TYPE_APP = evry_type_register("APPLICATION"); + EVRY_TYPE_ACTION = evry_type_register("ACTION"); + EVRY_TYPE_PLUGIN = evry_type_register("PLUGIN"); + EVRY_TYPE_BORDER = evry_type_register("BORDER"); + EVRY_TYPE_TEXT = evry_type_register("TEXT"); + _config_init(); evry_history_init(); @@ -106,14 +150,6 @@ e_modapi_init(E_Module *m) if (!EVRY_EVENT_ITEM_CHANGED) EVRY_EVENT_ITEM_CHANGED = ecore_event_type_new(); - EVRY_TYPE_FILE = eina_stringshare_add("EVRY_FILE"); - EVRY_TYPE_APP = eina_stringshare_add("EVRY_APP"); - EVRY_TYPE_ACTION = eina_stringshare_add("EVRY_ACTN"); - EVRY_TYPE_PLUGIN = eina_stringshare_add("EVRY_PLUG"); - EVRY_TYPE_NONE = eina_stringshare_add("EVRY_NONE"); - EVRY_TYPE_BORDER = eina_stringshare_add("EVRY_BORDER"); - EVRY_TYPE_TEXT = eina_stringshare_add("EVRY_TEXT"); - e_module_delayed_set(m, 0); /* make sure module is loaded before others */ @@ -128,6 +164,8 @@ EAPI int e_modapi_shutdown(E_Module *m __UNUSED__) { E_Config_Dialog *cfd; + const char *t; + evry_shutdown(); view_thumb_shutdown(); @@ -139,13 +177,8 @@ e_modapi_shutdown(E_Module *m __UNUSED__) _config_free(); evry_history_free(); - eina_stringshare_del(EVRY_TYPE_FILE); - eina_stringshare_del(EVRY_TYPE_APP); - eina_stringshare_del(EVRY_TYPE_ACTION); - eina_stringshare_del(EVRY_TYPE_PLUGIN); - eina_stringshare_del(EVRY_TYPE_NONE); - eina_stringshare_del(EVRY_TYPE_BORDER); - eina_stringshare_del(EVRY_TYPE_TEXT); + EINA_LIST_FREE(_evry_types, t) + eina_stringshare_del(t); e_configure_registry_item_del("extensions/run_everything"); e_configure_registry_category_del("extensions"); @@ -445,7 +478,7 @@ _evry_plugin_free(Evry_Item *it) Evry_Plugin * evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, - const char *icon, const char *item_type, + const char *icon, Evry_Type item_type, Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item), void (*finish) (Evry_Plugin *p), int (*fetch) (Evry_Plugin *p, const char *input), @@ -461,10 +494,10 @@ evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, evry_item_new(EVRY_ITEM(p), NULL, label, NULL, _evry_plugin_free); p->base.icon = icon; - p->base.type = eina_stringshare_ref(EVRY_TYPE_PLUGIN); + p->base.type = EVRY_TYPE_PLUGIN; if (item_type) - p->base.subtype = eina_stringshare_add(item_type); + p->base.subtype = item_type; p->name = eina_stringshare_add(name); p->begin = begin; diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index b420be3..a874302 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -323,7 +323,8 @@ evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label, } if (p && EVRY_ITEM(p)->subtype) - it->type = eina_stringshare_ref(EVRY_ITEM(p)->subtype); + it->type = EVRY_ITEM(p)->subtype; + it->plugin = p; if (label) it->label = eina_stringshare_add(label); @@ -331,7 +332,6 @@ evry_item_new(Evry_Item *base, Evry_Plugin *p, const char *label, it->icon_get = icon_get; it->ref = 1; - /* it->usage = -1; */ #ifdef CHECK_REFS item_cnt++; @@ -361,7 +361,6 @@ evry_item_free(Evry_Item *it) if (it->id) eina_stringshare_del(it->id); if (it->context) eina_stringshare_del(it->context); if (it->detail) eina_stringshare_del(it->detail); - if (it->type) eina_stringshare_del(it->type); if (it->free) it->free(it); @@ -369,29 +368,6 @@ evry_item_free(Evry_Item *it) E_FREE(it); } -EAPI int -evry_item_type_check(const Evry_Item *it, const char *type, const char *subtype) -{ - int ok = 0; - - if (it) - { - if (type) - { - if (it->type && type) - ok = (!strcmp(it->type, type)); - } - - if (!(type && !ok) || subtype) - { - if (it->subtype && subtype) - ok = (!strcmp(it->subtype, subtype)); - } - } - - return ok; -} - static Evry_Selector * _evry_selector_for_plugin_get(Evry_Plugin *p) { @@ -1144,7 +1120,7 @@ _evry_selector_objects_get(Evry_Action *act) EINA_LIST_FOREACH(sel->plugins, l, p) { - if (!evry_item_type_check(EVRY_ITEM(p), NULL, act->it2.type)) + if (!CHECK_SUBTYPE(p, act->it2.type)) continue; if (p->begin) @@ -1734,8 +1710,8 @@ _evry_plugin_action(Evry_Selector *sel, int finished) if (!(it_act = s_act->cur_item)) return; - if (evry_item_type_check(it_act, EVRY_TYPE_ACTION, NULL) || - evry_item_type_check(it_act, NULL, EVRY_TYPE_ACTION)) + if (CHECK_TYPE(it_act, EVRY_TYPE_ACTION) || + CHECK_SUBTYPE(it_act, EVRY_TYPE_ACTION)) { GET_ACTION(act, it_act); diff --git a/src/modules/everything/evry_config.c b/src/modules/everything/evry_config.c index 5b3b5d9..4ab9123 100644 --- a/src/modules/everything/evry_config.c +++ b/src/modules/everything/evry_config.c @@ -207,8 +207,10 @@ _fill_list(Eina_List *plugins, Evas_Object *obj, int enabled __UNUSED__) e_widget_ilist_clear(obj); EINA_LIST_FOREACH(plugins, l, pc) - e_widget_ilist_append(obj, NULL, pc->name, NULL, pc, NULL); - + { + e_widget_ilist_append(obj, NULL, pc->name, NULL, pc, NULL); + } + e_widget_ilist_go(obj); e_widget_size_min_get(obj, &w, NULL); e_widget_size_min_set(obj, w > 180 ? w : 180, 200); diff --git a/src/modules/everything/evry_history.c b/src/modules/everything/evry_history.c index 5ae7919..4ea2d3b 100644 --- a/src/modules/everything/evry_history.c +++ b/src/modules/everything/evry_history.c @@ -245,7 +245,7 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i hi = E_NEW(History_Item, 1); hi->plugin = eina_stringshare_ref(it->plugin->name); if (it->type) - hi->type = eina_stringshare_ref(it->type); + hi->type = eina_stringshare_ref(evry_type_get(it->type)); he->items = eina_list_append(he->items, hi); } @@ -257,10 +257,6 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i hi->transient = it->plugin->transient; hi->count += (hi->transient ? 2:1); - /* XXX can be remove just for update */ - if (it->type && !hi->type) - hi->type = eina_stringshare_ref(it->type); - if (ctxt && !hi->context) hi->context = eina_stringshare_ref(ctxt); diff --git a/src/modules/everything/evry_plug_actions.c b/src/modules/everything/evry_plug_actions.c index 753bc35..846919a 100644 --- a/src/modules/everything/evry_plug_actions.c +++ b/src/modules/everything/evry_plug_actions.c @@ -39,13 +39,12 @@ _begin(Evry_Plugin *plugin, const Evry_Item *it) GET_PLUGIN(p, plugin); Evry_Action *act; Eina_List *l; - const char *type; + Evry_Type type; if (!it || !it->type) return NULL; type = it->type; - if (it->browseable) { EINA_LIST_FOREACH(evry_conf->actions, l, act) @@ -142,7 +141,7 @@ evry_plug_actions_new(Evry_Selector *sel, int type) { Evry_Plugin *plugin; - plugin = EVRY_PLUGIN_NEW(Plugin, N_("Actions"), NULL, NULL, _begin, _finish, _fetch, NULL); + plugin = EVRY_PLUGIN_NEW(Plugin, N_("Actions"), NULL, 0, _begin, _finish, _fetch, NULL); GET_PLUGIN(p, plugin); p->selector = sel; @@ -155,7 +154,8 @@ evry_plug_actions_new(Evry_Selector *sel, int type) int evry_plug_actions_init() { - _base_plug = evry_plugin_new(NULL, _("Actions"), NULL, NULL, NULL, NULL, NULL, NULL, NULL); + _base_plug = evry_plugin_new(NULL, _("Actions"), NULL, NULL, + EVRY_TYPE_ACTION, NULL, NULL, NULL, NULL); return 1; } @@ -193,29 +193,24 @@ _action_free_cb(Evry_Item *it) GET_ACTION(act, it); if (act->name) eina_stringshare_del(act->name); - if (act->it1.type) eina_stringshare_del(act->it1.type); - if (act->it2.type) eina_stringshare_del(act->it2.type); E_FREE(act); } EAPI Evry_Action * evry_action_new(const char *name, const char *label, - const char *type_in1, const char *type_in2, + Evry_Type type_in1, Evry_Type type_in2, const char *icon, int (*action) (Evry_Action *act), int (*check_item) (Evry_Action *act, const Evry_Item *it)) { - Evry_Action *act = E_NEW(Evry_Action, 1); - - evry_item_new(EVRY_ITEM(act), _base_plug, label, NULL, _action_free_cb); + Evry_Action *act = EVRY_ITEM_NEW(Evry_Action, _base_plug, label, NULL, _action_free_cb); act->base.icon = icon; - act->base.type = eina_stringshare_ref(EVRY_TYPE_ACTION); act->name = eina_stringshare_add(name); - act->it1.type = (type_in1 ? eina_stringshare_add(type_in1) : NULL); - act->it2.type = (type_in2 ? eina_stringshare_add(type_in2) : NULL); + act->it1.type = type_in1; + act->it2.type = type_in2; act->action = action; act->check_item = check_item; diff --git a/src/modules/everything/evry_plug_aggregator.c b/src/modules/everything/evry_plug_aggregator.c index 2d74377..750d619 100644 --- a/src/modules/everything/evry_plug_aggregator.c +++ b/src/modules/everything/evry_plug_aggregator.c @@ -269,7 +269,7 @@ evry_plug_aggregator_new(Evry_Selector *sel, int type) { Evry_Plugin *p; - p = EVRY_PLUGIN_NEW(Plugin, N_("All"), NULL, NULL, NULL, _finish, _fetch, NULL); + p = EVRY_PLUGIN_NEW(Plugin, N_("All"), NULL, 0, NULL, _finish, _fetch, NULL); p->history = EINA_FALSE; evry_plugin_register(p, type, -1); diff --git a/src/modules/everything/evry_plug_clipboard.c b/src/modules/everything/evry_plug_clipboard.c index 762ede1..f4a765c 100644 --- a/src/modules/everything/evry_plug_clipboard.c +++ b/src/modules/everything/evry_plug_clipboard.c @@ -31,8 +31,10 @@ evry_plug_clipboard_init(void) if (!win) return EINA_FALSE; //FIXME: Icon name doesnt follow FDO Spec - act = EVRY_ACTION_NEW(N_("Copy to Clipboard"), EVRY_TYPE_TEXT, NULL, "everything-clipboard", - _action, _check_item); + act = EVRY_ACTION_NEW(N_("Copy to Clipboard"), + EVRY_TYPE_TEXT, 0, + "everything-clipboard", + _action, _check_item); evry_action_register(act, 10); diff --git a/src/modules/everything/evry_util.c b/src/modules/everything/evry_util.c index af2290a..63fb3bc 100644 --- a/src/modules/everything/evry_util.c +++ b/src/modules/everything/evry_util.c @@ -382,7 +382,7 @@ evry_util_icon_get(Evry_Item *it, Evas *e) if (!o && it->icon) o = evry_icon_theme_get(it->icon, e); - if (evry_item_type_check(it, EVRY_TYPE_FILE, NULL)) + if (CHECK_TYPE(it, EVRY_TYPE_FILE)) o = _file_icon_get(it, e); /* TODO default type: files, apps */ diff --git a/src/modules/everything/evry_view_plugin_tabs.c b/src/modules/everything/evry_view_plugin_tabs.c index ca9fec0..272c04c 100644 --- a/src/modules/everything/evry_view_plugin_tabs.c +++ b/src/modules/everything/evry_view_plugin_tabs.c @@ -20,7 +20,7 @@ _animator(void *data) Tab_View *v = data; double da; - double spd = (5.0 / (double)e_config->framerate); + double spd = (8.0 / (double)e_config->framerate); if (spd > 0.9) spd = 0.9; int wait = 0; -- 2.7.4