GTK 2.0 and 3.0 with Geany under Windows
First Step

We need:

1. gcc, g++ and gtk2.0 or 3.0 under Windows, installed with "win-builds-1.5.0" for example into directory C:\MinGW.
2. Geany under Windows.
3. Configure Geany to compile file .cpp with #include and g++ compiler.

Point 1:
a. Execute win-builds-1.5.0.exe and select the directory c:\MinGW for example.
b. Insert the variable C:\MinGW\bin to path.

Point 2:
a. Install Geany for Windows.

Point 3:
a. Into compiler configuration menu to modify the row Compile with the follow line:
g++ -Wall -c "%f" -mms-bitfields -IC:\MinGW\include\gtk-2.0 -IC:\MinGW\lib64\gtk-2.0\include -IC:\MinGW\include\atk-1.0 -IC:\MinGW\include\cairo -IC:\MinGW\include\gdk-pixbuf-2.0 -IC:\MinGW\include\pango-1.0 -IC:\MinGW\include\glib-2.0 -IC:\MinGW\lib64\glib-2.0\include -IC:\MinGW\include\pixman-1 -IC:\MinGW\include -IC:\MinGW\include\freetype2 -IC:\MinGW\include\libpng14 -Wl,-luuid -LC:\MinGW\lib64 -lgtk-win32-2.0 -lgdk-win32-2.0 -limm32 -lshell32 -lole32 -latk-1.0 -lpangocairo-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lm -lcairo -lgobject-2.0 -lglib-2.0 -lintl
b. Into compiler configuration menu to modify the row Build with the same follow line:
g++ -Wall -o "%e" "%f" -mms-bitfields -IC:\MinGW\include\gtk-2.0 -IC:\MinGW\lib64\gtk-2.0\include -IC:\MinGW\include\atk-1.0 -IC:\MinGW\include\cairo -IC:\MinGW\include\gdk-pixbuf-2.0 -IC:\MinGW\include\pango-1.0 -IC:\MinGW\include\glib-2.0 -IC:\MinGW\lib64\glib-2.0\include -IC:\MinGW\include\pixman-1 -IC:\MinGW\include -IC:\MinGW\include\freetype2 -IC:\MinGW\include\libpng14 -Wl,-luuid -LC:\MinGW\lib64 -lgtk-win32-2.0 -lgdk-win32-2.0 -limm32 -lshell32 -lole32 -latk-1.0 -lpangocairo-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lm -lcairo -lgobject-2.0 -lglib-2.0 -lintl
c. Adjust the other parameters with %e = execute file or %f with file .cpp.

Attention:

For gtk 2.0 must be installed in directory C:\MinGW.
You must change this directory in the before lines, if the directory of gtk 2.0 is different.

We obtained the lines parameter of g++ from the follow command line in the shell cmd.exe of Windows:

C:>pkg-config --cflags --libs gtk+-win32-2.0 > file1.txt ( or 3.0 for gtk3.0).

Open the file file1.txt and change the text /opt/windows-64 with C:\MinGW od other directory of gtk-2.0..
Change slash / with back slash \ using Replace command.
The same thing for gtk3.0, where you must change gtk-2.0 with gtk-3.0..

A simple window

#include <gtk/gtk.h>


int main(int argc, char* argv[])
{
gtk_init(&argc, &argv);

GtkWidget * window;

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

gtk_window_set_title(GTK_WINDOW(window),"Hello World");
gtk_widget_set_size_request(window,1366,680);

g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);

gtk_widget_show_all(window);

gtk_main();

return 0;

}

Window with button

#include <gtk/gtk.h>

static void button_clicked(GtkWidget* widget, gpointer data)
{
g_print("%s\n", "Button is clicked!!");
}

int main(int argc, char* argv[])
{
gtk_init(&argc, &argv);
GtkWidget * window, *button;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label("Click Me");

gtk_container_add(GTK_CONTAINER(window),button);

gtk_window_set_title(GTK_WINDOW(window),"Hello World");
gtk_widget_set_size_request(window,1366,680);

g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(button, "clicked", G_CALLBACK(button_clicked), NULL); // parameter data is NULL

gtk_widget_show_all(window);

gtk_main();

return 0;

}

Window with button, label e vbox

#include <gtk/gtk.h>

static void button_clicked(GtkWidget* widget, gpointer data)
{
gtk_label_set_text(GTK_LABEL(data),"Button is Clicked" );
g_print("%s\n", "Button is clicked");
}

int main(int argc, char* argv[])
{

gtk_init(&argc, &argv);
GtkWidget * window, *label, *button, *vbox;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label("Click Me");
label = gtk_label_new("Hello World!!");

vbox = gtk_vbox_new(GTK_ORIENTATION_VERTICAL,2);
gtk_box_pack_start(GTK_BOX(vbox), label, 1,1,0);
gtk_box_pack_start(GTK_BOX(vbox), button,1,1,0);

gtk_container_add(GTK_CONTAINER(window),vbox);
gtk_label_set_text(GTK_LABEL(label), "World Hello");
gtk_window_set_title(GTK_WINDOW(window),"Hello World");
gtk_widget_set_size_request(window,1366,680);

g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(button, "clicked", G_CALLBACK(button_clicked), label);

gtk_widget_show_all(window);

gtk_main();

return 0;

}

Window with button, label, entry e vbox

#include <gtk/gtk.h>

static void button_clicked(GtkWidget* widget, gpointer data[2])
{
gtk_label_set_text(GTK_LABEL(data[0]), gtk_entry_get_text(GTK_ENTRY(data[1])));
gchar* gc = (gchar*) gtk_entry_get_text(GTK_ENTRY(data[1]));
g_print("%s\n", gc);
}

int main(int argc, char* argv[])
{
gtk_init(&argc, &argv);
GtkWidget * window, *label, *button, *vbox, *entry, *vetWidget[2];
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label("Click Me");
label = gtk_label_new("Hello World!!");
entry = gtk_entry_new();

vetWidget[0] = label;
vetWidget[1] = entry;

//vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL,130); in gtk3.0
vbox = gtk_vbox_new(GTK_ORIENTATION_VERTICAL,130);
gtk_box_pack_start(GTK_BOX(vbox), entry, 1,1,0);
gtk_box_pack_start(GTK_BOX(vbox), label, 1,1,0);
gtk_box_pack_start(GTK_BOX(vbox), button,1,1,0);

gtk_container_add(GTK_CONTAINER(window),vbox);

gtk_window_set_title(GTK_WINDOW(window),"Hello World");
gtk_widget_set_size_request(window,1366,680);

g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(button, "clicked", G_CALLBACK(button_clicked), vetWidget);

gtk_widget_show_all(window);

gtk_main();

return 0;

}

Window with two button, label, vbox and hbox

#include <gtk/gtk.h>
#include <cstring>

static void button_clicked(GtkWidget* widget, gpointer data)
{
if ( strcmp(gtk_button_get_label(GTK_BUTTON(widget)),"Click Me 1") == 0)
{
gtk_label_set_text(GTK_LABEL(data),"Button1 is Clicked" );
g_print("%s\n", "Button1 is clicked");
}

if ( strcmp(gtk_button_get_label(GTK_BUTTON(widget)),"Click Me 2") == 0)
{
gtk_label_set_text(GTK_LABEL(data),"Button2 is Clicked" );
g_print("%s\n", "Button2 is clicked");
}
}

int main(int argc, char* argv[])
{

gtk_init(&argc, &argv);
GtkWidget * window, *label, *button1, *button2, *vbox, *hbox;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button1 = gtk_button_new_with_label("Click Me 1");
button2 = gtk_button_new_with_label("Click Me 2");
label = gtk_label_new("Hello World!!");

hbox = gtk_hbox_new(GTK_ORIENTATION_HORIZONTAL,2);

vbox = gtk_vbox_new(GTK_ORIENTATION_VERTICAL,2);
gtk_box_pack_start(GTK_BOX(hbox), button1, 1,1,0);
gtk_box_pack_start(GTK_BOX(hbox), button2, 1,1,0);
gtk_box_pack_start(GTK_BOX(vbox), label,1,1,0);
gtk_box_pack_start(GTK_BOX(vbox), hbox,1,1,0);

gtk_container_add(GTK_CONTAINER(window),vbox);
gtk_window_set_title(GTK_WINDOW(window),"Hello World");
gtk_widget_set_size_request(window,1366,680);

g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(button1, "clicked", G_CALLBACK(button_clicked), label);
g_signal_connect(button2, "clicked", G_CALLBACK(button_clicked), label);

gtk_widget_show_all(window);

gtk_main();

return 0;
}

Window with two button, two label, vbox and hbox

#include <gtk/gtk.h>

static void button1_clicked(GtkWidget* widget, gpointer data)
{
gtk_label_set_text(GTK_LABEL(data),"Button1 is Clicked" );
g_print("%s\n", "Button1 is clicked");
}

static void button2_clicked(GtkWidget* widget, gpointer data)
{
gtk_label_set_text(GTK_LABEL(data),"Button2 is Clicked" );
g_print("%s\n", "Button2 is clicked");
}
int main(int argc, char* argv[])
{

gtk_init(&argc, &argv);
GtkWidget * window, *label1, *label2, *button1, *button2, *vbox, *hbox1, *hbox2;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button1 = gtk_button_new_with_label("Click Me 1");
button2 = gtk_button_new_with_label("Click Me 2");
label1 = gtk_label_new("Hello World!!");
label2 = gtk_label_new("Hello World!!");

hbox1 = gtk_hbox_new(GTK_ORIENTATION_HORIZONTAL,2);
hbox2 = gtk_hbox_new(GTK_ORIENTATION_HORIZONTAL,2);

vbox = gtk_vbox_new(GTK_ORIENTATION_VERTICAL,2);
gtk_box_pack_start(GTK_BOX(hbox1), label1, 1,1,0);
gtk_box_pack_start(GTK_BOX(hbox1), label2, 1,1,0);
gtk_box_pack_start(GTK_BOX(hbox2), button1, 1,1,0);
gtk_box_pack_start(GTK_BOX(hbox2), button2, 1,1,0);
gtk_box_pack_start(GTK_BOX(vbox), hbox1,1,1,0);
gtk_box_pack_start(GTK_BOX(vbox), hbox2,1,1,0);

gtk_container_add(GTK_CONTAINER(window),vbox);
gtk_window_set_title(GTK_WINDOW(window),"Hello World");
gtk_widget_set_size_request(window,1366,680);

g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(button1, "clicked", G_CALLBACK(button1_clicked), label1);
g_signal_connect(button2, "clicked", G_CALLBACK(button2_clicked), label2);

gtk_widget_show_all(window);

gtk_main();

return 0;
}