
    cc                     0    d dl mZmZ d dlZ G d d      Zy)    )GtkGdkNc                   >    e Zd Zd ZdZd Zd Zd Zd Zd Z	d Z
d Zy	)
DrPrintingManagerFc                      || _         d | _        y N)_window_auto_orientation)selfwindows     :/usr/lib/python3/dist-packages/drawing/printing_manager.py__init__zDrPrintingManager.__init__   s    $,$    c                    t        j                         }t        j                         }|j                         |j	                         k  r t         j
                  j                  | _        nt         j
                  j                  | _        |j                  | j                         | j                  r$|j                  t        j                  d             |j                  |       |j                  d| j                  |       |j                  d| j                   |       | j                  r,|j#                  d       t         j$                  j&                  }nt         j$                  j(                  }|j+                  || j,                        }y)z>Starts the GTK "print" dialog with a few pre-defined settings.A4z	draw-pagezbegin-printzDocuments/sortie.pdfN)r   PrintOperation	PageSetup
get_height	get_widthPageOrientation	LANDSCAPEr
   PORTRAITset_orientation_AUTO_SETTINGSset_paper_size	PaperSizeset_default_page_setupconnect_do_draw_page_do_begin_printset_export_filenamePrintOperationActionEXPORTPRINT_DIALOGrunr	   )r   pixbufprint_oppsetupaction_typeress         r   print_pixbufzDrPrintingManager.print_pixbuf   s!   !(==?&6++--//994//884//0		t,-
!!&) ; 2 2F;
=$"6"6?	 67))00;))66; 	[$,,/#r   c                 (    | j                  ||       y r   )_show_pixbuf_on_page)r   op	print_ctxpage_numr&   s        r   r   zDrPrintingManager._do_draw_pageE   s    Iv.r   c                 J    |j                  d       | j                  ||       y )N   )set_n_pagesr-   )r   r.   r/   r&   s       r   r    z!DrPrintingManager._do_begin_printH   s    ..Iv.r   c                    | j                  |      }|dk(  xs |dk(  }| j                  |||      }|j                  |      }|j                         }t	        j
                  ||dd       |j                  ||       |j                          y)z1Paint the (scaled) image on the page using cairo.r      N)_get_delta_orientation
_get_scalerotate_simpleget_cairo_contextr   cairo_set_source_pixbufscalepaint)r   r/   r&   angleuse_natural_ratiosr;   rotated_pixbufcairo_contexts           r   r-   z&DrPrintingManager._show_pixbuf_on_pageT   s    

%
%i
0%
2esl
//)V-?
@% ''.. --/-m^QB eU#
 r   c                 H   |rC|j                         |j                         z  }|j                         |j                         z  }nB|j                         |j                         z  }|j                         |j                         z  }|dk  s|dk  rt        ||      }|S d}|S )Ng      ?)r   r   min)r   r/   r&   r>   h_ratiow_ratior;   s          r   r7   zDrPrintingManager._get_scalei   s    !!#f&7&7&997  "V%5%5%777!!#f&6&6&887  "V%6%6%887s]gmw 5 
, 5	,r   c                 |   | j                   t        j                  j                  k(  rd}nd}|j	                         j                         }|t        j                  j                  k(  rd}nB|t        j                  j                  k(  rd}n"|t        j                  j                  k(  rd}nd}||z
  }|dk  r|dz   }|S )Nr   Z   r5   i  ih  )r
   r   r   r   get_page_setupget_orientationr   REVERSE_PORTRAIT)r   r/   initial_anglecurrent_orientation	new_angledelta_angles         r   r6   z(DrPrintingManager._get_delta_orientationw   s    	s22;;;==!002BBDC//8889c11;;;9c11BBB99M)+1_s";	r   N)__name__
__module____qualname____gtype_name__r   r   r+   r   r    r-   r7   r6    r   r   r   r      s2    %  !0L//*r   r   )gi.repositoryr   r   mathr   rR   r   r   <module>rU      s   $ # u ur   