# 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


import sys
import mari
from dpa.ui.icon.factory import IconFactory
from PySide import QtGui, QtCore
    def __init__(self, name, layout=None, widget=None, palette=None):
        self._name = name

        if not layout:
            layout = QtGui.QHBoxLayout()
        self._layout = layout

        if not widget:
            widget = QtGui.QWidget()
            widget.setLayout(self.layout)
        self._widget = widget

        if not palette:
            palette = mari.palettes.create(name, widget)
        self._palette = palette

        self._palette.show()

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

        # so not sure if this is going to work, yay programming!
        # intercept/adjust some of the arguments

        cmd = kwargs.get('command', 'print "No action defined"')
        label = kwargs.get('label', 'Unknown')
        annotation = kwargs.get('annotation', '')
        image = QtGui.QPixmap()

        for (key, val) in kwargs.iteritems():

# 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/mari/shelf.py
import sys
import mari
from dpa.ui.icon.factory import IconFactory
from PySide import QtGui, QtCore

    def __init__(self, name, layout=None, widget=None, palette=None):
        self._name = name

        if not layout:
            layout = QtGui.QHBoxLayout()
        self._layout = layout

        if not widget:
            widget = QtGui.QWidget()
            widget.setLayout(self.layout)
        self._widget = widget

        if not palette:
            palette = mari.palettes.create(name, widget)
        self._palette = palette

        self._palette.show()

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

        # so not sure if this is going to work, yay programming!
        # intercept/adjust some of the arguments

        cmd = kwargs.get('command', 'print "No action defined"')
        label = kwargs.get('label', 'Unknown')
        annotation = kwargs.get('annotation', '')
        image = QtGui.QPixmap()

        for (key, val) in kwargs.iteritems():

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