The skin already has this functionality built in though, kinda:
Code:
<onclick condition="Library.HasContent(movies) + Skin.HasSetting(home_no_categories_widget)">ActivateWindow(Videos,videodb://movies/,return)</onclick>
<onclick condition="Library.HasContent(movies) + !Skin.HasSetting(home_no_categories_widget)">ActivateWindow(Videos,videodb://movies/titles/,return)</onclick>
<onclick condition="!Library.HasContent(movies)">ActivateWindow(Videos,sources://video/,return)</onclick>
If I have the categories widget enabled on the home screen, it flattens the hierarchy. When I disable the categories widget, the hierarchy returns.
I could amend the skin so both ActivateWindows are set to videodb://movies/titles/, or add a skin.setting for flatten_hierarchy and read that, I just thought it would be a better solution if I could read the setting straight out of the guisettings.xml, rather than create a duplicate setting.