home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / plugins / digsby_about / aboutdialog.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  6.9 KB  |  171 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import wx
  5. import sys
  6. import os
  7. import util
  8. import path
  9. import hooks
  10. import common
  11. import gui.browser.webkit as webkit
  12. import rpc.jsonrpc as jsonrpc
  13. import protocols
  14. import peak.util.addons as addons
  15. import gui.infobox.interfaces as gui_interfaces
  16. import gui.infobox.providers as gui_providers
  17. import logging
  18. log = logging.getLogger('aboutdlg')
  19.  
  20. class AboutAddon(addons.AddOn):
  21.     
  22.     def setup(self, *a):
  23.         self.dlg = None
  24.  
  25.     
  26.     def Show(self):
  27.         self.maybe_make_dialog()
  28.         self.dlg.Show()
  29.         self.dlg.js('get_update_status();')
  30.  
  31.     
  32.     def maybe_make_dialog(self):
  33.         if self.dlg is None:
  34.             self.dlg = AboutDialog(None)
  35.         
  36.  
  37.     
  38.     def update_check_result(self, update_required):
  39.         if self.dlg is not None:
  40.             self.dlg.update_check_result(update_required)
  41.         
  42.  
  43.  
  44.  
  45. class AboutDialog(wx.Dialog, jsonrpc.RPCClient):
  46.     _rpc_handlers = {
  47.         'check_for_updates': 'check_for_updates',
  48.         'get_update_status': 'get_update_status',
  49.         'show_filetransfer_window': 'show_filetransfer_window' }
  50.     
  51.     def __init__(self, parent, *a, **k):
  52.         wx.Dialog.__init__(self, parent, *a, **k)
  53.         jsonrpc.RPCClient.__init__(self)
  54.         self.SetTitle(_('About Digsby'))
  55.         self._update_check_rpc_id = None
  56.         self.construct()
  57.         self.bind_events()
  58.  
  59.     
  60.     def construct(self):
  61.         self.webview = webkit.WebKitWindow(self)
  62.         self.webview.WebSettings.SetAllowUniversalAccessFromFileURLs(True)
  63.         self.webview.SetSize((191, 264))
  64.         self.refresh_content()
  65.         self.bridge = jsonrpc.JSPythonBridge(self.webview)
  66.         (self.bridge.on_call,) += (lambda x: self.json(x, self.webview))
  67.         self.Sizer = wx.BoxSizer(wx.VERTICAL)
  68.         self.Sizer.Add(self.webview, 1, wx.EXPAND | wx.ALL)
  69.         self.Fit()
  70.  
  71.     
  72.     def bind_events(self):
  73.         pass
  74.  
  75.     
  76.     def refresh_content(self):
  77.         acp = AboutContentProvider()
  78.         self.webview.SetHTML(acp.get_html())
  79.  
  80.     
  81.     def _default_rpc(self, rpc, webview, id, *a, **k):
  82.         log.info('jscall: %r, %r, %r, %r, %r', rpc, webview, id, a, k)
  83.  
  84.     
  85.     def check_for_updates(self, rpc, webview, id):
  86.         if self._update_check_rpc_id is not None:
  87.             return self.Derror(self.webview, id, message = 'checking')
  88.         self._update_check_rpc_id = id
  89.         log.info('Requesting update check from about dialog')
  90.         hooks.notify('digsby.updater.check')
  91.  
  92.     
  93.     def get_update_status(self, rpc, webview, id):
  94.         for hook in hooks.Hook('digsby.updater.status'):
  95.             res = hook()
  96.             if res:
  97.                 self.Dsuccess(webview, id, status = res)
  98.                 break
  99.                 continue
  100.         
  101.  
  102.     
  103.     def update_check_result(self, update_required):
  104.         if self._update_check_rpc_id is None:
  105.             return None
  106.         id = self._update_check_rpc_id
  107.         self._update_check_rpc_id = None
  108.         self.Dsuccess(self.webview, id, update_required = update_required)
  109.  
  110.     
  111.     def show_filetransfer_window(self, rpc, webview, id, *a):
  112.         import gui.filetransfer as ft
  113.         wx.CallAfter(ft.FileTransferDialog.Display)
  114.         self.Dsuccess(webview, id)
  115.         self.Show(False)
  116.  
  117.     
  118.     def js(self, s):
  119.         self.webview.RunScript(s)
  120.  
  121.  
  122.  
  123. class AboutContentProvider(gui_providers.InfoboxProviderBase):
  124.     javascript_libs = [
  125.         'jquery',
  126.         'json',
  127.         'utils']
  128.     
  129.     def get_app_context(self, ctxt_class):
  130.         return ctxt_class(path.path(__file__).parent.parent, 'digsby_about')
  131.  
  132.     
  133.     def get_context(self):
  134.         ctxt = super(AboutContentProvider, self).get_context()
  135.         ctxt.update(tag = sys.TAG, revision = sys.REVISION)
  136.         return ctxt
  137.  
  138.  
  139.  
  140. def help_menu_items(*a):
  141.     return [
  142.         (_('&About Digsby'), show_dialog)]
  143.  
  144.  
  145. def get_addon():
  146.     p = common.profile()
  147.     if p is not None:
  148.         return AboutAddon(p)
  149.     return None
  150.  
  151.  
  152. def show_dialog(*a):
  153.     a = get_addon()
  154.     if a is not None:
  155.         a.Show()
  156.     
  157.  
  158.  
  159. def on_update_check_complete(update_required, *a):
  160.     a = get_addon()
  161.     if a is not None:
  162.         a.update_check_result(update_required)
  163.     
  164.  
  165. if __name__ == '__main__':
  166.     from tests.testapp import testapp
  167.     a = testapp('..\\..\\', username = 'mike')
  168.     AboutDialog(None).Show()
  169.     a.MainLoop()
  170.  
  171.