[Beta] GObjectIntrospection Support [Updated]

Developed or developing a new product in PureBasic? Tell the world about it.
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

[Beta] GObjectIntrospection Support [Updated]

Post by remi_meier »

Hi there

I had some time today and tried to wrap my head
around the gir stuff that is coming up in the Gnome
universe.
This means for you that you can now generate PB
includes (imports) of most gnome libraries with a
simple script (which is actually written in Python
which should not disturb you much :mrgreen: ).
As I have just written this code in a few hours, the
includes will not have alpha quality. Actually I only
tested the GDK-gir, which compiles.
You may notice, that structures are commented. This
has three reasons. First the PB compiler rejects those
that are already declared, second the structures actually
are different (a wee bit) and third they certainly contain
bugs.
Another to-do are prototypes (just because I am lazy),
documentation support and if popular enough, I may
write a version that produces nice interfaces instead
of imports.

It would be very nice if some people help me test the
imports, especially 64bit people!

The usage is quite simple. Run the following command
in the extracted directory and you will get a gdk2.0.pbi.
Maybe you need a "chmod +x gir2pb.py" first:

Code: Select all

./gir2pb.py gir-files/Gdk-2.0.gir > gdk2.0.pbi
The code is of course included:
http://remi.secretly.de/downloads/gir2pbV4.tar.bz2

Read more about GObjectIntrospection here:
http://live.gnome.org/GObjectIntrospection

greetz
remi
Last edited by remi_meier on Fri Jan 13, 2012 4:46 pm, edited 3 times in total.
Athlon64 3700+, 1024MB Ram, Radeon X1600
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: [Alpha] GObjectIntrospection Support

Post by remi_meier »

Fixed a few bugs and added a .pbi which
imports all the girs in the gir-files directory.
But sadly those ~20900 lines crash my PB
compiler :mrgreen:

So anybody who is interested in:
  • - ATK
    - Clutter
    - COGL
    - Epiphany
    - GConf
    - Gdk, -pixbuf, -X11
    - GMenu
    - GnomeGames
    - GStreamer, -app, -audio, -base, -check, -controller, -Fft, -interfaces, -net, -netbuffer, -pbutils, -riff, -rtp, -rtsp, -sdp, -tag, -video
    - Gtk
    - Json
    - Pango
    - Wnck
or wants to use his/her Vala classes in PB has
something to play with now.
Last edited by remi_meier on Thu Jan 12, 2012 11:30 am, edited 1 time in total.
Athlon64 3700+, 1024MB Ram, Radeon X1600
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: [Alpha] GObjectIntrospection Support

Post by Rook Zimbabwe »

Remi this is good work! I haveintended to play more with OGRE this year and this should CERTAINLY come in useful!!! :D

Keep up the GOOD WORKS!!! :mrgreen:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Re: [Alpha] GObjectIntrospection Support

Post by hallodri »

Uhhh. geil...

Thanks Remi, finally all the gtk functions in one place. Thank you.

Win32 Python 3.1.2, may not "print" without parentheses.
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: [Alpha] GObjectIntrospection Support

Post by remi_meier »

Sorry for the late reply, there was a lot going on
in RL :)

@Rook Zimbabwe:
I'm not really sure how this would help you, but
thanks!

@hallodri:
I surely hope all the gtk functions are imported
correctly. Let me know if you find any problems!
About the "print" error: Yep, I'm still using Python
2.6... Meanwhile, you might wanna try '2to3' until
I adapt to Python3 in some distant future.
http://diveintopython3.org/porting-code ... -2to3.html

greetz
Remi
Athlon64 3700+, 1024MB Ram, Radeon X1600
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: [Alpha] GObjectIntrospection Support

Post by idle »

That's really handy thanks.
Will have a go at doing this natively in PB, not that there's anything wrong with python.
Windows 11, Manjaro, Raspberry Pi OS
Image
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: [Alpha] GObjectIntrospection Support

Post by remi_meier »

That's perfect as I probably will not really go any
further with this. I hope you will be successful and
also implement the missing stuff like prototypes
and perhaps nice interfaces :)
Since Gnome3 is released, a lot of new components
support introspection. Here is a short list of those
that have easily installable bindings in Ubuntu 11.04:

- Buzztard
- Lightdm
- AppIndicator
- ATK
- ATSPI
- Champlain
- Clutter, -GST, -GTK
- CouchDB
- DBusMenu
- Dee
- Gee
- GES
- Desktopcouch
- Evince
- Freedesktop
- GConf
- GDA
- GData
- GDKPixBuf
- GLib
- GMenu
- GNOME Games
- Grip
- GSSDP
- GStreamer
- GTK2/3
- GTKSource
- GTop
- GUdev
- GUPNP

And of course a lot more that are not in the Ubuntu
repositories. It's an awesome time to use GNOME :mrgreen:

greetz
remi
Athlon64 3700+, 1024MB Ram, Radeon X1600
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: [Beta] GObjectIntrospection Support [Updated]

Post by remi_meier »

Update:
- fix bug when function can "throw" an error
- comment duplicate function declarations
- fix library path problems using pkg-config
- add type safe prototype / callback support

For download see first post.
Athlon64 3700+, 1024MB Ram, Radeon X1600
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: [Beta] GObjectIntrospection Support [Updated]

Post by idle »

Great thanks
Windows 11, Manjaro, Raspberry Pi OS
Image
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: [Beta] GObjectIntrospection Support [Updated]

Post by remi_meier »

You're welcome :)

Just fixed another issue about methods of
"Unions" not being imported.
Athlon64 3700+, 1024MB Ram, Radeon X1600
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: [Beta] GObjectIntrospection Support [Updated]

Post by idle »

thanks, I'd really like to contribute but alas I'm idle in python :wink:
Windows 11, Manjaro, Raspberry Pi OS
Image
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: [Beta] GObjectIntrospection Support [Updated]

Post by remi_meier »

:D
Let me know if you want to get active :wink:
Athlon64 3700+, 1024MB Ram, Radeon X1600
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: [Beta] GObjectIntrospection Support [Updated]

Post by remi_meier »

Update:
- do manual x86 / x64 and unicode / ascii paddings in structures
- handle constant name clashes because of case-insensitivity

E.g. Clutter.gir now exports all constants.
Athlon64 3700+, 1024MB Ram, Radeon X1600
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: [Beta] GObjectIntrospection Support [Updated]

Post by uwekel »

Thank you very much! Now i can even work with Glade GUI designer :-)

Still a problem are the existing GTK2 bindings of PB, which often get a naming conflict. I decided just to take the synopsis without any structures. Structure i will add when they are required and different from GTK2.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Post Reply