1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
unit uIntf;
{
**********************************************************************
This file is part of a Lazarus Package, Examples Window.
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
**********************************************************************
This unit provides the interface between Lazarus and the Package.
}
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
// LazUtils
LazFileUtils, LazConfigStorage, LazLoggerBase,
// LCL,
LCLType,
// BuildIntf
BaseIDEIntf, IDEOptionsIntf,
// IdeIntf
LazIDEIntf, MenuIntf, IDECommands, ToolBarIntf, IDEOptEditorIntf;
procedure Register;
implementation
{$R exampleprojects_images.res}
uses
uLaz_Examples, uConst, ExWinSettings;
// Note : IDEEnvironmentOptions.GetParsedLazarusDirectory is the Lazarus STC tree.
function GetExamplesHomeDir() : string;
var
Config: TConfigStorage;
begin
try
Config := GetIDEConfigStorage(cConfigFileName, true);
try
Result := Config.GetValue('Examples/Directory',
AppendPathDelim(LazarusIDE.GetPrimaryConfigPath));
// + AppendPathDelim(cExamplesDir));
finally
Config.Free;
end;
except
on E: Exception do begin
DebugLn('Examples UIntf GetExamplesDirectory Loading ' + cConfigFileName + ' failed: ' + E.Message);
Result := IDEEnvironmentOptions.GetParsedLazarusDirectory;
end;
end;
end;
procedure IDEMenuSectionClicked(Sender: TObject);
var
ProjectFFile : string;
begin
FormLazExam := TFormLazExam.Create(nil);
try
FormLazExam.ExamplesHome := GetExamplesHomeDir();
FormLazExam.RemoteRepo := cRemoteRepository;
FormLazExam.LazConfigDir := AppendPathDelim(LazarusIDE.GetPrimaryConfigPath);
FormLazExam.ShowModal;
ProjectFFile := FormLazExam.ProjectToOpen;
finally
FormLazExam.Free;
FormLazExam := nil;
end;
if ProjectFFile <> '' then
LazarusIDE.DoOpenProjectFile(ProjectFFile, [ofProjectLoading]);
end;
procedure Register;
var
IDEShortCutX: TIDEShortCut;
IDECommandCategory: TIDECommandCategory;
IDECommand: TIDECommand;
begin
IDEShortCutX := IDEShortCut(VK_E, [ssCtrl, ssAlt], VK_UNKNOWN, []);
IDECommandCategory := IDECommandList.FindCategoryByName('ToolMenu');
IDECommand := nil;
if IDECommandCategory <> nil then
begin
IDECommand := RegisterIDECommand(IDECommandCategory, 'Example Projects', rsExampleProjects, IDEShortCutX, nil, @IDEMenuSectionClicked);
if IDECommand <> nil then
RegisterIDEButtonCommand(IDECommand);
end;
RegisterIDEMenuCommand(itmSecondaryTools, 'Example Projects', rsExampleProjects + ' ...', nil, @IDEMenuSectionClicked, IDECommand, 'pkg_oep');
RegisterIDEMenuCommand(ComponentPalettePageDropDownExtraEntries, 'Example Projects', rsExampleProjects + ' ...', nil, @IDEMenuSectionClicked, nil, 'pkg_oep');
ExWinOptionsFrameID := RegisterIDEOptionsEditor(ExWindowOptionsGroup, TExWinSettingsFrame, 9999)^.Index; // AIndex = what ???
end;
initialization
finalization
end.
|