home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / gui / browser / webkit / webkiteditsource.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  4.0 KB  |  98 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from __future__ import with_statement
  5.  
  6. def EditSource(self):
  7.     import wx
  8.     soupify = soupify
  9.     import util
  10.     StyledTextCtrl = StyledTextCtrl
  11.     STC_LEX_HTML = STC_LEX_HTML
  12.     import wx.stc
  13.     font = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, 'Consolas')
  14.     f = wx.Frame(wx.GetTopLevelParent(self), -1, 'View Source', name = 'View Source', size = (640, 480))
  15.     s = wx.BoxSizer(wx.VERTICAL)
  16.     t = StyledTextCtrl(f, -1, wx.DefaultPosition, wx.DefaultSize, wx.NO_BORDER)
  17.     orightml = self.HTML
  18.     html = soupify(orightml).prettify()
  19.     t.SetText(html)
  20.     wx.CallAfter(t.SetSelection, 0, 0)
  21.     buttons = wx.Panel(f)
  22.     save = wx.Button(buttons, -1, '&Save')
  23.     None((save.Bind, wx.EVT_BUTTON), (lambda e: self.SetHTML(t.GetText())))
  24.     save_as_file = wx.Button(buttons, -1, 'Save &As File...')
  25.     
  26.     def onsaveasfile(e):
  27.         diag = wx.FileDialog(self, 'Save HTML', 'contents.html', style = wx.SAVE)
  28.         if diag.ShowModal() == wx.ID_OK:
  29.             
  30.             try:
  31.                 f = _[2]
  32.                 f.write(orightml.encode('utf-8'))
  33.             finally:
  34.                 pass
  35.  
  36.         
  37.  
  38.     save_as_file.Bind(wx.EVT_BUTTON, onsaveasfile)
  39.     copybutton = wx.Button(buttons, -1, _('&Copy'))
  40.     
  41.     def openinbrowser(e):
  42.         Popen = Popen
  43.         import subprocess
  44.         import os.path as os
  45.         import tempfile
  46.         (fdesc, fname) = tempfile.mkstemp()
  47.         
  48.         try:
  49.             f = _[2]
  50.             f.write(t.GetText().encode('utf-8'))
  51.         finally:
  52.             pass
  53.  
  54.         if 'wxMSW' in wx.PlatformInfo:
  55.             pref = pref
  56.             import common
  57.             path = path
  58.             import path
  59.             browser_exe = pref('debug.message_area.debug_browser', 'c:\\Program Files\\Safari\\Safari.exe', type = basestring)
  60.             browser_exe = path(browser_exe).expand()
  61.             if browser_exe.isfile():
  62.                 Popen([
  63.                     browser_exe,
  64.                     fname])
  65.             else:
  66.                 wx.MessageBox('Error launching browser:\n\n"%s"\n\nPlease set the "debug.message_area.debug_browser" pref to\nthe path to your web browser.' % browser_exe, 'Open in Browser')
  67.         else:
  68.             import webbrowser
  69.             webbrowser.open_new('file://' + fname)
  70.  
  71.     openbutton = wx.Button(buttons, -1, _('&Open in Browser'))
  72.     openbutton.Bind(wx.EVT_BUTTON, openinbrowser)
  73.     openbutton.SetToolTipString(_('Launches browser in pref "debug.message_area.debug_browser"'))
  74.     
  75.     def docopy(e):
  76.         clip = wx.TheClipboard
  77.         if clip.Open():
  78.             clip.SetData(wx.TextDataObject(t.Value))
  79.             clip.Close()
  80.         
  81.  
  82.     copybutton.Bind(wx.EVT_BUTTON, docopy)
  83.     buttons.Sizer = wx.BoxSizer(wx.HORIZONTAL)
  84.     buttons.Sizer.AddMany([
  85.         save,
  86.         copybutton,
  87.         openbutton,
  88.         save_as_file])
  89.     s.Add(t, 1, wx.EXPAND)
  90.     s.Add(buttons, 0, wx.EXPAND)
  91.     f.SetSizer(s)
  92.     persist_window_pos = persist_window_pos
  93.     import gui.toolbox
  94.     persist_window_pos(f)
  95.     f.EnsureNotStacked()
  96.     f.Show()
  97.  
  98.