
    Egb	                     ,    d dl mZ d dlZ G d d      Zy)    )GtkNc                   D    e Zd ZdZg fdZd Zd Zd Zd Zd Z	d Z
d	 Zy
)FocusNavigatorz
    FocusNavigator helps with tab navigation between
    widgets in our status.focusWidgets list.

    Since we handle most user events ourselves, we also
    need to handle Tab events correctly.
    c                     |t         _        y N)statusfocusWidgets)selfwidgetss     6/usr/share/cinnamon-screensaver/util/focusNavigator.py__init__zFocusNavigator.__init__   s
    %    c                     t         j                  }d}|D ]&  }|j                         s|j                  |      } |S  |S N)r   r	   	has_focusindexr
   r   focus_indexwidgets       r   _get_focus_indexzFocusNavigator._get_focus_index   sL    %% 	F!%mmF3	
 r   c                     t         j                  }|D ]4  }|j                         s|j                          |j	                           y  y r   )r   r	   get_sensitive
grab_focusgrab_default)r
   r   r   s      r   _focus_first_possiblez$FocusNavigator._focus_first_possible   sC    %% 	F##%!!###%		r   c                     t         j                  }|dz   }|t        |      k\  rd}||   j                         s| j	                  |       y ||   j                          ||   j                          y N   r   )r   r	   lenr   _focus_nextr   r   r
   currentr   news       r   r!   zFocusNavigator._focus_next&   sh    %%k#g,Cs|))+S!!!!#r   c                     t         j                  }|dz
  }|dk  rt        |      dz
  }||   j                         s| j	                  |       y ||   j                          ||   j                          y r   )r   r	   r    r   _focus_previousr   r   r"   s       r   r&   zFocusNavigator._focus_previous4   sl    %%k7g,"Cs|))+  %!!!#r   c                     | j                         }|dk(  r| j                          |r| j                  |       y | j                  |       y r   )r   r   r&   r!   )r
   reversecurrent_indexs      r   navigatezFocusNavigator.navigateB   sC    --/B&&(  /]+r   c                    t         j                  }| j                         }|dk(  ry ||   }t        |t        j
                        r|j                          y t        |t        j                        r|j                          y y r   )	r   r	   r   
isinstancer   ButtonclickedEntryactivater   s       r   activate_focuszFocusNavigator.activate_focusL   se    %%++-"%fcjj)NN		*OO +r   c                 X    t         j                  }| j                         }|dk(  ry ||   S r   )r   r	   r   )r
   r   r   s      r   get_focused_widgetz!FocusNavigator.get_focused_widget[   s1    %%++-"{##r   N)__name__
__module____qualname____doc__r   r   r   r!   r&   r*   r1   r3    r   r   r   r      s4      " &$$,$r   r   )gi.repositoryr   r   r   r8   r   r   <module>r:      s     [$ [$r   