2
votes

Good resources for using Glade [Interface Designer] with Vala seem to be very sparse, and I'm having a difficult time getting started with Glade.

I did find a tutorial that seemed pretty good last year, but Ican no longer locate it.

Basically, I want to use Glade to do the GUI stuff, and then somehow "hook" it into my Vala code. How do we do this?

2
use glade to generate your gui xml and run it from your vala code - see this tutorialamdixon

2 Answers

2
votes

Glade generates a UI description in an XML format. GTK contains a class called Gtk.Builder which reads this XML and constructs a widget hierarchy.

"Traditionally", the way to tie the two together is to give the widgets meaningful names in Glade, and then use widget = Gtk.Builder.get_object(name) to grab the widget for use in your programme. You'll find quite a few examples like this on the web (google "vala gtkbuilder" or something similar to find them).

However, the latest versions of Vala and GTK have some new features to cut out quite a bit of the boilerplate from the way things have been done in the past. It's very new so you won't find many examples yet, but this blog post has all the details:

http://blogs.gnome.org/tvb/2013/05/29/composite-templates-lands-in-vala/

1
votes

at the GTK tutorial there's simple vala sample where they show how to load an xml glade file.

and for glade:

I would prefere learning how to design the gui in vala first because it will give you a better understanding of how GTK works. layouts like gtk.box and gtk.window etc.