GTK on Windows

Windows specific forum
klaver
Enthusiast
Enthusiast
Posts: 146
Joined: Wed Jun 28, 2006 6:55 pm
Location: Schröttersburg

GTK on Windows

Post 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.
Image
klaver
Enthusiast
Enthusiast
Posts: 146
Joined: Wed Jun 28, 2006 6:55 pm
Location: Schröttersburg

Re: GTK on Windows

Post 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.
Image
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: GTK on Windows

Post by flaith »

i have tested it, good work :D , thanks for sharing
“Fear is a reaction. Courage is a decision.” - WC
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Re: GTK on Windows

Post by milan1612 »

Very nice! Thank you for your work :D
Windows 7 & PureBasic 4.4
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: GTK on Windows

Post 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.
klaver
Enthusiast
Enthusiast
Posts: 146
Joined: Wed Jun 28, 2006 6:55 pm
Location: Schröttersburg

Re: GTK on Windows

Post 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.
Image
Fred
Administrator
Administrator
Posts: 16686
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: GTK on Windows

Post 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).
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Re: GTK on Windows

Post 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)
klaver
Enthusiast
Enthusiast
Posts: 146
Joined: Wed Jun 28, 2006 6:55 pm
Location: Schröttersburg

Re: GTK on Windows

Post 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.
Image
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: GTK on Windows

Post by SFSxOI »

The link for http://drkaczka.ovh.org/pbgtk.zip no longer works.
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
klaver
Enthusiast
Enthusiast
Posts: 146
Joined: Wed Jun 28, 2006 6:55 pm
Location: Schröttersburg

Re: GTK on Windows

Post by klaver »

Because of the newer link in second post: http://drkaczka.ovh.org/gtk2pb.zip
Image
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: GTK on Windows

Post by SFSxOI »

DuH! OK, the blindness was only temporary :)

Thanks Klaver :)
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
pauljuzza
New User
New User
Posts: 1
Joined: Fri Mar 12, 2010 6:53 pm

Re: GTK on Windows

Post 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
aarenlainey
New User
New User
Posts: 3
Joined: Tue Apr 06, 2010 4:01 am

Re: GTK on Windows

Post 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 .
Post Reply