mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Use KDE function to move into trash under KDE
This commit is contained in:
parent
30b7efcea7
commit
40a274cc28
4 changed files with 55 additions and 4 deletions
|
|
@ -209,7 +209,7 @@ begin
|
|||
else
|
||||
begin
|
||||
// Delete to trash (one function for file and folder)
|
||||
DeleteResult:= mbDeleteToTrash(FileName);
|
||||
DeleteResult:= FileTrashUtf8(FileName);
|
||||
if not DeleteResult then
|
||||
begin
|
||||
case FDeleteDirectly of
|
||||
|
|
|
|||
|
|
@ -1,3 +1,25 @@
|
|||
{
|
||||
Double Commander
|
||||
-------------------------------------------------------------------------
|
||||
K Desktop Environment integration unit
|
||||
|
||||
Copyright (C) 2014-2015 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
}
|
||||
|
||||
unit uKde;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
|
@ -15,7 +37,7 @@ var
|
|||
implementation
|
||||
|
||||
uses
|
||||
uDCUtils, uGlobs, uGlobsPaths, uOSUtils;
|
||||
uDCUtils, uGlobs, uGlobsPaths, uOSUtils, uClipboard, uTrash;
|
||||
|
||||
var
|
||||
PythonScript: UTF8String = 'scripts/doublecmd-kde.py';
|
||||
|
|
@ -31,12 +53,18 @@ begin
|
|||
Result:= ExecCmdFork('python ' + PythonScript + Args);
|
||||
end;
|
||||
|
||||
function FileTrash(const FileName: UTF8String): Boolean;
|
||||
begin
|
||||
Result:= fpSystemStatus('kioclient move ' + FileNameToURI(FileName) + ' trash:/') = 0;
|
||||
end;
|
||||
|
||||
procedure Initialize;
|
||||
begin
|
||||
UseKde:= (DesktopEnv = DE_KDE);
|
||||
if UseKde then
|
||||
begin
|
||||
PythonScript:= gpExePath + PythonScript;
|
||||
if ExecutableInSystemPath('kioclient') then FileTrashUtf8:= @FileTrash;
|
||||
UseKde:= (fpSystemStatus('python ' + PythonScript + ' > /dev/null 2>&1') = 0);
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
This unit contains specific UNIX functions.
|
||||
|
||||
Copyright (C) 2008-2013 Koblov Alexander (Alexx2000@mail.ru)
|
||||
Copyright (C) 2008-2015 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -192,6 +192,7 @@ function FileIsUnixExecutable(const Filename: UTF8String): Boolean;
|
|||
@returns(Mount point of file system)
|
||||
}
|
||||
function FindMountPointPath(const FileName: UTF8String): UTF8String;
|
||||
function ExecutableInSystemPath(const FileName: UTF8String): Boolean;
|
||||
function GetDefaultAppCmd(const FileName: UTF8String): UTF8String;
|
||||
function GetFileMimeType(const FileName: UTF8String): UTF8String;
|
||||
{en
|
||||
|
|
@ -239,7 +240,7 @@ var
|
|||
implementation
|
||||
|
||||
uses
|
||||
URIParser, Unix, FileUtil, DCClassesUtf8, DCStrUtils, uDCUtils, uOSUtils
|
||||
URIParser, Unix, FileUtil, DCClassesUtf8, DCStrUtils, uDCUtils, DCBasicTypes, uOSUtils
|
||||
{$IF (NOT DEFINED(FPC_USE_LIBC)) or (DEFINED(BSD) AND NOT DEFINED(DARWIN))}
|
||||
, SysCall
|
||||
{$ENDIF}
|
||||
|
|
@ -425,6 +426,22 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function ExecutableInSystemPath(const FileName: UTF8String): Boolean;
|
||||
var
|
||||
I: Integer;
|
||||
Path: String;
|
||||
Value: TDynamicStringArray;
|
||||
begin
|
||||
Path:= GetEnvironmentVariable('PATH');
|
||||
Value:= SplitString(Path, PathSeparator);
|
||||
for I:= Low(Value) to High(Value) do
|
||||
begin
|
||||
if fpAccess(IncludeTrailingPathDelimiter(Value[I]) + FileName, X_OK) = 0 then
|
||||
Exit(True);
|
||||
end;
|
||||
Result:= False;
|
||||
end;
|
||||
|
||||
function GetDefaultAppCmd(const FileName: UTF8String): UTF8String;
|
||||
{$IF NOT DEFINED(DARWIN)}
|
||||
var
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ function mbDeleteToTrash(const FileName: UTF8String): Boolean;
|
|||
// 14.05.2009 - this funсtion checks trash availability.
|
||||
function mbCheckTrash(sPath: UTF8String): Boolean;
|
||||
|
||||
var
|
||||
FileTrashUtf8: function(const FileName: UTF8String): Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
|
|
@ -307,5 +310,8 @@ begin
|
|||
end;
|
||||
{$ENDIF}
|
||||
|
||||
initialization
|
||||
FileTrashUtf8:= @mbDeleteToTrash;
|
||||
|
||||
end.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue