Re: [gtk-list] Re: Serialization (was: Re: GTK questions)



On Tue, 20 Jul 1999, David Orme wrote:

> Havoc Pennington wrote:
> 
> > On Tue, 20 Jul 1999, David Orme wrote:
> > >
> > > Another (somewhat related) question: is there an easy way to clone a GTK
> > > object.  ie: the equivalent of a C++ copy constructor?
> > >
> >
> > Nope, there's no way at all. It might be nice if there were, but...
> > You could write your own copy constructors for individual objects of
> > course. :-)
> 
> I want to create a serialization library (like Java's java.io.serializable or
> Python's pickles) for GTK objects.  It seems like the best I can do is to
> create my own object inheriting from GtkObject and make everything that
> inherits from that serializable.

take a look at the gle module in gnome cvs, apart from its editing
functionality a bunch of its code actually deals with serialization
of gtk objects, and dealing with objects and their arguments in a
generic way. the gtk object system in general has certain deficencies
in that regard, you're especially hosed when it comes to inter object
links outside of the parent<->child relation ships.

> It seems you'd need:
> 
> 1) a way to register a GTK type that you see in a data stream even if it
> hasn't been used in the app yet.

gle solves that with some autogenerated code that calls type initialization
functions on demand.

> 2) a convention that all serializable objects must use GTK arguments for their
> properties.

yes. unfortunately, gtk arguments are still not thoroughly implemented
throughout the toolkit, and another drawback of the arg system is that
object modifications are usually not routed through a single point, so
you don't get notification upon certain object data changes and thus
can not reliably implement supression of default value serialization.

> 3) a way to construct a new object given its type name

that's easy once you got 1) done, you then simply do
gtk_object_new (gtk_type_from_name (string), NULL);

> 
> Does this sound right?

pretty much, though it sounds like you end up duplicating a bunch of
code that is already contained in gle. it might be worth looking into
splitting up some of gle's code, if you end up really implementing
such a system. (for another project where i needed an object system in
C, i actually ended up reimplementing the type and argument system,
because gtk's is actually just too limited for things like thorough
serialization and comprehensive object state notification).

> 
> --
> David Orme                                       LINUX...

---
ciaoTJ



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