
    Jelm                        d Z ddlZddlZddlmZ ddlZddlZddlmZ	 ddl
Z
ddlZddlZddlmZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZmZ ddlmZmZm Z m!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 dd	l1m2Z2 dd
l3m4Z4 ddl5m6Z6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZAmBZB ddlCmDZD ej                  dk(  r e2       sddlFZG ej                  eI      ZJdZKd ZLdEdZMd ZNdFdZOd ZPdaQd ZRd ZSd ZTd ZUdGdZVd ZWd ZXd ZY	 	 	 	 	 dHd!ZZdId"Z[	 	 dJd#Z\d$ Z]dddddddej                  dddddd d fd%Z_d& Z`d' Zad( Zbd) ZcdGd*Zdd+ Zed, ZfdKd-Zgd. ZhdKd/Zig fd0Zj G d1 d2e      Zkd3 Zl G d4 d5e#      Zm G d6 d7e0      Znd8 Zod9 ZpdGd:Zqd; Zr G d< d=e+      Zs G d> d?e%      Zt G d@ dAe$      ZudB Zv	 	 dLdCZweIdDk(  r eo        yy)MzQt utilities.    N)pi)unquote)from_qvariantto_qvariant)
QEventQLibraryInfoQLocaleQObjectQtQTimerQTranslatorQUrlSignalSlot)QDesktopServices	QKeyEventQKeySequenceQPixmap)QActionQApplicationQDialogQHBoxLayoutQLabel	QLineEditQMenuQPlainTextEditQProxyStyleQPushButtonQStyleQToolButtonQVBoxLayoutQWidget)running_in_mac_app)CONF)is_text_stringto_text_string)ima)programs)get_image_path)QStylePalette)ACTION_REGISTRYTOOLBUTTON_REGISTRY)QWaitingSpinnerdarwinc                 b    t               }|j                  |        t        j                  |      S )z
    Generalized os.startfile for all platforms supported by Qt

    This function is simply wrapping QDesktopServices.openUrl

    Returns True if successful, otherwise returns False.
    )r   setUrlr   openUrl)filenameurls     8/usr/lib/python3/dist-packages/spyder/utils/qthelpers.py
start_filer5   =   s(     &CJJx##C((    c                 b    t               }|j                  t        t        | |                   |S )z#Return image inside a QLabel object)r   	setPixmapr   r)   )namedefaultlabels      r4   get_image_labelr<   O   s&    HE	OOGN49:;Lr6   c                      t        j                         } | j                  | j                  } | j                  | j                  j                  S )z+Return the filename at the top of the stack)sys	_getframef_backf_codeco_filename)fs    r4   get_origin_filenamerD   V   s>     	A
((
HH ((
88r6   c                    t         j                  dk(  rt        }nt        }|j	                         }| |ddg      }|j                  d       t         j                  dk(  r+t               s!t        j                  ddd      r
t                | rt        |       t        j                  j                  dd      }|Dt        |      }|j                  j                  |j                          |j#                  |d	z         |S )
z
    Return QApplication instance
    Creates it if it doesn't already exist

    test_time: Time to maintain open the application when testing. It's given
    in seconds
    r.   NSpyderz--no-sandboxmainmac_open_fileFTEST_CI_WIDGETSi  )r>   platformMacApplicationr   instancesetApplicationNamer#   r$   getregister_app_launchservicesinstall_translatorosenvironr   timeoutconnectquitstart)	translate	test_timeSpyderApplicationapptest_citimer_shutdowns         r4   qapplicationr]   _   s     ||x*(

$
$
&C
{  > :; 	x( &(%8#%3jjnn.5G&&sxx0Y-.Jr6   c                 r    t         j                  dk(  r t        j                  d|       rd| z   S d| z   S d| z   S )zBSelect the right file uri scheme according to the operating systemntz
^[a-zA-Z]:file:///file://)rQ   r9   research)fnames    r4   file_urire      s>    	ww$99]E*%% u$$5  r6   c                    t         bt               }|j                  dt        j                         j                         z   t        j                  t        j                              r|a t         | j                  t                yy)z2Install Qt translator to the QApplication instanceNqt_)
QT_TRANSLATORr   loadr	   systemr9   r   locationTranslationsPathinstallTranslator)qappqt_translators     r4   rP   rP      sl     #(--//%%l&C&CDF *M }- !r6   c                 n    t        t        |       }t        t        j                  |      d   t              S )zReturn keybindingr   )getattrr   r   keyBindingsstr)attrkss     r4   
keybindingrv      s+    	t	$B11"5a8#>>r6   c                    	 t        | j                         | j                         z        j                         S # t        $ r | j                         }| j                         t
        j                  z  }| j                         t
        j                  z  }| j                         t
        j                  z  }| j                         t
        j                  z  }|}|r|t
        j                  z  }|r|t
        j                  z  }|r|t
        j                  z  }|r|t
        j                  z  }t        |      j                         cY S w xY w)z:Get key sequence corresponding to a key event as a string.)r   	modifierskeytoString	TypeErrorr   AltModifierShiftModifierControlModifierMetaModifierCTRLSHIFTALTMETA)eventry   altshiftctrlmetakey_sequences          r4   keyevent_to_keysequence_strr      s    5EOO-		;<EEGG 5
 iikoo"..0!B$4$44 2#5#55 2??2BGG#LBHH$LBFF"LBGG#LL)2244+5s   7: DE
	E
c                 8   | j                  d      r5t        j                  dk(  r| j                  d      r| dd  } n| dd  } n| dd  } | j                  dt        j                        } t        j                  |       r|t        j                  |       d   |v r| S y y )	Nra   r_   r`            \   )
startswithrQ   r9   replacesepospexistssplitext)pathextlists     r4   _process_mime_pathr      s    z"77d? {+ABxABx8D<<bff%D
zz$?cll403w>K ? r6   c           	         g }| j                         rV| j                         D ]B  }t        t        t	        |j                                     |      }|2|j                  |       D n\| j                         rLt	        | j                               j                         D ]"  }t        ||      }||j                  |       $ |r|S y)zR
    Extract url list from MIME data
    extlist: for example ('.py', '.pyw')
    N)
hasUrlsurlsr   r   r&   rz   appendhasTexttext
splitlines)sourcer   pathlistr3   r   rawpaths         r4   mimedata2urlr      s    
 H~~;;= 	&C%s||~67BD%		&
 
	%fkkm4??A 	&G%gw7D%	&  r6   c                     | j                         | j                         | j                         | j                         | j	                         | j                         fS )z'Convert QKeyEvent instance into a tuple)typery   rx   r   isAutoRepeatcount)r   s    r4   keyevent2tupler      sB    JJL%))+u'8%**, %++-1 1r6   c                     t        |  S )z'Convert tuple into a QKeyEvent instance)r   )
past_events    r4   tuple2keyeventr      s    j!!r6   c                    t        | t              r| \  }}}}}}t        |       } n0| j                         }| j	                         }| j                         }|t        j                  z  }|t        j                  z  }| ||||fS N)	
isinstancetupler   r   rx   ry   r   r~   r}   )r   _ry   rx   r   r   r   s          r4   restore_keyeventr      s{    %(-%3	4Au%zz|OO%	iikr)))D(((E$T5((r6   Fc                    t        |       }||j                  |       |1t        |      rt        j                  |      }|j                  |       |||j                  ||n|       |r|j                  t        j                         |j                  |       ||j                  j                  |       |t        |||	|
       ||j                  |       |||_        |rt!        j"                  ||||       |S )zCreate a QToolButton)r    setTextr%   r'   get_iconsetIcon
setToolTipsetToolButtonStyler   ToolButtonTextBesideIconsetAutoRaiseclickedrT   setup_toggled_actionsetShortcutIDr,   register_reference)parentr   shortcuticontiptoggled	triggered	autoraisetext_beside_iconsectionoptionid_plugincontext_nameregister_toolbuttonbuttons                   r4   create_toolbuttonr     s      Ft$<<%Dt3?#+$37!!""="=>
	"y)VWgv>8$
	..C	/Mr6   c                 T   d}t         | z  ||z  z
  |t         z   z  }| d|z  z
  dz  }t        |d      }|j                  d       |j                  |       |j	                  |       |j                  |       |j                  |       |j                  t        j                         |S )zS
    Create a wait spinner with the specified size built with n circling dots.
    r      F)centerOnParentT)
r   r-   setTrailSizeDecreasingsetNumberOfLinessetLineLengthsetLineWidthsetInnerRadiussetColorr*   COLOR_TEXT_1)sizenr   dot_paddingdot_sizeinner_radiusspinners          r4   create_waitspinnerr   %  s     K T	AO+B7H1x<'1,LfU;G""4(Q(#"<(]//0Nr6   c                     || j                         }t        |      }|j                  |        |j                  |       |r|j	                  t
        j                         |r| j                  |       |S )z3Create a QToolButton directly from a QAction object)r   r    setDefaultActionr   r   r   r   r   )actionr   r   r   r   r   s         r4   action2buttonr   =  se     ~ F
F#
	"!!""="=>tMr6   c                 @    | | D ]  }||j                  |        yy)zEnable/disable actionsN)
setEnabled)actionsenabler   s      r4   toggle_actionsr   L  s0     	*F!!!&)	* r6   c                    t        || |      }||j                  j                  |       |t        ||||
       |1t	        |      rt        j                  |      }|j                  |       |"|j                  |       |j                  |       ||j                  t        |             ||j                  |       t        j                  dk(  rQd|_        |	t         j"                  k(  r|||_        nQd|_        nI||j%                  |       |j'                  |	       n$||j%                  |       |j'                  |	       |rt)        j*                  |||||       |S )zCreate a QAction	action_idNr.   missing)SpyderActionr   rT   r   r%   r'   r   r   r   setStatusTipsetDatar   setMenuRoler>   rJ   _shown_shortcutr   WidgetShortcutr   setShortcutContextr+   r   )r   r   r   r   r   r   r   datamenurolecontextr   r   r   r   r   register_action	overwriter   s                     r4   create_actionr   T  sU    $#6F  +VWgv>$<<%Dt
#C {4()8$ ||x!%b'''#)1& *3&#""8,%%g.x(!!'***Cy	:Mr6   c                     t        |||      }| j                  j                  |       | j                  d       |&|#t	        j
                  | ||       t        |        yyy)z]
    Setup a checkable action and wrap the toggle function to receive
    configuration.
    TN)wrap_toggledr   rT   setCheckabler$   observe_configurationadd_configuration_update)r   r   r   r   s       r4   r   r     s_    
 7GV4G
NN7#
v1""67F; (  2r6   c                 V     #!t        j                          fd       }|S  S )z@Wrap a toggle function to set a value on a configuration option.c                 H    t        j                  | d        |        y )NT)recursive_notification)r$   set)valuer   r   r   s    r4   wrapped_toggledz%wrap_toggled.<locals>.wrapped_toggled  s    HHWfeDIENr6   )	functoolswraps)r   r   r   r  s   ``` r4   r   r     s6    v1		!	 
"	 Nr6   c                 P    d }t        j                  ||       }t        | d|       y)zCAdd on_configuration_change to a SpyderAction that depends on CONF.c                 j    | j                  d       | j                  |       | j                  d       y NTF)blockSignals
setChecked)self_option_sectionr  s       r4   on_configuration_changez9add_configuration_update.<locals>.on_configuration_change  s*    $% r6   r  N)types
MethodTypesetattr)r   r  methods      r4   r   r     s)    ! 5v>FF-v6r6   c                 |   t        | d      s| j                         | _        	 t        j                  ||      }|rVt        |      }|j                  t        j                        }| j                  dj                  | j                  |             yy# t
        j                  t
        j                  f$ r d}Y w xY w)z>Add the shortcut associated with a given action to its tooltip_tooltip_backup)r   r9   Nz	{0} ({1}))hasattrtoolTipr  r$   get_shortcutconfigparserNoSectionErrorNoOptionErrorr   rz   
NativeTextr   format)r   r   r9   r   keyseqstrings         r4   add_shortcut_to_tooltipr!    s    6,-
 "(!1$$W4@ h'!8!89,--f.D.DfMN	  '')C)CD s   B %B;:B;c                    d}t        | j                               }|r|d   }|j                         rd}|D ]  }|'|%|| j                          n| j	                  |       nnt        |t              r'|| j                  |       nJ| j                  ||       n7t        |t              r'|	 | j                  |       n| j                  ||       |} y# t        $ r Y w xY w)z%Add actions to a QMenu or a QToolBar.N)listr   isSeparatoraddSeparatorinsertSeparatorr   r   addMenu
insertMenur   	addActionRuntimeErrorinsertAction)targetr   insert_beforeprevious_actiontarget_actionsr   s         r4   add_actionsr1    s    O&..*+N(,&&("O !N!<$##%&&}5&$v&!!-8($$$V, ##M6: -!$ $ s   -C	C"!C"c                 ^    t        | j                  dt        j                        t              S )z$Get QTreeWidgetItem user role stringr   )r   r   r   UserRoler&   )items    r4   get_item_user_textr5    s    1bkk2NCCr6   c                 X    | j                  dt        j                  t        |             y)z$Set QTreeWidgetItem user role stringr   N)r   r   r3  r   )r4  r   s     r4   set_item_user_textr7    s    LLBKKT!23r6   c                 H    t               fd       }t        | ||||      S )zCreate bookmark actionc                      t               S r   )r5   )r3   s   r4   open_urlz(create_bookmark_action.<locals>.open_url  s    #r6   )r   r   r   )r   r   )r   r3   titler   r   r:  s    `    r4   create_bookmark_actionr<    s3     
V  &%($,. .r6   c                     g }|D ]E  \  }}}d}|dk(  rt        j                  |      sd}|s(t        | ||      }|j                  |       G |S )zt
    Create bookmark actions depending on module installation:
    bookmarks = ((module_name, url, title), ...)
    T	winpythonF)r(   is_module_installedr<  r   )r   	bookmarksr   ry   r3   r;  
create_actacts           r4   create_module_bookmark_actionsrC    sd    
 G$ 	 S% 
+//4"
(e<CNN3	  Nr6   c                     t        |      rt        j                  |      }t        j                  dk(  r||t        j                        }|t        | ||fd      S y)zCreate action to run a programr_   Nc                  .    t        j                         S r   )r(   run_program)r9   s   r4   <lambda>z'create_program_action.<locals>.<lambda>  s    x/C/CD/I r6   r   r   )r%   r'   r   rQ   r9   r(   find_programr   )r   r   r9   r   nt_namer   s     `   r4   create_program_actionrK    sa    d||D!	ww$7.  &DVT'IK 	K r6   c                     t        |      rt        j                  |      }t        j                        rt        | ||fd      S y)z.Create action to run a GUI based Python scriptc                  2    t        j                         S r   )r(   run_python_script)argsmodulepackages   r4   rG  z-create_python_script_action.<locals>.<lambda>  s    %77N r6   rH  N)r%   r'   r   r(   python_script_existsr   )r   r   r   rQ  rP  rO  s      ```r4   create_python_script_actionrS    sI    d||D!$$Wf5VT(OP 	P 6r6   c                   (    e Zd ZdZd Zd Zd Zd Zy)DialogManagerz
    Object that keep references to non-modal dialog boxes for another QObject,
    typically a QMainWindow or any kind of QWidget
    c                 <    t        j                  |        i | _        y r   )r
   __init__dialogsr  s    r4   rW  zDialogManager.__init__#  s    r6   c                     t         j                  j                               D ]W  }t        |j	                               t        |j	                               k(  s7|j                          |j                           y |j                          | j                  t        |      <   |j                  j                  t        |      f fd	       |j                  j                  t        |      f fd	       y)zYGeneric method to show a non-modal dialog and keep reference
        to the Qt C++ objectc                 &    j                  |       S r   dialog_finishedeidr  s    r4   rG  z$DialogManager.show.<locals>.<lambda>4      t';';C'@ r6   c                 &    j                  |       S r   r\  r^  s    r4   rG  z$DialogManager.show.<locals>.<lambda>6  r`  r6   N)r$  rX  valuesr&   windowTitleshowraise_idacceptedrT   rejected)r  dialogdlgs   `  r4   rd  zDialogManager.show'  s     ++-. 	BCcoo/0 !3!3!567


	B KKM'-DLLF$OO##f:@BOO##f:@Br6   c                 8    | j                   j                  |      S )zManage non-modal dialog boxes)rX  pop)r  	dialog_ids     r4   r]  zDialogManager.dialog_finished8  s    ||	**r6   c                 t    t        | j                  j                               D ]  }|j                           y)zClose all opened dialog boxesN)r$  rX  rb  reject)r  rj  s     r4   	close_allzDialogManager.close_all<  s,    ++-. 	CJJL	r6   N)__name__
__module____qualname____doc__rW  rd  r]  rp   r6   r4   rU  rU    s    
B"+r6   rU  c                     t        j                  |       d   }|j                  d      r|dd }t        j                  d|z  t        j
                  d            S )zReturn file type iconr   .Nz%s.pngFileIcon)r   r   r   r'   r   r   )rd   exts     r4   get_filetype_iconrz  B  sJ    
,,u
a
 C
~~c!"g<<3(<==r6   c                   4     e Zd ZdZdd fd
Zd Zd Z xZS )r   >Spyder QAction class wrapper to handle cross platform patches.Nr   c                    t        t        | 
  |i | || _        t        j
                  dk(  r| j                  d       yy)r|  r.   FN)superr   rW  r   r>   rJ   setIconVisibleInMenu)r  r   rO  kwargs	__class__s       r4   rW  zSpyderAction.__init__M  s=    lD*D;F;"<<8#%%e, $r6   c                 @    dj                  | j                               S NzSpyderAction('{0}')r  r   rY  s    r4   __str__zSpyderAction.__str__T      $++DIIK88r6   c                 @    dj                  | j                               S r  r  rY  s    r4   __repr__zSpyderAction.__repr__W  r  r6   )rq  rr  rs  rt  rW  r  r  __classcell__r  s   @r4   r   r   J  s    H(, -99r6   r   c                       e Zd ZdZd Zy)ShowStdIconsz'
    Dialog showing standard icons
    c           	         t        j                  | |       t               }d}d}t        t              D ]  }|j                  d      s|dk(  r
t               }t               }t        j                  |      }t               }	|	j                  |j                  dd             |j                  |	       |j                  t        |j                  dd                   j                  |       |dz   |z  }|dk(  s|j                  |        | j!                  |       | j#                  d       | j%                  t        j                  d             y )	N   r   SP_     r   zStandard Platform IconsTitleBarMenuButton)r"   rW  r   dirr   r   r!   r'   get_std_iconr   r8   pixmap	addWidgetr   r   	addLayout	setLayoutsetWindowTitlesetWindowIcon)
r  r   layoutrow_nbcindexchild
col_layouticon_layoutr   r;   s
             r4   rW  zShowStdIcons.__init__`  s   v&[ 	1E&Q;!,J)m''.B 34%%e,%%ieR0H&IJ$$[1 1*.Q;$$Z0	1 	v563++,@ABr6   N)rq  rr  rs  rt  rW  ru  r6   r4   r  r  [  s    Cr6   r  c                      t               } t        d      }|j                          t        j                  | j                                y)z!
    Show all standard Icons
    N)r]   r  rd  r>   exitexec_)rZ   ri  s     r4   show_std_iconsr  x  s0     .C$F
KKMHHSYY[r6   c           
         dddddddddd	}t               j                         j                  d	      }t        j                  d
|}||v r:||   \  }}| j                         j                         }||z
  |z   }t        |d      S y)a  
    Return a spacing (int) or None if we don't have the appropriate metrics
    to calculate the spacing.

    We're trying to adapt the spacing below the tools_layout spacing so that
    the main_widget has the same vertical position as the editor widgets
    (which have tabs above).

    The required spacing is

        spacing = tabbar_height - tools_height + offset

    where the tabbar_heights were empirically determined for a combination of
    operating systems and styles. Offsets were manually adjusted, so that the
    heights of main_widgets and editor widgets match. This is probably
    caused by a still not understood element of the layout and style metrics.
    )r  r   )      )   r   )   r#  )&   )   r   )   r   )	z	nt.fusionznt.windowsvistaznt.windowsxpz
nt.windowszposix.breezezposix.oxygenzposix.qtcurvezposix.windowszposix.fusionr9   rw  r   N)r]   stylepropertyrQ   r9   sizeHintheightmax)tools_layoutmetrics
style_namery   tabbar_heightoffsettools_heightspacings           r4   calc_tools_spacingr    s    & "    
G %%'008JWWj
)C
g~ 'v#,,.557,.77A	 r6   c                     t               }|j                  dddd       t        |       }||j                  |       |j	                  |        ||j                  |       |S )a  
    Returns a layout for a set of controls above a main widget. This is a
    standard layout for many plugin panes (even though, it's currently
    more often applied not to the pane itself but with in the one widget
    contained in the pane.

    tools_layout: a layout containing the top toolbar
    main_widget: the main widget. Can be None, if you want to add this
        manually later on.
    r   )r!   setContentsMarginsr  
setSpacingr  r  )r  main_widgetr  r  s       r4   create_plugin_layoutr    sd     ]F
aAq) .G'"
\"%Mr6   c                     | j                         }|D ]P  }	 |j                         t        |j                         |       n"|j                         r@|j	                  |       R y# t
        $ r Y _w xY w)z!Show/hide icons for menu actions.N)r   menuset_menu_iconsr%  r  r+  )r  statemenu_actionsr   s       r4   r  r    so    <<>L 
		{{}(v{{}e4##%++E2
  		s   ;A'A''	A32A3c                       e Zd ZdZddZy)SpyderProxyStylez(Style proxy to adjust qdarkstyle issues.c                 \    |t         j                  k(  ryt        j                  | ||||      S )zOverride Qt method.r   )r   SH_ComboBox_Popupr   	styleHint)r  hintr   widget
returnDatas        r4   r  zSpyderProxyStyle.styleHint  s.    6+++ $$T4LLr6   N)r   r   r   )rq  rr  rs  rt  r  ru  r6   r4   r  r    s    2Mr6   r  c                   $     e Zd ZdZd fd	Z xZS )QInputDialogMultilinezy
    Build a replica interface of QInputDialog.getMultilineText.

    Based on: https://stackoverflow.com/a/58823967
    c                    t        t        | 
  |fi | || j                  |       | j	                  t                      | j                         j                  t        |             t               | _
        | j                         j                  | j                         t               }|j                          t        d      }|j                  |       t        d      }|j                  |       | j                         j                  |       | j                  j                  |       |j                   j#                  | j$                         |j                   j#                  | j&                         y )NOKCancel)r~  r  rW  r  r  r!   r  r  r   r   	text_editr   
addStretchr   r  setPlainTextr   rT   acceptro  )
r  r   r;  r;   r   r  button_layout	ok_buttoncancel_buttonr  s
            r4   rW  zQInputDialogMultiline.__init__  s   #T3FEfE&{}%u.')/#  "%		*#H-..##D)!!$++.%%dkk2r6   )r  )rq  rr  rs  rt  rW  r  r  s   @r4   r  r    s    3 3r6   r  c                   ,    e Zd ZdZ ee      Zd Zd Zy)rK   z;Subclass to be able to open external files with our Mac appc                 h    t        j                  | g|  d| _        d| _        g | _        i | _        y r
  )r   rW  _never_shown_has_started_pending_file_open_original_handlers)r  rO  s     r4   rW  zMacApplication.__init__  s5    d*T* !"$"$r6   c                 v   |j                         t        j                  k(  rt        |j	                               }t
        j                  rt
        j                  d   |k(  rnC| j                  r| j                  j                  |       n| j                  j                  |       t        j                  | |      S )Nr   )r   r   FileOpenrs   filer>   argvr  sig_open_external_fileemitr  r   r   r   )r  r   rd   s      r4   r   zMacApplication.event
  s    ::<6??*

%ExxCHHQK50 ""++007''..u5!!$..r6   N)	rq  rr  rs  rt  r   rs   r  rW  r   ru  r6   r4   rK   rK     s    E#C[%/r6   rK   c                      t        j                         } | j                  j                         D ]!  \  }}|\  }}t	        j
                  |||       # y)z,Restore LaunchServices to the previous stateN)r   rL   r  itemsalsset_UTI_handler)rZ   ry   handlerUTIroles        r4   restore_launchservicesr    sM    



!C..446 0W	TCw/0r6   c                 r    t        j                         t        j                         }|j                   f<   j
                  j                  t               j                  s,t        j                         }t        j                   |       y fd}j                  j                  |       y)zO
    Register app to the Apple launch services so it can open Python files
    Nc                     | t         j                  k(  r@j                  r3d_        t        j                         }t        j
                  |       y y y )NF)r   ApplicationActiver  r  get_bundle_identifierr  )r  bundle_identifierrZ   r  uniform_type_identifiers     r4   handle_applicationStateChangedzCregister_app_launchservices.<locals>.handle_applicationStateChanged6  sO    B(((S-=-=$C # 9 9 ;'/@B .>(r6   )r   rL   r  get_UTI_handlerr  aboutToQuitrT   r  r  r  r  applicationStateChanged)r  r  old_handlerr  r  rZ   s   ``   @r4   rO   rO      s     


!C%%&=tDK>IC3T:; OO23557#T+<	>B ''(FGr6   __main__)	not_found)Tr  r   )NNNNNNTFNNNNNF)r     N)TFNN)NN)zpublic.python-scripteditor)xrt  r  r  mathr   loggingrQ   os.pathr   r   rb   r>   r  urllib.parser   qtpy.compatr   r   qtpy.QtCorer   r   r	   r
   r   r   r   r   r   r   
qtpy.QtGuir   r   r   r   qtpy.QtWidgetsr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   spyder.config.baser#   spyder.config.managerr$   spyder.py3compatr%   r&   spyder.utils.icon_managerr'   spyder.utilsr(   spyder.utils.image_path_managerr)   spyder.utils.paletter*   spyder.utils.registriesr+   r,   spyder.widgets.waitingspinnerr-   rJ   applaunchservicesr  	getLoggerrq  loggerMENU_SEPARATORr5   r<   rD   r]   re   rh   rP   rv   r   r   r   r   r   r   r   r   r   r   WindowShortcutr   r   r   r   r!  r1  r5  r7  r<  rC  rK  rS  rU  rz  r   r  r  r  r  r  r  r  rK   r  rO   ru  r6   r4   <module>r     s%        	  	 
    3: : : I I? ? ? ? 2 & ; ) ! : . H 9 <<8$6$8# 
		8	$)$ $N
! 
.?5:"*1"

) HL.27<BF=B	B0 JN* *.Dd$TD++D$4d"'5	.b
)7O,!BD
4
.&	K KM P"G "J>97 9"C7 C:%P. 
M{ 
M3G 3B/\ /20 !7H@ z r6   