Recent

Author Topic: How to call a function?  (Read 8389 times)

A

  • Guest
Re: How to call a function?
« Reply #15 on: January 07, 2018, 03:45:14 pm »
@jamie

I know, however the issue is, assigning native icons to it programmatically. As of yet, a solution to this is unknown.

To see what I mean, this is an example of LibreOffice running on Linux Mint. Note the toolbar icons:
http://linuxscoop.com/wp-content/uploads/2015/09/Linux-Mint-17.2-Xfce-Libreoffice.png

Now, this is an example of LibreOffice running on a different distribution, using the GTK+ stock icons. Note the toolbar icons:
https://proyectosbeta.net/wp-content/uploads/2012/09/LibreOffice-3.6-en-Debian-Wheezy.png

For other applications, you can find examples of them using Windows' native icon set too.

The reason for this is to allow the application to blend into its native environments where it is being executed.

This is not done by having:
"Download for Linux Mint" - a version with Linux Mint's native icon set in the resource files.
"Download for Debian"      - a version with Debian's native icon set in the resource files.
"Download for Windows"  - a version with Windows' native icon set in the resource files.

No, it is done programmatically and I am trying to figure out how I can apply the same thing with my Lazarus application.

I know it is possible, as many Lazarus components do the same thing (change icons depending on Desktop Environment) - see DirEdit, ButtonPanel, etc.

Other applications that use the same sort of thing include:

- GIMP
- Kate Text Editor
- KeePass
- Geany
- Emacs
- Legacy Versions of Firefox
- And more...

That's what I'm trying to do.

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: How to call a function?
« Reply #16 on: January 07, 2018, 03:53:58 pm »
I windows you have a API call "LoadBitMap" and with it, you can load predefined images

https://msdn.microsoft.com/en-us/library/windows/desktop/dd145033(v=vs.85).aspx

I do not know the calls for Linux , maybe the RTL has a compatible function ?
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: How to call a function?
« Reply #17 on: January 07, 2018, 03:59:56 pm »
Looks like "LoadImage" is the more updated, that also will load the same
The only true wisdom is knowing you know nothing

A

  • Guest
Re: How to call a function?
« Reply #18 on: January 08, 2018, 11:21:18 pm »
Just another thing about the stock image problem I've been having:
I've been searching online some more, as I will be for at least a year, and I've found that somebody has implemented code in Python using GTK's library trying to basically do the same thing as I am:
https://stackoverflow.com/questions/13659445/how-can-i-make-small-stock-icons-in-my-application

So this got me wondering - since Lazarus's applications use GTK (I presume, correct me if I'm wrong), will I be able to do what I am trying to do using the same technique? If so, does anybody have any insight as to how?

Thanks for your help.

_____

PS: Jamie, unfortunately this is not what I need :/ However thanks for your help anyways. :)

A

  • Guest
Re: How to call a function?
« Reply #19 on: January 09, 2018, 11:55:47 am »
Some more evidence of Gtk's libraries being used in Lazarus:
https://forum.lazarus.freepascal.org/index.php?topic=10509.0

I wonder where I would program the design elements using Gtk's libraries?

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: How to call a function?
« Reply #20 on: January 09, 2018, 12:13:07 pm »
So this got me wondering - since Lazarus's applications use GTK (I presume, correct me if I'm wrong)
Yes you are. GTK is the default except for windows, but you can also choose QT, or owner drawn or....
And note not all platforms provide system images like Windows does.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

A

  • Guest
Re: How to call a function?
« Reply #21 on: January 09, 2018, 03:48:15 pm »
Cheers for the reply Thaddy,

I fear that I am quickly becoming the cancer of this forum with my persistence with regards to this problem.

Regardless, is there any way to implement Gtk+'s library via code (how Gtk+ is typically implimented - plain C) in Lazarus? Being so abstacted from the libraries actual code is really problematic for what I'm trying to do.

So, is there a way to either:

1). Program the form(s) in straight C and then somehow connect the Lazarus Object Pascal signals directly to this form?

2). Preferably, just somehow do this in Object Pascal:
https://stackoverflow.com/questions/13659445/how-can-i-make-small-stock-icons-in-my-application
Code: Pascal  [Select][+][-]
  1. def _getCloseIcon(self):
  2.         return gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR)
  3.  

The fact that it has been done in Python makes me believe that it is possible to do it in Pascal (Laz).

Thanks a tonne for your help!

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to call a function?
« Reply #22 on: January 09, 2018, 03:57:02 pm »
Cheers for the reply Thaddy,

I fear that I am quickly becoming the cancer of this forum with my persistence with regards to this problem.

Regardless, is there any way to implement Gtk+'s library via code (how Gtk+ is typically implimented - plain C) in Lazarus? Being so abstacted from the libraries actual code is really problematic for what I'm trying to do.

So, is there a way to either:

1). Program the form(s) in straight C and then somehow connect the Lazarus Object Pascal signals directly to this form?

2). Preferably, just somehow do this in Object Pascal:
https://stackoverflow.com/questions/13659445/how-can-i-make-small-stock-icons-in-my-application
Code: Pascal  [Select][+][-]
  1. def _getCloseIcon(self):
  2.         return gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR)
  3.  

The fact that it has been done in Python makes me believe that it is possible to do it in Pascal (Laz).

Thanks a tonne for your help!
search your disk. in my windows installation I can see a gtk sample included in the folder D:\Lazarus\1.4.4\fpc\2.6.4\source\packages\gtk2\examples\gtk_demo that has everything you need to implement that feature for gtk your self.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

A

  • Guest
Re: How to call a function?
« Reply #23 on: January 11, 2018, 10:59:32 pm »
Thanks Thaddy!

That was a really helpful example project and I have now managed to implement Gtk stock icons to my menubar!

Thanks for resolving my headache!

 

TinyPortal © 2005-2018