%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core22/current/usr/share/subiquity/subiquitycore/ui/__pycache__/
Upload File :
Create Path :
Current File : //snap/core22/current/usr/share/subiquity/subiquitycore/ui/__pycache__/utils.cpython-310.pyc

o

K��^�)�@s~dZddlmZddlZddlmZmZmZmZm	Z	m
ZmZm
Z
mZmZddlmZmZddlmZmZmZddlmZddlmZdd	lmZdd
lmZe�d�Z dd
�Z!e!Gdd�d��Z
e"gd��Z#dd�Z$e$Gdd�d��Z%dd�e#e"dg�BD�Z&dd�Z'dd�Z(dd�Z)		d0dd �Z*Gd!d"�d"e�Z+Gd#d$�d$e�Z,	&	'd1d(d)�Z-d*d+�Z.Gd,d-�d-e�Z/Gd.d/�d/e�Z0dS)2z UI utilities �)�
partialmethodN)
�ACTIVATE�AttrMap�CompositeCanvas�connect_signal�LineBox�Padding�SelectableIcon�Text�WidgetDecoration�
WidgetDisable)�
cancel_btn�	other_btn)�ListBox�Pile�
WidgetWrap)�Spinner)�Stretchy)�TableRow)�widget_widthzsubiquitycore.ui.utilsc
Cs�d}td|�D][}t|d�|�tt|d��t|d�|�tt|d��t|d�|�ttd||d	��t|d
�|�ttdd|fd��t|d
�|�ttdd|fd��t|d�|�ttdd|fd��q|S)aT Decorator for generating useful padding methods

    Loops through and generates methods like:

      Padding.push_1(Widget)

      Sets the left padding attribute by 1

      Padding.pull_24(Widget)

      Sets right padding attribute by 24.

      Padding.center_50(Widget)

      Provides center padding with a relative width of 50
    �d�zpush_{})�leftzpull_{})�rightzfixed_{}�center)�align�width�	min_widthz	center_{}�relative)rrzleft_{}rzright_{}r)�range�setattr�formatr�_Padding)�cls�
padding_count�i�r&�./usr/share/subiquity/subiquitycore/ui/utils.py�
apply_padders3s2��������r(c@seZdZdZee�ZdS)rau Padding methods

    .. py:meth:: push_X(:class:`urwid.Widget`)

       This method supports padding the left side of the widget
       from 1-99, for example:

       .. code::

          Padding.push_20(Text("This will be indented 20 columns")

    .. py:meth:: pull_X(:class:`urwid.Widget`)

       This method supports padding the right side of the widget
       from 1-99, for example:

       .. code::

          Padding.pull_20(Text("This will be right indented 20 columns")

    .. py:meth:: fixed_X(:class:`urwid.Widget`)

       This method supports padding the widget to a fixed size and
       centering it.
       from 1-99, for example:

       .. code::

          Padding.fixed_20(Text("This will be centered and fixed sized
                                 of 20 columns"))

    .. py:meth:: center_X(:class:`urwid.Widget`)

       This method centers a widget with X being the relative width of
       the widget.

       .. code::

          Padding.center_10(Text("This will be centered with a "
                                 "width of 10 columns"))

    .. py:meth:: left_X(:class:`urwid.Widget`)

       This method aligns a widget left with X being the relative width of
       the widget.

       .. code::

          Padding.left_10(Text("This will be left aligned with a "
                               "width of 10 columns"))

    .. py:meth:: right_X(:class:`urwid.Widget`)

       This method right aligns a widget with X being the relative width of
       the widget.

       .. code::

          Padding.right_10(Text("This will be right aligned with a "
                                "width of 10 columns"))

    N)�__name__�
__module__�__qualname__�__doc__rr
�
line_breakr&r&r&r'rXs>r)�bodyzdanger_button focus�
danger_buttonzdone_button focus�done_buttonzframe_button focus�frame_button�frame_header�frame_header_fringe�
info_error�
info_minor�info_primary�menu_button focus�menu_buttonzother_button focus�other_button�progress_complete�progress_incompletezscrollbar focus�	scrollbarzstring_input focus�string_inputc	CsJtD] }|d}|tvrt||tt||d��qt||tt|d��q|S)z� Applies AttrMap attributes to Color class

    Eg:

      Color.frame_header(Text("I'm text in the Orange frame header"))
      Color.body(Text("Im text in wrapped with the body color"))
    z focus)�attr_map�	focus_map)r>)�STYLE_NAMESr rr)r#�k�kfr&r&r'�apply_style_map�srCc@seZdZdZdS)�ColoraZ Partial methods for :class:`~subiquity.palette.STYLES`

    .. py:meth:: frame_header(:class:`urwid.Widget`)

       This method colors widget based on the style map used.

       .. code::

          Color.frame_header(Text("This will use foreground and background "
                                  "defined from the STYLES attribute"))

    N)r)r*r+r,r&r&r&r'rD�srDcCsi|]}|d�qS)r5r&)�.0rAr&r&r'�
<dictcomp>�srFcCstt|t��S�N)rr�_disable_everything_map��wr&r&r'�disabled��rKcCs$t|t�r|j}t|t�r|j}|SrG)�
isinstancer�original_widgetrrIr&r&r'�
undisabled�s


rOcCs0d}|D]	}tt|�|�}qtt|�||dd�S)N�r)rrr)�maxrr"r)�buttonsr�buttonr&r&r'�button_pile�s�rTTFcCs�t|t�r	t|�}|rt�|�}|durd}n	t|t�r t|�}g}|dur2dt|�fdtd�fg}|dtd�fg}|durK|�d|fdtd�fg�t||�}|rZt	|�d|_
tj|dd�S)a_Helper to create a common screen layout.

    The commonest screen layout in subiquity is:

        [ 1 line padding (optional) ]
        excerpt (optional)
        [ 1 line padding ]
        Box widget (usually a ListBox)
        [ 1 line padding ]
        a button_pile
        [ 1 line padding ]

    This helper makes creating this a 1-liner.
    NF�pack���L)r)rM�listrr�	center_63rTr
�extendr�len�focus_position�	center_79)�rowsrR�
focus_buttons�excerpt�narrow_rows�excerpt_rowsr.�piler&r&r'�screen�s2




�
�
�recsHeZdZdZdZd�fdd�	Zdd�Zdd	�Zd
d�Zdd
d�Z	�Z
S)�CursorOverridezKDecoration to override where the cursor goes when a widget is focused.
    Trcst��|�||_dSrG)�super�__init__�cursor_x)�selfrJri��	__class__r&r'rh$s
zCursorOverride.__init__cCs
|jdfS)Nr�ri)rj�sizer&r&r'�get_cursor_coords(s
z CursorOverride.get_cursor_coordscC�|j�||�SrG)�_original_widgetr_�rjrn�focusr&r&r'r_+rLzCursorOverride.rowscCrprG)rq�keypressrrr&r&r'rt.rLzCursorOverride.keypressFcCs*|j�||�}|rt|�}|�|�|_|SrG)rq�renderrro�cursor)rjrnrs�cr&r&r'ru1s
zCursorOverride.render)r)F)r)r*r+r,�has_original_widthrhror_rtru�
__classcell__r&r&rkr'rfsrfc@seZdZdZdgZdd�ZdS)�
ClickableIconzLike Button, but simpler. �clickcCs |j|tkr	|S|�d�dS)Nr{)�_command_mapr�_emit)rjrn�keyr&r&r'rt>szClickableIcon.keypressN)r)r*r+r,�signalsrtr&r&r&r'rz:srzr8r7rWcspt|�}t�t�s
d�i�t�t�sd�i�tt||d�����t|d��fdd��t|d��fdd���S)Nrm�openc�
����SrG��set_attr_map��menu)�amr?r&r'�<lambda>O�
z&make_action_menu_row.<locals>.<lambda>�closecr�rGr�r�)r�r>r&r'r�Pr�)rrM�dictrrfr)�cellsr�r>r?ri�rowr&)r�r>r?r'�make_action_menu_rowDs

r�cCs"|�d�}d�dd�|D����S)Nz

cSsg|]}|�dd��qS)�
� )�replace)rE�pr&r&r'�
<listcomp>Vszrewrap.<locals>.<listcomp>)�split�join�strip)�text�parasr&r&r'�rewrapTs
r�cs$eZdZ�fdd�Zdd�Z�ZS)�SomethingFailedcsX||_ttd�|jd�}t|�td�t|�d��td�t|g�g}t��d|dd�dS)N�Close��label�on_pressrVr�rW�)	�parentr�_r�r
r�rTrgrh)rjr��msg�stderr�ok�widgetsrkr&r'rhZs��zSomethingFailed.__init__cCs|j��dSrG)r��remove_overlay�rj�senderr&r&r'r�irLzSomethingFailed.close�r)r*r+rhr�ryr&r&rkr'r�Ysr�cs&eZdZ�fdd�Zddd�Z�ZS)�
LoadingDialogcs�||_t|dd�|_|j��d|_t|�d|_dtd|�fd|jfg}|dur@||_t	t
d�|jd�}|�dt
|g�f�t��tt|���dS)	N�dots)�styleFr�rUr��Cancelr�)r�r�spinner�start�closedr\rr
�task_to_cancelr
r�r��appendrTrgrhrr)rjr��aio_loopr�r�r��cancelrkr&r'rhos
�zLoadingDialog.__init__NcCs:|jrdS|dur|j��d|_|j��|j��dS)NT)r�r�r�r��stopr�r�r�r&r&r'r��s

zLoadingDialog.closerGr�r&r&rkr'r�msr�)NTNF)r8r7rW)1r,�	functoolsr�logging�urwidrrrrrrr"r	r
rr�subiquitycore.ui.buttonsr
r�subiquitycore.ui.containerrrr�subiquitycore.ui.spinnerr�subiquitycore.ui.stretchyr�subiquitycore.ui.tabler�subiquitycore.ui.widthr�	getLogger�logr(�setr@rCrDrHrKrOrTrerfrzr�r�r�r�r&r&r&r'�<module>sB0

%E
�-

�

Zerion Mini Shell 1.0