Linux Headquarters

I've installed Linux… now what???

GTK+ examples : A Basic Window

Introduction

Our first GTK+ program will be nothing more than a basic window. There are no event handlers, which means that the window will not respond to any user input such as mouse clicks. Although clicking the X button on the title bar to exit the program will cause the window to disappear, the process is still active. You will have to press ctrl-c from the command line from which you executed the program in order to kill it.
When you compile the source code, please note that the quotes used in the command gcc -Wall -g window.c -o window `gtk-config –cflags` `gtk-config –libs` are single backquotes (the one on the ~ key). I don’t know why this is, but it won’t work any other way.
As you can see, it doesn’t take very much code to get something basic on the screen.

Remember that you will have to press ctrl-c in the terminal from which you executed the program in order to kill it.

Source Code

/*
*File name: window.c
*/

#include
#include

int main (int argc, char *argv[])
{
/*– Declare the GTK Widgets used in the program –*/
GtkWidget *window;

/*– Initialize GTK –*/
gtk_init (&argc, &argv);

/*– Create the new window –*/
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

/*– Display the window –*/
gtk_widget_show(window);

/*– Start the GTK event loop –*/
gtk_main();

/*– Return 0 if exit is successful –*/
return 0;
}

Compile the Source Code
gcc -Wall -g window.c -o window `gtk-config –cflags` `gtk-config –libs`

Execute the Program
./window

What is Related

Comments are closed.

Subscribe to email feed

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube
Free UK Domain Names
Inside iOS Apps TechWench
TheDesignMag

Technology blog
Cloud Storage Providers List

Linux top news 2012

Linux is known as one of the basic software used ...

Dedicated Linux Serv

Linux is the popular system nowadays, offering all the benefits ...

StarOffice 5.1

Introduction StarOffice 5.1 is a complete office suite with a word ...

AxY FTP

Introduction AxY FTP, formerly known as wxFTP, is a graphical FTP ...

Adobe Acrobat PDF Re

Introduction Many of you are probably familar with Adobe Acrobat Reader ...

Twitter updates

No public Twitter messages.