I would like to build a bunch of little custom actions in Thunar, but I can't get to organise them properly since I don't know how to make 'child menus' (like that Create Document and in the screenshot below). Anyway, if I were to right-click somewhere empty in a folder in Thunar, a little menu pops up:
...etc. I'm sure you can see what I mean. Since I could not find the way to do that, I decided to go with Templates (~/Templates), but for some reason Thunar is displaying some generic icon instead of (in this case) Python's icon (I'm referring to Script):
As we have talked on #xfce-dev, in order to accomplish what you ask, thunar-custom-actions plugin needs to be updated to make use of ThunarxMenu to nest ThunarxMenuItems (not that hard). Also its dialog needs to somehow allow users to create/edit/move submenus, perhaps using GtkTreeView or a custom widget (this is the tricky part).
It's not a simple feature, don't expect me on it soon, on the other hand, patches will be reviewed/merged ASAP.
I'm not sure thunar-actions-plugin is in good shape, it targets thunarx-1, depends on thunar-vfs (superseded by gfvs a long time ago) and it's been 8 years since it was touched, for those reasons I asked to be archived. I also suspect it doesn't works, taking a quick look it seems the code is too short to accomplish what it advertises.
And I agree, it's preferable to introduce its features in UCA than resurrect it.
There is the sendto plugin that does this. A simple copy of it, with another name for the submenu, and its own folder for custom actions(sendto uses ~/.local/share/Thunar/sendto/), and removal of default actions, imo it should be enough.
@mg979 not exactly. sendto-email plugin just installs a desktop file in <prefix>/share/Thunar that runs an executable (i.e. /usr/lib/Thunar/thunar-sendto-email). Thunar loads files from this folder and insert their entries in Send To context menu, it's hard coded and does not use the Thunar Extension Framework (thunarx) in any way. What you propose is similar but not as good as to what bug 14114 and bug 14024 ask IMHO.
Still there's the question of how the user tells to Thunar to nest actions into submenus, what first comes to my mind is to update UCA's dialog as I explained in comment 1, but now that we're talking about actions into separated desktop files instead of uca.xml, using folders to nest desktop files and then create submenus based on those folder could be a simpler approach.
This feature has been requested repeatedly over several years. Custom actions are a very cool feature of Thunar, but only "power users" are likely to figure it out. Shortly after figuring out the feature, the user is going to quickly discover just how limited its presentation becomes (a linear list of 15 custom actions isn't especially navigable).
The objection seems to be related to difficulty implementing the graphical user interface for supporting such a feature. Fine. What about supporting multiple-level menu parsing within the uca.xml file? It's not ideal, but it's better than the proposed alternatives (none of which seem to work in 2020 BTW) and at least it's a step in right direction.
The objection seems to be related to difficulty implementing the graphical user interface for supporting such a feature. Fine. What about supporting multiple-level menu parsing within the uca.xml file?
The major problem is, that so far nobody raised his hand to work on it :) .. you are interested to work on it ?
I suppose there are different possible approaches ... I did not check the possibilities. Not clear to me what you mean by "multi level menu parsing in uca.xml".
According to #53 (closed) dolphin uses .desktop files for that purpose (though I as well did not check that).
I'm considering this to be handled only via UI, asking users to edit XML files is a recipe for trouble (they still can, but at their own risk).
Another thing that I thought is making menus hierarchy flat, the users can either add entries to the context menu's root or inside submenus, but not nested submenus. This should cover most of needs while keeping things simpler (and less buggy).
Alexander, it has previously been pointed out that the right-click context Menu in Thunar DID previously support custom action submenus (maybe back at Gtk+/Gtk2). If I were to make a contribution, it would likely involve reviewing that old source and attempting to port the feature. Sounds cringingly hackish, but I don't have a sufficient background with the codebase or Gtk to do better. I can try if it still sounds vaguely useful, but it wouldn't address Andre's desire to get the edit feature into a UI.
Andre, the current suggestions for adding user customizable submenus are a LOT more risky / buggy than editing an XML file (and don't work now anyway). Is it really asking that much to tell a power user to open the XML file and enclose the desired group of submenu items with code like <submenu name="My Custom Submenu">...</submenu>? The existing UI element could simply ignore the submenu tag and present custom items as a flat file (or use an interface like your UI graphic where the left panel is the "name=" attribute in the sample XML).
If I'm understanding your image correctly and you're saying limit the submenus to a single level deep, then it's perfect. I wasn't suggesting support of infinite nested submenu levels. This allows a linear list of 20 custom actions to be grouped in a logical set of 4 root items with 5 custom actions under each. Much friendly than an enormous menu list popping up ;-)
Matthew, please feel free to take I try for the old approach and resurrect that old plugin, if you think it is more promising /costs less work.
Though I doubt so, because menu-creation logic itself changed alot meanwhile .. however it might help to look into the old code and copy parts of the uca.xml aspects (I dont even know if subemnu-info was stored inside uca.xml in the old days)
Is it really asking that much to tell a power user to open the XML file and enclose the desired group of submenu items
IMO as well non-power users should be able to use that feature sooner or later :) Ofc there is no problem with starting on a raw XML approach. Though on the long run, we as well should provide a GUI option.
Compiling this on Raspbian, so I'll need to work on the xfce-4.12 branch. However, a quick perusal of the master branch suggests that there's a simple solution that should work with the existing UI and allow for future UI improvements.
In thunar/thunar-launcher.c, in the function thunar_launcher_append_custom_actions around line 2011 there is gtk_menu_item = thunar_gtk_menu_thunarx_menu_item_new (lp_item->data, menu); that looks like a reasonable place to modify to push these custom actions into submenus.
Within the aforementioned thunar-launcher.c, simple logic based would consider a sub-menu delimiter (>), e.g.:
if (custom_action_name contains '>') { // Split on > and push 2nd element into submenu } else { // This is a root level custom action, just default to root menu gtk_menu_items = thunar_gtk_menu_thunarx_menu_item_new(lp_item->data, menu); }
Configuring submenus via UI is now accomplished quite simply by naming convention. For example, two custom actions named like "Compress > Zip" and "Compress > Gzip" would have a parent menu entry of "Compress" with submenu entries of Zip and Gzip.
The above approach would work as a transitional solution. The longer term solution might be as simple as adding a dropdown preceding the existing Name: textbox, e.g.: [Root/Compress/Custom Action/Other Custom Action] / []. Adding such a drop-down might necessitate a checkbox, like "[ ] Group Name" that, when checked, would disable the Command and Keyboard Shortcut fields. Internally, the arrow separator could continue to be used within custom action string (or possible a '/' to be consistent with a pathname approach).
This approach eliminates the need to touch uca.xml, does not alter the existing uca.xml conventions, doesn't require the need for additional keyword(s), and removes the need for a treelist menu in the UI.
Within the xfce-4.12 code branch, it looks like code would go inside the for (lp = actions; lp != NULL; lp = lp->next) loop around line 2082, but it's a lot less clear how one would create a submenu here.
Is the latest code in the master branch likely to break Thunar under XFCE-4.12 or would a corresponding upgrade be required for XFCE as well?
Ok for me to use the delimeter approach, though I would use '/' over '>' as delimeter.
For building (sub) menus, there is already recursive functionality for that in thunar_gtk_menu_thunarx_menu_item_new .. e.g. RabbitVCS makes use of it .. that part already works within thunar-master.
I suppose you need to define the thunarx_menu for UCA's in some way, so that the recursive part is called.
Is the latest code in the master branch likely to break Thunar under XFCE-4.12 or would a corresponding upgrade be required for XFCE as well?
Not sure what you are asking for here .. how could the current thunar master "break" thunar 4.12 ? I suppose you would need all the old dependencies installed, using the old API-level. If you realy want to do that, I would advice a virtual machine or container. Though I suppose it would not be worth the trouble.
I really like both proposed solutions, they are very simple, but I would go with the second one, a text field within the custom action edit dialog where users could type the Group or Category name, if empty the UCA is to be created on the context menu root.
And forget about 4.12, that's not maintained anymore, such feature might be backported to 4.16, for sure not 4.14.
Hopefully this will inspire the programming work for custom action submenus for some not-too-distant version of Thunar/XFCE. My build system ATM (Pi) isn't set up to be able to build for XFCE 4.16+ (and far from ideal for VM).