
    cc                     B    d dl mZmZmZ  G d dej                        Zy)    )Gtk	GdkPixbufPangoc                   p     e Zd Zd Z ed       ed       ed      dZ fdZd Zd Zd Z	d	 Z
d
 Z xZS )DrPropertiesDialogz%s pxz%s cmz%s in)pxcminc                 B   d|j                   v }t        | 	  |d|t        d             || _        | j                          |r9| j                  j                         }| j                         j                  |       | j                  dd       | j                          y )NhTzImage properties)use_header_bardestroy_with_parenttransient_fortitlei     )deco_layoutsuper__init____image	_build_uiget_filename_for_displayget_titlebarset_subtitleset_default_sizeshow)selfparent_windowimage	wants_csdsubtitle	__class__s        4/usr/lib/python3/dist-packages/drawing/properties.pyr   zDrPropertiesDialog.__init__   s    ]...)')'+!.-.  0 $+..kk2248##H-S!))+    c                 d   d}t         j                  j                  |      }| j                         j	                  |j                  d             |j                  d      | _        |j                  d      | _        |j                  d      | _        d| _	        |j                  d      }|j                  d      }|j                  d	      }|j                  |       |j                  |       |j                  d
| j                  d       |j                  d
| j                  d       |j                  d
| j                  d       | j                          | j                  j                  t!        d      }t!        d      }nM| j                  j#                         }t$        j&                  j)                  |      \  }}	}
|j+                         }| j-                  dt!        d      |       | j-                  dt!        d      |       | j-                  dt!        d      | j/                                y)z;Fill the dialog with labels displaying correct information.z./com/github/maoschanz/drawing/ui/properties.uimain_widgetimage_props_gridlabel_widthlabel_heightr   units_pixelsunits_inchesunits_cmtoggledr	   r
   NzUnsaved filer   Path   Format   
Colorspace)r   Buildernew_from_resourceget_content_areaadd
get_object_gridr(   r)   unit
join_groupconnect	_set_unit_set_size_labelsr   gfiler   get_file_pathr   Pixbufget_file_infoget_name_add_grid_row_set_colorspace_label)r   ui_file_pathbuilderbtn_pxbtn_inbtn_cm
label_pathlabel_file_format	pb_formatwr   s              r#   r   zDrPropertiesDialog._build_ui,   s   A,KK)),7'g00?@!!"45$* ''6$((8$$)n-&n-&j)&FF..DNND1..DNND1..DNND1 
[[.!:())+: ''55jAIq! ))+ Q&	:.Q(%67Q,)C)C)EFr$   c                    t        j                  |t         j                  j                  d      }| j                  j                  |d|dd       t        j                  |t         j                  j                  dt        j                  j                  d      }|j                         j                  d       | j                  j                  |d|dd       y)	zBAdds a row 2 labels (a key and a value) to the dialog's main grid.T)labelhalignvisibler   r/   )rO   rP   wrap	wrap_moderQ   z	dim-labelr1   N)r   LabelAlignENDr8   attachSTARTr   WrapModeCHARget_style_context	add_class)r   indexkeyvalue	key_labelvalue_labels         r#   rC   z DrPropertiesDialog._add_grid_rowV   s    iic#))--F)**Iq%A.		ciioo(;(;TK+!++K8**KE1a0r$   c                     ddddddd}| j                   j                         j                         }|j                  |t	        d            }|S )	NARGB32RGB24A8A1	RGB16_565RGB30)r   r/   r1            zInvalid format)r   get_surface
get_formatgetr   )r   enumcairo_formatcolorspace_texts       r#   rD   z(DrPropertiesDialog._set_colorspace_label_   sV     


$ ((*557,HH\1-=+>?/	r$   c                 $   | j                   j                         }| j                   j                         }| j                  dk(  rt	        |dz  d      }t	        |dz  d      }n2| j                  dk(  rt	        |dz  d      }t	        |dz  d      }n|}|}| j
                  j                  | j                  | j                     t        |      z         | j                  j                  | j                  | j                     t        |      z         y)z\Set the labels for picture width and height according to the selected
		unit (px, cm or in).r
   g      X@r1   r	   gwS/B@N)
r   get_pixbuf_widthget_pixbuf_heightr9   roundr(   	set_label
units_dictstrr)   )r   px_width	px_heightwidthheights        r#   r=   z#DrPropertiesDialog._set_size_labelsp   s     [[))+(kk++-)	YY$$"5)D.!$6yyD,&*5)L(!,656T__TYY7#e*DEdoodii83v;FGr$   c                 8    |d   | _         | j                          y )Nr/   )r9   r=   )r   argss     r#   r<   zDrPropertiesDialog._set_unit   s    1g$)r$   )__name__
__module____qualname____gtype_name__r   rw   r   r   rC   rD   r=   r<   __classcell__)r"   s   @r#   r   r      sG    & 	
'
	'
	'
&GT1"H$r$   r   N)gi.repositoryr   r   r   Dialogr    r$   r#   <module>r      s   $ 0 /p pr$   