Re: Implementing GInterfaces purely from C++?



On Tue, 2008-02-05 at 08:46 -0800, Philip Langdale wrote:
> Murray Cumming wrote:
> > 
> > I don't think you need to mention Glib::ObjectBase there because
> > Glib::Object has it already.
> > 
> > You can generally find this technique in custom CellRenderer and
> > TreeModel implementations.
> > 
> 
> I think you have to have Glib::ObjectBase mentioned explicitly, otherwise
> you can't specify the custom typename (there's no Glib::Object constructor
> that lets you specify one).

Yes, but that's just the initialization list, not the list of the base
classes to derive from.

>  If you just inherit from TreeModel and Object,
> you end up with a class that reports its type as Glib::Object

What does "reports its type as" mean. The GType will be a custom GType
with the name that you supplied to the ObjectBase constructor.

>  and does not
> report that it implements GtkTreeModel.

In Glom I do:

class DbTreeModel
  : public Glib::Object,
    public Gtk::TreeModel
here:
http://svn.gnome.org/viewvc/glom/trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.h?view=markup

and

DbTreeModel::DbTreeModel()
: Glib::ObjectBase( typeid(DbTreeModel) ), //register a custom GType.
  Glib::Object(), //The custom GType is actually registered here.
here:
http://svn.gnome.org/viewvc/glom/trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc?view=markup

and it seems to work. It's not otherwise a good example though.

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com
> 



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