diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2020-04-17 18:16:54 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2020-04-17 18:33:46 +0200 |
commit | 1a2bc1d0806ab6178f65125bf0b2283eb3378d4d (patch) | |
tree | 245594a7295200a98899ffd17a9b0ca5529a8056 /gi/overrides | |
parent | 4927856945899de09cfe99c052a83aec6e2f3c1a (diff) | |
download | pygobject-1a2bc1d0806ab6178f65125bf0b2283eb3378d4d.tar.gz |
get/set_focus_on_click: Fix return value, add a test and document why the override is there
Also make it conditional on the Gtk.Widget method existing since that was only
added with gtk 3.20 and we support 3.18+.
Diffstat (limited to 'gi/overrides')
-rw-r--r-- | gi/overrides/Gtk.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py index b797cf8c..64a5088e 100644 --- a/gi/overrides/Gtk.py +++ b/gi/overrides/Gtk.py @@ -1460,15 +1460,17 @@ class Button(Gtk.Button, Container): else: self._init(*args, **kwargs) - def set_focus_on_click(self, focus_on_click): - # Gtk.Button.set_focus_on_click is deprecated since version 3.20 - # Use Gtk.Widget.set_focus_on_click instead - Gtk.Widget.set_focus_on_click(self, focus_on_click) - - def get_focus_on_click(self): - # Gtk.Button.get_focus_on_click is deprecated since version 3.20 - # Use Gtk.Widget.get_focus_on_click instead - Gtk.Widget.get_focus_on_click(self) + if hasattr(Gtk.Widget, "set_focus_on_click"): + def set_focus_on_click(self, *args, **kwargs): + # Gtk.Widget.set_focus_on_click should be used instead but it's + # no obvious how because of the shadowed method, so override here + return Gtk.Widget.set_focus_on_click(self, *args, **kwargs) + + if hasattr(Gtk.Widget, "get_focus_on_click"): + def get_focus_on_click(self, *args, **kwargs): + # Gtk.Widget.get_focus_on_click should be used instead but it's + # no obvious how because of the shadowed method, so override here + return Gtk.Widget.get_focus_on_click(self, *args, **kwargs) Button = override(Button) |