From d8a2b452ec2729edac1d7c0c1964ea6d0a899769 Mon Sep 17 00:00:00 2001 From: tombo Date: Tue, 8 Apr 2008 13:31:23 +0000 Subject: [PATCH] LCL file dropping under gtk: applied #0011105: Patch to fix file drag and drop problems from Colin Western git-svn-id: trunk@14784 - --- lcl/interfaces/gtk/gtkcallback.inc | 20 ++++++++------------ lcl/interfaces/gtk/gtkproc.pp | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lcl/interfaces/gtk/gtkcallback.inc b/lcl/interfaces/gtk/gtkcallback.inc index b71ecb0bd8..9d5d90e06b 100644 --- a/lcl/interfaces/gtk/gtkcallback.inc +++ b/lcl/interfaces/gtk/gtkcallback.inc @@ -2666,10 +2666,11 @@ procedure GtkDragDataReceived(widget:PGtkWidget; context:PGdkDragContext; var S: TStringList; I: Integer; - FileName: String; + FileName, DecodedFileName: String; Files: Array of String; Form: TControl; Result: Boolean; + U: TURI; begin //DebugLn('GtkDragDataReceived ' + PChar(selection_data^.data)); Result := False; @@ -2686,18 +2687,13 @@ begin FileName := S[I]; if FileName = '' then Continue; - // uri -> file name, maybe for GTK2: g_filename_from_uri // uri = protocol://hostname/file name - // convert uri of local files to file name - if Copy(FileName, 1, 17) = 'file://localhost/' then Delete(FileName, 1, 17) - else - if SameText(Copy(FileName, 1, 8), 'file:///') then - begin - Delete(FileName, 1, 8); - // do not remove UNIX root path - if (Pos(':', FileName) <> 2) and (Pos('/', FileName) <> 1) then - FileName := '/' + FileName; - end; + U := ParseURI(FileName); + if (SameText(U.Host, 'localhost') or (U.Host = '')) and SameText(U.Protocol, 'file') + and URIToFileName(FileName, DecodedFileName) then // convert uri of local files to file name + begin + FileName := DecodedFileName; + end; // otherwise: protocol and hostname are preserved! if FileName = '' then Continue; diff --git a/lcl/interfaces/gtk/gtkproc.pp b/lcl/interfaces/gtk/gtkproc.pp index 449746ba52..77cfda6cf9 100644 --- a/lcl/interfaces/gtk/gtkproc.pp +++ b/lcl/interfaces/gtk/gtkproc.pp @@ -807,7 +807,7 @@ implementation uses {$IFDEF StaticXinerama} Xinerama, {$ENDIF} - dynlibs, GtkWSPrivate; + dynlibs, GtkWSPrivate, URIParser; const KCINFO_FLAG_SHIFT = $01;