o
    \cj	                     @   s   d dl 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mZmZ d dlmZ d dlmZ G d	d
 d
eZdS )    )gettext)AnyDictUnion)Device)Battery)Manager)Notification_NotificationBubble_NotificationDialog)AppletPlugin)GLibc                
   @   s   e Zd ZU dZdZedZdZi Ze	e
eeef f ed< dddZdd	d
Zde
de
deddfddZdede
ddfddZdede
dede
ddf
ddZdS )ConnectionNotifiercschrammzbluetooth-symboliczGShows desktop notifications when devices get connected or disconnected.N_notificationsreturnc                 C   s   t  | _| jd| j| _d S )Nzbattery-created)r   _managerconnect_signal_on_battery_created_sigself r   K/usr/lib/python3/dist-packages/blueman/plugins/applet/ConnectionNotifier.pyon_load   s   zConnectionNotifier.on_loadc                 C   s    | j d ur| j| j  d S d S )N)r   r   disconnect_signalr   r   r   r   	on_unload   s   
zConnectionNotifier.on_unloadpathkeyvaluec                    s   t |d}t|d |dkrP|r?t|d td|d d | j|< }|   d| jdtf fdd	}t	
d
| d S t|d td|d d  d S d S )Nobj_path	ConnectedAliasIcon)	icon_namezproperty-changedr   c                      s      dS )NF)r   r   batterysigr   r   r   +   s   
zHConnectionNotifier.on_device_property_changed.<locals>.disconnect_signal   Disconnected)r   r   r	   _r   showr   _on_battery_property_changedboolr   timeout_add_seconds)r   r   r   r   devicenotificationr   r   r&   r   on_device_property_changed   s   

"z-ConnectionNotifier.on_device_property_changedr   r!   c                 C   s"   t |d}| |d|d | d S )Nr    
Percentage)r   r-   )r   r   r!   r'   r   r   r   r   2   s   
z&ConnectionNotifier._on_battery_created_batteryc                 C   sF   |dkr| j | }|r!|td d| d |d d S d S d S )Nr3   r"    %r'   )r   set_messager+   set_notification_icon)r   r4   r   r   r   r1   r   r   r   r-   6   s   
z/ConnectionNotifier._on_battery_property_changed)r   N)__name__
__module____qualname__
__author____icon__r+   __description__r   r   r   strr   r
   r   __annotations__r   r   r   r2   r   r   r   r-   r   r   r   r   r      s   
 

"r   N)r   r+   typingr   r   r   blueman.bluez.Devicer   blueman.bluez.Batteryr   blueman.bluez.Managerr   blueman.gui.Notificationr	   r
   r   blueman.plugins.AppletPluginr   gi.repositoryr   r   r   r   r   r   <module>   s    