[gst-devel] GtkObject vs. GObject

Erik Walthinsen omega at temple-baptist.com
Wed Sep 5 20:33:02 CEST 2001


A lot of people have been confused by the whole object model thin in
GStreamer, and for good read ;-)  I'll see if I can explain it:

1) GStreamer started out being written to the GtkObject model, which
exists in gtk-1.2.  This is still the current version of Gtk that everyone
has.  All the code was written with the various "GtkThis" and GtkThat"
symbols.

2) A few months ago, I converted GStreamer to the glib-2.0 GObject model.
GObject is very similar to GtkObject, except it's more advanced (and
unfortunately not as mature in various areas), and doesn't require
anything but glibc.  That means no more X dependency for apps that don't
want it.

3) ALL code in GStreamer is now written to "GThis" and "GThat", and other
GObject-isms (some minor symbol name/semantics changes besides the
s/gtk/g/).

4) The normal case for GStreamer (compiling without any special options)
is to link against gtk-1.2, i.e. the GtkObject model.  This is
accomplished by way of a shim (a gtk2gobject.[ch]) that transforms all the
instances of various GObject symbols into their GtkObject counterparts.
gtk2gobject.c has to do some rather interesting tricks in some cases due
to fundamental differences in the two object models.

5) If you add --enable-glib2 to the configure commandline, it will drop
this shim and compile directly against glib-2.0.  This however keeps you
from linking against gtk-1.2 (becuase gtk-1.2 needs glib-1.2, which by
definition causes massive symbol overlap with glib-2.0), which means that
all the apps that actually *do* use Gtk will no longer link and ideally
have been shut off in the Makefiles.

6) If you do wish to work on something that uses gtk-2.0, you can do so
fairly easily, just start linking.

7) If you want to make use of these tricks, you'll want to check out the
--enable-glib2 check in configure.base, and the various compilation
changes that are made.  These lead to gtk2gobject.[ch], which need to be
compiled/included as appropriate.  In gstobject.h you'll find at the top a
simple #ifdef that decides whether to include gobject.h (for GObject) or
gtk2gobject.h (for GtkObject, which will include gtk.h).  In gst_init() is
another #ifdef that calls the appropriate initialization routines for the
object model in question.  That's all you should have to grab.

8) If you find anything that the shim does not do, especially while
working on your own package that uses the shim, please add the changes to
the gstreamer gtk2gobject.[ch].  Parapraxis has done this with paranormal,
and has contributed quite a bit to the shim.

Any things I didn't cover?

      Erik Walthinsen <omega at temple-baptist.com> - System Administrator
        __
       /  \                GStreamer - The only way to stream!
      |    | M E G A        ***** http://gstreamer.net/ *****
      _\  /_





More information about the gstreamer-devel mailing list