'everything' module:

- restructured and rewrote most parts of core
- new gui


SVN revision: 41655
This commit is contained in:
Hannes Janetzek 2009-08-10 11:36:37 +00:00
parent 7dc51a07c9
commit 10b20c24e5
14 changed files with 3797 additions and 2179 deletions

File diff suppressed because it is too large Load Diff

View File

@ -85,6 +85,13 @@ evry_plug_aspell_la_LIBADD = @e_libs@
evry_plug_aspell_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_aspell_la_LIBTOOLFLAGS = --tag=disable-static
evry_plug_clipboarddir = $(pkgdir)
evry_plug_clipboard_LTLIBRARIES = evry_plug_clipboard.la
evry_plug_clipboard_la_SOURCES = evry_plug_clipboard.c
evry_plug_clipboard_la_LIBADD = @e_libs@
evry_plug_clipboard_la_LDFLAGS = -no-undefined -module -avoid-version
evry_plug_clipboard_la_LIBTOOLFLAGS = --tag=disable-static
uninstall:
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)

View File

@ -85,7 +85,10 @@ e_modapi_init(E_Module *m)
}
/* evry_conf->history = eina_hash_string_superfast_new(NULL); */
evry_conf->width = 380;
evry_conf->height = 235;
evry_conf->scroll_animate = 0;
/* conf_module = m; */
evry_init();
@ -107,8 +110,8 @@ e_modapi_init(E_Module *m)
maug = e_int_menus_menu_augmentation_add("main/1", _e_mod_menu_add, NULL, NULL, NULL);
e_configure_registry_category_add("advanced", 80, _("Advanced"), NULL, "preferences-advanced");
e_configure_registry_item_add("advanced/run_everything", 40, _("Run Everything"), NULL, "system-run", evry_config_dialog);
e_configure_registry_category_add("extensions", 80, _("Extensions"), NULL, "preferences-extensions");
e_configure_registry_item_add("extensions/run_everything", 40, _("Run Everything"), NULL, "system-run", evry_config_dialog);
e_module_delayed_set(m, 1);
@ -136,6 +139,8 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
evry_shutdown();
/* conf_module = NULL; */
eina_list_free(evry_conf->plugins);
eina_list_free(evry_conf->actions);
eina_module_list_unload(plugins);
eina_module_list_flush(plugins);
@ -144,8 +149,8 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
eina_module_shutdown();
while ((cfd = e_config_dialog_get("E", "_config_everything_dialog"))) e_object_del(E_OBJECT(cfd));
e_configure_registry_item_del("advanced/run_everything");
e_configure_registry_category_del("advanced");
e_configure_registry_item_del("extensions/run_everything");
e_configure_registry_category_del("extensions");
/* Clean EET */
E_CONFIG_DD_FREE(conf_item_edd);
@ -212,3 +217,73 @@ _e_mod_menu_add(void *data __UNUSED__, E_Menu *m)
e_util_menu_item_theme_icon_set(mi, "system-run");
e_menu_item_callback_set(mi, _e_mod_run_cb, NULL);
}
static int
_evry_cb_plugin_sort(const void *data1, const void *data2)
{
const Evry_Plugin *p1 = data1;
const Evry_Plugin *p2 = data2;
return p1->config->priority - p2->config->priority;
}
EAPI void
evry_plugin_register(Evry_Plugin *plugin)
{
Eina_List *l;
Plugin_Config *pc;
Eina_Bool found = 0;
evry_conf->plugins = eina_list_append(evry_conf->plugins, plugin);
EINA_LIST_FOREACH(evry_conf->plugins_conf, l, pc)
{
if (pc->name && plugin->name && !strcmp(pc->name, plugin->name))
{
found = 1;
break;
}
}
if (!found)
{
pc = E_NEW(Plugin_Config, 1);
pc->name = eina_stringshare_add(plugin->name);
pc->enabled = 1;
pc->priority = eina_list_count(evry_conf->plugins);
evry_conf->plugins_conf = eina_list_append(evry_conf->plugins_conf, pc);
}
/* if (plugin->trigger && !pc->trigger)
* pc->trigger = eina_stringshare_add(plugin->trigger); */
plugin->config = pc;
evry_conf->plugins = eina_list_sort(evry_conf->plugins,
eina_list_count(evry_conf->plugins),
_evry_cb_plugin_sort);
/* TODO sorting, initialization, etc */
}
EAPI void
evry_plugin_unregister(Evry_Plugin *plugin)
{
evry_conf->plugins = eina_list_remove(evry_conf->plugins, plugin);
/* cleanup */
}
EAPI void
evry_action_register(Evry_Action *action)
{
evry_conf->actions = eina_list_append(evry_conf->actions, action);
/* TODO sorting, initialization, etc */
}
EAPI void
evry_action_unregister(Evry_Action *action)
{
evry_conf->actions = eina_list_remove(evry_conf->actions, action);
/* cleanup */
}

View File

@ -45,6 +45,7 @@ struct _Config
/**/
Eina_List *plugins;
Eina_List *actions;
Eina_Hash *history;
};
@ -67,10 +68,14 @@ struct _Plugin_Config
struct _Evry_Item
{
Evry_Plugin *plugin;
const char *label;
const char *uri;
const char *mime;
Eina_Bool browseable;
/* these are only for internally use by plugins */
/* used e.g. as pointer for item data (Efreet_Desktop) or */
@ -80,13 +85,16 @@ struct _Evry_Item
/* not to be set by plugin! */
Evas_Object *o_icon;
Evas_Object *o_bg;
Evas_Object *o_bg;
};
struct _Evry_Plugin
{
const char *name;
const char *icon;
enum {type_subject, type_action, type_object } type;
const char *type_in;
const char *type_out;
@ -99,6 +107,8 @@ struct _Evry_Plugin
* e.g. borders, app history */
Eina_Bool need_query;
Eina_Bool browseable;
/* run when plugin is activated. */
int (*begin) (Evry_Plugin *p, Evry_Item *item);
@ -108,14 +118,14 @@ struct _Evry_Plugin
/* run before new query and when hiding 'everything' */
void (*cleanup) (Evry_Plugin *p);
/* TODO return icon */
void (*icon_get) (Evry_Plugin *p, Evry_Item *it, Evas *e);
Evas_Object *(*icon_get) (Evry_Plugin *p, Evry_Item *it, Evas *e);
/* provide more information for a candidate */
/* int (*candidate_info) (Evas *evas, Evry_Item *item); */
/* optional: default action for this plugins items */
int (*action) (Evry_Plugin *p, Evry_Item *item, const char *input);
Evry_Action *act;
/* optional: create list of items when shown (e.g. for sorting) */
void (*realize_items) (Evry_Plugin *p, Evas *e);
@ -124,6 +134,9 @@ struct _Evry_Plugin
Evas_Object *(*config_page) (void);
void (*config_apply) (void);
/* only for internal use by plugin */
void *private;
/* not to be set by plugin! */
Evas_Object *tab;
Plugin_Config *config;
@ -136,17 +149,20 @@ struct _Evry_Action
const char *type_in1;
const char *type_in2;
const char *type_out;
Evry_Item *thing1;
Evry_Item *thing2;
int (*action) (Evry_Action *act);
int (*action) (Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input);
int (*check_item) (Evry_Action *act, Evry_Item *it);
void (*icon_get) (Evry_Action *act, Evry_Item *it, Evas *e);
Evas_Object *(*icon_get) (Evry_Action *act, Evas *e);
/* use icon name from theme */
const char *icon;
void *priv;
Eina_Bool is_default;
/* only for internal use by plugin */
void *private;
/* not to be set by plugin! */
Evas_Object *o_icon;
@ -175,6 +191,10 @@ EAPI void evry_action_register(Evry_Action *act);
EAPI void evry_action_unregister(Evry_Action *act);
EAPI void evry_plugin_async_update(Evry_Plugin *plugin, int state);
EAPI void evry_clear_input(void);
EAPI Evry_Item *evry_item_new(Evry_Plugin *p, const char *label);
EAPI void evry_item_free(Evry_Item *it);
EAPI int evry_icon_theme_set(Evas_Object *obj, const char *icon);
extern Config *evry_conf;

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,9 @@ static void *_create_data (E_Config_Dialog *cfd);
static void _free_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static int _basic_apply_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create_widgets (E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
/* static int _subject = type_subject;
* static int _action = type_action;
* static int _object = type_object; */
struct _E_Config_Dialog_Data
@ -15,8 +18,13 @@ struct _E_Config_Dialog_Data
int scroll_animate;
Evas_Object *l_avail;
Evas_Object *l_subject;
Evas_Object *l_action;
Evas_Object *l_object;
Eina_List *p_subject;
Eina_List *p_action;
Eina_List *p_object;
};
@ -45,9 +53,20 @@ evry_config_dialog(E_Container *con, const char *params __UNUSED__)
static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
Eina_List *l;
Evry_Plugin *p;
cfdata->scroll_animate = evry_conf->scroll_animate;
cfdata->height = evry_conf->height;
cfdata->width = evry_conf->width;
EINA_LIST_FOREACH(evry_conf->plugins, l, p)
if (p->type == type_subject)
cfdata->p_subject = eina_list_append(cfdata->p_subject, p);
else if (p->type == type_action)
cfdata->p_action = eina_list_append(cfdata->p_action, p);
else if (p->type == type_object)
cfdata->p_object = eina_list_append(cfdata->p_object, p);
}
static void *
@ -63,9 +82,21 @@ _create_data(E_Config_Dialog *cfd __UNUSED__)
static void
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
eina_list_free(cfdata->p_subject);
eina_list_free(cfdata->p_action);
eina_list_free(cfdata->p_object);
E_FREE(cfdata);
}
static int
_evry_cb_plugin_sort(const void *data1, const void *data2)
{
const Evry_Plugin *p1 = data1;
const Evry_Plugin *p2 = data2;
return p1->config->priority - p2->config->priority;
}
static int
_basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
@ -73,12 +104,16 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
evry_conf->height = cfdata->height;
evry_conf->scroll_animate = cfdata->scroll_animate;
evry_conf->plugins = eina_list_sort(evry_conf->plugins,
eina_list_count(evry_conf->plugins),
_evry_cb_plugin_sort);
e_config_save_queue();
return 1;
}
static void
_fill_list(Evas_Object *obj, int enabled __UNUSED__)
_fill_list(Eina_List *plugins, Evas_Object *obj, int enabled __UNUSED__)
{
Evas *evas;
Evas_Coord w;
@ -92,7 +127,7 @@ _fill_list(Evas_Object *obj, int enabled __UNUSED__)
e_widget_ilist_freeze(obj);
e_widget_ilist_clear(obj);
EINA_LIST_FOREACH(evry_conf->plugins, l, p)
EINA_LIST_FOREACH(plugins, l, p)
e_widget_ilist_append(obj, NULL, p->name, NULL, p, NULL);
e_widget_ilist_go(obj);
@ -104,7 +139,7 @@ _fill_list(Evas_Object *obj, int enabled __UNUSED__)
}
static void
_plugin_move(Evas_Object *list, int dir)
_plugin_move(Eina_List *plugins, Evas_Object *list, int dir)
{
int sel;
Eina_List *l1, *l2;
@ -116,40 +151,32 @@ _plugin_move(Evas_Object *list, int dir)
Evry_Plugin *p;
int prio = 0;
l1 = eina_list_nth_list(evry_conf->plugins, sel);
l2 = eina_list_nth_list(evry_conf->plugins, sel + dir);
l1 = eina_list_nth_list(plugins, sel);
l2 = eina_list_nth_list(plugins, sel + dir);
if (!l1 || !l2) return;
p = l1->data;
l1->data = l2->data;
l2->data = p;
_fill_list(list, 0);
_fill_list(plugins, list, 0);
e_widget_ilist_selected_set(list, sel + dir);
EINA_LIST_FOREACH(evry_conf->plugins, l1, p)
EINA_LIST_FOREACH(plugins, l1, p)
p->config->priority = prio++;
}
}
static void
_plugin_move_up_cb(void *data, void *data2 __UNUSED__)
_plugin_move_up_cb(void *data, void *data2)
{
E_Config_Dialog_Data *cfdata;
cfdata = data;
_plugin_move(cfdata->l_avail, -1);
_plugin_move(data2, data, -1);
}
static void
_plugin_move_down_cb(void *data, void *data2 __UNUSED__)
_plugin_move_down_cb(void *data, void *data2)
{
E_Config_Dialog_Data *cfdata;
cfdata = data;
_plugin_move(cfdata->l_avail, 1);
_plugin_move(data2, data, 1);
}
static Evas_Object *
@ -164,36 +191,84 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dial
of = e_widget_framelist_add(evas, _("General Settings"), 0);
ob = e_widget_label_add(evas, _("Popup Width"));
e_widget_framelist_object_append(of, ob);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 300, 800, 5, 0, NULL, &(cfdata->width), 200);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"),
300, 800, 5, 0, NULL,
&(cfdata->width), 200);
e_widget_framelist_object_append(of, ob);
ob = e_widget_label_add(evas, _("Popup Height"));
e_widget_framelist_object_append(of, ob);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 200, 800, 5, 0, NULL, &(cfdata->height), 200);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"),
200, 800, 5, 0, NULL,
&(cfdata->height), 200);
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_framelist_add(evas, _("Scroll Settings"), 0);
ob = e_widget_check_add(evas, _("Scroll Animate"), &(cfdata->scroll_animate));
ob = e_widget_check_add(evas, _("Scroll Animate"),
&(cfdata->scroll_animate));
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
e_widget_toolbook_page_append(otb, NULL, _("General Settings"), o, 0, 0, 0, 0, 0.5, 0.0);
e_widget_toolbook_page_show(otb, 0);
e_widget_toolbook_page_append(otb, NULL, _("General Settings"),
o, 0, 0, 0, 0, 0.5, 0.0);
of = e_widget_framelist_add(evas, _("Available Plugins"), 0);
ob = e_widget_list_add(evas, 1, 1);
of = e_widget_framelist_add(evas, _("Subject Plugins"), 0);
o = e_widget_ilist_add(evas, 24, 24, NULL);
cfdata->l_avail = o;
/* e_widget_ilist_multi_select_set(ol, 1); */
cfdata->l_subject = o;
/* e_widget_on_change_hook_set(ol, _avail_list_cb_change, cfdata); */
_fill_list(o, 0);
_fill_list(cfdata->p_subject, o, 0);
e_widget_framelist_object_append(of, o);
o = e_widget_button_add(evas, _("Move Up"), NULL, _plugin_move_up_cb, cfdata, NULL);
o = e_widget_button_add(evas, _("Move Up"), NULL,
_plugin_move_up_cb,
cfdata->l_subject,
cfdata->p_subject);
e_widget_framelist_object_append(of, o);
o = e_widget_button_add(evas, _("Move Down"), NULL, _plugin_move_down_cb, cfdata, NULL);
o = e_widget_button_add(evas, _("Move Down"), NULL,
_plugin_move_down_cb,
cfdata->l_subject,
cfdata->p_subject);
e_widget_framelist_object_append(of, o);
e_widget_list_object_append(ob, of, 1, 1, 0.5);
e_widget_toolbook_page_append(otb, NULL, _("Plugins"), of, 0, 0, 0, 0, 0.5, 0.0);
of = e_widget_framelist_add(evas, _("Action Plugins"), 0);
o = e_widget_ilist_add(evas, 24, 24, NULL);
cfdata->l_action = o;
_fill_list(cfdata->p_action, o, 0);
e_widget_framelist_object_append(of, o);
o = e_widget_button_add(evas, _("Move Up"), NULL,
_plugin_move_up_cb,
cfdata->l_action,
cfdata->p_action);
e_widget_framelist_object_append(of, o);
o = e_widget_button_add(evas, _("Move Down"), NULL,
_plugin_move_down_cb,
cfdata->l_action,
cfdata->p_action);
e_widget_framelist_object_append(of, o);
e_widget_list_object_append(ob, of, 1, 1, 0.5);
of = e_widget_framelist_add(evas, _("Object Plugins"), 0);
o = e_widget_ilist_add(evas, 24, 24, NULL);
cfdata->l_object = o;
_fill_list(cfdata->p_object, o, 0);
e_widget_framelist_object_append(of, o);
o = e_widget_button_add(evas, _("Move Up"), NULL,
_plugin_move_up_cb,
cfdata->l_object,
cfdata->p_object);
e_widget_framelist_object_append(of, o);
o = e_widget_button_add(evas, _("Move Down"), NULL,
_plugin_move_down_cb,
cfdata->l_object,
cfdata->p_object);
e_widget_framelist_object_append(of, o);
e_widget_list_object_append(ob, of, 1, 1, 0.5);
e_widget_toolbook_page_append(otb, NULL, _("Plugins"),
ob, 0, 0, 0, 0, 0.5, 0.0);
e_widget_toolbook_page_show(otb, 1);
return otb;
}

View File

@ -16,44 +16,44 @@ static int _action(Evry_Plugin *p, Evry_Item *item, const char *input);
static void _cleanup(Evry_Plugin *p);
static void _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio);
static int _cb_sort(const void *data1, const void *data2);
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static int _exec_app_action(Evry_Action *act);
static Evas_Object *_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static int _exec_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input);
static int _exec_app_check_item(Evry_Action *act, Evry_Item *it);
static int _edit_app_action(Evry_Action *act);
static int _edit_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input);
static int _edit_app_check_item(Evry_Action *act, Evry_Item *it);
static int _new_app_action(Evry_Action *act);
static int _new_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input);
static int _new_app_check_item(Evry_Action *act, Evry_Item *it);
static Eina_Bool _init(void);
static void _shutdown(void);
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);
static Evry_Plugin *p1;
static Evry_Plugin *p2;
static Evry_Action *act;
static Evry_Action *act1;
static Evry_Action *act2;
static Evry_Action *act3;
static Inst *inst;
/* static Inst *inst = NULL; */
static Eina_List *exe_path = NULL;
static Eina_Bool
_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->need_query = 0;
p1->begin = &_begin;
p1->fetch = &_fetch;
p1->action = &_action;
/* p1->action = &_action; */
p1->cleanup = &_cleanup;
p1->icon_get = &_item_icon_get;
evry_plugin_register(p1);
p2 = E_NEW(Evry_Plugin, 1);
p2->name = "Open With...";
p2->type = type_action;
p2->type_in = "FILE";
p2->type_out = "NONE";
p2->need_query = 0;
@ -65,54 +65,91 @@ _init(void)
evry_plugin_register(p2);
act = E_NEW(Evry_Action, 1);
act->name = "Open File...";
act->name = "Launch";
act->is_default = EINA_TRUE;
act->type_in1 = "APPLICATION";
act->type_in2 = "FILE";
act->type_out = "NONE";
act->action = &_exec_app_action;
act->check_item = &_exec_app_check_item;
act->icon = "everything-launch";
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 = "everything-launch";
evry_action_register(act1);
act2 = E_NEW(Evry_Action, 1);
act2->name = "Edit Application Entry";
act2->type_in1 = "APPLICATION";
act2->type_in2 = "NONE";
act2->type_out = "NONE";
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->type_in2 = "NONE";
act3->type_out = "NONE";
act3->action = &_new_app_action;
act3->check_item = &_new_app_check_item;
act3->icon = "everything-launch";
evry_action_register(act3);
inst = NULL;
/* taken from e_exebuf.c */
path = getenv("PATH");
if (path)
{
path = strdup(path);
last = path;
for (p = path; p[0]; p++)
{
if (p[0] == ':') p[0] = '\0';
if (p[0] == 0)
{
exe_path = eina_list_append(exe_path, strdup(last));
last = p + 1;
}
}
if (p > last)
exe_path = eina_list_append(exe_path, strdup(last));
free(path);
}
return 1;
}
static void
_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);
EINA_LIST_FREE(exe_path, str)
free(str);
}
static int
_begin(Evry_Plugin *p __UNUSED__, Evry_Item *it)
_begin(Evry_Plugin *p, Evry_Item *it)
{
const char *mime;
if (inst) return 0;
Inst *inst = NULL;
if (it)
{
if (!it->uri) return 0;
@ -127,8 +164,8 @@ _begin(Evry_Plugin *p __UNUSED__, Evry_Item *it)
inst = E_NEW(Inst, 1);
inst->candidate = it;
inst->apps = efreet_util_desktop_mime_list(mime);
if (strcmp(mime, "Folder"))
inst->apps = efreet_util_desktop_mime_list(mime);
if (!inst->apps)
{
Efreet_Desktop *desktop;
@ -137,22 +174,21 @@ _begin(Evry_Plugin *p __UNUSED__, Evry_Item *it)
inst->apps = eina_list_append(inst->apps, desktop);
}
}
else
{
inst = E_NEW(Inst, 1);
}
p->private = inst;
return 1;
}
static int
_action(Evry_Plugin *p __UNUSED__, Evry_Item *it, const char *input)
_action(Evry_Plugin *p, Evry_Item *it, const char *input)
{
E_Zone *zone;
Evry_App *app = NULL;
Efreet_Desktop *desktop = NULL;
Eina_List *files = NULL;
Inst *inst = p->private;
if (it) app = it->data[0];
if (app && app->desktop)
@ -187,10 +223,16 @@ _action(Evry_Plugin *p __UNUSED__, Evry_Item *it, const char *input)
zone = e_util_zone_current_get(e_manager_current_get());
e_exec(zone, desktop, NULL, files, "everything");
if (inst && inst->candidate && inst->candidate->mime)
e_exehist_mime_desktop_add(inst->candidate->mime, desktop);
if (app->desktop)
{
e_exec(zone, desktop, NULL, files, "everything");
if (inst && inst->candidate && inst->candidate->mime)
e_exehist_mime_desktop_add(inst->candidate->mime, desktop);
}
else
/* dont put custom commands in exec history.. */
e_exec(zone, desktop, NULL, files, NULL);
if (!it)
efreet_desktop_free(desktop);
@ -211,16 +253,18 @@ _list_free(Evry_Plugin *p)
EINA_LIST_FREE(p->items, it)
{
if (it->label) eina_stringshare_del(it->label);
app = it->data[0];
if (app->file) eina_stringshare_del(app->file);
E_FREE(app);
E_FREE(it);
evry_item_free(it);
}
}
static void
_cleanup(Evry_Plugin *p)
{
Inst *inst = p->private;
_list_free(p);
if (inst)
@ -229,7 +273,7 @@ _cleanup(Evry_Plugin *p)
E_FREE(inst);
}
inst = NULL;
p->private = NULL;
}
static int
@ -242,9 +286,19 @@ _fetch(Evry_Plugin *p, const char *input)
char match2[4096];
Evry_Item *it;
Evry_App *app;
Inst *inst = p->private;
if (!inst)
{
inst = E_NEW(Inst, 1);
p->private = inst;
}
_list_free(p);
snprintf(match1, sizeof(match1), "%s*", input);
snprintf(match2, sizeof(match2), "*%s*", input);
if (inst && inst->apps)
{
if (!input)
@ -254,9 +308,6 @@ _fetch(Evry_Plugin *p, const char *input)
}
else
{
snprintf(match1, sizeof(match1), "%s*", input);
snprintf(match2, sizeof(match2), "*%s*", input);
EINA_LIST_FOREACH(inst->apps, l, desktop)
{
if (e_util_glob_case_match(desktop->exec, match1))
@ -284,29 +335,31 @@ _fetch(Evry_Plugin *p, const char *input)
snprintf(match1, sizeof(match1), "%s*", input);
l = efreet_util_desktop_exec_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 1);
if (e_util_glob_match(ecore_file_file_get(desktop->exec), match2))
_item_add(p, desktop, NULL, 1);
l = efreet_util_desktop_name_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 3);
_item_add(p, desktop, NULL, 3);
snprintf(match1, sizeof(match1), "*%s*", input);
l = efreet_util_desktop_exec_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 2);
if (e_util_glob_match(ecore_file_file_get(desktop->exec), match1))
_item_add(p, desktop, NULL, 2);
l = efreet_util_desktop_name_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 4);
// TODO make these optional/configurable
l = efreet_util_desktop_generic_name_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 5);
/* l = efreet_util_desktop_generic_name_glob_list(match1);
* EINA_LIST_FREE(l, desktop)
* _item_add(p, desktop, NULL, 5); */
l = efreet_util_desktop_comment_glob_list(match1);
EINA_LIST_FREE(l, desktop)
_item_add(p, desktop, NULL, 5);
/* l = efreet_util_desktop_comment_glob_list(match1);
* EINA_LIST_FREE(l, desktop)
* _item_add(p, desktop, NULL, 5); */
}
else if (!p->items)
{
@ -322,15 +375,32 @@ _fetch(Evry_Plugin *p, const char *input)
inst->added = NULL;
}
it = E_NEW(Evry_Item, 1);
app = E_NEW(Evry_App, 1);
app->file = eina_stringshare_add(input);
app->desktop = NULL;
it->data[0] = app;
it->priority = 100;
it->label = eina_stringshare_add("Run Command");
p->items = eina_list_append(p->items, it);
if (input || p == p2) /* FIXME plugins is 'Open with'.. hackish */
{
int found = 0;
char *path;
EINA_LIST_FOREACH(exe_path, l, path)
{
snprintf(match1, 4096, "%s/%s", path, input);
if (ecore_file_exists(match1))
{
found = 1;
break;
}
}
if (found || p == p2)
{
snprintf(match1, 4096, "xterm -hold -e %s", input);
it = evry_item_new(p, "Run Command");
app = E_NEW(Evry_App, 1);
app->file = eina_stringshare_add(match1);
app->desktop = NULL;
it->data[0] = app;
it->priority = 100;
p->items = eina_list_append(p->items, it);
}
}
if (p->items)
{
p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
@ -346,7 +416,8 @@ _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio)
Evry_Item *it;
Evry_App *app;
Efreet_Desktop *desktop2;
Inst *inst = p->private;
if (desktop)
{
Eina_List *l;
@ -410,35 +481,38 @@ _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio)
file = NULL;
}
it = E_NEW(Evry_Item, 1);
if (desktop)
it = evry_item_new(p, desktop->name);
else
it = evry_item_new(p, file);
app = E_NEW(Evry_App, 1);
app->desktop = desktop;
app->file = file;
it->data[0] = app;
it->priority = prio;
if (desktop)
it->label = eina_stringshare_add(desktop->name);
else
it->label = eina_stringshare_add(file);
it->o_icon = NULL;
p->items = eina_list_append(p->items, it);
}
static void
static Evas_Object *
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
{
Evas_Object *o = NULL;
Evry_App *app = it->data[0];
if (app->desktop)
it->o_icon = e_util_desktop_icon_add(app->desktop, 24, e);
o = e_util_desktop_icon_add(app->desktop, 64, e);
if (!it->o_icon)
if (!o)
{
it->o_icon = edje_object_add(e);
/* e_util_icon_theme_set(it->o_icon, "system-run") */
e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/system-run");
/* o = edje_object_add(e); */
/* e_theme_edje_object_set(o, "base/theme/fileman", "e/icons/system-run"); */
o = e_icon_add(e);
evry_icon_theme_set(o, "system-run");
}
return o;
}
static int
@ -494,53 +568,58 @@ _exec_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it)
static int
_exec_app_action(Evry_Action *act)
_exec_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input)
{
if (act->thing1 && act->thing2)
E_Zone *zone;
Evry_App *app = NULL;
Efreet_Desktop *desktop = NULL;
Eina_List *files = NULL;
if (!it1 || !it1->data[0]) return 0;
app = it1->data[0];
if (app->desktop)
desktop = app->desktop;
else
{
E_Zone *zone;
Evry_App *app = NULL;
Efreet_Desktop *desktop = NULL;
Eina_List *files = NULL;
app = act->thing1->data[0];
if (app->desktop)
desktop = app->desktop;
desktop = efreet_desktop_empty_new("");
if (strchr(app->file, '%'))
desktop->exec = strdup(app->file);
else
{
desktop = efreet_desktop_empty_new("");
if (strchr(app->file, '%'))
desktop->exec = strdup(app->file);
else
{
int len = strlen(app->file) + 4;
desktop->exec = malloc(len);
if (desktop->exec)
snprintf(desktop->exec, len, "%s %%U", app->file);
}
int len = strlen(app->file) + 4;
desktop->exec = malloc(len);
if (desktop->exec)
snprintf(desktop->exec, len, "%s %%U", app->file);
}
}
if (desktop)
if (desktop)
{
if (it2 && it2->uri)
files = eina_list_append(files, it2->uri);
zone = e_util_zone_current_get(e_manager_current_get());
if (app->desktop)
{
files = eina_list_append(files, act->thing2->uri);
zone = e_util_zone_current_get(e_manager_current_get());
e_exec(zone, desktop, NULL, files, "everything");
if (act->thing2->mime)
e_exehist_mime_desktop_add(act->thing2->mime, desktop);
if (!app->desktop)
efreet_desktop_free(desktop);
eina_list_free(files);
return EVRY_ACTION_FINISHED;
if (it2 && it2->mime)
e_exehist_mime_desktop_add(it2->mime, desktop);
}
else
/* dont put custom commands in exec history.. */
e_exec(zone, desktop, NULL, files, NULL);
if (!app->desktop)
efreet_desktop_free(desktop);
return EVRY_ACTION_CONTINUE;
if (files)
eina_list_free(files);
return 1;
}
return 0;
@ -558,33 +637,29 @@ _edit_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it)
static int
_edit_app_action(Evry_Action *act)
_edit_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input)
{
if (act->thing1)
{
Evry_Item *it = act->thing1;
Evry_App *app = it->data[0];
Efreet_Desktop *desktop;
if (app->desktop)
desktop = app->desktop;
else
{
char buf[128];
snprintf(buf, 128, "%s/.local/share/applications/%s.desktop", e_user_homedir_get(), app->file);
desktop = efreet_desktop_empty_new(eina_stringshare_add(buf));
/* XXX check if this gets freed by efreet*/
desktop->exec = strdup(app->file);
}
Evry_App *app;
Efreet_Desktop *desktop;
e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop);
return 1;
if (!it1) return 0;
app = it1->data[0];
if (app->desktop)
desktop = app->desktop;
else
{
char buf[128];
snprintf(buf, 128, "%s/.local/share/applications/%s.desktop", e_user_homedir_get(), app->file);
desktop = efreet_desktop_empty_new(eina_stringshare_add(buf));
/* XXX check if this gets freed by efreet*/
desktop->exec = strdup(app->file);
}
return 0;
e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop);
return 1;
}
@ -603,62 +678,62 @@ _new_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it)
static int
_new_app_action(Evry_Action *act)
_new_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input)
{
if (act->thing1)
Evry_App *app;
char *name;
char buf[4096];
char *end;
Efreet_Desktop *desktop;
int i;
if (!it1) return 0;
app = it1->data[0];
if (app->desktop)
name = strdup(app->desktop->name);
else
/* TODO replace '/' and remove other special characters */
name = strdup(app->file);
if ((end = strchr(name, ' ')))
name[end - name] = '\0';
for (i = 0; i < 10; i++)
{
Evry_Item *it = act->thing1;
Evry_App *app = it->data[0];
char *name;
char buf[4096];
char *end;
Efreet_Desktop *desktop;
int i;
if (app->desktop)
name = strdup(app->desktop->name);
else
/* TODO replace '/' and remove other special characters */
name = strdup(app->file);
if ((end = strchr(name, ' ')))
name[end - name] = '\0';
for (i = 0; i < 10; i++)
snprintf(buf, 4096, "%s/.local/share/applications/%s-%d.desktop", e_user_homedir_get(), name, i);
if (ecore_file_exists(buf))
{
snprintf(buf, 4096, "%s/.local/share/applications/%s-%d.desktop", e_user_homedir_get(), name, i);
if (ecore_file_exists(buf))
{
buf[0] = '\0';
continue;
}
else break;
buf[0] = '\0';
continue;
}
free(name);
if (strlen(buf) == 0)
return 0;
if (!app->desktop)
{
desktop = efreet_desktop_empty_new(buf);
desktop->exec = strdup(app->file);
}
else
{
efreet_desktop_save_as(app->desktop, buf);
/*XXX hackish - desktop is removed on save_as..*/
efreet_desktop_new(app->desktop->orig_path);
desktop = efreet_desktop_new(buf);
}
e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop);
return 1;
else break;
}
return 0;
free(name);
if (strlen(buf) == 0)
return 0;
if (!app->desktop)
{
desktop = efreet_desktop_empty_new(buf);
desktop->exec = strdup(app->file);
}
else
{
efreet_desktop_save_as(app->desktop, buf);
/*XXX hackish - desktop is removed on save_as..*/
efreet_desktop_new(app->desktop->orig_path);
desktop = efreet_desktop_new(buf);
}
e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop);
return 1;
}
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);

View File

@ -2,15 +2,8 @@
#include "e_mod_main.h"
#include <ctype.h>
static Eina_Bool _init(void);
static void _shutdown(void);
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);
static const char TRIGGER[] = "aspell ";
static const char LANG_MODIFIER[] = "lang=";
static Ecore_X_Window clipboard_win = 0;
typedef struct _Plugin Plugin;
@ -89,20 +82,13 @@ _item_add(Evry_Plugin *p, const char *word, int word_size, int prio)
{
Evry_Item *it;
it = E_NEW(Evry_Item, 1);
it = evry_item_new(p, NULL);
if (!it) return;
it->priority = prio;
it->label = eina_stringshare_add_length(word, word_size);
p->items = eina_list_append(p->items, it);
}
static void
_item_del(Evry_Item *it)
{
eina_stringshare_del(it->label);
E_FREE(it);
}
static void
_suggestions_add(Evry_Plugin *p, const char *line)
{
@ -143,7 +129,7 @@ _clear_list(Evry_Plugin *plugin)
Evry_Item *it;
evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_CLEAR);
EINA_LIST_FREE(plugin->items, it)
_item_del(it);
evry_item_free(it);
}
static int
@ -263,7 +249,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
else
lang = NULL;
eina_stringshare_del(p->lang);
if (p->lang) eina_stringshare_del(p->lang);
if (p->lang != lang)
{
p->lang = lang;
@ -288,7 +274,7 @@ _fetch(Evry_Plugin *plugin, const char *input)
if (len < 1)
return 1;
input = eina_stringshare_add_length(input, len);
eina_stringshare_del(p->input);
if (p->input) eina_stringshare_del(p->input);
if (p->input == input)
return 1;
@ -302,44 +288,44 @@ _fetch(Evry_Plugin *plugin, const char *input)
return 1;
}
static int
_action(Evry_Plugin *plugin, Evry_Item *it, const char *input __UNUSED__)
{
const char *label;
int len;
if (!it) return EVRY_ACTION_CONTINUE;
label = it->label;
len = eina_stringshare_strlen(label);
if (!ecore_x_selection_primary_set(clipboard_win, label, len))
fprintf(stderr, "ASPELL cannot set primary selection to %#x '%s'\n",
clipboard_win, label);
if (!ecore_x_selection_clipboard_set(clipboard_win, label, len))
fprintf(stderr, "ASPELL cannot set clipboard selection to %#x '%s'\n",
clipboard_win, label);
if (plugin->items)
{
Eina_List *l, *l_next;
Evry_Item *it2;
evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_CLEAR);
EINA_LIST_FOREACH_SAFE(plugin->items, l, l_next, it2)
{
if (it == it2) continue;
plugin->items = eina_list_remove_list(plugin->items, l);
eina_stringshare_del(it2->label);
E_FREE(it2);
}
}
evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_ADD);
return EVRY_ACTION_FINISHED;
}
/* static int
* _action(Evry_Plugin *plugin, Evry_Item *it, const char *input __UNUSED__)
* {
* const char *label;
* int len;
*
* if (!it) return EVRY_ACTION_CONTINUE;
*
* label = it->label;
* len = eina_stringshare_strlen(label);
*
* if (!ecore_x_selection_primary_set(clipboard_win, label, len))
* fprintf(stderr, "ASPELL cannot set primary selection to %#x '%s'\n",
* clipboard_win, label);
* if (!ecore_x_selection_clipboard_set(clipboard_win, label, len))
* fprintf(stderr, "ASPELL cannot set clipboard selection to %#x '%s'\n",
* clipboard_win, label);
*
* if (plugin->items)
* {
* Eina_List *l, *l_next;
* Evry_Item *it2;
*
* evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_CLEAR);
*
* EINA_LIST_FOREACH_SAFE(plugin->items, l, l_next, it2)
* {
* if (it == it2) continue;
* plugin->items = eina_list_remove_list(plugin->items, l);
* eina_stringshare_del(it2->label);
* E_FREE(it2);
* }
* }
*
* evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_ADD);
*
* return EVRY_ACTION_FINISHED;
* } */
static void
_cleanup(Evry_Plugin *plugin)
@ -348,7 +334,7 @@ _cleanup(Evry_Plugin *plugin)
Evry_Item *it;
EINA_LIST_FREE(p->base.items, it)
_item_del(it);
evry_item_free(it);
if (p->handler.data)
{
@ -377,12 +363,6 @@ _cleanup(Evry_Plugin *plugin)
}
}
static void
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e __UNUSED__)
{
it->o_icon = NULL;
}
static Eina_Bool
_init(void)
{
@ -393,22 +373,17 @@ _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 = "NONE";
p->base.type_out = "TEXT";
p->base.icon = "accessories-dictionary";
p->base.trigger = TRIGGER;
p->base.need_query = 0;
p->base.async_query = 1;
p->base.begin = _begin;
p->base.fetch = _fetch;
p->base.action = _action;
/* p->base.action = _action; */
p->base.cleanup = _cleanup;
p->base.icon_get = _item_icon_get;
if (clipboard_win == 0)
{
clipboard_win = ecore_x_window_new(0, 0, 0, 1, 1);
fprintf(stderr, "ASPELL clipboard_win=%#x\n", clipboard_win);
}
evry_plugin_register(&p->base);
@ -429,8 +404,11 @@ _shutdown(void)
_singleton = NULL;
EINA_LIST_FREE(p->base.items, it)
_item_del(it);
evry_item_free(it);
evry_plugin_unregister(&p->base);
E_FREE(p);
}
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);

View File

@ -2,11 +2,11 @@
#include "e_mod_main.h"
static int _fetch(Evry_Plugin *p, const char *input);
static int _action(Evry_Plugin *p, Evry_Item *item, const char *input);
/* static int _action(Evry_Plugin *p, Evry_Item *item, const char *input); */
static void _cleanup(Evry_Plugin *p);
static void _item_add(Evry_Plugin *p, E_Border *bd, int prio);
static int _cb_sort(const void *data1, const void *data2);
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static Evas_Object *_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static Eina_Bool _init(void);
static void _shutdown(void);
@ -21,11 +21,12 @@ _init(void)
{
p = E_NEW(Evry_Plugin, 1);
p->name = "Windows";
p->type = type_subject;
p->type_in = "NONE";
p->type_out = "BORDER";
p->need_query = 0;
p->fetch = &_fetch;
p->action = &_action;
/* p->action = &_action; */
p->cleanup = &_cleanup;
p->icon_get = &_item_icon_get;
evry_plugin_register(p);
@ -40,33 +41,6 @@ _shutdown(void)
E_FREE(p);
}
static int
_action(Evry_Plugin *p __UNUSED__, Evry_Item *it, const char *input __UNUSED__)
{
E_Border *bd;
E_Zone *zone;
if (!it) return EVRY_ACTION_CONTINUE;
bd = (E_Border *)it->data[0];
zone = e_util_zone_current_get(e_manager_current_get());
if (bd->desk != (e_desk_current_get(zone)))
e_desk_show(bd->desk);
if (bd->shaded)
e_border_unshade(bd, E_DIRECTION_UP);
if (bd->iconic)
e_border_uniconify(bd);
else
e_border_raise(bd);
/* e_border_focus_set(bd, 1, 1); */
e_border_focus_set_with_pointer(bd);
return EVRY_ACTION_FINISHED;
}
static void
_cleanup(Evry_Plugin *p)
@ -76,8 +50,7 @@ _cleanup(Evry_Plugin *p)
EINA_LIST_FREE(p->items, it)
{
/* if (it->data[0]) e_object_unref(E_OBJECT(it->data[0])); */
if (it->label) eina_stringshare_del(it->label);
E_FREE(it);
evry_item_free(it);
}
}
@ -133,10 +106,14 @@ _fetch(Evry_Plugin *p, const char *input)
return 0;
}
static void
static Evas_Object *
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
{
it->o_icon = e_border_icon_add(((E_Border *)it->data[0]), e);
Evas_Object *icon;
icon = e_border_icon_add(((E_Border *)it->data[0]), e);
return icon;
}
static void
@ -144,11 +121,11 @@ _item_add(Evry_Plugin *p, E_Border *bd, int prio)
{
Evry_Item *it;
it = E_NEW(Evry_Item, 1);
it = evry_item_new(p, e_border_name_get(bd));
/* e_object_ref(E_OBJECT(bd)); */
it->data[0] = bd;
it->priority = prio;
it->label = eina_stringshare_add(e_border_name_get(bd));
p->items = eina_list_append(p->items, it);
}

View File

@ -8,26 +8,192 @@ struct _Inst
E_Border *border;
};
static int _begin(Evry_Plugin *p, Evry_Item *item);
static int _fetch(Evry_Plugin *p, const char *input);
static int _action(Evry_Plugin *p, Evry_Item *item, const char *input);
static void _cleanup(Evry_Plugin *p);
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static void _item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon);
static Eina_Bool _init(void);
static void _shutdown(void);
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);
static Evry_Plugin *p;
static Inst *inst;
static void
_act_cb_border_switch_to(E_Border *bd)
{
E_Zone *zone;
zone = e_util_zone_current_get(e_manager_current_get());
if (bd->desk != (e_desk_current_get(zone)))
e_desk_show(bd->desk);
if (bd->shaded)
e_border_unshade(bd, E_DIRECTION_UP);
if (bd->iconic)
e_border_uniconify(bd);
else
e_border_raise(bd);
/* e_border_focus_set(bd, 1, 1); */
e_border_focus_set_with_pointer(bd);
}
static void
_act_cb_border_fullscreen(E_Border *bd)
{
if (!bd->fullscreen)
e_border_fullscreen(bd, E_FULLSCREEN_RESIZE);
else
e_border_unfullscreen(bd);
}
static void
_act_cb_border_close(E_Border *bd)
{
if (!bd->lock_close) e_border_act_close_begin(bd);
}
static void
_act_cb_border_minimize(E_Border *bd)
{
if (!bd->lock_user_iconify) e_border_iconify(bd);
}
static void
_act_cb_border_unminimize(E_Border *bd)
{
if (!bd->lock_user_iconify) e_border_uniconify(bd);
}
static int
_begin(Evry_Plugin *p __UNUSED__, Evry_Item *item)
{
E_Border *bd;
bd = item->data[0];
/* e_object_ref(E_OBJECT(bd)); */
inst->border = bd;
return 1;
}
static int
_cb_sort(const void *data1, const void *data2)
{
const Evry_Item *it1, *it2;
it1 = data1;
it2 = data2;
return (it1->priority - it2->priority);
}
static void
_item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon, char *m1, char *m2)
{
Evry_Item *it;
int prio = 1;
if (m1[0] && m2[0])
{
if (e_util_glob_case_match(label, m1))
prio = 1;
else if (e_util_glob_case_match(label, m2))
prio = 2;
else
prio = 0;
}
if (!prio) return;
it = evry_item_new(p, label);
it->data[0] = action_cb;
it->data[1] = (void *) eina_stringshare_add(icon);
it->priority = prio;
p->items = eina_list_prepend(p->items, it);
}
static void
_cleanup(Evry_Plugin *p)
{
Evry_Item *it;
EINA_LIST_FREE(p->items, it)
{
if (it->data[1]) eina_stringshare_del((const char *)it->data[1]);
evry_item_free(it);
}
}
static int
_fetch(Evry_Plugin *p, const char *input __UNUSED__)
{
char m1[128];
char m2[128];
_cleanup(p);
if (input)
{
snprintf(m1, sizeof(m1), "%s*", input);
snprintf(m2, sizeof(m2), "*%s*", input);
}
else
{
m1[0] = 0;
m2[0] = 0;
}
_item_add(p, _("Switch To"), _act_cb_border_switch_to, "go-next", m1, m2);
if (inst->border->iconic)
_item_add(p, _("Uniconify"), _act_cb_border_unminimize, "window-minimize", m1, m2);
else
_item_add(p, _("Iconify"), _act_cb_border_minimize, "window-minimize", m1, m2);
if (!inst->border->fullscreen)
_item_add(p, _("Fullscreen"), _act_cb_border_fullscreen, "view-fullscreen", m1, m2);
else
_item_add(p, _("Unfullscreen"), _act_cb_border_fullscreen, "view-restore", m1, m2);
_item_add(p, _("Close"), _act_cb_border_close, "window-close", m1, m2);
if (eina_list_count(p->items) > 0)
{
p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
return 1;
}
return 0;
}
static int
_action(Evry_Plugin *p __UNUSED__, Evry_Item *item, const char *input __UNUSED__)
{
void (*border_action) (E_Border *bd);
border_action = item->data[0];
border_action(inst->border);
return EVRY_ACTION_FINISHED;
}
static Evas_Object *
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
{
Evas_Object *o;
o = e_icon_add(e);
evry_icon_theme_set(o, (const char *)it->data[1]);
/* icon = edje_object_add(e);
* e_theme_edje_object_set(icon, "base/theme/borders", (const char *)it->data[1]); */
return o;
}
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->need_query = 0;
@ -52,97 +218,6 @@ _shutdown(void)
E_FREE(inst);
}
static void
_act_cb_border_fullscreen(E_Border *bd)
{
if (!bd->fullscreen)
e_border_fullscreen(bd, E_FULLSCREEN_RESIZE);
else
e_border_unfullscreen(bd);
}
static void
_act_cb_border_close(E_Border *bd)
{
if (!bd->lock_close) e_border_act_close_begin(bd);
}
static void
_act_cb_border_minimize(E_Border *bd)
{
if (!bd->lock_user_iconify) e_border_iconify(bd);
}
static int
_begin(Evry_Plugin *p __UNUSED__, Evry_Item *item)
{
E_Border *bd;
bd = item->data[0];
/* e_object_ref(E_OBJECT(bd)); */
inst->border = bd;
return 1;
}
static int
_fetch(Evry_Plugin *p, const char *input __UNUSED__)
{
_cleanup(p);
_item_add(p, _("Iconify"), _act_cb_border_minimize,
"e/widgets/border/default/minimize");
if (!inst->border->fullscreen)
_item_add(p, _("Fullscreen"), _act_cb_border_fullscreen,
"e/widgets/border/default/fullscreen");
else
_item_add(p, _("Unfullscreen"), _act_cb_border_fullscreen,
"e/widgets/border/default/fullscreen");
_item_add(p, _("Close"), _act_cb_border_close,
"e/widgets/border/default/close");
return 1;
}
static int
_action(Evry_Plugin *p __UNUSED__, Evry_Item *item, const char *input __UNUSED__)
{
void (*border_action) (E_Border *bd);
border_action = item->data[0];
border_action(inst->border);
return EVRY_ACTION_FINISHED;
}
static void
_cleanup(Evry_Plugin *p)
{
Evry_Item *it;
EINA_LIST_FREE(p->items, it)
{
if (it->data[1]) eina_stringshare_del(it->data[1]);
if (it->label) eina_stringshare_del(it->label);
E_FREE(it);
}
}
static void
_item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon)
{
Evry_Item *it;
it = E_NEW(Evry_Item, 1);
it->data[0] = action_cb;
it->data[1] = (void *) eina_stringshare_add(icon);
it->label = eina_stringshare_add(label);
p->items = eina_list_append(p->items, it);
}
static void
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
{
it->o_icon = edje_object_add(e);
e_theme_edje_object_set(it->o_icon, "base/theme/borders", (const char *)it->data[1]);
}
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);

View File

@ -10,63 +10,19 @@ static int _fetch(Evry_Plugin *p, const char *input);
static int _action(Evry_Plugin *p, Evry_Item *item, const char *input);
static void _cleanup(Evry_Plugin *p);
static void _item_add(Evry_Plugin *p, char *output, int prio);
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static int _cb_data(void *data, int type, void *event);
static int _cb_error(void *data, int type, void *event);
static int _cb_del(void *data, int type, void *event);
static Eina_Bool _init(void);
static void _shutdown(void);
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);
static Evry_Plugin *p;
static Ecore_Exe *exe = NULL;
static Eina_List *history = NULL;
static Ecore_Event_Handler *data_handler = NULL;
static Ecore_Event_Handler *error_handler = NULL;
static Ecore_Event_Handler *del_handler = NULL;
static Ecore_X_Window clipboard_win = 0;
static int error = 0;
static Eina_Bool
_init(void)
{
p = E_NEW(Evry_Plugin, 1);
p->name = "Calculator";
p->type_in = "NONE";
p->type_out = "NONE";
p->trigger = "=";
p->need_query = 0;
p->async_query = 1;
p->begin = &_begin;
p->fetch = &_fetch;
p->action = &_action;
p->cleanup = &_cleanup;
p->icon_get = &_item_icon_get;
evry_plugin_register(p);
clipboard_win = ecore_x_window_new(0, 0, 0, 1, 1);
return EINA_TRUE;
}
static void
_shutdown(void)
{
Evry_Item *it;
EINA_LIST_FREE(p->items, it)
{
if (it->label) eina_stringshare_del(it->label);
free(it);
}
evry_plugin_unregister(p);
E_FREE(p);
ecore_x_window_free(clipboard_win);
}
static int
_begin(Evry_Plugin *p, Evry_Item *it __UNUSED__)
@ -89,20 +45,12 @@ static void
_cleanup(Evry_Plugin *p)
{
Evry_Item *it;
int i = 0;
int items = 10;
EINA_LIST_FREE(p->items, it)
{
if (i < 10)
{
history = eina_list_append(history, it);
}
else
{
if (it->label) eina_stringshare_del(it->label);
free(it);
}
}
if (items-- > 0)
history = eina_list_append(history, it);
else evry_item_free(it);
ecore_event_handler_del(data_handler);
ecore_event_handler_del(error_handler);
@ -116,8 +64,7 @@ _cleanup(Evry_Plugin *p)
static int
_action(Evry_Plugin *p, Evry_Item *it, const char *input __UNUSED__)
{
if (!it) return EVRY_ACTION_CONTINUE;
/* if (!it) return EVRY_ACTION_CONTINUE; */
if (p->items)
{
Eina_List *l;
@ -140,7 +87,7 @@ _action(Evry_Plugin *p, Evry_Item *it, const char *input __UNUSED__)
if (it2)
{
p->items = eina_list_remove(p->items, it2);
eina_stringshare_del(it2->label);
if (it2->label) eina_stringshare_del(it2->label);
E_FREE(it2);
}
}
@ -150,10 +97,7 @@ _action(Evry_Plugin *p, Evry_Item *it, const char *input __UNUSED__)
_item_add(p, (char *) it->label, 1);
}
/* evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); */
ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label));
ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label));
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
return EVRY_ACTION_FINISHED;
}
@ -189,21 +133,13 @@ _fetch(Evry_Plugin *p, const char *input)
}
static void
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e __UNUSED__)
{
it->o_icon = NULL;
}
static void
_item_add(Evry_Plugin *p, char *output, int prio)
_item_add(Evry_Plugin *p, char *result, int prio)
{
Evry_Item *it;
it = E_NEW(Evry_Item, 1);
it->priority = prio;
it->label = eina_stringshare_add(output);
it = evry_item_new(p, result);
if (!it) return;
p->items = eina_list_prepend(p->items, it);
}
@ -260,3 +196,39 @@ _cb_del(void *data __UNUSED__, int type __UNUSED__, void *event)
return 1;
}
static Eina_Bool
_init(void)
{
p = E_NEW(Evry_Plugin, 1);
p->name = "Calculator";
p->type = type_subject;
p->type_in = "NONE";
p->type_out = "TEXT";
p->trigger = "=";
p->icon = "accessories-calculator";
p->need_query = 0;
p->async_query = 1;
p->begin = &_begin;
p->fetch = &_fetch;
p->action = &_action;
p->cleanup = &_cleanup;
evry_plugin_register(p);
return EINA_TRUE;
}
static void
_shutdown(void)
{
Evry_Item *it;
EINA_LIST_FREE(p->items, it)
evry_item_free(it);
evry_plugin_unregister(p);
E_FREE(p);
}
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);

View File

@ -1,91 +1,41 @@
#include "e.h"
#include "e_mod_main.h"
static int _fetch(Evry_Plugin *p, const char *input);
static int _action(Evry_Plugin *p, Evry_Item *item, const char *input);
static void _cleanup(Evry_Plugin *p);
static void _item_add(Evry_Plugin *p, E_Configure_It *eci, int prio);
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static int _cb_sort(const void *data1, const void *data2);
static Eina_Bool _init(void);
static void _shutdown(void);
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);
static Evry_Plugin *p;
static Evry_Action *act;
static Eina_Bool
_init(void)
{
p = E_NEW(Evry_Plugin, 1);
p->name = "Settings";
p->type_in = "NONE";
p->type_out = "NONE";
p->fetch = &_fetch;
p->action = &_action;
p->cleanup = &_cleanup;
p->icon_get = &_item_icon_get;
evry_plugin_register(p);
return EINA_TRUE;
}
static void
_shutdown(void)
{
evry_plugin_unregister(p);
E_FREE(p);
}
static int
_action(Evry_Plugin *p __UNUSED__, Evry_Item *it, const char *input __UNUSED__)
{
E_Configure_It *eci, *eci2;
E_Container *con;
E_Configure_Cat *ecat;
Eina_List *l, *ll;
char buf[1024];
int found = 0;
if (!it) return EVRY_ACTION_CONTINUE;
eci = it->data[0];
con = e_container_current_get(e_manager_current_get());
for (l = e_configure_registry; l && !found; l = l->next)
{
ecat = l->data;
for (ll = ecat->items; ll && !found; ll = ll->next)
{
eci2 = ll->data;
if (eci == eci2)
{
found = 1;
snprintf(buf, sizeof(buf), "%s/%s",
ecat->cat,
eci->item);
}
}
}
if (found)
e_configure_registry_call(buf, con, NULL);
return EVRY_ACTION_FINISHED;
}
static void
_cleanup(Evry_Plugin *p)
{
Evry_Item *it;
EINA_LIST_FREE(p->items, it)
{
if (it->label) eina_stringshare_del(it->label);
E_FREE(it);
}
evry_item_free(it);
}
static void
_item_add(Evry_Plugin *p, E_Configure_It *eci, int prio)
{
Evry_Item *it;
it = evry_item_new(p, eci->label);
it->data[0] = eci;
it->priority = prio;
p->items = eina_list_append(p->items, it);
}
static int
_cb_sort(const void *data1, const void *data2)
{
const Evry_Item *it1, *it2;
it1 = data1;
it2 = data2;
/* TODO sort by name? */
return (it1->priority - it2->priority);
}
static int
@ -134,48 +84,93 @@ _fetch(Evry_Plugin *p, const char *input)
return 0;
}
static void
static Evas_Object *
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
{
E_Configure_It *eci = it->data[0];
Evas_Object *o = NULL;
E_Configure_It *eci = it->data[0];
if (eci->icon)
{
o = e_icon_add(e);
if (!e_util_icon_theme_set(o, eci->icon))
if (!evry_icon_theme_set(o, eci->icon))
{
evas_object_del(o);
o = e_util_icon_add(eci->icon, e);
}
}
it->o_icon = o;
}
static void
_item_add(Evry_Plugin *p, E_Configure_It *eci, int prio)
{
Evry_Item *it;
it = E_NEW(Evry_Item, 1);
it->data[0] = eci;
it->priority = prio;
it->label = eina_stringshare_add(eci->label);
it->o_icon = NULL;
p->items = eina_list_append(p->items, it);
return o;
}
static int
_cb_sort(const void *data1, const void *data2)
_action(Evry_Action *act, Evry_Item *it, Evry_Item *it2 __UNUSED__, const char *input __UNUSED__)
{
const Evry_Item *it1, *it2;
E_Configure_It *eci, *eci2;
E_Container *con;
E_Configure_Cat *ecat;
Eina_List *l, *ll;
char buf[1024];
int found = 0;
it1 = data1;
it2 = data2;
eci = it->data[0];
con = e_container_current_get(e_manager_current_get());
/* TODO sort by name? */
for (l = e_configure_registry; l && !found; l = l->next)
{
ecat = l->data;
for (ll = ecat->items; ll && !found; ll = ll->next)
{
eci2 = ll->data;
if (eci == eci2)
{
found = 1;
snprintf(buf, sizeof(buf), "%s/%s",
ecat->cat,
eci->item);
}
}
}
return (it1->priority - it2->priority);
if (found)
e_configure_registry_call(buf, con, NULL);
return EVRY_ACTION_FINISHED;
}
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;
evry_plugin_register(p);
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;
}
static void
_shutdown(void)
{
evry_plugin_unregister(p);
evry_action_unregister(act);
E_FREE(p);
E_FREE(act);
}
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);

View File

@ -1,25 +1,29 @@
#include "e.h"
#include "e_mod_main.h"
#define MAX_ITEMS 100
typedef struct _State State;
struct _State
{
const char *directory;
/* all files of directory */
Eina_List *items;
/* current list of files */
Eina_List *cur;
int command;
};
static int _begin(Evry_Plugin *p, Evry_Item *it);
static int _fetch(Evry_Plugin *p, const char *input);
static int _action(Evry_Plugin *p, Evry_Item *it, const char *input);
static void _cleanup(Evry_Plugin *p);
static int _cb_sort(const void *data1, const void *data2);
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static void _list_free(Evry_Plugin *p);
static void _item_fill(Evry_Item *it, Evas *evas);
static Evas_Object *_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static void _item_fill(Evry_Item *it);
static Evry_Item *_item_add(const char *directory, const char *file);
static void _realize(Evry_Plugin *p, Evas *e);
static int _dirbrowse_idler(void *data);
static Eina_Bool _init(void);
static void _shutdown(void);
@ -27,26 +31,40 @@ EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);
static Evry_Plugin *p;
static Eina_List *stack = NULL;
static Evry_Plugin *p2;
static Ecore_Idler *idler = NULL;
static Eina_Bool
_init(void)
{
p = E_NEW(Evry_Plugin, 1);
p->name = "Browse Files";
p->name = "Files";
p->type = type_subject;
p->type_in = "NONE|FILE";
p->type_out = "FILE";
/* p->trigger = "/"; */
p->browseable = EINA_TRUE;
p->begin = &_begin;
p->fetch = &_fetch;
p->action = &_action;
p->cleanup = &_cleanup;
p->realize_items = &_realize;
p->icon_get = &_item_icon_get;
evry_plugin_register(p);
p2 = E_NEW(Evry_Plugin, 1);
p2->name = "Files";
p2->type = type_object;
p2->type_in = "NONE|FILE";
p2->type_out = "FILE";
p2->browseable = EINA_TRUE;
p2->begin = &_begin;
p2->fetch = &_fetch;
p2->cleanup = &_cleanup;
p2->realize_items = &_realize;
p2->icon_get = &_item_icon_get;
evry_plugin_register(p2);
return EINA_TRUE;
}
@ -54,13 +72,18 @@ static void
_shutdown(void)
{
evry_plugin_unregister(p);
evry_plugin_unregister(p2);
E_FREE(p);
E_FREE(p2);
}
static int
_begin(Evry_Plugin *p, Evry_Item *it)
{
State *s;
char *file;
Eina_List *files;
Eina_List *stack = p->private;
if (stack)
{
@ -75,60 +98,85 @@ _begin(Evry_Plugin *p, Evry_Item *it)
s = E_NEW(State, 1);
s->directory = eina_stringshare_add(it->uri);
p->items = NULL;
}
else
{
s = E_NEW(State, 1);
s->directory = eina_stringshare_add(e_user_homedir_get());
p->items = NULL;
}
files = ecore_file_ls(s->directory);
stack = eina_list_prepend(stack, s);
p->items = NULL;
return 1;
}
static int
_action(Evry_Plugin *p __UNUSED__, Evry_Item *it __UNUSED__, const char *input __UNUSED__)
{
return EVRY_ACTION_OTHER;
}
static void
_list_free(Evry_Plugin *p)
{
Evry_Item *it;
EINA_LIST_FREE(p->items, it)
EINA_LIST_FREE(files, file)
{
if (it->label) eina_stringshare_del(it->label);
if (it->uri) eina_stringshare_del(it->uri);
if (it->mime) eina_stringshare_del(it->mime);
free(it);
it = NULL;
if (file[0] == '.')
{
free(file);
continue;
}
it = _item_add(s->directory, file);
if (it)
s->items = eina_list_append(s->items, it);
free(file);
}
if (idler)
ecore_idler_del(idler);
idler = ecore_idler_add(_dirbrowse_idler, p);
stack = eina_list_prepend(stack, s);
p->private = stack;
return 1;
}
static void
_cleanup(Evry_Plugin *p)
{
State *s;
Evry_Item *it;
Eina_List *stack = p->private;
if (!stack) return;
s = stack->data;
_list_free(p);
eina_stringshare_del(s->directory);
if (s->directory) eina_stringshare_del(s->directory);
EINA_LIST_FREE(s->items, it)
{
if (it->uri) eina_stringshare_del(it->uri);
if (it->mime) eina_stringshare_del(it->mime);
evry_item_free(it);
}
if (idler)
{
ecore_idler_del(idler);
idler = NULL;
}
E_FREE(s);
eina_list_free(p->items);
p->items = NULL;
stack = eina_list_remove_list(stack, stack);
p->private = stack;
if (stack)
{
s = stack->data;
p->items = s->items;
p->items = s->cur;
}
}
@ -136,24 +184,27 @@ _cleanup(Evry_Plugin *p)
static int
_fetch(Evry_Plugin *p, const char *input)
{
Eina_List *files;
char *file;
const char *directory = NULL;
Evry_Item *it;
Eina_List *l;
char match1[4096];
char match2[4096];
int cnt = 0;
Eina_List *stack = p->private;
State *s = stack->data;
_list_free(p);
if (p->items) eina_list_free(p->items);
p->items = NULL;
/* input is command ? */
if (input)
{
/* XXX free s->items? */
if (!strncmp(input, "/", 1))
{
it = E_NEW(Evry_Item, 1);
it = evry_item_new(p, "/");
if (!it) return 0;
it->uri = eina_stringshare_add("/");
it->label = eina_stringshare_add("/");
p->items = eina_list_append(p->items, it);
s->command = 1;
return 1;
@ -175,9 +226,9 @@ _fetch(Evry_Plugin *p, const char *input)
{
tmp = strdup(dir);
snprintf(dir, (end - dir) + 1, "%s", tmp);
it = E_NEW(Evry_Item, 1);
it = evry_item_new(p, dir);
if (!it) return 0;
it->uri = eina_stringshare_add(dir);
it->label = eina_stringshare_add(dir);
it->priority = prio;
p->items = eina_list_append(p->items, it);
end = strrchr(dir, '/');
@ -185,12 +236,11 @@ _fetch(Evry_Plugin *p, const char *input)
prio--;
}
it = E_NEW(Evry_Item, 1);
it = evry_item_new(p, "/");
if (!it) return 0;
it->uri = eina_stringshare_add("/");
it->label = eina_stringshare_add("/");
it->priority = prio;
p->items = eina_list_append(p->items, it);
s->command = 1;
return 1;
@ -200,51 +250,37 @@ _fetch(Evry_Plugin *p, const char *input)
if (!directory)
directory = s->directory;
files = ecore_file_ls(directory);
if (input)
{
snprintf(match1, sizeof(match1), "%s*", input);
snprintf(match2, sizeof(match2), "*%s*", input);
}
EINA_LIST_FREE(files, file)
EINA_LIST_FOREACH(s->items, l, it)
{
it = NULL;
if (file[0] == '.')
{
free(file);
continue;
}
if (input)
{
if (e_util_glob_case_match(file, match1))
{
it = _item_add(directory, file);
it->priority = 1;
}
else if (e_util_glob_case_match(file, match2))
{
it = _item_add(directory, file);
it->priority = 0;
}
/* TODO fix sort priority */
if (e_util_glob_case_match(it->label, match1))
it->priority += 2;
else if (e_util_glob_case_match(it->label, match2))
it->priority += 1;
else it = NULL;
}
else
{
it = _item_add(directory, file);
}
if (it)
p->items = eina_list_append(p->items, it);
free(file);
if (it)
{
p->items = eina_list_append(p->items, it);
cnt++;
if (cnt >= MAX_ITEMS) break;
}
}
s->items = p->items;
if (p->items) return 1;
if (p->items)
{
s->cur = p->items;
return 1;
}
return 0;
}
@ -255,11 +291,11 @@ _item_add(const char *directory, const char *file)
Evry_Item *it = NULL;
char buf[4096];
it = E_NEW(Evry_Item, 1);
it = evry_item_new(p, file);
if (!it) return NULL;
snprintf(buf, sizeof(buf), "%s/%s", directory, file);
it->uri = eina_stringshare_add(buf);
it->label = eina_stringshare_add(file);
return it;
}
@ -269,22 +305,23 @@ _realize(Evry_Plugin *p, Evas *e)
{
Eina_List *l;
Evry_Item *it;
Eina_List *stack = p->private;
State *s = stack->data;
EINA_LIST_FOREACH(p->items, l, it)
_item_fill(it, e);
/* EINA_LIST_FOREACH(p->items, l, it)
* _item_fill(it, e); */
if (eina_list_count(p->items) > 0)
{
p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
s->items = p->items;
s->cur = p->items;
}
}
/* based on directory-watcher from drawer module */
static void
_item_fill(Evry_Item *it, Evas *e)
_item_fill(Evry_Item *it)
{
const char *mime;
@ -309,9 +346,8 @@ _item_fill(Evry_Item *it, Evas *e)
else if (ecore_file_is_dir(it->uri))
{
it->mime = eina_stringshare_add("Folder");
it->browseable = EINA_TRUE;
it->priority += 1;
it->o_icon = edje_object_add(e);
e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/folder");
}
else if ((mime = efreet_mime_type_get(it->uri)))
{
@ -321,45 +357,37 @@ _item_fill(Evry_Item *it, Evas *e)
{
it->mime = eina_stringshare_add("None");
}
if (strcmp(it->mime, "Folder"))
{
char *item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 32);
if (item_path)
it->o_icon = e_util_icon_add(item_path, e);
else
{
it->o_icon = edje_object_add(e);
e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/fileman/file");
}
}
}
static void
static Evas_Object *
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
{
Evas_Object *o = NULL;
char *item_path;
if (!it->mime) return;
if (!it->mime)
_item_fill(it);
if (!it->mime) return NULL;
if (!strcmp(it->mime, "Folder"))
{
it->o_icon = edje_object_add(e);
e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/folder");
o = e_icon_add(e);
evry_icon_theme_set(o, "folder");
}
else
{
item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 32);
item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 64);
if (item_path)
it->o_icon = e_util_icon_add(item_path, e);
else
o = e_util_icon_add(item_path, e);
if (!o)
{
it->o_icon = edje_object_add(e);
e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/fileman/file");
o = e_icon_add(e);
evry_icon_theme_set(o, "none");
}
}
return o;
}
static int
@ -375,3 +403,45 @@ _cb_sort(const void *data1, const void *data2)
else
return strcasecmp(it1->label, it2->label);
}
static int
_dirbrowse_idler(void *data)
{
Evry_Plugin *p = data;
State *s = ((Eina_List *)p->private)->data;
int cnt = 10;
Eina_List *l;
Evry_Item *it;
/* printf("dirbrowse idler\n"); */
if (!idler) return 0;
EINA_LIST_FOREACH(s->items, l, it)
{
if (!it->mime)
{
_item_fill(it);
cnt--;
}
if (cnt == 0) break;
}
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_CLEAR);
if (eina_list_count(p->items) > 0)
{
p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
s->cur = p->items;
}
evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
if (cnt > 0)
{
idler = NULL;
return 0;
}
return 1;
}

View File

@ -10,57 +10,73 @@ struct _Inst
E_DBus_Connection *conn;
};
static int _fetch(Evry_Plugin *p, const char *input);
static void _cleanup(Evry_Plugin *p);
static void _item_add(Evry_Plugin *p, char *file, char *mime, int prio);
static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e);
static void _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error);
static Eina_Bool _init(void);
static void _shutdown(void);
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);
static Evry_Plugin *p;
static Evry_Plugin *p2;
static Inst *inst;
static Eina_Bool active = EINA_FALSE;
static Eina_Bool
_init(void)
static void
_item_add(Evry_Plugin *p, char *file, char *mime, int prio)
{
E_DBus_Connection *conn = e_dbus_bus_get(DBUS_BUS_SESSION);
Evry_Item *it;
const char *filename;
if (!conn) return 0;
filename = ecore_file_file_get(file);
p = E_NEW(Evry_Plugin, 1);
p->name = "Search Files";
p->type_in = "NONE";
p->type_out = "FILE";
p->need_query = 1;
p->fetch = &_fetch;
p->cleanup = &_cleanup;
p->icon_get = &_item_icon_get;
if (!filename) return;
inst = E_NEW(Inst, 1);
inst->conn = conn;
evry_plugin_register(p);
it = evry_item_new(p, filename);
it->priority = prio;
it->uri = eina_stringshare_add(file);
it->mime = eina_stringshare_add(mime);
return EINA_TRUE;
if (!strcmp(it->mime, "Folder"))
it->browseable = EINA_TRUE;
p->items = eina_list_append(p->items, it);
}
static void
_shutdown(void)
_dbus_cb_reply(void *data __UNUSED__, DBusMessage *msg, DBusError *error)
{
evry_plugin_unregister(p);
DBusMessageIter array, iter, item;
if (inst)
if (!active) return;
if (dbus_error_is_set(error))
{
if (inst->conn)
e_dbus_connection_close(inst->conn);
E_FREE(inst);
printf("Error: %s - %s\n", error->name, error->message);
return;
}
dbus_message_iter_init(msg, &array);
if(dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_ARRAY)
{
dbus_message_iter_recurse(&array, &item);
while(dbus_message_iter_get_arg_type(&item) == DBUS_TYPE_ARRAY)
{
char *uri, *mime;
dbus_message_iter_recurse(&item, &iter);
if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING)
{
dbus_message_iter_get_basic(&iter, &uri);
dbus_message_iter_next(&iter);
/* dbus_message_iter_get_basic(&iter, &service); */
dbus_message_iter_next(&iter);
dbus_message_iter_get_basic(&iter, &mime);
if (uri && mime)
{
_item_add(p, uri, mime, 1);
}
}
dbus_message_iter_next(&item);
}
}
if (p) E_FREE(p);
if (p->items) evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
}
static void
@ -72,9 +88,9 @@ _cleanup(Evry_Plugin *p)
{
if (it->mime) eina_stringshare_del(it->mime);
if (it->uri) eina_stringshare_del(it->uri);
if (it->label) eina_stringshare_del(it->label);
free(it);
evry_item_free(it);
}
active = EINA_FALSE;
}
static int
@ -90,6 +106,8 @@ _fetch(Evry_Plugin *p, const char *input)
_cleanup(p);
active = EINA_TRUE;
match = malloc(sizeof(char) * strlen(input) + 2);
sprintf(match, "%s*", input);
@ -112,87 +130,83 @@ _fetch(Evry_Plugin *p, const char *input)
return 0;
}
static void
static Evas_Object *
_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e)
{
char *item_path;
Evas_Object *o = NULL;
if (!strcmp(it->mime, "Folder"))
{
it->o_icon = edje_object_add(e);
/* e_util_icon_theme_set(it->o_icon, "folder"); */
e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/folder");
o = e_icon_add(e);
evry_icon_theme_set(o, "folder");
}
else
{
item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 32);
item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 64);
if (item_path)
it->o_icon = e_util_icon_add(item_path, e);
o = e_util_icon_add(item_path, e);
else
{
it->o_icon = edje_object_add(e);
/* e_util_icon_theme_set(it->o_icon, "file"); */
e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/fileman/file");
o = e_icon_add(e);
evry_icon_theme_set(o, "none");
}
}
return o;
}
static Eina_Bool
_init(void)
{
E_DBus_Connection *conn = e_dbus_bus_get(DBUS_BUS_SESSION);
if (!conn) return 0;
p = E_NEW(Evry_Plugin, 1);
p->name = "Find Files";
p->type = type_subject;
p->type_in = "NONE";
p->type_out = "FILE";
p->need_query = 1;
p->fetch = &_fetch;
p->cleanup = &_cleanup;
p->icon_get = &_item_icon_get;
evry_plugin_register(p);
p2 = E_NEW(Evry_Plugin, 1);
p2->name = "Find Files";
p2->type = type_object;
p2->type_in = "NONE";
p2->type_out = "FILE";
p2->need_query = 1;
p2->fetch = &_fetch;
p2->cleanup = &_cleanup;
p2->icon_get = &_item_icon_get;
evry_plugin_register(p2);
inst = E_NEW(Inst, 1);
inst->conn = conn;
return EINA_TRUE;
}
static void
_item_add(Evry_Plugin *p, char *file, char *mime, int prio)
_shutdown(void)
{
Evry_Item *it;
it = E_NEW(Evry_Item, 1);
it->priority = prio;
it->label = eina_stringshare_add(ecore_file_file_get(file));
it->uri = eina_stringshare_add(file);
it->mime = eina_stringshare_add(mime);
it->o_icon = NULL;
evry_plugin_unregister(p);
evry_plugin_unregister(p2);
p->items = eina_list_append(p->items, it);
}
static void
_dbus_cb_reply(void *data __UNUSED__, DBusMessage *msg, DBusError *error)
{
DBusMessageIter array, iter, item;
if (dbus_error_is_set(error))
{
printf("Error: %s - %s\n", error->name, error->message);
return;
}
dbus_message_iter_init(msg, &array);
if(dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_ARRAY)
{
dbus_message_iter_recurse(&array, &item);
while(dbus_message_iter_get_arg_type(&item) == DBUS_TYPE_ARRAY)
{
char *uri;
char *mime;
dbus_message_iter_recurse(&item, &iter);
if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING)
{
dbus_message_iter_get_basic(&iter, &uri);
dbus_message_iter_next(&iter);
/* dbus_message_iter_get_basic(&iter, &service); */
dbus_message_iter_next(&iter);
dbus_message_iter_get_basic(&iter, &mime);
if (uri && mime)
{
_item_add(p, uri, mime, 1);
}
}
dbus_message_iter_next(&item);
}
}
if (p->items) evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD);
if (p) E_FREE(p);
if (p2) E_FREE(p2);
if (inst)
{
if (inst->conn)
e_dbus_connection_close(inst->conn);
E_FREE(inst);
}
}
EINA_MODULE_INIT(_init);
EINA_MODULE_SHUTDOWN(_shutdown);