GNOME Bugzilla – Bug 672324
Support usage of freeze_notify in python "with" statement
Last modified: 2012-04-09 12:47:57 UTC
This will allow usage of the method along with the "with" statement. The returned context manager object would then call thaw_notify upon an exception or an exiting of the context. This technique keeps chunks of code that do heavy modification to objects in a frozen state clean and free of potential errors in regards to calling thaw. with obj.freeze_notify(): obj.props.width = 100 obj.props.height = 100 obj.props.opacity = 0.5 See: http://docs.python.org/reference/datamodel.html#context-managers
Created attachment 210494 [details] [review] Added context management to freeze_notify and handler_block These methods now return a context manager object which implement __enter__ and __exit__. Within the __exit__ method thaw_notify and handler_unblock are called respectively. This allows statements like the following: with obj.freeze_notify(): obj.props.width = 100 obj.props.height = 100 obj.props.opacity = 0.5 This does not affect standard usage of these methods. This could have been implemented in python in only a few lines of code, but cannot do to the lack of ability to override GObject methods in python, see: https://bugzilla.gnome.org/show_bug.cgi?id=672727
This looks like a fine, but nice detail indeed, and the patch looks good to me. Thank you! Pushed with some whitespace/grammar fixes.