Cross-platform Graphical User Interface library
Website: http://www.gtk.org
Platforms supported: Win32, Linux, FreeBSD
Headers to include: gtk/gtk.bi
Example Usage: yes, in examples/GUI/GTK+/
Header version: 2.24.27, 3.14.10
By default, gtk/gtk.bi will use the GTK+ 2 API.
Define __USE_GTK3__ before including gtk/gtk.bi to use GTK+ 3.
GObject property setters are variadic C calls: pass the type declared for each property. A double property needs a Double expression, not an Integer. Use CTRUE (1) for boolean properties; FreeBASIC TRUE (-1) can be rejected by property validation. In the GooCanvas table example, the width_TJF parameter must supply the width property, rather than BASIC's WIDTH function.
The Linux GTK example runner checks the original GTK 2, GTK 3 and GooCanvas windows on isolated, authenticated Xvfb displays, including normal window closure. It stages each example's assets, tests all three packing layouts and opens a text fixture in the application example. GooCanvas checks also drag the arrow-width handle and verify keyboard focus events. Software OpenGL and these headless windows do not establish accelerated GPU or physical display operation. See build_scripts/test-gtk-examples.py and doc/linux-example-qualification.md.
On FreeBSD, the manual GTK 2 window example exited under Xvfb and linked GTK 2.
The synthetic close emitted a Gdk-WARNING when the headless server destroyed
the window. GTK 3 and GooCanvas runtime behavior remains unqualified.
Example
#include Once "gtk/gtk.bi"
Dim Shared As GtkWidget Ptr win
Private Sub on_clicked cdecl(ByVal button As GtkButton Ptr, ByVal userdata As gpointer)
Static As Integer clickcount = 0
clickcount += 1
gtk_window_set_title(GTK_WINDOW(win), "clicked " & clickcount & " times")
End Sub
gtk_init(NULL, NULL)
win = gtk_window_new(GTK_WINDOW_TOPLEVEL)
gtk_window_set_title(GTK_WINDOW(win), "A small GTK+ example")
gtk_window_set_default_size(GTK_WINDOW(win), 300, 200)
gtk_container_set_border_width(GTK_CONTAINER(win), 20)
g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(@gtk_main_quit), NULL)
Dim As GtkWidget Ptr button = gtk_button_new_with_label("Click me!")
gtk_container_add(GTK_CONTAINER(win), button)
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(@on_clicked), NULL)
gtk_widget_show_all(win)
gtk_main()