³ò /üßEc@s dZdefd„ƒYZdS(só This module documents a class that creates the template editor's window. @author: Lateef Alabi-Oki @organization: The Scribes Project @copyright: Copyright © 2007 Lateef Alabi-Oki @license: GNU GPLv2 or Later @contact: mystilleef@gmail.com tTemplateWindowcBsŒeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„ZRS(s: This class creates the window for the template editor. cCsç|i||ƒ|iƒ|id|iƒ|_|id|iƒ|_|iid|iƒ|_ |iid|i ƒ|_ |id|i ƒ|_ |id|iƒ|_|id|iƒ|_|iid|iƒ|_d S( s4 Initialize object. @param self: Reference to the TemplateWindow instance. @type self: A TemplateWindow object. @param manager: Reference to the TemplateManager instance. @type manager: A TemplateManager object. @param editor: Reference to the text editor. @type editor: An Editor object. tdestroytshows delete-eventskey-press-eventt importings import-errort sensitivesdrag-data-receivedN(t _TemplateWindow__init_attributest_TemplateWindow__set_propertiestconnectt_TemplateWindow__destroy_cbt_TemplateWindow__signal_id_1t_TemplateWindow__show_cbt_TemplateWindow__signal_id_2t_TemplateWindow__windowt _TemplateWindow__delete_event_cbt_TemplateWindow__signal_id_3t#_TemplateWindow__key_press_event_cbt_TemplateWindow__signal_id_4t_TemplateWindow__importing_cbt_TemplateWindow__signal_id_5t _TemplateWindow__import_error_cbt_TemplateWindow__signal_id_6t_TemplateWindow__sensitive_cbt_TemplateWindow__signal_id_7t&_TemplateWindow__drag_data_received_cbt_TemplateWindow__signal_id_8(tselftmanagerteditor((s plugins/TemplateEditor/Window.pyt__init__$s  cCsr||_||_t|_d|_|_|_d|_|_ |_ d|_ |_ |i idƒ|_dS(s= Initialize data attributes. @param self: Reference to the TemplateWindow instance. @type self: A TemplateWindow object. @param manager: Reference to the TemplateManager instance. @type manager: A TemplateManager object. @param editor: Reference to the text editor. @type editor: An Editor object. tTemplateEditorWindowN(t_TemplateWindow__managert_TemplateWindow__editortFalset_TemplateWindow__is_visibletNoneR R RRRRRRtgladet get_widgetR (RRR((s plugins/TemplateEditor/Window.pyt__init_attributes<s   cCsÙddkl}||iiddƒ\}}|iid|ƒ|iid|ƒddkl}l}|iid|ƒ|iidt ƒ|ii |iiƒdg}dd k l }|ii |||ƒd S(s~ Set default properties. @param self: Reference to the TemplateWindow instance. @type self: A TemplateWindow object. iÿÿÿÿ(t!calculate_resolution_independencegš™™™™™ù?s default-widthsdefault-height(tWIN_POS_CENTER_ON_PARENTtDEST_DEFAULT_ALLswindow-positionsdestroy-with-parents text/uri-listiio(t ACTION_COPYN(s text/uri-listiio(t SCRIBES.utilsR&RtwindowR t set_propertytgtkR'R(tTruetset_transient_fortgtk.gdkR)t drag_dest_set(RR&twidththeightR'R(ttargetsR)((s plugins/TemplateEditor/Window.pyt__set_propertiesRs cCsA|iiƒ|iiƒt|_|iiƒ|iiƒdS(ss Show window. @param self: Reference to the TemplateWindow instance. @type self: A TemplateWindow object. N(RtresponseR tshow_allR.R!tpresent(R((s plugins/TemplateEditor/Window.pyt __show_windowfs      cCsD|iiƒ|iiƒt|_|iidƒ|iiƒdS(ss Hide window. @param self: Reference to the TemplateWindow instance. @type self: A TemplateWindow object. thideN(RR6R R:R R!Rtemit(R((s plugins/TemplateEditor/Window.pyt __hide_windowts     c CsyÄddkl}l}ddkl}l}ddkl}l}|ii dƒ||d ƒo |‚nddk l }||ƒ} || ƒo t ‚n| dd} |ii d| ƒWnQ|j oIddkl} |iii| d |iƒ|ii d ƒ|‚nþ|j oIdd kl} |iii| d |iƒ|ii d ƒ|‚nª|j oIdd kl} |iii| d |iƒ|ii d ƒ|‚nVt j oIdd kl} |iii| d |iƒ|ii d ƒ|‚nXd S(sŠ Import templates from an XML file. @param self: Reference to the TemplateWindow instance. @type self: An TemplateWindow object. iÿÿÿÿ(tFileNotFoundErrortInvalidFileError(tValidationErrort DragDropError(tis_tnot_R(timport_template_from_filesimported-language(tmsg0013t parent_windows import-error(tmsg0014(tmsg0015N(t ExceptionsR=R>R?R@toperatorRARBRR;R"tImportTemplateRCt NoDataErrorti18nRDRt error_dialogt show_messageR RFRG(Rtxml_template_fileR=R>R?R@RARBRCt templatestlanguageRDRFRG((s plugins/TemplateEditor/Window.pyt__import_template‚s@     cCsÃddkl}l}||i|ƒ||i|ƒ||i|iƒ||i|iƒ||i|ƒ||i |ƒ||i |ƒ||i |iƒ|ii ƒ||ƒd}~dS(s Handles callback when the "destroy" signal is emitted. @param self: Reference to the TemplateWindow instance. @type self: A TemplateWindow object. @param manager: Reference to the TemplateManager instance. @type manager: A TemplateManager object. iÿÿÿÿ(tdisconnect_signaltdelete_attributesN(R*RSRTR R RR RRRRRRR"(RRRSRT((s plugins/TemplateEditor/Window.pyt __destroy_cbªs   cCs|iƒdS(sý Handles callback when the "show" signal is emitted. @param self: Reference to the TemplateWindow instance. @type self: A TemplateWindow object. @param self: Reference to the TemplateManager instance. @type self: A TemplateManager object. N(t_TemplateWindow__show_window(RR((s plugins/TemplateEditor/Window.pyt __show_cbÃs cGs|iƒtS(s¢ Handles callback when the "delete-event" signal is emitted. @param self: Reference to the TemplateWindow instance. @type self: A TemplateWindow object. (t_TemplateWindow__hide_windowR.(Rtargs((s plugins/TemplateEditor/Window.pyt__delete_event_cbÐs cCsjddkl}l}||iƒotSnddkl}||i|iƒotSn|i ƒt S(sÏ Handles callback when the "key-press-event" signal is emitted. @param self: Reference to the TemplateEditorWindow instance. @type self: A TemplateEditorWindow object. @param window: The template editor's window. @type window: A TemplateEditorWindow object. @param event: An event that occurs when the close button is pressed. @type event: A gtk.Event object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. iÿÿÿÿ(RBtne(tkeysyms( RIRBR[R!R R-R\tkeyvaltEscapeRXR.(RR+teventRBR[R\((s plugins/TemplateEditor/Window.pyt__key_press_event_cbÚs  cCsA|iiƒ|iiiƒ|iidtƒ|iiƒdS(s Handles callback when the "importing" signal is emitted. @param self: Reference to the TemplateWindow instance. @type self: A TemplateWindow object. @param manager: Reference to the TemplateManager instance. @type manager: A TemplateManager object. RN(RR6tfeedbacktstart_busy_cursorR R,R (RR((s plugins/TemplateEditor/Window.pyt__importing_cbñs  cCsA|iiƒ|iiiƒ|iidtƒ|iiƒdS(s  Handles callback when the "import-error" signal is emitted. @param self: Reference to the TemplateWindow instance. @type self: A TemplateWindow object. @param manager: Reference to the TemplateManager instance. @type manager: A TemplateManager object. RN(RR6Ratstop_busy_cursorR R,R.(RR((s plugins/TemplateEditor/Window.pyt__import_error_cbs  cCs1|iiƒ|iid|ƒ|iiƒdS(NR(RR6R R,(RRR((s plugins/TemplateEditor/Window.pyt__sensitive_cbs  c CsÏddkl}l} ||dƒotSn|iiƒ|iƒ} ddkl} ddk l } xa| D]Y} y:| | i dƒƒownn| | ƒ}|i |ƒWqn| j o qnqnXqnWtS(s Handles callback when the "drag-data-received" signal is emitted. @param self: Reference to the TemplateEditorWindow instance. @type self: A TemplateEditorWindow object. @param window: Reference to the TemplateEditorWindow. @type window: A TemplateEditorWindow object. @param context: An object containing data about a drag selection. @type context: A gtk.DragContextData object. @param x: The x-cordinate of the drop. @type x: An Integer object. @param y: The y-cordinate of the drop. @type y: An Integer object. @param selection_data: Data representing the drag selection. @type selection_data: A gtk.SelectionData object. @param info: A unique identification for the text editor. @type info: An Integer object. @param time: The time the drop operation occurred. @type time: An Integer object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. iÿÿÿÿ(R[RBio(tget_local_path_from_uri(R@sfile:///( RIR[RBR.R R8tget_uristgnomevfsRgRHR@t startswitht _TemplateWindow__import_template(RR+tcontexttxtytselection_datatinfottimeR[RBturisRgR@turit local_path((s plugins/TemplateEditor/Window.pyt__drag_data_received_cbs    (t__name__t __module__t__doc__RRRRVRXRkRR R RRRRR(((s plugins/TemplateEditor/Window.pyRs      (     N(RxtobjectR(((s plugins/TemplateEditor/Window.pyss