0

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_init() 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)

BJ Myers
  • 6,617
  • 6
  • 34
  • 50
Waxhead
  • 500
  • 3
  • 16
  • For others with issues related to gtk_buildeR_add_from_string() I suggest reading this : http://library.gnome.org/devel/glib/stable/glib-Error-Reporting.html#glib-Error-Reporting.description – Waxhead Nov 09 '10 at 17:58

2 Answers2

1

In general the steps are the following:

  1. Get the builder (you got it)
  2. 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.
  3. 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.
  4. 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.

Diego Sevilla
  • 28,636
  • 4
  • 59
  • 87
1

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

AshFTW
  • 141
  • 3
  • 12
ptomato
  • 56,175
  • 13
  • 112
  • 165