home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 February / maximum-cd-2011-02.iso / DiscContents / digsby_setup85.exe / lib / gui / pref / pg_research.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-11-24  |  5.1 KB  |  75 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import wx
  5. import config
  6. import gui.pref.prefcontrols as PC
  7. from gui.uberwidgets.PrefPanel import PrefPanel, PrefCollection
  8. from common import setpref, pref
  9. from util import traceguard
  10. from gui.browser.webkit import WebKitDisplay
  11. WALL_OF_TEXT = _('Help Digsby stay free and ad-free. Allow Digsby to use part of your computer\'s idle processing power to contribute to commercial grid computing projects by enabling the Research Module.\n<p>\nThis module turns on after your computer has been completely idle (no mouse or keyboard movement) for a period of time. It turns off the instant you move your mouse or press a key, so it has no effect on your PC\'s performance when you\'re using it. The research module also runs as a low priority, sandboxed Java process, so that other tasks your computer is doing will get done first, and so that it is completely secure.\n<p>\nFor more details, see the <a href="http://wiki.digsby.com/doku.php?id=cpuusage">Research Module FAQ</a>.\n')
  12. if config.platform == 'win':
  13.     import gui.native.win.winutil as winutil
  14.     if winutil.is_vista():
  15.         font = 'Segoe UI, Tahoma, MS Sans Serif; font-size: 9pt;'
  16.     else:
  17.         font = 'Tahoma, MS Sans Serif; font-size: 11px;'
  18. else:
  19.     font = 'Arial 12px'
  20. css = 'body {\nmargin: 0;\noverflow: hidden;\ncursor: default;\nbackground-color: white;\nfont-family: %s;\n-webkit-text-size-adjust: none;\n-webkit-user-select: none;\n}' % font
  21. description_html = '<!doctype html><html><head><style>{css}</style></head>\n<body><div id="container">{body}</container></body></html>'.format(css = css, body = WALL_OF_TEXT)
  22.  
  23. def build_description_webview(parent, prefix):
  24.     webview = WebKitDisplay(parent)
  25.     webview._loaded = False
  26.     
  27.     def on_load(e):
  28.         e.Skip()
  29.         if e.GetState() == wx.webview.WEBVIEW_LOAD_ONLOAD_HANDLED:
  30.             webview._loaded = True
  31.         
  32.  
  33.     
  34.     def on_timer():
  35.         if not webview._loaded:
  36.             return None
  37.         webview._timer.Stop()
  38.         traceguard.__enter__()
  39.         
  40.         try:
  41.             height = webview.RunScript('document.getElementById("container").clientHeight')
  42.             height = int(height)
  43.             webview.SetMinSize((-1, height))
  44.             webview.GrandParent.Layout()
  45.         finally:
  46.             pass
  47.  
  48.         parent.Thaw()
  49.  
  50.     webview.SetMinSize((-1, 160))
  51.     webview._timer = wx.PyTimer(on_timer)
  52.     webview._timer.StartRepeating(50)
  53.     webview.Bind(wx.webview.EVT_WEBVIEW_LOAD, on_load)
  54.     webview.SetPageSource(description_html)
  55.     parent.Freeze()
  56.     return webview
  57.  
  58.  
  59. def panel(panel, sizer, addgroup, exithooks):
  60.     
  61.     try:
  62.         import researchdriver.driver as researchdriver
  63.     except ImportError:
  64.         default_cpu_num = 75
  65.         default_bandwidth_num = 75
  66.  
  67.     default_cpu_num = int(researchdriver.driver.get_cpu_percent())
  68.     default_bandwidth_num = int(researchdriver.driver.get_bandwidth_percent())
  69.     description = PrefPanel(panel, build_description_webview, _('Research Module'), prefix = '')
  70.     options = PrefPanel(panel, PrefCollection(PrefCollection(PC.Check('local.research.enabled', _('Allow Digsby to use CPU time to conduct research after %2(research.idle_time_min)d minutes of idle time')), layout = PC.VSizer(), itemoptions = (0, wx.ALL, 3)), (PrefCollection,)(((lambda parent, prefix: PC.Slider(PC.pname(prefix, 'local.research.cpu_percent'), _('Maximum CPU Usage:'), start = 1, stop = 101, step = 1, value = int(PC.get_pref('local.research.cpu_percent', default = default_cpu_num)), default = int(PC.get_pref('local.research.cpu_percent', default = default_cpu_num)), fireonslide = True, unit = _('%'))(parent)[0]),), (lambda parent, prefix: PC.Slider(PC.pname(prefix, 'local.research.bandwidth_percent'), _('Maximum Bandwidth Usage:'), start = 1, stop = 101, step = 1, value = int(PC.get_pref('local.research.bandwidth_percent', default = default_bandwidth_num)), default = int(PC.get_pref('local.research.bandwidth_percent', default = default_bandwidth_num)), fireonslide = True, unit = _('%'))(parent)[0]), layout = PC.HSizer(), itemoptions = (0, wx.ALL, 3)), layout = PC.VSizer(), itemoptions = (0, wx.BOTTOM | wx.TOP, 3)), _('Options'), prefix = '')
  71.     sizer.Add(description, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)
  72.     sizer.Add(options, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)
  73.     return panel
  74.  
  75.