Page MenuHome

UI: FILE_OT_rename Poll Function
Needs ReviewPublic

Authored by Harley Acheson (harley) on Feb 27 2021, 4:17 AM.

Details

Reviewers
Julian Eisel (Severin)
Group Reviewers
User Interface
Summary

Poll function for File Rename that ensures that exactly one file
browser item is selected.


This is just a custom poll function for FILE_OT_rename.

It currently only checks if File Browser is in use. Therefore it is enabled when nothing is selected and just fails silently if you select it. Similarly it is enabled when more than one file is selected and therefore hard to tell which one it will operate on.

The patch checks if File Browser is active, not in Asset browser, that we are not browsing in a library, and that exactly one file is selected.

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Feb 27 2021, 4:17 AM
Harley Acheson (harley) created this revision.

It might be nice to have a poll message set when the number of selected files is greater than 1. It's obvious that you can't rename with no selected files, but with more than one it might not be completely obvious.

@Hans Goudey (HooglyBoogly) - It might be nice to have a poll message set when the number of selected files is greater than 1...

Good idea! I've never used that CTX_wm_operator_poll_msg_set() before; seems useful.

Done.

updated to current state of master

updated to current state of master.

Harley Acheson (harley) edited the summary of this revision. (Show Details)

Updating to current state of master.

Julian Eisel (Severin) requested changes to this revision.Sep 20 2021, 3:49 PM

I think what this should do is just check if there is an active item (params.active_file) and if that is selected (using filelist_entry_select_index_get()). Because that is the file it's gonna operate on. And I think it makes sense to disable renaming if the active file isn't selected (that's just confusing).

This revision now requires changes to proceed.Sep 20 2021, 3:49 PM

@Julian Eisel (Severin) - should do is just check if there is an active item...

I added checks for active_file and that active_file is also selected. But I think we still need the other checks in here, like making sure that multiple files are not selected.

I think it's fine to have multiple files selected and invoking renaming. It just uses the active one.

source/blender/editors/space_file/file_ops.c
2841

ot->poll = ot->poll =? :)

@Julian Eisel (Severin) - I think it's fine to have multiple files selected and invoking renaming. It just uses the active one.

But we don't show active File Browser item different from selected items. So if you have multiple items selected and then choose "rename", just a single random item will be renamed. Removing that confusion is part of the reason for this