~ubuntu-branches/ubuntu/gutsy/lazarus/gutsy

« back to all changes in this revision

Viewing changes to packager/pkgoptionsdlg.pas

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-05-06 13:46:10 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070506134610-lf4rbsb7p0mx31x1
Tags: 0.9.22-1
* Add homepage to debian/control.
* New upstream release. (Closes: #421850, #408512)
* Remove old patch and add new symlink /usr/bin/startlazarus.
* Add myself to Uploaders.
* Add XS-X-Vcs-Svn header to debian/control.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{  $Id: pkgoptionsdlg.pas 9815 2006-09-05 11:36:29Z mattias $  }
 
1
{  $Id: pkgoptionsdlg.pas 10410 2007-01-09 21:41:45Z mattias $  }
2
2
{
3
3
 /***************************************************************************
4
4
                            pkgoptionsdlg.pas
40
40
uses
41
41
  Classes, SysUtils, LCLProc, Forms, Controls, Buttons, LResources,
42
42
  ExtCtrls, StdCtrls, Spin, Dialogs, PathEditorDlg, IDEProcs, IDEWindowIntf,
 
43
  IDEDialogs, MacroIntf,
43
44
  LazarusIDEStrConsts, BrokenDependenciesDlg, PackageDefs, PackageSystem,
44
45
  CompilerOptions;
45
46
 
46
47
type
 
48
 
 
49
  { TPackageOptionsDialog }
 
50
 
47
51
  TPackageOptionsDialog = class(TForm)
48
52
    Notebook: TNotebook;
49
53
    // Description page
88
92
    IDEPage: TPage;
89
93
    PkgTypeRadioGroup: TRadioGroup;
90
94
    UpdateRadioGroup: TRadioGroup;
 
95
    LazDocGroupBox: TGroupBox;
 
96
    LazDocPathEdit: TEdit;
 
97
    LazDocPathButton: TPathEditorButton;
 
98
    RSTOutputGroupBox: TGroupBox;
 
99
    RSTOutputDirectoryEdit: TEdit;
 
100
    RSTOutputDirectoryButton: TButton;
91
101
    // buttons
92
102
    OkButton: TButton;
93
103
    CancelButton: TButton;
95
105
    procedure AddPathsGroupBoxResize(Sender: TObject);
96
106
    procedure DescriptionPageResize(Sender: TObject);
97
107
    procedure IDEPageResize(Sender: TObject);
 
108
    procedure LazDocPathButtonClick(Sender: TObject);
98
109
    procedure OkButtonClick(Sender: TObject);
 
110
    procedure RSTOutputDirectoryButtonClick(Sender: TObject);
99
111
    procedure PackageOptionsDialogClose(Sender: TObject;
100
112
      var CloseAction: TCloseAction);
101
113
    procedure PackageOptionsDialogResize(Sender: TObject);
184
196
  end else
185
197
  if AButton=LibraryPathButton then begin
186
198
    Templates:='';
 
199
  end else
 
200
  if AButton=LazDocPathButton then begin
 
201
    Templates:='docs';
187
202
  end;
188
203
  AButton.CurrentPathEditor.Path:=OldPath;
189
204
  AButton.CurrentPathEditor.Templates:=SetDirSeparators(Templates);
194
209
  AButton: TPathEditorButton;
195
210
  NewPath: String;
196
211
  AnEdit: TEdit;
 
212
  OldPath: String;
 
213
  CurDir: string;
 
214
  StartPos: Integer;
 
215
  DlgResult: TModalResult;
 
216
  OldStartPos: LongInt;
197
217
begin
198
218
  if not (Sender is TPathEditorButton) then exit;
199
219
  AButton:=TPathEditorButton(Sender);
200
220
  if AButton.CurrentPathEditor.ModalResult<>mrOk then exit;
201
221
  NewPath:=AButton.CurrentPathEditor.Path;
202
222
  AnEdit:=GetEditForPathButton(AButton);
 
223
  OldPath:=AnEdit.Text;
 
224
  if OldPath<>NewPath then begin
 
225
    // check NewPath
 
226
    StartPos:=1;
 
227
    repeat
 
228
      OldStartPos:=StartPos;
 
229
      CurDir:=GetNextDirectoryInSearchPath(NewPath,StartPos);
 
230
      if CurDir<>'' then begin
 
231
        IDEMacros.SubstituteMacros(CurDir);
 
232
        LazPackage.LongenFilename(CurDir);
 
233
        if not FileExists(CurDir) then begin
 
234
          DlgResult:=QuestionDlg('Directory not found',
 
235
            'Directory "'+CurDir+'" not found.',
 
236
            mtError,[mrIgnore,mrYes,'Remove from search path',mrCancel],0);
 
237
          case DlgResult of
 
238
          mrIgnore: ;
 
239
          mrYes:
 
240
            begin
 
241
              // remove directory from search path
 
242
              NewPath:=copy(NewPath,1,OldStartPos-1)
 
243
                       +copy(NewPath,StartPos,length(NewPath));
 
244
              StartPos:=OldStartPos;
 
245
            end;
 
246
          else
 
247
            // undo
 
248
            NewPath:=OldPath;
 
249
            break;
 
250
          end;
 
251
        end;
 
252
      end;
 
253
    until StartPos>length(NewPath);
 
254
  end;
203
255
  AnEdit.Text:=NewPath;
204
256
end;
205
257
 
314
366
  h:=90;
315
367
  with PkgTypeRadioGroup do begin
316
368
    SetBounds(x,y,w,h);
317
 
    inc(y,h+10);
318
369
  end;
319
 
 
320
 
  h:=90;
321
 
  with UpdateRadioGroup do
322
 
    SetBounds(x,y,w,h);
 
370
end;
 
371
 
 
372
procedure TPackageOptionsDialog.LazDocPathButtonClick(Sender: TObject);
 
373
begin
 
374
 
323
375
end;
324
376
 
325
377
procedure TPackageOptionsDialog.OkButtonClick(Sender: TObject);
401
453
    LinkerOptions:=LinkerOptionsMemo.Text;
402
454
    CustomOptions:=CustomOptionsMemo.Text;
403
455
  end;
404
 
  
 
456
  LazPackage.LazDocPaths:=LazDocPathEdit.Text;
 
457
  LazPackage.RSTOutputDirectory:=RSTOutputDirectoryEdit.Text;
 
458
 
405
459
  ModalResult:=mrOk;
406
460
end;
407
461
 
 
462
procedure TPackageOptionsDialog.RSTOutputDirectoryButtonClick(Sender: TObject);
 
463
var
 
464
  NewDirectory: string;
 
465
begin
 
466
  NewDirectory:=LazSelectDirectory(lisPOChoosePoFileDirectory,
 
467
                                   LazPackage.Directory);
 
468
  if NewDirectory='' then exit;
 
469
  LazPackage.ShortenFilename(NewDirectory,true);
 
470
  RSTOutputDirectoryEdit.Text:=NewDirectory;
 
471
end;
 
472
 
408
473
procedure TPackageOptionsDialog.PackageOptionsDialogClose(Sender: TObject;
409
474
  var CloseAction: TCloseAction);
410
475
begin
653
718
  PkgTypeRadioGroup:=TRadioGroup.Create(Self);
654
719
  with PkgTypeRadioGroup do begin
655
720
    Name:='UsageRadioGroup';
656
 
    Parent:=IDEPage;
657
721
    Caption:=lisPckOptsPackageType;
658
722
    with Items do begin
659
723
      BeginUpdate;
664
728
    end;
665
729
    ItemIndex:=2;
666
730
    OnClick:=@PkgTypeRadioGroupClick;
 
731
    Parent:=IDEPage;
667
732
  end;
668
733
 
669
734
  UpdateRadioGroup:=TRadioGroup.Create(Self);
670
735
  with UpdateRadioGroup do begin
671
736
    Name:='UpdateRadioGroup';
672
 
    Parent:=IDEPage;
673
737
    Caption:=lisPckOptsUpdateRebuild;
674
738
    with Items do begin
675
739
      BeginUpdate;
679
743
      EndUpdate;
680
744
    end;
681
745
    ItemIndex:=0;
682
 
  end;
 
746
    Parent:=IDEPage;
 
747
    Height:=90;
 
748
    AnchorToCompanion(akTop,6,PkgTypeRadioGroup);
 
749
  end;
 
750
 
 
751
  // lazdoc
 
752
  LazDocGroupBox:=TGroupBox.Create(Self);
 
753
  with LazDocGroupBox do begin
 
754
    Name:='LazDocGroupBox';
 
755
    Caption:='LazDoc - Lazarus documentation';
 
756
    AnchorToCompanion(akTop,6,UpdateRadioGroup);
 
757
    AutoSize:=true;
 
758
    Parent:=IDEPage;
 
759
  end;
 
760
 
 
761
  LazDocPathEdit:=TEdit.Create(Self);
 
762
  with LazDocPathEdit do begin
 
763
    Name:='LazDocPathEdit';
 
764
    SetBounds(6,0,Width,Height);
 
765
    Parent:=LazDocGroupBox;
 
766
  end;
 
767
 
 
768
  LazDocPathButton:=TPathEditorButton.Create(Self);
 
769
  with LazDocPathButton do begin
 
770
    Name:='LazDocPathButton';
 
771
    Caption:='...';
 
772
    AutoSize:=true;
 
773
    Anchors:=[akTop,akRight,akBottom];
 
774
    AnchorParallel(akRight,6,LazDocGroupBox);
 
775
    Top:=0;
 
776
    AnchorParallel(akBottom,0,LazDocPathEdit);
 
777
    OnClick:=@PathEditBtnClick;
 
778
    OnExecuted:=@PathEditBtnExecuted;
 
779
    Parent:=LazDocGroupBox;
 
780
  end;
 
781
  LazDocPathEdit.AnchorToNeighbour(akRight,0,LazDocPathButton);
 
782
 
 
783
  // PO files
 
784
  RSTOutputGroupBox:=TGroupBox.Create(Self);
 
785
  with RSTOutputGroupBox do begin
 
786
    Name:='POFilesGroupBox';
 
787
    Caption:='Directory of .po files';
 
788
    AnchorToCompanion(akTop,6,LazDocGroupBox);
 
789
    AutoSize:=true;
 
790
    Parent:=IDEPage;
 
791
  end;
 
792
 
 
793
  RSTOutputDirectoryEdit:=TEdit.Create(Self);
 
794
  with RSTOutputDirectoryEdit do begin
 
795
    Name:='POFilesPathEdit';
 
796
    SetBounds(6,0,Width,Height);
 
797
    Parent:=RSTOutputGroupBox;
 
798
  end;
 
799
 
 
800
  RSTOutputDirectoryButton:=TButton.Create(Self);
 
801
  with RSTOutputDirectoryButton do begin
 
802
    Name:='POFilesPathButton';
 
803
    Caption:='...';
 
804
    AutoSize:=true;
 
805
    Anchors:=[akTop,akRight,akBottom];
 
806
    AnchorParallel(akRight,6,RSTOutputGroupBox);
 
807
    Top:=0;
 
808
    AnchorParallel(akBottom,0,RSTOutputDirectoryEdit);
 
809
    OnClick:=@RSTOutputDirectoryButtonClick;
 
810
    Parent:=RSTOutputGroupBox;
 
811
  end;
 
812
  RSTOutputDirectoryEdit.AnchorToNeighbour(akRight,0,RSTOutputDirectoryButton);
683
813
end;
684
814
 
685
815
procedure TPackageOptionsDialog.SetupUsagePage(PageIndex: integer);
859
989
    LinkerOptionsMemo.Text:=LinkerOptions;
860
990
    CustomOptionsMemo.Text:=CustomOptions;
861
991
  end;
 
992
  
 
993
  LazDocPathEdit.Text:=LazPackage.LazDocPaths;
 
994
  RSTOutputDirectoryEdit.Text:=LazPackage.RSTOutputDirectory;
862
995
end;
863
996
 
864
997
procedure TPackageOptionsDialog.ReadPkgTypeFromPackage;
881
1014
    Result:=ObjectPathEdit
882
1015
  else if AButton=LibraryPathButton then
883
1016
    Result:=LibraryPathEdit
 
1017
  else if AButton=LazDocPathButton then
 
1018
    Result:=LazDocPathEdit
884
1019
  else
885
1020
    Result:=nil;
886
1021
end;