5
/* Create a new hbox with an image and a label packed into it
6
* and return the box. */
8
static GtkWidget *xpm_label_box( gchar *xpm_filename,
15
/* Create box for image and label */
16
box = gtk_hbox_new (FALSE, 0);
17
gtk_container_set_border_width (GTK_CONTAINER (box), 2);
19
/* Now on to the image stuff */
20
image = gtk_image_new_from_file (xpm_filename);
22
/* Create a label for the button */
23
label = gtk_label_new (label_text);
25
/* Pack the image and label into the box */
26
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3);
27
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3);
29
gtk_widget_show (image);
30
gtk_widget_show (label);
35
/* Our usual callback function */
36
static void callback( GtkWidget *widget,
39
g_print ("Hello again - %s was pressed\n", (char *) data);
45
/* GtkWidget is the storage type for widgets */
50
gtk_init (&argc, &argv);
52
/* Create a new window */
53
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
55
gtk_window_set_title (GTK_WINDOW (window), "Pixmap'd Buttons!");
57
/* It's a good idea to do this for all windows. */
58
g_signal_connect (G_OBJECT (window), "destroy",
59
G_CALLBACK (gtk_main_quit), NULL);
61
g_signal_connect (G_OBJECT (window), "delete_event",
62
G_CALLBACK (gtk_main_quit), NULL);
64
/* Sets the border width of the window. */
65
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
67
/* Create a new button */
68
button = gtk_button_new ();
70
/* Connect the "clicked" signal of the button to our callback */
71
g_signal_connect (G_OBJECT (button), "clicked",
72
G_CALLBACK (callback), (gpointer) "cool button");
74
/* This calls our box creating function */
75
box = xpm_label_box ("info.xpm", "cool button");
77
/* Pack and show all our widgets */
78
gtk_widget_show (box);
80
gtk_container_add (GTK_CONTAINER (button), box);
82
gtk_widget_show (button);
84
gtk_container_add (GTK_CONTAINER (window), button);
86
gtk_widget_show (window);
88
/* Rest in gtk_main and wait for the fun to begin! */