o
    \c                     @   s   d dl m Z d dlmZmZmZ d dlmZmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d dlmZ G d	d
 d
ZG dd dZG dd dZG dd deejZdS )    )gettext)OptionalTupleList)GObjectGLibGio)launch)Config)PluginManager)AppletPlugin)GSignalsc                   @   s"   e Zd Zdeeef fddZdS ) StatusIconImplementationProviderreturnc                 C      d S N selfr   r   C/usr/lib/python3/dist-packages/blueman/plugins/applet/StatusIcon.py#on_query_status_icon_implementation      zDStatusIconImplementationProvider.on_query_status_icon_implementationN)__name__
__module____qualname__r   strintr   r   r   r   r   r      s    r   c                   @   s   e Zd ZdefddZdS )StatusIconVisibilityHandlerr   c                 C   r   r   r   r   r   r   r   %on_query_force_status_icon_visibility   r   zAStatusIconVisibilityHandler.on_query_force_status_icon_visibilityN)r   r   r   boolr   r   r   r   r   r      s    r   c                   @   s   e Zd Zdee fddZdS )StatusIconProviderr   c                 C   r   r   r   r   r   r   r   on_status_icon_query_icon   r   z,StatusIconProvider.on_status_icon_query_iconN)r   r   r   r   r   r!   r   r   r   r   r       s    r    c                   @   s>  e Zd ZU dejjddfiZeed< dZ	dZ
dgZdZdZdZd1d	d
Zd2dededdfddZdefddZdededdfddZdeddfddZdee ddfddZdejdeddfddZd1dd Zd!eddfd"d#Zd!eddfd$d%Zd&eddfd'd(Zd)ed*eddfd+d,Z de!e fd-d.Z"defd/d0Z#dS )3
StatusIconactivateNr   __gsignals__Fzbluetooth-symbolicMenur   c                    s  t j   td _d _td _ jd j  j	dd  j
jd j  j
jd j  d	d
d fdd  dd  dd  dd  dd
d fdd  dd
d fdd  dd  dd
d j  dd
d j  dd
d fdd d S )NzBluetooth Enabled zorg.blueman.generalzchanged::symbolic-status-iconsFemitzplugin-loadedzplugin-unloadedGetVisibilityr   bc                          j S r   )visibler   r   r   r   <lambda>6       z$StatusIcon.on_load.<locals>.<lambda>VisibilityChangedToolTipTitleChangedsToolTipTextChangedGetToolTipTitlec                      r+   r   )_tooltip_titler   r   r   r   r-   :   r.   GetToolTipTextc                      r+   r   )_tooltip_textr   r   r   r   r-   ;   r.   IconNameChangedGetStatusIconImplementationsasGetIconNameActivatec                      s
     dS )Nr#   r'   r   r   r   r   r-   ?   s   
 )r   __init___r4   r6   r
   general_configconnecton_symbolic_config_changequery_visibilityparentPlugins_on_plugins_changed_add_dbus_method_add_dbus_signal _get_status_icon_implementations_get_icon_namer   r   r   r   on_load)   s$   

zStatusIcon.on_loadTdelay_hidingr(   c                 C   sj   | j j stdd | j jtD r| d| d S | js3|r+t	
d| j| _d S | d| d S d S )Nc                 s       | ]}|  V  qd S r   )r   .0pluginr   r   r   	<genexpr>C       z.StatusIcon.query_visibility.<locals>.<genexpr>Ti	  F)rB   Managerget_adaptersanyrC   get_loaded_pluginsr   set_visiblevisibility_timeoutr   timeout_addon_visibility_timeout)r   rJ   r(   r   r   r   rA   A   s   zStatusIcon.query_visibilityc                 C   s,   | j d usJ t| j  d | _ |   dS )NF)rV   r   source_removerA   r   r   r   r   rX   L   s
   z StatusIcon.on_visibility_timeoutr,   c                 C   s   || _ |r| d| d S d S )Nr/   )r,   _emit_dbus_signal)r   r,   r(   r   r   r   rU   S   s   zStatusIcon.set_visibletitlec                 C   s   || _ | d| d S )Nr0   )r4   rZ   )r   r[   r   r   r   set_tooltip_titleX   s   zStatusIcon.set_tooltip_titletextc                 C   s$   |d u rdn|| _ | d| j  d S )Nr&   r2   )r6   rZ   )r   r]   r   r   r   set_tooltip_text\   s   zStatusIcon.set_tooltip_textsettingskeyc                 C      |    d S r   )icon_should_change)r   r_   r`   r   r   r   r@   `      z$StatusIcon.on_symbolic_config_changec                 C   s   |  d|   |   d S )Nr7   )rZ   rH   rA   r   r   r   r   rb   c   s   zStatusIcon.icon_should_change_pathc                 C   ra   r   rA   r   rd   r   r   r   on_adapter_addedg   rc   zStatusIcon.on_adapter_addedc                 C   ra   r   re   rf   r   r   r   on_adapter_removedj   rc   zStatusIcon.on_adapter_removedstatec                 C   s"   |    |rtdddd d S d S Nblueman-traybluemanF)	icon_namesn)rA   r	   )r   ri   r   r   r   on_manager_state_changedm   s   z#StatusIcon.on_manager_state_changed_plugins_namec                 C   s<   |   }| jr| j|kr|| _| jjrtdddd d S d S rj   )rG   _implementationsrB   manager_stater	   )r   rp   rq   implementationsr   r   r   rD   r   s   zStatusIcon._on_plugins_changedc                 C   s6   dd t dd | jjtD dd ddD d	g S )
Nc                 S   s   g | ]\}}|qS r   r   )rM   implementationr=   r   r   r   
<listcomp>{   s    z?StatusIcon._get_status_icon_implementations.<locals>.<listcomp>c                 s   rK   r   )r   rL   r   r   r   rO   |   rP   z>StatusIcon._get_status_icon_implementations.<locals>.<genexpr>c                 S   s   | d S )N   r   )implementation_priorityr   r   r   r-   ~   s    z=StatusIcon._get_status_icon_implementations.<locals>.<lambda>T)r`   reverseGtkStatusIcon)sortedrB   rC   rT   r   r   r   r   r   rG   z   s   z+StatusIcon._get_status_icon_implementationsc                 C   sR   d}| j jtD ]}| }|d ur|}q	|dd}| jdr'| d}|S )Nrk   z	-symbolicr&   zsymbolic-status-icons)rB   rC   rT   r    r!   replacer>   get_boolean)r   namerN   iconr   r   r   rH      s   
zStatusIcon._get_icon_name)r   N)FT)$r   r   r   r   SignalFlagsNO_HOOKSr$   r   __annotations____unloadable____icon____depends__r,   rV   rr   rI   r   rA   rX   rU   r   r\   r   r^   r   Settingsr@   rb   rg   rh   ro   r   rD   r   rG   rH   r   r   r   r   r"      s,   
 

r"   N)r   r=   typingr   r   r   gi.repositoryr   r   r   blueman.Functionsr	   blueman.main.Configr
   blueman.main.PluginManagerr   blueman.plugins.AppletPluginr   blueman.bluemantypingr   r   r   r    r"   r   r   r   r   <module>   s    