Upload
ahmed-saeed
View
1.134
Download
0
Embed Size (px)
Citation preview
Ahmed Mohamed Saeed
Sun Campus Ambas s ador. .Ahmed Sae e d@Sun c om
GTK+ 101
2
Agenda
Introduction to GTK+Why GTK+?Supporting LibrariesGTK Applications StructureGTK Setup and Compilation on NetBeansDemo
3
Introduction
4
History
GNU Image Manipulation Program (GIMP) Peter Mattis, Spencer Kimball, and Josh
MacDonald (Class Project!!)MotifGTK
GIMP ToolKit (GTK)Object Oriented and renamed GTK+.
5
What is GTK?
“GTK+ is a highly usable, feature rich toolkit for creating graphical user interfaces which boasts cross platform compatibility and an easy to use API. GTK+ it is written in C, but has bindings to many other popular programming languages” http://www.gtk.org
LGPL
Part of the GNU Project
All written in C!
6
Features
Stability
Cross Platform
Language Bindings
Mobile
Accommodating
Interfaces
Foundations
http://www.gtk.org
7
Why GTK?
8
Did you see the features ?!
Why GTK?
9
Where is GTK?
10
GTK Supporting Libraries
11
Glib
GLib is a general-purpose utility library, which provides many useful data types, macros, type conversions, string utilities, file utilities, a main loop abstraction, and so on. It works on many UNIX-like platforms, Windows, OS/2 and BeOS. GLib is released under the GNU Library General Public License (GNU LGPL).
12
GObjectA generic type system to register arbitrary single-inherited flat and deep derived
types as well as interfaces for structured types. It takes care of creation, initialization and memory management of the assorted object and class structures, maintains parent/child relationships and deals with dynamic implementations of such types. That is, their type specific implementations are relocatable/unloadable during runtime.
A collection of fundamental type implementations, such as integers, doubles, enums and structured types, to name a few.
A sample fundamental type implementation to base object hierarchies upon - the GObject fundamental type.
13
Gobject (Cont'd)
A signal system that allows very flexible user customization of virtual/overridable object methods and can serve as a powerful notification mechanism.
An extensible parameter/value system, supporting all the provided fundamental types that can be used to generically handle object properties or otherwise parameterized types.
14
GDK
GIMP DrawingKitMeant to deal with X Window SystemActs as an intermediate layer between GTK+ and Xlib
15
Pango and ATK
PangoTexts and fonts rendering along with Cairo
ATKAccessibility ToolKit
16
GTK Applications Structure
17
GTK code anatomy
InitializationMain Event LoopData types Call back functions
18
Initialization and the main event loop
gtk_init() initializes the GTK environment Should be called at the beginning of the programTerminates the program if it failed to initialize the
environment
get_main()Starts the event loop that will check for the signals
connected to the widgets
19
Data Types (widgets hierarchy)
http://www.gtk.org/tutorial1.2/gtk_tut-5.html
20
Call back functions
SignalsWidgets need to be notified if the user clicked, typed, etc.g_signal_connect (G_OBJECT (window),
"destroy", G_CALLBACK (destroy),
NULL);
Call back functionsSimply “Functions that signal handlers call in case that
signal occurred”
21
GTK Setup and Compilation on
Netbeans/Ubuntu
22
Compilation Parameter
Command Line Argument`pkg-config --cflags --libs gtk+-2.0`Don't miss the “`”
23
Demo 1Setup and Configuration
24
Demo 2GTK+ 2.0 Tutorial Code Samples walk through