Re: [Java-gnome-developer] Problems with FileChooserWidget
Brought to you by:
afcowie
From: Andrew C. <an...@op...> - 2005-06-04 16:06:10
|
Hi Igor, On Fri, 2005-03-06 at 15:22 -0400, Igor Foox wrote: > [GtkFileChooser] A few nights ago at GUADEC I was working with Ben Konrath (scsibear) on a similar problem. I'm no expert, but I do have working FileChooser code to tell you about. > Does anyone have any idea on what might be causing this, or better yet, > a solution? I think at least part of the problem is that Dialogs tend to be treated a bit specially - both by the underlying GTK libraries and up at our level in java-gnome land. I found that the API was a bit fragile. You'd think that you could just new FileChooser() and be happy, but for various reasons that seems to work sub-optimally, if at all. [sub-optimally includes it not remembering where you were if you'd previously navigated the chooser] Of about five different reasonable seeming combinations I tried, the only way I could get FileChooser to behave was to add a FileChooser dialog to my .glade file. [Some people seem to find this natural, but until now I've only ever had one Window per glade file. I kinda stumbled across doing it this way by accidentally hitting the wrong button in Glade. Gotta love it]. Then, in my code, I wrote bits to get a reference to that dialog, and then handled run()ing it and then parse the weirdo int return code (seems to be from the API that comes from the parent Dialog class). Anything else just plain didn't work right. If you want to see an example, try grabbing the code to xseq[1] and seeing if that works for you - right off the bat there's a file selection dialog you can try. If that all works, then you know that your java-gnome installation is ok. If xseq won't run, then upgrade to >=libgtk-java 2.6.2 and >=libglade-java 2.10.1, and try again. AfC Stuttgart P.S. First time we've seen you on this list, so a very warm welcome to you. [1] xseq: yes, in just about every email I send to this list I'm going to refer people to my code. Why? Becuase our JavaDoc is terrible, our examples tend to be simplistic or contribed, and our API itself tends to be a bit fragile (largely because there are several ways you *could* use something, but only generally one way you *should* use something). Figuring out workable code paths was *very* challenging - and I'm not exactly an amateur - but once you've got a working model, you can generally replicate it and be golden. Since I *have* a working instance of many of the java-gnome peices now (TreeView, TextView, FileChooser, LibGlade of course, Pixbuf/Image loading, Listener/Event patterns, etc) it would be kind of foolish for me NOT to point people at that code, at least as a starting point for them to try and get ideas. Anyway, for some FileChooser code, see http://research.operationaldynamics.com/darcs/xseq/tests/xseq/ui/TestLoadWindow.java in particular around line 143 for dealing with the int response code, and also note the byplay between showAll()+present(), run() and hide(). To see it in action, see screen shots at: http://research.operationaldynamics.com/projects/xseq/wiki/ScreenShots AfC Stuttgart -- Andrew Frederick Cowie Technology strategy, managing change, establishing procedures, and executing successful upgrades to mission critical business infrastructure. http://www.operationaldynamics.com/ Sydney New York Toronto London |