Compatibility stuff



Hi guys,

I tried to compile some GNOME 1.x stuff with GTK+ 2.0 recently to find
out how much work it is to port this stuff to GTK+ 2.0 and figured out
that a lot of work could be avoided if GTK+ had a better compatibility
interface.

Here's a little proposal how we can improve this:

* there's a hell lot of code out there which is using things like
  object->klass, klass->type etc. which is now using GTK_OBJECT_GET_CLASS
  and GTK_CLASS_TYPE.

  To ease migration to GTK+ 2.0, I'd like to suggest that we add these
  macros to GTK+ 1.2.x. When we do this, people can start to port their
  existing code to use these new macros when they feel like it without
  breaking it on the GNOME 1.x platform.

* there's a lot of code using gtk_object_class_add_signals().

  Would it be possible to add this function to gtkcompat.h and let it
  just print a warning that it's deprecated ?

* there's also a hell lot of code out there which is using the `finalize'
  method of GtkObject.

  This may sound a bit hackish, but what do you think about adding
  something like the following to GTK+ 1.2.x ?

        #define GObjectClass GtkObjectClass
        #define G_OBJECT_CLASS GTK_OBJECT_CLASS
        /* etc. */

  This way people can start rewriting their existing code to use

        /* in _finalize */
        G_OBJECT_CLASS (class)->finalize (object);

        /* in class_init */
        GObjectClass *gobject_class = (GObjectClass *) klass;
        gobject_class->finalize = foo_finalize;

The big advantage of this stuff is that it'll avoid a lot of conditionals
in existing code; it'd allow you to compile existing code almost unchanged
on GTK+ 2.0.

Comments are welcome .... :-)

-- 
Martin Baulig
martin gnome org (private)
baulig suse de (work)




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