Enlightenment CVS committal Author : devilhorns Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_fm.c e_theme.h e_theme.c e_fm_mime.c Log Message: Add context menu for setting themes from efm. Fix e_fm_mime returns. =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_fm.c,v retrieving revision 1.217 retrieving revision 1.218 diff -u -3 -r1.217 -r1.218 --- e_fm.c 14 Oct 2007 16:09:51 -0000 1.217 +++ e_fm.c 14 Oct 2007 17:31:27 -0000 1.218 @@ -360,6 +360,7 @@ 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 @@ } /* 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,31 +6923,44 @@ Evas_List *ll = NULL; 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); + e_menu_item_separator_set(mi, 1); + + for (ll = l; ll; ll = ll->next) { - mi = e_menu_item_new(mn); - e_menu_item_separator_set(mi, 1); + 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; - 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); - } + 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 =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_theme.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- e_theme.h 29 Apr 2006 03:51:27 -0000 1.9 +++ e_theme.h 14 Oct 2007 17:31:27 -0000 1.10 @@ -26,6 +26,9 @@ 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 =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_theme.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -3 -r1.28 -r1.29 --- e_theme.c 28 Dec 2006 14:29:39 -0000 1.28 +++ e_theme.c 14 Oct 2007 17:31:27 -0000 1.29 @@ -28,14 +28,21 @@ 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 @@ 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); @@ -460,6 +469,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 */ =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_fm_mime.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- e_fm_mime.c 14 Oct 2007 15:25:57 -0000 1.22 +++ e_fm_mime.c 14 Oct 2007 17:31:27 -0000 1.23 @@ -172,7 +172,7 @@ 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 @@ 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 @@ 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); } } ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs