How do I add a popup menu to my GTK+ application?

The menu example in the examples/menu directory of the GTK+ distribution implements a popup menu with this technique:

static gint button_press (GtkWidget *widget, GdkEvent *event)

    if (event->type == GDK_BUTTON_PRESS) {
        GdkEventButton *bevent = (GdkEventButton *) event; 
        gtk_menu_popup (GTK_MENU(widget), NULL, NULL, NULL, NULL,
                        bevent->button, bevent->time);
        /* Tell calling code that we have handled this event; the buck
         * stops here. */
        return TRUE;

    /* Tell calling code that we have not handled this event; pass it on. */
    return FALSE;