The interface written with GTK today is quite simple. It's my entry-level work.

Source: Internet
Author: User
Tags gtk

# Include <GTK/GTK. h>
Static gtkwidget * credits_window;
Gtkwidget * create_credits ()
{
Gtkwidget * window;
Gtkwidget * vbox, * hbox;
Gtkwidget * notebook, * button;
Gtkwidget * Page, * viewport;
Gtkwidget * label, * text;
Gtkwidget * entry, * image; // in personal information.
Gdkpixbuf * pixbuf;
Gtktextbuffer * text_buffer;
Gtkwidget * view;

Window = gtk_window_new (gtk_window_toplevel );
Gtk_window_set_title (gtk_window (window), "Kai Fa Ren yuan ");
Vbox = gtk_vbox_new (false, 0 );
Gtk_container_add (gtk_container (window), vbox );
Notebook = gtk_notebook_new ();
Gtk_box_pack_start (gtk_box (vbox), notebook, true, true, 5 );

Page = gtk_vbox_new (false, 0 );

// Viewport = gtk_viewport_new (null, null );
// Gtk_box_pack_start (gtk_box (PAGE), viewport, true, true, 5 );

View = gtk_scrolled_window_new (null, null );//
Gtk_scrolled_window_set_policy (gtk_scrolled_window (view), gtk_policy_automatic, gtk_policy_automatic );
TEXT = gtk_text_view_new ();
Gtk_box_pack_start (gtk_box (PAGE), view, true, true, 5); // vbox
Gtk_container_add (gtk_container (view), text );
// Gtk_container_add (gtk_container (viewport), view );
Text_buffer = gtk_text_view_get_buffer (gtk_text_view (text ));

Hbox = gtk_hbox_new (false, 0 );
Gtk_box_pack_start (gtk_box (PAGE), hbox, false, false, 5 );

Button = gtk_button_new_with_label ("Confirm release ");
G_signal_connect (g_object (button), "clicked ",
G_callback (gtk_main_quit), null );//
Gtk_box_pack_start (gtk_box (hbox), button, false, false, 5 );
Button = gtk_button_new_with_label ("cancel ");
G_signal_connect (g_object (button), "clicked ",
G_callback (gtk_main_quit), null );
Gtk_box_pack_start (gtk_box (hbox), button, false, false, 5 );
 
 
Label = gtk_label_new ("Publish notification ");
Gtk_notebook_append_page (gtk_notebook (notebook), page, label );
// ================================================ ========================================================== ===
Page = gtk_vbox_new (false, 0 );
View = gtk_scrolled_window_new (null, null );//
Gtk_scrolled_window_set_policy (gtk_scrolled_window (view), gtk_policy_automatic, gtk_policy_automatic );
TEXT = gtk_text_view_new ();
Gtk_box_pack_start (gtk_box (PAGE), view, true, true, 5); // vbox
Gtk_container_add (gtk_container (view), text );
// Viewport = gtk_viewport_new (null, null );
// Gtk_box_pack_start (gtk_box (PAGE), viewport, true, true, 5 );
// Text = gtk_text_view_new ();
// Gtk_container_add (gtk_container (viewport), text );
Text_buffer = gtk_text_view_get_buffer (gtk_text_view (text ));

Hbox = gtk_hbox_new (false, 0 );
Gtk_box_pack_start (gtk_box (PAGE), hbox, false, false, 5 );


Button = gtk_button_new_with_label ("approval for leave ");
G_signal_connect (g_object (button), "clicked ",
G_callback (gtk_main_quit), null );//
Gtk_box_pack_start (gtk_box (hbox), button, false, false, 5 );
Button = gtk_button_new_with_label ("not approved ");
G_signal_connect (g_object (button), "clicked ",
G_callback (gtk_main_quit), null );
Gtk_box_pack_start (gtk_box (hbox), button, false, false, 5 );
 

Label = gtk_label_new ("approval for leave ");
Gtk_notebook_append_page (gtk_notebook (notebook), page, label );

// ================================================ ========================================================== ========
Page = gtk_vbox_new (false, 0 );
// Label = gtk_label_new ("Yu 1123/nhello, nice to meet you/n gglad To see you again ");
Hbox = gtk_hbox_new (false, 5 );
Gtk_box_pack_start (gtk_box (PAGE), hbox, false, false, 0 );
 
Viewport = gtk_viewport_new (null, null );
Gtk_container_add (gtk_container (PAGE), viewport );
Pixbuf = gdk_pixbuf_new_from_file ("gnome-spider.png", null );
Image = gtk_image_new_from_pixbuf (pixbuf );
Gtk_container_add (gtk_container (viewport), image );
Hbox = gtk_hbox_new (false, 5 );
Gtk_box_pack_start (gtk_box (PAGE), hbox, false, false, 0 );

Label = gtk_label_new ("student ID :");
Gtk_box_pack_start (gtk_box (hbox), label, false, false, 0 );

Entry = gtk_entry_new ();
Gtk_box_pack_start (gtk_box (hbox), entry, false, false, 0 );

Label = gtk_label_new ("name :");
Gtk_box_pack_start (gtk_box (hbox), label, false, false, 0 );

Entry = gtk_entry_new ();
Gtk_box_pack_start (gtk_box (hbox), entry, false, false, 0 );

Hbox = gtk_hbox_new (false, 5 );
Gtk_box_pack_start (gtk_box (PAGE), hbox, false, false, 0 );

Label = gtk_label_new ("Tel :");
Gtk_box_pack_start (gtk_box (hbox), label, false, false, 0 );

Entry = gtk_entry_new ();
Gtk_box_pack_start (gtk_box (hbox), entry, false, false, 0 );
 
Label = gtk_label_new ("score :");
Gtk_box_pack_start (gtk_box (hbox), label, false, false, 0 );

Entry = gtk_entry_new ();
Gtk_box_pack_start (gtk_box (hbox), entry, false, false, 0 );

Hbox = gtk_hbox_new (false, 5 );
Gtk_box_pack_start (gtk_box (PAGE), hbox, false, false, 0 );

Label = gtk_label_new ("number of leave requests :");
Gtk_box_pack_start (gtk_box (hbox), label, false, false, 0 );

Entry = gtk_entry_new ();
Gtk_box_pack_start (gtk_box (hbox), entry, false, false, 0 );

Label = gtk_label_new ("Times late :");
Gtk_box_pack_start (gtk_box (hbox), label, false, false, 0 );

Entry = gtk_entry_new ();
Gtk_box_pack_start (gtk_box (hbox), entry, false, false, 0 );

Hbox = gtk_hbox_new (false, 5 );
Gtk_box_pack_start (gtk_box (PAGE), hbox, false, false, 0 );

Label = gtk_label_new ("absenteeism :");
Gtk_box_pack_start (gtk_box (hbox), label, false, false, 0 );

Entry = gtk_entry_new ();
Gtk_box_pack_start (gtk_box (hbox), entry, false, false, 0 );

Label = gtk_label_new ("number of early departures :");
Gtk_box_pack_start (gtk_box (hbox), label, false, false, 0 );

Entry = gtk_entry_new ();
Gtk_box_pack_start (gtk_box (hbox), entry, false, false, 0 );

Hbox = gtk_hbox_new (false, 5 );
Gtk_box_pack_start (gtk_box (PAGE), hbox, false, true, 0 );

Label = gtk_label_new ("Awards :");
Gtk_box_pack_start (gtk_box (hbox), label, false, false, 0 );

Viewport = gtk_viewport_new (null, null );
Gtk_container_add (gtk_container (hbox), viewport );
TEXT = gtk_text_view_new ();
Gtk_container_add (gtk_container (viewport), text );
Text_buffer = gtk_text_view_get_buffer (gtk_text_view (text ));

Hbox = gtk_hbox_new (false, 5 );
Gtk_box_pack_start (gtk_box (PAGE), hbox, false, true, 0 );

Label = gtk_label_new ("sanction :");
Gtk_box_pack_start (gtk_box (hbox), label, false, false, 0 );
Viewport = gtk_viewport_new (null, null );
Gtk_container_add (gtk_container (hbox), viewport );
TEXT = gtk_text_view_new ();
Gtk_container_add (gtk_container (viewport), text );
Text_buffer = gtk_text_view_get_buffer (gtk_text_view (text ));
 
// Gtk_box_pack_start (gtk_box (PAGE), viewport, false, false, 5 );
Label = gtk_label_new ("class information ");
Gtk_notebook_append_page (gtk_notebook (notebook), page, label );
// ================================================ ======================================
Page = gtk_vbox_new (false, 0 );
View = gtk_scrolled_window_new (null, null );//
Gtk_scrolled_window_set_policy (gtk_scrolled_window (view), gtk_policy_automatic, gtk_policy_automatic );
TEXT = gtk_text_view_new ();
Gtk_box_pack_start (gtk_box (PAGE), view, true, true, 5); // vbox
Gtk_container_add (gtk_container (view), text );
// Viewport = gtk_viewport_new (null, null );
// Gtk_box_pack_start (gtk_box (PAGE), viewport, true, true, 5 );
// Text = gtk_text_view_new ();
// Gtk_container_add (gtk_container (viewport), text );
Text_buffer = gtk_text_view_get_buffer (gtk_text_view (text ));

Hbox = gtk_hbox_new (false, 0 );
Gtk_box_pack_start (gtk_box (PAGE), hbox, false, false, 5 );

// Gtk_box_pack_start (gtk_box (PAGE), label, false, false, 5 );
Label = gtk_label_new ("Message Board ");
Gtk_notebook_append_page (gtk_notebook (notebook), page, label );
// ================================================ ======================================
Gtk_widget_show_all (window );
Return window;

}
Void show_credits ()
{
Credits_window = create_credits ();
Gtk_widget_show (credits_window );

}
Int main (INT argc, char * argv [])
{
Gtkwidget * window;
Gtkwidget * bBox;
Gtkwidget * vbox;
Gtkwidget * label;
Gtkwidget * image;
Gtkwidget * Sep;
Gtkwidget * button;
Gtk_init (& argc, & argv );
Window = gtk_window_new (gtk_window_toplevel );
G_signal_connect (g_object (window), "delete_event", g_callback (gtk_main_quit), null );
Gtk_window_set_title (gtk_window (window), "about dialog ");
Gtk_window_set_position (gtk_window (window), gtk_win_pos_center );
Gtk_container_set_border_width (gtk_container (window), 10 );

Vbox = gtk_vbox_new (false, 0 );
Gtk_container_add (gtk_container (window), vbox );
Image = gtk_image_new_from_file ("gnome-spider.png ");
Gtk_box_pack_start (gtk_box (vbox), image, false, false, 5 );
Label = gtk_label_new (null );
Gtk_label_set_markup (gtk_label (Label), "<span> <big> GTK + 2.0 shi li Pian Cheng </big> </span> ");
Gtk_box_pack_start (gtk_box (vbox), label, false, false, 5 );
SEP = gtk_hseparator_new ();
Gtk_box_pack_start (gtk_box (vbox), SEP, false, false, 5 );
BBox = gtk_hbutton_box_new ();
Gtk_button_box_set_layout (gtk_button_box (bBox), gtk_buttonbox_edge );

Gtk_box_pack_start (gtk_box (vbox), bBox, false, false, 5 );
Button = gtk_button_new_with_label ("Kai Fa Ren yuan ");
// Gtk_box_pack_start (gtk_box (vbox), button, false, false, 5 );
G_signal_connect (g_object (button), "clicked", g_callback (show_credits), null );
Gtk_box_pack_start (gtk_box (bBox), button, false, false, 35 );
Gtk_widget_show_all (window );
Gtk_main ();
Return false;
}

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.