I am new to Gtk and I am also using Glade to design a GUI.
What is the necessary steps to show a GUI designed in glade by using gtk_builder_add_from_string() ?
So far I loaded a .glade file into memory , ran g_type_ini开发者_运维技巧t() and I got myself a gtk_builder_new() struct that I pass to gtk_builder_add_from_string().
What do I need to do next to show the GUI and "talk" with the widgets?
(sorry for a possibly stupid question but me and google are not exactly friends today)
I always thought this was a very good tutorial: https://web.archive.org/web/20151230154736/http://www.micahcarrick.com/gtk-glade-tutorial-part-1.html
In general the steps are the following:
- Get the builder (you got it)
- Call
gtk_builder_add_from_string
. That string has to be created in the .glade file. You just have to convert the file into a C string. - You can get the different graphical elements using
gtk_builder_get_object(builder,"name")
, where name is the name of some element. You usually have a top-level window in it. - Call the
show()
method on all the widgets you recover from the builder. In particular, the top-level windows.
This will bring your application to life. Note that you also can connect signals and such. You can see an example here.
精彩评论