Ë
    c­øc  ã                   ó0   — d dl mZmZmZmZ  G d„ d«      Zy)é    )ÚGdkÚGioÚ	GdkPixbufÚGLibc                   ó†   — e Zd Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zi fd„Zd„ Zd„ Zy)ÚDrHistoryManagerc                 óJ   — || _         g | _        g | _        d| _        d| _        y )NTF)Ú_imageÚ_undo_historyÚ_redo_historyÚ	_is_savedÚ_waiting_for_rebuild)ÚselfÚimageÚkwargss      ú9/usr/lib/python3/dist-packages/drawing/history_manager.pyÚ__init__zDrHistoryManager.__init__   s(   € Ø€$„+à€$ÔØ€$ÔØ€$„.Ø#€$Õó    c                 ó   — | j                   S ©N)r   ©r   s    r   Ú	get_savedzDrHistoryManager.get_saved   s   € ð 
�‰Ðr   c                 óÂ   — | j                   D ]  }| j                  |«       Œ | j                  D ]  }| j                  |«       Œ | j                  | j                  «       y)z{Probably useless way to explicitly 'forget' the objects. It doesn't
		really free the memory, but it kinda helps i suppose.N)r   Ú_delete_operationr   Úinitial_operation)r   Úops     r   Úempty_historyzDrHistoryManager.empty_history   s^   € ð ×Ñò €bØ×Ñ˜"Õðà×Ñò €bØ×Ñ˜"Õðà×Ñ˜×/Ñ/Õ0r   c                 ó$   — |D ]  }d ||<   Œ	 i }d }y r   © )r   r   Úkeys      r   r   z"DrHistoryManager._delete_operation!   s$   € Øò €cØ€2€c‚7ðà	€"Ø�"r   c                 ód  — | j                  «       r)| j                  j                  «       j                  «        y t	        | j
                  «      dkD  r5| j
                  j                  «       }| j                  j                  |«       | j                  «        | j                  j                  «        y ©Nr   )Ú_operation_is_ongoingr
   Úactive_toolÚcancel_ongoing_operationÚlenr   Úpopr   ÚappendÚ_rebuild_from_history_asyncÚupdate_history_sensitivity)r   Úlast_ops     r   Útry_undozDrHistoryManager.try_undo*   s�   € Ø	×ÑÔ!Ø‡;�;×ÑÓ×5Ñ5Ô7Ø	Üˆ×	Ñ	Ó˜qÒ Ø×Ñ×#Ñ#Ó%€7Ø×Ñ×Ñ˜WÔ%Ø×"Ñ"Ô$Ø‡+�+×(Ñ(Õ*r   c                 óô   — | j                   j                  «       }|d   €6| j                  j                  |«       | j                  j                  «        y | j                  |d   «      j                  |«       y )NÚtool_id)r   r'   r   r(   r
   Úrestore_last_stateÚ	_get_toolÚapply_operation)r   ÚargsÚ	operations      r   Útry_redozDrHistoryManager.try_redo4   sa   € Ø× Ñ ×$Ñ$Ó&€)ØˆyÑÐ!Ø×Ñ×Ñ˜YÔ'Ø‡;�;×!Ñ!Õ#à‡>�>�)˜IÑ&Ó'×7Ñ7¸	ÕBr   c                 óV   — t        | j                  «      dkD  xs | j                  «       S r"   )r&   r   r#   r   s    r   Úcan_undozDrHistoryManager.can_undo<   s&   € ä
ˆd× Ñ Ó
! AÑ
%Ò	F¨$×*DÑ*DÓ*FÐFr   c                 ó2   — t        | j                  «      dkD  S r"   )r&   r   r   s    r   Úcan_redozDrHistoryManager.can_redo@   s   € ä	ˆT×ÑÓ	  1Ñ	$Ð$r   c                 óŽ   — | j                   ddd…   | j                  z   | _        g | _         | j                  j                  «        y)zkPut the entire 'undo' history into the 'redo' history, so the image
		can be reset without losing any data.Néÿÿÿÿ)r   r   r
   r*   r   s    r   Úrewind_historyzDrHistoryManager.rewind_historyW   s>   € ð ×)Ñ)©$¨B¨$Ñ/°$×2DÑ2DÑD€$ÔØ€$ÔØ‡+�+×(Ñ(Õ*r   c                 ó|   — | j                   j                  «        d| _        | j                  j	                  |«       y )NF)r
   Úset_surface_as_stable_pixbufr   r   r(   )r   r3   s     r   Úadd_operationzDrHistoryManager.add_operationa   s/   € Ø‡+�+×*Ñ*Ô,ð €$„.Ø×Ñ×Ñ˜IÕ&r   c                 ó¼   — t        |d   «      }t        |d   «      }t        |d   «      }t        |d   «      }d |t        j                  ||||¬«      ||dœ| _        y )Nr   é   é   é   )ÚredÚgreenÚblueÚalpha)r.   ÚpixbufÚrgbaÚwidthÚheight)Úfloatr   ÚRGBAr   )	r   Ú
rgba_arrayrG   rI   rJ   ÚrÚgÚbÚas	            r   Úset_initial_operationz&DrHistoryManager.set_initial_operationn   sa   € ÜˆJ�q‰MÓ€!ÜˆJ�q‰MÓ€!ÜˆJ�q‰MÓ€!ÜˆJ�q‰MÓ€!àØÜ�8‰8˜ ¨°!Ô4Ø˜Vñ	€$Õr   c                 ó¶   — |€t        t        d«      «      ‚| j                  j                  d ||j	                  «       |j                  «       dœ«       d| _        y )Nz Attempt to save an invalid state)r.   rG   rI   rJ   T)Ú	ExceptionÚ_r   r(   Ú	get_widthÚ
get_heightr   )r   rG   s     r   Ú	add_statezDrHistoryManager.add_statez   sX   € Ø€^ä	”1Ð7Ó8Ó	9Ð9Ø×Ñ×ÑØØØ×ÑÓØ×ÑÓ ñ	ô ð €$….r   c                 ó$   — | j                   d   d uS )NrG   )r   r   s    r   Úhas_initial_pixbufz#DrHistoryManager.has_initial_pixbuf†   s   € Ø	×	Ñ	 Ñ	)°Ð	5Ð5r   c                 ód   — | j                  d«      }|dk(  r| j                  S | j                  |   S )NFr:   )Ú_get_last_state_indexr   r   )r   Úindexs     r   Úget_last_saved_statez%DrHistoryManager.get_last_saved_state‰   s6   € Ø
×
$Ñ
$ UÓ
+€%Ø
ˆb‚[Ø
×
 Ñ
 Ð à
×
Ñ
˜UÑ
#Ð#r   c                 ó€   — d}d}| j                   D ]*  }|d   �Œ	|}| j                   j                  |«      }|dz  }Œ, |S )zðReturn the index of the last "state" operation (dict whose 'tool_id'
		value is None) in the undo-history. If there is no such operation, the
		returned index is -1 which means the only known state is the
		self.initial_operation attribute.r:   r   r.   r@   )r   r]   )r   Úallow_yeeting_statesÚreturned_indexÚ	nbPixbufsr   Úlast_saved_pixbuf_ops         r   r\   z&DrHistoryManager._get_last_state_index�   sZ   € ð €.Ø€)Ø×Ñò €bØˆ�mÑØÐØ×'Ñ'×-Ñ-¨bÓ1€NØ��N�Ið	ð 
Ðr   c                 ón   — | j                   s)d| _         t        j                  d| j                  i «       y y )NTiô  )r   r   Útimeout_addÚ_rebuild_from_historyr   s    r   r)   z,DrHistoryManager._rebuild_from_history_async§   s0   € Ø	×	"Ò	"à#€4ÔÜ×Ñ�C˜×3Ñ3°RÕ8ð 
#r   c                 ó¬  — | j                   syd| _         | j                  d«      }| j                  j                  «        | j                  j                  «       }g | _        |D ]U  }|j                  |«      |kD  r$| j                  |d   «      j                  |«       Œ;| j                  j                  |«       ŒW | j                  j                  «        y)z}Rebuild the image according to the content of the current history.
		This is used as a GSourceFunc so it should return False.FTr.   )r   r\   r
   r/   r   Úcopyr]   r0   Úsimple_apply_operationr(   Úupdate)r   Úasync_cb_dataÚlast_save_indexÚhistoryr   s        r   rf   z&DrHistoryManager._rebuild_from_history±   sº   € ð 
×	"Ò	"à
Ø#€$Ôà×.Ñ.¨tÓ4€/Ø‡+�+× Ñ Ô"Ø×Ñ×#Ñ#Ó%€'Ø€$ÔØò "€bØ‡m�m�BÓ˜/Ò)à‡N�N�2�i‘=Ó!×8Ñ8¸Õ<ð 	×Ñ×Ñ˜bÕ!ð"ð ‡+�+×ÑÔØ	r   c                 óR   — | j                   j                  «       j                  «       S r   )r
   r$   Úhas_ongoing_operationr   s    r   r#   z&DrHistoryManager._operation_is_ongoingÇ   s   € Ø	�‰×	 Ñ	 Ó	"×	8Ñ	8Ó	:Ð:r   c                 ó¸   — | j                   j                  j                  }||v r||   S | j                   j                  j                  t	        d|z  «      «       y )NzError: no tool '%s')r
   ÚwindowÚtoolsÚreveal_action_reportrU   )r   r.   Ú	all_toolss      r   r0   zDrHistoryManager._get_toolÊ   sM   € Ø�k‰k× Ñ ×&Ñ&€)Ø�	ÑØ
�GÑ
Ðà‡;�;×Ñ×*Ñ*¬1Ð-BÀWÑ-LÓ+MÕNr   N)Ú__name__Ú
__module__Ú__qualname__Ú__gtype_name__r   r   r   r   r,   r4   r6   r8   r;   r>   rR   rX   rZ   r^   r\   r)   rf   r#   r0   r   r   r   r   r      sn   „ Ø$€ò$òò
1òò+òCòGò%ò.+ò'ò
ò
ò6ò$òò.9ð 02ó ò,;óOr   r   N)Úgi.repositoryr   r   r   r   r   r   r   r   ú<module>rz      s   ð÷ 4Ó 3÷
GOò GOr   