[pygobject] Override GtkAction and GtkRadioAction constructors.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Override GtkAction and GtkRadioAction constructors.
- Date: Fri, 10 Dec 2010 13:03:59 +0000 (UTC)
commit d8abcc9463542af9cd43d71849d0ad4c183b570b
Author: Paolo Borelli <pborelli gnome org>
Date: Fri Dec 10 14:05:20 2010 +0100
Override GtkAction and GtkRadioAction constructors.
gi/overrides/Gtk.py | 20 +++++++++++++++++---
tests/test_overrides.py | 18 ++++++++++++++++++
2 files changed, 35 insertions(+), 3 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 0313664..3fe6f1b 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -88,6 +88,20 @@ class Editable(Gtk.Editable):
Editable = override(Editable)
__all__.append("Editable")
+class Action(Gtk.Action):
+ def __init__(self, name, label, tooltip, stock_id, **kwds):
+ Gtk.Action.__init__(self, name=name, label=label, tooltip=tooltip, stock_id=stock_id, **kwds)
+
+Action = override(Action)
+__all__.append("Action")
+
+class RadioAction(Gtk.RadioAction):
+ def __init__(self, name, label, tooltip, stock_id, value, **kwds):
+ Gtk.RadioAction.__init__(self, name=name, label=label, tooltip=tooltip, stock_id=stock_id, value=value, **kwds)
+
+RadioAction = override(RadioAction)
+__all__.append("RadioAction")
+
class ActionGroup(Gtk.ActionGroup):
def __init__(self, name, **kwds):
super(ActionGroup, self).__init__(name = name, **kwds)
@@ -124,7 +138,7 @@ class ActionGroup(Gtk.ActionGroup):
raise TypeError('entries must be iterable')
def _process_action(name, stock_id=None, label=None, accelerator=None, tooltip=None, callback=None):
- action = Gtk.Action(name=name, label=label, tooltip=tooltip, stock_id=stock_id)
+ action = Action(name, label, tooltip, stock_id)
if callback is not None:
action.connect('activate', callback, user_data)
@@ -169,7 +183,7 @@ class ActionGroup(Gtk.ActionGroup):
raise TypeError('entries must be iterable')
def _process_action(name, stock_id=None, label=None, accelerator=None, tooltip=None, callback=None, is_active=False):
- action = Gtk.ToggleAction(name=name, label=label, tooltip=tooltip, stock_id=stock_id)
+ action = Gtk.ToggleAction(name, label, tooltip, stock_id)
action.set_active(is_active)
if callback is not None:
action.connect('activate', callback, user_data)
@@ -217,7 +231,7 @@ class ActionGroup(Gtk.ActionGroup):
first_action = None
def _process_action(group_source, name, stock_id=None, label=None, accelerator=None, tooltip=None, entry_value=0):
- action = Gtk.RadioAction(name=name, label=label, tooltip=tooltip, stock_id=stock_id, value=entry_value)
+ action = RadioAction(name, label, tooltip, stock_id, entry_value)
# FIXME: join_group is a patch to Gtk+ 3.0
# otherwise we can't effectively add radio actions to a
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 95c14f6..8220c95 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -78,6 +78,24 @@ class TestGtk(unittest.TestCase):
l = [x for x in box]
self.assertEqual(l, [label, label2])
+ def test_actions(self):
+ self.assertEquals(Gtk.Action, overrides.Gtk.Action)
+ self.assertRaises(TypeError, Gtk.Action)
+ action = Gtk.Action("test", "Test", "Test Action", Gtk.STOCK_COPY)
+ self.assertEquals(action.get_name(), "test")
+ self.assertEquals(action.get_label(), "Test")
+ self.assertEquals(action.get_tooltip(), "Test Action")
+ self.assertEquals(action.get_stock_id(), Gtk.STOCK_COPY)
+
+ self.assertEquals(Gtk.RadioAction, overrides.Gtk.RadioAction)
+ self.assertRaises(TypeError, Gtk.RadioAction)
+ action = Gtk.RadioAction("test", "Test", "Test Action", Gtk.STOCK_COPY, 1)
+ self.assertEquals(action.get_name(), "test")
+ self.assertEquals(action.get_label(), "Test")
+ self.assertEquals(action.get_tooltip(), "Test Action")
+ self.assertEquals(action.get_stock_id(), Gtk.STOCK_COPY)
+ self.assertEquals(action.get_current_value(), 1)
+
def test_actiongroup(self):
self.assertEquals(Gtk.ActionGroup, overrides.Gtk.ActionGroup)
self.assertRaises(TypeError, Gtk.ActionGroup)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]