Linux down from the beginning gtk+-3.0 (a)

Source: Internet
Author: User
Tags gtk

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.