For GTK + problems, please come in !!!

Source: Internet
Author: User
For GTK + problems, please come in !!! -- Linux general technology-Linux programming and kernel information. The following is a detailed description. # Include
GtkWidget * create_list (void)
{
GtkWidget * scrolled;
GtkWidget * list;
GtkWidget * list_item;
Int I;
Char buffer [16];
Scrolled = gtk_scrolled_window_new (NULL, NULL );
Gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
List = gtk_list_new ();
Gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled), list );
Gtk_widget_show (list );
For (I = 1; I <10; I ++)
{
Sprintf (buffer, "Message # % d", I );
List_item = gtk_list_item_new_with_label (buffer );
Gtk_container_add (GTK_CONTAINER (list), list_item );
Gtk_widget_show (list_item );
}
Return scrolled;
}
Void realize_text (GtkWidget * text, gpointer data)
{
Gtk_text_freeze (GTK_TEXT (text ));
Gtk_text_insert (GTK_TEXT (text), NULL, & text-> style-> black, NULL,
"From: pathfinder@nasa.gov \ n"
"To: mom@nasa.gov \ n"
"Subject: Made it! \ N"
"\ N"
"We just got in this morning. The weather has been \ n"
"Great-clear but cold, and there are lots of fun sights. \ n"
"Sojurner says hi. see you soon. \ n"
"-Path \ n",-1 );
Gtk_text_thaw (GTK_TEXT (text ));
}
GtkWidget * create_text (void)
{
GtkWidget * table;
GtkWidget * hscrollbar;
GtkWidget * vscrollbar;
GtkText * text;
GtkAdjustment * hadj, * vadj;
Table = gtk_table_new (2, 2, FALSE );
Vadj = gtk_adjustment_new (5, 1, 15, 2, 5 );
Hadj = gtk_adjustment_new (5, 1, 15, 2, 5 );
Text = gtk_text_new (NULL, NULL );
Gtk_table_attach (GTK_TABLE (table), text, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND | GTK_SHRINK );
// Gtk_text_set_adjustments (text, hadj, vadj );
Gtk_widget_show (text );
// Hadj = gtk_text_get_hadjustment (GTK_TEXT (text ));
Hscrollbar = gtk_hscrollbar_new (GTK_TEXT (text)-> hadj );
Gtk_table_attach (GTK_TABLE (table), hscrollbar, GTK_FILL | GTK_EXPAND, GTK_FILL );
Gtk_widget_show (hscrollbar );
// Vadj = gtk_text_get_vadjustment (GTK_TEXT (text ));
Vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)-> vadj );
Gtk_table_attach (GTK_TABLE (table), vscrollbar, GTK_FILL, GTK_FILL | GTK_EXPAND | GTK_SHRINK );
Gtk_widget_show (vscrollbar );
Gtk_signal_connect (GTK_OBJECT (text), "realize", GTK_SIGNAL_FUNC (realize_text), NULL );
Return table;
}
Int main (int argc, char * argv [])
{
GtkWidget * window;
GtkWidget * vpaned;
GtkWidget * list;
GtkWidget * text;
Gtk_init (& argc, & argv );
Window = gtk_window_new (GTK_WINDOW_TOPLEVEL );
Gtk_container_set_border_width (GTK_CONTAINER (window), 10 );
Gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_main_quit), NULL );
Gtk_window_set_title (GTK_WINDOW (window), "Paned Windows ");
Gtk_widget_set_usize (window, 450,400 );
Vpaned = gtk_vpaned_new ();
Gtk_container_add (GTK_CONTAINER (window), vpaned );
// Gtk_paned_set_handle_size (GTK_PANED (vpaned), 10 );
Gtk_paned_set_gutter_size (GTK_PANED (vpaned), 15 );
Gtk_widget_show (vpaned );
List = create_list ();
Gtk_paned_add1 (GTK_PANED (vpaned), list );
Gtk_widget_show (list );
Text = create_text ();
Gtk_paned_add2 (GTK_PANED (vpaned), text );
Gtk_widget_show (text );
Gtk_widget_show (window );
Gtk_main ();
Return 0;


}

I used: gcc-o gtktext. c 'pkg-config -- cflags -- libs gtk +-1000'

During compilation, GTK_TEXTf is not defined. What's going on ??

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.