GTK+ By Example/Glib/GObject

From Wikibooks, open books for an open world
Jump to navigation Jump to search

See the GObject Developer Docs.

See creating a Gobject for an example on deriving objects.

GObject is implemented in Glib and builds Objects in run-time (unlike C++ and many other object oriented languages which do this at compile tim).

  • similar to C++, using vtables.
  • explicit upcasting and downcasting.
  • Capable of meeting the three tenets of OOP. (See The Wikipedia Article).

Example[edit | edit source]

create a person that says "hi my name is xxx". when person::talk is implemented

create an example dr_phil that inherits from person and says "And hows that working for you?" when person::talk is called.

this should provide us with deriving a first object, which is a pain to learn. and how inheritance works in Glib.

What needs to be explained[edit | edit source]

  • type check and type cast macros
  • the purpose of get type
  • the order in which objects are instantiated
    • creating object
    • construct and desctructor methods
    • the difference between class and instance
    • virtual functions