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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import traceback
  5. import wx
  6. import gui.toolbox as gui
  7. import gui.wxextensions as gui
  8. import gui.pref.prefcontrols as pc
  9. import supportoptions
  10. _parentclass = wx.Panel
  11.  
  12. def _SetColors(thing, fg, bg):
  13.     thing.BackgroundColour = bg
  14.     thing.ForegroundColour = fg
  15.  
  16.  
  17. class SupportPanel(_parentclass):
  18.     SPACING = 6
  19.     
  20.     def __init__(self, options, *a, **k):
  21.         self.separators = []
  22.         self.options = options
  23.         _parentclass.__init__(self, *a, **k)
  24.         self.build()
  25.         self.do_layout()
  26.  
  27.     
  28.     def OnClose(self):
  29.         pass
  30.  
  31.     
  32.     def do_layout(self):
  33.         self.Layout()
  34.         self.Fit()
  35.         self.SetMinSize(self.Size)
  36.         self.SetMaxSize(self.Size)
  37.         self.Parent.Layout()
  38.         self.Parent.Fit()
  39.         self.Refresh()
  40.  
  41.     
  42.     def build(self):
  43.         sz = pc.VSizer()
  44.         for option in self.options[:-1]:
  45.             sz.Add(self.build_option(option), border = self.SPACING, flag = wx.EXPAND | wx.ALL)
  46.             sz.Add(self.make_separator(), flag = wx.CENTER | wx.EXPAND)
  47.         
  48.         sz.Add(self.build_option(self.options[-1]), border = self.SPACING, flag = wx.EXPAND | wx.ALL)
  49.         main_sz = pc.HSizer()
  50.         main_sz.Add(sz, 1, flag = wx.EXPAND | wx.LEFT | wx.RIGHT, border = self.SPACING)
  51.         self.Sizer = main_sz
  52.  
  53.     
  54.     def make_separator(self):
  55.         sz = pc.HSizer()
  56.         sz.AddSpacer((5, 0))
  57.         line = wx.StaticLine(self, size = wx.Size(0, 2))
  58.         sz.Add(line, proportion = 1, flag = wx.EXPAND | wx.CENTER)
  59.         sz.AddSpacer((5, 0))
  60.         return sz
  61.  
  62.     
  63.     def build_option(self, o):
  64.         sz = pc.HSizer()
  65.         txt = wx.StaticText(self, label = o.description)
  66.         btn = wx.Button(self, label = o.action_text)
  67.         sz.Add(txt, flag = wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border = self.SPACING)
  68.         help_link = getattr(o, 'help_link', None)
  69.         if help_link is not None:
  70.             HelpLink = HelpLink
  71.             import gui.toolbox
  72.             sz.Add(HelpLink(self, help_link))
  73.         
  74.         sz.AddSpacer(10)
  75.         sz.AddStretchSpacer()
  76.         sz.Add(btn, flag = wx.ALIGN_RIGHT)
  77.         btn.Bind(wx.EVT_BUTTON, self.make_click_handler(o, txt, btn))
  78.         return sz
  79.  
  80.     
  81.     def make_click_handler(self, o, txt, btn):
  82.         
  83.         def click_handler(e = (None, None, None)):
  84.             on_action = getattr(o, 'on_action', None)
  85.             action_url = getattr(o, 'action_url', None)
  86.             perform_action = True
  87.             if getattr(o, 'confirm', False) and getattr(o, 'should_confirm', (lambda : True))():
  88.                 confirm_title = getattr(o, 'confirm_title', _('Are you sure?'))
  89.                 confirm_msg = getattr(o, 'confirm_text', _('Are you sure you want do this?'))
  90.                 default = getattr(o, 'confirm_default', True)
  91.                 if not gui.toolbox.yes_no_prompt(confirm_title, confirm_msg, default):
  92.                     perform_action = False
  93.                 
  94.             
  95.             if perform_action:
  96.                 if on_action is not None:
  97.                     on_action()
  98.                 
  99.                 if action_url is not None:
  100.                     wx.LaunchDefaultBrowser(action_url)
  101.                 
  102.                 if getattr(o, 'say_thanks', False):
  103.                     wx.MessageBox(_('Thank you for supporting Digsby.'), _('Thank you!'))
  104.                 
  105.             
  106.             txt.Label = o.description
  107.             btn.Label = o.action_text
  108.  
  109.         return click_handler
  110.  
  111.  
  112.  
  113. class SupportFrame(wx.Frame):
  114.     
  115.     def __init__(self, parent = None, **k):
  116.         title = k.pop('title', _('Support Digsby'))
  117.         style = k.pop('style', wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER) & ~(wx.MAXIMIZE_BOX))
  118.         components = k.pop('components', None)
  119.         wx.Frame.__init__(self, parent, title = title, style = style, **k)
  120.         self.AutoLayout = True
  121.         self._supportpanel = SupportPanel(components, self)
  122.         self.Fit()
  123.         
  124.         try:
  125.             import gui.skin as skin
  126.             self.SetFrameIcon(skin.get('AppDefaults.TaskbarIcon'))
  127.         except Exception:
  128.             None if components is None else []
  129.             None if components is None else []
  130.             traceback.print_exc()
  131.         except:
  132.             None if components is None else []
  133.  
  134.         self.CenterOnScreen()
  135.         self.Bind(wx.EVT_CLOSE, self.OnClose)
  136.  
  137.     
  138.     def OnClose(self, e = None):
  139.         self._supportpanel.OnClose()
  140.         del self._supportpanel
  141.         self.Destroy()
  142.  
  143.  
  144. if __name__ == '__main__':
  145.     a = wx.PySimpleApp()
  146.     f = SupportFrame.MakeOrShow()
  147.     a.MainLoop()
  148.  
  149.