Recent

Author Topic: Open the project folder.  (Read 1163 times)

Otto

  • Full Member
  • ***
  • Posts: 224
Open the project folder.
« on: February 19, 2020, 10:48:48 am »
Mainly I use Lazarus on Windows, I would need to know if, from the Project Inspector, there was a way to open the project folder in a Windows File Explorer.
If not, how to add a button to the Project Inspector to achieve this?

Otto.
Kind regards.

GetMem

  • Hero Member
  • *****
  • Posts: 3685
Re: Open the project folder.
« Reply #1 on: February 19, 2020, 11:43:44 am »
@Otto

Right click the source editor's statusbar,  like in the attached picture. Then click "Open folder".

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3775
  • I like bugs.
Re: Open the project folder.
« Reply #2 on: February 19, 2020, 11:49:51 am »
Mainly I use Lazarus on Windows, I would need to know if, from the Project Inspector, there was a way to open the project folder in a Windows File Explorer.
You can open it from source editor's status bar. Mouse right-click on the file name opens a popup menu with "Open folder ...". Just open the project main file or any file in the project directory and there you go.
It works on every platform by opening the default file manager. For example on my KDE system Dolphin gets opened.

Quote
If not, how to add a button to the Project Inspector to achieve this?
Currently there is no API to extend it. If you add a popup item in the Files section for this task and create a patch, it will surely be accepted.
Most people don't need this feature so a button for everybody is an overkill. But yes, it should be extensible with plugins.

[Edit] Oops, GetMem was faster ... :)

Otto

  • Full Member
  • ***
  • Posts: 224
Re: Open the project folder.
« Reply #3 on: February 19, 2020, 12:07:08 pm »
Thank you all.

Where can I find the documentation for creating new plugins?
For now I found : https://wiki.freepascal.org/Extending_the_IDE

Otto.
« Last Edit: February 19, 2020, 12:23:39 pm by Otto »
Kind regards.

Otto

  • Full Member
  • ***
  • Posts: 224
Re: Open the project folder.
« Reply #4 on: February 19, 2020, 06:10:30 pm »
I analyzed the Lazarus IDE code in the projectinspector.pas file and I think that I've identified the changes to be made to add a button to the Project Inspector.

Code: Pascal  [Select][+][-]
  1. // Add the following code to the file  projectinspector.pas
  2. uses
  3.    LCLIntF;
  4.  
  5. OpenPrjFolderBitBtn: TToolButton;
  6. procedure OpenPrjFolderBitBtnClick(Sender: TObject);
  7.  
  8.  
  9. procedure TProjectInspectorForm.OpenPrjFolderBitBtnClick(Sender: TObject);
  10. var
  11.   ADirectory:String;
  12. begin
  13.   ADirectory:=LazProject.Directory;
  14.   if ADirectory<>'' then
  15.     OpenURL(ADirectory);
  16. end;  
  17.  
  18. OpenPrjFolderBitBtn := CreateToolButton('OpenPrjFolderBitBtn', 'Open Folder', 'Open Project Folder', 'Open_project_folder', @OpenPrjFolderBitBtnClick);      
  19.  
  20.  

Unfortunately, I have no experience in compiling the Lazzarus IDE and would need help to verify that it is working properly.

Otto.
« Last Edit: February 21, 2020, 09:55:03 am by Otto »
Kind regards.

Otto

  • Full Member
  • ***
  • Posts: 224
Re: Open the project folder.
« Reply #5 on: February 20, 2020, 06:57:26 am »

I managed to test the change in Windows 10 64bit. Everything works correctly apart from the fact that the button does not yet have the image. I attached the modified "projectinspector.pas" file in case it was useful to someone, the changes are preceded by a comment line containing the string "Modified by Otto" and terminated with an empty comment line.

I used the "Tools > Build Lazarus" command to recompile the IDE. Previously I also tried to recompile the project using the project "lazarus-ide-lazarus.lpi", in an attempt to obtain an independent test IDE, but the build failed.

Otto.
« Last Edit: February 20, 2020, 01:41:15 pm by Otto »
Kind regards.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3775
  • I like bugs.
Re: Open the project folder.
« Reply #6 on: February 21, 2020, 02:22:36 am »
I managed to test the change in Windows 10 64bit. Everything works correctly apart from the fact that the button does not yet have the image. I attached the modified "projectinspector.pas" file in case it was useful to someone, the changes are preceded by a comment line containing the string "Modified by Otto" and terminated with an empty comment line.
Good. You studied lots of code.
In future you can learn to make patches, too:
 https://wiki.freepascal.org/Creating_A_Patch
The wiki page Extending_the_IDE was correct. As you can see extensions are limited. For example the project inspector window has no API.
If you are interested you can create such an API to IDEIntf package and it can be added to Lazarus trunk. Just remember that an API should be intuitive. Once it is published it will not be changed easily.

Quote
I used the "Tools > Build Lazarus" command to recompile the IDE. Previously I also tried to recompile the project using the project "lazarus-ide-lazarus.lpi", in an attempt to obtain an independent test IDE, but the build failed.
Yes, that was the right way to build. Project lazarus.lpi can now be used only for debugging.

Otto

  • Full Member
  • ***
  • Posts: 224
Re: Open the project folder.
« Reply #7 on: February 21, 2020, 01:31:37 pm »
Thank you JuhaManninen, for your precious advice.

Creating a patch requires the use of the trunk/development version of Lazarus, is it correct to use fpcupdeluxe to get it? Do I have to use the FPC trunk to build?

Otto.
Kind regards.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3775
  • I like bugs.
Re: Open the project folder.
« Reply #8 on: February 21, 2020, 05:53:54 pm »
Creating a patch requires the use of the trunk/development version of Lazarus, is it correct to use fpcupdeluxe to get it?
You can use fpcupdeluxe also for installing Lazarus but it is not really needed.
Just install the release version of FPC and download Lazarus sources from SVN server. Then run "make".

Quote
Do I have to use the FPC trunk to build?
No. Lazarus trunk supports at least FPC 3.0.x and development branches 3.2 and trunk.

FYI, I got excited with this open folder idea in a popup menu of both project inspector and package editor so I implemented it in r62656 (trunk).
I used OpenDocument() but I guess OpenURL() works, too.
Please test.

BTW, there are some API menu section hooks in MenuIntf for package editor :
Code: Pascal  [Select][+][-]
  1.   // Package editor(s)
  2.   PackageEditorMenuRoot: TIDEMenuSection = nil;
  3.     PkgEditMenuSectionFiles: TIDEMenuSection; // e.g. sort files, clean up files
  4.     PkgEditMenuSectionUse: TIDEMenuSection; // e.g. install, add to project
  5.     PkgEditMenuSectionSave: TIDEMenuSection; // e.g. save as, revert, publish
  6.     PkgEditMenuSectionCompile: TIDEMenuSection; // e.g. build clean, create Makefile
  7.     PkgEditMenuSectionAddRemove: TIDEMenuSection; // e.g. add unit, add dependency
  8.     PkgEditMenuSectionMisc: TIDEMenuSection; // e.g. options
  9.   PackageEditorMenuFilesRoot: TIDEMenuSection = nil;
  10.     PkgEditMenuSectionFile: TIDEMenuSection; // e.g. open file, remove file, move file up/down
  11.     PkgEditMenuSectionDirectory: TIDEMenuSection; // e.g. change all properties of all files in a directory and ub directories moved ..
  12.     PkgEditMenuSectionDependency: TIDEMenuSection; // e.g. open package, remove dependency
It means a user plugin can add menu items there.
No access for the toolbar is provided though.
« Last Edit: February 21, 2020, 05:56:40 pm by JuhaManninen »

GetMem

  • Hero Member
  • *****
  • Posts: 3685
Re: Open the project folder.
« Reply #9 on: February 21, 2020, 06:05:38 pm »
@Otto

1. Install TorotiseSVN(https://tortoisesvn.net/downloads.html), it's free
2. Create a "Lazarus" folder somewhere
3. Right click "Lazarus" folder, then "SVN Checkout...". The following dialog will apear(see screenshot1)
4. Type/paste in the URL: "https://svn.freepascal.org/svn/lazarus/trunk" , press OK
5. After the checkout is done, create a batch file(lazarus.bat for example), with the following content:
Quote
set path=C:\FPC\3.0.4\bin\i386-win32\;
make bigide
where the path must point to a valid FPC installation
6. Copy lazarus.bat inside the Lazarus folder, then doubleclick the bat file. If everything works well, the trunk IDE is build.
7. To create a patch, right click Lazarus folder then click "Create patch...". See attachment2.

PS: Make sure you backup your config folder, just in case. If you have a standard installation lazarus trunk may overwrite the settings.
« Last Edit: February 21, 2020, 06:10:28 pm by GetMem »

Otto

  • Full Member
  • ***
  • Posts: 224
Re: Open the project folder.
« Reply #10 on: February 21, 2020, 07:04:43 pm »
@JuhaManninen

Very good JuhaManninen. I am glad to have contributed, albeit for such a small thing, to the development of the Lazarus IDE.


FYI, I got excited with this open folder idea in a popup menu of both project inspector and package editor so I implemented it in r62656 (trunk).
I used OpenDocument() but I guess OpenURL() works, too.
Please test.

I will run the tests as soon as possible.

FYI, I have other ideas for extending The features of Lazarus, but I have yet to verify them.
Could I use the IDE Window: External Tool to speed up the verification process?
(I have not yet used the external tools, because it has only recently been suggested to me by the bonmario user.)

Otto.
Kind regards.

Otto

  • Full Member
  • ***
  • Posts: 224
Re: Open the project folder.
« Reply #11 on: February 21, 2020, 07:15:54 pm »
@ GetMem

Thank you very much GetMem.
Your guide is really very exhaustive, thanks to it I will greatly reduce the time it takes to configure the environment to carry out the tests.

Otto.
Kind regards.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3775
  • I like bugs.
Re: Open the project folder.
« Reply #12 on: February 21, 2020, 08:42:10 pm »
FYI, I have other ideas for extending The features of Lazarus, but I have yet to verify them.
Could I use the IDE Window: External Tool to speed up the verification process?
No if you modify the code of Lazarus IDE itself. Then you must build the IDE and see how it behaves.
It can be debugged with breakpoints and stepping and all by running the lazarus.lpi project after building with debug info.
Mouse and keyboard events may mess up such debugging.
A better way then is to add DebugLn() lines to your code and read their output. DebugLn has nice overloads with variant parameters. Search Lazarus source for examples.
« Last Edit: February 21, 2020, 08:44:33 pm by JuhaManninen »

Otto

  • Full Member
  • ***
  • Posts: 224
Re: Open the project folder.
« Reply #13 on: February 21, 2020, 09:12:57 pm »
@ JuhaManninen

A better way then is to add DebugLn() lines to your code and read their output. DebugLn has nice overloads with variant parameters. Search Lazarus source for examples.

I'm going to study what you suggested.



I tested the version r62656 (trunk).
Everything looks good, great job.

Otto.
Kind regards.

Otto

  • Full Member
  • ***
  • Posts: 224
Re: Open the project folder.
« Reply #14 on: February 23, 2020, 09:31:00 pm »
@ JuhaManninen

Hello.
To add the open folder in a popup menu of project inspector
you had to edit other files besides “projectinspector.pas” ?

Are the main changes as follows?
Code: Pascal  [Select][+][-]
  1. +     LCLIntf,
  2. +     procedure mnuOpenFolderClick(Sender: TObject);
  3. +     AddPopupMenuItem(cLineCaption, Nil, False);                // Separator
  4. +     AddPopupMenuItem(lisMenuOpenFolder, @mnuOpenFolderClick);
  5.  
  6. +     procedure TProjectInspectorForm.mnuOpenFolderClick(Sender: TObject);
  7. +     begin
  8. +       OpenDocument(LazProject.Directory);
  9. +     end;
  10.  

I ask this because, if possible (perhaps in the near future), I would like to add an SVN control (or similar) from within the project inspector. So that project sources can be synchronized or compared to online sources directly, without using external programs.

As you already know I had a little problem with svn2revisioninc , so I started studying the code. A volte non tutti i mali vengono per nuocere [Sometimes not all evils come to harm].

Greetings.
Otto.
Kind regards.

 

TinyPortal © 2005-2018