diff options
| author | Jan Djärv | 2004-11-14 09:59:02 +0000 |
|---|---|---|
| committer | Jan Djärv | 2004-11-14 09:59:02 +0000 |
| commit | 24ca7c5a6fba97df0e29f3de6dd7d5e16b028bf2 (patch) | |
| tree | 42c3d4f962a0627f825238b7a15efea3c5bcb6d8 /src | |
| parent | 6babdce9e8750afafdccefe1bae1cd5cf2d84990 (diff) | |
| download | emacs-24ca7c5a6fba97df0e29f3de6dd7d5e16b028bf2.tar.gz emacs-24ca7c5a6fba97df0e29f3de6dd7d5e16b028bf2.zip | |
* xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
Record unwind with clean_up_file_dialog.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/src/xfns.c b/src/xfns.c index 3179fa1c77b..66b2448527c 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -5105,6 +5105,23 @@ file_dialog_unmap_cb (widget, client_data, call_data) | |||
| 5105 | *result = XmCR_CANCEL; | 5105 | *result = XmCR_CANCEL; |
| 5106 | } | 5106 | } |
| 5107 | 5107 | ||
| 5108 | static Lisp_Object | ||
| 5109 | clean_up_file_dialog (arg) | ||
| 5110 | Lisp_Object arg; | ||
| 5111 | { | ||
| 5112 | struct Lisp_Save_Value *p = XSAVE_VALUE (arg); | ||
| 5113 | Widget dialog = (Widget) p->pointer; | ||
| 5114 | |||
| 5115 | /* Clean up. */ | ||
| 5116 | BLOCK_INPUT; | ||
| 5117 | XtUnmanageChild (dialog); | ||
| 5118 | XtDestroyWidget (dialog); | ||
| 5119 | x_menu_set_in_use (0); | ||
| 5120 | UNBLOCK_INPUT; | ||
| 5121 | |||
| 5122 | return Qnil; | ||
| 5123 | } | ||
| 5124 | |||
| 5108 | 5125 | ||
| 5109 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, | 5126 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, |
| 5110 | doc: /* Read file name, prompting with PROMPT in directory DIR. | 5127 | doc: /* Read file name, prompting with PROMPT in directory DIR. |
| @@ -5126,6 +5143,10 @@ or directory must exist. ONLY-DIR-P is ignored." */) | |||
| 5126 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; | 5143 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 5127 | 5144 | ||
| 5128 | GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); | 5145 | GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); |
| 5146 | |||
| 5147 | if (x_menu_in_use ()) | ||
| 5148 | error ("Trying to use a menu from within a menu-entry"); | ||
| 5149 | |||
| 5129 | CHECK_STRING (prompt); | 5150 | CHECK_STRING (prompt); |
| 5130 | CHECK_STRING (dir); | 5151 | CHECK_STRING (dir); |
| 5131 | 5152 | ||
| @@ -5208,13 +5229,16 @@ or directory must exist. ONLY-DIR-P is ignored." */) | |||
| 5208 | XmStringFree (default_xmstring); | 5229 | XmStringFree (default_xmstring); |
| 5209 | } | 5230 | } |
| 5210 | 5231 | ||
| 5232 | record_unwind_protect (clean_up_file_dialog, make_save_value (dialog, 0)); | ||
| 5233 | |||
| 5211 | /* Process events until the user presses Cancel or OK. */ | 5234 | /* Process events until the user presses Cancel or OK. */ |
| 5212 | result = 0; | 5235 | result = 0; |
| 5213 | while (result == 0) | 5236 | while (result == 0) |
| 5214 | { | 5237 | { |
| 5215 | XEvent event; | 5238 | XEvent event; |
| 5239 | x_menu_wait_for_event (0); | ||
| 5216 | XtAppNextEvent (Xt_app_con, &event); | 5240 | XtAppNextEvent (Xt_app_con, &event); |
| 5217 | (void) x_dispatch_event (&event, FRAME_X_DISPLAY (f) ); | 5241 | (void) x_dispatch_event (&event, FRAME_X_DISPLAY (f)); |
| 5218 | } | 5242 | } |
| 5219 | 5243 | ||
| 5220 | /* Get the result. */ | 5244 | /* Get the result. */ |
| @@ -5232,9 +5256,6 @@ or directory must exist. ONLY-DIR-P is ignored." */) | |||
| 5232 | else | 5256 | else |
| 5233 | file = Qnil; | 5257 | file = Qnil; |
| 5234 | 5258 | ||
| 5235 | /* Clean up. */ | ||
| 5236 | XtUnmanageChild (dialog); | ||
| 5237 | XtDestroyWidget (dialog); | ||
| 5238 | UNBLOCK_INPUT; | 5259 | UNBLOCK_INPUT; |
| 5239 | UNGCPRO; | 5260 | UNGCPRO; |
| 5240 | 5261 | ||
| @@ -5249,6 +5270,15 @@ or directory must exist. ONLY-DIR-P is ignored." */) | |||
| 5249 | 5270 | ||
| 5250 | #ifdef USE_GTK | 5271 | #ifdef USE_GTK |
| 5251 | 5272 | ||
| 5273 | static Lisp_Object | ||
| 5274 | clean_up_dialog (arg) | ||
| 5275 | Lisp_Object arg; | ||
| 5276 | { | ||
| 5277 | x_menu_set_in_use (0); | ||
| 5278 | |||
| 5279 | return Qnil; | ||
| 5280 | } | ||
| 5281 | |||
| 5252 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, | 5282 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, |
| 5253 | doc: /* Read file name, prompting with PROMPT in directory DIR. | 5283 | doc: /* Read file name, prompting with PROMPT in directory DIR. |
| 5254 | Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file | 5284 | Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file |
| @@ -5261,16 +5291,21 @@ directories. */) | |||
| 5261 | FRAME_PTR f = SELECTED_FRAME (); | 5291 | FRAME_PTR f = SELECTED_FRAME (); |
| 5262 | char *fn; | 5292 | char *fn; |
| 5263 | Lisp_Object file = Qnil; | 5293 | Lisp_Object file = Qnil; |
| 5264 | int count = specpdl_ptr - specpdl; | 5294 | int count = SPECPDL_INDEX (); |
| 5265 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; | 5295 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 5266 | char *cdef_file; | 5296 | char *cdef_file; |
| 5267 | 5297 | ||
| 5268 | GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); | 5298 | GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file); |
| 5299 | |||
| 5300 | if (x_menu_in_use ()) | ||
| 5301 | error ("Trying to use a menu from within a menu-entry"); | ||
| 5302 | |||
| 5269 | CHECK_STRING (prompt); | 5303 | CHECK_STRING (prompt); |
| 5270 | CHECK_STRING (dir); | 5304 | CHECK_STRING (dir); |
| 5271 | 5305 | ||
| 5272 | /* Prevent redisplay. */ | 5306 | /* Prevent redisplay. */ |
| 5273 | specbind (Qinhibit_redisplay, Qt); | 5307 | specbind (Qinhibit_redisplay, Qt); |
| 5308 | record_unwind_protect (clean_up_dialog, Qnil); | ||
| 5274 | 5309 | ||
| 5275 | BLOCK_INPUT; | 5310 | BLOCK_INPUT; |
| 5276 | 5311 | ||