3
7ßL]Z  ã               @   st   d Z ddlmZmZmZmZmZmZ ddlm	Z	 ddl
mZ ddlmZ edƒZedƒZedƒZG d	d
„ d
eƒZdS )z: An action manager item that represents an actual action. é    )ÚAnyÚInstanceÚListÚPropertyÚStrÚon_trait_change)ÚAction)ÚActionManagerItem)Útoolkit_objectzaction.action_item:_MenuItemzaction.action_item:_Toolzaction.action_item:_PaletteToolc               @   s|   e Zd ZdZeeƒZeeƒZ	e
Ze
Zee
ƒZdd„ Zdd„ Zdd„ Zedƒd	d
„ ƒZdd„ Zddd„Zddd„Zdd„ ZdS )Ú
ActionItemz: An action manager item that represents an actual action. c             C   s   | j jS )N)ÚactionÚid)Úself© r   ú=/tmp/pip-install-5sebvq2j/pyface/pyface/action/action_item.pyÚ_get_idC   s    zActionItem._get_idc             C   s   || j _d S )N)r   Zenabled)r   Ú
trait_nameÚoldÚnewr   r   r   Ú_enabled_changedH   s    zActionItem._enabled_changedc             C   s   || j _d S )N)r   Zvisible)r   r   r   r   r   r   r   Ú_visible_changedK   s    zActionItem._visible_changedz_wrappers.controlc             C   s    |dkr|dkr| j j|ƒ dS )z( Handle the destruction of the wrapper. ÚcontrolN)Ú	_wrappersÚremove)r   ÚobjectÚnamer   r   r   r   r   Ú_on_destroyN   s    zActionItem._on_destroyc             C   sJ   |dks|j | jƒrFt||| |ƒ}|dkr:|j| _|j| _| jj|ƒ dS )aD   Add the item to a menu.

        Parameters
        ----------
        parent : toolkit control
            The parent of the new menu item control.
        menu : toolkit menu
            The menu to add the action item to.
        controller : ActionController instance or None
            The controller to use.
        N)Zcan_add_to_menur   Ú	_MenuItemr   Ú
control_idr   Úappend)r   ÚparentÚmenuÚ
controllerÚwrapperr   r   r   Úadd_to_menuX   s    zActionItem.add_to_menuTc             C   sN   |dks|j | jƒrJt|||| ||ƒ}|dkr>|j| _|j| _| jj|ƒ dS )aú   Adds the item to a tool bar.

        Parameters
        ----------
        parent : toolkit control
            The parent of the new menu item control.
        tool_bar : toolkit toolbar
            The toolbar to add the action item to.
        image_cache : ImageCache instance
            The image cache for resized images.
        controller : ActionController instance or None
            The controller to use.
        show_labels : bool
            Should the toolbar item show a label.
        N)Zcan_add_to_toolbarr   Ú_Toolr   r   r   r   )r   r    Ztool_barÚimage_cacher"   Úshow_labelsr#   r   r   r   Úadd_to_toolbarn   s    zActionItem.add_to_toolbarc             C   s   t ||| |ƒ}| jj|ƒ dS )a²   Adds the item to a tool palette.

        Parameters
        ----------
        parent : toolkit control
            The parent of the new menu item control.
        tool_palette : toolkit tool palette
            The tool palette to add the action item to.
        image_cache : ImageCache instance
            The image cache for resized images.
        show_labels : bool
            Should the toolbar item show a label.
        N)Ú_PaletteToolr   r   )r   Ztool_paletter&   r'   r#   r   r   r   Úadd_to_palette‹   s    zActionItem.add_to_palettec             C   s   | j jƒ  dS )z} Called when the action is no longer required.

        By default this method calls 'destroy' on the action itself.
        N)r   Údestroy)r   r   r   r   r+   œ   s    zActionItem.destroyN)T)T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r$   r(   r*   r+   r   r   r   r   r      s   


r   N)r/   Z
traits.apir   r   r   r   r   r   Zpyface.action.actionr   Z!pyface.action.action_manager_itemr	   Zpyface.toolkitr
   r   r%   r)   r   r   r   r   r   Ú<module>   s    