Implements LCLIntf.OpenDocument to open a document with the default application

git-svn-id: trunk@25413 -
This commit is contained in:
sekelsenmat 2010-05-15 08:49:19 +00:00
parent 8a1ed611d5
commit aa50d358b4

View File

@ -89,6 +89,7 @@ function GetTickStep: DWord;
function FindDefaultBrowser(out ABrowser, AParams: String): Boolean;
function OpenURL(AURL: String): Boolean;
function OpenDocument(APath: String): Boolean;
implementation
@ -239,8 +240,8 @@ begin
Result := ABrowser <> '';
end;
{$IFDEF Windows}
function OpenURL(AURL: String): Boolean;
{$IFDEF Windows}
var
{$IFDEF WinCE}
Info: SHELLEXECUTEINFO;
@ -274,7 +275,6 @@ begin
end;
{$ELSE}
{$IFDEF DARWIN}
function OpenURL(AURL: string): Boolean;
var
cf: CFStringRef;
url: CFURLRef;
@ -290,7 +290,6 @@ begin
CFRelease(cf);
end;
{$ELSE}
function OpenURL(AURL: String): Boolean;
var
ABrowser, AParams: String;
BrowserProcess: TProcessUTF8;
@ -311,6 +310,36 @@ end;
{$ENDIF}
{$ENDIF}
function OpenDocument(APath: String): Boolean;
{$IFDEF Windows}
begin
Result := OpenURL(APath);
end;
{$ELSE}
{$IFDEF DARWIN}
begin
Result := True;
Shell('Open ' + APath);
end;
{$ELSE}
var
lApp: string;
begin
Result := True;
if shell('which xdg-open') = 0 then // Portland OSDL/FreeDesktop standard on Linux
lApp := 'xdg-open '
else if shell('which kfmclient') = 0 then // KDE command
lApp := 'kfmclient exec '
else if shell('which gnome-open') = 0 then// GNOME command
lApp := 'gnome-open '
else Exit(False);
shell(lApp + APath);
end;
{$ENDIF}
{$ENDIF}
{$I winapi.inc}
{$I lclintf.inc}