mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Show KDE specific "New" sub menu under KDE
This commit is contained in:
parent
01f6a6d149
commit
c91209573b
1 changed files with 57 additions and 3 deletions
|
|
@ -54,8 +54,8 @@ type
|
|||
implementation
|
||||
|
||||
uses
|
||||
LCLProc, Dialogs, IniFiles, Graphics, BaseUnix, Unix, uTypes, uFindEx, uDCUtils,
|
||||
uOSUtils, uFileProcs, uShellExecute, uLng, uGlobs, uPixMapManager,
|
||||
LCLProc, Dialogs, IniFiles, Graphics, Unix, uTypes, uFindEx, uDCUtils,
|
||||
uOSUtils, uFileProcs, uShellExecute, uLng, uGlobs, uPixMapManager, uMyUnix,
|
||||
fMain, fFileProperties
|
||||
{$IFDEF LINUX}
|
||||
, uMimeActions
|
||||
|
|
@ -100,6 +100,60 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function GetKdeTemplateMenu(out Items: TStringList): Boolean;
|
||||
var
|
||||
I: Integer;
|
||||
desktopFile: TIniFile = nil;
|
||||
templateDir: array [0..1] of UTF8String;
|
||||
searchRec: TSearchRecEx;
|
||||
templateName,
|
||||
templatePath: UTF8String;
|
||||
begin
|
||||
Result:= False;
|
||||
try
|
||||
templateDir[0]:= '/usr/share/templates';
|
||||
templateDir[1]:= GetHomeDir + '.kde/share/templates';
|
||||
for I:= Low(templateDir) to High(templateDir) do
|
||||
if mbDirectoryExists(templateDir[I]) then
|
||||
begin
|
||||
if FindFirstEx(templateDir[I] + PathDelim + '*.desktop', faAnyFile, searchRec) = 0 then
|
||||
begin
|
||||
Items:= TStringList.Create;
|
||||
repeat
|
||||
// Skip directories
|
||||
if FPS_ISDIR(searchRec.Attr) then Continue;
|
||||
|
||||
try
|
||||
desktopFile:= TIniFile.Create(templateDir[I] + PathDelim + searchRec.Name);
|
||||
templateName:= desktopFile.ReadString('Desktop Entry', 'Name', EmptyStr);
|
||||
templatePath:= desktopFile.ReadString('Desktop Entry', 'URL', EmptyStr);
|
||||
templatePath:= GetAbsoluteFileName(templateDir[I] + PathDelim, templatePath);
|
||||
|
||||
Items.Add(templateName + '=' + templatePath);
|
||||
finally
|
||||
FreeThenNil(desktopFile);
|
||||
end;
|
||||
until FindNextEx(searchRec) <> 0;
|
||||
Result:= Items.Count > 0;
|
||||
end;
|
||||
FindCloseEx(searchRec);
|
||||
end;
|
||||
finally
|
||||
if Items.Count = 0 then
|
||||
FreeThenNil(Items);
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetTemplateMenu(out Items: TStringList): Boolean;
|
||||
begin
|
||||
case GetDesktopEnvironment of
|
||||
DE_KDE:
|
||||
Result:= GetKdeTemplateMenu(Items);
|
||||
else
|
||||
Result:= GetGnomeTemplateMenu(Items);
|
||||
end;
|
||||
end;
|
||||
|
||||
(* handling user commands from context menu *)
|
||||
procedure TShellContextMenu.ContextMenuSelect(Sender: TObject);
|
||||
var
|
||||
|
|
@ -465,7 +519,7 @@ begin
|
|||
mi.Action := frmMain.actPasteFromClipboard;
|
||||
Self.Items.Add(mi);
|
||||
|
||||
if GetGnomeTemplateMenu(sl) then
|
||||
if GetTemplateMenu(sl) then
|
||||
begin
|
||||
mi:=TMenuItem.Create(Self);
|
||||
mi.Caption:='-';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue