GIO – Input/Output on Steroids The GTK+ Widget Toolkit

GIO is striving to provide a modern, easy-to-use Vir- On top of GLib/GObject/GIO sits GTK+, a tual File System (VFS) API that sits at the right level containing a wide range of widgets. A widget is a basic in the library stack. GIO also contains other generally component of a , for instance a The GLib/GTK+ Development useful for desktop applications (such as network- , some text, a , etc. A container is a spe- ing and -Bus support). It was created to provide cial widget that can contain other widgets. All these Platform an API that is so good that developers prefer it over widgets are (indirect) subclasses of the GObject base raw POSIX calls. Among other things that means us- class. ing GObject. It also means not cloning the POSIX Although widgets can be created, configured and as- API, but providing higher-level, document-centric in- sembled programmatically, the Glade interface builder terfaces. can be used to create the user interface graphically. GTK+ is a multi-platform toolkit for creating graphi- The abstract file system model of GIO consists of a The Glade application creates an XML file that can be cal user interfaces. Offering a complete set of widgets, number of interfaces and base classes for I/O and files. loaded with GTK+. GTK+ is suitable for projects ranging from small one- Then there is a number of stream classes, similar to the Among other things, GTK+ provides a flexible them- off tools to complete application suites. input and output stream hierarchies that can be found ing system with a CSS-like language, as well as an GTK+ is written in but has been designed from the in frameworks like Java. There is a framework for stor- interactive inspector. ing and retrieving application settings. There is sup- ground up to support a wide range of languages, not port for network programming, including connectivity only C/C++. Using GTK+ from languages such as monitoring, name resolution, lowlevel socket APIs and Long-Term Support GTK+ Versions Python and JavaScript (especially in combination with highlevel client and server helper classes. There is sup- the Glade GUI builder) provides an effective method port for connecting to the D-Bus inter-process com- During the GTK+ 3 development, a new minor version of application development. munication system: sending and receiving messages, was released every six months. GTK+ 3.22 – released GTK+ is free/libre software and part of the GNU owning and watching bus names, and making objects in September 2016 – is and will be the last minor ver- Project. The licensing terms for GTK+, the GNU available on the bus. Beyond these, GIO provides: file sion of the 3.x series. Moving forward, the GTK+ LGPL, allow it to be used by all developers without monitoring; utility classes to implement asynchronous project has adopted a new versioning scheme with a any license fees or royalties. and/or cancellable operations; an easy-to-use API to new Long-Term Support (LTS) version released every GTK+ has been created in 1996 for the GIMP — launch and interact with child processes; and more. two to three years. GTK+ 3.22 is an LTS version, the LTS version will be GTK+ 4.0, then 5.0, etc. the GNU Image Manipulation Program — but quickly By using the same GIO API, an application can sup- Intermediary versions will continue to be released ev- evolved into a general-purpose library used by a large port remote files in addition to local files. The local ery six months; for GTK+ 4, those intermediary ver- number of applications including the GNU project’s case is implemented by GIO, while implementations for sions are numbered 3.90, 3.92, 3.94 and so on. Those GNOME desktop. various network file systems are provided by the GVFS non-LTS versions have less stability guarantees. Devel- package as loadable modules. Another design choice is opers preferring a stable foundation should choose an to move backends out-of-process, which minimizes the LTS version of GTK+. An LTS version is supported dependency bloat and makes the whole system more at least three years. robust. The backends are not included in GIO, but in the separate GVFS package. GVFS also contains a daemon which spawn further mount daemons for each More Information individual connection. TM https://www.gtk.org/ https://blog.gtk.org/ Architecture Overview GLib – the Core Library

Over time GTK+ has been built up to be based on Firstly, GLib provides common data structures: other libraries, also developed by the GTK+ team: • Single and doubly linked lists. • GLib, a low-level core library that forms the ba- • Hash tables. sis of GTK+. It provides data structure handling for C, portability wrappers and interfaces for such • Balanced binary trees. A main loop. run-time functionality as an event loop, threads, • N-ary trees: trees of data with any number of dynamic loading, an object system (GObject) and branches. GObject – an Object System high-level input/output APIs (GIO). • Strings with text buffers which grow automatically • , a library for layout and rendering of text as text is added. Most modern programming languages come with their with an emphasis on internationalization. It forms own native object systems and additional fundamen- • Arrays of arbitrary elements which grow automat- the core of text and font handling for GTK+. tal algorithmic language constructs. Just as GLib ically as elements are added. serves as an implementation of such fundamental types • ATK, a library for a set of interfaces providing • GVariant, a generic data type that stores a value and algorithms (linked lists, hash tables and so forth), accessibility. By supporting the ATK interfaces, an along with information about the type of that GObject provides an implementation of a flexible, ex- application or toolkit can be used with tools such value. tensible, and intentionally easy to map (into other lan- as screen readers, magnifiers, and alternative input guages) object-oriented framework for C. devices. • And a few other data structures. All common object-oriented concepts are present: in- • GDK is the abstraction layer that allows GTK+ heritance, interfaces, virtual/overridable methods, ab- to support multiple windowing systems. GDK pro- GLib also contains loads of utilities: stract classes, constructors, destructors, and so on. vides backends for X11, Windows, Mac OS X, Way- • String and Unicode manipulation. Memory management is handled by reference count- land, , and a web browser. • Date and time functions. ing: when the reference count decreases to 0 the object Another library used heavily by GTK+, but which • A command-line option parser. is destroyed. GObject also provides a powerful system: you can create your own signals and connect is external to the GTK+ project, is , a library • -compatible regular expressions. for 2D graphics with support for multiple output de- callback functions to it. It is a great way to decou- vices (including the X System, Win32 and • An XML parser. ple classes since the object sending the signal doesn’t know who receive it. Another peculiarity of GObject Quartz) while producing a consistent output on all me- • A unit-test framework. while taking advantage of display hardware accel- is a property, which is basically an object attribute sur- • And many other utilities. eration when available. mounted by a notify signal that is sent when its value changes. Last, but not least, GLib provides some core event- Alongside a GLib event loop, the GObject signal sys- driven programming features, with a main event loop, tem forms a foundation for event-driven programming. Your GTK+ Application support for threads and asynchronous communication The event-driven paradigm is not only useful for graph- between threads. An event loop listens some sources of GTK+ ical user interfaces (with user events such as key presses events, that can come from file descriptors (plain files, and mouse clicks), but also for daemons that respond Pango GDK ATK GIO pipes or sockets), timeouts, or other custom sources. A to hardware changes (a USB stick inserted, a second priority is associated with each source of events. When monitor connected, a printer low on paper), or soft- Cairo GLib an event arrives, the event loop dispatches it to the ware that listen to network connections or messages application. The event can then be taken into account, from other processes, among other examples. either in the same or another thread.