diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-04-21 07:21:23 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-04-21 08:05:14 +0200 |
commit | ea358359a34ad96bf395641911aeaf80182d3aad (patch) | |
tree | 8007a55c64a251b60f54c3e2bbe1f46e606544db /gi/overrides/Gtk.py | |
parent | d0bfb29fe5b34c58a190e084614fe489771bf53b (diff) | |
download | pygobject-ea358359a34ad96bf395641911aeaf80182d3aad.tar.gz |
Make Gtk.Widget.freeze_child_notify a context manager. Fixes #45widget-freeze-child
Diffstat (limited to 'gi/overrides/Gtk.py')
-rw-r--r-- | gi/overrides/Gtk.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py index 23d06adf..612c07da 100644 --- a/gi/overrides/Gtk.py +++ b/gi/overrides/Gtk.py @@ -118,10 +118,25 @@ def _builder_connect_callback(builder, gobj, signal_name, handler_name, connect_ gobj.connect(signal_name, handler, *args) +class _FreezeNotifyManager(object): + def __init__(self, obj): + self.obj = obj + + def __enter__(self): + pass + + def __exit__(self, exc_type, exc_value, traceback): + self.obj.thaw_child_notify() + + class Widget(Gtk.Widget): translate_coordinates = strip_boolean_result(Gtk.Widget.translate_coordinates) + def freeze_child_notify(self): + super(Widget, self).freeze_child_notify() + return _FreezeNotifyManager(self) + def drag_dest_set_target_list(self, target_list): if (target_list is not None) and (not isinstance(target_list, Gtk.TargetList)): target_list = Gtk.TargetList.new(_construct_target_list(target_list)) |