Xfce Foundation Classes

« Main Page | Basic XFC Application »

# GTK+ Programming in C++ with XFC

### Table of Contents

1. Basic XFC Application
2. Hello World
3. Hello Buttons
4. Adding a menubar and toolbar
5. Writing a composite statusbar
6. Adding a statusbar
7. Adding a client area and context menu
8. Building a GNU autotools project
9. Adding International Support

## Overview

GTK+ programming in C++ is more efficient and more powerful than progamming in C, and with the Xfce Foundation Classes (XFC) it's a lot easier and much more fun. By combining the power of GTK+ and the power of C++, XFC provides the programmer with a well integrated set of C++ classes that wraps most of the functionality found in the GTK+ libraries. XFC is divided into two main libraries: libXFCcore and libXFCui, but other add-on libraries planned, such as libXFCde which will provide a C++ interface for the Xfce core libraries.
The libXFCcore library wraps the GLib object system and selected objects from the GLIb utility library. Essentially, it provides a low level object system that can be used to build other libraries; libXFCui depends on this library. libXFCcore uses the new libsigc++ 2.0 callback library to implement a typesafe system of signals and slots that makes using native GObject signals or creating your own signals very easy. There is a standard string compatible UTF-8 string class, reference documentation and several test programs.
The libXFCui library is a state-of-the-art graphical user interface toolkit for developing GTK+ applications in C++. There are more than 420 classes that wrap most of the objects found in the ATK, GDK, Gdk-Pixbuf, GTK and Pango libraries. Included is a full set of simple example programs, a C++ version of the GTK+ widget demonstration program, an extensive reference manual, several test programs and this tutorial.

## Programming in C++

Over the years application programming has become more complex. Today, C++ is a better way the manage that complexity because it provides you with a variety of programming designs, both object-oriented and conventional, that let you develop high-quality applications easily. Properly used, C++ code is easily maintainable, is extensible, and can be performance and memory efficient.
The Xfce Foundation Classes are a compact but comprehensive C++ wrapper around the GTK+ library. XFC judiciously uses C++ language features and does not layer on too much extra C++ complexity. Its API is easy to understand and use, and should feel immediately familiar to most GTK+ programmers. Throughout its development XFC has maintained a good balance between remaining faithful to GTK+ and remaining faithful to C++. Hence the catchphrase - "the power of gtk, the power of c++".

## The XFC Tutorial

Whether you're new to GTK+ or an experienced programmer, you should find the XFC tutorial beneficial and worthy of the small amount of time it will take to work through. On completion of this tutorial you will have covered the basics of GTK+ programming in C++ using the Xfce Foundation Classes. And for the benefit of new programmers, the tutorial will discuss several important GTK+ and GNU concepts along the way.
Rather than just working through the usual 'hello world' program, this tutorial also takes you through the process building a real application, called 'XfcApp', which you can use as a starting point for your own projects. The tutorial starts off in chapter one by creating a basic application that is nothing more than an empty main window. Then in chapters two and three, two simple applications are created: Hello World and Hello Buttons. These two applications serve to introduce you to important topics such as packing widgets, libsigc++ signals and slots, and virtual signal classes.
The interesting stuff really begins in chapter four. Starting with the XfcApp program from chapter one, successive chapters take you through the process of enhancing XfcApp, adding features such as an action-based menubar and toolbar, a composite statusbar that looks and behaves just like a GNOME appbar, and a client area that responds to mouse button events by displaying a pop up context menu.
The tutorial finishes off by covering two important topics that are essential for new programmers. Chapter eight takes you step-by-step through the process of turning XfcApp into a GNU compliant autotools project. Then chapter nine shows you how to add international support. If you already know how to build a GNU autotools project and how to add international support, you can skip these two chapters.

Copyright © 2004-2005 The XFC Development Team | Top | XFC 4.4