Thread: [Java-gnome-developer] Potential API issue with Table.attach() & AttachOptions?
Brought to you by:
afcowie
From: Jacek F. <ja...@gm...> - 2009-03-19 19:42:54
|
I was looking at the Table.attach() method. I need to pass in a combination of AttachOptions (e.g. FILL | EXPAND), just like you can in Glade. However, the Java signature seems to allow passing in only a single AttachOptions instance, not a bitwise combination of them, unlike let's say in PyGTK: *The xoptions and yoptions determine the expansion properties of the widget in the horizontal and vertical directions respectively (the default value is gtk.FILL|gtk.EXPAND). The value of the options is a combination of:* *gtk.EXPAND* *the table cell should expand to take up any extra space that has been allocated to the table.* *gtk.SHRINK* *the widget should shrink when the table cell shrinks.* *gtk.FILL* *the widget should fill the space allocated to it in the table cell.* *The xpadding and ypadding parameters determine the extra padding added around the widget. By default these are 0.* It seems we do not have the option of creating a combination of AttachOptions in the Java bindings...or am I missing something? I tried passing in AttachOptions.FILL | AttachOptions.EXPAND, but obviously does not compile. public void attach(Widget child, int leftAttach, int rightAttach, int topAttach, int bottomAttach, AttachOptions xoptions, AttachOptions yoptions, int xpadding, int ypadding) { GtkTable.attach(this, child, leftAttach, rightAttach, topAttach, bottomAttach, xoptions, yoptions, xpadding, ypadding); } I'm on the latest build 4.0.10. Thanks in advance for any help, Jacek |
From: Stefan P. <pr...@tz...> - 2009-03-19 20:41:20
|
Hi Jacek, Am Donnerstag, den 19.03.2009, 15:42 -0400 schrieb Jacek Furmankiewicz: > I was looking at the Table.attach() method. I need to pass in a > combination of AttachOptions (e.g. FILL | EXPAND), just like you can > in Glade. Interesting. I admit I wasn't aware of the fact that you could combine the options. >From what I can say the fastest way would be to make the AttachOptions constructor public. Currently it is defined as private AttachOptions(int ordinal, String nickname) { super(ordinal, nickname); } I guess that the "ordinal" parameter should be the integer you are talking about. So you would use the class like this new AttachOptions(GtkAttachOptions.FILL|GtkAttachOptions.SHRINK, "FILL|SHRINK") Please, just make the constructor public, try it and give us feedback if this workaround would solve your problem. This has two drawbacks: 1. I am not sure how to deal with the "nickname" parameter in such a case. "FILL|SHRINK" was just a guess of mine. 2. It is extremly unelegant. Better perhaps would be to let AttachOptions have int constants and calculate a nickname within the constructor: public final static int SHRINK = GtkAttachOptions.SHRINK; public AttachOptions(int ordinal) { super(ordinal, AttachOptions.getNicknameFor(ordinal)); } private final static String getNicknameFor(int ordinal) { .. some StringBuffer magic ... } RFC Stefan |
From: Andrew C. <an...@op...> - 2009-03-19 22:16:21
|
On Thu, 2009-03-19 at 21:39 +0100, Stefan Prelle wrote: > Interesting. I admit I wasn't aware of the fact that you could combine > the options. > I guess that the "ordinal" parameter should be the integer ... You guys are completely off in left field. :) The bug is simple: whoever exposed AttachOptions did so incorrectly. GtkAttachOptions is a (define-flag) and our binding has it as a Constant, not as a Flags. Fixed. If you need to OR them use the strongly typed or() function, just like any other Flags subclass. Code is at 'hackers/andrew/bug-attach-is-flag'. If one of you try that branch and write a unit test to ensure its behaviour, we can merge it to 'mainline'. See ValidateConstants's testFlagsHandling() if you need some ideas. As this is API and library design discussion, follow-ups to java-gnome-hackers, please. AfC Sydney |
From: Stefan P. <pr...@tz...> - 2009-03-19 22:33:15
|
Am Freitag, den 20.03.2009, 09:16 +1100 schrieb Andrew Cowie: > You guys are completely off in left field. :) The bug is simple: > whoever exposed AttachOptions did so incorrectly. I guess that could have been me :) *sigh* :) Stefan |
From: Jacek F. <ja...@gm...> - 2009-03-20 11:48:47
|
I tried to check out Andrew's branch, but it was timing out on me this morning. If anyone can send me a compiled version of the jar and .so (or maybe just the jar, if that's all that's needed) I'd be glad to test it out and write a unit test for it. Cheers, Jacek (JACEK99 AT GMAIL DOT COM) On Thu, Mar 19, 2009 at 6:31 PM, Stefan Prelle <pr...@tz...> wrote: > Am Freitag, den 20.03.2009, 09:16 +1100 schrieb Andrew Cowie: > > You guys are completely off in left field. :) The bug is simple: > > whoever exposed AttachOptions did so incorrectly. > > I guess that could have been me :) > > *sigh* :) > > Stefan > > > > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > java-gnome-developer mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-gnome-developer > |