KKFc@s0dZddklZdefdYZdS(s This module documents a class that creates the treeview for the 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(tTreeViewtCompletionTreeViewcBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZRS(sF This class implements the treeview for the word completion window. cCsti||i||||i|i|id|i|_|id|i|_ |id|i |_ |id|i |_ |id|i|_|iid|i|_|id|i|_|idS( s Initialize 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. @param editor: Reference to the text editor. @type editor: An Editor object. @param completion: Reference to the WordCompletionManager instance. @type completion: A WordCompletionManager object. tdestroys match-founds row-activatedsbutton-press-events is-visibleskey-press-eventscursor-changedN(Rt__init__t$_CompletionTreeView__init_attributest#_CompletionTreeView__set_propertiest'_CompletionTreeView__precompile_methodstconnectt_CompletionTreeView__destroy_cbt _CompletionTreeView__signal_id_1t#_CompletionTreeView__match_found_cbt _CompletionTreeView__signal_id_2t%_CompletionTreeView__row_activated_cbt _CompletionTreeView__signal_id_3t'_CompletionTreeView__button_press_eventt _CompletionTreeView__signal_id_4t"_CompletionTreeView__is_visible_cbt _CompletionTreeView__signal_id_5ttextviewt'_CompletionTreeView__key_press_event_cbt _CompletionTreeView__signal_id_7t&_CompletionTreeView__cursor_changed_cbt _CompletionTreeView__signal_id_8t#_CompletionTreeView__block_textview(tselftmanagerteditort completion((s%plugins/WordCompletionGUI/TreeView.pyR's   cCsg||_||_||_|i|_|i|_|i|_t |_ t |_ g|_ dS(s Initialize data attributes. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView 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. N( t_CompletionTreeView__editort_CompletionTreeView__managert_CompletionTreeView__completiont!_CompletionTreeView__create_modelt_CompletionTreeView__modelt$_CompletionTreeView__create_renderert_CompletionTreeView__renderert"_CompletionTreeView__create_columnt_CompletionTreeView__columntFalset_CompletionTreeView__is_blockedt_CompletionTreeView__is_visiblet_CompletionTreeView__word_list(RRRR((s%plugins/WordCompletionGUI/TreeView.pyt__init_attributesDs      cCs|i|i|it|idt|idt|id|iddkl}ddk l }l }|i i i}|i|}|i||dS(s Define the view object's properties. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. s rules-hintshover-selectiontmodeli(t color_parse(tSTATE_SELECTEDt STATE_ACTIVEN(t append_columnR$tset_headers_visibleR%t set_propertytTrueR tgtk.gdkR+tgtkR,R-RRt get_styletbaset modify_base(RR+R,R-tstyletcolor((s%plugins/WordCompletionGUI/TreeView.pyt__set_properties_s  cCsddkl}|||iow||_|iiddkl}x@|iD]5}|ii|g|i||i |_ qSW|i n|i i d|iid|dS(s Populate the view's data model. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. i(tne(tidle_addispopulated-modelN(toperatorR:R(R tcleartgobjectR;tappendt%_CompletionTreeView__stop_populate_idt_CompletionTreeView__responset&_CompletionTreeView__populate_model_idtcolumns_autosizet get_selectiont select_pathRtemit(Rtcompletion_listR:R;tword((s%plugins/WordCompletionGUI/TreeView.pyt__populate_modelxs    cCs/y!ddkl}||iWnnXdS(Ni(t source_remove(R>RJRB(RRJ((s%plugins/WordCompletionGUI/TreeView.pyt__stop_populate_ids cCs|iitS(N(RtresponseR%(R((s%plugins/WordCompletionGUI/TreeView.pyt __responses cCs|i}||ddid}ddkl}t||iiid}||}|iii|iii||iii ddk l }|ii i |ddS(s Insert items selected in the completion window into the text editor's buffer. @param path: The selected row in the completion window. @type path: A gtk.TreeRow object. @param editor: Reference to the editor object. @type editor: An editor object. itutf8i(tget_word_before_cursor(tmsg0001tsucceedN(R tdecodetSCRIBES.cursorROtlenRt textbuffertbegin_user_actiontinsert_at_cursortend_user_actionti18nRPtfeedbacktupdate_status_message(RtpathR*tcompletion_stringROtindextstringRP((s%plugins/WordCompletionGUI/TreeView.pyt__insert_word_completions ! cCsHy.ddkl}||i||iWntj onXdS(Ni(tbind(tpsycoRat#_CompletionTreeView__populate_modelt+_CompletionTreeView__insert_word_completiont ImportError(RRa((s%plugins/WordCompletionGUI/TreeView.pyt__precompile_methodss cCs ddkl}|t}|S(s Create the view's model, or database. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. i(t ListStore(R3Rgtstr(RRgR*((s%plugins/WordCompletionGUI/TreeView.pyt__create_models cCsddkl}|}|S(s Create the view's text renderer. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. i(tCellRendererText(R3Rj(RRjtrenderer((s%plugins/WordCompletionGUI/TreeView.pyt__create_renderers cCs9ddkl}|d|idd}|it|S(s Create the view's column. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. i(tTreeViewColumntttexti(R3RmR"t set_expandR%(RRmtcolumn((s%plugins/WordCompletionGUI/TreeView.pyt__create_columns cCsddkl}l}||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.utilsRsRtR R RR RRRRRRtNone(RRRsRt((s%plugins/WordCompletionGUI/TreeView.pyt __destroy_cbs   cCs|i|dS(s Handles callback when the "match-found" signal is emitted. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. @param completion: Reference to the WordCompletionManager instance. @type completion: A WordCompletionManager object. @param completion_list: A list of words for completion. @type completion_list: A List object. N(Rc(RRRG((s%plugins/WordCompletionGUI/TreeView.pyt__match_found_cbs cCsMyt|_|i|Wntj onX|iidt|_tS(s- Handles callback when the "row-activated" signal is emitted. @param self: Reference to the CompletionView instance. @type self: A CompletionView object. @param treeview: The text editor's completion window's view. @type treeview: A CompletionView object. @param path: An object representing a row in the view. @type path: A Path object. @param column: The text editor's completion window's view's column. @type column: A gtk.TreeViewColumn object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. s hide-window(R%R'RdtAttributeErrorRRFR1(RttreeviewR\Rq((s%plugins/WordCompletionGUI/TreeView.pyt__row_activated_cbs  cCsP|i}|i\}}|i|}|id}|i||tS(s Handles callback when the "button-press-event" signal is emitted. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. @param treeview: The text editor's completion window's view. @type treeview: A CompletionTreeView object. @param event: An event that occurs when the right mouse button is pressed. @type event: A gtk.Event object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. i(RDt get_selectedtget_patht get_columnt row_activatedR1(RRzteventt selectionR*titeratorR\Rq((s%plugins/WordCompletionGUI/TreeView.pyt__button_press_event2s  c Csddkl}l}l}||iotSn|i}|i\}}||o#|id|i\}}n|i |} ddk l } ||i | i o|i| |idn ||i | iow|| do2t|} |i| d|i| dq|i| ddf|i| ddfn|||i | ioa|i|} | o-|i| |i | } |i| q|id|idntStS(s Handles callback when the "key-press-event" signal is emitted. This function allows the "Up" and "Down" arrow keys to work in the word completion window. @param self: Reference to the CompletionView instance. @type self: A CompletionView object. @param treeview: The text editor's completion view. @type treeview: A CompletionView object. @param event: An event that occurs when keys are pressed. @type event: A gtk.Event object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. i(tnot_teqttruthi(tkeysymsi(i(R<RRRR'R%RDR|RER}R3RtkeyvaltReturnRR~tUpRTtscroll_to_celltDownt iter_nextt select_iterR1( RRzRRRRRR*RR\Rtnumber_of_rowst next_iterator((s%plugins/WordCompletionGUI/TreeView.pyt__key_press_event_cbMs8      cCsbddkl}|o4t|_|i|i|iidnt|_|i dS(s Handles callback when the "is-visible" signal is emitted. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. @param manager: Reference to the CompletionManager instance. @type manager: A CompletionManager object. @param is_visible: Whether or not the word completion window is visible. @type is_visible: A Boolean object. i(RiN( R<RR1R'RCt%_CompletionTreeView__unblock_textviewRDRER%R(RRt is_visibleR((s%plugins/WordCompletionGUI/TreeView.pyt__is_visible_cbs      cCsKddkl}||iodSn|iii|it|_dS(s Unblock textview's "key-press-event" signal. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. i(RN(R<RR&RRthandler_unblockRR%(RR((s%plugins/WordCompletionGUI/TreeView.pyt__unblock_textviews  cCsKddkl}||iodSn|iii|it|_dS(s Block textview's "key-press-event" signal. The "key-press-event" signal is only useful when the word completion window is visible. @param self: Reference to the CompletionTreeView instance. @type self: A CompletionTreeView object. i(RN(R<RR&RRt handler_blockRR1(RR((s%plugins/WordCompletionGUI/TreeView.pyt__block_textviews  cGs|iidtS(Ni(RDRER%(Rtargs((s%plugins/WordCompletionGUI/TreeView.pyt__cursor_changed_cbs(t__name__t __module__t__doc__RRRRcR@RARdRRR!R#RR R RRRRRR(((s%plugins/WordCompletionGUI/TreeView.pyR"s*              >  N(RR3RR(((s%plugins/WordCompletionGUI/TreeView.pyss