Just how can I see the code of gnome panels? as an example watch the code is implemented When I click closure switch in the panel.
As much as I see it the pertinent code remains in panel-action-button.c. This code takes care of the closure and also various other points. You locate the full code at git repository of gnome-panel.