
    g
f4                         d Z dZdZdZdZdZddlZ ej                  dd	       dd
lm	Z	 ddl
mZ ddlmZ  G d d      Zy)a  
Utilities for obtaining information about containers supporting selection.
These utilities are app-type- and toolkit-agnostic. Utilities that might have
different implementations or results depending on the type of app (e.g. terminal,
chat, web) or toolkit (e.g. Qt, Gtk) should be in script_utilities.py file(s).

N.B. There are currently utilities that should never have custom implementations
that live in script_utilities.py files. These will be moved over time.
z$Id$z
$Revision$z$Date$zCopyright (c) 2023 Igalia, S.L.LGPL    NAtspiz2.0)r      )debug)AXObjectc                   @    e Zd ZdZed        Zed        Zed        Zy)AXSelectionzJUtilities for obtaining information about containers supporting selection.c                 H   t        j                  |       sy	 t        j                  j	                  |       }d| d|dg}t        j                  t        j                  |d       |S # t
        $ r3}d|g}t        j                  t        j                  |d       Y d}~yd}~ww xY w)z'Returns the selected child count of objr   z3AXSelection: Exception in get_selected_child_count:TNAXSelection:reportszselected children)	r   supports_selectionr   	Selectionget_n_selected_children	Exceptionr   printTokens
LEVEL_INFO)objcounterrortokenss       3/usr/lib/python3/dist-packages/orca/ax_selection.pyget_selected_child_countz$AXSelection.get_selected_child_count1   s     **3/	OO;;C@E !#y%9LM%**FD9  	KUSFe..=	s   A% %	B!.)BB!c                    t         j                  |       }|dk  ry|dk(  r|dz
  }d|cxk  r|k  sy y	 t        j                  j	                  | |      }|| k(  r+d| dg}t        j                  t        j                  |d       yd|d	|d
| g}t        j                  t        j                  |d       |S # t
        $ r3}d|g}t        j                  t        j                  |d       Y d}~yd}~ww xY w)z&Returns the nth selected child of obj.r   Nr   z-AXSelection: Exception in get_selected_child:Tr   #claims to be its own selected childzis selected child #of)	r	   r   r   r   get_selected_childr   r   r   r   )r   index
n_childrenchildr   r   s         r   r   zAXSelection.get_selected_childC   s     !99#>
?B;NEE&J& '	OO66sEBE C<$c+PQFe..= %)>tSQ%**FD9  	EuMFe..=	s    B4 4	C0=)C++C0c                 ^   t         j                  |       }t               }t        |      D ]7  }	 t        j
                  j                  | |      }|'|j                  |       9 | |v r;d| dg}t        j                  t        j                  |d       |j                  |        t        |      }t        |      |k7  r-d| d| g}t        j                  t        j                  |d       |S # t        $ r7}d|g}t        j                  t        j                  |d       g cY d}~c S d}~ww xY w)z3Returns a list of all the selected children of obj.z0AXSelection: Exception in get_selected_children:TNr   r   z$AXSelection: Selected child count ofzis )r	   r   setranger   r   r   r   r   r   r   addremovelistlen)r   r   childrenir    r   r   results           r   get_selected_childrenz!AXSelection.get_selected_childrena   s    44S95u 		$A::3B  U#		$ (?$c+PQFe..=OOC hv;%<cS=QFe..=%  LeT!!%"2"2FDA	s    C,,	D,5*D'D,'D,N)__name__
__module____qualname____doc__staticmethodr   r   r+        r   r	   r	   .   s?    T "  :  r2   r	   )r/   __id____version____date____copyright____license__girequire_versiongi.repositoryr    r   	ax_objectr   r	   r1   r2   r   <module>r=      sO   * 1 	   7E "   N Nr2   