³ò ,–ÕEc@s6dZddklZlZdefd„ƒYZdS(s This module documents a class that implements the preview window for 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 iÿÿÿÿ(t SourceViewt SourceBuffertPreviewcBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( sE This class implements the preview window for the template editor. cCs‘ti|tƒƒ|i||ƒ|iƒ|id|iƒ|_|id|iƒ|_ |id|i ƒ|_ |id|i ƒ|_ dS(s& Initialize object. @param self: Reference to the Preview instance. @type self: A Preview 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. tdestroys description-treeview-sensitivitystemplate-selectedslanguage-selectedN(Rt__init__Rt_Preview__init_attributest_Preview__set_propertiestconnectt_Preview__destroy_cbt_Preview__signal_id_1t_Preview__sensitivity_cbt_Preview__signal_id_2t_Preview__template_selected_cbt_Preview__signal_id_3t_Preview__language_selected_cbt_Preview__signal_id_4(tselftmanagerteditor((s!plugins/TemplateEditor/Preview.pyR's  cCsK||_||_|idƒ|_|i|_d|_|_|_ dS(s/ Initialize data attributes. @param self: Reference to the Preview instance. @type self: A Preview 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. tbufferN( t_Preview__managert_Preview__editort get_propertyt_Preview__buffert gconf_clientt_Preview__clienttNoneR R R (RRR((s!plugins/TemplateEditor/Preview.pyt__init_attributes<s   cCsÛ|idtƒ|idtƒ|idtƒ|idtƒ|iidtƒ|iidtƒ|idtƒ|idtƒ|id tƒd }|iid ƒo|iid ƒ}n|i|ƒt}|iid ƒo|iid ƒ}n|i | ƒd }|iidƒo|ii dƒ}nddk l }||ƒ}|i |ƒt}|iidƒo|iidƒ}nt}|iidƒo|iidƒ}nddkl}l} |o|i|ƒn|i| ƒ|tjoÊddkl} d} d} |iidƒo|ii dƒ} n|iidƒo|ii dƒ} nddkl} | | ƒ}| | ƒ}ddkl}|i||ƒ|i||ƒndS(sp Set default properties. @param self: Reference to the Preview instance. @type self: A Preview object. s auto-indentsshow-line-markerssshow-line-numberss show-margint highlightscheck-bracketsscursor-visibleteditablet sensitiveis/apps/scribes/tabs/apps/scribes/use_tabss Monospace 12s/apps/scribes/fontiÿÿÿÿ(tFontDescriptions/apps/scribes/text_wrappings/apps/scribes/use_theme_colors(t WRAP_WORDt WRAP_NONE(t VALUE_STRINGs#000000s#ffffffs/apps/scribes/fgcolors/apps/scribes/bgcolor(t color_parse(t STATE_NORMALN(t set_propertytFalseRRtgettget_inttset_tabs_widthtTruetget_boolt!set_insert_spaces_instead_of_tabst get_stringtpangoRt modify_fonttgtkR R!t set_wrap_modetgconfR"tgtk.gdkR#R$t modify_baset modify_text(Rt tab_widthtuse_tabst gconf_fontRtfonttwrap_mode_booltuse_theme_colorsR R!R"tfgcolortbgcolorR#tforeground_colortbackground_colorR$((s!plugins/TemplateEditor/Preview.pyt__set_propertiesPs`       c Csž|iidtƒddkl}l}|ƒ}|iƒ}ddkl}x)|D]!}||i ƒ|ƒoPqUqUWddk l }||i|ƒdS(s Toggle syntax highlight on for a particular language. @param self: Reference to the TemplateEditorTextView instance. @type self: A TemplateEditorTextView object. @param language_id: An identification for a particular language. @type language_id: A String object. Riÿÿÿÿ(tSourceLanguagetSourceLanguagesManager(teq(tactivate_syntax_highlightN( RR%R*t gtksourceviewRARBtget_available_languagestoperatorRCtget_idtSCRIBES.syntaxRD( Rt language_idRARBRt languagesRCtlanguageRD((s!plugins/TemplateEditor/Preview.pyt__activate_syntax_highlight‹s    cCswddkl}l}||i|ƒ||i|ƒ||i|ƒ||i|ƒ|iƒ||ƒd}~dS(sî Handles callback when the "destroy" signal is emitted. @param self: Reference to the Preview instance. @type self: A Preview object. @param manager: Reference to the TemplateManager @type manager: A TemplateManager object. iÿÿÿÿ(tdelete_attributestdisconnect_signalN( t SCRIBES.utilsRNROR R R RRR(RRRNRO((s!plugins/TemplateEditor/Preview.pyt __destroy_cb¡s   cCs?|o|id|ƒn!|iidƒ|id|ƒdS(sp Handles callback when the "description-treeview-sensitivity" is emitted. @param self: Reference to the Preview instance. @type self: A Preview object. @param manager: Reference to the TemplateManager @type manager: A TemplateManager object. @param sensitive: Whether or not the description treeview is sensitive. @type sensitive: A Boolean object. RtN(R%Rtset_text(RRR((s!plugins/TemplateEditor/Preview.pyt__sensitivity_cb¶s c CsÚ|iidƒ|idtƒddkl}|\}}||}ddkl}ddkl}|ƒ} xJ| i ƒD]<} || |ƒoq|n| | d} |ii| ƒPq|W|| ƒ|idt ƒdS( sp Handles callback when the "template-selected" signal is emitted. @param self: Reference to the Preview instance. @type self: A Preview object. @param manager: Reference to the TemplateManager instance. @type manager: A TemplateManager object. @param data: A tuple represent a template trigger and its language category. @type data: A tuple object. RRRiÿÿÿÿ(tne(topen_template_database(tclose_template_databaseiN( RRSR%R&RGRUtMetadataRVRWtkeysR*( RRtdataRURLttriggert database_keyRVRWtdatabasetkeyttemplate((s!plugins/TemplateEditor/Preview.pyt__template_selected_cbÊs"      cCsHddkl}||dƒo|iidtƒn|i|ƒdS(s; Handles callback when the "language-selected" signal is emitted. @param self: Reference to the Preview instance. @type self: A Preview object. @param manager: Reference to the TemplateManager @type manager: A TemplateManager object. @param language: A language. @type language: A String object. iÿÿÿÿ(RCtGeneralRN(RGRCRR%R&t#_Preview__activate_syntax_highlight(RRRLRC((s!plugins/TemplateEditor/Preview.pyt__language_selected_cbès  ( t__name__t __module__t__doc__RRRRbRR R R(((s!plugins/TemplateEditor/Preview.pyR"s   ;    N(RfRERRR(((s!plugins/TemplateEditor/Preview.pyss