B
    h                 @   s  d dl mZ d dl mZ d dl mZ dgZd dlZd dl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 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 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 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  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% 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* d d$lm+Z+ G d%d de,Z-dS )&    )absolute_import)print_function)unicode_literalsToastNotifierN)path)sleep)Requirement)resource_filename)GetModuleHandle)PostQuitMessage)CW_USEDEFAULT)IDI_APPLICATION)
IMAGE_ICON)LR_DEFAULTSIZE)LR_LOADFROMFILE)
WM_DESTROY)WM_USER)WS_OVERLAPPED)
WS_SYSMENU)CreateWindow)DestroyWindow)LoadIcon)	LoadImage)NIF_ICON)NIF_INFO)NIF_MESSAGE)NIF_TIP)NIM_ADD)
NIM_DELETE)
NIM_MODIFY)RegisterClass)UnregisterClass)Shell_NotifyIcon)UpdateWindow)WNDCLASSc               @   s:   e Zd ZdZdd Zdd ZdddZdd Zdd ZdS )r   zvCreate a Windows 10  toast notification.

    from: https://github.com/jithurjacob/Windows-10-Toast-Notifications
    c             C   s
   d| _ dS )zInitialize.N)_thread)self r'   PC:\Users\sanjo\AppData\Local\Qlobot\Launcher\ext_packages\win10toast\__init__.py__init__:   s    zToastNotifier.__init__c             C   s  t | ji}t | _td | _| j_td| j_|| j_	yt
| j| _W n   Y nX ttB }t| jd|ddttdd| jd| _t| j |dk	rt|}nttdd}ttB }yt| j|tdd|}W n@ tk
r }	 z td||	 tdt }W dd}	~	X Y nX t!t"B t#B }
| jd|
t$d |d	f}t%t&| t%t'| jdt(t$d |d
|d|f	 t)| t*| j t+| jjd dS )zNotification settings.

        :title: notification title
        :msg: notification message
        :icon_path: path to the .ico file to custom notification
        :duration: delay in seconds before notification self-destruction
        NZPythonTaskbarZTaskbarr   
win10toastzwin10toast/data/python.icoz#Some trouble with the icon ({}): {}   ZTooltipzBalloon Tooltip   ),r   
on_destroyr$   Zwcr
   ZhinstZ	hInstancestrZlpszClassNameZlpfnWndProcr    Z	classAtomr   r   r   r   hwndr#   r   realpathr	   r   parser   r   r   r   	Exceptionloggingerrorformatr   r   r   r   r   r   r"   r   r   r   r   r   r!   )r&   titlemsg	icon_pathdurationZmessage_mapstyleZ
icon_flagsZhiconeflagsnidr'   r'   r(   _show_toast>   sJ    	





zToastNotifier._show_toastNotificationHere comes the messageN   Fc             C   sJ   |s|  |||| n0|  r"dS tj| j ||||fd| _| j  dS )zNotification settings.

        :title: notification title
        :msg: notification message
        :icon_path: path to the .ico file to custom notification
        :duration: delay in seconds before notification self-destruction
        F)targetargsT)r>   notification_active	threadingThreadr%   start)r&   r6   r7   r8   r9   threadedr'   r'   r(   
show_toastu   s    	
zToastNotifier.show_toastc             C   s   | j dkr| j  rdS dS )z-See if we have an active notification showingNTF)r%   is_alive)r&   r'   r'   r(   rD      s    z!ToastNotifier.notification_activec             C   s    | j df}tt| td dS )zhClean after notification ended.

        :hwnd:
        :msg:
        :wparam:
        :lparam:
        r   N)r/   r"   r   r   )r&   r/   r7   ZwparamZlparamr=   r'   r'   r(   r-      s    

zToastNotifier.on_destroy)r?   r@   NrA   F)	__name__
__module____qualname____doc__r)   r>   rI   rD   r-   r'   r'   r'   r(   r   4   s   7 
).
__future__r   r   r   __all__r3   rE   osr   timer   Zpkg_resourcesr   r	   Zwin32apir
   r   Zwin32conr   r   r   r   r   r   r   r   r   Zwin32guir   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   objectr   r'   r'   r'   r(   <module>   sJ   