Ë
    c­øc.  ã                   óF   — d dl Z d dlmZmZ  G d„ de«      Z G d„ d«      Zy)é    N)ÚGtkÚGdkc                   ó   ‡ — e Zd Zˆ fd„Zˆ xZS )ÚWrongToolIdExceptionc                 óZ   •— t        d«      }t        ‰| �	  |j                  ||«      «       y )Nz<Can't start operation: wrong tool id (expected {0}, got {1}))Ú_ÚsuperÚ__init__Úformat)ÚselfÚexpectedÚactualÚmsgÚ	__class__s       €ú7/usr/lib/python3/dist-packages/drawing/abstract_tool.pyr
   zWrongToolIdException.__init__   s&   ø€ ä	Ð
HÓI€#Ü�'Ñ�3—:‘:˜h¨Ó/Õ0ó    )Ú__name__Ú
__module__Ú__qualname__r
   Ú__classcell__)r   s   @r   r   r      s   ø„ ÷1ð 1r   r   c                   ód  — 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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%d#„ Z&d$„ Z'd%„ Z(d&„ Z)d'„ Z*d(„ Z+d)„ Z,d*„ Z-d+„ Z.d,„ Z/d-„ Z0d.„ Z1d/„ Z2d0„ Z3d1„ Z4d2„ Z5d3„ Z6d4„ Z7d5„ Z8d;d6„Z9d7„ Z:d8„ Z;d9„ Z<y:)<ÚAbstractAbstractToolz2Super-class implemented and extended by all tools.z'/com/github/maoschanz/drawing/tools/ui/c                 óÚ   — || _         || _        d| _        |x| _        | _        d| _        || _        d| _        d| _        d| _	        d| _
        d| _        g | _        | j                  «        y )Nr   Ú FÚcell)ÚwindowÚidÚmenu_idÚlabelÚ_mnemo_labelÚ_mnemo_charÚ
_icon_nameÚaccept_selectionÚ	use_colorÚuse_operatorÚcursor_nameÚ_ongoing_operationÚ_modifier_keysÚtry_build_pane)r   Útool_idr   Ú	icon_namer   Úkwargss         r   r
   zAbstractAbstractTool.__init__#   sp   € Ø€$„+à€$„'Ø€$„,Ø#(Ð(€$„*ˆtÔ Ø€$ÔØ€$„/à€$ÔØ€$„.Ø€$Ôà€$ÔØ!€$ÔØ€$Ôà×ÑÕr   c                 ó<   — | j                   j                  ||«       y)z¬Convenient wrapper method adding a stateless action to the window. It
		will be named 'action_name' (string) and activating the action will
		trigger the method 'callback'.N)r   Úadd_action_simple)r   Úaction_nameÚcallbacks      r   Úadd_tool_action_simplez+AbstractAbstractTool.add_tool_action_simple9   s   € ð
 ‡+�+×Ñ ¨XÕ6r   c                 óP   — | j                   j                  j                  ||«       y ©N)r   Úoptions_managerÚadd_option_boolean©r   r/   Údefaults      r   Úadd_tool_action_booleanz,AbstractAbstractTool.add_tool_action_boolean@   s   € Ø‡+�+×Ñ×0Ñ0°¸gÕFr   c                 óP   — | j                   j                  j                  ||«       y r3   )r   r4   Úadd_option_enumr6   s      r   Úadd_tool_action_enumz)AbstractAbstractTool.add_tool_action_enumC   s   € Ø‡+�+×Ñ×-Ñ-¨k¸7ÕCr   c                 óR   — | j                   j                  }|j                  ||«      S r3   )r   r4   Úadd_option_from_bool_key©r   r/   Úkey_nameÚoms       r   Úload_tool_action_booleanz-AbstractAbstractTool.load_tool_action_booleanF   ó$   € Ø‡{�{×"Ñ"€"Ø	×	$Ñ	$ [°(Ó	;Ð;r   c                 óR   — | j                   j                  }|j                  ||«      S r3   )r   r4   Úadd_option_from_enum_keyr>   s       r   Úload_tool_action_enumz*AbstractAbstractTool.load_tool_action_enumJ   rB   r   c                 óL   — | j                   j                  j                  |«      S r3   )r   r4   Ú	get_value)r   r/   s     r   Úget_option_valuez%AbstractAbstractTool.get_option_valueN   s   € Ø	�‰×	$Ñ	$×	.Ñ	.¨{Ó	;Ð;r   c                 óX   — | j                   j                  |«      j                  |«       y r3   )r   Úlookup_actionÚset_enabled)r   r/   Ústates      r   Úset_action_sensitivityz+AbstractAbstractTool.set_action_sensitivityQ   s   € Ø‡+�+×Ñ˜KÓ(×4Ñ4°UÕ;r   c                 ó,  — | j                  d| j                  «       | j                  d| j                  «       | j                  d| j                  «       | j                  d| j                  «       | j                  dd«       | j                  dd«       y )NÚ
main_colorÚsecondary_colorÚexchange_colorÚcairo_operatorÚcancel_transformFÚapply_transform)rM   r$   r%   ©r   s    r   Úupdate_actions_statez)AbstractAbstractTool.update_actions_stateT   sy   € Ø×Ñ˜l¨D¯N©NÔ;Ø×ÑÐ/°·±Ô@Ø×ÑÐ.°·±Ô?Ø×ÑÐ.°×0AÑ0AÔBà×ÑÐ0°%Ô8Ø×ÑÐ/°Õ7r   c                 óB   — | j                   j                  j                  S r3   )r   r4   Ú_tools_gsettingsrU   s    r   Úget_settingsz!AbstractAbstractTool.get_settings]   s   € Ø	�‰×	$Ñ	$×	5Ñ	5Ð5r   c                 ó:  — g }|t         j                  j                  z  t         j                  j                  k(  r|j                  d«       |t         j                  j                  z  t         j                  j                  k(  r|j                  d«       || _        y )NÚSHIFTÚALT)r   ÚModifierTypeÚ
SHIFT_MASKÚappendÚ	MOD1_MASKr(   )r   Úevent_stateÚmodifier_keyss      r   Úupdate_modifier_statez*AbstractAbstractTool.update_modifier_state`   su   € Ø€-à”C×$Ñ$×/Ñ/Ñ/´C×4DÑ4D×4OÑ4OÒOØ×Ñ˜Ô Ø”C×$Ñ$×.Ñ.Ñ.´3×3CÑ3C×3MÑ3MÒMØ×Ñ˜ÔØ%€$Õr   c                 ó:   — | j                   j                  |«       y r3   )r   Úreveal_message)r   Ú
error_texts     r   Ú
show_errorzAbstractAbstractTool.show_errorl   s   € Ø‡+�+×Ñ˜ZÕ(r   c                  ó   — y r3   © )r   Úevent_xÚevent_yÚmotion_behaviors       r   Úget_tooltipz AbstractAbstractTool.get_tooltipo   ó   € Ø	r   c                  ó   — y r3   ri   rU   s    r   r)   z#AbstractAbstractTool.try_build_paneu   ó   € Ør   c                  ó   — y r3   ri   rU   s    r   Úbuild_bottom_panez&AbstractAbstractTool.build_bottom_panex   rn   r   c                  ó   — y r3   ri   ©r   Úargss     r   Ú!on_apply_transform_tool_operationz6AbstractAbstractTool.on_apply_transform_tool_operation{   rp   r   c                  ó   — y r3   ri   rt   s     r   Ú"on_cancel_transform_tool_operationz7AbstractAbstractTool.on_cancel_transform_tool_operation~   rp   r   c                 ó   — t        d«      S )Nz
No options)r   rU   s    r   Úget_options_labelz&AbstractAbstractTool.get_options_label�   s   € Ü	
ˆ<‹Ðr   c                  ó   — y r3   ri   )r   Úavailable_widths     r   Úadapt_to_window_sizez)AbstractAbstractTool.adapt_to_window_size„   rp   r   c                 óV   — |j                  | j                  d| j                  z   «       y )Nzwin.active_tool::)r_   r    r   )r   Ú
tools_menus     r   Úadd_item_to_menuz%AbstractAbstractTool.add_item_to_menu‡   s"   € Ø×Ñ�D×%Ñ%Ð':¸T¿W¹WÑ'DÕEr   c                 ó    — | j                   dz   | j                  z   dz   }t        j                  j	                  |«      }|j                  d«      S )z³Returns a Gio.MenuModel corresponding to the tool's options. It'll be
		shown in the menubar (if any) and in the bottom pane (if the tool's
		bottom pane supports such a feature).ztool-z.uizoptions-menu)ÚUI_PATHr   r   ÚBuilderÚnew_from_resourceÚ
get_object)r   ÚfpathÚbuilders      r   Úget_options_modelz&AbstractAbstractTool.get_options_modelŠ   sE   € ð �,‰,˜Ñ
  4§7¡7Ñ
*¨UÑ
2€%Ü�K‰K×)Ñ)¨%Ó0€'Ø	×	Ñ	˜NÓ	+Ð+r   c                  ó   — y)zúReturns a Gtk.Widget (normally a box) corresponding to the tool's
		options. It'll be in the bottom pane (if the tool's bottom pane supports
		such a feature) in replacement of the Gio.MenuModel if such a simple
		menu can't provide all the features.Nri   rU   s    r   Úget_options_widgetz'AbstractAbstractTool.get_options_widget’   s   € ð
 
r   c                 ó   — | j                   gS r3   )r   rU   s    r   Úget_editing_tipsz%AbstractAbstractTool.get_editing_tips™   s   € Ø
�*‰*ˆÐr   c                 óx   — | j                   j                  |d|z   d«      | _        |j                  «       | _        y )Nr   é   )r   Úreplacer    Úupperr!   )r   Ú	characters     r   Úset_mnemonicsz"AbstractAbstractTool.set_mnemonicsŸ   s0   € Ø—j‘j×(Ñ(¨°C¸)±OÀQÓG€$ÔØ—_‘_Ó&€$Õr   c                 ó0  — | j                   j                  j                  d«      rt        j                  j
                  }nt        j                  j                  }t        j                  «       j                  | j                  |«      }t        j                  t        j                  j                  dd¬«      | _        | j                  j                  |«       t        j                  d| j                   ¬«      }| j                  j                  |«       | j                  j#                  «        t        j                  dd| j$                  z   ¬«      }| j                  j                  |«       |j                  | j                  «       | j                  j'                  «       | _        | j$                  dk(  r&| j(                  j+                  | j,                  «       y
| j,                  dz   | j$                  z   d	z   }| j(                  j+                  |«       y
)z-Build the icon and its label for the sidebar.ú	big-iconsé   )ÚorientationÚspacingÚmarginT)Úuse_underliner   r   r   z (Alt+ú)N)r   Ú	gsettingsÚget_booleanr   ÚIconSizeÚLARGE_TOOLBARÚSMALL_TOOLBARÚImageÚnew_from_icon_namer"   ÚBoxÚOrientationÚ
HORIZONTALÚ
_label_boxÚaddÚLabelr    Úshow_allr!   Ú
get_parentÚ	_fb_childÚset_tooltip_textr   )r   ÚflowboxÚsizeÚimageÚlabel_widgetÚ
mini_labelÚtooltips          r   Úbuild_flowbox_childz(AbstractAbstractTool.build_flowbox_child£   sp  € ð 
‡[�[×Ñ×&Ñ& {Ô3Ü
�,‰,×
$Ñ
$�4ä
�,‰,×
$Ñ
$€4Ü
�)‰)‹+×
(Ñ
(¨¯©¸$Ó
?€%Ü—G‘GÜ�‰×)Ñ)ØØ
ô€$„/ð
 ‡/�/×Ñ�eÔô —‘¨°T×5FÑ5FÔG€,Ø‡/�/×Ñ�lÔ#Ø‡/�/×ÑÔô �y‰y t°3¸×9IÑ9IÑ3IÔJ€*Ø‡/�/×Ñ�jÔ!à	‡+�+ˆd�o‰oÔØ—?‘?×-Ñ-Ó/€$„.ð 
×Ñ˜ÒØ‡>�>×"Ñ" 4§:¡:Õ.à�Z‰Z˜(Ñ" T×%5Ñ%5Ñ5¸Ñ;€7Ø‡>�>×"Ñ" 7Õ+r   c                 ób   — | j                   j                  j                  | j                  «       y r3   )r   Útools_flowboxÚselect_childrª   rt   s     r   Úselect_flowbox_childz)AbstractAbstractTool.select_flowbox_childÅ   s   € Ø‡+�+×Ñ×(Ñ(¨¯©Õ8r   c                 ó6   — | j                   j                  «       S r3   )rª   Úis_selectedrU   s    r   Úis_flowbox_child_selectedz.AbstractAbstractTool.is_flowbox_child_selectedÈ   s   € Ø	�‰×	#Ñ	#Ó	%Ð%r   c                 óD  — | j                   j                  «       d   }|j                  |«       | j                   j                  «       d   }|r*|j                  t        j
                  j                  «       y |j                  t        j
                  j                  «       y )NrŽ   r   )r¥   Úget_childrenÚset_visibleÚ
set_halignr   ÚAlignÚSTARTÚCENTER)r   Úlabel_visibler¯   Úicons       r   Úset_show_labelz#AbstractAbstractTool.set_show_labelË   sk   € Ø—‘×-Ñ-Ó/°Ñ2€,Ø×Ñ˜=Ô)Ø	�‰×	%Ñ	%Ó	'¨Ñ	*€$ÙØ‡?�?”3—9‘9—?‘?Õ#à‡?�?”3—9‘9×#Ñ#Õ$r   c                 ó*  — | j                   j                  «       d   }| j                  j                  j	                  d«      rt
        j                  j                  }nt
        j                  j                  }|j                  | j                  |«       y )Nr   r”   )r¥   r»   r   r›   rœ   r   r�   rž   rŸ   Úset_from_icon_namer"   )r   r®   r­   s      r   Úupdate_icon_sizez%AbstractAbstractTool.update_icon_sizeÔ   sc   € Ø
�/‰/×
&Ñ
&Ó
(¨Ñ
+€%Ø	‡[�[×Ñ×&Ñ& {Ô3Ü
�,‰,×
$Ñ
$�4ä
�,‰,×
$Ñ
$€4Ø×Ñ˜4Ÿ?™?¨DÕ1r   c                 ó:  — | j                   dk(  ry | j                  j                  «       d   }|j                  «       ry | j                  j                  «       d   }| j                  j                  «       d   }|j	                  | «       |j	                  |«       y )Nr   rŽ   r   é   )r!   r¥   r»   Úget_visibler¼   )r   Úshould_showr¯   r®   r°   s        r   Úshow_only_mnemonicsz(AbstractAbstractTool.show_only_mnemonicsÜ   s…   € Ø	×Ñ˜ÒØ	Ø—‘×-Ñ-Ó/°Ñ2€,Ø×ÑÔØ	Ø
�/‰/×
&Ñ
&Ó
(¨Ñ
+€%Ø�‰×+Ñ+Ó-¨aÑ0€*à×Ñ˜�OÔ$Ø×Ñ˜Õ%r   c                  ó   — y r3   ri   rU   s    r   Úon_tool_selectedz%AbstractAbstractTool.on_tool_selectedë   rp   r   c                  ó   — y r3   ri   rU   s    r   Úon_tool_unselectedz'AbstractAbstractTool.on_tool_unselectedî   rp   r   c                 óÈ   — | j                  «        | j                  | j                  «       | j                  «        | j	                  «        | j                  «        d| _        y)zdReset the current tool when 'undo' is pressed while an operation has
		been started but not applied.FN)rÏ   Úgive_back_controlr#   rÍ   Úrestore_pixbufÚnon_destructive_show_modifr'   rU   s    r   Úcancel_ongoing_operationz-AbstractAbstractTool.cancel_ongoing_operationñ   sP   € ð ×ÑÔØ×Ñ˜×.Ñ.Ô/Ø×ÑÔØ×ÑÔØ×!Ñ!Ô#Ø!€$Õr   c                 óD   — | j                  «        | j                  «        y)z¢Reset the tool's state well enough to allow for a new tool to start.
		It should include unselecting/applying the selection if the next tool
		doesn't support it.N)rÒ   rÓ   )r   Úpreserve_selections     r   rÑ   z&AbstractAbstractTool.give_back_controlû   s   € ð ×ÑÔØ×!Ñ!Õ#r   c                 ó   — | j                   S r3   )r'   rU   s    r   Úhas_ongoing_operationz*AbstractAbstractTool.has_ongoing_operation  s   € Ø	×	 Ñ	 Ð r   c                  ó   — y r3   ri   ©r   Ú	operations     r   Údo_tool_operationz&AbstractAbstractTool.do_tool_operation  rp   r   c                 óˆ   — |d   | j                   k7  rt        |d   | j                   «      ‚| j                  «        d| _        y )Nr*   T)r   r   rÒ   r'   rÚ   s     r   Ústart_tool_operationz)AbstractAbstractTool.start_tool_operation  s=   € ØˆyÑ˜TŸW™WÒ$Ü	˜i¨	Ñ2°D·G±GÓ	<Ð<Ø×ÑÔØ €$Õr   c                 óž   — | j                  |«       | j                  «       j                  «        | j                  «       j                  «        y)z{Complete method to apply an operation: the operation is applied and
		the image is updated as well as the state of actions.N)Úsimple_apply_operationÚ	get_imagerV   Úupdate_history_sensitivityrÚ   s     r   Úapply_operationz$AbstractAbstractTool.apply_operation  s8   € ð ×Ñ˜iÔ(Ø‡.�.Ó×'Ñ'Ô)Ø‡.�.Ó×-Ñ-Õ/r   c                 óô   — 	 | j                  |«       | j                  «       j                  |«       d| _        | j                  «        y# t        $ r$}| j	                  t        |«      «       Y d}~Œ@d}~ww xY w)z?Simpler apply_operation, for the 'rebuild from history' method.NF)rÜ   rá   Úadd_to_historyÚ	Exceptionrg   Ústrr'   rÓ   )r   rÛ   Úes      r   rà   z+AbstractAbstractTool.simple_apply_operation  se   € ðØ×Ñ˜)Ô$Ø‡>�>Ó×"Ñ" 9Ô-ð "€$ÔØ×!Ñ!Õ#øô 
ò Ø‡?�?”3�q“6×Ñûðús   ‚0A
 Á
	A7ÁA2Á2A7c                 ó6   — | j                  «       j                  S r3   )rá   Ú	selectionrU   s    r   Úget_selectionz"AbstractAbstractTool.get_selection%  s   € Ø	�‰Ó	×	#Ñ	#Ð#r   c                 ó6   — | j                  «       j                  S r3   )rë   Ú	is_activerU   s    r   Úselection_is_activez(AbstractAbstractTool.selection_is_active(  s   € Ø	×	Ñ	Ó	×	'Ñ	'Ð'r   c                 ó>   — | j                  «       j                  «       S r3   )rë   Ú
get_pixbufrU   s    r   Úget_selection_pixbufz)AbstractAbstractTool.get_selection_pixbuf+  s   € Ø	×	Ñ	Ó	×	(Ñ	(Ó	*Ð*r   c                 ó<   — d| j                  «       j                  z  S )NrŽ   )rá   Ú
zoom_levelrU   s    r   Úget_overlay_thicknessz*AbstractAbstractTool.get_overlay_thickness.  s   € Ø
ˆd�n‰nÓ×)Ñ)Ñ
)Ð*r   c                 ó6   — | j                   j                  «       S r3   )r   Úget_active_imagerU   s    r   rá   zAbstractAbstractTool.get_image4  s   € Ø	�‰×	%Ñ	%Ó	'Ð'r   c                 ó>   — | j                  «       j                  «       S r3   )rá   Úget_surfacerU   s    r   rø   z AbstractAbstractTool.get_surface7  s   € Ø	�‰Ó	×	%Ñ	%Ó	'Ð'r   c                 ó6   — | j                  «       j                  S r3   )rá   ÚSCALE_FACTORrU   s    r   Úscale_factorz!AbstractAbstractTool.scale_factor:  s   € Ø	�‰Ó	×	&Ñ	&Ð&r   c                 óH   — t        j                  | j                  «       «      S r3   )ÚcairoÚContextrø   rU   s    r   Úget_contextz AbstractAbstractTool.get_context=  s   € Ü	�‰�t×'Ñ'Ó)Ó	*Ð*r   c                 ó6   — | j                  «       j                  S r3   )rá   Úmain_pixbufrU   s    r   Úget_main_pixbufz$AbstractAbstractTool.get_main_pixbuf@  s   € Ø	�‰Ó	×	%Ñ	%Ð%r   c                 ó@   — | j                  «       j                  «        y r3   )rá   ÚupdaterU   s    r   rÓ   z/AbstractAbstractTool.non_destructive_show_modifC  s   € Ø‡.�.Ó×ÑÕr   c                 ó@   — | j                  «       j                  «        y r3   )rá   Úuse_stable_pixbufrU   s    r   rÒ   z#AbstractAbstractTool.restore_pixbufF  s   € Ø‡.�.Ó×$Ñ$Õ&r   c                  ó   — y r3   ri   ©r   ÚeventÚsurfacerj   rk   s        r   Úon_press_on_areaz%AbstractAbstractTool.on_press_on_areaL  rp   r   c                  ó   — y r3   ri   )r   r	  r
  rj   rk   Úrenders         r   Úon_motion_on_areaz&AbstractAbstractTool.on_motion_on_areaO  rp   r   c                  ó   — y r3   ri   )r   r	  r
  s      r   Úon_unclicked_motion_on_areaz0AbstractAbstractTool.on_unclicked_motion_on_areaR  rp   r   c                  ó   — y r3   ri   r  s        r   Úon_release_on_areaz'AbstractAbstractTool.on_release_on_areaU  rp   r   c                  ó   — y r3   ri   )r   ÚareaÚcairo_contexts      r   Úon_draw_abovez"AbstractAbstractTool.on_draw_aboveX  rp   r   N)T)=r   r   r   Ú__doc__Ú__gtype_name__r‚   r
   r1   r8   r;   rA   rE   rH   rM   rV   rY   rc   rg   rm   r)   rr   rv   rx   rz   r}   r€   rˆ   rŠ   rŒ   r’   r²   r¶   r¹   rÃ   rÆ   rË   rÍ   rÏ   rÔ   rÑ   rØ   rÜ   rÞ   rã   rà   rë   rî   rñ   rô   rá   rø   rû   rÿ   r  rÓ   rÒ   r  r  r  r  r  ri   r   r   r   r      s&  „ Ù9à(€Ø4€òò,7òGòDò<ò<ò<ò<ò8ò6ò&ò)òòòòòòòòFò,òòò'ò ,òD9ò&ò%ò2ò
&òòò"ò$ò!òò!ò0ò$ò$ò(ò+ò+ò(ò(ò'ò+ò&òò'òóòòór   r   )rý   Úgi.repositoryr   r   ræ   r   r   ri   r   r   ú<module>r     s%   ðó$ ß "ô1˜9ô 1÷|ò |r   