;;;; File handling.
-(defun x-file-dialog (prompt dir default_filename mustmatch only_dir_p)
-"Read file name, prompting with PROMPT in directory DIR.
-Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
-selection box, if specified. If MUSTMATCH is non-nil, the returned file
-or directory must exist.
-
-This function is only defined on PGTK, MS Windows, and X Windows with the
-Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
-Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories."
- (pgtk-read-file-name prompt dir mustmatch default_filename only_dir_p))
-
-(defun pgtk-open-file-using-panel ()
- "Pop up open-file panel, and load the result in a buffer."
- (interactive)
- ;; Prompt dir defaultName isLoad initial.
- (setq pgtk-input-file (pgtk-read-file-name "Select File to Load" nil t nil))
- (if pgtk-input-file
- (and (setq pgtk-input-file (list pgtk-input-file)) (pgtk-find-file))))
-
-(defun pgtk-write-file-using-panel ()
- "Pop up save-file panel, and save buffer in resulting name."
- (interactive)
- (let (pgtk-output-file)
- ;; Prompt dir defaultName isLoad initial.
- (setq pgtk-output-file (pgtk-read-file-name "Save As" nil nil nil))
- (message pgtk-output-file)
- (if pgtk-output-file (write-file pgtk-output-file))))
-
(defcustom pgtk-pop-up-frames 'fresh
"Non-nil means open files upon request from the Workspace in a new frame.
If t, always do so. Any other non-nil value means open a new frame
(declare-function pgtk-hide-emacs "pgtkfns.c" (on))
-(defun pgtk-find-file ()
- "Do a `find-file' with the `pgtk-input-file' as argument."
- (interactive)
- (let* ((f (file-truename
- (expand-file-name (pop pgtk-input-file)
- command-line-default-directory)))
- (file (find-file-noselect f))
- (bufwin1 (get-buffer-window file 'visible))
- (bufwin2 (get-buffer-window "*scratch*" 'visible)))
- (cond
- (bufwin1
- (select-frame (window-frame bufwin1))
- (raise-frame (window-frame bufwin1))
- (select-window bufwin1))
- ((and (eq pgtk-pop-up-frames 'fresh) bufwin2)
- (pgtk-hide-emacs 'activate)
- (select-frame (window-frame bufwin2))
- (raise-frame (window-frame bufwin2))
- (select-window bufwin2)
- (find-file f))
- (pgtk-pop-up-frames
- (pgtk-hide-emacs 'activate)
- (let ((pop-up-frames t)) (pop-to-buffer file nil)))
- (t
- (pgtk-hide-emacs 'activate)
- (find-file f)))))
-
(defun pgtk-drag-n-drop (event &optional new-frame force-text)
"Edit the files listed in the drag-n-drop EVENT.
/* Called when a delete-event occurs on WIDGET. */
+#ifndef HAVE_PGTK
static gboolean
delete_cb (GtkWidget *widget,
GdkEvent *event,
{
return TRUE;
}
+#endif
/* Create and set up the GTK widgets for frame F.
Return true if creation succeeded. */
}
+#ifndef HAVE_GTK3
/* This callback is called when a tool bar item shall be redrawn.
It modifies the expose event so that the GtkImage widget redraws the
whole image. This to overcome a bug that makes GtkImage draw the image
return FALSE;
}
+#endif
/* Attach a tool bar to frame F. */
PGTK_TRACE("x_set_background_color: col.pixel=%08lx.", col.pixel);
FRAME_X_OUTPUT(f)->background_color = col.pixel;
FRAME_BACKGROUND_PIXEL (f) =
- ARGB_TO_ULONG ((int)(0xff), (int)(col.red>>8), (int)(col.green>>8), (int)(col.blue>>8));
+ ARGB_TO_ULONG ((unsigned int)(0xff), (unsigned int)(col.red>>8), (unsigned int)(col.green>>8), (unsigned int)(col.blue>>8));
xg_set_background_color(f, col.pixel);
update_face_from_frame_parameter (f, Qbackground_color, arg);
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
+selection box, if specified. If MUSTMATCH is non-nil, the returned file
+or directory must exist.
+
+This function is defined only on PGTK, NS, MS Windows, and X Windows with the
+Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
+Otherwise, if ONLY-DIR-P is non-nil, the user can select only directories.
+On MS Windows 7 and later, the file selection dialog "remembers" the last
+directory where the user selected a file, and will open that directory
+instead of DIR on subsequent invocations of this function with the same
+value of DIR as in previous invocations; this is standard MS Windows behavior. */)
+ (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
+{
+ struct frame *f = SELECTED_FRAME ();
+ char *fn;
+ Lisp_Object file = Qnil;
+ Lisp_Object decoded_file;
+ ptrdiff_t count = SPECPDL_INDEX ();
+ char *cdef_file;
+
+ check_window_system (f);
+
+ CHECK_STRING (prompt);
+ CHECK_STRING (dir);
+
+ /* Prevent redisplay. */
+ specbind (Qinhibit_redisplay, Qt);
+#if 0
+ record_unwind_protect_void (clean_up_dialog);
+#endif
+
+ block_input ();
+
+ if (STRINGP (default_filename))
+ cdef_file = SSDATA (default_filename);
+ else
+ cdef_file = SSDATA (dir);
+
+ fn = xg_get_file_name (f, SSDATA (prompt), cdef_file,
+ ! NILP (mustmatch),
+ ! NILP (only_dir_p));
+
+ if (fn)
+ {
+ file = build_string (fn);
+ xfree (fn);
+ }
+
+ unblock_input ();
+
+ /* Make "Cancel" equivalent to C-g. */
+ if (NILP (file))
+ quit ();
+
+ decoded_file = DECODE_FILE (file);
+
+ return unbind_to (count, decoded_file);
+}
+
DEFUN ("pgtk-backend-display-class", Fpgtk_backend_display_class, Spgtk_backend_display_class,
0, 1, "",
doc: /* Returns the name of the Gdk backend display class of the TERMINAL.
defsubr (&Spgtk_print_frames_dialog);
defsubr (&Spgtk_backend_display_class);
+ defsubr (&Sx_file_dialog);
+
as_status = 0;
as_script = Qnil;
as_result = 0;