diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2020-09-11 17:48:11 +0100 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2020-11-15 17:52:02 +0100 |
commit | 5d766d5d46c749f9b2892d3d91946815c90e8583 (patch) | |
tree | ccec7664c1d6d67012d9e54c2ddb3909e6ef0243 | |
parent | 3e64ba2877a13449e37764af5693baf4ee902138 (diff) | |
download | pygobject-5d766d5d46c749f9b2892d3d91946815c90e8583.tar.gz |
Drop the GtkButton override for GTK4
We don't need to override anything, once we drop the deprecated
compatibility layer for pygtk.
-rw-r--r-- | gi/overrides/Gtk.py | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py index 087de16a..52ff83d2 100644 --- a/gi/overrides/Gtk.py +++ b/gi/overrides/Gtk.py @@ -1522,46 +1522,47 @@ TreeSelection = override(TreeSelection) __all__.append('TreeSelection') -class Button(Gtk.Button, Container): - _init = deprecated_init(Gtk.Button.__init__, - arg_names=('label', 'stock', 'use_stock', 'use_underline'), - ignore=('stock',), - category=PyGTKDeprecationWarning, - stacklevel=3) +if GTK2 or GTK3: + class Button(Gtk.Button, Container): + _init = deprecated_init(Gtk.Button.__init__, + arg_names=('label', 'stock', 'use_stock', 'use_underline'), + ignore=('stock',), + category=PyGTKDeprecationWarning, + stacklevel=3) - def __init__(self, *args, **kwargs): - # Doubly deprecated initializer, the stock keyword is non-standard. - # Simply give a warning that stock items are deprecated even though - # we want to deprecate the non-standard keyword as well here from - # the overrides. - if 'stock' in kwargs and kwargs['stock']: - warnings.warn('Stock items are deprecated. ' - 'Please use: Gtk.Button.new_with_mnemonic(label)', - PyGTKDeprecationWarning, stacklevel=2) - new_kwargs = kwargs.copy() - new_kwargs['label'] = new_kwargs['stock'] - new_kwargs['use_stock'] = True - new_kwargs['use_underline'] = True - del new_kwargs['stock'] - Gtk.Button.__init__(self, **new_kwargs) - else: - self._init(*args, **kwargs) + def __init__(self, *args, **kwargs): + # Doubly deprecated initializer, the stock keyword is non-standard. + # Simply give a warning that stock items are deprecated even though + # we want to deprecate the non-standard keyword as well here from + # the overrides. + if 'stock' in kwargs and kwargs['stock']: + warnings.warn('Stock items are deprecated. ' + 'Please use: Gtk.Button.new_with_mnemonic(label)', + PyGTKDeprecationWarning, stacklevel=2) + new_kwargs = kwargs.copy() + new_kwargs['label'] = new_kwargs['stock'] + new_kwargs['use_stock'] = True + new_kwargs['use_underline'] = True + del new_kwargs['stock'] + Gtk.Button.__init__(self, **new_kwargs) + else: + self._init(*args, **kwargs) - 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, "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) + 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) -__all__.append('Button') + Button = override(Button) + __all__.append('Button') class LinkButton(Gtk.LinkButton): |