Enable / disable dangerous timeline keyboard shortcuts by handling focus events directly in the timeline and ruler widgets
Submitted by Jeff F.T.
Assigned to Jeff F.T.
In mainwindow, we have a "setActionsSensitive" method that basically just allows disabling or enabling the global keyboard shortcuts related to the timeline, including:
- Space to play/pause
- Delete to remove clips
- S to split clips
Even after fixing various issues throughout time (bug #T2604, bug #T2381, and various unreported problems that were solved through many commits related to "actions"), there are still some bugs with it.
For example: select a clip on the timeline, focus a gtk widget that is supposedly protected (such as an effect property spinbutton, or the media library's search widget), try pressing Delete and the clip is not deleted... but then click the clip again, click the search widget again, press Delete and... whoops, the clip is gone! That's because we were relying on focus events on the search widget, but the focus didn't change.
And that's the case all over the place.
Turns out that the way we handle this is all backwards.
The cleaner and (probably) safer way is to set the can-focus (can_focus) property on the timeline canvas and on the ruler widget, and then connect them to their focus-in-event and focus-out-event to handle the setActionsSensitive stuff there and only there. As far as I can see, if you handle it in those two widgets, no need to handle it anywhere else anymore. Epic win.
But then, at this point you might start thinking that setActionsSensitive probably shouldn't be in mainwindow anymore (should it be in timeline/timeline.py?), and might also be named differently...
This is all so exciting, I'll certainly make a patch for this soon ;)
Imported from https://bugzilla.gnome.org/show_bug.cgi?id=707828