diff options
| author | Jan Djärv | 2004-11-02 08:21:16 +0000 |
|---|---|---|
| committer | Jan Djärv | 2004-11-02 08:21:16 +0000 |
| commit | f9d64bb358607b8bb771c5d61eccaea2859d3e5f (patch) | |
| tree | c94b0355ad29207ff09e565c5b613901380ac14c /src/macfns.c | |
| parent | 46bfc73bed2e2b6b3cdfff43f82c6705fb89355c (diff) | |
| download | emacs-f9d64bb358607b8bb771c5d61eccaea2859d3e5f.tar.gz emacs-f9d64bb358607b8bb771c5d61eccaea2859d3e5f.zip | |
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Fx_file_dialog if only directories should be read.
* lisp.h: Fx_file_dialog takes 5 parameters.
* xfns.c (Fx_file_dialog): Both Motif and GTK version: Add
parameter only_dir_p.
In Motif version, don't put DEFAULT_FILENAME in filter part of the
dialog, just text field part. Do not add DEFAULT_FILENAME
to list of files if it isn't there.
In GTK version, pass only_dir_p parameter to xg_get_file_name.
* macfns.c (Fx_file_dialog): Add parameter only_dir_p. Check
only_dir_p instead of comparing prompt to "Dired". When using
a save dialog, add option kNavDontConfirmReplacement, change title
to "Enter name", change text for save button to "Ok".
* w32fns.c (Fx_file_dialog): Add parameter only_dir_p. Check
only_dir_p instead of comparing prompt to "Dired".
* gtkutil.c (xg_get_file_with_chooser)
(xg_get_file_with_selection): New functions, only defined ifdef
HAVE_GTK_FILE_CHOOSER_DIALOG_NEW and HAVE_GTK_FILE_SELECTION_NEW
respectively.
(xg_get_file_name): Add parameter only_dir_p.
Call xg_get_file_with_chooser or xg_get_file_with_selection
depending on HAVE_GTK_FILE* and the value of use_old_gtk_file_dialog.
(xg_initialize): New DEFVAR_BOOL use_old_gtk_file_dialog.
* gtkutil.h (xg_get_file_name): Add parameter only_dir_p.
Diffstat (limited to 'src/macfns.c')
| -rw-r--r-- | src/macfns.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/macfns.c b/src/macfns.c index 88f975a65c8..401c7011fea 100644 --- a/src/macfns.c +++ b/src/macfns.c | |||
| @@ -4216,22 +4216,23 @@ Value is t if tooltip was open, nil otherwise. */) | |||
| 4216 | 4216 | ||
| 4217 | extern Lisp_Object Qfile_name_history; | 4217 | extern Lisp_Object Qfile_name_history; |
| 4218 | 4218 | ||
| 4219 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0, | 4219 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, |
| 4220 | doc: /* Read file name, prompting with PROMPT in directory DIR. | 4220 | doc: /* Read file name, prompting with PROMPT in directory DIR. |
| 4221 | Use a file selection dialog. | 4221 | Use a file selection dialog. |
| 4222 | Select DEFAULT-FILENAME in the dialog's file selection box, if | 4222 | Select DEFAULT-FILENAME in the dialog's file selection box, if |
| 4223 | specified. Ensure that file exists if MUSTMATCH is non-nil. */) | 4223 | specified. Ensure that file exists if MUSTMATCH is non-nil. |
| 4224 | (prompt, dir, default_filename, mustmatch) | 4224 | If ONLY-DIR-P is non-nil, the user can only select directories. */) |
| 4225 | Lisp_Object prompt, dir, default_filename, mustmatch; | 4225 | (prompt, dir, default_filename, mustmatch, only_dir_p) |
| 4226 | Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p; | ||
| 4226 | { | 4227 | { |
| 4227 | struct frame *f = SELECTED_FRAME (); | 4228 | struct frame *f = SELECTED_FRAME (); |
| 4228 | Lisp_Object file = Qnil; | 4229 | Lisp_Object file = Qnil; |
| 4229 | int count = SPECPDL_INDEX (); | 4230 | int count = SPECPDL_INDEX (); |
| 4230 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 4231 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 4231 | char filename[1001]; | 4232 | char filename[1001]; |
| 4232 | int default_filter_index = 1; /* 1: All Files, 2: Directories only */ | 4233 | int default_filter_index = 1; /* 1: All Files, 2: Directories only */ |
| 4233 | 4234 | ||
| 4234 | GCPRO5 (prompt, dir, default_filename, mustmatch, file); | 4235 | GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p); |
| 4235 | CHECK_STRING (prompt); | 4236 | CHECK_STRING (prompt); |
| 4236 | CHECK_STRING (dir); | 4237 | CHECK_STRING (dir); |
| 4237 | 4238 | ||
| @@ -4245,7 +4246,8 @@ specified. Ensure that file exists if MUSTMATCH is non-nil. */) | |||
| 4245 | NavDialogRef dialogRef; | 4246 | NavDialogRef dialogRef; |
| 4246 | NavTypeListHandle fileTypes = NULL; | 4247 | NavTypeListHandle fileTypes = NULL; |
| 4247 | NavUserAction userAction; | 4248 | NavUserAction userAction; |
| 4248 | CFStringRef message=NULL, client=NULL, saveName = NULL; | 4249 | CFStringRef message=NULL, client=NULL, saveName = NULL, ok = NULL; |
| 4250 | CFStringRef title = NULL; | ||
| 4249 | 4251 | ||
| 4250 | BLOCK_INPUT; | 4252 | BLOCK_INPUT; |
| 4251 | /* No need for a callback function because we are modal */ | 4253 | /* No need for a callback function because we are modal */ |
| @@ -4268,13 +4270,19 @@ specified. Ensure that file exists if MUSTMATCH is non-nil. */) | |||
| 4268 | options.clientName = client; | 4270 | options.clientName = client; |
| 4269 | */ | 4271 | */ |
| 4270 | 4272 | ||
| 4271 | /* Do Dired hack copied from w32fns.c */ | 4273 | if (!NILP (only_dir_p)) |
| 4272 | if (!NILP(prompt) && strncmp (SDATA(prompt), "Dired", 5) == 0) | ||
| 4273 | status = NavCreateChooseFolderDialog(&options, NULL, NULL, NULL, | 4274 | status = NavCreateChooseFolderDialog(&options, NULL, NULL, NULL, |
| 4274 | &dialogRef); | 4275 | &dialogRef); |
| 4275 | else if (NILP (mustmatch)) | 4276 | else if (NILP (mustmatch)) |
| 4276 | { | 4277 | { |
| 4277 | /* This is a save dialog */ | 4278 | /* This is a save dialog */ |
| 4279 | ok = CFStringCreateWithCString (NULL, "Ok", kCFStringEncodingUTF8); | ||
| 4280 | title = CFStringCreateWithCString (NULL, "Enter name", | ||
| 4281 | kCFStringEncodingUTF8); | ||
| 4282 | options.optionFlags |= kNavDontConfirmReplacement; | ||
| 4283 | options.actionButtonLabel = ok; | ||
| 4284 | options.windowTitle = title; | ||
| 4285 | |||
| 4278 | if (!NILP(default_filename)) | 4286 | if (!NILP(default_filename)) |
| 4279 | { | 4287 | { |
| 4280 | saveName = CFStringCreateWithCString(NULL, SDATA(default_filename), | 4288 | saveName = CFStringCreateWithCString(NULL, SDATA(default_filename), |
| @@ -4282,20 +4290,10 @@ specified. Ensure that file exists if MUSTMATCH is non-nil. */) | |||
| 4282 | options.saveFileName = saveName; | 4290 | options.saveFileName = saveName; |
| 4283 | options.optionFlags |= kNavSelectDefaultLocation; | 4291 | options.optionFlags |= kNavSelectDefaultLocation; |
| 4284 | } | 4292 | } |
| 4285 | /* MAC_TODO: Find a better way to determine if this is a save | ||
| 4286 | or load dialog than comparing dir with default_filename */ | ||
| 4287 | if (EQ(dir, default_filename)) | ||
| 4288 | { | ||
| 4289 | status = NavCreateChooseFileDialog(&options, fileTypes, | ||
| 4290 | NULL, NULL, NULL, NULL, | ||
| 4291 | &dialogRef); | ||
| 4292 | } | ||
| 4293 | else { | ||
| 4294 | status = NavCreatePutFileDialog(&options, | 4293 | status = NavCreatePutFileDialog(&options, |
| 4295 | 'TEXT', kNavGenericSignature, | 4294 | 'TEXT', kNavGenericSignature, |
| 4296 | NULL, NULL, &dialogRef); | 4295 | NULL, NULL, &dialogRef); |
| 4297 | } | 4296 | } |
| 4298 | } | ||
| 4299 | else | 4297 | else |
| 4300 | { | 4298 | { |
| 4301 | /* This is an open dialog*/ | 4299 | /* This is an open dialog*/ |
| @@ -4324,6 +4322,8 @@ specified. Ensure that file exists if MUSTMATCH is non-nil. */) | |||
| 4324 | if (saveName) CFRelease(saveName); | 4322 | if (saveName) CFRelease(saveName); |
| 4325 | if (client) CFRelease(client); | 4323 | if (client) CFRelease(client); |
| 4326 | if (message) CFRelease(message); | 4324 | if (message) CFRelease(message); |
| 4325 | if (ok) CFRelease(ok); | ||
| 4326 | if (title) CFRelease(title); | ||
| 4327 | 4327 | ||
| 4328 | if (status == noErr) { | 4328 | if (status == noErr) { |
| 4329 | userAction = NavDialogGetUserAction(dialogRef); | 4329 | userAction = NavDialogGetUserAction(dialogRef); |