2009-08-13 08:10:54 -07:00
|
|
|
#include "Evry.h"
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
static Evry_Plugin *p;
|
2009-08-10 04:36:37 -07:00
|
|
|
static Evry_Action *act;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static void
|
|
|
|
_cleanup(Evry_Plugin *p)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
EVRY_PLUGIN_ITEMS_FREE(p);
|
2009-06-24 13:02:37 -07:00
|
|
|
}
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-07-29 13:43:09 -07:00
|
|
|
static void
|
2009-08-14 11:55:35 -07:00
|
|
|
_item_add(Evry_Plugin *p, E_Configure_It *eci, int match, int prio)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
Evry_Item *it;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
it = evry_item_new(NULL, p, eci->label, NULL);
|
|
|
|
it->data = eci;
|
2009-08-10 04:36:37 -07:00
|
|
|
it->priority = prio;
|
2009-08-14 11:55:35 -07:00
|
|
|
it->fuzzy_match = match;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
EVRY_PLUGIN_ITEM_APPEND(p, it);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-07-07 09:30:11 -07:00
|
|
|
_fetch(Evry_Plugin *p, const char *input)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
E_Configure_Cat *ecat;
|
|
|
|
E_Configure_It *eci;
|
2009-08-14 11:55:35 -07:00
|
|
|
int match;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-07-07 09:30:11 -07:00
|
|
|
_cleanup(p);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-10 11:39:11 -07:00
|
|
|
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 11:39:11 -07:00
|
|
|
if ((ecat->pri < 0) || (!ecat->items)) continue;
|
|
|
|
if (!strcmp(ecat->cat, "system")) continue;
|
2009-08-14 07:44:18 -07:00
|
|
|
|
2009-08-10 11:39:11 -07:00
|
|
|
EINA_LIST_FOREACH(ecat->items, ll, eci)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 11:39:11 -07:00
|
|
|
if (eci->pri >= 0)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-15 17:13:56 -07:00
|
|
|
if ((match = evry_fuzzy_match(eci->label, input)))
|
2009-08-14 11:55:35 -07:00
|
|
|
_item_add(p, eci, match, 0);
|
2009-08-15 17:13:56 -07:00
|
|
|
else if ((match = evry_fuzzy_match(ecat->label, input)))
|
2009-08-14 11:55:35 -07:00
|
|
|
_item_add(p, eci, match, 1);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
if (eina_list_count(p->items) > 0)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
p->items = evry_fuzzy_match_sort(p->items);
|
2009-05-06 07:20:45 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static Evas_Object *
|
2009-08-12 05:17:43 -07:00
|
|
|
_item_icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-06-11 07:50:34 -07:00
|
|
|
Evas_Object *o = NULL;
|
2009-08-22 20:12:05 -07:00
|
|
|
E_Configure_It *eci = it->data;
|
2009-07-04 04:10:28 -07:00
|
|
|
|
|
|
|
if (eci->icon)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-18 07:29:30 -07:00
|
|
|
if (!(o = evry_icon_theme_get(eci->icon, e)))
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
o = e_util_icon_add(eci->icon, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return o;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static int
|
2009-08-21 18:15:21 -07:00
|
|
|
_action(Evry_Action *act)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-10 04:36:37 -07:00
|
|
|
E_Configure_It *eci, *eci2;
|
|
|
|
E_Container *con;
|
|
|
|
E_Configure_Cat *ecat;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
char buf[1024];
|
|
|
|
int found = 0;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-22 20:12:05 -07:00
|
|
|
eci = act->item1->data;
|
2009-08-10 04:36:37 -07:00
|
|
|
con = e_container_current_get(e_manager_current_get());
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 11:39:11 -07:00
|
|
|
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
2009-08-10 11:39:11 -07:00
|
|
|
if (found) break;
|
2009-08-14 07:44:18 -07:00
|
|
|
|
2009-08-10 11:39:11 -07:00
|
|
|
EINA_LIST_FOREACH(ecat->items, ll, eci2)
|
2009-08-10 04:36:37 -07:00
|
|
|
{
|
|
|
|
if (eci == eci2)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s",
|
|
|
|
ecat->cat,
|
|
|
|
eci->item);
|
2009-08-10 11:39:11 -07:00
|
|
|
found = 1;
|
|
|
|
break;
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
e_configure_registry_call(buf, con, NULL);
|
|
|
|
|
|
|
|
return EVRY_ACTION_FINISHED;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_init(void)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-08-21 15:42:06 -07:00
|
|
|
p = evry_plugin_new(NULL, "Settings", type_subject, NULL, "E_SETTINGS", 0, NULL, NULL,
|
|
|
|
NULL, _cleanup, _fetch, NULL, _item_icon_get, NULL, NULL);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-21 15:42:06 -07:00
|
|
|
act = evry_action_new("Show Dialog", "E_SETTINGS", NULL, NULL, "preferences-advanced",
|
2009-08-21 18:15:21 -07:00
|
|
|
_action, NULL, NULL, NULL, NULL);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
evry_plugin_register(p, 10);
|
2009-08-10 04:36:37 -07:00
|
|
|
evry_action_register(act);
|
2009-07-04 04:10:28 -07:00
|
|
|
|
2009-08-10 04:36:37 -07:00
|
|
|
return EINA_TRUE;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
2009-08-10 04:36:37 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_shutdown(void)
|
|
|
|
{
|
2009-08-22 20:12:05 -07:00
|
|
|
EVRY_PLUGIN_FREE(p);
|
2009-08-21 15:42:06 -07:00
|
|
|
|
2009-08-18 07:29:30 -07:00
|
|
|
evry_action_free(act);
|
2009-08-10 04:36:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EINA_MODULE_INIT(_init);
|
|
|
|
EINA_MODULE_SHUTDOWN(_shutdown);
|