Recent

Author Topic: How do you change a package icon once set?  (Read 6311 times)

Aruna

  • Hero Member
  • *****
  • Posts: 793
How do you change a package icon once set?
« on: July 19, 2025, 05:06:37 am »
In the Lazarus IDE top menu ,These are the steps I used to build a new custom component.:
  • Package
  • New Package
  • Add
  • New Component --> Select TcustomControl
The first screenshot shows the form after following the steps above — this is where you can assign an icon to your component. So far, everything works as expected. The second screenshot shows the component after compiling and installing the package, and again, no issues there.

Now, I have two questions:

1. Changing the Component Icon:
If I want to update the icon and use a different one, what’s the correct way to do that? I couldn’t find clear instructions for replacing the existing icon.

2. Issue with Publishing the Package:
When I tried to publish the package and set a custom folder path, the dialog said it was published successfully. However, upon checking, the test files I had placed in that folder were deleted, and nothing was saved or published. While this isn’t a major issue for me, I thought it was worth bringing to the developers' attention, since the warning mechanism works but the publishing doesn't seem to save anything.

EDIT: Screenshots 3 and 4 are for issue 2.


« Last Edit: July 19, 2025, 05:17:46 am by Aruna »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4689
  • I like bugs.
Re: How do you change a package icon once set?
« Reply #1 on: July 19, 2025, 01:21:29 pm »
1. Changing the Component Icon:
There is no easy way. There should be a nice GUI for setting / replacing the icons but there isn't. What more, the New Component feature is outdated and uses the old .lrs resource format. It needs a revamp and update for .res format.
(Hint for anybody who wants to take a piece of Lazarus IDE under his care)

Quote
2. Issue with Publishing the Package:
Uhhh, that is another bug then. It used to work some years ago after I improved the Publish Project / Package feature.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Aruna

  • Hero Member
  • *****
  • Posts: 793
Re: How do you change a package icon once set?
« Reply #2 on: July 19, 2025, 01:46:16 pm »
1. Changing the Component Icon:
There is no easy way. There should be a nice GUI for setting / replacing the icons but there isn't. What more, the New Component feature is outdated and uses the old .lrs resource format. It needs a revamp and update for .res format.
(Hint for anybody who wants to take a piece of Lazarus IDE under his care)
  Alright, let me dig into this a bit more and see if I can contribute something useful.

2. Issue with Publishing the Package:
Uhhh, that is another bug then. It used to work some years ago after I improved the Publish Project / Package feature.
Please double check and see if you can re-produce the same experience I had.  I will dig into this as well  ;)

wp

  • Hero Member
  • *****
  • Posts: 13401
Re: How do you change a package icon once set?
« Reply #3 on: July 19, 2025, 02:29:48 pm »
I never use the "New Component" dialog for this. Doing it manually gives me full control:
  • Create a new project for testing the new component. Add a new unit for the new component and add the component code (or put it into an existing unit). Write code in the project so that the component can be tested.
  • When the component works correctly at this runtime test - and only then - create a new package: "Package" > "New package" (or open an existing one to which you want to add the new component).
  • Add the component unit to the package. Add also any requirements of other packages. In the unit add a Register procedure which calls RegisterComponents (or call this from a common registration unit).
  • Compile the package. When ok install it. Test again.
  • Find or draw an icon for the component, ideally in png format. Usually you need three versions: one for 96 ppi screen resolution, one for 144 ppi, and one for 192 ppi. The name of the icon must match the name of the component. Append a "_150" and a "_200" for the 144ppi and 192 ppi versions, respectively. Example: for a component "TMySuperButton" the icon files must be named "tmysuperbutton.png", "tmysuperbutton_150.png" and "tmysuperbutton_200.png" (lowercase not mandatory, using it here just for conveniency).
  • Write a batch file (or shell script in Linux) to create a resource file for the icons: "lazres  MyResourceFile.res @files.txt" Here MyResourceFile.res is the name of the resourcefile to be created, and files.txt is a simple text file which contains each icon name per line. Run the batch/script to create the resource file.
  • Link the resourcefile to the package by adding a line {$R MyResourceFile.res} after the "implementation" of the registration unit.
  • Do a clean rebuild of the IDE ("clean" required to be sure that the new resource is used.)
  • Done!
  • Now returning to your question how to replace the icon: Copy the new icon files over the existing files, run the batch/script to recreate the resource file, and do a clean rebuild of the IDE again -- this is easy now once you understood the whole process.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4689
  • I like bugs.
Re: How do you change a package icon once set?
« Reply #4 on: July 19, 2025, 04:15:20 pm »
Please double check and see if you can re-produce the same experience I had.  I will dig into this as well  ;)
Yes there is a bug. I does not copy any files.
It may be a small thing that can easily be found by debugging. You can try. I can look at it later.

wp, the process works yes but there should be a nice GUI to automate it.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4689
  • I like bugs.
Re: How do you change a package icon once set?
« Reply #5 on: July 19, 2025, 09:34:40 pm »
Yes there is a bug. I does not copy any files.
It may be a small thing that can easily be found by debugging. You can try. I can look at it later.
Yes, actually copying package files works well but compressing them does not. Only a project gets compressed. I think the compression feature was added last and not tested with packages. :(

[Edit] Fixed in 33e034b595. Please test. I will merge it to fixes_4 but it will not make it to the 4.2 release. No problem, there will be other releases later.
« Last Edit: July 19, 2025, 10:23:48 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Aruna

  • Hero Member
  • *****
  • Posts: 793
Re: How do you change a package icon once set?
« Reply #6 on: July 20, 2025, 12:20:17 am »
I never use the "New Component" dialog for this. Doing it manually gives me full control:
Thank you wp for the help and guidance.But, I just got here wp where as you have been around the block more than a few times. It was a learning experience for me that is my excuse and I feel it is always good to learn more than one way to do things? Same end result but different methods like in the movie 'Brick Mansions'  with Paul Walker and David Belle that was some movie!

  • Create a new project for testing the new component. Add a new unit for the new component and add the component code (or put it into an existing unit). Write code in the project so that the component can be tested.
  • When the component works correctly at this runtime test - and only then - create a new package: "Package" > "New package" (or open an existing one to which you want to add the new component).
  • Add the component unit to the package. Add also any requirements of other packages. In the unit add a Register procedure which calls RegisterComponents (or call this from a common registration unit).
  • Compile the package. When ok install it. Test again.
This is more or less what I did...

  • Find or draw an icon for the component, ideally in png format. Usually you need three versions: one for 96 ppi screen resolution, one for 144 ppi, and one for 192 ppi. The name of the icon must match the name of the component. Append a "_150" and a "_200" for the 144ppi and 192 ppi versions, respectively. Example: for a component "TMySuperButton" the icon files must be named "tmysuperbutton.png", "tmysuperbutton_150.png" and "tmysuperbutton_200.png" (lowercase not mandatory, using it here just for conveniency).
I did not have to rename my icons to match the name of the component. I just clicked the button where it asks for the three icons 24x24 then 36x36 and 48x48 browsed to my image file and it loaded fine and compiled ok then installed no hiccups.

The other thing I did while experimenting is to open up the *.lrs file in a text editor and I changed the component name and it worked. Like shown below where it says 'TToggle' it said TCustomControl5' before, I do realize this may not be the way to do things.
I just wanted to get things working so was fiddling literally everything and anything I could think of  :-[

Code: Text  [Select][+][-]
  1. LazarusResources.Add('[TToggle','PNG',[
  2.   #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
  3.   +#0#0#4'sBIT'#8#8#8#8'|'#8'd'#136#0#0#0#9'pHYs'#0#0#0#166#0#0#0#166#1#221'}'
  4.   +#255'8'#0#0#0#25'tEXtSoftware'#0'www.inkscape.org'#155#238'<'#26#0#0#1'+IDAT'
  5.   +'H'#137#221#212#189'J'#3'A'#20#5#224'ob'#26#193'B'#16'R'#8'bg/h!'#164#150'46'
  6.   +#150'>'#130'O h'#145#23#176#177#14#216#251#0#130#133#133#141#176')'#236#5#17
  7.   +';'#241#167#17#236'T'#198#194')'#242#183#187'Y'#221'4'#30#184'0g'#231#236#189
  8.   +'s'#207#222'Y1F'#147#2'-'#156#224#17'gh'#229'i'#139#162'!'#31'G'#248#192':'
  9.   +#238#208'+'#208#230#163#160#131#23','#165#245#28#158#177'Zg'#7#183#216'H'#135
  10.   +#248#194'9v'#234#236'`'#15#151#3'|'#23#23'U;(*'#208#196'=6'#19'_'#192#27#22
  11.   +'j'#177'('#198#248#137'c'#28'$'#254#142'kl'#215'bQ:'#245#188#159'1]K|'#31#167
  12.   +#181'X4P'#228#16#189#180'^'#193#19#26'u'#22'X'#196'+'#150#19#191#193'V-'#5
  13.   +#208'F'#134#152#19#25#218#127')'#144#161'S'#176#223'AV'#148'#$'#225'D'#132#16
  14.   +'b'#140'1'#20#13'I'#169#166#162'%e1fY%K'#166#24#136'1'#203#134','#154#198#146
  15.   +'2'#140#230'('#250#217#213#130#255'W'#160#31'B'#232#252'6Yz'#183'?'#244'p'
  16.   +#214'cZ'#233#162#133#16#186#233'P'#221'<'#205'(f'#254#13#154'%'#251'W#'#252
  17.   +'a'#10#205#16#190#1#138#171#202#191'")'#239#250#0#0#0#0'IEND'#174'B`'#130
  18. ]);
    • Write a batch file (or shell script in Linux) to create a resource file for the icons: "lazres  MyResourceFile.res @files.txt" Here MyResourceFile.res is the name of the resourcefile to be created, and files.txt is a simple text file which contains each icon name per line. Run the batch/script to create the resource file.
    • Link the resourcefile to the package by adding a line {$R MyResourceFile.res} after the "implementation" of the registration unit.
    • Do a clean rebuild of the IDE ("clean" required to be sure that the new resource is used.)
    • Done!
      Why not keep the old .lrs format and alow the end-user to choose which one he/she wants to go with?

    Now returning to your question how to replace the icon: Copy the new icon files over the existing files, run the batch/script to recreate the resource file, and do a clean rebuild of the IDE again -- this is easy now once you understood the whole process.
    I prefer to keep multiple icon sets so overwriting in my case is a no-no. Just way too much work and time spent on creating those darn blasted 24x24 icons by hand so uh-uh I am not overwriting them.[/list]
    « Last Edit: July 20, 2025, 12:26:28 am by Aruna »

    Aruna

    • Hero Member
    • *****
    • Posts: 793
    Re: How do you change a package icon once set?
    « Reply #7 on: July 20, 2025, 12:34:34 am »
    Please double check and see if you can re-produce the same experience I had.  I will dig into this as well  ;)
    Yes there is a bug. I does not copy any files.
    It may be a small thing that can easily be found by debugging. You can try. I can look at it later.
    Juha, so if I want to debug the actual IDE source let's say if I open up /home/aruna/lazarus/packager/pkgmanager.pas then set a breakpoint on line :158:   procedure MainIDEitmPkgNewPackageClick(Sender: TObject); this shoudl trigger and activate the debugger? (Yes / Nope / Definitely a maybe?) I have not done this before. I have debugged my own projects many times but never tried with the actual IDE.

    wp, the process works yes but there should be a nice GUI to automate it.
    Once I fully understand packageeditor.pas, I'll create a user-friendly GUI to automate everything
    « Last Edit: July 20, 2025, 01:49:57 am by Aruna »

    Aruna

    • Hero Member
    • *****
    • Posts: 793
    Re: How do you change a package icon once set?
    « Reply #8 on: July 20, 2025, 05:56:19 am »
    wp, the process works yes but there should be a nice GUI to automate it.
    Juha,

    The first screenshot shows an additional menu item under the Package Manager > Use menu — we now have an Icon Resource Manager. 🎉
    The second screenshot speaks for itself. We’re making progress!

    That said, once again I find myself humbled by the Lazarus IDE, not just by its features, but by the work of a single individual.
    It took me a long time to even begin to grasp the depth of what he’s built, and I’m still only scratching the surface.

    Mattias Gaertner, if you ever read this, know that your contributions are monumental. I have many questions, and I suspect only you would truly know the answers.
    How can one reach Mattias Gaertner? I would genuinely love to ask him a few things.

    Also, credit where it’s due — this time around, ChatGPT has been incredibly helpful. I truly couldn’t have gotten this far without its assistance.

    n7800

    • Hero Member
    • *****
    • Posts: 644
    • Lazarus IDE contributor
      • GitLab profile
    Re: How do you change a package icon once set?
    « Reply #9 on: July 20, 2025, 11:02:26 am »
    so if I want to debug the actual IDE source let's say if I open up /home/aruna/lazarus/packager/pkgmanager.pas then set a breakpoint on line :158:   procedure MainIDEitmPkgNewPackageClick(Sender: TObject); this shoudl trigger and activate the debugger? (Yes / Nope / Definitely a maybe?) I have not done this before. I have debugged my own projects many times but never tried with the actual IDE.

    To debug Lazarus itself, you need to open the ide/lazarus.lpi project and run it with [F9]. The second IDE will start in debug mode. The breakpoints you set in the first one will work in it. Don't get confused in the windows ))

    The lazarus.lpi project is special, and exists only for writing code and debugging (before that, it must already be rebuilt).
    * To rebuild, use only Menu > Tools > Build Lazarus (not Run > Build).
    * To configure the build mode, use only Menu > Tools > Configure Build Lazarus (not Project Options). For debugging, the IDE must be built in "debug" mode.

    The IDE has to be rebuilt (restarted) after each change, so that lazarus.exe is replaced with a new one. Don't forget to do this, otherwise the old version will work.

    n7800

    • Hero Member
    • *****
    • Posts: 644
    • Lazarus IDE contributor
      • GitLab profile
    Re: How do you change a package icon once set?
    « Reply #10 on: July 20, 2025, 11:34:43 am »
    Mattias Gaertner, if you ever read this, know that your contributions are monumental. I have many questions, and I suspect only you would truly know the answers.
    How can one reach Mattias Gaertner? I would genuinely love to ask him a few things.

    I agree that this developer's contribution is enormous, he wrote most of the source code, including key parts of the IDE.

    But one person can't answer all the questions for everyone, especially if he has to take time away from writing code. That's why a question asked on the forum is better than a personal question. Other developers/users will be able to answer you too, and this answer will be visible to others. We will also be interested in learning something ))

    Aruna

    • Hero Member
    • *****
    • Posts: 793
    Re: How do you change a package icon once set?
    « Reply #11 on: July 20, 2025, 12:09:11 pm »
    so if I want to debug the actual IDE source let's say if I open up /home/aruna/lazarus/packager/pkgmanager.pas then set a breakpoint on line :158:   procedure MainIDEitmPkgNewPackageClick(Sender: TObject); this shoudl trigger and activate the debugger? (Yes / Nope / Definitely a maybe?) I have not done this before. I have debugged my own projects many times but never tried with the actual IDE.

    To debug Lazarus itself, you need to open the ide/lazarus.lpi project and run it with [F9]. The second IDE will start in debug mode. The breakpoints you set in the first one will work in it. Don't get confused in the windows ))

    The lazarus.lpi project is special, and exists only for writing code and debugging (before that, it must already be rebuilt).
    * To rebuild, use only Menu > Tools > Build Lazarus (not Run > Build).
    * To configure the build mode, use only Menu > Tools > Configure Build Lazarus (not Project Options). For debugging, the IDE must be built in "debug" mode.

    The IDE has to be rebuilt (restarted) after each change, so that lazarus.exe is replaced with a new one. Don't forget to do this, otherwise the old version will work.
    🙏 Thank you!

    Aruna

    • Hero Member
    • *****
    • Posts: 793
    Re: How do you change a package icon once set?
    « Reply #12 on: July 20, 2025, 12:32:28 pm »
    Mattias Gaertner, if you ever read this, know that your contributions are monumental. I have many questions, and I suspect only you would truly know the answers.
    How can one reach Mattias Gaertner? I would genuinely love to ask him a few things.

    I agree that this developer's contribution is enormous, he wrote most of the source code, including key parts of the IDE.

    But one person can't answer all the questions for everyone, especially if he has to take time away from writing code. That's why a question asked on the forum is better than a personal question. Other developers/users will be able to answer you too, and this answer will be visible to others. We will also be interested in learning something ))
    The reason I was hoping for a direct dialogue with Mattias is simply because he wrote the packageeditor.pas unit. Who better to understand the intent behind the design, and who else could explain the best way to hook into certain areas without breaking things? It was never meant to bypass or diminish the importance of the broader community, quite the opposite. I am very sorry if it came out that way and my sincere and humble apologies if I have offended anyone.

    I have the greatest respect for every single person who gives their time freely to help others here on the forum. A few folks come to mind right away: yourself, n7800 when I was completely lost dealing with git, and Tron, who was the very first to try and help me sort a grid on an integer field. I’ve probably caused high blood pressure at times for MarkMLl  when I was working on the IRC client and the Arduino serial comm, and 'I' said "everything is a file"—I think at that point Mark wanted me committed to a psychiatric asylum. 😄 I did manage to really piss him off. but then somehow I got it to work 😅. And FredVS when I was trying to get sound working on that sine wave generator. Joanna when she called in kee because for the life of me I simply could not figure out how to install Lazarus under QEMU. Too many people have helped me and I have learned from to mention individually but here is a big thank you to one and all of you.

    But honestly, so many people have helped me, and I’ve learned something valuable from every single one of you. I’m truly grateful and happy to be part of this community. Thank you again for everything you do.

    n7800, I have a question for you if I may please. In the packageeditor.pas how does one get a form to display when a menu item is clicked? I have managed to get the ShowMessage dialog working but I need to display a from that has our icon stuff in it like the option to select between the .lrs legacy format or the .res newer format. If anyone out there knows please show me how!

    Aruna

    • Hero Member
    • *****
    • Posts: 793
    Re: How do you change a package icon once set?
    « Reply #13 on: July 20, 2025, 01:57:31 pm »
    I felt it would be a disservice to anyone I’ve interacted with on the forum—even just once—not to be fully transparent and express my thanks. So, in the spirit of openness and in the hope of making everyone feel seen (which is easier said than done!), here is a list of people I want to say THANK YOU to for all that you do.

    The list is sorted alphabetically—no ranking or priority implied. Every single person is valued and appreciated!
    • 440bx               
    • ALLIGATOR           
    • ASerge               
    • AlanTheBeast         
    • Ally                 
    • Arend041             
    • Bart                 
    • BrunoK               
    • CharlyTango         
    • Curt Carpenter       
    • Fibonacci           
    • GabrielMoraru.com   
    • Gustavo 'Gus' Carreno
    • Guva                 
    • Handoko               
    • Hartmut               
    • Joanna               
    • Jonax                 
    • JuhaManninen   
    • Kays                 
    • Khrys                 
    • KodeZwerg             
    • LBoxPO               
    • LV                   
    • Lutz Mändle           
    • Marc                 
    • MarkMLl               
    • Martin_fr             
    • Mr.Madguy             
    • Nimbus               
    • PeterBB               
    • PierceNg             
    • Remy Lebeau           
    • Roland57               
    • Sieben                 
    • TBMan                 
    • TRon                   
    • Thaddy                 
    • Tony Stone             
    • VisualLab             
    • Wallaby               
    • Warfley               
    • WayneSherman           
    • What I can do         
    • Zvoni                 
    • ackarwow               
    • af0815         // Removed double entry       
    • alpine                 
    • arnoldpa               
    • avra                   
    • bobby100               
    • bpranoto               
    • ccrause               
    • cdbc                   
    • dbannon       EDIT: Corrected misspelled name. My apologies Davo  :-[         
    • dseligo               
    • dsiders               
    • gidesa                 
    • gues1                 
    • jamie                 
    • jcmontherock           
    • jeremiah               
    • jwdietrich             
    • lainz                 
    • marcov                 
    • mav                   
    • munair                 
    • paule32               
    • paweld                 
    • petevick               
    • rca                   
    • rvk                   
    • silvercoder70         
    • szlbz                 
    • tetrastes             
    • varianus               
    • vfclists               
    • wizzwizz4             
    • wp                     
    « Last Edit: July 22, 2025, 04:19:18 am by Aruna »

    n7800

    • Hero Member
    • *****
    • Posts: 644
    • Lazarus IDE contributor
      • GitLab profile
    Re: How do you change a package icon once set?
    « Reply #14 on: July 20, 2025, 03:32:09 pm »
    The reason I was hoping for a direct dialogue with Mattias is simply because he wrote the packageeditor.pas unit. Who better to understand the intent behind the design, and who else could explain the best way to hook into certain areas without breaking things? It was never meant to bypass or diminish the importance of the broader community, quite the opposite. I am very sorry if it came out that way and my sincere and humble apologies if I have offended anyone.

    No offense, your intentions to look at the author of the unit and contact him are completely logical. I just wanted to say that no matter who created the unit, in open source software it is often supplemented by many other developers (and contributors). So it is possible that other team members also know it, or knowledge about it is scattered among the participants ))

     

    TinyPortal © 2005-2018