Enlightenment CVS committal Author : devilhorns Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_fm.c e_bg.h e_bg.c Log Message: E_FM Context Menus :) Big Thanks to CodeWarrior for his help !!! Add context handler for backgrounds. Can now right-click an .edj and Set as Background. =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_fm.c,v retrieving revision 1.215 retrieving revision 1.216 diff -u -3 -r1.215 -r1.216 --- e_fm.c 9 Oct 2007 01:30:25 -0000 1.215 +++ e_fm.c 14 Oct 2007 16:06:51 -0000 1.216 @@ -18,17 +18,18 @@ typedef enum _E_Fm2_Action_Type { FILE_ADD, - FILE_DEL, - FILE_CHANGE + FILE_DEL, + FILE_CHANGE } E_Fm2_Action_Type; -typedef struct _E_Fm2_Smart_Data E_Fm2_Smart_Data; -typedef struct _E_Fm2_Region E_Fm2_Region; -typedef struct _E_Fm2_Finfo E_Fm2_Finfo; -typedef struct _E_Fm2_Action E_Fm2_Action; -typedef struct _E_Fm2_Client E_Fm2_Client; -typedef struct _E_Fm2_Mount E_Fm2_Mount; -typedef struct _E_Fm2_Uri E_Fm2_Uri; +typedef struct _E_Fm2_Smart_Data E_Fm2_Smart_Data; +typedef struct _E_Fm2_Region E_Fm2_Region; +typedef struct _E_Fm2_Finfo E_Fm2_Finfo; +typedef struct _E_Fm2_Action E_Fm2_Action; +typedef struct _E_Fm2_Client E_Fm2_Client; +typedef struct _E_Fm2_Mount E_Fm2_Mount; +typedef struct _E_Fm2_Uri E_Fm2_Uri; +typedef struct _E_Fm2_Context_Menu_Data E_Fm2_Context_Menu_Data; struct _E_Fm2_Smart_Data { @@ -207,6 +208,12 @@ const char *path; }; +struct _E_Fm2_Context_Menu_Data +{ + E_Fm2_Icon *icon; + E_Fm2_Mime_Handler *handler; +}; + static E_Fm2_Mount *_e_fm2_mount(E_Volume *v, void (*mount_ok) (void *data), void (*mount_fail) (void *data), void (*unmount_ok) (void *data), void (*unmount_fail) (void *data), void *data); static void _e_fm2_unmount(E_Fm2_Mount *m); static E_Volume *e_volume_find(const char *udi); @@ -301,6 +308,7 @@ static void _e_fm2_menu_post_cb(void *data, E_Menu *m); static void _e_fm2_icon_menu(E_Fm2_Icon *ic, Evas_Object *obj, unsigned int timestamp); static void _e_fm2_icon_menu_post_cb(void *data, E_Menu *m); +static void _e_fm2_icon_menu_item_cb(void *data, E_Menu *m, E_Menu_Item *mi); static void _e_fm2_refresh(void *data, E_Menu *m, E_Menu_Item *mi); static void _e_fm2_toggle_hidden_files(void *data, E_Menu *m, E_Menu_Item *mi); static void _e_fm2_toggle_ordering(void *data, E_Menu *m, E_Menu_Item *mi); @@ -351,6 +359,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 char *_e_fm2_meta_path = NULL; static Evas_Smart *_e_fm2_smart = NULL; @@ -362,7 +371,7 @@ static Evas_List *_e_stores = NULL; static Evas_List *_e_vols = NULL; static Evas_List *_e_fm2_mounts = NULL; - +static Evas_List *_e_fm2_menu_contexts = NULL; /* contains: * _e_volume_edd @@ -6649,7 +6658,8 @@ E_Manager *man; E_Container *con; E_Zone *zone; - Evas_List *sel; + Evas_List *sel, *l = NULL; + Evas_List *handlers = NULL; int x, y, can_w, can_w2, protect; char buf[4096]; @@ -6861,7 +6871,21 @@ "e/fileman/default/button/properties"), "e/fileman/default/button/properties"); e_menu_item_callback_set(mi, _e_fm2_file_properties, ic); - + + if (ic->info.mime) + { + /* see if we have any mime handlers registered for this file */ + l = e_fm2_mime_handler_mime_handlers_get(ic->info.mime); + _e_fm2_context_menu_append(l, mn, ic); + if (l) evas_list_free(l); + } + + /* see if we have any glob handlers registered for this 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); + if (sd->icon_menu.end.func) sd->icon_menu.end.func(sd->icon_menu.end.data, sd->obj, mn, &(ic->info)); } @@ -6892,6 +6916,38 @@ E_MENU_POP_DIRECTION_DOWN, timestamp); } +static inline void +_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); + + 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); + /* TODO: Add Icon */ + e_menu_item_callback_set(mi, _e_fm2_icon_menu_item_cb, md); + } + } +} + static void _e_fm2_icon_menu_post_cb(void *data, E_Menu *m) { @@ -6899,6 +6955,30 @@ ic = data; ic->menu = NULL; + while (_e_fm2_menu_contexts) + { + E_Fm2_Context_Menu_Data *md; + + md = _e_fm2_menu_contexts->data; + _e_fm2_menu_contexts = evas_list_remove_list(_e_fm2_menu_contexts, + _e_fm2_menu_contexts); + E_FREE(md); + } +} + +static void +_e_fm2_icon_menu_item_cb(void *data, E_Menu *m, E_Menu_Item *mi) +{ + E_Fm2_Context_Menu_Data *md = NULL; + Evas_Object *obj = NULL; + char buf[4096]; + + md = data; + if (!md) return; + obj = md->icon->info.fm; + if (!obj) return; + snprintf(buf, sizeof(buf), "%s/%s", e_fm2_real_path_get(obj), md->icon->info.file); + e_fm2_mime_handler_call(md->handler, obj, buf); } static void =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_bg.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- e_bg.h 20 Oct 2006 03:23:46 -0000 1.9 +++ e_bg.h 14 Oct 2007 16:06:51 -0000 1.10 @@ -11,6 +11,7 @@ } E_Bg_Transition; typedef struct _E_Event_Bg_Update E_Event_Bg_Update; + #else #ifndef E_BG_H #define E_BG_H @@ -35,5 +36,8 @@ EAPI void e_bg_del(int container, int zone, int desk_x, int desk_y); EAPI void e_bg_default_set(char *file); EAPI void e_bg_update(void); +EAPI void e_bg_handler_set(Evas_Object *obj, const char *path, void *data); +EAPI int e_bg_handler_test(Evas_Object *obj, const char *path, void *data); + #endif #endif =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_bg.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- e_bg.c 12 Oct 2007 18:36:48 -0000 1.30 +++ e_bg.c 14 Oct 2007 16:06:51 -0000 1.31 @@ -9,6 +9,7 @@ /* local subsystem globals */ EAPI int E_EVENT_BG_UPDATE = 0; +static E_Fm2_Mime_Handler *bg_hdl = NULL; /* externally accessible functions */ EAPI int @@ -16,6 +17,12 @@ { Evas_List *l = NULL; + /* Register mime handler */ + bg_hdl = e_fm2_mime_handler_new(_("Set As Background"), NULL, + e_bg_handler_set, NULL, + e_bg_handler_test, NULL); + e_fm2_mime_handler_glob_add(bg_hdl, "*.edj"); + /* Register files in use */ if (e_config->desktop_default_background) e_filereg_register(e_config->desktop_default_background); @@ -38,7 +45,10 @@ { Evas_List *l = NULL; - /* Register files in use */ + /* Deregister mime handler */ + if (bg_hdl) e_fm2_mime_handler_free(bg_hdl); + + /* Deregister files in use */ if (e_config->desktop_default_background) e_filereg_deregister(e_config->desktop_default_background); @@ -330,8 +340,32 @@ } } -/* local subsystem functions */ +EAPI void +e_bg_handler_set(Evas_Object *obj, const char *path, void *data) +{ + E_Container *con; + E_Zone *zone; + E_Desk *desk; + + if (!path) return; + con = e_container_current_get(e_manager_current_get()); + zone = e_zone_current_get(con); + desk = e_desk_current_get(zone); + e_bg_del(con->num, zone->num, desk->x, desk->y); + e_bg_add(con->num, zone->num, desk->x, desk->y, (char *)path); + e_bg_update(); + e_config_save_queue(); +} + +EAPI int +e_bg_handler_test(Evas_Object *obj, const char *path, void *data) +{ + if (!path) return 0; + if (edje_file_group_exists(path, "e/desktop/background")) return 1; + return 0; +} +/* local subsystem functions */ static void _e_bg_signal(void *data, Evas_Object *obj, const char *emission, const char *source) { ------------------------------------------------------------------------- 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