Check out
SmartRes2 and SmartRes2 Chat Module to see a working example.
Both addons are "dead" for Retail and Classic, the former because it isn't needed, the latter because I'd have to rewrite they thing (yet again) from scratch including LibResInfo. However, the parts you want do still work.