³ņ —żEFc@s0dZddklZdefd„ƒYZdS(sü This module documents a class that creates the window for word completion window. @author: Lateef Alabi-Oki @organization: The Scribes Project @copyright: Copyright Ā© 2007 Lateef Alabi-Oki @license: GNU GPLv2 or Later @contact: mystilleef@gmail.com i’’’’(tWindowtCompletionWindowcBsžeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„ZRS(s= This class creates the window object for word completion. cCs!ddkl}ti||ƒ|i|||ƒ|iƒ|iƒ|id|iƒ|_ |id|i ƒ|_ |id|i ƒ|_ |iid|iƒ|_|iid|i ƒ|_|iid|i ƒ|_|id |i ƒ|_|iid |iƒ|_|iƒd S( s< Initialize object. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. @param manager: Reference to the CompletionManager instance. @type manager: A CompletionManager object. @param editor: Reference to the text editor. @type editor: An Editor object. i’’’’(t WINDOW_POPUPtdestroys show-windows hide-windowskey-press-eventsfocus-out-events delete-rangesno-match-foundsbutton-press-eventN(tgtkRRt__init__t"_CompletionWindow__init_attributest!_CompletionWindow__set_propertiest%_CompletionWindow__precompile_methodstconnectt_CompletionWindow__destroy_cbt_CompletionWindow__signal_id_1t!_CompletionWindow__show_window_cbt_CompletionWindow__signal_id_2t"_CompletionWindow__generic_hide_cbt_CompletionWindow__signal_id_3twindowt%_CompletionWindow__key_press_event_cbt_CompletionWindow__signal_id_5ttextviewt_CompletionWindow__signal_id_6t textbuffert_CompletionWindow__signal_id_7t_CompletionWindow__signal_id_8t(_CompletionWindow__button_press_event_cbt_CompletionWindow__signal_id_9t _CompletionWindow__block_signals(tselftmanagerteditort completionR((s#plugins/WordCompletionGUI/Window.pyR's   c Cs||_||_||_t|i_|_t|_ddkl }|i |i |i |i |i|i|i|i|i|ig |_dS(sĄ Initialize data attributes. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. @param manager: Reference to the CompletionManager instance. @type manager: A CompletionManager object. @param editor: Reference to the text editor. @type editor: An Editor object. @param completion: Reference to the WordCompletionManager instance. @type completion: A WordCompletionManager object. i’’’’(tkeysymsN(t_CompletionWindow__editort_CompletionWindow__managert_CompletionWindow__completiontFalset is_visiblet_CompletionWindow__is_visibletTruet&_CompletionWindow__signals_are_blockedRRtTabtRighttLefttHometEndtInserttDeletetPage_Upt Page_DowntEscapet_CompletionWindow__keys(RRRRR((s#plugins/WordCompletionGUI/Window.pyt__init_attributesCs    cCsDddkl}|id|ƒ|iddƒ|iddƒdS(s Define the completion window's default properties. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. i’’’’(tWINDOW_TYPE_HINT_MENUs type-hints width-requestiČsheight-requestN(tgtk.gdkR4t set_property(RR4((s#plugins/WordCompletionGUI/Window.pyt__set_properties`s cCsp|iidtƒddkl}||iƒodSn||iƒo|iƒn|iƒt|_dS(s† Show the completion window. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. s is-visiblei’’’’(ttruthN( R!temitR&toperatorR8R%R't"_CompletionWindow__unblock_signalstshow_all(RR8((s#plugins/WordCompletionGUI/Window.pyt __show_windowss  cCs|iidtƒddkl}l}||iƒodSn|iiƒ||i ƒo|i ƒn|i ƒt|_|iiƒdS(s† Hide the completion window. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. s is-visiblei’’’’(tnot_R8N( R!R9R#R:R>R8R%R tresponseR'Rthide_all(RR>R8((s#plugins/WordCompletionGUI/Window.pyt __hide_window…s    cCs’ddkl}l}||iiƒ\}}||iiƒd}ddkl}|iii|ƒ} |iiiƒ} | i ƒ\} } | i | i } }| |}| ||}ddk l }l}l}|||| | ƒo| | |}n|||| |ƒo| ||}n||iƒoF|||iƒdƒo$|iƒd}|i||ƒndSn|i||ƒdS(sč Position the completion window in the text editor's buffer. @param width: The completion window's width. @type width: An Integer object. @param height: The completion window's height. @type height: An Integer object. i’’’’(tget_cursor_window_coordinatestget_cursor_sizei(tTEXT_WINDOW_TEXT(tgtR>tneiN(tSCRIBES.cursorRBRCR RRRDt get_windowtget_visible_rectt get_origintwidththeightR:RER>RFR't get_positiontmove(RRKRLRBRCtcursor_xtcursor_yt cursor_heightRDRt rectangletwindow_xtwindow_yt window_widtht window_heightt position_xt position_yRER>RF((s#plugins/WordCompletionGUI/Window.pyt__position_window—s,  cCs8ddkl}||dƒo d}n |d7}|S(s> Calculate the completion window's height. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. @param height: The completion window's view's height. @type height: An Integer object. @return: The height of the completion window. @rtype: An Integer object. i’’’’(tleiČi(R:RZ(RRKRZ((s#plugins/WordCompletionGUI/Window.pyt__calculate_window_width¾s   cCs.ddkl}||dƒo d}n|S(s> Calculate the completion window's height. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. @param height: The completion window's view's height. @type height: An Integer object. @return: The height of the completion window. @rtype: An Integer object. i’’’’(REiČ(R:RE(RRLRE((s#plugins/WordCompletionGUI/Window.pyt__calculate_window_heightŅs  cCsˆ|ii|iƒ|ii|iƒ|iii|iƒ|iii|iƒ|ii i|i ƒ|i i|i ƒt |_dS(s˜ Block some signals when the window is hidden. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. N(R!t handler_blockR RR RRRRRRR"RR&R'(R((s#plugins/WordCompletionGUI/Window.pyt__block_signalsäs cCsˆ|ii|iƒ|ii|iƒ|iii|iƒ|iii|iƒ|ii i|i ƒ|i i|i ƒt |_dS(s Unblock signals when window is shown. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. N(R!thandler_unblockR RR RRRRRRR"RR#R'(R((s#plugins/WordCompletionGUI/Window.pyt__unblock_signalsōs cCs‰yoddkl}||iƒ||iƒ||iƒ||iƒ||iƒ||iƒ||iƒWnt j onXdS(Ni’’’’(tbind( tpsycoRat"_CompletionWindow__position_windowt*_CompletionWindow__calculate_window_heightt)_CompletionWindow__calculate_window_widtht_CompletionWindow__show_windowt_CompletionWindow__hide_windowRR;t ImportError(RRa((s#plugins/WordCompletionGUI/Window.pyt__precompile_methodss      cCsĘddkl}l}||i|ƒ||i|ƒ||i|ƒ||i|iƒ||i|iƒ||i |iƒ||i |i ƒ||i |iƒ|i ƒ||ƒd}~dS(sü Destroy instance of this object. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. @param manager: Reference to the CompletionManager instance. @type manager: A CompletionManager object. i’’’’(tdelete_attributestdisconnect_signalN(t SCRIBES.utilsRjRkR R RRR RRRR"RRtNone(RRRjRk((s#plugins/WordCompletionGUI/Window.pyt __destroy_cbs   cGs|iƒdS(sŚ Generic callback handler to hide the window. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. @param args: Irrelevant arguments. @type args: A List object. N(Rg(Rtargs((s#plugins/WordCompletionGUI/Window.pyt__generic_hide_cb1s cCs†|iƒ\}}|i|ƒd}|i|ƒd}|i||ƒ|id|ƒ|id|ƒ|i||ƒ|iƒdS(sy Handles callback when the "show-window" signal is shown. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. @param manager: Reference to the CompletionManager instance. @type manager: A CompletionManager object. @param view: Reference to the CompletionTreeView instance. @type view: A CompletionTreeView object. is width-requestsheight-requestN(t size_requestReRdtresizeR6RcRf(RRtviewRKRL((s#plugins/WordCompletionGUI/Window.pyt__show_window_cb>s  cCs>ddkl}l}||i|iƒo|iƒntS(s Handles callback when the "key-press-event" signal is emitted. @param self: Reference to the CompletionWindow instance. @type self: A CompletionWindow object. @param window: Reference to the CompletionWindow instance. @type window: A CompletionWindow object. i’’’’(teqtcontains(R:RuRvR2tkeyvalRgR#(RRteventRuRv((s#plugins/WordCompletionGUI/Window.pyt__key_press_event_cbUs cGs|iƒtS(sŖ Handles callback when the "button-press-event" signal is emitted. @param self: Reference to the ScribesTextView instance. @type self: A ScribesTextView object. (RgR#(RRo((s#plugins/WordCompletionGUI/Window.pyt__button_press_event_cbds (t__name__t __module__t__doc__RRRRfRgRcReRdRR;RR RR RR(((s#plugins/WordCompletionGUI/Window.pyR"s"      '        N(R}RRR(((s#plugins/WordCompletionGUI/Window.pyss