#include static void callback( GtkWidget *widget, gpointer data ) { g_print ("Hello again - %s was pressed\n", (gchar *) data); } /* another callback */ static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ) { gtk_main_quit (); return FALSE; } int main( int argc, char *argv[] ) { GtkWidget *xwindow; GtkWidget *xbutton; GtkWidget *xicon_connect, *xicon_disconnect, *xicon_preferences, *xicon_help; GtkWidget *xbutton_connect, *xbutton_disconnect, *xbutton_preferences, *xbutton_help; GtkWidget *xtoolbar; GtkWidget *xvbox; gtk_init (&argc, &argv); xwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (xwindow), "xwintelnet"); g_signal_connect (G_OBJECT (xwindow), "delete_event", G_CALLBACK (delete_event), NULL); gtk_container_set_border_width (GTK_CONTAINER (xwindow), 10); /* We create a box to pack widgets into. This is described in detail * in the "packing" section. The box is not really visible, it * is just used as a tool to arrange widgets. */ xvbox = gtk_vbox_new (FALSE, 0); /* Creates a new button with the label "Button 1". */ xbutton = gtk_button_new_with_label ("Button 1"); xicon = gtk_image_new_from_file("/usr/share/pixmaps/gnome-question.png"); // /usr/share/pixmaps/keyring.png /usr/share/pixmaps/no.xpm xtoolbar = gtk_toolbar_new (); /usr/share/pixmaps/gnome-util.png gtk_toolbar_set_orientation(GTK_TOOLBAR(xtoolbar), GTK_ORIENTATION_HORIZONTAL); xbutton_connect = gtk_toolbar_append_item(GTK_TOOLBAR (xtoolbar), "Close", "My close", "Private", xicon, GTK_SIGNAL_FUNC(delete_event), NULL); gtk_toolbar_append_space(GTK_TOOLBAR(xtoolbar)); xbutton_close = gtk_toolbar_append_item(GTK_TOOLBAR (xtoolbar), NULL, "My close", "Private", xbutton, GTK_SIGNAL_FUNC(delete_event), NULL); /* Now when the button is clicked, we call the "callback" function * with a pointer to "button 1" as its argument */ g_signal_connect (G_OBJECT (xbutton), "clicked", G_CALLBACK (callback), (gpointer) "button 1"); /* Instead of gtk_container_add, we pack this button * into the invisib$ gnome_app_add_toolbar (GNOME_APP (main_window), GTK_TOOLBAR (toolb ar), "toolbar", // gtk_box_pack_start (GTK_BOX(box1), xbutton, TRUE, TRUE, 0); /* Call the same callback function with a different * argument, passing a pointer to "button 2" instead. */ g_signal_connect (G_OBJECT (xbutton), "clicked", G_CALLBACK (callback), (gpointer) "button 2"); // gtk_box_pack_start(GTK_BOX (xvbox), xbutton, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX (xvbox), xtoolbar, TRUE, TRUE, 0); /* Put the box into the main window. */ gtk_container_add (GTK_CONTAINER (xwindow), xvbox); gtk_widget_show_all(xwindow); gtk_main (); return 0; } /* gcc -Wall -g helloworld.c -o helloworld `pkg-config --cflags gtk+-2.0` \ `pkg-config --libs gtk+-2.0` */