Re: [gtkmm] Glade-2, libgtkmm, Xml::create, callbacks



Hey Douglas!

Douglas Roberts wrote:
Glade/glademm already saves all callback methods defined by the user. The callback code, with the appropriate signal handling is saved as valid C++ code. The problem is that glade/glademm does not give you a handle to the gui objects that it creates, so that unless you go into the code that glade/glademm wrote there the Gtk::objects are created, and re-declare them at a global scope, you have no way to get a handle to the Gtk::objects.

It sounds like you might not have used glade-2 to save a gui with C++ bindings.


You keep telling us what Glade/glademm does and does not, and keep asking us if we know what we're talking about. Let me assure you that everyone that has tried to explain this to you know exactly what they are talking about.

So, in an attempt to be a litte more precise;
There are two different tools.

1: glademm. glademm lives within glade. glademm writes code.
2: libglademm. libglademm lives within you program. libglademm does not write code.

You have 3 different choices in how to use the tools;

1: Use only glademm.
2: Use only libglademm.
3: Use glademm and libglademm together.

So what is different between these 3 ways of using them?

Choice 1: glademm creates C++ files for you. You fill in the blanks. If you want to make adjustments to the user interface after you have generated the C++ files and compiled your program, you need to go back to glademm and re-generate the C++ files. This is completely unrelated to using libglademm.

Choice 2: You write the C++ code yourself. No C++ code whatsoever is generated. You will need to write C++ code that 1) loads the XML file(s) generated by glade (not glademm!), 2) implements your signal handlers, and 3) connect your signal handlers to the user interface. All three is usually a snap using the libglademm API - very little code needs to be written. If you want to make adjustments to your user interface, you only have to tweak the XML file, even after your program has been compiled.

Choice 3: This appears to be what you are trying to do. Just as in [choice 1], glademm generates C++ code for you, and you fill in the blanks. However, this code is _very_ different from the code generated in [choice 1]. Instead, this code will look like the code you would have written yourself in [choice 2].

Now, obviously glademm can't read your mind, so you need to tell glademm that it should generate code that uses the libglademm API [choice 3], as opposed to code that uses the gtkmm API directly [choice 1] (which is glademm's default mode of operation). Thus, as already pointed out, you need to add the '--libglade' flag to glademm to work in this mode.

--
Christer Palm




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]