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/xfns.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/xfns.c')
| -rw-r--r-- | src/xfns.c | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/src/xfns.c b/src/xfns.c index 01d528e2790..2cf8a59ca52 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -5106,27 +5106,26 @@ file_dialog_unmap_cb (widget, client_data, call_data) | |||
| 5106 | } | 5106 | } |
| 5107 | 5107 | ||
| 5108 | 5108 | ||
| 5109 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0, | 5109 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, |
| 5110 | doc: /* Read file name, prompting with PROMPT in directory DIR. | 5110 | doc: /* Read file name, prompting with PROMPT in directory DIR. |
| 5111 | Use a file selection dialog. | 5111 | Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file |
| 5112 | Select DEFAULT-FILENAME in the dialog's file selection box, if | 5112 | selection box, if specified. If MUSTMATCH is non-nil, the returned file |
| 5113 | specified. Don't let the user enter a file name in the file | 5113 | or directory must exist. ONLY-DIR-P is ignored." */) |
| 5114 | selection dialog's entry field, if MUSTMATCH is non-nil. */) | 5114 | (prompt, dir, default_filename, mustmatch, only_dir_p) |
| 5115 | (prompt, dir, default_filename, mustmatch) | 5115 | Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p; |
| 5116 | Lisp_Object prompt, dir, default_filename, mustmatch; | ||
| 5117 | { | 5116 | { |
| 5118 | int result; | 5117 | int result; |
| 5119 | struct frame *f = SELECTED_FRAME (); | 5118 | struct frame *f = SELECTED_FRAME (); |
| 5120 | Lisp_Object file = Qnil; | 5119 | Lisp_Object file = Qnil; |
| 5121 | Widget dialog, text, list, help; | 5120 | Widget dialog, text, help; |
| 5122 | Arg al[10]; | 5121 | Arg al[10]; |
| 5123 | int ac = 0; | 5122 | int ac = 0; |
| 5124 | extern XtAppContext Xt_app_con; | 5123 | extern XtAppContext Xt_app_con; |
| 5125 | XmString dir_xmstring, pattern_xmstring; | 5124 | XmString dir_xmstring, pattern_xmstring; |
| 5126 | int count = SPECPDL_INDEX (); | 5125 | int count = SPECPDL_INDEX (); |
| 5127 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 5126 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 5128 | 5127 | ||
| 5129 | GCPRO5 (prompt, dir, default_filename, mustmatch, file); | 5128 | GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); |
| 5130 | CHECK_STRING (prompt); | 5129 | CHECK_STRING (prompt); |
| 5131 | CHECK_STRING (dir); | 5130 | CHECK_STRING (dir); |
| 5132 | 5131 | ||
| @@ -5159,9 +5158,9 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) | |||
| 5159 | XtAddCallback (dialog, XmNunmapCallback, file_dialog_unmap_cb, | 5158 | XtAddCallback (dialog, XmNunmapCallback, file_dialog_unmap_cb, |
| 5160 | (XtPointer) &result); | 5159 | (XtPointer) &result); |
| 5161 | 5160 | ||
| 5162 | /* Disable the help button since we can't display help. */ | 5161 | /* Remove the help button since we can't display help. */ |
| 5163 | help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON); | 5162 | help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON); |
| 5164 | XtSetSensitive (help, False); | 5163 | XtUnmanageChild (help); |
| 5165 | 5164 | ||
| 5166 | /* Mark OK button as default. */ | 5165 | /* Mark OK button as default. */ |
| 5167 | XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON), | 5166 | XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON), |
| @@ -5183,30 +5182,30 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) | |||
| 5183 | /* Manage the dialog, so that list boxes get filled. */ | 5182 | /* Manage the dialog, so that list boxes get filled. */ |
| 5184 | XtManageChild (dialog); | 5183 | XtManageChild (dialog); |
| 5185 | 5184 | ||
| 5186 | /* Select DEFAULT_FILENAME in the files list box. DEFAULT_FILENAME | ||
| 5187 | must include the path for this to work. */ | ||
| 5188 | list = XmFileSelectionBoxGetChild (dialog, XmDIALOG_LIST); | ||
| 5189 | if (STRINGP (default_filename)) | 5185 | if (STRINGP (default_filename)) |
| 5190 | { | 5186 | { |
| 5191 | XmString default_xmstring; | 5187 | XmString default_xmstring; |
| 5192 | int item_pos; | 5188 | Widget wtext = XmFileSelectionBoxGetChild (dialog, XmDIALOG_TEXT); |
| 5189 | Widget list = XmFileSelectionBoxGetChild (dialog, XmDIALOG_LIST); | ||
| 5193 | 5190 | ||
| 5194 | default_xmstring | 5191 | XmTextPosition last_pos = XmTextFieldGetLastPosition (wtext); |
| 5195 | = XmStringCreateLocalized (SDATA (default_filename)); | 5192 | XmTextFieldReplace (wtext, 0, last_pos, |
| 5193 | (SDATA (Ffile_name_nondirectory (default_filename)))); | ||
| 5196 | 5194 | ||
| 5197 | if (!XmListItemExists (list, default_xmstring)) | 5195 | /* Select DEFAULT_FILENAME in the files list box. DEFAULT_FILENAME |
| 5198 | { | 5196 | must include the path for this to work. */ |
| 5199 | /* Add a new item if DEFAULT_FILENAME is not in the list. */ | 5197 | |
| 5200 | XmListAddItem (list, default_xmstring, 0); | 5198 | default_xmstring = XmStringCreateLocalized (SDATA (default_filename)); |
| 5201 | item_pos = 0; | ||
| 5202 | } | ||
| 5203 | else | ||
| 5204 | item_pos = XmListItemPos (list, default_xmstring); | ||
| 5205 | XmStringFree (default_xmstring); | ||
| 5206 | 5199 | ||
| 5207 | /* Select the item and scroll it into view. */ | 5200 | if (XmListItemExists (list, default_xmstring)) |
| 5208 | XmListSelectPos (list, item_pos, True); | 5201 | { |
| 5209 | XmListSetPos (list, item_pos); | 5202 | int item_pos = XmListItemPos (list, default_xmstring); |
| 5203 | /* Select the item and scroll it into view. */ | ||
| 5204 | XmListSelectPos (list, item_pos, True); | ||
| 5205 | XmListSetPos (list, item_pos); | ||
| 5206 | } | ||
| 5207 | |||
| 5208 | XmStringFree (default_xmstring); | ||
| 5210 | } | 5209 | } |
| 5211 | 5210 | ||
| 5212 | /* Process events until the user presses Cancel or OK. */ | 5211 | /* Process events until the user presses Cancel or OK. */ |
| @@ -5250,23 +5249,23 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) | |||
| 5250 | 5249 | ||
| 5251 | #ifdef USE_GTK | 5250 | #ifdef USE_GTK |
| 5252 | 5251 | ||
| 5253 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0, | 5252 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, |
| 5254 | "Read file name, prompting with PROMPT in directory DIR.\n\ | 5253 | doc: /* Read file name, prompting with PROMPT in directory DIR. |
| 5255 | Use a file selection dialog.\n\ | 5254 | Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file |
| 5256 | Select DEFAULT-FILENAME in the dialog's file selection box, if\n\ | 5255 | selection box, if specified. If MUSTMATCH is non-nil, the returned file |
| 5257 | specified. Don't let the user enter a file name in the file\n\ | 5256 | or directory must exist. If ONLY-DIR-P is non-nil, the user can only select |
| 5258 | selection dialog's entry field, if MUSTMATCH is non-nil.") | 5257 | directories. */) |
| 5259 | (prompt, dir, default_filename, mustmatch) | 5258 | (prompt, dir, default_filename, mustmatch, only_dir_p) |
| 5260 | Lisp_Object prompt, dir, default_filename, mustmatch; | 5259 | Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p; |
| 5261 | { | 5260 | { |
| 5262 | FRAME_PTR f = SELECTED_FRAME (); | 5261 | FRAME_PTR f = SELECTED_FRAME (); |
| 5263 | char *fn; | 5262 | char *fn; |
| 5264 | Lisp_Object file = Qnil; | 5263 | Lisp_Object file = Qnil; |
| 5265 | int count = specpdl_ptr - specpdl; | 5264 | int count = specpdl_ptr - specpdl; |
| 5266 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 5265 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 5267 | char *cdef_file; | 5266 | char *cdef_file; |
| 5268 | 5267 | ||
| 5269 | GCPRO5 (prompt, dir, default_filename, mustmatch, file); | 5268 | GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); |
| 5270 | CHECK_STRING (prompt); | 5269 | CHECK_STRING (prompt); |
| 5271 | CHECK_STRING (dir); | 5270 | CHECK_STRING (dir); |
| 5272 | 5271 | ||
| @@ -5280,7 +5279,9 @@ selection dialog's entry field, if MUSTMATCH is non-nil.") | |||
| 5280 | else | 5279 | else |
| 5281 | cdef_file = SDATA (dir); | 5280 | cdef_file = SDATA (dir); |
| 5282 | 5281 | ||
| 5283 | fn = xg_get_file_name (f, SDATA (prompt), cdef_file, ! NILP (mustmatch)); | 5282 | fn = xg_get_file_name (f, SDATA (prompt), cdef_file, |
| 5283 | ! NILP (mustmatch), | ||
| 5284 | ! NILP (only_dir_p)); | ||
| 5284 | 5285 | ||
| 5285 | if (fn) | 5286 | if (fn) |
| 5286 | { | 5287 | { |