DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

C - Simple Example GTK

12.05.2006
| 18141 views |
  • submit to reddit
        // gcc file.c -o file.o `pkg-config --libs --cflags gtk+-2.0`

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

void displayUI()
{
	GtkWidget* mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);

	gtk_window_set_default_size(GTK_WINDOW(mainWindow), 400, 300);
	gtk_window_set_title(GTK_WINDOW(mainWindow), "GTK Simple Example");
	gtk_window_set_position(GTK_WINDOW(mainWindow), GTK_WIN_POS_CENTER_ALWAYS);

	gtk_signal_connect(GTK_OBJECT(mainWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL);

	gtk_widget_show_all(mainWindow);
}

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

	displayUI();

	gtk_main();

	return EXIT_SUCCESS;
}