Hi,

Am Donnerstag, den 05.01.2006, 21:36 +0000 schrieb Colin Western:
> dannym wrote:
> 
> >Hi,
> >
> >Am Dienstag, den 03.01.2006, 22:17 +0000 schrieb C Western:
> >  
> >
> >>You might be interested in the attached fragment, which I posted to the 
> >>mailing list a while back. It simulates the windows file Drag and drop 
> >>calls using gtk calls. I would supply a patch to put it in the LCL, only 
> >>I am not sure where to put it.
> >>Colin
> >>    
> >>
> >
> >function DroppedFiles(var Message: TMessage):TStringList;
> >var
> >  i: Integer;
> >begin
> >  Result := TStringList.Create;
> >  try
> >    Result.Text := PChar(Message.lParam);
> >    for i := 0 to Result.Count-1 do
> >      if Pos('file://', Result[i]) = 1 then
> >        Result[i] := Copy(Result[i], 8, Length(Result[i]));
> >
> >dnd urls look like:
> >
> >file://foo.bar.com/path/to/file/on/local/disk
> >
> >You put into the string list:
> >foo.bar.com/path/to/file/on/local/disk
> >  
> >
> The string I get begins file:///home/..., i.e. does not include the hostname

Yes, but the point is that as per freedesktop standard, they should
(and, with newer file managers, they do :))

The reason for supporting that is that with X, you can launch programs
remotely. When you then drag files from a remote program in your X
session to a local program in your X session, it would fetch the wrong
file.

> 
> >And, are you sure you want to keep the hostname in? I'd do something
> >like check if it matches fqdn (or is empty to support broken clients)
> >and if not, set a failed flag, but if so, strip the hostname off (since
> >no pascal function can handle file paths like that anyways :))
> >
> >  
> >
> 
> >You forgot to call gtk_drag_finish in the DropCallBack (or I'm blind :))
> >  
> >
> I set  GTK_DEST_DEFAULT_ALL in DragAccept files, and my reading of the 
> documentation suggests this means that gtk calls gtk_drag_finish 
> automatically

yes, my fault.. I overlooked that... I checked that now and it's true. I
wonder how it determines if the drop was successful or not though O_o
guess it defaults to "yes" :)

> 
> >Note that selection data can contain _multiple_ urls. so split on (I
> >think) #13#10 (or whatever it is) and handle all.
> >  
> >
> This is handled by the string list assignment:
> Result.Text := PChar(Message.lParam);
> which does the split correctly.

I see :)

> 
> >And what does the loop over the targets do in DropCallBack ? the target
> >item doesn't seem to be used for anything in that function ^^
> >  
> >
> It does look odd - I think the intent was to look for a type that could 
> be handled.

I think gtk does that on it's own with the targets list. It would make
sense to do that manually if your target list had completely different
kinds of data in it (f.e. image/png and text/url-list). (so you don't
take an image for an URL or vice versa).

> 
> >Note also that accepting "text/plain" and "STRING" targets is a horrible
> >workaround to support broken clients (after all, it could just be text -
> >and if it is pasted from a edit box, it's "UTF8_STRING", I think), and
> >there should be a comment which says so (since you never know, all
> >broken clients could vanish one day ;) yeah, as if....) 
> >  
> >
> The text does have to begin with file://, which random text will not.

Good point :)

> 
> >I'd call the DragAcceptFiles "RegisterDragAcceptFiles" or so :)
> >  
> >
> DragAcceptFiles is the Windows equivalent - the calls mirror the Windows 
> equivalent pretty much exactly.

Good point.

> 
> Colin

cheers,
   Danny


_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to