Page 1 of 1

GTK on Windows

Posted: Mon Nov 16, 2009 4:07 am
by klaver
Hello, I recently was tinkering with GTK2 on Windows (runtimes needed). I think it's nice to use it as it allows 1:1 port of GUI through all platforms. So if you are developing cross-platform software you wouldn't be afraid of using API for making GUI more advanced anymore, as GTK API is the same on all platforms. Of course as long as required runtimes are not a problem (it's only about 6 MiB).

To PB Team: is there chance of getting the PB GUI library (windows & gadgets) from Linux made on GTK, but compiled for use on Windows with runtimes? Of course only as option for coders who want to use it.

If you would like to try GTK on Win32, you should get runtimes:
http://gtk-win.sourceforge.net/home/ind ... /Downloads

And a package for PureBasic:
http://drkaczka.ovh.org/pbgtk.zip

It contains libraries made with DLL Importer (only some of functions imported, quite far from being finished), gtk.res (PB resident from Linux, contains structures and constants) and few examples. I also included fixed DLL Importer as the one with PB4.31 is bugged.

Re: GTK on Windows

Posted: Wed Nov 18, 2009 10:06 am
by klaver
I was wrong - GTK is using CDECL instead of StdCall, so DLL Importer can't be used for this.
Now I did it with ImportC...EndImport and imported functions from .lib libraries that are made for the runtimes and it's all working great.
Link: http://drkaczka.ovh.org/gtk2pb.zip
Image

I spent hundreds of hours tinkering with my controls on Windows (backgrounds, ownerdrawn & colored gadgets, editable listviews etc etc) just to realize it's all useless when I needed my app on Linux (it's still long way for WINE btw). Now I'm going to learn GTK API and start making nice cross-platform GUI with it :)

The last thing that I need is to know is what to do with functions that has variable number of arguments?
Any ideas about this? Thanks in advance.

Re: GTK on Windows

Posted: Wed Nov 18, 2009 11:37 am
by flaith
i have tested it, good work :D , thanks for sharing

Re: GTK on Windows

Posted: Wed Nov 18, 2009 12:35 pm
by milan1612
Very nice! Thank you for your work :D

Re: GTK on Windows

Posted: Thu Nov 19, 2009 2:49 am
by Mistrel
The problem with using GTK on Windows is that the runtime is huge (about 8mb, I think). I think the correct way to go about it would be to use the Win32 API on Windows and GTK on Linux.

I'm writing my own UI library in C++ and this is how I'm doing it. It's simpler and is guaranteed to support the most features.

Re: GTK on Windows

Posted: Thu Nov 19, 2009 4:35 am
by klaver
Mistrel wrote:The problem with using GTK on Windows is that the runtime is huge (about 8mb, I think). I think the correct way to go about it would be to use the Win32 API on Windows and GTK on Linux.

I'm writing my own UI library in C++ and this is how I'm doing it. It's simpler and is guaranteed to support the most features.
Are you serious, it's simpler... ? So in fact you must develop two separate libraries as GTK is totally different from WinAPI. BTW it's EXACLY the same method PureBasic Team is using. And when a trivial thing like sorting a ListIconGadget kicks in, you need to use API and do this differently for each platform. Very comfortable... Oh! and you must WATCH OUT not to MESS UP the PB INTERNALS!

And the runtimes... I mentioned that shouldn't be problem for someone who wants to use GTK. Is 6,5 MiB really a big deal compared to .NET Framework and Java Virtual Machine?

* .NET Framework 1.0: 19.7 MiB
* .NET Framework 1.1: 23.1 MiB
* .NET Framework 2.0: 22.4 MiB
* .NET Framework 3.0: 50.3 MiB (x86)
* .NET Framework 3.0: 90.1 MiB (x64)
* .NET Framework 3.5: 197.0 MiB

I don't think so. Thanks, I still prefer the INCORRECT way.

Re: GTK on Windows

Posted: Thu Nov 19, 2009 10:46 am
by Fred
Mistrel wrote:The problem with using GTK on Windows is that the runtime is huge (about 8mb, I think). I think the correct way to go about it would be to use the Win32 API on Windows and GTK on Linux.

I'm writing my own UI library in C++ and this is how I'm doing it. It's simpler and is guaranteed to support the most features.
Actually it's the way PB does things. And some other toolkit as well (wxwidget for example).

Re: GTK on Windows

Posted: Fri Nov 20, 2009 5:03 pm
by walker
klaver wrote:The last thing that I need is to know is what to do with functions that has variable number of arguments?
Any ideas about this? Thanks in advance.
simply add a -1 to the arguments :) (this is how it works on Linux)

Re: GTK on Windows

Posted: Fri Nov 20, 2009 5:10 pm
by klaver
walker wrote:simply add a -1 to the arguments :) (this is how it works on Linux)
But how to import such function with ImportC...EndImport?

And how to use such functions on Linux as compiler gives error - wrong number of parameters?

And the argument list is sometimes teminated with 0 and sometimes with -1, depends of function.

Re: GTK on Windows

Posted: Sun Dec 06, 2009 5:41 pm
by SFSxOI
The link for http://drkaczka.ovh.org/pbgtk.zip no longer works.

Re: GTK on Windows

Posted: Sun Dec 06, 2009 5:43 pm
by klaver
Because of the newer link in second post: http://drkaczka.ovh.org/gtk2pb.zip

Re: GTK on Windows

Posted: Mon Dec 07, 2009 12:14 am
by SFSxOI
DuH! OK, the blindness was only temporary :)

Thanks Klaver :)

Re: GTK on Windows

Posted: Mon Mar 15, 2010 4:46 pm
by pauljuzza
I have actually done this done this, thank you so much for the nice tips and advice now I know how GTK is using CDECL instead of StdCall.



_________________
pacquiao vs clottey live | Hits Tech Gadgets | Rapid Blog Share | Shop Market-Market

Re: GTK on Windows

Posted: Wed Apr 07, 2010 4:52 am
by aarenlainey
Nice tips , but is it work in windows 7 ? I am asking because i want to reboot my system , i don't want to take any risk .