[Glade-users] Generate c-file in glade3?? from Aug 15 2006
Tristan Van Berkom
tvb at gnome.org
Wed Dec 6 10:06:16 EST 2006
On Wed, 2006-12-06 at 21:05 +1100, Derek Law wrote:
> Hi, I'm a new comer to this list.
>
> I was about to write about something concerning a
> strange behavior in libglade + Glade-2 but just when I
> was looking at the archive to see if someone came
> across the same problem I actually stumbled across
> this thread. This brought back memories of reading a
> reasonably big discussion several months ago about
> abandoning C code generation. While I could see both
> sides of the argument I actually sided with leaving
> the feature there at that time, as I had a similar
> problem to one of the authors (I couldn't seem to find
> where the thread is):
>
There were a few threads, this one [1] is quite extensive
but a little repetetive.
> In one of the applications I wrote, there's a dialogue
> with the following layout:
>
> Label Spinbutton
> Label Spinbutton
> ...
>
> The problem is the number of Label-Spinbutton pairs is
> determined at run time. I cannot have a single glade
> file with just the two widgets and apply it multiple
> times because each widget has to have a unique name.
> Therefore I'm just curious if there are more "libglade
> friendly" ways of doing that in Glade-3, or I'd need
> to code it - in which case a code generator will
> actually ease the process quite a bit.
>
Well, how are they packed ? you can generate them more than once
from the glade file... i'd say the code you're looking for
should look something like the following:
void
fill_box (GtkWidget *box)
{
for (something about entries) {
GladeXML *xml;
if ((xml = glade_xml_new (gladefile, "label-spin-box")) != NULL) {
GtkWidget *hbox = glade_xml_get_widget (xml,
"label-spin-box");
/* dynamicly append a label/spin pair to the box. */
gtk_box_pack_end (box, hbox, FALSE, FALSE);
/* free unneeded resources */
g_object_unref (xml);
}
}
}
That should give you a general idea of how to do what
you need to do using libglade, ofcourse your implementation
will vary because you probably pack things in a specific way.
Cheers,
-Tristan
[1]http://mail.gnome.org/archives/gtk-app-devel-list/2006-October/msg00182.html
More information about the Glade-users
mailing list