28
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Bill Baxter <bill@billbaxter.com>
|
|
12 *******************************************************************************/
|
|
13 module org.eclipse.swt.snippets.Snippet72;
|
|
14
|
|
15 /*
|
|
16 * FileDialog example snippet: prompt for a file name (to save)
|
|
17 *
|
|
18 * For a list of all SWT example snippets see
|
|
19 * http://www.eclipse.org/swt/snippets/
|
|
20 */
|
|
21 import org.eclipse.swt.SWT;
|
|
22 import org.eclipse.swt.widgets.Display;
|
|
23 import org.eclipse.swt.widgets.Shell;
|
|
24 import org.eclipse.swt.widgets.FileDialog;
|
|
25
|
112
|
26 version(Tango){
|
|
27 import tango.io.Stdout;
|
|
28 } else { // Phobos
|
|
29 import std.stdio;
|
|
30 }
|
28
|
31
|
|
32 void main () {
|
|
33 Display display = new Display ();
|
|
34 Shell shell = new Shell (display);
|
|
35 shell.open ();
|
|
36 FileDialog dialog = new FileDialog (shell, SWT.SAVE);
|
|
37 dialog.setFilterNames (["Batch Files", "All Files (*.*)"]);
|
|
38 dialog.setFilterExtensions (["*.bat", "*.*"]); //Windows wild cards
|
|
39 dialog.setFilterPath ("c:\\"); //Windows path
|
|
40 dialog.setFileName ("fred.bat");
|
112
|
41 version(Tango){
|
|
42 Stdout.formatln ("Save to: {}", dialog.open ());
|
|
43 } else { // Phobos
|
|
44 writeln ("Save to: %s", dialog.open ());
|
|
45 }
|
28
|
46 while (!shell.isDisposed ()) {
|
|
47 if (!display.readAndDispatch ()) display.sleep ();
|
|
48 }
|
|
49 display.dispose ();
|
|
50 }
|
|
51
|