forked from enlightenment/enlightenment
'everything' add missing files, clean shutdown of modules
SVN revision: 47903
This commit is contained in:
parent
d9be7c9c5a
commit
31ab8c471e
|
@ -870,9 +870,6 @@ module_shutdown(void)
|
|||
evry_action_free(act3);
|
||||
evry_action_free(act4);
|
||||
evry_action_free(act5);
|
||||
|
||||
E_CONFIG_DD_FREE(exelist_edd);
|
||||
E_CONFIG_DD_FREE(exelist_exe_edd);
|
||||
}
|
||||
|
||||
/* taken from e_exebuf.c */
|
||||
|
@ -1026,6 +1023,9 @@ e_modapi_shutdown(E_Module *m)
|
|||
if (active && e_datastore_get("everything_loaded"))
|
||||
module_shutdown();
|
||||
|
||||
E_CONFIG_DD_FREE(exelist_edd);
|
||||
E_CONFIG_DD_FREE(exelist_exe_edd);
|
||||
|
||||
module = NULL;
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -242,11 +242,6 @@ module_init(void)
|
|||
static void
|
||||
module_shutdown(void)
|
||||
{
|
||||
char *result;
|
||||
|
||||
EINA_LIST_FREE(history, result)
|
||||
eina_stringshare_del(result);
|
||||
|
||||
EVRY_PLUGIN_FREE(p1);
|
||||
}
|
||||
|
||||
|
@ -283,9 +278,14 @@ e_modapi_init(E_Module *m)
|
|||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
char *result;
|
||||
|
||||
if (active && e_datastore_get("everything_loaded"))
|
||||
module_shutdown();
|
||||
|
||||
EINA_LIST_FREE(history, result)
|
||||
eina_stringshare_del(result);
|
||||
|
||||
module = NULL;
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -510,8 +510,6 @@ module_init(void)
|
|||
"system-run",
|
||||
_open_term_action, NULL, NULL, NULL, NULL);
|
||||
evry_action_register(act2, 2);
|
||||
|
||||
mime_folder = eina_stringshare_add("inode/directory");
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -522,8 +520,6 @@ module_shutdown(void)
|
|||
EVRY_PLUGIN_FREE(p1);
|
||||
EVRY_PLUGIN_FREE(p2);
|
||||
|
||||
eina_stringshare_del(mime_folder);
|
||||
|
||||
evry_action_free(act1);
|
||||
evry_action_free(act2);
|
||||
}
|
||||
|
@ -551,9 +547,11 @@ e_modapi_init(E_Module *m)
|
|||
|
||||
if (e_datastore_get("everything_loaded"))
|
||||
active = module_init();
|
||||
|
||||
mime_folder = eina_stringshare_add("inode/directory");
|
||||
|
||||
e_module_delayed_set(m, 1);
|
||||
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@ -563,6 +561,8 @@ e_modapi_shutdown(E_Module *m)
|
|||
if (active && e_datastore_get("everything_loaded"))
|
||||
module_shutdown();
|
||||
|
||||
eina_stringshare_del(mime_folder);
|
||||
|
||||
module = NULL;
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -496,7 +496,6 @@ module_init(void)
|
|||
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, NULL);
|
||||
evry_plugin_register(plugin2, 1);
|
||||
inst = E_NEW(Inst, 1);
|
||||
|
||||
act = evry_action_new("Open File...", "BORDER", "FILE", "APPLICATION",
|
||||
"everything-launch",
|
||||
|
@ -512,8 +511,7 @@ module_shutdown(void)
|
|||
{
|
||||
EVRY_PLUGIN_FREE(plugin);
|
||||
EVRY_PLUGIN_FREE(plugin2);
|
||||
E_FREE(inst);
|
||||
|
||||
|
||||
evry_action_free(act);
|
||||
}
|
||||
|
||||
|
@ -543,6 +541,8 @@ e_modapi_init(E_Module *m)
|
|||
|
||||
e_module_delayed_set(m, 1);
|
||||
|
||||
inst = E_NEW(Inst, 1);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@ -552,6 +552,8 @@ e_modapi_shutdown(E_Module *m)
|
|||
if (active && e_datastore_get("everything_loaded"))
|
||||
module_shutdown();
|
||||
|
||||
E_FREE(inst);
|
||||
|
||||
module = NULL;
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -118,6 +118,8 @@ EAPI int
|
|||
e_modapi_shutdown(E_Module *m __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
Evry_Plugin *p;
|
||||
Evry_Action *act;
|
||||
|
||||
evry_shutdown();
|
||||
|
||||
|
@ -139,7 +141,12 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
|||
view_help_shutdown();
|
||||
evry_plug_clipboard_shutdown();
|
||||
|
||||
|
||||
EINA_LIST_FREE(evry_conf->plugins, p)
|
||||
evry_plugin_free(p, 1);
|
||||
|
||||
EINA_LIST_FREE(evry_conf->actions, act)
|
||||
evry_action_free(act);
|
||||
|
||||
while ((cfd = e_config_dialog_get("E", "_config_everything_dialog")))
|
||||
e_object_del(E_OBJECT(cfd));
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
#include "Evry.h"
|
||||
|
||||
|
||||
static Evry_Action *act;
|
||||
static Ecore_X_Window clipboard_win = 0;
|
||||
|
||||
static int
|
||||
_action(Evry_Action *act)
|
||||
{
|
||||
const Evry_Item *it = act->item1;
|
||||
|
||||
ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label));
|
||||
ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_check_item(Evry_Action *act __UNUSED__, const Evry_Item *it)
|
||||
{
|
||||
return (it && it->label && (strlen(it->label) > 0));
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
evry_plug_clipboard_init(void)
|
||||
{
|
||||
if (!evry_api_version_check(EVRY_API_VERSION))
|
||||
return EINA_FALSE;
|
||||
|
||||
Ecore_X_Window win = ecore_x_window_new(0, 0, 0, 1, 1);
|
||||
if (!win) return EINA_FALSE;
|
||||
|
||||
act = evry_action_new("Copy to Clipboard", "TEXT", NULL, NULL, "edit-copy",
|
||||
_action, _check_item, NULL, NULL, NULL);
|
||||
|
||||
evry_action_register(act, 10);
|
||||
|
||||
clipboard_win = win;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
evry_plug_clipboard_shutdown(void)
|
||||
{
|
||||
ecore_x_window_free(clipboard_win);
|
||||
evry_action_free(act);
|
||||
}
|
||||
|
|
@ -0,0 +1,262 @@
|
|||
#include "Evry.h"
|
||||
|
||||
typedef struct _Image_View Image_View;
|
||||
|
||||
|
||||
struct _Image_View
|
||||
{
|
||||
Evry_View view;
|
||||
Evas *evas;
|
||||
|
||||
const Evry_State *state;
|
||||
|
||||
Evas_Object *o_main;
|
||||
|
||||
Eina_List *items;
|
||||
Evas_Object *o_thumb[4];
|
||||
};
|
||||
|
||||
|
||||
static Evry_View *view = NULL;
|
||||
static const char *view_types = NULL;
|
||||
|
||||
static int
|
||||
_check_item(const Evry_Item *it)
|
||||
{
|
||||
if (!it || it->plugin->type_out != view_types) return 0;
|
||||
|
||||
ITEM_FILE(file, it);
|
||||
|
||||
if (!file->path || !file->mime) return 0;
|
||||
|
||||
if (!strncmp(file->mime, "image/", 6))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_preview_thumb_gen(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Coord w, h;
|
||||
Image_View *v = data;
|
||||
|
||||
e_icon_size_get(v->o_thumb[1], &w, &h);
|
||||
edje_extern_object_min_size_set(v->o_thumb[1], w, h);
|
||||
edje_object_part_swallow(v->o_main, "e.swallow.icon2", v->o_thumb[1]);
|
||||
evas_object_show(v->o_thumb[1]);
|
||||
}
|
||||
|
||||
void
|
||||
_show_item(Image_View *v, const Evry_Item_File *file, int dir)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
if (v->o_thumb[1 + dir])
|
||||
{
|
||||
e_thumb_icon_end(v->o_thumb[1+dir]);
|
||||
edje_object_part_unswallow(v->o_main, v->o_thumb[1+dir]);
|
||||
evas_object_hide(v->o_thumb[1+dir]);
|
||||
evas_object_del(v->o_thumb[1+dir]);
|
||||
}
|
||||
|
||||
if (dir && v->o_thumb[1])
|
||||
{
|
||||
edje_object_part_unswallow(v->o_main, v->o_thumb[1]);
|
||||
|
||||
if (dir > 0)
|
||||
{
|
||||
v->o_thumb[2] = v->o_thumb[1];
|
||||
edje_object_part_swallow(v->o_main, "e.swallow.icon1", v->o_thumb[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
v->o_thumb[0] = v->o_thumb[1];
|
||||
edje_object_part_swallow(v->o_main, "e.swallow.icon3", v->o_thumb[0]);
|
||||
}
|
||||
}
|
||||
|
||||
v->o_thumb[1] = e_thumb_icon_add(v->evas);
|
||||
e_thumb_icon_file_set(v->o_thumb[1], file->path, NULL);
|
||||
evas_object_smart_callback_add(v->o_thumb[1], "e_thumb_gen", _cb_preview_thumb_gen, v);
|
||||
edje_object_part_geometry_get(v->o_main, "e.swallow.icon2", NULL, NULL, &w, &h);
|
||||
e_thumb_icon_size_set(v->o_thumb[1], w, h);
|
||||
e_thumb_icon_begin(v->o_thumb[1]);
|
||||
|
||||
if (dir)
|
||||
{
|
||||
if (dir > 0)
|
||||
edje_object_signal_emit(v->o_main, "e,signal,slide_left", "e");
|
||||
else
|
||||
edje_object_signal_emit(v->o_main, "e,signal,slide_right", "e");
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_key_down(Evry_View *view, const Ecore_Event_Key *ev)
|
||||
{
|
||||
Image_View *v = (Image_View *) view;
|
||||
|
||||
Eina_List *l;
|
||||
Evry_Item_File *file = NULL;
|
||||
|
||||
ITEM_FILE(cur_item, v->state->cur_item);
|
||||
|
||||
if (!strcmp(ev->key, "Down"))
|
||||
{
|
||||
if (!v->items) return 1;
|
||||
|
||||
l = eina_list_data_find_list(v->items, cur_item);
|
||||
|
||||
if (l && l->next)
|
||||
file = l->next->data;
|
||||
else
|
||||
file = v->items->data;
|
||||
|
||||
if (file && (file != cur_item))
|
||||
{
|
||||
_show_item(v, file, 1);
|
||||
evry_item_select(v->state, EVRY_ITEM(file));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(ev->key, "Up"))
|
||||
{
|
||||
if (!v->items) return 1;
|
||||
|
||||
l = eina_list_data_find_list(v->items, cur_item);
|
||||
|
||||
if (l && l->prev)
|
||||
file = l->prev->data;
|
||||
else
|
||||
file = eina_list_last(v->items)->data;
|
||||
|
||||
if (file && (file != cur_item))
|
||||
{
|
||||
_show_item(v, file, -1);
|
||||
evry_item_select(v->state, EVRY_ITEM(file));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_view_clear(Evry_View *view)
|
||||
{
|
||||
Image_View *v = (Image_View *) view;
|
||||
|
||||
if (v->o_thumb[0]) evas_object_del(v->o_thumb[0]);
|
||||
v->o_thumb[0] = NULL;
|
||||
if (v->o_thumb[1]) evas_object_del(v->o_thumb[1]);
|
||||
v->o_thumb[1] = NULL;
|
||||
if (v->o_thumb[2]) evas_object_del(v->o_thumb[2]);
|
||||
v->o_thumb[2] = NULL;
|
||||
if (v->items) eina_list_free(v->items);
|
||||
v->items = NULL;
|
||||
}
|
||||
|
||||
static Eina_List *
|
||||
_get_list(const Evry_State *s)
|
||||
{
|
||||
Eina_List *l, *items = NULL;
|
||||
Evry_Item *it;
|
||||
|
||||
EINA_LIST_FOREACH(s->plugin->items, l, it)
|
||||
if (_check_item(it))
|
||||
items = eina_list_append(items, it);
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
static int
|
||||
_view_update(Evry_View *view)
|
||||
{
|
||||
Image_View *v = (Image_View *) view;
|
||||
Evry_Item_File *file;
|
||||
Evry_Item *selected = v->state->cur_item;
|
||||
|
||||
v->items = _get_list(v->state);
|
||||
if (!v->items) return 0;
|
||||
|
||||
file = eina_list_data_find(v->items, selected);
|
||||
if (!file)
|
||||
{
|
||||
file = v->items->data;
|
||||
evry_item_select(v->state, EVRY_ITEM(file));
|
||||
}
|
||||
|
||||
_show_item(v, file, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evry_View *
|
||||
_view_create(Evry_View *view, const Evry_State *s, const Evas_Object *swallow)
|
||||
{
|
||||
Image_View *v;
|
||||
int w, h, x, y;
|
||||
|
||||
if (!s->plugin)
|
||||
return NULL;
|
||||
|
||||
if (!_get_list(s))
|
||||
return NULL;
|
||||
|
||||
v = E_NEW(Image_View, 1);
|
||||
v->view = *view;
|
||||
v->state = s;
|
||||
v->evas = evas_object_evas_get(swallow);
|
||||
v->o_main = edje_object_add(v->evas);
|
||||
e_theme_edje_object_set(v->o_main, "base/theme/everything",
|
||||
"e/modules/everything/preview");
|
||||
|
||||
edje_object_part_geometry_get(swallow, "e.swallow.list", &x, &y, &w, &h);
|
||||
edje_extern_object_min_size_set(v->o_main, w * 3, 100);
|
||||
evas_object_resize(v->o_main, w * 3, h);
|
||||
|
||||
EVRY_VIEW(v)->o_list = v->o_main;
|
||||
|
||||
return EVRY_VIEW(v);
|
||||
}
|
||||
|
||||
static void
|
||||
_view_destroy(Evry_View *view)
|
||||
{
|
||||
Image_View *v = (Image_View *) view;
|
||||
|
||||
_view_clear(view);
|
||||
evas_object_del(v->o_main);
|
||||
|
||||
E_FREE(v);
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
view_preview_init(void)
|
||||
{
|
||||
if (!evry_api_version_check(EVRY_API_VERSION))
|
||||
return EINA_FALSE;
|
||||
|
||||
view = E_NEW(Evry_View, 1);
|
||||
view->id = view;
|
||||
view->name = "Image Viewer";
|
||||
view->create = &_view_create;
|
||||
view->destroy = &_view_destroy;
|
||||
view->update = &_view_update;
|
||||
view->clear = &_view_clear;
|
||||
view->cb_key_down = &_cb_key_down;
|
||||
evry_view_register(view, 3);
|
||||
|
||||
view_types = eina_stringshare_add("FILE");
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
view_preview_shutdown(void)
|
||||
{
|
||||
eina_stringshare_del(view_types);
|
||||
evry_view_unregister(view);
|
||||
E_FREE(view);
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
#include "Evry.h"
|
||||
|
||||
static Evry_View *view;
|
||||
static Evas_Object *o_text = NULL;
|
||||
|
||||
static void
|
||||
_view_clear(Evry_View *v)
|
||||
{
|
||||
v->active = 0;
|
||||
evas_object_del(v->o_list);
|
||||
evas_object_del(o_text);
|
||||
o_text = NULL;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_view_update(Evry_View *v)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_cb_key_down(Evry_View *v, const Ecore_Event_Key *ev)
|
||||
{
|
||||
Evas_Object *o;
|
||||
double align;
|
||||
int h;
|
||||
|
||||
if (!strcmp(ev->key, "Down"))
|
||||
{
|
||||
o = v->o_list;
|
||||
evas_object_geometry_get(o, NULL, NULL, NULL, &h);
|
||||
e_box_align_get(o, NULL, &align);
|
||||
|
||||
align = align - (double)10/(double)h;
|
||||
if (align < 0.0) align = 0.0;
|
||||
|
||||
e_box_align_set(v->o_list, 0.5, align);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(ev->key, "Up"))
|
||||
{
|
||||
o = v->o_list;
|
||||
evas_object_geometry_get(o, NULL, NULL, NULL, &h);
|
||||
e_box_align_get(o, NULL, &align);
|
||||
|
||||
align = align + (double)10/(double)h;
|
||||
if (align > 1.0) align = 1.0;
|
||||
|
||||
e_box_align_set(v->o_list, 0.5, align);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Evry_View *
|
||||
_view_create(Evry_View *v, const Evry_State *s, const Evas_Object *swallow)
|
||||
{
|
||||
Evas_Object *o;
|
||||
int mw, mh;
|
||||
|
||||
char *text =
|
||||
"<title><b>Welcome!</b></title>"
|
||||
"Ok, here comes the explanation of <hilight>everything</hilight>...<br>"
|
||||
"Just type a few letters of the thing you are looking for. <br>"
|
||||
"Use cursor <hilight><up/down></hilight> to choose from the list of things.<br>"
|
||||
"Press <hilight><tab></hilight> to select "
|
||||
"an action, then press <hilight><return></hilight>.<br>"
|
||||
/* "You might want to know <br>some mo keybinding to ease your experience though.<br>" */
|
||||
"<hilight><space><?></hilight> show this page<br>"
|
||||
"<hilight><ctrl+letter></hilight> jump to plugin beginning with 'letter'<br>"
|
||||
"<hilight><ctrl+left/right></hilight>"
|
||||
"cycle through plugins<br>"
|
||||
"<hilight><ctrl+1></hilight> "
|
||||
"choose a different view (e.g. for images)<br>";
|
||||
|
||||
if (v->active) return v;
|
||||
|
||||
o = e_box_add(evas_object_evas_get(swallow));
|
||||
e_box_orientation_set(o, 0);
|
||||
e_box_align_set(o, 0.5, 1.0);
|
||||
v->o_list = o;
|
||||
e_box_freeze(v->o_list);
|
||||
o = edje_object_add(evas_object_evas_get(swallow));
|
||||
e_theme_edje_object_set(o, "base/theme/widgets",
|
||||
"e/widgets/textblock");
|
||||
|
||||
edje_object_part_text_set(o, "e.textblock.text", text);
|
||||
e_box_pack_start(v->o_list, o);
|
||||
edje_object_size_min_calc(o, &mw, &mh);
|
||||
e_box_pack_options_set(o, 1, 0, 1, 0, 0.5, 0.5, mw, mh + 200, 999, 999);
|
||||
e_box_thaw(v->o_list);
|
||||
evas_object_show(o);
|
||||
o_text = o;
|
||||
|
||||
v->active = 1;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
_view_destroy(Evry_View *v)
|
||||
{
|
||||
v->active = 0;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
view_help_init(void)
|
||||
{
|
||||
if (!evry_api_version_check(EVRY_API_VERSION))
|
||||
return EINA_FALSE;
|
||||
|
||||
view = E_NEW(Evry_View, 1);
|
||||
view->id = view;
|
||||
view->name = "Help";
|
||||
view->create = &_view_create;
|
||||
view->destroy = &_view_destroy;
|
||||
view->update = &_view_update;
|
||||
view->clear = &_view_clear;
|
||||
view->cb_key_down = &_cb_key_down;
|
||||
view->trigger = "?";
|
||||
/* view->types = "NONE"; */
|
||||
evry_view_register(view, 2);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
view_help_shutdown(void)
|
||||
{
|
||||
evry_view_unregister(view);
|
||||
E_FREE(view);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue