home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / gui / invite_friends.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  9.8 KB  |  204 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from anylists import AnyRow
  5. from pref import prefcontrols
  6. from uberwidgets.PrefPanel import PrefPanel
  7. from common import profile as p
  8. from gui.anylists import AnyList
  9. from util.observe import ObservableList
  10. from util.callbacks import callsback
  11. import wx
  12.  
  13. class StaticEmailRow(AnyRow):
  14.     checkbox_border = 3
  15.     row_height = 20
  16.     image_offset = (6, 0)
  17.     
  18.     def __init__(self, *a, **k):
  19.         AnyRow.__init__(self, *a, **k)
  20.  
  21.     
  22.     def PopulateControls(self, account):
  23.         self.checkbox.Value = True
  24.         self.text = self.data[1]
  25.  
  26.     
  27.     def image(self):
  28.         return self.data[0]
  29.  
  30.     image = property(image)
  31.     
  32.     def on_right_up(self, *a, **k):
  33.         pass
  34.  
  35.  
  36.  
  37. def f_f(a, b):
  38.     
  39.     def factory(*args):
  40.         return a(b(*args))
  41.  
  42.     
  43.     factory.__repr__ = lambda : '<factory composing %(a)r with %(b)s>' % locals()
  44.     return factory
  45.  
  46. pen_f = f_f(wx.Pen, wx.Color)
  47. brush_f = f_f(wx.Brush, wx.Color)
  48.  
  49. def pen_f_f(*a):
  50.     return (lambda : pen_f(*a))
  51.  
  52.  
  53. def brush_f_f(*a):
  54.     return (lambda : f_f(wx.Brush, wx.Color)(*a))
  55.  
  56. webmail_types = frozenset(('gmail', 'ymail', 'aolmail', 'hotmail'))
  57. TIME_UNTIL_SPAM = 604800
  58.  
  59. def do_user_initiated_check():
  60.     make_invite_diag(background = False, success = dialog_closed_callback)
  61.  
  62.  
  63. def do_background_check():
  64.     pref = pref
  65.     setpref = setpref
  66.     import common
  67.     time = time
  68.     import time
  69.     invite_times = pref('usertrack.invite.dialog.results', type = dict, default = { })
  70.     if invite_times:
  71.         return None
  72.     if not any((lambda .0: for e in .0:
  73. e.protocol in webmail_types)(p.emailaccounts[:])):
  74.         return None
  75.     first_online = pref('usertrack.firstknownonline', type = int, default = -1)
  76.     if not first_online > 0:
  77.         setpref('usertrack.firstknownonline', int(time()))
  78.         return None
  79.     if int(time()) - first_online < 604800:
  80.         return None
  81.     make_invite_diag(background = True, success = dialog_closed_callback)
  82.  
  83.  
  84. def dialog_closed_callback(result):
  85.     S = Storage
  86.     import util
  87.     time = time
  88.     import time
  89.     pref = pref
  90.     setpref = setpref
  91.     import common
  92.     result = S(result)
  93.     invite_times = pref('usertrack.invite.dialog.results', type = dict, default = { })
  94.     num_email_accts = len(p.emailaccounts)
  95.     num_webmail_accts = []([ e.protocol in webmail_types for e in p.emailaccounts[:] ])
  96.     track_data = dict(accts = len(result.accts), web_accts = num_webmail_accts, email_accts = num_email_accts, background = result.background, send = result.send)
  97.     num_not_triggered = sum((lambda .0: for t in .0:
  98. t.get('background', False))(invite_times.values()))
  99.  
  100.  
  101. def make_invite_diag(background = False, callback = None):
  102.     f = wx.Dialog(None)
  103.     f.Sizer = wx.BoxSizer(wx.VERTICAL)
  104.     p1 = InvitePanel(f)
  105.     
  106.     def handle_invite_done(e):
  107.         if e.EventType in wx.EVT_BUTTON:
  108.             print 'send was hit'
  109.             (name, accts) = p1.info()
  110.             if not name:
  111.                 return wx.MessageBox('Please enter your name so that ...\n will know from whom the invites were sent.', 'Please enter your name.')
  112.             callback.success(dict(name = name, accts = accts, background = background, send = True))
  113.         elif e.EventType in wx.EVT_CLOSE:
  114.             (name, accts) = p1.info()
  115.             callback.success(dict(name = name, accts = accts, background = background, send = False))
  116.         
  117.         f.Show(False)
  118.         f.Destroy()
  119.  
  120.     f.Bind(wx.EVT_CLOSE, handle_invite_done)
  121.     f.Bind(wx.EVT_BUTTON, handle_invite_done)
  122.     f.Sizer.Add(p1, 1, wx.EXPAND)
  123.     p1.Layout()
  124.     f.Layout()
  125.     f.Fit()
  126.     f.SetMinSize(f.GetSize())
  127.     f.Show()
  128.     return f
  129.  
  130. make_invite_diag = callsback(make_invite_diag)
  131.  
  132. class InvitePanel(wx.Panel):
  133.     
  134.     def __init__(self, *a, **k):
  135.         if k.get('name') is not None:
  136.             k['name'] = 'Invite Panel'
  137.         
  138.         wx.Panel.__init__(self, *a, **k)
  139.         accounts = _[1]
  140.         data = []
  141.         for acct in accounts:
  142.             data.append((ico, acct.display_name, acct.protocol, acct.name, acct._decryptedpw()))
  143.         
  144.         self.data = data
  145.         self.Construct()
  146.         self.Fonts()
  147.         self.Layout()
  148.  
  149.     
  150.     def Construct(self):
  151.         parent = self
  152.         self.line1 = wx.StaticText(parent, label = "We hope you've enjoyed using Digsby.", style = wx.TE_CENTER)
  153.         self.line2 = wx.StaticText(parent, label = 'Please show your support and invite your friends.', style = wx.TE_CENTER)
  154.         self.separator = wx.StaticLine(parent)
  155.         self.name_label = wx.StaticText(parent, label = 'Full Name: ')
  156.         self.name_text = wx.TextCtrl(parent)
  157.         self.acct_list = AnyList(parent, ObservableList(self.data), row_control = StaticEmailRow, multiselect = False, edit_buttons = None, draggable_items = False, style = 0, velocity = None)
  158.         self.acct_list.SetMinSize(wx.Size(-1, 104))
  159.         self.acct_panel = PrefPanel(parent, self.acct_list, 'Account')
  160.         
  161.         self.acct_panel._bg_brush = lambda : wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))
  162.         
  163.         self.acct_panel._fg_pen = lambda : wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DSHADOW))
  164.         self.send_button = wx.Button(parent, wx.ID_OK, label = 'Send Invite!')
  165.         self.send_button.MoveAfterInTabOrder(self.name_text)
  166.  
  167.     
  168.     def info(self):
  169.         acct_list = self.acct_list
  170.         acct_list = [ acct_list[i] for i in xrange(len(acct_list)) ]
  171.         return ([], _[2])
  172.  
  173.     
  174.     def Fonts(self):
  175.         fnt1 = self.line1.Font
  176.         fnt1.SetPointSize(fnt1.GetPointSize() + 4)
  177.         fnt1.SetWeight(wx.FONTWEIGHT_BOLD)
  178.         self.line1.Font = fnt1
  179.         self.line2.Font = fnt1
  180.         fnt2 = self.name_label.Font
  181.         fnt2.SetPointSize(fnt2.GetPointSize() + 2)
  182.         self.name_label.Font = fnt2
  183.  
  184.     
  185.     def Layout(self):
  186.         self.Sizer = s1 = prefcontrols.VSizer()
  187.         s1.Add(self.line1, 0, wx.EXPAND | wx.ALL, 5)
  188.         s1.Add(self.line2, 0, wx.EXPAND | wx.ALL & ~(wx.TOP), 5)
  189.         s1.Add(self.separator, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 6)
  190.         s2 = prefcontrols.HSizer()
  191.         s2.AddSpacer(6)
  192.         s2.Add(self.name_label, 0, wx.EXPAND)
  193.         s2.Add(self.name_text, 3, wx.EXPAND)
  194.         s2.AddSpacer(6)
  195.         s1.Add(s2, 0, wx.EXPAND | wx.ALL, 9)
  196.         s1.Add(self.acct_panel, 1, wx.EXPAND | wx.ALL & ~(wx.TOP), 15)
  197.         s3 = prefcontrols.HSizer()
  198.         s3.AddStretchSpacer(20)
  199.         s3.Add(self.send_button, 60, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL & ~(wx.TOP), 3)
  200.         s3.AddStretchSpacer(20)
  201.         s1.Add(s3, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND | wx.BOTTOM, 6)
  202.  
  203.  
  204.