Thread: [java-gnome-hackers] RadioAction and RadioMenuItem coverage
Brought to you by:
afcowie
From: Guillaume M. <res...@gm...> - 2010-02-02 02:56:19
|
Hello, I'm facing some difficulty to add the coverage of RadioAction and RadioMenuItem. As we spoke with Andrew several hours ago, I created a RadioMenuItemGroup to avoid the complexity [and the idiocy] of the GSList* to manage a group of widget. I did it like the existed RadioButtonGroup. Here is an example of how to use my current code: RadioMenuItemGroup group = new RadioMenuItemGroup(); RadioMenuItem item1 = new RadioMenuItem(group, "item1"); ... But I have an error when I try to use this previous piece of code. org.gnome.glib.FatalError: Gtk-CRITICAL gtk_radio_menu_item_new_with_label_from_widget: assertion `GTK_IS_RADIO_MENU_ITEM (group)' failed at org.gnome.gtk.GtkRadioMenuItem.gtk_radio_menu_item_new_with_label_from_widget(Native Method) at org.gnome.gtk.GtkRadioMenuItem.createRadioMenuItemWithLabelFromWidget(GtkRadioMenuItem.java:143) at org.gnome.gtk.RadioMenuItem.<init>(RadioMenuItem.java:76) Into the RadioMenuItem constructor, I call the getMember() method from the RadioMenuItemGroup which returns a RadioMenuItem. But the first call of this method will return *null* because there will be no member in the group. So, I assume that the error is due to that group.getMember() == null. Do you have any idea? Thank you for your advice and your help. -- Guillaume Mazoyer - http://www.respawner.fr/ |
From: Guillaume M. <res...@gm...> - 2010-02-12 08:01:05
|
Hello, I was pretty busy these last days and I couldn't work on the RadioMenuItemGroup. I'm back now, so I took a look to the code code again and I still cannot see how to fix the error that I have. The branch is available for the people who are interested to take a look to it. You can found it at: bzr/java-gnome/hackers/guillaume/toggle-action/ -- Guillaume Mazoyer - http://www.respawner.fr/ |
From: Andrew C. <an...@op...> - 2010-02-15 12:56:25
|
On Fri, 2010-02-12 at 09:00 +0100, Guillaume Mazoyer wrote: > I took a look to the code code > again and I still cannot see how to fix the error that I have. Do you have a test case or example? I grabbed your branch but there's no test coverage so it's a bit hard to duplicate the crash you're experiencing. Write a test that fails in tests/bindings/, add it to the test suite, and then we can see what you're up to. This is often a good way to see how your API is shaping up. Failing that there are the tests/snapshots/ and doc/examples/ trees too. AfC Sydney |
From: Guillaume M. <res...@gm...> - 2010-02-15 21:15:45
|
> Write a test that fails in tests/bindings/, add it to the test suite, > and then we can see what you're up to. This is often a good way to see > how your API is shaping up. Failing that there are the tests/snapshots/ > and doc/examples/ trees too. Done. And the test case confirms what I was thinking. -- Guillaume Mazoyer - http://www.respawner.fr/ |
From: Andrew C. <an...@op...> - 2010-02-15 21:52:20
|
On Mon, 2010-02-15 at 22:15 +0100, Guillaume Mazoyer wrote: > Done. And the test case confirms what I was thinking. Great. The extra check you put in [which was actually a no-op type check] was misleading you. The error you were getting from GTK was in fact telling you the problem - which was that you were passing a NULL down to a constructor that doesn't accept them. So here's what I did to make Guillaume's branch work. Mostly it was just choosing different constructors to achieve the desired effect. I took a guess and experimented with what happens if you call gtk_radio_menu_action_new() with NULL as the GSList*. Turns out it works. === modified file 'src/bindings/org/gnome/gtk/RadioMenuItem.java' --- src/bindings/org/gnome/gtk/RadioMenuItem.java 2010-02-01 15:49:40 +0000 +++ src/bindings/org/gnome/gtk/RadioMenuItem.java 2010-02-15 21:36:47 +0000 @@ -73,11 +73,23 @@ * @since 4.0.15 */ public RadioMenuItem(RadioMenuItemGroup group, String label) { - this(GtkRadioMenuItem.createRadioMenuItemWithLabelFromWidget(group.getMember(), label)); + super(createFirstOrNext(group, label)); group.setMember(this); enclosingGroup = group; } + private static long createFirstOrNext(RadioMenuItemGroup group, String label) { + final RadioMenuItem first; + + first = group.getMember(); + + if (first == null) { + return GtkRadioMenuItem.createRadioMenuItemWithMnemonic(null, label); + } else { + return GtkRadioMenuItem.createRadioMenuItemWithMnemonicFromWidget(first, label); + } + } + Anyway, my fix to your branch is at bzr://research.operationaldynamics.com/bzr/java-gnome/hackers/andrew/radio-things Merge away :) On Fri, 2010-02-12 at 09:00 +0100, Guillaume Mazoyer wrote: > 'hackers/guillaume/toggle-action' Incidentally, if you copy a class verbatim, it'd be nice to put a note saying where you got the code from. It would have made it easier to realize that: $ diff src/bindings/org/gnome/gtk/RadioButtonGroup.java src/bindings/org/gnome/gtk/RadioMenuItemGroup.java wasn't going to show anything meaningful. That class sure is ulgy. And now there are two of them. :( You're right that it'd be nice to be able to have some group thing that was common for all the RadioWhatevers. Not sure how we'd do that, though. AfC Sydney -- Andrew Frederick Cowie Operational Dynamics is an operations and engineering consultancy focusing on IT strategy, organizational architecture, systems review, and effective procedures for change management: enabling successful deployment of mission critical information technology in enterprises, worldwide. http://www.operationaldynamics.com/ Sydney New York Toronto London |
From: Guillaume M. <res...@gm...> - 2010-02-19 15:09:18
|
Hello, Well, now, everything is working. All the radio stuffs are working and implemented. RadioButtonGroup doesn't exist anymore and RadioGroup is taking its place. The RadioGroup is a generic group that can be used with RadioButton, RadioAction, RadioMenuItem and RadioToolButton. It has the same method and signal that the RadioButtonGroup had. So I guess that the branch can be merged (to be a part of java-gnome 4.0.15) but it's up to Andrew to decide. If you have any comments or improvements (that can be done), please let me now. -- Guillaume Mazoyer - http://www.respawner.fr/ |
From: Andrew C. <an...@op...> - 2010-02-21 03:13:29
|
On Fri, 2010-02-19 at 16:08 +0100, Guillaume Mazoyer wrote: > Hello, > > Well, now, everything is working. All the radio stuffs are working and > implemented. RadioButtonGroup doesn't exist anymore Uh, oops. No. We can't just delete it; it's been published API for many releases so we have to keep it (and mark it deprecated). I've taken care of that. Merged to 'mainline'. AfC Sydney |