42 |
import java.awt.FileDialog; |
import java.awt.FileDialog; |
43 |
import java.awt.Graphics; |
import java.awt.Graphics; |
44 |
import java.awt.Window; |
import java.awt.Window; |
45 |
|
import java.awt.event.ComponentEvent; |
46 |
import java.awt.peer.FileDialogPeer; |
import java.awt.peer.FileDialogPeer; |
47 |
import java.io.File; |
import java.io.File; |
48 |
import java.io.FilenameFilter; |
import java.io.FilenameFilter; |
55 |
private String currentDirectory = null; |
private String currentDirectory = null; |
56 |
private FilenameFilter filter; |
private FilenameFilter filter; |
57 |
|
|
58 |
native void create (GtkContainerPeer parent); |
native void create (GtkContainerPeer parent, int mode); |
59 |
native void connectSignals (); |
native void connectSignals (); |
60 |
native void nativeSetFile (String file); |
native void nativeSetFile (String file); |
61 |
public native String nativeGetDirectory(); |
public native String nativeGetDirectory(); |
64 |
|
|
65 |
public void create() |
public void create() |
66 |
{ |
{ |
67 |
create((GtkContainerPeer) awtComponent.getParent().getPeer()); |
create((GtkContainerPeer) awtComponent.getParent().getPeer(), |
68 |
|
((FileDialog) awtComponent).getMode()); |
69 |
|
|
70 |
FileDialog fd = (FileDialog) awtComponent; |
FileDialog fd = (FileDialog) awtComponent; |
71 |
|
|
89 |
{ |
{ |
90 |
int[] dims = new int[2]; |
int[] dims = new int[2]; |
91 |
gtkWidgetGetPreferredDimensions (dims); |
gtkWidgetGetPreferredDimensions (dims); |
92 |
((GtkFileDialogPeer) this).setBoundsCallback ((Window) awtComponent, |
|
93 |
awtComponent.getX (), |
if (dims[0] != awtComponent.getWidth() |
94 |
awtComponent.getY (), |
|| dims[1] != awtComponent.getHeight()) |
95 |
dims[0], dims[1]); |
awtComponent.setSize(dims[0], dims[1]); |
96 |
} |
} |
97 |
super.setComponentBounds (); |
super.setComponentBounds (); |
98 |
} |
} |
157 |
GtkFileFilterInfo object and send it to this method, which will |
GtkFileFilterInfo object and send it to this method, which will |
158 |
in turn call the filter's accept() method and give back the return |
in turn call the filter's accept() method and give back the return |
159 |
value. */ |
value. */ |
160 |
|
// called back by native side: filename_filter_cb |
161 |
boolean filenameFilterCallback (String fullname) { |
boolean filenameFilterCallback (String fullname) { |
162 |
String filename = fullname.substring(fullname.lastIndexOf(FS) + 1); |
String filename = fullname.substring(fullname.lastIndexOf(FS) + 1); |
163 |
String dirname = fullname.substring(0, fullname.lastIndexOf(FS)); |
String dirname = fullname.substring(0, fullname.lastIndexOf(FS)); |
170 |
// GtkFileDialog will repaint by itself |
// GtkFileDialog will repaint by itself |
171 |
return null; |
return null; |
172 |
} |
} |
173 |
|
|
174 |
|
// called back by native side: handle_response_cb |
175 |
|
// only called from the GTK thread |
176 |
void gtkHideFileDialog () |
void gtkHideFileDialog () |
177 |
{ |
{ |
178 |
|
// hide calls back the peer's setVisible method, so locking is a |
179 |
|
// problem. |
180 |
((Dialog) awtComponent).hide(); |
((Dialog) awtComponent).hide(); |
181 |
} |
} |
182 |
|
|
183 |
|
// called back by native side: handle_response_cb |
184 |
void gtkDisposeFileDialog () |
void gtkDisposeFileDialog () |
185 |
{ |
{ |
186 |
((Dialog) awtComponent).dispose(); |
((Dialog) awtComponent).dispose(); |
187 |
} |
} |
188 |
|
|
189 |
/* Callback to set the file and directory values when the user is finished |
// Callback to set the file and directory values when the user is finished |
190 |
* with the dialog. |
// with the dialog. |
191 |
*/ |
// called back by native side: handle_response_cb |
192 |
void gtkSetFilename (String fileName) |
void gtkSetFilename (String fileName) |
193 |
{ |
{ |
194 |
FileDialog fd = (FileDialog) awtWidget; |
FileDialog fd = (FileDialog) awtWidget; |