o
    œh  ã                   @   sF   d Z ddlZddlZddlZddlZejdedd� G dd„ dƒZdS )zAGUI support for the IPython ZeroMQ kernel - GTK toolkit support.
é    Nz/The Gtk3 event loop for ipykernel is deprecatedé   )ÚcategoryÚ
stacklevelc                   @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )ÚGTKEmbedz7A class to embed a kernel into the GTK main event loop.c                 C   s   || _ d| _d| _dS )zInitialize the embed.N)ÚkernelÚgtk_mainÚgtk_main_quit)Úselfr   © r
   úLc:\Users\shubh\Videos\agent\nova\Lib\site-packages\ipykernel/gui/gtkembed.pyÚ__init__!   s   
zGTKEmbed.__init__c                 C   s   t  | j¡ t ¡  dS )zCStarts the GTK main event loop and sets our kernel startup routine.N)ÚgobjectZidle_addÚ_wire_kernelÚgtkÚmain©r	   r
   r
   r   Ústart(   s   zGTKEmbed.startc                 C   s.   |   ¡ \| _| _t td| jj ƒ| j¡ dS )z·Initializes the kernel inside GTK.

        This is meant to run only once at startup, so it does its job and
        returns False to ensure it doesn't get run again by GTK.
        iè  F)	Ú_hijack_gtkr   r   r   Ztimeout_addÚintr   Z_poll_intervalÚiterate_kernelr   r
   r
   r   r   .   s   zGTKEmbed._wire_kernelc                 C   s   | j  ¡  dS )zÑRun one iteration of the kernel and return True.

        GTK timer functions must return True to be called again, so we make the
        call to :meth:`do_one_iteration` and then return True for GTK.
        T)r   Zdo_one_iterationr   r
   r
   r   r   8   s   
zGTKEmbed.iterate_kernelc                 C   s   | j r|   ¡  t ¡  dS )zStop the embed.N)r   ÚsysÚexitr   r
   r
   r   ÚstopA   s   zGTKEmbed.stopc                 C   s,   dd„ }t j|}t _t j|}t _||fS )aÃ  Hijack a few key functions in GTK for IPython integration.

        Modifies pyGTK's main and main_quit with a dummy so user code does not
        block IPython.  This allows us to use %run to run arbitrary pygtk
        scripts from a long-lived IPython session, and when they attempt to
        start or stop

        Returns
        -------
        The original functions that have been hijacked:
        - gtk.main
        - gtk.main_quit
        c                  _   s   dS )zNo-op.Nr
   )ÚargsÚkwr
   r
   r   ÚdummyY   s    z#GTKEmbed._hijack_gtk.<locals>.dummy)r   r   Z	main_quit)r	   r   Z	orig_mainZorig_main_quitr
   r
   r   r   J   s   zGTKEmbed._hijack_gtkN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r
   r
   r
   r   r      s    
		r   )r   r   Úwarningsr   r   ÚwarnÚDeprecationWarningr   r
   r
   r
   r   Ú<module>   s    ÿ	