comparison src/xfns.c @ 58214:aaad85fd645c

* xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use. Record unwind with clean_up_file_dialog.
author Jan Djärv <jan.h.d@swipnet.se>
date Sun, 14 Nov 2004 09:59:02 +0000
parents 68ea73fe257b
children c163562b2d59
comparison
equal deleted inserted replaced
58213:5201ea9b1985 58214:aaad85fd645c
5103 { 5103 {
5104 int *result = (int *) client_data; 5104 int *result = (int *) client_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.
5111 Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file 5128 Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
5112 selection box, if specified. If MUSTMATCH is non-nil, the returned file 5129 selection box, if specified. If MUSTMATCH is non-nil, the returned file
5124 XmString dir_xmstring, pattern_xmstring; 5141 XmString dir_xmstring, pattern_xmstring;
5125 int count = SPECPDL_INDEX (); 5142 int count = SPECPDL_INDEX ();
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
5132 /* Prevent redisplay. */ 5153 /* Prevent redisplay. */
5133 specbind (Qinhibit_redisplay, Qt); 5154 specbind (Qinhibit_redisplay, Qt);
5206 } 5227 }
5207 5228
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. */
5221 if (result == XmCR_OK) 5245 if (result == XmCR_OK)
5222 { 5246 {
5230 XtFree (data); 5254 XtFree (data);
5231 } 5255 }
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
5241 /* Make "Cancel" equivalent to C-g. */ 5262 /* Make "Cancel" equivalent to C-g. */
5242 if (NILP (file)) 5263 if (NILP (file))
5246 } 5267 }
5247 5268
5248 #endif /* USE_MOTIF */ 5269 #endif /* USE_MOTIF */
5249 5270
5250 #ifdef USE_GTK 5271 #ifdef USE_GTK
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 }
5251 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
5255 selection box, if specified. If MUSTMATCH is non-nil, the returned file 5285 selection box, if specified. If MUSTMATCH is non-nil, the returned file
5259 Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p; 5289 Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
5260 { 5290 {
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
5277 if (STRINGP (default_filename)) 5312 if (STRINGP (default_filename))
5278 cdef_file = SDATA (default_filename); 5313 cdef_file = SDATA (default_filename);