Page MenuHome

Add file browser operator to edit directory field
ClosedPublic

Authored by Damien Picard (pioverfour) on Jun 14 2022, 7:14 PM.

Details

Summary

This allows using a shortcut from the file browser to edit the directory path. The shortcut Ctrl + L is quite standard and used in multiple GNU/Linux desktop desktop environments, Windows, as well as most web browsers. Safari on macOS uses Cmd + L.

This allows workflows such as copying a path from the command line or file explorer, then pasting it into the field without having to select it using the mouse.
The reverse can also be practical: running Save As, copying the address to the blend file, then escaping and pasting it into a terminal or file explorer, as in the following video:

The new operator is simply a duplication of FILE_OT_start_filter, I don’t know if there is a better way to do that.

Diff Detail

Event Timeline

Damien Picard (pioverfour) requested review of this revision.Jun 14 2022, 7:14 PM
Damien Picard (pioverfour) created this revision.

This feature was actually mentioned in D6941 already, from which this code is copied, as well as requested here.
@Jacques Lucke (JacquesLucke), you mentioned the UI team should be involved to validate the addition of a shortcut; should I add it as reviewer?

Looks good to me. Will also add @Julian Eisel (Severin) as reviewer in case he has some thoughts about this before.

Julian Eisel (Severin) requested changes to this revision.Jun 16 2022, 4:32 PM

Nice, thank you!

Code looks fine, I'd just change the name from Edit Directoy to Edit Directory Path. You're editing the path, not the directory itself :)

source/blender/editors/space_file/file_ops.c
2958–2960

These can be const.

2981

This should get a better name, Directory is not an action. Suggest Edit Directory Path

This revision now requires changes to proceed.Jun 16 2022, 4:32 PM
  • Rename edit_directory to edit_directory_path
  • const types
This revision is now accepted and ready to land.Jun 16 2022, 6:15 PM
Damien Picard (pioverfour) marked 2 inline comments as done.Jun 16 2022, 6:18 PM

Thank you to you two for the review!

You’re right about the naming, I wasn’t too sure, either.

source/blender/editors/space_file/file_ops.c
2958–2960

Should this be applied to the function this was copied from, file_start_filter_exec() as well?

source/blender/editors/space_file/file_ops.c
2958–2960

Wasn't worth the hassle to create a patch, and then having to apply and commit it separately. So I just committed rB650d2f863dca.