forked from enlightenment/enlightenment
Add context menu for setting themes from efm.
Fix e_fm_mime returns. SVN revision: 32070
This commit is contained in:
parent
08ca1d1e04
commit
511e3c1b8a
|
@ -360,6 +360,7 @@ static void _e_fm2_client_mount(const char *udi, const char *mountpoint);
|
||||||
static void _e_fm2_client_unmount(const char *udi);
|
static void _e_fm2_client_unmount(const char *udi);
|
||||||
static void _e_fm2_sel_rect_update(void *data);
|
static void _e_fm2_sel_rect_update(void *data);
|
||||||
static inline void _e_fm2_context_menu_append(Evas_List *l, E_Menu *mn, E_Fm2_Icon *ic);
|
static inline void _e_fm2_context_menu_append(Evas_List *l, E_Menu *mn, E_Fm2_Icon *ic);
|
||||||
|
static int _e_fm2_context_list_sort(void *data1, void *data2);
|
||||||
|
|
||||||
static char *_e_fm2_meta_path = NULL;
|
static char *_e_fm2_meta_path = NULL;
|
||||||
static Evas_Smart *_e_fm2_smart = NULL;
|
static Evas_Smart *_e_fm2_smart = NULL;
|
||||||
|
@ -6881,7 +6882,7 @@ _e_fm2_icon_menu(E_Fm2_Icon *ic, Evas_Object *obj, unsigned int timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* see if we have any glob handlers registered for this file */
|
/* see if we have any glob handlers registered for this file */
|
||||||
snprintf(buf, sizeof(buf), "*.%s", strrchr(ic->info.file, '.'));
|
snprintf(buf, sizeof(buf), "*%s", strrchr(ic->info.file, '.'));
|
||||||
l = e_fm2_mime_handler_glob_handlers_get(buf);
|
l = e_fm2_mime_handler_glob_handlers_get(buf);
|
||||||
_e_fm2_context_menu_append(l, mn, ic);
|
_e_fm2_context_menu_append(l, mn, ic);
|
||||||
if (l) evas_list_free(l);
|
if (l) evas_list_free(l);
|
||||||
|
@ -6922,8 +6923,9 @@ _e_fm2_context_menu_append(Evas_List *l, E_Menu *mn, E_Fm2_Icon *ic)
|
||||||
Evas_List *ll = NULL;
|
Evas_List *ll = NULL;
|
||||||
E_Menu_Item *mi;
|
E_Menu_Item *mi;
|
||||||
|
|
||||||
if (l)
|
if (!l) return;
|
||||||
{
|
|
||||||
|
l = evas_list_sort(l, -1, _e_fm2_context_list_sort);
|
||||||
mi = e_menu_item_new(mn);
|
mi = e_menu_item_new(mn);
|
||||||
e_menu_item_separator_set(mi, 1);
|
e_menu_item_separator_set(mi, 1);
|
||||||
|
|
||||||
|
@ -6940,6 +6942,7 @@ _e_fm2_context_menu_append(Evas_List *l, E_Menu *mn, E_Fm2_Icon *ic)
|
||||||
|
|
||||||
md->icon = ic;
|
md->icon = ic;
|
||||||
md->handler = handler;
|
md->handler = handler;
|
||||||
|
|
||||||
mi = e_menu_item_new(mn);
|
mi = e_menu_item_new(mn);
|
||||||
e_menu_item_label_set(mi, handler->label);
|
e_menu_item_label_set(mi, handler->label);
|
||||||
if (handler->icon_group)
|
if (handler->icon_group)
|
||||||
|
@ -6947,6 +6950,17 @@ _e_fm2_context_menu_append(Evas_List *l, E_Menu *mn, E_Fm2_Icon *ic)
|
||||||
e_menu_item_callback_set(mi, _e_fm2_icon_menu_item_cb, md);
|
e_menu_item_callback_set(mi, _e_fm2_icon_menu_item_cb, md);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_e_fm2_context_list_sort(void *data1, void *data2)
|
||||||
|
{
|
||||||
|
E_Fm2_Mime_Handler *d1, *d2;
|
||||||
|
|
||||||
|
if (!data1) return 1;
|
||||||
|
if (!data2) return -1;
|
||||||
|
d1 = data1;
|
||||||
|
d2 = data2;
|
||||||
|
return (strcmp(d1->label, d2->label));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -172,7 +172,7 @@ e_fm2_mime_handler_mime_add(E_Fm2_Mime_Handler *handler, const char *mime)
|
||||||
if ((handlers = evas_hash_find(_mime_handlers, mime)))
|
if ((handlers = evas_hash_find(_mime_handlers, mime)))
|
||||||
{
|
{
|
||||||
handlers = evas_list_append(handlers, handler);
|
handlers = evas_list_append(handlers, handler);
|
||||||
_mime_handlers = evas_hash_modify(_mime_handlers, mime, handlers);
|
evas_hash_modify(_mime_handlers, mime, handlers);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -196,7 +196,7 @@ e_fm2_mime_handler_glob_add(E_Fm2_Mime_Handler *handler, const char *glob)
|
||||||
if ((handlers = evas_hash_find(_glob_handlers, glob)))
|
if ((handlers = evas_hash_find(_glob_handlers, glob)))
|
||||||
{
|
{
|
||||||
handlers = evas_list_append(handlers, handler);
|
handlers = evas_list_append(handlers, handler);
|
||||||
_glob_handlers = evas_hash_modify(_glob_handlers, glob, handlers);
|
evas_hash_modify(_glob_handlers, glob, handlers);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -362,8 +362,8 @@ static Evas_Bool _e_fm2_mime_handler_glob_match_foreach(Evas_Hash *hash, const c
|
||||||
handlers = data;
|
handlers = data;
|
||||||
for (l = handlers; l; l = l->next)
|
for (l = handlers; l; l = l->next)
|
||||||
{
|
{
|
||||||
if (handlers->data)
|
if (l->data)
|
||||||
tuple->list = evas_list_append(tuple->list, handlers->data);
|
tuple->list = evas_list_append(tuple->list, l->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,13 +28,20 @@ static Evas_List *categories = NULL;
|
||||||
static Evas_List *transitions = NULL;
|
static Evas_List *transitions = NULL;
|
||||||
static Evas_List *borders = NULL;
|
static Evas_List *borders = NULL;
|
||||||
static Evas_List *shelfs = NULL;
|
static Evas_List *shelfs = NULL;
|
||||||
|
static E_Fm2_Mime_Handler *theme_hdl = NULL;
|
||||||
|
|
||||||
/* externally accessible functions */
|
/* externally accessible functions */
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
e_theme_init(void)
|
e_theme_init(void)
|
||||||
{
|
{
|
||||||
Evas_List *l;
|
Evas_List *l = NULL;
|
||||||
|
|
||||||
|
/* Register mime handler */
|
||||||
|
theme_hdl = e_fm2_mime_handler_new(_("Set As Theme"), "enlightenment/themes",
|
||||||
|
e_theme_handler_set, NULL,
|
||||||
|
e_theme_handler_test, NULL);
|
||||||
|
e_fm2_mime_handler_glob_add(theme_hdl, "*.edj");
|
||||||
|
|
||||||
/* this is a fallback that is ALWAYS there - if all fails things will */
|
/* this is a fallback that is ALWAYS there - if all fails things will */
|
||||||
/* always fall back to the default theme. the rest after this are config */
|
/* always fall back to the default theme. the rest after this are config */
|
||||||
|
@ -96,6 +103,8 @@ e_theme_init(void)
|
||||||
EAPI int
|
EAPI int
|
||||||
e_theme_shutdown(void)
|
e_theme_shutdown(void)
|
||||||
{
|
{
|
||||||
|
if (theme_hdl) e_fm2_mime_handler_free(theme_hdl);
|
||||||
|
|
||||||
if (mappings)
|
if (mappings)
|
||||||
{
|
{
|
||||||
evas_hash_foreach(mappings, _e_theme_mappings_free_cb, NULL);
|
evas_hash_foreach(mappings, _e_theme_mappings_free_cb, NULL);
|
||||||
|
@ -462,6 +471,33 @@ e_theme_shelf_list(void)
|
||||||
return shelfs;
|
return shelfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_theme_handler_set(Evas_Object *obj, const char *path, void *data)
|
||||||
|
{
|
||||||
|
E_Action *a;
|
||||||
|
|
||||||
|
if (!path) return;
|
||||||
|
e_theme_config_set("theme", path);
|
||||||
|
e_config_save_queue();
|
||||||
|
a = e_action_find("restart");
|
||||||
|
if ((a) && (a->func.go)) a->func.go(NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
e_theme_handler_test(Evas_Object *obj, const char *path, void *data)
|
||||||
|
{
|
||||||
|
E_Config_Theme *ct;
|
||||||
|
|
||||||
|
if (!path) return 0;
|
||||||
|
|
||||||
|
/* test is this theme is already set */
|
||||||
|
ct = e_theme_config_get("theme");
|
||||||
|
if ((ct) && (!strcmp(ct->file, path))) return 0;
|
||||||
|
if (!edje_file_group_exists(path, "e/widgets/border/default/border"))
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* local subsystem functions */
|
/* local subsystem functions */
|
||||||
static Evas_Bool
|
static Evas_Bool
|
||||||
_e_theme_mappings_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
|
_e_theme_mappings_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
|
||||||
|
|
|
@ -27,5 +27,8 @@ EAPI Evas_List *e_theme_border_list(void);
|
||||||
EAPI int e_theme_shelf_find(const char *shelf);
|
EAPI int e_theme_shelf_find(const char *shelf);
|
||||||
EAPI Evas_List *e_theme_shelf_list(void);
|
EAPI Evas_List *e_theme_shelf_list(void);
|
||||||
|
|
||||||
|
EAPI void e_theme_handler_set(Evas_Object *obj, const char *path, void *data);
|
||||||
|
EAPI int e_theme_handler_test(Evas_Object *obj, const char *path, void *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue