#include <gtk/gtk.h>

gboolean
on_button_pressed (GtkWidget *widget,
                   GdkEvent  *event,
                   gpointer   user_data)
{
	if ((event->type == GDK_BUTTON_PRESS) && (((GdkEventButton *) event)->button == 3))
	{
		gtk_menu_popup (GTK_MENU (user_data),
		                NULL, NULL, NULL, NULL,
		                ((GdkEventButton *)event)->button, ((GdkEventButton *)event)->time);

		return FALSE;
	}

	return FALSE;
}

int
main (int argc, char *argv[])
{
	GtkWidget *window;
	GtkWidget *box;
	GtkWidget *view;
	GtkWidget *scrollbar;
	GtkWidget *menu;

	gtk_init (&argc, &argv);

	view = gtk_tool_palette_new ();
	scrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (view)));
	box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start (GTK_BOX (box), view, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (box), scrollbar, FALSE, FALSE, 0);

	menu = gtk_menu_new ();
	g_signal_connect (G_OBJECT (box), "button-press-event", G_CALLBACK (on_button_pressed), menu);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_container_add (GTK_CONTAINER (window), box);

	g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

	gtk_widget_show_all (window);

	gtk_main ();

	return 0;
}
