forked from enlightenment/enlightenment
implement tag aliases for configure options, also add top-level files category when fileman is loaded
SVN revision: 82173
This commit is contained in:
parent
3f6fa63824
commit
a486201959
|
@ -18,7 +18,12 @@ static Eina_List *gtk_theme_mons = NULL; //Eio_Monitor
|
||||||
static Eio_File *bg_ls[2] = {NULL, NULL};
|
static Eio_File *bg_ls[2] = {NULL, NULL};
|
||||||
static Eio_Monitor *bg_mon[2] = {NULL, NULL};
|
static Eio_Monitor *bg_mon[2] = {NULL, NULL};
|
||||||
static Eina_Inlist *opts_list = NULL;
|
static Eina_Inlist *opts_list = NULL;
|
||||||
|
static Eina_Hash *tags_name_hash = NULL;/* (const char*)tag:(Eina_Stringshare*)tag */
|
||||||
static Eina_Hash *tags_hash = NULL;/* tag:item */
|
static Eina_Hash *tags_hash = NULL;/* tag:item */
|
||||||
|
static Eina_Hash *tags_alias_hash = NULL; /* alias:tag */
|
||||||
|
static Eina_Hash *tags_tag_alias_hash = NULL; /* tag:Eina_List(aliases) */
|
||||||
|
static Eina_Hash *tags_alias_name_hash = NULL;/* (const char*)alias:(Eina_Stringshare*)alias */
|
||||||
|
static Eina_List *tags_alias_list = NULL; /* alias:tag */
|
||||||
static Eina_List *tags_list = NULL;/* Eina_Stringshare */
|
static Eina_List *tags_list = NULL;/* Eina_Stringshare */
|
||||||
static Eina_List *opts_changed_list = NULL; //co->changed
|
static Eina_List *opts_changed_list = NULL; //co->changed
|
||||||
static Eina_List *handlers = NULL;
|
static Eina_List *handlers = NULL;
|
||||||
|
@ -75,6 +80,19 @@ _e_configure_option_event_tag_add_del(Eina_Stringshare *tag, Eina_Bool del)
|
||||||
ecore_event_add(E_EVENT_CONFIGURE_OPTION_TAG_ADD, ev, NULL, NULL);
|
ecore_event_add(E_EVENT_CONFIGURE_OPTION_TAG_ADD, ev, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_configure_option_tag_alias_list_free(Eina_List *list)
|
||||||
|
{
|
||||||
|
Eina_Stringshare *alias;
|
||||||
|
|
||||||
|
EINA_LIST_FREE(list, alias)
|
||||||
|
{
|
||||||
|
eina_hash_del_by_key(tags_alias_name_hash, alias);
|
||||||
|
tags_alias_list = eina_list_remove(tags_alias_list, alias);
|
||||||
|
eina_hash_del_by_key(tags_alias_hash, alias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_configure_option_tag_remove(E_Configure_Option *co, Eina_Stringshare *tag)
|
_e_configure_option_tag_remove(E_Configure_Option *co, Eina_Stringshare *tag)
|
||||||
{
|
{
|
||||||
|
@ -88,6 +106,8 @@ _e_configure_option_tag_remove(E_Configure_Option *co, Eina_Stringshare *tag)
|
||||||
{
|
{
|
||||||
/* this seems dumb... */
|
/* this seems dumb... */
|
||||||
tags_list = eina_list_remove(tags_list, tag);
|
tags_list = eina_list_remove(tags_list, tag);
|
||||||
|
eina_hash_del_by_key(tags_name_hash, tag);
|
||||||
|
eina_hash_del_by_key(tags_tag_alias_hash, tag);
|
||||||
_e_configure_option_event_tag_add_del(tag, EINA_TRUE);
|
_e_configure_option_event_tag_add_del(tag, EINA_TRUE);
|
||||||
}
|
}
|
||||||
eina_hash_set(tags_hash, tag, items);
|
eina_hash_set(tags_hash, tag, items);
|
||||||
|
@ -161,6 +181,7 @@ _e_configure_option_tag_append(E_Configure_Option *co, const char *tag)
|
||||||
Eina_Stringshare *t;
|
Eina_Stringshare *t;
|
||||||
|
|
||||||
t = eina_stringshare_add(tag);
|
t = eina_stringshare_add(tag);
|
||||||
|
eina_hash_add(tags_name_hash, tag, t);
|
||||||
tags_list = eina_list_sorted_insert(tags_list, (Eina_Compare_Cb)strcmp, t);
|
tags_list = eina_list_sorted_insert(tags_list, (Eina_Compare_Cb)strcmp, t);
|
||||||
_e_configure_option_event_tag_add_del(t, EINA_FALSE);
|
_e_configure_option_event_tag_add_del(t, EINA_FALSE);
|
||||||
}
|
}
|
||||||
|
@ -1400,7 +1421,11 @@ e_configure_option_init(void)
|
||||||
E_EVENT_CONFIGURE_OPTION_TAG_ADD = ecore_event_type_new();
|
E_EVENT_CONFIGURE_OPTION_TAG_ADD = ecore_event_type_new();
|
||||||
E_EVENT_CONFIGURE_OPTION_TAG_DEL = ecore_event_type_new();
|
E_EVENT_CONFIGURE_OPTION_TAG_DEL = ecore_event_type_new();
|
||||||
|
|
||||||
|
tags_name_hash = eina_hash_string_superfast_new(NULL);
|
||||||
tags_hash = eina_hash_string_superfast_new(NULL);
|
tags_hash = eina_hash_string_superfast_new(NULL);
|
||||||
|
tags_tag_alias_hash = eina_hash_stringshared_new((Eina_Free_Cb)_e_configure_option_tag_alias_list_free);
|
||||||
|
tags_alias_hash = eina_hash_string_superfast_new(NULL);
|
||||||
|
tags_alias_name_hash = eina_hash_string_superfast_new(NULL);
|
||||||
#define OPT_ADD(TYPE, NAME, DESC, ...) \
|
#define OPT_ADD(TYPE, NAME, DESC, ...) \
|
||||||
co = e_configure_option_add(E_CONFIGURE_OPTION_TYPE_##TYPE, DESC, #NAME, EINA_FALSE, &e_config->NAME, NULL);\
|
co = e_configure_option_add(E_CONFIGURE_OPTION_TYPE_##TYPE, DESC, #NAME, EINA_FALSE, &e_config->NAME, NULL);\
|
||||||
e_configure_option_tags_set(co, (const char*[]){__VA_ARGS__, NULL}, 0)
|
e_configure_option_tags_set(co, (const char*[]){__VA_ARGS__, NULL}, 0)
|
||||||
|
@ -2074,6 +2099,12 @@ e_configure_option_init(void)
|
||||||
e_configure_option_category_tag_add(_("settings"), _("module"));
|
e_configure_option_category_tag_add(_("settings"), _("module"));
|
||||||
e_configure_option_category_icon_set(_("settings"), "preferences-preferences");
|
e_configure_option_category_icon_set(_("settings"), "preferences-preferences");
|
||||||
|
|
||||||
|
e_configure_option_tag_alias_add(_("border"), _("window"));
|
||||||
|
e_configure_option_tag_alias_add(_("exec"), _("launch"));
|
||||||
|
e_configure_option_tag_alias_add(_("image"), _("icon"));
|
||||||
|
e_configure_option_tag_alias_add(_("theme"), _("style"));
|
||||||
|
e_configure_option_tag_alias_add(_("pointer"), _("cursor"));
|
||||||
|
|
||||||
event_block = EINA_FALSE;
|
event_block = EINA_FALSE;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2082,18 +2113,17 @@ e_configure_option_init(void)
|
||||||
EINTERN int
|
EINTERN int
|
||||||
e_configure_option_shutdown(void)
|
e_configure_option_shutdown(void)
|
||||||
{
|
{
|
||||||
Eina_Stringshare *tag;
|
|
||||||
|
|
||||||
opts_changed_list = eina_list_free(opts_changed_list);
|
opts_changed_list = eina_list_free(opts_changed_list);
|
||||||
event_block = EINA_TRUE;
|
event_block = EINA_TRUE;
|
||||||
EINA_LIST_FREE(tags_list, tag)
|
E_FREE_LIST(tags_list, eina_stringshare_del);
|
||||||
{
|
E_FREE_LIST(tags_alias_list, eina_stringshare_del);
|
||||||
eina_hash_del_by_key(tags_hash, tag);
|
|
||||||
eina_stringshare_del(tag);
|
|
||||||
}
|
|
||||||
while (opts_list)
|
while (opts_list)
|
||||||
_e_configure_option_free((E_Configure_Option*)opts_list);
|
_e_configure_option_free((E_Configure_Option*)opts_list);
|
||||||
E_FN_DEL(eina_hash_free, tags_hash);
|
E_FN_DEL(eina_hash_free, tags_hash);
|
||||||
|
E_FN_DEL(eina_hash_free, tags_tag_alias_hash);
|
||||||
|
E_FN_DEL(eina_hash_free, tags_name_hash);
|
||||||
|
E_FN_DEL(eina_hash_free, tags_alias_name_hash);
|
||||||
|
E_FN_DEL(eina_hash_free, tags_alias_hash);
|
||||||
E_FN_DEL(eio_monitor_del, theme_mon[0]);
|
E_FN_DEL(eio_monitor_del, theme_mon[0]);
|
||||||
E_FN_DEL(eio_monitor_del, theme_mon[1]);
|
E_FN_DEL(eio_monitor_del, theme_mon[1]);
|
||||||
E_FN_DEL(eio_file_cancel, theme_ls[0]);
|
E_FN_DEL(eio_file_cancel, theme_ls[0]);
|
||||||
|
@ -2457,24 +2487,19 @@ e_configure_option_category_list(void)
|
||||||
EAPI void
|
EAPI void
|
||||||
e_configure_option_category_tag_add(const char *cat, const char *tag)
|
e_configure_option_category_tag_add(const char *cat, const char *tag)
|
||||||
{
|
{
|
||||||
Eina_List *l;
|
|
||||||
Eina_Stringshare *t, *c;
|
Eina_Stringshare *t, *c;
|
||||||
|
Eina_List *l;
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN(cat);
|
EINA_SAFETY_ON_NULL_RETURN(cat);
|
||||||
EINA_SAFETY_ON_NULL_RETURN(tag);
|
EINA_SAFETY_ON_NULL_RETURN(tag);
|
||||||
t = eina_stringshare_add(tag);
|
t = eina_hash_find(tags_name_hash, tag);
|
||||||
if (!eina_list_data_find(tags_list, t))
|
if (!t) return;
|
||||||
{
|
|
||||||
eina_stringshare_del(t);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!categories)
|
if (!categories)
|
||||||
{
|
{
|
||||||
c = eina_stringshare_add(cat);
|
c = eina_stringshare_add(cat);
|
||||||
eina_hash_add(category_hash, cat, eina_list_append(NULL, t));
|
eina_hash_add(category_hash, cat, eina_list_append(NULL, t));
|
||||||
categories = eina_list_append(categories, c);
|
categories = eina_list_append(categories, c);
|
||||||
_e_configure_option_event_category_add_del(c, EINA_FALSE);
|
_e_configure_option_event_category_add_del(c, EINA_FALSE);
|
||||||
eina_stringshare_del(t);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
l = eina_hash_find(category_hash, cat);
|
l = eina_hash_find(category_hash, cat);
|
||||||
|
@ -2490,7 +2515,6 @@ e_configure_option_category_tag_add(const char *cat, const char *tag)
|
||||||
eina_hash_add(category_hash, cat, eina_list_append(NULL, t));
|
eina_hash_add(category_hash, cat, eina_list_append(NULL, t));
|
||||||
_e_configure_option_event_category_add_del(c, EINA_FALSE);
|
_e_configure_option_event_category_add_del(c, EINA_FALSE);
|
||||||
}
|
}
|
||||||
eina_stringshare_del(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -2506,18 +2530,15 @@ e_configure_option_category_tag_del(const char *cat, const char *tag)
|
||||||
|
|
||||||
l = eina_hash_find(category_hash, cat);
|
l = eina_hash_find(category_hash, cat);
|
||||||
if (!l) return;
|
if (!l) return;
|
||||||
t = eina_stringshare_add(tag);
|
t = eina_hash_find(tags_name_hash, tag);
|
||||||
l = eina_list_remove(l, t);
|
l = eina_list_remove(l, t);
|
||||||
eina_hash_set(category_hash, cat, l);
|
eina_hash_set(category_hash, cat, l);
|
||||||
if (!l)
|
if (l) return;
|
||||||
{
|
|
||||||
c = eina_stringshare_add(cat);
|
c = eina_stringshare_add(cat);
|
||||||
categories = eina_list_remove(categories, c);
|
categories = eina_list_remove(categories, c);
|
||||||
_e_configure_option_event_category_add_del(c, EINA_TRUE);
|
_e_configure_option_event_category_add_del(c, EINA_TRUE);
|
||||||
eina_stringshare_del(c);
|
eina_stringshare_del(c);
|
||||||
}
|
}
|
||||||
eina_stringshare_del(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI Eina_Stringshare *
|
EAPI Eina_Stringshare *
|
||||||
e_configure_option_category_icon_get(const char *cat)
|
e_configure_option_category_icon_get(const char *cat)
|
||||||
|
@ -2533,6 +2554,43 @@ e_configure_option_category_icon_set(const char *cat, const char *icon)
|
||||||
eina_stringshare_del(eina_hash_set(category_icon_hash, cat, eina_stringshare_add(icon)));
|
eina_stringshare_del(eina_hash_set(category_icon_hash, cat, eina_stringshare_add(icon)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_configure_option_tag_alias_add(const char *tag, const char *alias)
|
||||||
|
{
|
||||||
|
Eina_Stringshare *t, *o;
|
||||||
|
Eina_List *l;
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(tag);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(alias);
|
||||||
|
|
||||||
|
t = eina_hash_find(tags_name_hash, tag);
|
||||||
|
if (!t) return;
|
||||||
|
o = eina_hash_set(tags_alias_hash, alias, t);
|
||||||
|
if (o) return; //alias already in list
|
||||||
|
o = eina_stringshare_add(alias);
|
||||||
|
tags_alias_list = eina_list_append(tags_alias_list, o);
|
||||||
|
l = eina_hash_find(tags_tag_alias_hash, t);
|
||||||
|
eina_hash_set(tags_tag_alias_hash, t, eina_list_append(l, o));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_configure_option_tag_alias_del(const char *tag, const char *alias)
|
||||||
|
{
|
||||||
|
Eina_Stringshare *t, *a;
|
||||||
|
Eina_List *l;
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(tag);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(alias);
|
||||||
|
|
||||||
|
t = eina_hash_set(tags_alias_hash, alias, NULL);
|
||||||
|
if (!t) return; //alias doesn't exist
|
||||||
|
a = eina_hash_find(tags_alias_name_hash, alias);
|
||||||
|
tags_alias_list = eina_list_remove(tags_alias_list, a);
|
||||||
|
l = eina_hash_find(tags_tag_alias_hash, t);
|
||||||
|
eina_hash_set(tags_tag_alias_hash, t, eina_list_remove(l, a));
|
||||||
|
eina_stringshare_del(a);
|
||||||
|
}
|
||||||
|
|
||||||
EAPI E_Configure_Option_Ctx *
|
EAPI E_Configure_Option_Ctx *
|
||||||
e_configure_option_ctx_new(void)
|
e_configure_option_ctx_new(void)
|
||||||
{
|
{
|
||||||
|
@ -2543,7 +2601,7 @@ EAPI Eina_Bool
|
||||||
e_configure_option_ctx_update(E_Configure_Option_Ctx *ctx, const char *str)
|
e_configure_option_ctx_update(E_Configure_Option_Ctx *ctx, const char *str)
|
||||||
{
|
{
|
||||||
Eina_List *l, *ll, *tlist, *clist = NULL;
|
Eina_List *l, *ll, *tlist, *clist = NULL;
|
||||||
Eina_Stringshare *tag;
|
Eina_Stringshare *tag, *alias;
|
||||||
char *s, *e;
|
char *s, *e;
|
||||||
|
|
||||||
if ((!str) || (!str[0]))
|
if ((!str) || (!str[0]))
|
||||||
|
@ -2553,6 +2611,36 @@ e_configure_option_ctx_update(E_Configure_Option_Ctx *ctx, const char *str)
|
||||||
ctx->opts = eina_list_free(ctx->opts);
|
ctx->opts = eina_list_free(ctx->opts);
|
||||||
return ctx->changed = EINA_TRUE;
|
return ctx->changed = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
tlist = eina_list_clone(tags_alias_list);
|
||||||
|
for (s = e = strdupa(str); e[0]; e++)
|
||||||
|
{
|
||||||
|
if (isalnum(e[0])) continue;
|
||||||
|
e[0] = 0;
|
||||||
|
if (e - s > 1)
|
||||||
|
{
|
||||||
|
EINA_LIST_FOREACH_SAFE(tlist, l, ll, alias)
|
||||||
|
{
|
||||||
|
if ((!strcasestr(s, alias)) && (!strcasestr(alias, s))) continue;
|
||||||
|
tag = eina_hash_find(tags_alias_hash, alias);
|
||||||
|
if (eina_list_data_find(clist, tag)) continue;
|
||||||
|
clist = eina_list_append(clist, tag);
|
||||||
|
tlist = eina_list_remove(tlist, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s = e + 1;
|
||||||
|
}
|
||||||
|
if (e - s > 1)
|
||||||
|
{
|
||||||
|
EINA_LIST_FOREACH_SAFE(tlist, l, ll, alias)
|
||||||
|
{
|
||||||
|
if ((!strcasestr(s, alias)) && (!strcasestr(alias, s))) continue;
|
||||||
|
tag = eina_hash_find(tags_alias_hash, alias);
|
||||||
|
if (eina_list_data_find(clist, tag)) continue;
|
||||||
|
clist = eina_list_append(clist, tag);
|
||||||
|
tlist = eina_list_remove(tlist, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eina_list_free(tlist);
|
||||||
tlist = eina_list_clone(tags_list);
|
tlist = eina_list_clone(tags_list);
|
||||||
for (s = e = strdupa(str); e[0]; e++)
|
for (s = e = strdupa(str); e[0]; e++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -151,6 +151,9 @@ EAPI void e_configure_option_info_free(E_Configure_Option_Info *oi);
|
||||||
EAPI Eina_List *e_configure_option_info_get(E_Configure_Option *co);
|
EAPI Eina_List *e_configure_option_info_get(E_Configure_Option *co);
|
||||||
EAPI Evas_Object *e_configure_option_info_thumb_get(E_Configure_Option_Info *oi, Evas *evas);
|
EAPI Evas_Object *e_configure_option_info_thumb_get(E_Configure_Option_Info *oi, Evas *evas);
|
||||||
|
|
||||||
|
EAPI void e_configure_option_tag_alias_add(const char *tag, const char *alias);
|
||||||
|
EAPI void e_configure_option_tag_alias_del(const char *tag, const char *alias);
|
||||||
|
|
||||||
EAPI const Eina_List *e_configure_option_category_list(void);
|
EAPI const Eina_List *e_configure_option_category_list(void);
|
||||||
EAPI const Eina_List *e_configure_option_category_list_tags(const char *cat);
|
EAPI const Eina_List *e_configure_option_category_list_tags(const char *cat);
|
||||||
EAPI void e_configure_option_category_tag_add(const char *cat, const char *tag);
|
EAPI void e_configure_option_category_tag_add(const char *cat, const char *tag);
|
||||||
|
|
|
@ -160,6 +160,9 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
||||||
|
|
||||||
e_config_domain_save("module.fileman", conf_edd, fileman_config);
|
e_config_domain_save("module.fileman", conf_edd, fileman_config);
|
||||||
e_configure_option_category_tag_del(_("files"), _("files"));
|
e_configure_option_category_tag_del(_("files"), _("files"));
|
||||||
|
e_configure_option_tag_alias_del(_("files"), _("filemanager"));
|
||||||
|
e_configure_option_tag_alias_del(_("files"), _("file manager"));
|
||||||
|
|
||||||
E_CONFIGURE_OPTION_LIST_CLEAR(cfg_opts);
|
E_CONFIGURE_OPTION_LIST_CLEAR(cfg_opts);
|
||||||
_e_mod_fileman_config_free();
|
_e_mod_fileman_config_free();
|
||||||
E_CONFIG_DD_FREE(conf_edd);
|
E_CONFIG_DD_FREE(conf_edd);
|
||||||
|
@ -465,6 +468,9 @@ _e_mod_fileman_config_load(void)
|
||||||
co->info = eina_stringshare_add("fileman/file_icons");
|
co->info = eina_stringshare_add("fileman/file_icons");
|
||||||
E_CONFIGURE_OPTION_ICON(co, "preferences-file-icons");
|
E_CONFIGURE_OPTION_ICON(co, "preferences-file-icons");
|
||||||
cfg_opts = eina_inlist_append(cfg_opts, EINA_INLIST_GET(co));
|
cfg_opts = eina_inlist_append(cfg_opts, EINA_INLIST_GET(co));
|
||||||
|
|
||||||
|
e_configure_option_tag_alias_add(_("files"), _("filemanager"));
|
||||||
|
e_configure_option_tag_alias_add(_("files"), _("file manager"));
|
||||||
}
|
}
|
||||||
|
|
||||||
e_config_save_queue();
|
e_config_save_queue();
|
||||||
|
|
Loading…
Reference in New Issue