From 3f29ece6dbfa16ca69080a80853a8454a3290efc Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Thu, 15 Apr 2010 21:42:30 +0000 Subject: [PATCH] 'everything' cleanup api - fix 'localization'? - translating plugin labels should work now SVN revision: 48042 --- src/modules/everything-apps/e_mod_main.c | 47 +++---- src/modules/everything-aspell/e_mod_main.c | 13 +- src/modules/everything-calc/e_mod_main.c | 16 ++- src/modules/everything-files/e_mod_main.c | 17 ++- src/modules/everything-settings/e_mod_main.c | 10 +- src/modules/everything-wallpaper/e_mod_main.c | 17 +-- src/modules/everything-windows/e_mod_main.c | 121 +++++++++--------- src/modules/everything/Evry.h | 50 +++++--- src/modules/everything/e_mod_main.c | 40 ++---- src/modules/everything/evry.c | 10 +- src/modules/everything/evry_plug_actions.c | 11 +- src/modules/everything/evry_plug_aggregator.c | 6 +- src/modules/everything/evry_plug_clipboard.c | 4 +- src/modules/everything/evry_plug_view_help.c | 2 +- src/modules/everything/evry_plug_view_thumb.c | 118 +++++++++-------- .../everything/evry_view_plugin_tabs.c | 4 +- 16 files changed, 244 insertions(+), 242 deletions(-) diff --git a/src/modules/everything-apps/e_mod_main.c b/src/modules/everything-apps/e_mod_main.c index 9eba26067..ac4f861ef 100644 --- a/src/modules/everything-apps/e_mod_main.c +++ b/src/modules/everything-apps/e_mod_main.c @@ -909,46 +909,37 @@ module_init(void) return EINA_FALSE; p1 = E_NEW(Plugin, 1); - evry_plugin_new(EVRY_PLUGIN(p1), "Applications", type_subject, "", "APPLICATION", 0, NULL, NULL, - _begin, _cleanup, _fetch, NULL, _icon_get, _free_plugin); + EVRY_PLUGIN_NEW(EVRY_PLUGIN(p1), "Applications", type_subject, "", "APPLICATION", + _begin, _cleanup, _fetch, _icon_get, _free_plugin); EVRY_PLUGIN(p1)->complete = &_complete; p2 = E_NEW(Plugin, 1); - evry_plugin_new(EVRY_PLUGIN(p2), "Open With...", type_action, "FILE", "", 0, NULL, NULL, - _begin_open_with, _cleanup, _fetch, _open_with_action, - _icon_get, _free_plugin); + EVRY_PLUGIN_NEW(EVRY_PLUGIN(p2), "Open With...", type_action, "FILE", "", + _begin_open_with, _cleanup, _fetch, + _icon_get, _free_plugin); + + EVRY_PLUGIN(p2)->action = &_open_with_action; evry_plugin_register(EVRY_PLUGIN(p1), 1); evry_plugin_register(EVRY_PLUGIN(p2), 1); - act = evry_action_new("Launch", "APPLICATION", NULL, NULL, - "everything-launch", - _exec_app_action, _exec_app_check_item, - NULL, NULL, NULL, NULL); + act = EVRY_ACTION_NEW("Launch", "APPLICATION", NULL, + "everything-launch", _exec_app_action, _exec_app_check_item); - act1 = evry_action_new("Open File...", "APPLICATION", "FILE", "APPLICATION", - "document-open", - _exec_app_action, _exec_app_check_item, - NULL, NULL, NULL, NULL); + act1 = EVRY_ACTION_NEW("Open File...", "APPLICATION", "FILE", "document-open", + _exec_app_action, _exec_app_check_item); - act2 = evry_action_new("Run in Terminal", "APPLICATION", NULL, NULL, - "system-run", - _exec_term_action, _exec_term_check_item, - NULL, NULL, NULL, NULL); + act2 = EVRY_ACTION_NEW("Run in Terminal", "APPLICATION", NULL, "system-run", + _exec_term_action, _exec_term_check_item); - act3 = evry_action_new("Edit Application Entry", "APPLICATION", NULL, NULL, - "everything-launch", - _edit_app_action, _edit_app_check_item, - NULL, NULL, NULL, NULL); + act3 = EVRY_ACTION_NEW("Edit Application Entry", "APPLICATION", NULL, "everything-launch", + _edit_app_action, _edit_app_check_item); - act4 = evry_action_new("New Application Entry", "APPLICATION", NULL, NULL, - "everything-launch", - _new_app_action, _new_app_check_item, - NULL, NULL, NULL, NULL); + act4 = EVRY_ACTION_NEW("New Application Entry", "APPLICATION", NULL, "everything-launch", + _new_app_action, _new_app_check_item); - act5 = evry_action_new("Run with Sudo", "APPLICATION", NULL, NULL, - "system-run", - _exec_sudo_action, NULL, NULL, NULL, NULL, NULL); + act5 = EVRY_ACTION_NEW("Run with Sudo", "APPLICATION", NULL, "system-run", + _exec_sudo_action, NULL); evry_action_register(act, 0); evry_action_register(act1, 1); diff --git a/src/modules/everything-aspell/e_mod_main.c b/src/modules/everything-aspell/e_mod_main.c index b24ae2be6..9cb84d277 100644 --- a/src/modules/everything-aspell/e_mod_main.c +++ b/src/modules/everything-aspell/e_mod_main.c @@ -338,12 +338,15 @@ module_init(void) return EINA_FALSE; p = E_NEW(Plugin, 1); - evry_plugin_new(EVRY_PLUGIN(p), "Spell Checker", type_subject, "", "TEXT", 1, - "accessories-dictionary", TRIGGER, - NULL, _cleanup, _fetch, NULL, NULL, _free_plugin); - EVRY_PLUGIN(p)->aggregate = EINA_FALSE; - EVRY_PLUGIN(p)->history = EINA_FALSE; + EVRY_PLUGIN_NEW(p, "Spell Checker", type_subject, "", "TEXT", + NULL, _cleanup, _fetch, NULL, _free_plugin); + + EVRY_PLUGIN(p)->aggregate = EINA_FALSE; + EVRY_PLUGIN(p)->history = EINA_FALSE; + EVRY_PLUGIN(p)->async_fetch = EINA_TRUE; + EVRY_PLUGIN(p)->icon = "accessories-dictionary"; + EVRY_PLUGIN(p)->trigger = TRIGGER; evry_plugin_register(EVRY_PLUGIN(p), 100); diff --git a/src/modules/everything-calc/e_mod_main.c b/src/modules/everything-calc/e_mod_main.c index 823eaab7a..76f1a64fd 100644 --- a/src/modules/everything-calc/e_mod_main.c +++ b/src/modules/everything-calc/e_mod_main.c @@ -229,12 +229,16 @@ module_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p1 = evry_plugin_new(NULL, "Calculator", type_subject, NULL, "TEXT", 1, "accessories-calculator", "=", - _begin, _cleanup, _fetch, _action, NULL, NULL); - - p1->view_mode = VIEW_MODE_LIST; - p1->aggregate = EINA_FALSE; - p1->history = EINA_FALSE; + p1 = EVRY_PLUGIN_NEW(NULL, "Calculator", type_subject, NULL, "TEXT", + _begin, _cleanup, _fetch, NULL, NULL); + + p1->view_mode = VIEW_MODE_LIST; + p1->aggregate = EINA_FALSE; + p1->history = EINA_FALSE; + p1->async_fetch = EINA_TRUE; + p1->icon = "accessories-calculator"; + p1->trigger = "="; + p1->action = &_action; evry_plugin_register(p1, 0); diff --git a/src/modules/everything-files/e_mod_main.c b/src/modules/everything-files/e_mod_main.c index 1c21a6acb..91944335c 100644 --- a/src/modules/everything-files/e_mod_main.c +++ b/src/modules/everything-files/e_mod_main.c @@ -526,22 +526,21 @@ module_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p1 = evry_plugin_new(NULL, "Files", type_subject, "FILE", "FILE", 0, NULL, NULL, - _begin, _cleanup, _fetch, NULL, _icon_get, NULL); + p1 = EVRY_PLUGIN_NEW(NULL, "Files", type_subject, "FILE", "FILE", + _begin, _cleanup, _fetch, _icon_get, NULL); - p2 = evry_plugin_new(NULL, "Files", type_object, "FILE", "FILE", 0, NULL, NULL, - _begin, _cleanup, _fetch, NULL, _icon_get, NULL); + p2 = EVRY_PLUGIN_NEW(NULL, "Files", type_object, "FILE", "FILE", + _begin, _cleanup, _fetch, _icon_get, NULL); evry_plugin_register(p1, 3); evry_plugin_register(p2, 1); - act1 = evry_action_new("Open Folder (EFM)", "FILE", NULL, NULL, "folder-open", - _open_folder_action, _open_folder_check, NULL, NULL, NULL, NULL); + act1 = EVRY_ACTION_NEW("Open Folder (EFM)", "FILE", NULL, "folder-open", + _open_folder_action, _open_folder_check); evry_action_register(act1, 0); - act2 = evry_action_new("Open Terminal here", "FILE", NULL, NULL, - "system-run", - _open_term_action, NULL, NULL, NULL, NULL, NULL); + act2 = EVRY_ACTION_NEW("Open Terminal here", "FILE", NULL, "system-run", + _open_term_action, NULL); evry_action_register(act2, 2); return EINA_TRUE; diff --git a/src/modules/everything-settings/e_mod_main.c b/src/modules/everything-settings/e_mod_main.c index 931f5e746..1b437b47c 100644 --- a/src/modules/everything-settings/e_mod_main.c +++ b/src/modules/everything-settings/e_mod_main.c @@ -123,13 +123,13 @@ module_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - p = evry_plugin_new(NULL, "Settings", type_subject, NULL, "E_SETTINGS", 0, NULL, NULL, - NULL, _cleanup, _fetch, NULL, _item_icon_get, NULL); - - act = evry_action_new("Show Dialog", "E_SETTINGS", NULL, NULL, "preferences-advanced", - _action, NULL, NULL, NULL, NULL, NULL); + p = EVRY_PLUGIN_NEW(NULL, "Settings", type_subject, NULL, "E_SETTINGS", + NULL, _cleanup, _fetch, _item_icon_get, NULL); evry_plugin_register(p, 10); + + act = EVRY_ACTION_NEW("Show Dialog", "E_SETTINGS", NULL, + "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 75eca9686..46459130f 100644 --- a/src/modules/everything-wallpaper/e_mod_main.c +++ b/src/modules/everything-wallpaper/e_mod_main.c @@ -48,7 +48,7 @@ static void _import_edj_gen(Import *import); static int _import_cb_edje_cc_exit(void *data, int type, void *event); static Import *import = NULL; -static Evry_Plugin *plugin; +static Evry_Plugin *_plug; static void _item_free(Evry_Item *item) @@ -205,12 +205,13 @@ module_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - plugin = evry_plugin_new(NULL, "Wallpaper", type_action, "FILE", "", - 0, "preferences-desktop-wallpaper", NULL, - _begin, _cleanup, _fetch, _action, _icon_get, - NULL); - - evry_plugin_register(plugin, 10); + _plug = EVRY_PLUGIN_NEW(NULL, "Wallpaper", type_action, "FILE", "", + _begin, _cleanup, _fetch, _icon_get, NULL); + + EVRY_PLUGIN(_plug)->icon = "preferences-desktop-wallpaper"; + EVRY_PLUGIN(_plug)->action = &_action; + + evry_plugin_register(_plug, 10); return EINA_TRUE; } @@ -218,7 +219,7 @@ module_init(void) static void module_shutdown(void) { - EVRY_PLUGIN_FREE(plugin); + EVRY_PLUGIN_FREE(_plug); if (import) { diff --git a/src/modules/everything-windows/e_mod_main.c b/src/modules/everything-windows/e_mod_main.c index a12500055..c79634485 100644 --- a/src/modules/everything-windows/e_mod_main.c +++ b/src/modules/everything-windows/e_mod_main.c @@ -5,7 +5,7 @@ #include "Evry.h" #include "e_mod_main.h" -static Evry_Plugin *plugin; +static Evry_Plugin *p1; static Eina_List *handlers = NULL; static Eina_Hash *border_hash = NULL; @@ -244,7 +244,7 @@ struct _Inst E_Border *border; }; -static Evry_Plugin *plugin2 = NULL; +static Evry_Plugin *p2 = NULL; static Inst *inst = NULL; static Evry_Action *act = NULL; @@ -436,48 +436,48 @@ _act_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) } -static int -_exec_border_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) -{ - E_Border *bd = it->data; - E_OBJECT_CHECK_RETURN(bd, 0); - E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, 0); - - if ((bd->desktop && bd->desktop->exec) && - ((strstr(bd->desktop->exec, "%u")) || - (strstr(bd->desktop->exec, "%U")) || - (strstr(bd->desktop->exec, "%f")) || - (strstr(bd->desktop->exec, "%F")))) - return 1; - - return 0; -} - -static int -_exec_border_action(Evry_Action *act) -{ - return evry_util_exec_app(act->item1, act->item2); -} - -static int -_exec_border_intercept(Evry_Action *act) -{ - Evry_Item_App *app = E_NEW(Evry_Item_App, 1); - E_Border *bd = act->item1->data; - - app->desktop = bd->desktop; - act->item1 = EVRY_ITEM(app); - - return 1; -} - - -static void -_exec_border_cleanup(Evry_Action *act) -{ - ITEM_APP(app, act->item1); - E_FREE(app); -} +/* static int + * _exec_border_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it) + * { + * E_Border *bd = it->data; + * E_OBJECT_CHECK_RETURN(bd, 0); + * E_OBJECT_TYPE_CHECK_RETURN(bd, E_BORDER_TYPE, 0); + * + * if ((bd->desktop && bd->desktop->exec) && + * ((strstr(bd->desktop->exec, "%u")) || + * (strstr(bd->desktop->exec, "%U")) || + * (strstr(bd->desktop->exec, "%f")) || + * (strstr(bd->desktop->exec, "%F")))) + * return 1; + * + * return 0; + * } + * + * static int + * _exec_border_action(Evry_Action *act) + * { + * return evry_util_exec_app(act->item1, act->item2); + * } + * + * static int + * _exec_border_intercept(Evry_Action *act) + * { + * Evry_Item_App *app = E_NEW(Evry_Item_App, 1); + * E_Border *bd = act->item1->data; + * + * app->desktop = bd->desktop; + * act->item1 = EVRY_ITEM(app); + * + * return 1; + * } + * + * + * static void + * _exec_border_cleanup(Evry_Action *act) + * { + * ITEM_APP(app, act->item1); + * E_FREE(app); + * } */ @@ -487,21 +487,24 @@ module_init(void) if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; - plugin = evry_plugin_new(NULL, "Windows", type_subject, NULL, "BORDER", 0, NULL, NULL, - _begin, _cleanup, _fetch, NULL, _item_icon_get, NULL); - plugin->transient = EINA_TRUE; - evry_plugin_register(plugin, 2); + p1 = EVRY_PLUGIN_NEW(NULL, "Windows", type_subject, NULL, "BORDER", + _begin, _cleanup, _fetch, _item_icon_get, NULL); + p1->transient = EINA_TRUE; + evry_plugin_register(p1, 2); - plugin2 = evry_plugin_new(NULL, "Window Action", type_action, "BORDER", NULL, 0, NULL, NULL, - _act_begin, _act_cleanup, _act_fetch, _act_action, _act_item_icon_get, NULL); - evry_plugin_register(plugin2, 1); + p2 = EVRY_PLUGIN_NEW(NULL, "Window Action", type_action, "BORDER", NULL, + _act_begin, _act_cleanup, _act_fetch, _act_item_icon_get, NULL); + + EVRY_PLUGIN(p2)->action = &_act_action; + + evry_plugin_register(p2, 1); - act = evry_action_new("Open File...", "BORDER", "FILE", "APPLICATION", - "everything-launch", - _exec_border_action, _exec_border_check_item, - _exec_border_cleanup, _exec_border_intercept, NULL, NULL); - evry_action_register(act, 10); + /* act = evry_action_new("Open File...", "BORDER", "FILE", "APPLICATION", + * "everything-launch", + * _exec_border_action, _exec_border_check_item, + * _exec_border_cleanup, _exec_border_intercept, NULL, NULL); + * evry_action_register(act, 10); */ return EINA_TRUE; } @@ -509,10 +512,10 @@ module_init(void) static void module_shutdown(void) { - EVRY_PLUGIN_FREE(plugin); - EVRY_PLUGIN_FREE(plugin2); + EVRY_PLUGIN_FREE(p1); + EVRY_PLUGIN_FREE(p2); - evry_action_free(act); + /* evry_action_free(act); */ } /***************************************************************************/ diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index 160713900..5f893f563 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -3,8 +3,7 @@ #include "e.h" -#define EVRY_API_VERSION 2 - +#define EVRY_API_VERSION 3 #define EVRY_ACTION_OTHER 0 #define EVRY_ACTION_FINISHED 1 @@ -18,6 +17,7 @@ #define EVRY_COMPLETE_INPUT 1 #define EVRY_COMPLETE_BROWSE 2 +#define VIEW_MODE_NONE -1 #define VIEW_MODE_LIST 0 #define VIEW_MODE_DETAIL 1 #define VIEW_MODE_THUMB 2 @@ -51,6 +51,7 @@ typedef struct _History_Entry History_Entry; typedef struct _History_Item History_Item; typedef struct _Config Evry_Config; + #define EVRY_ITEM(_item) ((Evry_Item *)_item) #define EVRY_PLUGIN(_plugin) ((Evry_Plugin *) _plugin) #define EVRY_VIEW(_view) ((Evry_View *) _view) @@ -159,14 +160,26 @@ struct _Evry_Item_File struct _Evry_Plugin { + /* identifier */ const char *name; + + /* shown title */ + const char *label; + + /* provide default icon */ const char *icon; + /* use plugin for first second or third part of an action + if actions are no dynamical lists better use Evry_Action */ enum { type_subject, type_action, type_object } type; - const char *type_in; + /* plugin provides items of this type */ const char *type_out; + + /* plugin accepts this type in begin function */ + const char *type_in; + /* show this plugin only when triggered */ const char *trigger; /* list of items visible for everything */ @@ -240,9 +253,6 @@ struct _Evry_State Eina_List *sel_items; - /* this is for the case when the current plugin was not selected - manually and a higher priority (async) plugin retrieves - candidates, the higher priority plugin is made current */ Eina_Bool plugin_auto_selected; Eina_Bool item_auto_selected; @@ -269,11 +279,15 @@ struct _Evry_View struct _Evry_Action { + /* identifier */ const char *name; + /* shown title */ + const char *label; + + /* */ const char *type_in1; const char *type_in2; - const char *type_out; const Evry_Item *item1; const Evry_Item *item2; @@ -296,6 +310,8 @@ struct _Evry_Action int priority; }; +/* FIXME this should be exposed. + - add functions to retrieve this stuff */ struct _Config { int version; @@ -397,28 +413,28 @@ EAPI void evry_history_unload(void); EAPI void evry_history_add(Eina_Hash *hist, Evry_State *s, const char *ctxt); 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, int type, +#define EVRY_PLUGIN_NEW(_base, _name, _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ + evry_plugin_new(EVRY_PLUGIN(_base), _name, _(_name), _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ + +EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, int type, const char *type_in, const char *type_out, - int async_fetch, const char *icon, const char *trigger, Evry_Plugin *(*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), Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e), void (*free) (Evry_Plugin *p)); EAPI void evry_plugin_free(Evry_Plugin *p, int free_pointer); -EAPI Evry_Action *evry_action_new(const char *name, const char *type_in1, - const char *type_in2, const char *type_out, +#define EVRY_ACTION_NEW(_name, _in1, _in2, _icon, _action, _check) \ + evry_action_new(_name, _(_name), _in1, _in2, _icon, _action, _check) + +EAPI Evry_Action *evry_action_new(const char *name, const char *label, + const char *type_in1, const char *type_in2, const char *icon, int (*action) (Evry_Action *act), - int (*check_item) (Evry_Action *act, const Evry_Item *it), - void (*cleanup) (Evry_Action *act), - int (*intercept) (Evry_Action *act), - Evas_Object *(*icon_get) (Evry_Action *act, Evas *e), - void (*free) (Evry_Action *p)); + int (*check_item) (Evry_Action *act, const Evry_Item *it)); EAPI 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 fa32b796b..43191db25 100644 --- a/src/modules/everything/e_mod_main.c +++ b/src/modules/everything/e_mod_main.c @@ -378,13 +378,11 @@ _evry_cb_plugin_sort(const void *data1, const void *data2) } Evry_Plugin * -evry_plugin_new(Evry_Plugin *base, const char *name, int type, +evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, int type, const char *type_in, const char *type_out, - int async_fetch, const char *icon, const char *trigger, Evry_Plugin *(*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), Evas_Object *(*icon_get) (Evry_Plugin *p, const Evry_Item *it, Evas *e), void (*cb_free) (Evry_Plugin *p)) { @@ -396,23 +394,23 @@ evry_plugin_new(Evry_Plugin *base, const char *name, int type, p = E_NEW(Evry_Plugin, 1); p->name = eina_stringshare_add(name); + p->label = eina_stringshare_add(label); p->type = type; 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->trigger = (trigger ? eina_stringshare_add(trigger) : NULL); */ + /* p->icon = (icon ? eina_stringshare_add(icon) : NULL); */ p->begin = begin; p->cleanup = cleanup; p->fetch = fetch; p->icon_get = icon_get; - p->action = action; + /* p->action = action; */ p->aggregate = EINA_TRUE; p->async_fetch = EINA_FALSE; p->free = cb_free; p->history = EINA_TRUE; - p->view_mode = -1; + p->view_mode = VIEW_MODE_NONE; DBG("%s", p->name); @@ -427,10 +425,11 @@ evry_plugin_free(Evry_Plugin *p, int free_pointer) DBG("%s", p->name); if (p->name) eina_stringshare_del(p->name); + if (p->label) eina_stringshare_del(p->label); 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); + /* if (p->trigger) eina_stringshare_del(p->trigger); */ + /* if (p->icon) eina_stringshare_del(p->icon); */ if (p->free) p->free(p); @@ -441,25 +440,18 @@ evry_plugin_free(Evry_Plugin *p, int free_pointer) } Evry_Action * -evry_action_new(const char *name, const char *type_in1, const char *type_in2, - const char *type_out, const char *icon, +evry_action_new(const char *name, const char *label, const char *type_in1, const char *type_in2, + const char *icon, int (*action) (Evry_Action *act), - int (*check_item) (Evry_Action *act, const Evry_Item *it), - void (*cleanup) (Evry_Action *act), - int (*intercept) (Evry_Action *act), - Evas_Object *(*icon_get) (Evry_Action *act, Evas *e), - void (*cb_free) (Evry_Action *p)) + int (*check_item) (Evry_Action *act, const Evry_Item *it)) { Evry_Action *act = E_NEW(Evry_Action, 1); act->name = eina_stringshare_add(name); + act->label = eina_stringshare_add(label); act->type_in1 = (type_in1 ? eina_stringshare_add(type_in1) : NULL); act->type_in2 = (type_in2 ? eina_stringshare_add(type_in2) : NULL); - act->type_out = (type_out ? eina_stringshare_add(type_out) : NULL); act->action = action; act->check_item = check_item; - act->intercept = intercept; - act->cleanup = cleanup; - act->free = cb_free; act->icon = (icon ? eina_stringshare_add(icon) : NULL); DBG("%s", name); @@ -473,9 +465,9 @@ evry_action_free(Evry_Action *act) evry_action_unregister(act); if (act->name) eina_stringshare_del(act->name); + if (act->label) eina_stringshare_del(act->label); if (act->type_in1) eina_stringshare_del(act->type_in1); if (act->type_in2) eina_stringshare_del(act->type_in2); - if (act->type_out) eina_stringshare_del(act->type_out); if (act->icon) eina_stringshare_del(act->icon); if (act->free) @@ -588,10 +580,6 @@ _evry_cb_view_sort(const void *data1, const void *data2) void evry_view_register(Evry_View *view, int priority) { - /* XXX remove: ignore old list view, some people might - forget to do make uninstall */ - if (!strcmp(view->name, "List View")) return; - view->priority = priority; evry_conf->views = eina_list_append(evry_conf->views, view); diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index 73f1b7903..05fecaf98 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -789,7 +789,7 @@ _evry_selector_activate(Evry_Selector *sel) if (sel->state->cur_item) edje_object_part_text_set(sel->o_main, "e.text.plugin", - s->cur_item->plugin->name); + s->cur_item->plugin->label); _evry_view_show(s->view); _evry_list_win_update(s); @@ -964,7 +964,7 @@ _evry_selector_update(Evry_Selector *sel) edje_object_part_text_set(sel->o_main, "e.text.label", it->label); if (sel == selector) - edje_object_part_text_set(sel->o_main, "e.text.plugin", it->plugin->name); + edje_object_part_text_set(sel->o_main, "e.text.plugin", it->plugin->label); else edje_object_part_text_set(sel->o_main, "e.text.plugin", ""); } @@ -973,7 +973,7 @@ _evry_selector_update(Evry_Selector *sel) /* no items for this state - clear selector */ edje_object_part_text_set(sel->o_main, "e.text.label", ""); if (sel == selector && s && s->plugin) - edje_object_part_text_set(sel->o_main, "e.text.plugin", s->plugin->name); + edje_object_part_text_set(sel->o_main, "e.text.plugin", s->plugin->label); else edje_object_part_text_set(sel->o_main, "e.text.plugin", ""); } @@ -1389,7 +1389,7 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) if (action == EVRY_COMPLETE_INPUT) { snprintf(s->input, INPUTLEN, "%s", input); - _evry_update_text_label(s); + _evry_update_text_label(s); _evry_cb_update_timer(selector); evry_item_select(s, it); } @@ -1847,10 +1847,8 @@ _evry_matches_update(Evry_Selector *sel, int async) Eina_List *l; const char *input; - /* TODO cleanup plugins */ EINA_LIST_FREE(s->cur_plugins, p); - /* if (strlen(s->input) > 0) */ if (s->input[0]) input = s->input; else diff --git a/src/modules/everything/evry_plug_actions.c b/src/modules/everything/evry_plug_actions.c index 0a9d694f4..9c9dd8145 100644 --- a/src/modules/everything/evry_plug_actions.c +++ b/src/modules/everything/evry_plug_actions.c @@ -50,8 +50,9 @@ _begin(Evry_Plugin *p, const Evry_Item *it) { act->item1 = it; - if (act->type_out && act->intercept && !(act->intercept(act))) - continue;; + /* FIXME where is this used ?*/ + /* if (act->type_out && act->intercept && !(act->intercept(act))) + * continue;; */ sel->cur_actions = eina_list_append(sel->cur_actions, act); } @@ -109,7 +110,7 @@ _fetch(Evry_Plugin *p, const char *input) if (!input || match) { - it = evry_item_new(NULL, p, act->name, NULL); + it = evry_item_new(NULL, p, act->label, NULL); it->fuzzy_match = match; it->data = act; it->priority = act->priority; @@ -146,8 +147,8 @@ evry_plug_actions_new(int type) { Evry_Plugin *p; - p = evry_plugin_new(NULL, action_selector, type, "", "", 0, NULL, NULL, - _begin, _cleanup, _fetch, NULL, _icon_get, NULL); + p = evry_plugin_new(NULL, action_selector, _("Actions"), type, "", "", + _begin, _cleanup, _fetch, _icon_get, NULL); evry_plugin_register(p, 2); diff --git a/src/modules/everything/evry_plug_aggregator.c b/src/modules/everything/evry_plug_aggregator.c index 4de559bb1..1dbce8528 100644 --- a/src/modules/everything/evry_plug_aggregator.c +++ b/src/modules/everything/evry_plug_aggregator.c @@ -294,9 +294,11 @@ evry_plug_aggregator_new(Evry_Selector *selector) Plugin_Config *pc; p = E_NEW(Plugin, 1); - evry_plugin_new(EVRY_PLUGIN(p), "All", 0, "", "", 0, NULL, NULL, - NULL, _cleanup, _fetch, _action, _icon_get, _plugin_free); + EVRY_PLUGIN_NEW(EVRY_PLUGIN(p), "All", 0, "", "", + NULL, _cleanup, _fetch, _icon_get, _plugin_free); + EVRY_PLUGIN(p)->action = &_action; + pc = E_NEW(Plugin_Config, 1); pc->enabled = 1; pc->priority = -1; diff --git a/src/modules/everything/evry_plug_clipboard.c b/src/modules/everything/evry_plug_clipboard.c index d01fbc987..83f971b32 100644 --- a/src/modules/everything/evry_plug_clipboard.c +++ b/src/modules/everything/evry_plug_clipboard.c @@ -31,8 +31,8 @@ evry_plug_clipboard_init(void) if (!win) return EINA_FALSE; //FIXME: Icon name doesnt follow FDO Spec - act = evry_action_new("Copy to Clipboard", "TEXT", NULL, NULL, "everything-clipboard", - _action, _check_item, NULL, NULL, NULL, NULL); + act = EVRY_ACTION_NEW("Copy to Clipboard", "TEXT", NULL, "everything-clipboard", + _action, _check_item); evry_action_register(act, 10); diff --git a/src/modules/everything/evry_plug_view_help.c b/src/modules/everything/evry_plug_view_help.c index a86111325..aa5f76c2e 100644 --- a/src/modules/everything/evry_plug_view_help.c +++ b/src/modules/everything/evry_plug_view_help.c @@ -74,7 +74,7 @@ _view_create(Evry_View *v, const Evry_State *s, const Evas_Object *swallow) "<ctrl+left/right>" "cycle through plugins
" "<ctrl+1> " - "choose a different view (e.g. for images)
"; + "choose a different view (e.g. for images)
"; if (v->active) return v; diff --git a/src/modules/everything/evry_plug_view_thumb.c b/src/modules/everything/evry_plug_view_thumb.c index dd1d40239..690e4c29c 100644 --- a/src/modules/everything/evry_plug_view_thumb.c +++ b/src/modules/everything/evry_plug_view_thumb.c @@ -6,8 +6,8 @@ typedef struct _View View; typedef struct _Smart_Data Smart_Data; typedef struct _Item Item; -#define SIZE_LIST 30 -#define SIZE_DETAIL 38 +#define SIZE_LIST 28 +#define SIZE_DETAIL 36 struct _View @@ -23,6 +23,7 @@ struct _View int iw, ih; int zoom; int mode; + int mode_prev; Eina_List *handlers; }; @@ -39,7 +40,6 @@ struct _Smart_Data Evas_Coord cx, cy, cw, ch; Evas_Coord sx, sy; Eina_Bool update : 1; - Eina_Bool switch_mode : 1; Eina_List *queue; Evas_Object *selector; @@ -284,19 +284,6 @@ _e_smart_reconfigure_do(void *data) changed = 1; } - if (sd->switch_mode) - { - if (changed) - evas_object_smart_callback_call(obj, "changed", NULL); - - sd->update = EINA_TRUE; - sd->switch_mode = EINA_FALSE; - - if (recursion == 0) - sd->idle_enter = NULL; - return 0; - } - if (sd->view->mode == VIEW_MODE_THUMB) { if (sd->w > sd->cw) ox = (sd->w - sd->cw) / 2; @@ -897,20 +884,24 @@ _view_update(Evry_View *view) Smart_Data *sd = evas_object_smart_data_get(v->span); Item *v_it; Evry_Item *p_it; - Eina_List *l, *ll, *p_items, *v_remove = NULL, *v_items = NULL; + Eina_List *l, *ll, *v_remove = NULL, *v_items = NULL; int pos, last_pos, last_vis = 0, first_vis = 0; Eina_Bool update = EINA_FALSE; - + Evry_Plugin *p = v->state->plugin; + sd->cur_item = NULL; - if (!v->state->plugin) + if (!p) { _view_clear(view); return 1; } - p_items = v->state->plugin->items; - + v->mode = v->mode_prev; + + if (p->view_mode >= 0) + v->mode = p->view_mode; + /* go through current view items */ EINA_LIST_FOREACH(sd->items, l, v_it) { @@ -919,7 +910,7 @@ _view_update(Evry_View *view) pos = 1; /* go through plugins current items */ - EINA_LIST_FOREACH(p_items, ll, p_it) + EINA_LIST_FOREACH(p->items, ll, p_it) { if (v_it->item == p_it) { @@ -976,7 +967,7 @@ _view_update(Evry_View *view) /* go through plugins current items */ pos = 1; - EINA_LIST_FOREACH(p_items, l, p_it) + EINA_LIST_FOREACH(p->items, l, p_it) { /* item is not already in view */ if (!eina_list_data_find_list(v_items, p_it)) @@ -1003,9 +994,9 @@ _view_update(Evry_View *view) sd->items = eina_list_sort(sd->items, eina_list_count(sd->items), _sort_cb); - if (update || !last_vis || v->plugin != v->state->plugin) + if (update || !last_vis || v->plugin != p) { - v->plugin = v->state->plugin; + v->plugin = p; sd->update = EINA_TRUE; _update_frame(v->span); @@ -1025,44 +1016,48 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) Smart_Data *sd = evas_object_smart_data_get(v->span); Eina_List *l = NULL, *ll; Item *it = NULL; - - if (!v->state->plugin) + const Evry_State *s = v->state; + + if (!s->plugin) return 0; - if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && - (!strcmp(ev->key, "2"))) + if (s->plugin->view_mode == VIEW_MODE_NONE) { - if (v->mode == VIEW_MODE_LIST) - v->mode = VIEW_MODE_DETAIL; - else - v->mode = VIEW_MODE_LIST; - - v->zoom = 0; - _clear_items(v->span); - _update_frame(v->span); - goto end; - } - else if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && - ((!strcmp(ev->key, "plus")) || - (!strcmp(ev->key, "3")))) - { - if (v->mode != VIEW_MODE_THUMB) + if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && + (!strcmp(ev->key, "2"))) { + if (v->mode == VIEW_MODE_LIST) + v->mode = VIEW_MODE_DETAIL; + else + v->mode = VIEW_MODE_LIST; + v->zoom = 0; - v->mode = VIEW_MODE_THUMB; _clear_items(v->span); + _update_frame(v->span); + goto end; } - else + else if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && + ((!strcmp(ev->key, "plus")) || + (!strcmp(ev->key, "3")))) { - v->zoom++; - if (v->zoom > 2) v->zoom = 0; - if (v->zoom == 2) - _clear_items(v->span); + if (v->mode != VIEW_MODE_THUMB) + { + v->zoom = 0; + v->mode = VIEW_MODE_THUMB; + _clear_items(v->span); + } + else + { + v->zoom++; + if (v->zoom > 2) v->zoom = 0; + if (v->zoom == 2) + _clear_items(v->span); + } + _update_frame(v->span); + goto end; } - _update_frame(v->span); - goto end; } - + if (v->tabs->key_down(v->tabs, ev)) { _view_update(view); @@ -1076,7 +1071,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) it = sd->items->data; _pan_item_select(v->span, it, 1); - evry_item_select(v->state, it->item); + evry_item_select(s, it->item); goto end; } else if ((ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) && @@ -1086,7 +1081,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) it = eina_list_last(sd->items)->data; _pan_item_select(v->span, it, 1); - evry_item_select(v->state, it->item); + evry_item_select(s, it->item); goto end; } @@ -1103,7 +1098,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) if (it) { _pan_item_select(v->span, it, 1); - evry_item_select(v->state, it->item); + evry_item_select(s, it->item); } goto end; } @@ -1117,7 +1112,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) if (it) { _pan_item_select(v->span, it, 1); - evry_item_select(v->state, it->item); + evry_item_select(s, it->item); } goto end; } @@ -1142,7 +1137,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) if (it) { _pan_item_select(v->span, it, 1); - evry_item_select(v->state, it->item); + evry_item_select(s, it->item); } goto end; } @@ -1168,7 +1163,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) if (it) { _pan_item_select(v->span, it, 1); - evry_item_select(v->state, it->item); + evry_item_select(s, it->item); } goto end; } @@ -1245,7 +1240,8 @@ _view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow) v->mode = evry_conf->view_mode; else v->mode = parent->mode; - + v->mode_prev = v->mode; + v->zoom = parent->zoom; v->bg = edje_object_add(v->evas); @@ -1311,7 +1307,7 @@ view_thumb_init(void) v->view.update = &_view_update; v->view.clear = &_view_clear; v->view.cb_key_down = &_cb_key_down; - v->mode = -1; + v->mode = VIEW_MODE_NONE; evry_view_register(EVRY_VIEW(v), 1); diff --git a/src/modules/everything/evry_view_plugin_tabs.c b/src/modules/everything/evry_view_plugin_tabs.c index ee7bbc8bf..918cd6c7a 100644 --- a/src/modules/everything/evry_view_plugin_tabs.c +++ b/src/modules/everything/evry_view_plugin_tabs.c @@ -88,7 +88,7 @@ _tabs_update(Tab_View *v) o = edje_object_add(v->evas); e_theme_edje_object_set(o, "base/theme/everything", "e/modules/everything/tab_item"); - edje_object_part_text_set(o, "e.text.label", p->name); + edje_object_part_text_set(o, "e.text.label", p->label); tab->o_tab = o; @@ -184,7 +184,7 @@ _plugin_next_by_name(Tab_View *v, const char *key) EINA_LIST_FOREACH(s->cur_plugins, l, p) { - if (p->name && (!strncasecmp(p->name, key, 1))) + if (p->label && (!strncasecmp(p->label, key, 1))) { if (!first) first = p;