hi all, here i attach the patch wich will add the functionality to add menu items outside the main routines of creating the menu. the idea is basically this:
on the function where the e_menu_new is called
1. set the category of the menu (i.e "fileman/action")
2. set some data to be passed to every callback that registers with
this category
on the client (modules, or whatever)
1. e_menu_category_callback_set("fileman/action", _callback_create,
_callback_free, local_data);
callback_create: will be called when the menu is activated will
receive the menu, the category data and local_data. here you have to
create the menu item or do whatever you want to do
callback_delete: will be called when the menu is freed, will receive
the local data
and thats it. some advice, the logic on the create-free should be the
same as in other parts of the e code, set some condition before the
menu item is going to be created or you will end with duplicate items
implementation:
a hash for the menus categories, the data is the E_Menu_Category wich
have a list of callbacks. when a menu is activated it checks the
category of the menu, find the category in the hash and call all the
callbacks on the list. the same procedure to the delete callback but
when the menu is freed.
notes:
all the menu items are created as usual, appended to the list of
items, the problem is that they will always appear at the end of the
menu. maybe should be done some kind of fixed positoin where to put
this items, or better be able to mark some items as fixed at the
end-beginning
ive already tested, and it does work, but any discussion, comments
would be appreciated.
thanks.
menu_items.diff.gz
Description: GNU Zip compressed data
