GNOME Bugzilla – Bug 622606
[Gtk] Add overrides for RadioButton
Last modified: 2010-10-13 18:32:20 UTC
Currently untested.
Created attachment 164509 [details] [review] [Gtk] Add overrides for Button/RadioButton
Created attachment 164515 [details] [review] Gtk.Button unit tests
Comment on attachment 164509 [details] [review] [Gtk] Add overrides for Button/RadioButton >From 8c90f60118e35f257ee7601a120fac0b7ae9ebdb Mon Sep 17 00:00:00 2001 >From: Johan Dahlin <johan@gnome.org> >Date: Thu, 24 Jun 2010 11:12:32 -0300 >Subject: [PATCH] [Gtk] Add overrides for Button/RadioButton > >Currently untested. > >https://bugzilla.gnome.org/show_bug.cgi?id=622606 >--- > gi/overrides/Gtk.py | 20 ++++++++++++++++++++ > 1 files changed, 20 insertions(+), 0 deletions(-) > >diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py >index 0c3dcc5..7fe608f 100644 >--- a/gi/overrides/Gtk.py >+++ b/gi/overrides/Gtk.py >@@ -399,6 +399,26 @@ class TreeViewColumn(Gtk.TreeViewColumn): > TreeViewColumn = override(TreeViewColumn) > __all__.append('TreeViewColumn') > >+class Button(Gtk.Button): >+ def __init__(self, label=None, stock=None, use_underline=False): >+ if stock: >+ label = stock >+ use_stock = True >+ use_underline = True >+ else: >+ use_stock = False >+ Gtk.Button.__init__(self, label=label, use_stock=use_stock, >+ use_underline=use_underline) >+Button = override(Button) >+__all__.append('Button') The above button patch is good to commit w/ the test patch I attached >+class RadioButton(Gtk.RadioButton): >+ def __init__(self, group=None, label=None, use_underline=False): >+ Gtk.RadioButton.__init__(self, group=group, label=label, >+ use_underline=use_underline) >+RadioButton = override(RadioButton) >+__all__.append('RadioButton') >+ There is a memory management issue with RadioButton groups being a list of radio buttons that gets modified by GTK which is why we added the join_group API for RadioActions (it takes a RadioAction instead of a group and joins the RadioAction's group inside of GTK). The same API needs to be added for RadioButtons. Colin stated that he did not think the get_group/set_group API is wrappable via GI due to the fact that the list is modified when setting it. > import sys > > initialized, argv = Gtk.init_check(sys.argv) >-- >1.6.6.1
Thanks! Attachment 164515 [details] pushed as 231e934 - Gtk.Button unit tests
(In reply to comment #3) > > There is a memory management issue with RadioButton groups being a list of > radio buttons that gets modified by GTK which is why we added the join_group > API for RadioActions (it takes a RadioAction instead of a group and joins the > RadioAction's group inside of GTK). The same API needs to be added for > RadioButtons. Colin stated that he did not think the get_group/set_group API > is wrappable via GI due to the fact that the list is modified when setting it. Any idea which API would be bindings-friendly?
The RadioAction object added a join_group method which takes another RadioAction. This should be copied for RadioButton.
https://bugzilla.gnome.org/show_bug.cgi?id=628935 fixes the group issue