This tutorial will explain how to install a full GTK version 3 software development kit on Parabola GNU/Linux computer operating systems. This will include the necessary components as well as the editor, compiler and documentation. Finally, we hope this helps people to develop more desktop free software. Now let's go!
This tutorial is for Parabola so if you want for Debian and Ubuntu, please visit Setup C/GTK for Ubuntu Tutorial instead.
About GTK
GTK, formerly called GTK+, is a choice of computer software libraries to develop graphical user interface applications and desktop environments. GNOME, Gimp and PureOS (Librem Computers) are the best examples of software products created with GTK. With GTK, one can create cross-platform desktop applications with C programming language (other languages also supported). The name GTK itself stands for Gimp Toolkit and in turn is originated from GNU Operating System. Visit its official website at https://www.gtk.org.
Components of GTK:
- GTK
- Glib
- Pango
- Gdk-pixbuf
- ATK
- Gobject-introspection
- Epoxy
List of Programs To Install
Programs we will install as a full software development kit:
1. The seven components of GTK above.
2. GCC, the C compiler.
3. Geany, the integrated development environment.
4. Glade, the interface designer.
5. Devhelp, the documentation reader.
Install GTK on Parabola
First, install all GTK components.
# pacman -S gtk3 glib2 pango atk gobject-introspection gdk-pixbuf2 libepoxy
Then, install GTK documentation and examples.
# pacman -S gtk3-docs gtk3-demos
Then, install the C compiler.
# pacman -S gcc
Then, install the interface builder.
# pacman -S glade
# pacman -S devhelp
Installed Tools
Write Your First Program
// gui.c - Copied from https://developer.gnome.org/gtk3/stable/gtk-getting-started.html #include <gtk/gtk.h> static void print_hello (GtkWidget *widget, gpointer data) { g_print ("Hello World\n"); } static void activate (GtkApplication *app, gpointer user_data) { GtkWidget *window; GtkWidget *button; GtkWidget *button_box; window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), "Window"); gtk_window_set_default_size (GTK_WINDOW (window), 200, 200); button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); gtk_container_add (GTK_CONTAINER (window), button_box); button = gtk_button_new_with_label ("Hello World"); g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window); gtk_container_add (GTK_CONTAINER (button_box), button); gtk_widget_show_all (window); } int main (int argc, char **argv) { GtkApplication *app; int status; app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); return status; }
Compile:
$ gcc `pkg-config --cflags gtk+-3.0` -o gui gui.c `pkg-config --libs gtk+-3.0`
Execute:
$ ./gui
The result:
Happy hacking!
This article is licensed under CC BY-SA 3.0.