
    |~g                         d dl Z d dlZd dlmZ d dlmZmZmZmZm	Z	m
Z
mZmZ d dlmZ er*d dlmZ  G d de      Z G d d	ed
      Z G d de      ZneZ G d d      Zy)    N)gettext)ListTYPE_CHECKINGDictTupleAnyTypeVarTypeOptional)Gio)	TypedDictc                   "    e Zd ZU eed<   eed<   y)
OptionBasetypedefaultN)__name__
__module____qualname__r   __annotations__r        </usr/lib/python3/dist-packages/blueman/plugins/BasePlugin.pyr   r      s    
r   r   c                   6    e Zd ZU eed<   eed<   eeef   ed<   y)OptionnamedescrangeN)r   r   r   strr   r   intr   r   r   r   r      s    		S#Xr   r   F)totalc                   "    e Zd ZU eed<   ded<   y)	GSettingsschemaNpath)r   r   r   r   r   r   r   r   r"   r"      s    
r   r"   c                   d   e Zd ZU g Zee   ed<   g Zee   ed<   dZ e	d      Z
eed<    e	d      Zeed<   dZdZdZd	ed
<   i Zeedf   ed<   deddfdZ edd       Zedee   dee   fd       Zd dZedefd       Zd dZd dZd dZd dZd dZ dede!fdZ"dede!ddfdZ#dede!ddfdZ$y)!
BasePlugin__depends____conflicts__r   Unspecified__description__
__author__TNr"   __gsettings__r   __options___argsreturnc                     | j                   rJt        j                  | j                  j                  d   | j                  j                  d         | _        t        j                  | | j                         y )Nr#   r$   )	schema_idr$   )	r-   r   Settings	__class__r,   _BasePlugin__configweakreffinalize_on_plugin_delete)selfr.   s     r   __init__zBasePlugin.__init__.   sW    LL..66x@^^11&9DM
 	t556r   _T)boundclsc                     | j                   S N)__instance__)r<   s    r   get_instancezBasePlugin.get_instance9   s    r   c                 T    | j                          t        j                  d|         y )NzDeleting plugin instance )	on_deleteloggingdebugr8   s    r   r7   zBasePlugin._on_plugin_delete=   s     1$89r   c                 T    t        d | j                  j                               }d|v S )Nc                     t        |       dkD  S )N   )len)xs    r   <lambda>z,BasePlugin.is_configurable.<locals>.<lambda>C   s    SVaZ r   T)mapr-   values)r<   ress     r   is_configurablezBasePlugin.is_configurableA   s&    (#//*@*@*BCs{r   c                 F    | j                          d | j                  _        y r>   )	on_unloadr3   r?   rE   s    r   _unloadzBasePlugin._unloadF   s    &*#r   c                     	 | j                          | | j                  _        y # t        $ r,}d | j                  _        t	        j
                  |        d }~ww xY wr>   )on_loadr3   r?   	ExceptionrC   	exception)r8   es     r   _loadzBasePlugin._loadK   sI    	LLN*.DNN' 	*.DNN'a 		s   !$ 	A'AAc                      y)zRDo what is necessary for the plugin to work like add watches or create ui elementsNr   rE   s    r   rT   zBasePlugin.on_loadW       r   c                     t         )z8Tear down any watches and ui elements created in on_load)NotImplementedErrorrE   s    r   rQ   zBasePlugin.on_unload[   s    !!r   c                      y)z6Do cleanup that needs to happen when plugin is deletedNr   rE   s    r   rB   zBasePlugin.on_delete_   rZ   r   keyc                 f    || j                   j                  vrt        d      | j                  |   S )NNo such option)r3   r-   KeyErrorr4   )r8   r^   s     r   
get_optionzBasePlugin.get_optionc   s/    dnn000+,,}}S!!r   valuec                    || j                   j                  vrt        d      | j                   j                  |   }t        |      |d   u r"|| j                  |<   | j                  ||       y t        dt        |d                )Nr`   r   zWrong type, must be )r3   r-   ra   r   r4   option_changed	TypeErrorrepr)r8   r^   rc   opts       r   
set_optionzBasePlugin.set_optionh   s    dnn000+,,nn((-;#f+%!&DMM#U+24F3D2EFGGr   c                      y r>   r   )r8   r^   rc   s      r   re   zBasePlugin.option_changeds   s    r   )r/   N)%r   r   r   r'   r   r   r   r(   __priority___r*   r+   __unloadable____autoload__r?   r-   r   objectr9   r	   r:   classmethodr
   r   r@   r7   boolrO   rR   rX   rT   rQ   rB   r   rb   ri   re   r   r   r   r&   r&      s6   Kc!M49!L]+OS+&J&NLL')Kc8m$)7v 7$ 7 
\	*B $r(  x|    :   +
	""c "c "
	Hc 	H# 	H$ 	H# c d r   r&   )rC   r5   r   rl   typingr   r   r   r   r   r	   r
   r   gi.repositoryr   typing_extensionsr   r   r   r"   dictr&   r   r   r   <module>rv      s[        Q Q Q  +Y 5 
I  FW Wr   