[pygobject/pygobject-3-2] GTK overrides: Add missing keyword arguments
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/pygobject-3-2] GTK overrides: Add missing keyword arguments
- Date: Wed, 2 May 2012 09:17:46 +0000 (UTC)
commit 223b3c67634b4a2b066b38718498c89108371373
Author: Martin Pitt <martinpitt gnome org>
Date: Mon Apr 23 17:40:23 2012 +0200
GTK overrides: Add missing keyword arguments
Add missing **kwargs to overridden __init__() constructors, to allow specifying
arbitrary widget properties.
https://bugzilla.gnome.org/show_bug.cgi?id=660018
gi/overrides/Gtk.py | 34 ++++++++++++++++++----------------
tests/test_overrides.py | 6 ++++++
2 files changed, 24 insertions(+), 16 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 4018b32..007ea30 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -327,8 +327,8 @@ __all__.append('SizeGroup')
class MenuItem(Gtk.MenuItem):
- def __init__(self, label=None):
- super(MenuItem, self).__init__(label=label)
+ def __init__(self, label=None, **kwds):
+ super(MenuItem, self).__init__(label=label, **kwds)
MenuItem = override(MenuItem)
__all__.append('MenuItem')
@@ -387,8 +387,8 @@ __all__.append('Builder')
# NOTE: This must come before any other Window/Dialog subclassing, to ensure
# that we have a correct inheritance hierarchy.
class Window(Gtk.Window):
- def __init__(self, type=Gtk.WindowType.TOPLEVEL, **kwargs):
- Gtk.Window.__init__(self, type=type, **kwargs)
+ def __init__(self, type=Gtk.WindowType.TOPLEVEL, **kwds):
+ Gtk.Window.__init__(self, type=type, **kwds)
Window = override(Window)
__all__.append('Window')
@@ -552,8 +552,8 @@ __all__.append('RecentChooserDialog')
class IconView(Gtk.IconView):
- def __init__(self, model=None):
- Gtk.IconView.__init__(self, model=model)
+ def __init__(self, model=None, **kwds):
+ Gtk.IconView.__init__(self, model=model, **kwds)
def get_item_at_pos(self, x, y):
success, path, cell = super(IconView, self).get_item_at_pos(x, y)
@@ -576,8 +576,8 @@ __all__.append('IconView')
class ToolButton(Gtk.ToolButton):
- def __init__(self, stock_id=None):
- Gtk.ToolButton.__init__(self, stock_id=stock_id)
+ def __init__(self, stock_id=None, **kwds):
+ Gtk.ToolButton.__init__(self, stock_id=stock_id, **kwds)
ToolButton = override(ToolButton)
__all__.append('ToolButton')
@@ -1429,15 +1429,15 @@ __all__.append('ScrolledWindow')
class HScrollbar(Gtk.HScrollbar):
- def __init__(self, adjustment=None):
- Gtk.HScrollbar.__init__(self, adjustment=adjustment)
+ def __init__(self, adjustment=None, **kwds):
+ Gtk.HScrollbar.__init__(self, adjustment=adjustment, **kwds)
HScrollbar = override(HScrollbar)
__all__.append('HScrollbar')
class VScrollbar(Gtk.VScrollbar):
- def __init__(self, adjustment=None):
- Gtk.VScrollbar.__init__(self, adjustment=adjustment)
+ def __init__(self, adjustment=None, **kwds):
+ Gtk.VScrollbar.__init__(self, adjustment=adjustment, **kwds)
VScrollbar = override(VScrollbar)
__all__.append('VScrollbar')
@@ -1454,9 +1454,10 @@ __all__.append('Paned')
class Arrow(Gtk.Arrow):
- def __init__(self, arrow_type, shadow_type):
+ def __init__(self, arrow_type, shadow_type, **kwds):
Gtk.Arrow.__init__(self, arrow_type=arrow_type,
- shadow_type=shadow_type)
+ shadow_type=shadow_type,
+ **kwds)
Arrow = override(Arrow)
__all__.append('Arrow')
@@ -1475,9 +1476,10 @@ __all__.append('IconSet')
class Viewport(Gtk.Viewport):
- def __init__(self, hadjustment=None, vadjustment=None):
+ def __init__(self, hadjustment=None, vadjustment=None, **kwds):
Gtk.Viewport.__init__(self, hadjustment=hadjustment,
- vadjustment=vadjustment)
+ vadjustment=vadjustment,
+ **kwds)
Viewport = override(Viewport)
__all__.append('Viewport')
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 78e589f..6f2fbaf 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -1849,6 +1849,12 @@ class TestGtk(unittest.TestCase):
button = Gtk.ToolButton('gtk-new')
self.assertEquals(button.props.stock_id, 'gtk-new')
+ icon = Gtk.Image.new_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.SMALL_TOOLBAR)
+
+ button = Gtk.ToolButton(label='mylabel', icon_widget=icon)
+ self.assertEqual(button.props.label, 'mylabel')
+ self.assertEqual(button.props.icon_widget, icon)
+
def test_iconset(self):
# PyGTK compat
iconset = Gtk.IconSet()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]