Re: GtkBuilder Public API - Last call
- From: Steve Frécinaux <nudrema gmail com>
 
- To: Johan Dahlin <jdahlin async com br>
 
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
 
- Subject: Re: GtkBuilder Public API - Last call
 
- Date: Wed, 13 Jun 2007 01:33:34 +0200
 
On Wed, 2007-06-13 at 00:46 +0200, Steve Fr�naux wrote:
> Also, maybe an helper
> function to do that would be sufficient instead of a full-blown class,
> so that it can just be called in my_dialog_init to add the child widget
> and update its properties according to what's specified in the glade
> file.
Let me explain a bit more:
With such a function:
void
gtk_builder_build_object (GObject *object, const gchar *file, 
			  const gchar *name)
{
	GtkBuilder *builder;
	GObject *child;
	g_return_if_fail (GTK_IS_CONTAINER (object) &&
			  <typeof object inherits typeof widget(name)>);
	buider = gtk_builder_new ();
	gtk_builder_add_from_file (builder, file);
	child = gtk_builder_get_object (builder, <widget(name).child>);
	g_return_if_fail (child != NULL);
	gtk_container_add (GTK_CONTAINER (object), child);
	gtk_builder_update_object_properties (builder, object, name);
}
it would probably be as simple as overwriting the constructor of the
custom container type, this way:
static void
my_dialog_constructor (GObject *object, ...)
{
	G_OBJECT_CLASS (parent_class)->construct (object, ...);
	gtk_builder_build_object (object, "my-dialog");
	/* connect signals here */
}
the default destroy handler would take care of throwing away the built
objects.
This kind of API would look nice and simple, wouldn't it ?
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]