Yes you can do this. I have done it but the code
https://github.com/pchilds/MOFsim/blob/master/src/drawcirc.c is in a bit of a sorry incomplete state that I may or may not get back to sometime. It's a lot of wading trying to read it through so here is a short summary:
You will need the following:
1. Have a data structure of the shapes from which you can determine the coordinates of all the shapes (I imagine you already have this).
2. Set up button_press/release or motion_notify events (e.g. you may want to make a shape highlight if the mouse goes over it, to make it clearer to the user that it can be clicked). In a custom widget this would be done e.g. by putting the following in the class_init and init functions:
Code:
static void gtk_your_widget_name_class_init(GtkYourWidgetNameClass *klass)
{
...
(GTK_WIDGET_CLASS(klass))->button_press_event=gtk_your_widget_name_button_press;
}
static void gtk_your_widget_name_init(GtkYourWidgetName *name)
{
gtk_widget_add_events(GTK_WIDGET(name), GDK_BUTTON_PRESS_MASK);
...
}
3. In the _button_press(GtkWidget *widget, GdkEventButton *event) function, iterate over all the data shapes to determine if the event occurred within the bounds of any of the shapes. Coordinates of the event are found as event->x and event->y