comparison dwt/browser/FilePicker_1_8.d @ 125:5583f8eeee6c

Synced mozilla with dwt-linux
author Jacob Carlborg <doob@me.com>
date Fri, 16 Jan 2009 12:49:08 +0100
parents d8635bb48c7c
children
comparison
equal deleted inserted replaced
124:540fa4e9974a 125:5583f8eeee6c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2003, 2007 IBM Corporation and others. 2 * Copyright (c) 2003, 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * John Reimer <terminal.node@gmail.com>
10 *******************************************************************************/ 12 *******************************************************************************/
11 module dwt.browser.FilePicker_1_8; 13 module dwt.browser.FilePicker_1_8;
12 14
13 import dwt.dwthelper.utils; 15 import dwt.dwthelper.utils;
14 16
15 import dwt.internal.mozilla.XPCOM; 17 import dwt.browser.FilePicker;
16 import dwt.internal.mozilla.XPCOMObject; 18 import XPCOM = dwt.internal.mozilla.XPCOM;
19 import dwt.internal.mozilla.nsStringAPI;
17 20
18 class FilePicker_1_8 : FilePicker { 21 class FilePicker_1_8 : FilePicker {
19 22
20 void createCOMInterfaces () { 23 extern(D)
21 /* Create each of the interfaces that this object implements */ 24 String parseAString (nsAString* string) {
22 supports = new XPCOMObject (new int[] {2, 0, 0}) { 25 if (string is null) return null;
23 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} 26 return nsAString.toString(string);
24 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
25 public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
26 };
27
28 filePicker = new XPCOMObject (new int[] {2, 0, 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
29 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
30 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
31 public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
32 public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], cast(short)args[2]);}
33 public int /*long*/ method4 (int /*long*/[] args) {return AppendFilters (cast(int)/*64*/args[0]);}
34 public int /*long*/ method5 (int /*long*/[] args) {return AppendFilter (args[0], args[1]);}
35 public int /*long*/ method6 (int /*long*/[] args) {return GetDefaultString (args[0]);}
36 public int /*long*/ method7 (int /*long*/[] args) {return SetDefaultString (args[0]);}
37 public int /*long*/ method8 (int /*long*/[] args) {return GetDefaultExtension (args[0]);}
38 public int /*long*/ method9 (int /*long*/[] args) {return SetDefaultExtension (args[0]);}
39 public int /*long*/ method10 (int /*long*/[] args) {return GetFilterIndex (args[0]);}
40 public int /*long*/ method11 (int /*long*/[] args) {return SetFilterIndex (cast(int)/*64*/args[0]);}
41 public int /*long*/ method12 (int /*long*/[] args) {return GetDisplayDirectory (args[0]);}
42 public int /*long*/ method13 (int /*long*/[] args) {return SetDisplayDirectory (args[0]);}
43 public int /*long*/ method14 (int /*long*/[] args) {return GetFile (args[0]);}
44 public int /*long*/ method15 (int /*long*/[] args) {return GetFileURL (args[0]);}
45 public int /*long*/ method16 (int /*long*/[] args) {return GetFiles (args[0]);}
46 public int /*long*/ method17 (int /*long*/[] args) {return Show (args[0]);}
47 };
48 }
49
50 /*
51 * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type. This method
52 * answers a java string based on the type of string that is appropriate for the Mozilla
53 * version being used.
54 */
55 String parseAString (int /*long*/ string) {
56 if (string is 0) return null;
57 int length = XPCOM.nsEmbedString_Length (string);
58 int /*long*/ buffer = XPCOM.nsEmbedString_get (string);
59 char[] chars = new char[length];
60 XPCOM.memmove (chars, buffer, length * 2);
61 return new String (chars);
62 } 27 }
63 } 28 }