łň •BFc@s dZdefd„ƒYZdS(s This module documents a class that defines the behavior of the add dialog from the template editor. @author: Lateef Alabi-Oki @organization: The Scribes Project @copyright: Copyright Š 2007 Lateef Alabi-Oki @license: GNU GPLv2 or Later @contact: mystilleef@gmail.com t AddDialogcBseZdZd„Zd„Zd„Zd„Zed„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„ZRS(s6 This class defines the behavior of the add dialog. cCsŘ|i|||ƒ|iƒ|id|iƒ|_|id|iƒ|_|iid|iƒ|_ |i id|i ƒ|_ |i id|iƒ|_|iid|iƒ|_|iid|iƒ|_dS(sŇ Initialize object. @param self: Reference to the AddDialog instance. @type self: A AddDialog 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. @param language: The language of category of a template. @type language: A String object. @param trigger: A template trigger. @type trigger: A String object. tdestroyslanguage-selecteds delete-eventtclickedtchangedskey-press-eventN(t_AddDialog__init_attributest_AddDialog__set_propertiestconnectt_AddDialog__destroy_cbt_AddDialog__signal_id_1t _AddDialog__language_selected_cbt_AddDialog__signal_id_2t_AddDialog__dialogt_AddDialog__delete_event_cbt_AddDialog__signal_id_3t_AddDialog__save_buttont_AddDialog__save_clicked_cbt_AddDialog__signal_id_4t_AddDialog__cancel_buttont_AddDialog__cancel_clicked_cbt_AddDialog__signal_id_5t_AddDialog__name_entryt_AddDialog__changed_cbt_AddDialog__signal_id_6t_AddDialog__key_press_event_cbt_AddDialog__signal_id_7(tselftmanagerteditortlanguage((s#plugins/TemplateEditor/AddDialog.pyt__init__%s c Cs<ddkl}l}|tƒdƒd}||dƒ}ddkl}||ddd ƒ|_} | idƒ|_||_ ||_ ||_ | id ƒ|_ | id ƒ|_ | id ƒ|_| id ƒ|_| idƒ|_ddkl} | |||ƒ|_| idƒ|_| idƒ|_dS(sŘ Initialize data attributes. @param self: Reference to the AddDialog instance. @type self: A AddDialog 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. @param language: The language category of a template. @type language: A String object. @param trigger: A template trigger. @type trigger: A String object. i˙˙˙˙(tjointsplitt__file__isTemplate.glade(tXMLt EditorDialogtdomaintscribestEditorDialogNameLabeltEditorDialogDescriptionLabeltEditorDialogTemplateLabeltEditorDialogNameEntrytEditorDialogDescriptionEntry(tEditortEditorDialogSaveButtontEditorDialogCancelButtonN(tos.pathRRtglobalst gtk.gladeR!t_AddDialog__gladet get_widgetR t_AddDialog__managert_AddDialog__editort_AddDialog__languaget_AddDialog__name_labelt_AddDialog__description_labelt_AddDialog__buffer_labelRt_AddDialog__description_entryR*t_AddDialog__bufferRR( RRRRRRtcurrent_foldert glade_fileR!tgladeR*((s#plugins/TemplateEditor/AddDialog.pyt__init_attributesBs&   cCs.|iidƒ}|i|iƒddkl}||iiddƒ\}}|ii d|ƒ|ii d|ƒddk l }|ii d |ƒ|ii d d ƒ|ii |i iid ƒƒ|ii|iƒ|ii|iƒ|ii|iƒ|ii d tƒ|ii d tƒdS(su Set default properties. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. tEditorDialogScrolledWindowi˙˙˙˙(t!calculate_resolution_independenceig @s default-widthsdefault-height(tmsg0009ttitles icon-namesgnome-settingstTemplateEditorWindowt sensitiveN(R0R1taddR9t SCRIBES.utilsR?R3twindowR t set_propertyti18nR@tset_transient_forR2R<R5tset_mnemonic_widgetRR6R8R7tFalse(Rt scrollwinR?twidththeightR@((s#plugins/TemplateEditor/AddDialog.pyt__set_propertiesis cCs|iidtƒ|iidƒ|iidƒ|iiƒidƒ|iiƒ|i i ƒ|i i ƒ|i i ƒdS(sj Show dialog. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. RCtN( R2temitRKRtset_textR8R9t get_buffert grab_focusR3tresponseR tshow_all(R((s#plugins/TemplateEditor/AddDialog.pytshows    cCs>|iiƒ|iid|ƒ|iiƒ|iiƒdS(sj Hide dialog. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. RCN(R3RUR2RQR thide(RRC((s#plugins/TemplateEditor/AddDialog.pyt__hide’s    c CsËddkl}l}ddkl}l}||iiƒiƒƒo |‚n|i |iiƒiƒ}ddk l }ddk l }|ƒ}|i ƒ} ||ƒ|| |ƒo |‚ndS(s Validate template trigger. Whether or not the trigger entered in the name entry field is valid. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. i˙˙˙˙(tnot_tcontains(t EntryErrortSameTriggerError(topen_template_database(tclose_template_databaseN(toperatorRZR[t ExceptionsR\R]Rtget_texttstripR4tMetadataR^R_tkeys( RRZR[R\R]t database_keyR^R_tdatabaseRe((s#plugins/TemplateEditor/AddDialog.pyt__check_name_entryŸs &   c CsŽ|iiƒiƒ}|iiƒiƒ}|iiƒ}|iƒ\}}|i||ƒ}ddkl}ddkl }|dƒ} ||f| |i |<|| ƒdS(s{ Update the template database. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. i˙˙˙˙(R^(R_twN( RRbRcR8R9RSt get_boundsRdR^R_R4( Rttriggert descriptiont txtbuffertstarttendttemplateR^R_Rg((s#plugins/TemplateEditor/AddDialog.pyt__update_template_databaseľs  cCsÓddkl}l}||i|ƒ||i|ƒ||i|iƒ||i|iƒ||i |i ƒ||i |i ƒ||i |iƒ|iiƒ|i iƒ|iiƒ||ƒd}~dS(sô Handles callback when the "destroy" signal is emitted. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. @param manager: Reference to the TemplateManager. @type manager: A TemplateManager object. i˙˙˙˙(tdelete_attributestdisconnect_signalN(RERrRsRR R R RRRRRRRRtNone(RRRrRs((s#plugins/TemplateEditor/AddDialog.pyt __destroy_cbČs     cGs|iƒtS(sœ Handles callback when the "key-press-event" signal is emitted. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. (t_AddDialog__hidetTrue(Rtargs((s#plugins/TemplateEditor/AddDialog.pyt__delete_event_cbâs cGsáy]ddkl}l}|iƒ|itƒ|iid|ii ƒi ƒƒ|i ƒWn}|j o3ddk l }|iii|d|iƒn@|j o3ddk l}|iii|d|iƒnXtS(sč Handles callback when the "clicked" signal is emitted. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. i˙˙˙˙(R\R]strigger-selected(tmsg0007t parent_window(tmsg0008(RaR\R]t_AddDialog__check_name_entryRvRKR2RQRRbRct$_AddDialog__update_template_databaseRHRzR3t error_dialogt show_messageR R|Rw(RRxR\R]RzR|((s#plugins/TemplateEditor/AddDialog.pyt__save_clicked_cběs   " !cGs|iƒtS(sč Handles callback when the "clicked" signal is emitted. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. (RvRw(RRx((s#plugins/TemplateEditor/AddDialog.pyt__cancel_clicked_cbs cCsŞ|iiƒ|iiƒiƒo=|iidtƒ|iidtƒ|i idtƒn:|iidt ƒ|iidt ƒ|i idt ƒ|iiƒt S(s7 Handles callback when the "changed" signal is emitted. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. @param entry: The name text entry field. @type entry: A gtk.Entry object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. RC( R3RURRbRcR8RGRwR9RRK(Rtentry((s#plugins/TemplateEditor/AddDialog.pyt __changed_cbs  cCs ||_dS(s] Handles callback when the "language-selected" signal is emitted. @param self: Reference to the AddDialog instance. @type self: An AddDialog object. @param manager: Reference to the TemplateManager instance. @type manager: A TemplateManager object. @param language: Language category of template. @type language: A String object. N(R4(RRR((s#plugins/TemplateEditor/AddDialog.pyt__language_selected_cb*s cCsLddkl}ddkl}||i|iƒotSn|iƒtS(Ni˙˙˙˙(tkeysyms(tne( tgtkR†R`R‡tkeyvaltEscapeRKRvRw(RtdialogteventR†R‡((s#plugins/TemplateEditor/AddDialog.pyt__key_press_event_cb:s  (t__name__t __module__t__doc__RRRRWRwRvR}R~RR RRRR R(((s#plugins/TemplateEditor/AddDialog.pyR s  '        N(RtobjectR(((s#plugins/TemplateEditor/AddDialog.pyss