diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index b661c681b..46636f607 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -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_sel_rect_update(void *data); 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 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 */ - 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); _e_fm2_context_menu_append(l, mn, ic); if (l) evas_list_free(l); @@ -6922,33 +6923,46 @@ _e_fm2_context_menu_append(Evas_List *l, E_Menu *mn, E_Fm2_Icon *ic) Evas_List *ll = NULL; E_Menu_Item *mi; - if (l) - { - mi = e_menu_item_new(mn); - e_menu_item_separator_set(mi, 1); + if (!l) return; + + l = evas_list_sort(l, -1, _e_fm2_context_list_sort); + mi = e_menu_item_new(mn); + e_menu_item_separator_set(mi, 1); - for (ll = l; ll; ll = ll->next) - { - E_Fm2_Mime_Handler *handler = NULL; - E_Fm2_Context_Menu_Data *md = NULL; - - handler = ll->data; - if (!handler) continue; - md = E_NEW(E_Fm2_Context_Menu_Data, 1); - if (!md) continue; - _e_fm2_menu_contexts = evas_list_append(_e_fm2_menu_contexts, md); - - md->icon = ic; - md->handler = handler; - mi = e_menu_item_new(mn); - e_menu_item_label_set(mi, handler->label); - if (handler->icon_group) - e_util_menu_item_edje_icon_set(mi, handler->icon_group); - e_menu_item_callback_set(mi, _e_fm2_icon_menu_item_cb, md); - } + for (ll = l; ll; ll = ll->next) + { + E_Fm2_Mime_Handler *handler = NULL; + E_Fm2_Context_Menu_Data *md = NULL; + + handler = ll->data; + if (!handler) continue; + md = E_NEW(E_Fm2_Context_Menu_Data, 1); + if (!md) continue; + _e_fm2_menu_contexts = evas_list_append(_e_fm2_menu_contexts, md); + + md->icon = ic; + md->handler = handler; + + mi = e_menu_item_new(mn); + e_menu_item_label_set(mi, handler->label); + if (handler->icon_group) + e_util_menu_item_edje_icon_set(mi, handler->icon_group); + 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 _e_fm2_icon_menu_post_cb(void *data, E_Menu *m) { diff --git a/src/bin/e_fm_mime.c b/src/bin/e_fm_mime.c index 9723df942..8ace87351 100644 --- a/src/bin/e_fm_mime.c +++ b/src/bin/e_fm_mime.c @@ -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))) { handlers = evas_list_append(handlers, handler); - _mime_handlers = evas_hash_modify(_mime_handlers, mime, handlers); + evas_hash_modify(_mime_handlers, mime, handlers); } 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))) { handlers = evas_list_append(handlers, handler); - _glob_handlers = evas_hash_modify(_glob_handlers, glob, handlers); + evas_hash_modify(_glob_handlers, glob, handlers); } else { @@ -362,8 +362,8 @@ static Evas_Bool _e_fm2_mime_handler_glob_match_foreach(Evas_Hash *hash, const c handlers = data; for (l = handlers; l; l = l->next) { - if (handlers->data) - tuple->list = evas_list_append(tuple->list, handlers->data); + if (l->data) + tuple->list = evas_list_append(tuple->list, l->data); } } diff --git a/src/bin/e_theme.c b/src/bin/e_theme.c index 5115deed4..3daf013b4 100644 --- a/src/bin/e_theme.c +++ b/src/bin/e_theme.c @@ -28,14 +28,21 @@ static Evas_List *categories = NULL; static Evas_List *transitions = NULL; static Evas_List *borders = NULL; static Evas_List *shelfs = NULL; +static E_Fm2_Mime_Handler *theme_hdl = NULL; /* externally accessible functions */ EAPI int 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 */ /* always fall back to the default theme. the rest after this are config */ /* values users can set */ @@ -96,6 +103,8 @@ e_theme_init(void) EAPI int e_theme_shutdown(void) { + if (theme_hdl) e_fm2_mime_handler_free(theme_hdl); + if (mappings) { evas_hash_foreach(mappings, _e_theme_mappings_free_cb, NULL); @@ -462,6 +471,33 @@ e_theme_shelf_list(void) 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 */ static Evas_Bool _e_theme_mappings_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata) diff --git a/src/bin/e_theme.h b/src/bin/e_theme.h index bb4e23781..364413fd8 100644 --- a/src/bin/e_theme.h +++ b/src/bin/e_theme.h @@ -26,6 +26,9 @@ EAPI int e_theme_border_find(const char *border); EAPI Evas_List *e_theme_border_list(void); EAPI int e_theme_shelf_find(const char *shelf); 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