! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
[PATCH] Add functionality to allow extensions to create submenus
Status:
RESOLVED: WONTFIX
Severity:
enhancement

Comments

Description Adam Plumb editbugs 2009-12-15 17:08:07 CET
Created attachment 2739 
Patch file

I've written a patch that will allow thunar extensions to create submenus.  It required creating a new function that would be called recursively in order to add new submenu levels.

I'd appreciate it if you could look specifically at the memory management in the new _add_custom_actions function, as I'm still pretty new to gobject memory management.  I tried to match the style and conventions used in the rest of the code, but please correct me if anything isn't up to par.

Thanks.
Adam
Comment 1 Adam Plumb editbugs 2009-12-15 17:09:41 CET
Created attachment 2740 
Modified thunar-wallpaper plugin file to demonstrate submenus

I've added twp-provider.c to demonstrate how one would add a submenu and items.  This replaces /thunar/plugins/thunar-wallpaper/twp-provider.c.
Comment 2 Benedikt Meurer editbugs 2009-12-15 17:32:01 CET
It's already possible to attach submenus to folder actions. Just subclass GtkAction and implement create_menu_item() as appropriate. Thunar itself does this in various places. This way you don't need to create GtkAction's for the submenu items, but you can fill it on demand with GtkMenuItem's. See the template action for an example.
Comment 3 Adam Plumb editbugs 2009-12-15 18:13:23 CET
I noticed that thunar-vcs-plugin subclasses GtkAction as well.  However, do you need a separate subclass for each GtkAction that has a submenu, or can you just have a MyGtkAction subclass that you can use to create arbitrary submenus to an arbitrary level?
Comment 4 Benedikt Meurer editbugs 2009-12-16 18:23:52 CET
Well, a single class would do, depending on what you put into the create_menu_item() method.
Comment 5 Adam Plumb editbugs 2009-12-17 19:26:47 CET
(In reply to comment #4)
> Well, a single class would do, depending on what you put into the
> create_menu_item() method.

While it may be possible to do this with a GtkAction subclass, I think it would be quite a bit simpler to just use a GtkAction and be able to create submenus and sub-submenus in an intuitive and relatively straightforward fashion.  My patch is fairly small and doesn't add much complexity.

Bug #6085

Reported by:
Adam Plumb
Reported on: 2009-12-15
Last modified on: 2012-09-26

People

Assignee:
Jannis Pohlmann
CC List:
2 users

Version

Attachments

Patch file (7.50 KB, patch)
2009-12-15 17:08 CET , Adam Plumb
no flags
Modified thunar-wallpaper plugin file to demonstrate submenus (3.96 KB, text/x-csrc)
2009-12-15 17:09 CET , Adam Plumb
no flags

Additional information