GTK+学习笔记1

 

Object Hierarchy

 GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkContainer
                           +----GtkBin
                                 +----GtkWindow
The reason this heirarchy is so important is because when you're looking
 for functions, properties, and signals for any particular widget, you 
need to realize that the functions, properties, and signals of it's 
parent objects apply to it as well.
All objects beginning with Gtk are from GTK+. Later, we'll see things 
like GladeXML which is part of Libglade or GError which is part of GLib
Devhelp 
which is likely available as a package for your distribution. Devhelp 
allows you to browse and search the API documentation for the libraries 
you have installed on your system (assuming you install that libraries 
documentation as well
A glade file is actually an XML file which describes the heirachy of the widgets comprising the interface.
the ONLY thing glade does is allow you to generate a glade file which describes how the GUI is going to be built.
This allows more flexibility with the developer, prevents having to 
re-compile applications when a minor interface change is needed, and 
allows more programming languages to be used with Glade.
Start up Glade and let's get familiar with it's interface. I will be 
referring to various aspects of Glade by the names described here. On 
the left hand side is the "Palette". The Palette is like that of a 
graphics editing application. It is a palette of GtkWidgets which you 
can use to design your application. In the middle area (which is empty 
when you first start Glade) is the "Editor". This is where you see your 
design in progress. On the right hand side is the "Inspector" on top and
 the widget "Properties" below that. The Inspector shows your design as a
 tree allowing you to access and view the heirarchy of the widgets 
making up your design. We manipulate various properties of widgets in 
the Properties tabs, including specifying callback functions for signals
 (explained later).
let's look at the 'Common' tab. This tab also contains properties which
 belong to our GtkWindow, however, we don't see them in the reference 
documentation for GtkWindow. This is because this is where we set 
properties which areinherited from parent objects.
 
 
Click on the GtkContainer link to jump to the reference documentation for a GtkContainer.
 You'll notice that GtkContainer has a property called "border-width" 
and we have a property in Glade for "Border width" at the bottom of the 
'Common' tab. We'll learn more about what a container widget is later, 
however, this demonstrates how important that object heirarchy is. Since
 many widgets are derived from GtkContainer, Glade puts it's properties 
into the 'Common' tab. 
 
 
all GTK+ widgets are derivitives of GtkWidget.
If a user does anything within your GUI, chances are they are emitting 
signals. As a programmer, you choose which signals you want to capture 
and perform a task, and connect a callback function to that signal.

 

你可能感兴趣的:(GTK+学习笔记1)