Wandering between minigui and GTK for a few days

Source: Internet
Author: User
There were several days between minigui and GTK-Linux general technology-Linux programming and kernel information. The following is a detailed description. In fact, I have been working on minigui, installed from 1.3.3 to 1.6, and then to 2.0.3. I am a zombie, that is, it is still hard to get it. In fact, I don't want to get minigui, but I heard that it is easy to program, also, I learned programming materials on the Internet. I really want to learn this thing. I just got it half a month ago. I have never done it well and I have lost my sleep.

In fact, I still want to get GTK. I borrowed a book from the library manager, that is, the GTK Programming in C, which is very classic, but the make in it is useless, I have never learned how to modify make. I don't know how to change it. I just give up if I don't have problems with make. But today I once again have the courage to get the GTK again. After finding it online for a long time, I finally succeeded in finding a way to compile the GTK program.

Paste an instance below:

/* Env: gtk2.0 */
/* Gcc helloworld. c-o helloworld 'pkg-config -- cflags -- libs gtk +-1000 '*/

# Include

Void OK (GtkWidget * widget, gpointer data)
{
Gtk_main_quit ();
}

Gint quit (GtkWidget * widget, GdkEvent * event, gpointer data)
{
Gtk_main_quit ();
Return FALSE;
}

Int main (int argc, char * argv [])
{
GtkWidget * window;
GtkWidget * button;
GtkWidget * label;
GtkWidget * box;

Gtk_init (& argc, & argv );

Window = gtk_window_new (GTK_WINDOW_TOPLEVEL );
Gtk_container_set_border_width (GTK_CONTAINER (window), 10 );
G_signal_connect (G_OBJECT (window), "delete_event ",
G_CALLBACK (quit), NULL );

Button = gtk_button_new_with_label ("OK ");

G_signal_connect (G_OBJECT (button), "clicked ",
G_CALLBACK (OK), NULL );

Label = gtk_label_new ("Hello, world! ");

Box = gtk_vbox_new (FALSE, 10 );

Gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0 );
Gtk_box_pack_start (GTK_BOX (box), button, TRUE, FALSE, 0 );

Gtk_widget_show (label );
Gtk_widget_show (button );
Gtk_widget_show (box );

Gtk_container_add (GTK_CONTAINER (window), box );

Gtk_widget_show (window );

Gtk_main ();

Return 0;
}


In linux, enter the directory where the program is located. Do not directly use gcc. So gcc:

Gcc helloworld. c-o helloworld 'pkg-config -- cflags -- libs gtk +-1000'

The above "'" is a point on the tab key, and it cannot be wrong.

Compile a program.

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.