## GTK System Driver (since 3.0)

This driver was designed for the GTK+ version 2 and 3. It can be compiled in Windows or UNIX.

Although GTK has layout elements they are not used. IUP fill, vbox, hbox and zbox containers are implemented independent from the native system.

The oldest GTK version that can be used is 2.4, oldest versions will not compile. But using versions older than 2.12 several features will not work. Critical features need at least version 2.8.

Currently it is not available for IRIX, AIX and SunOS. But is it available for SunOS10 and it is not available for Linux24.

### Tips

#### Locale

Since 3.28, in IupOpen we call setlocale(LC_NUMERIC, "C") to reset the locale to the default for C applications. Because GTK is changing the locale in gtk_init to match the system language, and this affects the parse of the decimal separator of floating point numbers in strings.

#### Inspecting Native Controls

The GTK+ Inspector tool included in GTK is very useful to inspect GTK controls position, size and visibility. To enable the GTK+ inspector, you can use the Control-Shift-I or Control-Shift-D keyboard shortcuts, or set the GTK_DEBUG=interactive environment variable. In a similar way you can also use the IupLayoutDialog to show IUP controls attributes and callbacks, in a interactive display of the dialog layout.

#### GTK 3.x (since 3.7)

GTK 3.x is supported. But the pre-compiled binaries, up to Linux 3.2, are still built with GTK 2.x. This is because GTK 3 involves a big change for drawing applications, and most Tecgraf applications are heavily graphics dependent. The main change is that GDK does not have drawing primitives anymore, and all drawing is performed by Cairo. Cairo does not have support for XOR used by many drawing applications to perform a selection rubber band. Also Cairo could have a different behavior for some primitives.

Since Linux 3.13 the default is to use GTK 3.

For older Linux to build the driver with GTK 3.x support define USE_GTK3=Yes before calling make in the "iup/src" folder. Just the main library must be rebuilt. Also, if CD is used, the CD main library must be rebuilt with the same parameter.

#### Dependencies

GTK is in fact composed of several libraries. The GTK package contains the GDK library and depends on the ATK, Cairo, Glib and Pango libraries.

#### X11 Dependencies (since 3.25)

When using GTK 3, the X11 usage is drastically reduced. It is not necessary at all, although it is still there for backward compatibility. To completely remove the X11 dependencies define GDK_NULL in "iup/src/config.mak". The GDK_NULL definition can also be used for GTK 2, but there is a limitation, the SCREENSIZE attribute will not correctly exclude the desktop decorations.

#### UTF-8

GTK uses UTF-8 as its charset for all displayed text, so IUP will automatically convert all strings to (SetAttribute) and from (GetAttribute) UTF-8. But the default is still to use the current locale. To use UTF-8 strings set the global attribute UTF8MODE to YES.

#### Windows

The GTK driver can be compiled and used in Windows, but it is not recommended since it is slower and much more memory consuming than the IUP native Windows driver.

When using DLLs in Windows, the "iup.dll" uses the Win32 driver. So applications that dynamically load IUP will always use the "iup.dll", for example Lua using require. To use the IUP GTK dll in Windows you must rename the "iupgtk.dll" to "iup.dll", so the GTK driver will be loaded instead of the Win32 driver.

After installing the GTK binaries, we recommend changing the default theme to the "MS-Windows" theme. Edit the "gtk\etc\gtk-2.0\gtkrc" file and change its contents to:

    gtk-theme-name = "MS-Windows"

#### Ubuntu Unity

Since Ubuntu version 11, there is a new desktop called Unity. This desktop introduces some changes that affect all applications. Two of these changes directly affect IUP applications.

First the global menu forces all dialog menus to be displayed in the top of the desktop, like in MacOSX. This affected the size of the IUP dialog, it is fixed since IUP version 3.6. If you don't like the global menu you can remove it using:

    sudo apt-get remove appmenu-gtk3 appmenu-gtk appmenu-qt

You can also control that using "export UBUNTU_MENUPROXY=0". There are other forms to control this feature - see "How to Disable the AppMenu".

In later Ubuntu versions you can do the command:

    gsettings set com.canonical.Unity integrated-menus true

or you can uninstall the "indicator-appmenu" package. See "How do I enable or disable the global application menu?".

In some systems when using the appmenu, the application menu items do not get inactive when set.

Second, the scrollbars are reduced to a very tiny line and handlers are displayed only when the mouse moves over the right or bottom side of the element. All the controls, except the IupCanvas, will work ok with the new scrollbar. But in IupCanvas the SCROLL_CB callback will receive only the IUP_SBPOSV and IUP_SBPOSH operations codes (fixed in IUP 3.11.1).

You can remove the new scrollbar at the Synaptic Package Manager or at the Ubuntu Software Center searching for "overlay-scrollbar" and removing the installed packages. You can also control that using "export LIBOVERLAY_SCROLLBAR=0". In later Ubuntu versions you can do the command:

    gsettings set com.canonical.desktop.interface scrollbar-mode normal

#### MacOSX-Quartz

The GTK driver also compiles in MacOSX with the new GTK port available at http://gtk-osx.sourceforge.net/ using Quartz. But the IupGLCanvas is not available yet. You must use the GDK base driver of the CD library. Some elements like IupTree are not 100% functional because of the gtk-osx implementation. The installation of gtk-osx is quite complex because there are no pre-compiled binaries. Also if the MacOSX theme is used, several controls have problems. We hope that this will improve in the future. Must define GTK_MAC before compiling to enable this build.

#### MacOSX-X11

So for now we are distributing binaries that use the X11 version of GTK 2.16. They were installed using Fink. Here is a simple guide to install fink so the pre-compiled binaries will work (tested in 10.5 and 10.6):

    Download latest fink source: fink-0.29.21
    tar -xvzf fink-0.29.21.tar.gz
    cd fink-0.29.21
    ./bootstrap
    	Use all default answers, except for the second question about 64bits:
    	(10.5) => (1) Default (mostly 32bit)  [because gcc use 32bit as default]
    	(10.6) => (2) 64bit-only              [because gcc use 64bit as default]
    /sw/bin/pathsetup.sh
    fink selfupdate-rsync
    fink index -f
    fink install gtk+2 gtk+2-dev

It will take some time to download and install everything, so have patience.

After that you should get something like this:

    fink --version
      Package manager version: 0.29.10
      Distribution version: selfupdate-rsync Thu Apr 29 11:51:11 2010, 10.6, x86_64  (10.6)
      Distribution version: selfupdate-rsync Thu Apr 29 11:50:49 2010, 10.5, i386    (10.5)

    fink list -i gtk+2
      Information about XXXX packages read in X seconds.
       i   gtk+2            2.16.6-3     The Gimp Toolkit
       i   gtk+2-dev        2.16.6-3     The Gimp Toolkit
       i   gtk+2-shlibs     2.16.6-3     The Gimp Toolkit

You can use MacPorts instead of Fink. The installation is very similar, but it seems simpler. Although we did not have the opportunity to test it, some users report that this work ok.

MacPorts have two GTK installations, one for X11 and one for Quartz. This is a lot simpler than trying to install the gtk-osx distribution. Just keep in mind that if using Quartz, OpenGL with IUP will not be available.

When building IUP or CD in MacOSX, define the following variables in the system before typing "make":

    export USE_MACOS_OPENGL=Yes      # To use the OpenGL framework
    export GTK_BASE=/sw              # For Fink
    export GTK_BASE=/opt/local       # For MacPorts
    export GTK_MAC=Yes               # For Quartz instead of X11

#### Native Code

The GTK driver is not pure GTK and GDK code. It uses Win32 and X11 calls in some parts, specifically in "iupgtk_open.c". And it depends on some Win32 and X11 modules, such as: "iup*_info.c", "iup_glcanvas*.c". Also the CD library has some native code in the "cdcaironative_gdk.c" that affects the CD_IUP driver. These are the files that need to be changed for a fully functional MacOSX-Quartz driver.