# Path: dpa/ui/icon/factory.py
# class IconFactory(object):
# 
#     ICON_SCHEME = "icon:///"
# 
#     # -------------------------------------------------------------------------
#     @classmethod
#     def is_icon_path(cls, path):
#         return path.startswith(cls.ICON_SCHEME)        
# 
#     # -------------------------------------------------------------------------
#     def disk_path(self, uri):
# 
#         if not uri:
#             return ""
#         
#         # XXX need to properly parse uri
#         rel_path = uri.replace(self.__class__.ICON_SCHEME, "")
# 
#         image_paths = self.ptask_area.ancestor_paths(
#             relative_file=rel_path, include_install=True)
# 
#         for image_path in image_paths:
#             if os.path.exists(image_path):
#                 return image_path
# 
#         return rel_path    
# 
#     # -------------------------------------------------------------------------
#     @property
#     def ptask_area(self):
# 
#         if not hasattr(self, '_ptask_area'):
#             self._ptask_area = PTaskArea.current()
# 
#         return self._ptask_area


from maya import cmds, mel
from dpa.ui.icon.factory import IconFactory
        import sys
    @classmethod
    def get(cls, name, layout=None):
        
        if not layout:
            layout = cls.top_level_layout()

        cmds.setParent(layout)
        shelf = cmds.shelfLayout(name, q=True, exists=True)

        if shelf:
            return cls(name, layout)
        else:
            raise NameError("Unable to find shelf: " + name)

    # -------------------------------------------------------------------------
    def __init__(self, name, layout=None):
        self._name = name

        if not layout:
            layout = self.__class__.top_level_layout()
        self._layout = layout

    # -------------------------------------------------------------------------
    def add_button(self, **kwargs):


        # intercept/adjust some of the arguments
        for (key, val) in kwargs.iteritems():

            # get full image path

# Path: dpa/ui/icon/factory.py
# class IconFactory(object):
# 
#     ICON_SCHEME = "icon:///"
# 
#     # -------------------------------------------------------------------------
#     @classmethod
#     def is_icon_path(cls, path):
#         return path.startswith(cls.ICON_SCHEME)        
# 
#     # -------------------------------------------------------------------------
#     def disk_path(self, uri):
# 
#         if not uri:
#             return ""
#         
#         # XXX need to properly parse uri
#         rel_path = uri.replace(self.__class__.ICON_SCHEME, "")
# 
#         image_paths = self.ptask_area.ancestor_paths(
#             relative_file=rel_path, include_install=True)
# 
#         for image_path in image_paths:
#             if os.path.exists(image_path):
#                 return image_path
# 
#         return rel_path    
# 
#     # -------------------------------------------------------------------------
#     @property
#     def ptask_area(self):
# 
#         if not hasattr(self, '_ptask_area'):
#             self._ptask_area = PTaskArea.current()
# 
#         return self._ptask_area


# Path: dpa/maya/shelf.py
from maya import cmds, mel
from dpa.ui.icon.factory import IconFactory
        import sys

    @classmethod
    def get(cls, name, layout=None):
        
        if not layout:
            layout = cls.top_level_layout()

        cmds.setParent(layout)
        shelf = cmds.shelfLayout(name, q=True, exists=True)

        if shelf:
            return cls(name, layout)
        else:
            raise NameError("Unable to find shelf: " + name)

    # -------------------------------------------------------------------------
    def __init__(self, name, layout=None):
        self._name = name

        if not layout:
            layout = self.__class__.top_level_layout()
        self._layout = layout

    # -------------------------------------------------------------------------
    def add_button(self, **kwargs):


        # intercept/adjust some of the arguments
        for (key, val) in kwargs.iteritems():

            # get full image path

            if key.startswith("image") and IconFactory.is_icon_path(val):