[pygobject] GTK overrides: Add missing keyword arguments
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] GTK overrides: Add missing keyword arguments
- Date: Mon, 23 Apr 2012 15:41:54 +0000 (UTC)
commit c12b10ca0feaaf61f23354c7b6631a9ef3635c36
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 88e748f..5ae61b2 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -333,8 +333,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')
@@ -395,8 +395,8 @@ __all__.append('Builder')
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')
@@ -567,8 +567,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)
@@ -591,8 +591,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')
@@ -1474,16 +1474,16 @@ __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')
@@ -1501,9 +1501,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')
@@ -1522,9 +1523,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 ab7525f..831970b 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -1860,6 +1860,12 @@ class TestGtk(unittest.TestCase):
button = Gtk.ToolButton('gtk-new')
self.assertEqual(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
Gtk.IconSet()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]