ó
Ò:\c           @` s}  d  Z  d d l m Z m Z m Z d d l Z d d l m Z m Z d d l	 m
 Z
 m Z 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 m Z m Z m Z m Z m Z d d
 l m  Z  m! Z! d e f d „  ƒ  YZ" d e f d „  ƒ  YZ# d e f d „  ƒ  YZ$ d e f d „  ƒ  YZ% d e f d „  ƒ  YZ& d „  Z' e( d k rye' ƒ  n  d S(   s–   
Home Tab.

This widget does not perform the actual actions but it emits signals that
should be connected to the final controller on the main window.
i    (   t   absolute_importt   divisiont   print_functionN(   t   Qtt   Signal(   t   QApplicationt   QHBoxLayoutt   QLabelt   QProgressBart   QVBoxLayout(   t   AnacondaAPI(   t	   constants(   t   load_style_sheet(   t   ButtonNormalt   ComboBoxBaset   FrameTabContentt   FrameTabFootert   FrameTabHeadert	   LabelBaset   SpacerHorizontalt
   WidgetBase(   t   ListItemApplicationt   ListWidgetApplicationt   ButtonHomeRefreshc           B` s   e  Z d  Z RS(   s?   QFrame used for CSS styling refresh button inside the Home Tab.(   t   __name__t
   __module__t   __doc__(    (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR   ,   s   t   ComboHomeEnvironmentc           B` s   e  Z d  Z RS(   s   Widget Used for CSS styling.(   R   R   R   (    (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR   0   s   t   ButtonHomeChannelsc           B` s   e  Z d  Z RS(   s   Widget Used for CSS styling.(   R   R   R   (    (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR   4   s   t	   LabelHomec           B` s   e  Z d  Z RS(   s/   QLabel used for CSS styling the Home Tab label.(   R   R   R   (    (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR   8   s   t   HomeTabc           B` s@  e  Z d  Z e e e e ƒ Z e e e ƒ Z e e e e e e e ƒ Z e e e e e e ƒ Z	 e e ƒ Z
 e e e ƒ Z e e e ƒ Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d d „ Z d d	 „ Z d
 „  Z e d „  ƒ Z d d „ Z d „  Z d „  Z d d d d d „ Z d d „ Z RS(   s   Home applications tab.c         C` s  t  t |  ƒ j | ƒ | |  _ t ƒ  |  _ d |  _ d |  _ d |  _	 d |  _
 t ƒ  |  _ t d ƒ |  _ t d ƒ |  _ t ƒ  |  _ t |  ƒ |  _ t |  ƒ |  _ t |  ƒ |  _ t d ƒ |  _ t d ƒ |  _ t d ƒ |  _ t ƒ  |  _ |  j |  _  |  j! d ƒ |  j j" t# ƒ |  j j$ t% j& ƒ t' ƒ  } | j( |  j ƒ | j( t) ƒ  ƒ | j( |  j ƒ | j( t) ƒ  ƒ | j( |  j ƒ | j( t) ƒ  ƒ | j* ƒ  | j( |  j ƒ |  j j+ | ƒ t, ƒ  } | j( |  j ƒ |  j j+ | ƒ t' ƒ  } | j( |  j ƒ | j( t) ƒ  ƒ | j( |  j ƒ | j* ƒ  | j( |  j ƒ |  j j+ | ƒ t, ƒ  } | j( |  j ƒ | j( |  j ƒ | j( |  j ƒ |  j+ | ƒ |  j j- j. |  j- ƒ |  j j/ j. |  j/ ƒ |  j j0 j. |  j0 ƒ |  j j1 j. |  j2 ƒ |  j j1 j. |  j3 ƒ |  j j4 t# ƒ d S(   s   Home applications tab.t   Channelst   Refreshs   Applications ont    t   TabN(5   t   superR   t   __init__t   _parentR
   t   apit   Nonet   applicationst   style_sheett
   app_timerst   current_prefixR   t   listR   t   button_channelsR   t   button_refreshR   t   comboR   t	   frame_topR   t
   frame_bodyR   t   frame_bottomR   t
   label_homeR   t   label_status_actiont   label_statusR   t   progress_bart   first_widgett   setObjectNamet   setTextVisiblet   Falset   setVerticalScrollBarPolicyR   t   ScrollBarAlwaysOnR   t	   addWidgetR   t
   addStretcht	   setLayoutR	   t   sig_conda_action_requestedt   connectt   sig_url_clickedt   sig_launch_action_requestedt   clickedt   show_channelst   refresh_cardst
   setVisible(   t   selft   parentt
   layout_topt   layout_bodyt   layout_bottomt   layout(    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR$   V   sn    						
		
	

c         C` so   | j  d ƒ } | j  d ƒ } | j  d ƒ } | j  d ƒ } | j  d ƒ |  _ |  j | ƒ |  j | | ƒ d S(   s   Setup the tab content.t   processed_infot   __environmentsR(   t   packagest   default_prefixN(   t   getR+   t   set_environmentst   set_applications(   RH   t
   conda_datat   conda_processed_infot   environmentsR(   RP   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyt   setup¡   s    c   	      C` sG  y |  j  j j ƒ  Wn t k
 r' n X|  j  j ƒ  |  j  j ƒ  } g  } xh t | j ƒ  ƒ D]T \ } \ } } | j | j	 | ƒ ƒ |  j  j
 | | ƒ |  j  j | | t j ƒ q] Wd } x? t | j ƒ  ƒ D]+ \ } \ } } |  j | k rÎ | } PqÎ qÎ W|  j  j | ƒ |  j  j j |  j ƒ t | ƒ d } |  j  j | ƒ d S(   s   Setup the environments list.i    i@   N(   R/   t   currentIndexChangedt
   disconnectt	   TypeErrort   cleart   fontMetricst	   enumeratet   itemst   appendt   widtht   addItemt   setItemDataR   t   ToolTipRoleR+   t   setCurrentIndexRA   t   _item_selectedt   maxt   setMinimumWidth(	   RH   RW   t   fmt   widthst   it
   env_prefixt   env_namet   indexRa   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyRS   «   s(    %%c         C` sô  |  j  j | d |  j ƒ} g  } g  } g  } |  j  j |  j ƒ } g  | D] } | | k rI | ^ qI }	 x |	 D] } | | | | <qn Wxt t | j ƒ  ƒ ƒ D]ë }
 | |
 } | j d ƒ } | j d | ƒ } | j |
 ƒ pâ i  } | d pû | j d ƒ } t d | d | d | d | d d | d d | d d |  j d	 | j d	 t	 ƒ d
 | j d
 t	 ƒ ƒ 	} | j
 r}| j | ƒ qŸ | j | ƒ qŸ W| | } |  j j ƒ  x | D] } |  j j | ƒ q¬W|  j j |  j ƒ |  j t ƒ |  j ƒ  d S(   s@   Build the list of applications present in the current conda env.t   prefixt   namet   display_namet   descriptiont   summaryt   versionst   commandt
   image_patht   needs_licenset	   non_condaN(   R&   t   process_appsR+   t   conda_linked_apps_infot   sortedR,   t   keysRR   R   R:   t	   installedR`   R\   Rb   t   update_style_sheetR)   t   set_widgets_enabledt   Truet   update_status(   RH   R(   RP   t   appst   all_applicationst   installed_applicationst   not_installed_applicationst   linked_appst   appt   missing_appst   app_nameRp   Rq   t   package_dataRr   t   itemRk   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyRT   Ê   sD    %



		
c         C` s   |  j  j ƒ  } |  j j | ƒ S(   s(   Return the current selected environment.(   R/   t   currentTextR&   t   conda_get_prefix_envname(   RH   Rm   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyt   current_environmentú   s    c         C` s]   |  j  j |  j ƒ |  j  j ƒ  x6 |  j  j ƒ  D]% } | j j ƒ  s0 | j j ƒ  q0 q0 Wd S(   s»   Refresh application widgets.

        List widget items sometimes are hidden on resize. This method tries
        to compensate for that refreshing and repainting on user demand.
        N(   R,   R~   R)   t   repaintR_   t   widgett	   isVisible(   RH   R‹   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyRF   ÿ   s
    c         C` s   |  j  j |  j t j ƒ d S(   s2   Emit signal requesting the channels dialog editor.N(   t   sig_channels_requestedt   emitR-   t   Ct   TAB_HOME(   RH   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyRE     s    c         C` s>   |  j  ƒ  |  j j t ƒ |  j j t ƒ |  j j t ƒ d S(   s   Update applications list.N(   RT   R5   RG   R:   R4   R6   (   RH   Rp   t   version(    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyt   update_list  s    
c         C` s±   g  |  _  x¡ t |  j j ƒ  ƒ D]Š } |  j j | ƒ } |  j  j | ƒ t | t ƒ r | j } | j	 | ƒ } | r© | d } |  j
 j | j ƒ } | j | | ƒ q© q q Wd S(   s   Update applications versions.Rt   N(   R_   t   rangeR,   t   countR‹   R`   t
   isinstanceR   Rp   RR   R&   t   get_dev_tool_versiont   patht   update_versions(   RH   R‚   Rk   R‹   Rp   t   metaRt   R–   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR     s    		
c         C` sA   |  j  j | ƒ } |  j  j | ƒ } |  j j | | t j ƒ d S(   s4   Notify that the item in combo (environment) changed.N(   R/   t   itemTextt   itemDatat   sig_item_selectedR“   R”   R•   (   RH   Rn   Rp   Ro   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyRf   '  s    c         C` s'   |  j  j ƒ  r# |  j  j ƒ  d j Sd S(   s?   Return the last element of the list to be used in tab ordering.iÿÿÿÿN(   R,   R_   R   (   RH   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyt   last_widget-  s    c         C` s/   |  j  |  j |  j g } | |  j j ƒ  7} | S(   s%   Return a list of the ordered widgets.(   R/   R-   R.   R,   t   ordered_widgets(   RH   t   next_widgetR£   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR£   3  s
    c         C` s…   |  j  j | ƒ |  j j | ƒ |  j j | ƒ xN |  j j ƒ  D]= } | j j | ƒ | j j | ƒ | r@ | j | ƒ q@ q@ Wd S(   s   Enable or disable widgets.N(	   R/   t
   setEnabledR-   R.   R,   R_   t   button_installt   button_optionst   set_loading(   RH   t   valueR‹   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR   >  s    c         C` s4   |  j  r0 x$ |  j  j ƒ  D] } | j ƒ  q Wn  d S(   s   Update status of items in list.N(   R,   R_   R   (   RH   R‹   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyt   update_itemsJ  s    	R!   c   	      C` s  t  j ƒ  j ƒ  j ƒ  } t | d d ƒ } d } |  j j ƒ  } | j | t j	 t | | d ƒ ƒ } | j | t j	 t | d | d ƒ ƒ } |  j j
 | ƒ |  j j
 | ƒ | d k rÙ | d k rÙ |  j j t ƒ n0 |  j j t ƒ |  j j | ƒ |  j j | ƒ d S(   s%   Update the application action status.g       @g      @i    gffffffæ?i   NgUUUUUUå?(   R   t   desktopt   availableGeometryRa   t   roundR4   R]   t
   elidedTextR   t
   ElideRightt   setTextR5   R'   R6   RG   R:   R€   t
   setMaximumt   setValue(	   RH   t   actiont   messageR©   t	   max_valueRa   t   max_status_lengtht   msg_percentRi   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR   P  s     	c         C` sN   | d k r t ƒ  |  _ n	 | |  _ |  j j d |  j ƒ |  j |  j ƒ d S(   s   Update custom CSS style sheet.R)   N(   R'   R   R)   R,   R~   t   setStyleSheet(   RH   R)   (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR~   j  s
    	N(   R   R   R   R   t   objectR¡   R’   t   boolRC   R@   RB   t   sig_install_action_requestedt   sig_remove_action_requestedR'   R$   RX   RS   RT   RŽ   RF   RE   R—   R   Rf   t   propertyR¢   R£   R   Rª   R   R~   (    (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyR   >   s2   K	
		0						c          C` sà   d d l  m }  |  ƒ  } t ƒ  } i  } x} t d ƒ D]o } d j | ƒ } t d | d d d d	 d
 t | ƒ t | d ƒ t | d ƒ g d d d d ƒ } | | | <q5 W| j | ƒ | j	 ƒ  | j
 ƒ  t j | j ƒ  ƒ d S(   s   Run local test.i    (   t   qapplicationi   s   Package {0}Rp   Ro   t   boomRr   s)   Scientific PYthon Development EnviRonmentRt   i   i   Ru   Rv   N(   t"   anaconda_navigator.utils.qthelpersR¾   R   R˜   t   formatt   dictt   strR'   RX   R~   t   showMaximizedt   syst   exitt   exec_(   R¾   R‡   R   R‚   Rk   Rp   t   application(    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyt
   local_testw  s$    		)	

t   __main__()   R   t
   __future__R    R   R   RÅ   t   qtpy.QtCoreR   R   t   qtpy.QtWidgetsR   R   R   R   R	   t#   anaconda_navigator.api.anaconda_apiR
   t   anaconda_navigator.utilsR   R”   t   anaconda_navigator.utils.stylesR   t   anaconda_navigator.widgetsR   R   R   R   R   R   R   R   t%   anaconda_navigator.widgets.lists.appsR   R   R   R   R   R   R   RÉ   R   (    (    (    sC   lib/python2.7/site-packages/anaconda_navigator/widgets/tabs/home.pyt   <module>   s$   (:	ÿ :	