2009-05-06 07:20:45 -07:00
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
static int _fetch(const char *input);
|
|
|
|
static int _action(Evry_Item *item, const char *input);
|
|
|
|
static void _cleanup(void);
|
|
|
|
static void _item_add(E_Configure_It *eci, int prio);
|
|
|
|
static void _item_icon_get(Evry_Item *it, Evas *e);
|
2009-06-21 14:16:02 -07:00
|
|
|
static int _cb_sort(const void *data1, const void *data2);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
static Evry_Plugin *p;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
|
|
|
EAPI int
|
2009-06-24 13:02:37 -07:00
|
|
|
evry_plug_config_init(void)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-06-24 13:02:37 -07:00
|
|
|
p = E_NEW(Evry_Plugin, 1);
|
|
|
|
p->name = "Settings";
|
|
|
|
p->type_in = "NONE";
|
|
|
|
p->type_out = "NONE";
|
|
|
|
p->prio = 4;
|
2009-06-21 14:16:02 -07:00
|
|
|
p->fetch = &_fetch;
|
|
|
|
p->action = &_action;
|
|
|
|
p->cleanup = &_cleanup;
|
|
|
|
p->icon_get = &_item_icon_get;
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
evry_plugin_register(p);
|
|
|
|
return 1;
|
|
|
|
}
|
2009-06-21 03:31:38 -07:00
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
EAPI int
|
|
|
|
evry_plug_config_shutdown(void)
|
2009-06-21 03:31:38 -07:00
|
|
|
{
|
2009-06-24 13:02:37 -07:00
|
|
|
evry_plugin_unregister(p);
|
2009-06-21 03:31:38 -07:00
|
|
|
E_FREE(p);
|
2009-06-24 13:02:37 -07:00
|
|
|
|
|
|
|
return 1;
|
2009-06-21 03:31:38 -07:00
|
|
|
}
|
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
static int
|
2009-06-24 13:02:37 -07:00
|
|
|
_action(Evry_Item *it, const char *input)
|
2009-05-06 07:20:45 -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-06-21 14:16:02 -07:00
|
|
|
|
2009-07-03 06:37:54 -07:00
|
|
|
if (!it) return EVRY_ACTION_CONTINUE;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-06-21 14:16:02 -07:00
|
|
|
eci = it->data[0];
|
2009-05-06 07:20:45 -07:00
|
|
|
con = e_container_current_get(e_manager_current_get());
|
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
for (l = e_configure_registry; l && !found; l = l->next)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
ecat = l->data;
|
2009-06-21 03:31:38 -07:00
|
|
|
for (ll = ecat->items; ll && !found; ll = ll->next)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
2009-07-03 06:37:54 -07:00
|
|
|
return EVRY_ACTION_FINISHED;
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-06-24 13:02:37 -07:00
|
|
|
_cleanup(void)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
Evry_Item *it;
|
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
EINA_LIST_FREE(p->items, it)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
if (it->label) eina_stringshare_del(it->label);
|
2009-07-03 06:37:54 -07:00
|
|
|
E_FREE(it);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-06-24 13:02:37 -07:00
|
|
|
_fetch(const char *input)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
E_Manager *man;
|
|
|
|
E_Zone *zone;
|
|
|
|
|
|
|
|
char match1[4096];
|
|
|
|
char match2[4096];
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
E_Configure_Cat *ecat;
|
|
|
|
E_Configure_It *eci;
|
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
_cleanup();
|
2009-05-06 07:20:45 -07:00
|
|
|
|
2009-06-21 14:16:02 -07:00
|
|
|
snprintf(match1, sizeof(match1), "%s*", input);
|
|
|
|
snprintf(match2, sizeof(match2), "*%s*", input);
|
2009-05-06 07:20:45 -07:00
|
|
|
|
|
|
|
for (l = e_configure_registry; l; l = l->next)
|
|
|
|
{
|
|
|
|
ecat = l->data;
|
|
|
|
if ((ecat->pri >= 0) && (ecat->items))
|
|
|
|
{
|
|
|
|
for (ll = ecat->items; ll; ll = ll->next)
|
|
|
|
{
|
|
|
|
eci = ll->data;
|
|
|
|
if (eci->pri >= 0)
|
|
|
|
{
|
|
|
|
if (e_util_glob_case_match(eci->label, match1))
|
2009-06-24 13:02:37 -07:00
|
|
|
_item_add(eci, 1);
|
2009-05-06 07:20:45 -07:00
|
|
|
else if (e_util_glob_case_match(eci->label, match2))
|
2009-06-24 13:02:37 -07:00
|
|
|
_item_add(eci, 2);
|
2009-05-06 07:20:45 -07:00
|
|
|
else if (e_util_glob_case_match(ecat->label, match1))
|
2009-06-24 13:02:37 -07:00
|
|
|
_item_add(eci, 3);
|
2009-05-06 07:20:45 -07:00
|
|
|
else if (e_util_glob_case_match(ecat->label, match2))
|
2009-06-24 13:02:37 -07:00
|
|
|
_item_add(eci, 4);
|
2009-05-06 07:20:45 -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-06-24 13:02:37 -07:00
|
|
|
p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort);
|
2009-05-06 07:20:45 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-06-24 13:02:37 -07:00
|
|
|
_item_icon_get(Evry_Item *it, Evas *e)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
2009-06-21 03:31:38 -07:00
|
|
|
E_Configure_It *eci = it->data[0];
|
2009-06-11 07:50:34 -07:00
|
|
|
Evas_Object *o = NULL;
|
2009-05-06 07:20:45 -07:00
|
|
|
|
|
|
|
if (eci->icon)
|
|
|
|
{
|
|
|
|
o = e_icon_add(e);
|
|
|
|
if (!e_util_icon_theme_set(o, eci->icon))
|
|
|
|
{
|
|
|
|
evas_object_del(o);
|
|
|
|
o = e_util_icon_add(eci->icon, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
it->o_icon = o;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-06-24 13:02:37 -07:00
|
|
|
_item_add(E_Configure_It *eci, int prio)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
Evry_Item *it;
|
|
|
|
|
2009-07-03 06:37:54 -07:00
|
|
|
it = E_NEW(Evry_Item, 1);
|
2009-06-21 03:31:38 -07:00
|
|
|
it->data[0] = eci;
|
2009-05-06 07:20:45 -07:00
|
|
|
it->priority = prio;
|
|
|
|
it->label = eina_stringshare_add(eci->label);
|
|
|
|
it->o_icon = NULL;
|
|
|
|
|
2009-06-21 03:31:38 -07:00
|
|
|
p->items = eina_list_append(p->items, it);
|
2009-05-06 07:20:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-06-21 14:16:02 -07:00
|
|
|
_cb_sort(const void *data1, const void *data2)
|
2009-05-06 07:20:45 -07:00
|
|
|
{
|
|
|
|
const Evry_Item *it1, *it2;
|
|
|
|
|
|
|
|
it1 = data1;
|
|
|
|
it2 = data2;
|
|
|
|
|
2009-06-24 13:02:37 -07:00
|
|
|
/* TODO sort by name? */
|
|
|
|
|
2009-05-06 07:20:45 -07:00
|
|
|
return (it1->priority - it2->priority);
|
|
|
|
}
|