Re: construct functions



murrayc t-online de (Murray Cumming) writes:

> On Tue, 2001-10-23 at 15:01, Havoc Pennington wrote:
> > 
> > murrayc t-online de (Murray Cumming) writes:
> > > A lot of objects seem to be missing construct functions for language
> > > bindings. Do I have permission to add these as I discover the need? It
> > > should be a simple matter of moving code from the _new function to
> > > _construct functions, then calling those _construct functions from the
> > > _new functions.
> > 
> > Instead of construct functions, objects are supposed to have
> > construct-time object properties. If anything requires a construct
> > function it is broken, file a bug report about it.
> 
> So we set these properties immediately after using g_type_new()? If
> there is an existing example of this, can you help me out by pointing me
> to it?
> 
> So, is gtk_tree_view_new_with_model() broken? :
> 
> GtkWidget *
> gtk_tree_view_new_with_model (GtkTreeModel *model)
> {
>   GtkTreeView *tree_view;
> 
>   tree_view = GTK_TREE_VIEW (gtk_type_new (gtk_tree_view_get_type ()));
>   gtk_tree_view_set_model (tree_view, model);
> 
>   return GTK_WIDGET (tree_view);
> }

It's just a convenience function from C.  You can also do

 g_type_new (GTK_TREE_VIEW_TYPE, "model", model, NULL);

or

 tree_view = gtk_tree_view_new ();
 gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), model);

Thanks,
-Jonathan



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