Thread: [Java-gnome-developer] Problems with FileChooserWidget
Brought to you by:
afcowie
From: Igor F. <if...@re...> - 2005-06-03 19:22:14
|
Hi everyone, I'm a fairly new user to java-gnome, so please bear with me. I seem to have some trouble with the FileChooserWidget. I first tried to use it in a semi-complex window, and got the following error (and no widget): -------- org.gnu.glade.GladeXMLException: unknown widget class 'GtkFileChooserWidget' at org.gnu.glade.LibGlade.glade_xml_new(Native Method) at org.gnu.glade.LibGlade.<init>(LibGlade.java:97) at org.gnu.glade.LibGlade.<init>(LibGlade.java) at com.redhat.uicopy.WindowLauncher.<init>(WindowLauncher.java:17) at com.redhat.uicopy.WindowLauncher.main(WindowLauncher.java:26) -------- Later on, I created a simple window and just stuck a file chooser in there without any other sugar. Both of these experiments are using Glade2. Again when I try to import this new glade file (with just the window with the chooser) into my java app I get the same exception. Does anyone have any idea on what might be causing this, or better yet, a solution? Thanks, Igor |
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 |
From: Joao V. <jvi...@ya...> - 2005-06-04 20:44:42
|
--- Igor Foox <if...@re...> escreveu: > Hi everyone, > > I'm a fairly new user to java-gnome, so please bear with me. Hi Igor, welcome! > > I seem to have some trouble with the FileChooserWidget. I first tried to > use it in a semi-complex window, and got the following error (and no > widget): Hmm, just so i get it right: do you want to just show a filechooser, or do you want to embbed it in another window? To just show it, this is the code i used in an app: ---- FileChooserDialog dialog = new FileChooserDialog("Select a picture", this, FileChooserAction.ACTION_OPEN); dialog.addButton("gtk-cancel", 0); dialog.addButton("gtk-ok", 1); dialog.setCurrentFolder(System.getProperty("user.home")); int result = dialog.run(); if (result == 1) { //.... } ---- Now, if you want to embbed it, i haven't tried doing it yet (will try), but take a look at GDVB, it seems to have a nice customized FileChooser, from what can be seen in this screenshot: http://news.nopcode.org/gdvb02.png Cheers, J.V. ____________________________________________________ Yahoo! Mail, cada vez melhor: agora com 1GB de espaço grátis! http://mail.yahoo.com.br |
From: pancake <pa...@ph...> - 2005-06-04 21:58:39
|
you can also take a look on the gdvb source code, in the file Gdvb.java -> = addLocalVideos() VBox addLocalVideos() { VBox vb =3D new VBox(false,5); vb.setBorderWidth(5); fcw=3Dnew FileChooserWidget(FileChooserAction.ACTION_OPEN); String videos =3D Gdvb.conf.getProperty("dir_videos"); try{ System.out.println("VIDEODIR: "+videos); if (videos!=3Dnull) { fcw.setCurrentFolder(videos); // XXX java-gnome BUG <- this is fixed in CVS // fcw.addShortcutFolder("/"); //videos); } } catch(Exception e) { System.out.println(e); } FileFilter mediaFilter =3D new FileFilter(); mediaFilter.setName("video"); mediaFilter.addMimeType("video/mpeg"); mediaFilter.addMimeType("video/x-msvideo"); mediaFilter.addMimeType("video/quicktime"); fcw.addFilter(mediaFilter); FileFilter allFilter =3D new FileFilter(); allFilter.setName("all filetypes"); allFilter.addPattern("*"); fcw.addFilter(allFilter); vb.add(fcw); HButtonBox hbb =3D new HButtonBox(); hbb.setSpacing(5); hbb.setLayout(ButtonBoxStyle.END); Button stop =3D new Button(GtkStockItem.MEDIA_STOP); stop.addListener((ButtonListener)this); hbb.add( stop ); Button play =3D new Button(GtkStockItem.MEDIA_PLAY); play.addListener((ButtonListener)this); hbb.add( play ); vb.packEnd(hbb,false,false,5); return vb; } On Sat, 4 Jun 2005 17:44:31 -0300 (ART) Joao Victor <jvi...@ya...> wrote: > --- Igor Foox <if...@re...> escreveu: >=20 > > Hi everyone, > >=20 > > I'm a fairly new user to java-gnome, so please bear with me. >=20 > Hi Igor, welcome! >=20 > >=20 > > I seem to have some trouble with the FileChooserWidget. I first tried to > > use it in a semi-complex window, and got the following error (and no > > widget): >=20 > Hmm, just so i get it right: do you want to just show a filechooser, or d= o you want to embbed it > in another window? To just show it, this is the code i used in an app: >=20 > ---- > FileChooserDialog dialog =3D new FileChooserDialog("Select a picture", th= is, > FileChooserAction.ACTION_OPEN); > dialog.addButton("gtk-cancel", 0); > dialog.addButton("gtk-ok", 1); > dialog.setCurrentFolder(System.getProperty("user.home")); > int result =3D dialog.run(); >=20 > if (result =3D=3D 1) { > //.... > } > ---- >=20 > Now, if you want to embbed it, i haven't tried doing it yet (will try), b= ut take a look at GDVB, > it seems to have a nice customized FileChooser, from what can be seen in = this screenshot: > http://news.nopcode.org/gdvb02.png >=20 > Cheers, > J.V. >=20 >=20 >=20 > =09 > =09 > =09 > ____________________________________________________ > Yahoo! Mail, cada vez melhor: agora com 1GB de espa=E7o gr=E1tis! http://= mail.yahoo.com.br >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by: NEC IT Guy Games. How far can you sho= tput > a projector? How fast can you ride your desk chair down the office luge t= rack? > If you want to score the big prize, get to know the little guy. =20 > Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=3D20 > _______________________________________________ > java-gnome-developer mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-gnome-developer |
From: Igor F. <if...@re...> - 2005-06-08 16:05:59
|
On Sat, 2005-06-04 at 17:44 -0300, Joao Victor wrote: > --- Igor Foox <if...@re...> escreveu: >=20 > > Hi everyone, > >=20 > > I'm a fairly new user to java-gnome, so please bear with me. >=20 > Hi Igor, welcome! Thanks for the warm welcome, from you as well as Andrew Cowie. >=20 > >=20 > > I seem to have some trouble with the FileChooserWidget. I first tried= to > > use it in a semi-complex window, and got the following error (and no > > widget): >=20 > Hmm, just so i get it right: do you want to just show a filechooser, or= do you want to embbed it > in another window? To just show it, this is the code i used in an app: I am trying to display a FileChooser widget inside an existing window, not a separate FileChooserDialog. I've been away for the past few days, but now I've tried just importing an empty window from my glade file, and creating a FileChooserWidget in the code (instead of glade), and adding it to the window. This works perfectly, so it seems there's some problem with libglade. I'll try to look into it. Thanks, Igor >=20 > ---- > FileChooserDialog dialog =3D new FileChooserDialog("Select a picture", = this, > FileChooserAction.ACTION_OPEN); > dialog.addButton("gtk-cancel", 0); > dialog.addButton("gtk-ok", 1); > dialog.setCurrentFolder(System.getProperty("user.home")); > int result =3D dialog.run(); >=20 > if (result =3D=3D 1) { > //.... > } > ---- >=20 > Now, if you want to embbed it, i haven't tried doing it yet (will try),= but take a look at GDVB, > it seems to have a nice customized FileChooser, from what can be seen i= n this screenshot: > http://news.nopcode.org/gdvb02.png >=20 > Cheers, > J.V. >=20 >=20 >=20 > =09 > =09 > =09 > ____________________________________________________ > Yahoo! Mail, cada vez melhor: agora com 1GB de espa=E7o gr=E1tis! http:= //mail.yahoo.com.br >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by: NEC IT Guy Games. How far can you s= hotput > a projector? How fast can you ride your desk chair down the office luge= track? > If you want to score the big prize, get to know the little guy. =20 > Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=3D20 > _______________________________________________ > java-gnome-developer mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-gnome-developer |