summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Djärv <jan.h.d@swipnet.se>2004-11-14 09:59:02 +0000
committerJan Djärv <jan.h.d@swipnet.se>2004-11-14 09:59:02 +0000
commit24ca7c5a6fba97df0e29f3de6dd7d5e16b028bf2 (patch)
tree42c3d4f962a0627f825238b7a15efea3c5bcb6d8
parent6babdce9e8750afafdccefe1bae1cd5cf2d84990 (diff)
downloademacs-24ca7c5a6fba97df0e29f3de6dd7d5e16b028bf2.tar.gz
* xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
Record unwind with clean_up_file_dialog.
-rw-r--r--src/xfns.c45
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)
*result = XmCR_CANCEL;
}
+static Lisp_Object
+clean_up_file_dialog (arg)
+ Lisp_Object arg;
+{
+ struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
+ Widget dialog = (Widget) p->pointer;
+
+ /* Clean up. */
+ BLOCK_INPUT;
+ XtUnmanageChild (dialog);
+ XtDestroyWidget (dialog);
+ x_menu_set_in_use (0);
+ UNBLOCK_INPUT;
+
+ return Qnil;
+}
+
DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
doc: /* Read file name, prompting with PROMPT in directory DIR.
@@ -5126,6 +5143,10 @@ or directory must exist. ONLY-DIR-P is ignored." */)
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
+
+ if (x_menu_in_use ())
+ error ("Trying to use a menu from within a menu-entry");
+
CHECK_STRING (prompt);
CHECK_STRING (dir);
@@ -5208,13 +5229,16 @@ or directory must exist. ONLY-DIR-P is ignored." */)
XmStringFree (default_xmstring);
}
+ record_unwind_protect (clean_up_file_dialog, make_save_value (dialog, 0));
+
/* Process events until the user presses Cancel or OK. */
result = 0;
while (result == 0)
{
XEvent event;
+ x_menu_wait_for_event (0);
XtAppNextEvent (Xt_app_con, &event);
- (void) x_dispatch_event (&event, FRAME_X_DISPLAY (f) );
+ (void) x_dispatch_event (&event, FRAME_X_DISPLAY (f));
}
/* Get the result. */
@@ -5232,9 +5256,6 @@ or directory must exist. ONLY-DIR-P is ignored." */)
else
file = Qnil;
- /* Clean up. */
- XtUnmanageChild (dialog);
- XtDestroyWidget (dialog);
UNBLOCK_INPUT;
UNGCPRO;
@@ -5249,6 +5270,15 @@ or directory must exist. ONLY-DIR-P is ignored." */)
#ifdef USE_GTK
+static Lisp_Object
+clean_up_dialog (arg)
+ Lisp_Object arg;
+{
+ x_menu_set_in_use (0);
+
+ return Qnil;
+}
+
DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
doc: /* Read file name, prompting with PROMPT in directory DIR.
Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
@@ -5261,16 +5291,21 @@ directories. */)
FRAME_PTR f = SELECTED_FRAME ();
char *fn;
Lisp_Object file = Qnil;
- int count = specpdl_ptr - specpdl;
+ int count = SPECPDL_INDEX ();
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
char *cdef_file;
GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
+
+ if (x_menu_in_use ())
+ error ("Trying to use a menu from within a menu-entry");
+
CHECK_STRING (prompt);
CHECK_STRING (dir);
/* Prevent redisplay. */
specbind (Qinhibit_redisplay, Qt);
+ record_unwind_protect (clean_up_dialog, Qnil);
BLOCK_INPUT;