
    ?g                     l    d dl mZ d dlZ G d dej                        Z G d dej
                        Zy)    )GtkNc                   *    e Zd Zd Zd Zd Zd Zd Zy)InspectViewc                    || _         t        j                  t        t        t        t        t              }t        j
                  j                  | |       d | _        | j                  dd       | j                  dd       | j                  dd       t        j                         | _
        t        j                  d      | _        | j                  j                  d| j                         | j                  j                  | j                         | j                  j!                          | j"                  j                  d	| j$                         | j"                  j                  d
| j&                         y )Nr   Name   Type   ValuezInsert into command entryactivatezbutton-press-eventzrow-activated)moduler   	ListStorestr	pageutilsBaseListView__init__selected_pathcreate_text_columnMenupopupMenuIteminsert_commandconnecton_insert_commandappendshow_all	tree_viewon_button_press_eventon_row_activated)selfr   stores      :/usr/share/cinnamon/cinnamon-looking-glass/page_inspect.pyr   zInspectView.__init__   s   c3S#6''e4!6*6*7+XXZ
!ll+FG##J0F0FG

$--.

3T5O5OP0E0EF    c                 l   t        |j                        }t        |j                        }|j                  ||      }|v|j                  dk(  rf|\  }}}}	|| _        |j                          |j                  ||d       | j                  j                  d d d d |j                  |j                         yy y )N   r   T)
intxyget_path_at_posbuttonr   
grab_focus
set_cursorr   time)
r    treevieweventr'   r(   pthinfopathcolcellxcellys
             r"   r   z!InspectView.on_button_press_event   s    LL**1a05<<1#4&-#D#ue!%D!c1-JJT4tU\\5::N $5r#   c                    | j                   j                  | j                        }| j                   j                  |d      }| j                   j                  |d      }|dk(  r|dz  }t        j
                  j                  | j                  j                  j                  |       | j                  j                  j                  j                          y )Nr      functionz())r!   get_iterr   	get_valuer   Entrydo_insert_at_cursorr   parentcommand_linegrab_focus_without_selecting)r    widget	tree_iterobj_typeobj_paths        r"   r   zInspectView.on_insert_command'   s    JJ''(:(:;	::''	15::''	15z!H		%%dkk&8&8&E&ExP''DDFr#   c                 X   | j                   j                  |      }| j                   j                  |d      }| j                   j                  |d      }| j                   j                  |d      }| j                   j                  |d      }| j                  j	                  ||||d       y )Nr   r   r%   r6   T)r!   r8   r9   r   update_inspector)r    r.   r1   view_columnr@   namerA   values           r"   r   zInspectView.on_row_activated0   s    JJ''-	zz##Iq1::''	15

$$Y2zz##Iq1$$T8T5$Gr#   c           
         | j                   j                          |j                  d        |D ]M  }| j                   j                  |d   |d   t	        j
                  |d         |d   |dz   |d   z   dz   g       O y )Nc                     | d   S )NrF    )items    r"   <lambda>z1InspectView.set_inspection_data.<locals>.<lambda>;   s
    4< r#   )keyrF   typerG   z['z'])r!   clearsortr   r   shorten_value)r    r1   datarK   s       r"   set_inspection_datazInspectView.set_inspection_data9   s    

		/	0 	CDJJtF|#F|(66tG}E#G}#d{T&\9D@	B C	Cr#   N)__name__
__module____qualname__r   r   r   r   rS   rJ   r#   r"   r   r      s    G(
GHCr#   r   c                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	ddZ
d	 Zd
 Zy)
ModulePagec                 6   t        |       | _        t        j                  j	                  | | j                         || _        t        j                  d      | _        | j                  j                  d       | j                  j                  d| j                         | j                  | j                  d       t        j                  d      | _        | j                  j                  d       | j                  j                  d       | j                  j                  d| j                         | j                  | j                  d       | j                  t!        j"                  d      d	       t!        j"                  d
      | _        | j                  | j$                  d	       | j                  t!        j"                  d      d	       t!        j"                  d      | _        | j                  | j&                  d	       | j                  t!        j"                  d      d	       t!        j"                  d      | _        | j                  | j(                  d	       d | _        g | _        | j
                  j.                  j                  d| j0                         y )Nzgo-previous-symboliczGo backclickedr   zinsert-object-symboliczInsert into resultsFzPath:r
   <No selection done yet>z; Type: z; Name:zstatus-changed)r   viewr   WindowAndActionBarsr   r<   ImageButtonbackset_tooltip_textr   on_back_buttonadd_to_left_barinsertset_sensitiveon_insert_buttonadd_to_bottom_barr   Label
path_label
type_label
name_labelcurrent_inspectionstacklg_proxyon_status_change)r    r<   s     r"   r   zModulePage.__init__D   s   %	%%..tTYY?))*@A			""9-		)T%8%89TYY*++,DE$$%:;!!%(It'<'<=T[[!,syy115))$=>t2syy3Q7))B-t2syy3Q7))B-t2"&
$$%5t7L7LMr#   c                 *    |r| j                          y y )N)rO   )r    proxyonlines      r"   ro   zModulePage.on_status_changec   s    JJL r#   c                     | j                   j                  d       | j                  j                  d       | j                  j                  d       | j                  j
                  j                          y )Nr[   r\   )ri   set_textrj   rk   r]   r!   rO   r    s    r"   rO   zModulePage.clearg   sM      !:;  $  $		r#   c                     t        | j                        dkD  r7| j                  \  }}}}| j                  j                  j                  |       y y Nr   )lenrm   rl   r<   rn   	AddResult)r    r?   r1   rA   rF   rG   s         r"   rf   zModulePage.on_insert_buttonm   sC    tzz?Q*.*A*A'D(D%KK  **40 r#   c                     t        | j                        dkD  r| j                          y | j                  j	                  d       y )Nr   results)rx   rm   pop_inspection_elementr<   activate_page)r    r?   s     r"   rb   zModulePage.on_back_buttonr   s0    tzz?Q'')KK%%i0r#   c                     t        | j                        dkD  r' | j                  | j                  j                           t        | j                        dkD  }| j                  j                  |       y rw   )rx   rm   rD   poprd   re   )r    	sensitives     r"   r|   z!ModulePage.pop_inspection_elementy   sQ    tzz?Q!D!!4::>>#34

Oa'	!!),r#   c                     | j                   A| j                  j                  | j                          | j                  j	                  d       y y )NT)rl   rm   r   rd   re   ru   s    r"   push_inspection_elementz"ModulePage.push_inspection_element   s=    "".JJd556KK%%d+ /r#   c                    |dv r|r| j                          ||||f| _        | j                  j                  |       | j                  j                  |       | j
                  j                  |       | j                  j                  d       | j                  j                  j                  || j                  |       y |dv r#t        j                  d|z   dz   d|z   dz          y t        j                  d	|z   d
z   |z   dz   |       y )N)arrayobjectinspect)	result_cb	user_data)	undefinednullzValue for ''z
Value is <>z
Value for z ')r   rl   ri   rt   rj   rk   r<   r}   rn   Inspectinspect_finish_cbr   ResultTextDialog)r    r1   rA   rF   rG   push_to_stacks         r"   rD   zModulePage.update_inspector   s    **,,.'+XtU&CD#OO$$T*OO$$X.OO$$T*KK%%i0KK  ((9O9O[_(`..&&}t';c'A<RZCZ]`C`a&&|h'>'E'Ls'RTYZr#   c                 "   |\  }}|r	 | j                   j                  ||       y | j                   j                  j                          y # t        $ r:}t        d|       | j                   j                  j                          Y d }~y d }~ww xY w)NzInspect:)r]   rS   	Exceptionprintr!   rO   )r    rq   resultr1   successrR   es          r"   r   zModulePage.inspect_finish_cb   sp     $(		--dD9
 IIOO!!#	  (j!$		%%''(s   A 	B0B		Bc                     | j                   d d = d | _        | j                  j                  d       | j	                  ||||       y )NF)rm   rl   rd   re   rD   )r    r1   rA   rF   rG   s        r"   inspect_elementzModulePage.inspect_element   s;    JJqM"&!!%(dHdE:r#   N)F)rT   rU   rV   r   ro   rO   rf   rb   r|   r   rD   r   r   rJ   r#   r"   rX   rX   C   s6    N> 1
1-,
[$	$;r#   rX   )gi.repositoryr   r   r   r   r^   rX   rJ   r#   r"   <module>r      s6     ;C)(( ;Czc;.. c;r#   