From xemacs-m  Sun Jul 27 19:30:26 1997
Received: from komtron.com (root@gatekeeper.komtron.com [194.77.5.33])
	by xemacs.org (8.8.5/8.8.5) with SMTP id TAA27823;
	Sun, 27 Jul 1997 19:30:11 -0500 (CDT)
Received: from slave1.komtron.com by komtron.com with SMTP id AA31755
  (5.67b/IDA-1.5); Mon, 28 Jul 1997 02:34:50 +0200
Received: (from Ufga@localhost) by slave1.komtron.com (8.7.5/8.7.3) with UUCP id CAA02852; Mon, 28 Jul 1997 02:32:36 +0200
X-Authentication-Warning: slave1.komtron.com: Ufga set sender to ograf@fga.de using -f
Received: by fga.de (8.8.5/8.8.5) id TAA13528
Received: by fga.de (8.8.5/8.8.5) id TAA04267
To: xemacs-beta@xemacs.org, SL Baur <steve@xemacs.org>
Subject: [PATCH] OffiX DnD type support for XEmacs
X-Face: [8r}|"6`WFUT0kiC9dBT%edO~lI5Gwog0Z@Cl=Inx|2F=+DjY#0nGtclM)9lU
        c/8JJ%b&&^:&pWh&nYlQbGSk=WdL^%f!<6a:?n)V_snw7Zc+AW10az=||e8Kv
        1PV49Qe64*68G2`)M8O$mlLQ\!O}$d8]T\L?i@$;=WA~0B[k)O.^T'x?O^=EX
        %=gt6(:hG!-|%$EZGq-Dn6r%N6xqOC4voztttHxOMp!2$o+qPAcT2k&dgO~`%
        kVcW7C<3hK[g9vVpk'#B2(f"pN,jBh`
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: multipart/mixed;
 boundary="Multipart_Sun_Jul_27_19:27:53_1997-1"
Content-Transfer-Encoding: 7bit
From: Oliver Graf <ograf@fga.de>
Date: 27 Jul 1997 19:27:53 +0200
Message-Id: <m3d8o4s8va.fsf@indie.fga-intern.de>
Lines: 192
X-Mailer: Gnus v5.4.63/XEmacs 20.3(beta14) - "Vienna"

--Multipart_Sun_Jul_27_19:27:53_1997-1
Content-Type: text/plain; charset=US-ASCII

The attached patch extends the standart handling of OffiX DnD to all possible
(and impossible) DND-Datatypes. I think I have also MULEized the
x_offix_drop_event_handler by using make_ext_string (please correct me if I'm
wrong).

The default-drag-and-drop-functions had been extended so that it will popup
buffers for the DndFile and DndFiles types (as before), insert data stuff
(DndText) at point (also as before) and handle other types as follows:
- DndURL: w3-fetch the URL
- DndDir: dired the Path
- DndMIME: popup data in a new buffer (but I've found no function to mimify
  it)
- DndExe and DndLink: Ignore (suggestions? -- I think all path-style Dnd types 
  are not needed because every path style type can be handled with
  DndFiles... the receiving application will know what the type of the path
  is)
- DndUnknown, DndRawData and any other type: popup in new buffer and hexlify
  the buffer.
(Any suggestions for different handling welcome)

The changes to the default-drag-and-drop-functions *should* be compatible to
others sorts of Dnd (CDE). Please report any problems (solution: splitted
dnd-functions bound after which dnd-feature is implemented).

I will now implement drag functions for OffiX. It looks like I must only
provide a function to set the data/type and start the drag. The actual start
event is matched by the package that wants to use the drag stuff, right
(like the cde-start-drag(-internal) function)?

Regards,
  Oliver.

--Multipart_Sun_Jul_27_19:27:53_1997-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="xe-dnd.diff"
Content-Transfer-Encoding: 7bit

*** xemacs-20.3-b14/src/frame-x.c.orig	Sun Jul 27 19:01:58 1997
--- xemacs-20.3-b14/src/frame-x.c	Sun Jul 27 19:02:57 1997
***************
*** 1178,1209 ****
  
    Lisp_Object path = Qnil;
    Lisp_Object frame = Qnil;
  
!   struct gcpro gcpro1, gcpro2;
  
    Type = DndDataType (event); 
!   if ((Type != DndFile) && (Type != DndFiles) && (Type != DndExe))
!     return;
    DndGetData (&Data, &Size);
    
!   GCPRO2 (path, frame);
  
    frame = make_frame ((struct frame *) data);
! 
!   if (Type == DndFiles)
      {
        while (*Data)
  	{
  	  len = strlen ((char*) Data);
! 	  path = make_string ((char*) Data, len);
  	  va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path);
  	  Data += len+1;
  	}
!     }
!   else
!     {
!       path = make_string ((char*) Data, strlen (Data));    
        va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path);
      }
  
    UNGCPRO;
--- 1178,1231 ----
  
    Lisp_Object path = Qnil;
    Lisp_Object frame = Qnil;
+   Lisp_Object dnd_data = Qnil;
+   Lisp_Object dnd_type = Qnil;
  
!   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
  
    Type = DndDataType (event); 
! 
    DndGetData (&Data, &Size);
    
!   GCPRO4 (path, frame, dnd_data, dnd_type);
  
    frame = make_frame ((struct frame *) data);
!   
!   switch (Type)
      {
+     case DndFiles:
        while (*Data)
  	{
  	  len = strlen ((char*) Data);
! 	  path = make_ext_string ((char*) Data, len, FORMAT_FILENAME);
  	  va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path);
  	  Data += len+1;
  	}
!       break;
!     case DndFile:
!       path = make_ext_string ((char*) Data, strlen(Data), FORMAT_FILENAME);
        va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path);
+       break;
+     case DndText:
+       dnd_data = make_ext_string ((char *) Data, strlen(Data), FORMAT_FILENAME);
+       va_run_hook_with_args (Qdrag_and_drop_functions, 3, frame, path, dnd_data);
+       break;
+     case DndDir:
+     case DndLink:
+     case DndExe:
+     case DndURL:
+     case DndMIME:
+       dnd_type = make_int (Type);
+       dnd_data = make_ext_string ((char*) Data, strlen(Data), FORMAT_FILENAME);
+       va_run_hook_with_args (Qdrag_and_drop_functions, 4,
+ 			     frame, path, dnd_data, dnd_type);
+       break;
+     default: /* Unknown, RawData and any other type */
+       dnd_type = make_int (Type);
+       dnd_data = make_ext_string ((char*) Data, Size, FORMAT_BINARY);
+       va_run_hook_with_args (Qdrag_and_drop_functions, 4,
+ 			     frame, path, dnd_data, dnd_type);
+       break;
      }
  
    UNGCPRO;
*** xemacs-20.3-b14/lisp/prim/frame.el.orig	Sat Jun 21 22:03:00 1997
--- xemacs-20.3-b14/lisp/prim/frame.el	Sun Jul 27 19:03:21 1997
***************
*** 817,834 ****
  (or deselect-frame-hook
      (add-hook 'deselect-frame-hook 'default-deselect-frame-hook))
  
! (defun default-drag-and-drop-functions (frame filepath &optional data)
    "Implements the `drag-and-drop-functions' variable.
  For use as the value of `drag-and-drop-functions'.
! This default simply pops up the file in the selected frame or,
! if the dragged object is a buffer, inserts it at point."
!   (if data
!       (insert data)
!     (let ((x pop-up-windows))
!       (setq pop-up-windows nil)
!       (pop-to-buffer (find-file-noselect filepath) nil frame)
!       (make-frame-visible frame)
!       (setq pop-up-windows x))))
  
  (and (boundp 'drag-and-drop-functions)
       (or drag-and-drop-functions
--- 817,852 ----
  (or deselect-frame-hook
      (add-hook 'deselect-frame-hook 'default-deselect-frame-hook))
  
! (defun default-drag-and-drop-functions (frame filepath &optional data type)
    "Implements the `drag-and-drop-functions' variable.
  For use as the value of `drag-and-drop-functions'.
! A file is popped up in a new buffer, some data without
! is inserted at point, and data with a type is handled
! for it's type (NOTE: type is only set for OffiX DnD)."
!   (cond (type 
! 	 (cond ((or (< type 2) (> type 9)) ;; this is raw data or unknown stuff
! 		(let ((buf (generate-new-buffer "DndRawData")))
! 		  (set-buffer buf)
! 		  (pop-to-buffer buf nil frame)
! 		  (insert data)
! 		  (hexlify-buffer)
! 		  (make-frame-visible frame)))
! 	       ((= type 5) (dired data))
! 	       ((= type 8) (w3-fetch data))
! 	       ((= type 9)
! 		(let ((buf (generate-new-buffer "DndMIME")))
! 		  (set-buffer buf)
! 		  (pop-to-buffer buf nil frame)
! 		  (insert data)
! 		  (make-frame-visible frame)))
! 	       (t (ding))))
! 	(data (insert data))
! 	(t
! 	 (let ((x pop-up-windows))
! 	   (setq pop-up-windows nil)
! 	   (pop-to-buffer (find-file-noselect filepath) nil frame)
! 	   (make-frame-visible frame)
! 	   (setq pop-up-windows x)))))
  
  (and (boundp 'drag-and-drop-functions)
       (or drag-and-drop-functions

--Multipart_Sun_Jul_27_19:27:53_1997-1--

