Originally due to the project requirements in Linux under a period of time to learn gtk+2.0 graphics development, after a period of time, want to really deep learning GTK.
This is a straight-from-the-gtk+-3.0, and it's easy to get started by writing a blog post for later viewing.
Installation Environment Reference:
Fedora:http://www.cnblogs.com/watsonlong/archive/2011/04/06/2006989.html
Ubuntu:http://www.cnblogs.com/niocai/archive/2011/07/15/2107472.html
Arch: Execute sudo pacman-s gtk3 directly.
note that the GTK3 is used, most of the above is GTK2, note the same way to install GTK3.
The first thing to learn is to create a blank window. We create a source file named Example.c. The contents are as follows
1#include <gtk/gtk.h>//each GTK program contains a header file that states many types, function prototypes, etc.2 3 Static voidActivate (Gtkapplication *app, gpointer data)4 {5Gtkwidget *window;//Declare a window6 7window = gtk_application_window_new (APP);//Create a window for your app8 9Gtk_window_set_title (Gtk_window (window),"Application");//set the title of the windowTenGtk_window_set_default_size (Gtk_window (window), $, $);//The default size of the setting window is 200 pixels long and wide OneGtk_widget_show_all (window);//Display window A } - - the intMainintARGC,Char**ARGV)//Main function - { -Gtkapplication *app;//Disclaimer Create a Gtkapplicatin object named App - intApp_status;//used to get the return value after the app has finished running + -App = Gtk_application_new ("ORG.RAIN.GTK", G_application_flags_none);//Create a application +G_signal_connect (App,"Activate", G_callback (Activate), NULL);//connect the signal, when initializing the app, call the Activate function AApp_status = G_application_run (g_application (APP), argc, argv);//Run the app at -G_object_unref (APP);//Destroying Apps - - returnApp_status; -}
Compile the source file as follows and execute the generated example executable file.
gcc example.c 'pkg-config --cflags--libs gtk+-3.0'-wall-o example. /example
The results of the operation are as follows:
Linux down from the beginning gtk+-3.0 (a)