bug 116: x11 file dialog
authoradam <adam@megacz.com>
Tue, 10 Feb 2004 06:16:40 +0000 (06:16 +0000)
committeradam <adam@megacz.com>
Tue, 10 Feb 2004 06:16:40 +0000 (06:16 +0000)
darcs-hash:20040210061640-5007d-6e44a500c32a43f64b74e668e31437d1cb4563f9.gz

Makefile
Makefile.upstream
src/org/ibex/Box.java
src/org/ibex/Ibex.java
src/org/ibex/plat/X11.cc
src/org/ibex/plat/X11.java

index 4e9dc64..77ff333 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ dist-clean:
        test -e upstream/mips && make -C upstream/mips clean
 
 JVM:        build/JVM/ibex.jar
-Linux:    ; make gcj platform=Linux   link_flags="-lX11 -lXext"
+Linux:    ; make gcj platform=Linux   link_flags="upstream/install/lib/libExtraWINGs.a upstream/install/lib/libWINGs.a upstream/install/lib/libwraster.a -L/usr/X11R6/lib -lXpm -lX11 -lXext"
 Solaris:  ; make gcj platform=Solaris link_flags="-lX11 -lXext -lpthread"
 Win32:    ; make gcj platform=Win32   link_flags="-Wl,--subsystem,windows -lcomdlg32"
 Darwin:   ; make gcj platform=Darwin  link_flags="$(darwin_linker_flags)"
@@ -167,6 +167,7 @@ build/$(platform)/%.java.o: build/java/%.java
        mkdir -p `dirname $@`
        $(gcj) -c $< -o $@
 
+build/$(platform)/org/ibex/plat/X11.cc.o: .install_WindowMaker-0.80.2_$(target) 
 build/$(platform)/org/ibex/plat/$(platform).cc.o: src/org/ibex/plat/$(platform).cc src/org/ibex/plat/*.cc .configure_jpeg-6b_$(target)
        @make $(java_headers)
        @echo -e "\n\033[1mcompiling            .cc -> .o:     $<\033[0m"
@@ -185,7 +186,7 @@ upstream/jpeg-6b/build-$(target)/libjpeg.a: .install_jpeg-6b_$(target)
 build/$(platform)/$(target_bin): build/$(platform)/org/ibex/plat/$(platform).cc.o upstream/jpeg-6b/build-$(target)/libjpeg.a build/$(platform)/builtin.o build/$(platform)/$(platform).ar build/$(platform)/org/ibex/plat/$(platform).java.o
        @echo -e "\n\033[1mlinking               .o -> $(target_bin)\033[0m"
        mkdir -p build/$(platform)
-       PATH=upstream/install/bin:$$PATH $(gcj) -v --main=org.ibex.Main -o $@ -Lupstream/install/$(target)/lib $^ $(link_flags)
+       PATH=upstream/install/bin:$$PATH $(gcj) -v --main=org.ibex.Main -o $@ -Lupstream/install/$(target)/lib -Lupstream/install/lib $^ $(link_flags)
 
 
 ### Builtin Resources ##############################################################################
index 64dd9b5..2d2719b 100644 (file)
@@ -18,6 +18,7 @@ url_libmspack-20030726 := http://www.kyz.uklinux.net/downloads/libmspack-2003072
 url_vera-1.10          := http://ftp.gnome.org/pub/GNOME/sources/ttf-bitstream-vera/1.10/ttf-bitstream-vera-1.10.tar.gz
 url_jode-1.1.1         := http://umn.dl.sourceforge.net/sourceforge/jode/jode-1.1.1.tar.gz
 url_java-getopt-1.0.9  := ftp://ftp.urbanophile.com/pub/arenn/software/sources/java-getopt-1.0.9.tar.gz
+url_WindowMaker-0.80.2 := ftp://windowmaker.org/pub/source/release/WindowMaker-0.80.2.tar.gz
 
 .install_binutils-2.13.2.1_powerpc-apple-darwin: .vendor
        rm -rf upstream/darwin-linker/src
index 6bd6ddf..90fd499 100644 (file)
@@ -166,7 +166,7 @@ public final class Box extends JSScope implements Scheduler.Task {
 
     // Instance Methods /////////////////////////////////////////////////////////////////////
 
-    public int fontSize() { return (font == null ? DEFAULT_FONT : font).pointsize; }
+    public final int fontSize() { return font == null ? DEFAULT_FONT.pointsize : font.pointsize; }
 
     /** invoked when a resource needed to render ourselves finishes loading */
     public void perform() throws JSExn {
index a5a2e85..3828b17 100644 (file)
@@ -169,6 +169,10 @@ public final class Ibex extends JS.Cloneable {
                         else if (url.startsWith("https://")) return new Stream.HTTP(url);
                         else if (url.startsWith("data:")) return new Stream.ByteArray(Base64.decode(url.substring(5)), null);
                         else if (url.startsWith("utf8:")) return new Stream.ByteArray(url.substring(5).getBytes(), null);
+                        else if (url.startsWith("file:")) {
+                            // FIXME
+                            Platform.fileDialog(url.substring(5), false);
+                        }
                         throw new JSExn("invalid resource specifier " + url);
                     }
                     case "thread.sleep": sleep(JS.toInt(a)); return null;
index 0252a81..62672d7 100644 (file)
@@ -769,6 +769,31 @@ void org::ibex::plat::X11::natInit() {
     org::ibex::util::Log::info(this->getClass(), JvNewStringLatin1(buf));
 }
 
+#include "WINGs/WINGs.h"
+jstring org::ibex::plat::X11::_fileDialog(jstring suggestedFileName, jboolean write) {
+  int argc = 1;
+  char* argv[2];
+  argv[0] = "Ibex";
+  argv[1] = NULL;
+  // FIXME see WINGs/Tests/filedialog.c for more info... need an icon
+  WMInitializeApplication("Ibex", &argc, argv);
+  WMScreen *scr = WMCreateSimpleApplicationScreen(display);
+  int len = min(1024, JvGetStringUTFLength(suggestedFileName));
+  char buf[len + 1];
+  JvGetStringUTFRegion(suggestedFileName, 0, len, buf);
+  buf[len] = '\0';
+  if (write) {
+    WMSavePanel *sPanel;
+    sPanel = WMGetSavePanel(scr);
+    if (WMRunModalFilePanelForDirectory(sPanel, NULL, buf, /*title*/ NULL, NULL) != True) return NULL;
+    return JvNewStringLatin1(WMGetFilePanelFileName(sPanel));
+  } else {
+    WMOpenPanel *oPanel;
+    oPanel = WMGetOpenPanel(scr);
+    if (WMRunModalFilePanelForDirectory(oPanel, NULL, buf, /*title*/ NULL, NULL) != True) return NULL;
+    return JvNewStringLatin1(WMGetFilePanelFileName(oPanel));
+  }
+}
 
 
 //////////////////////////////////////////////////////////////////////////////
index 14c4ca0..80db668 100644 (file)
@@ -40,6 +40,7 @@ public class X11 extends POSIX {
     protected native String _getClipBoard();
     protected native void _setClipBoard(String s);
     protected boolean _needsAutoDoubleClick() { return true; }
+    protected native String _fileDialog(String suggestedFileName, boolean write);
     protected native void eventThread();
     private native void natInit();