As far as I know, it’s not possible to determine the mode using code. See the Gallery API for details. In addition, not all Galleries support all of the API functions. The Pro Gallery is limited regarding the functions.
You might consider taking another approach demonstrated in the Change Layout example.