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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  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, flag = 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.         txt.SetBold(True)
  68.         sz.Add(txt, flag = wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border = self.SPACING)
  69.         sz.AddSpacer(10)
  70.         sz.AddStretchSpacer()
  71.         sz.Add(btn, flag = wx.ALIGN_RIGHT)
  72.         btn.Bind(wx.EVT_BUTTON, self.make_click_handler(o, txt, btn))
  73.         return sz
  74.  
  75.     
  76.     def make_click_handler(self, o, txt, btn):
  77.         
  78.         def click_handler(e = (None, None, None, None)):
  79.             on_action = getattr(o, 'on_action', None)
  80.             action_url = getattr(o, 'action_url', None)
  81.             perform_action = True
  82.             if getattr(o, 'confirm', False) and getattr(o, 'should_confirm', (lambda : True))():
  83.                 confirm_title = getattr(o, 'confirm_title', _('Are you sure?'))
  84.                 confirm_msg = getattr(o, 'confirm_text', _('Are you sure you want do this?'))
  85.                 default = getattr(o, 'confirm_default', True)
  86.                 if not gui.toolbox.yes_no_prompt(confirm_title, confirm_msg, default):
  87.                     perform_action = False
  88.                 
  89.             
  90.             if perform_action:
  91.                 if on_action is not None:
  92.                     on_action()
  93.                 
  94.                 if action_url is not None:
  95.                     wx.LaunchDefaultBrowser(action_url)
  96.                 
  97.                 if getattr(o, 'say_thanks', False):
  98.                     wx.MessageBox(_('Thank you for supporting Digsby.'), _('Thank you!'))
  99.                 
  100.             
  101.             txt.Label = o.description
  102.             btn.Label = o.action_text
  103.             self.do_layout()
  104.  
  105.         return click_handler
  106.  
  107.  
  108.  
  109. class SupportFrame(wx.Frame):
  110.     
  111.     def __init__(self, parent = None, **k):
  112.         title = k.pop('title', _('Support Digsby'))
  113.         style = k.pop('style', wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER) & ~(wx.MAXIMIZE_BOX))
  114.         components = k.pop('components', None)
  115.         wx.Frame.__init__(self, parent, title = title, style = style, **k)
  116.         self.AutoLayout = True
  117.         self._supportpanel = SupportPanel(components, self)
  118.         self.Fit()
  119.         
  120.         try:
  121.             import gui.skin as skin
  122.             self.SetFrameIcon(skin.get('AppDefaults.TaskbarIcon'))
  123.         except Exception:
  124.             None if components is None else []
  125.             None if components is None else []
  126.             traceback.print_exc()
  127.         except:
  128.             None if components is None else []
  129.  
  130.         self.CenterOnScreen()
  131.         self.Bind(wx.EVT_CLOSE, self.OnClose)
  132.  
  133.     
  134.     def OnClose(self, e = None):
  135.         self._supportpanel.OnClose()
  136.         del self._supportpanel
  137.         self.Destroy()
  138.  
  139.  
  140. if __name__ == '__main__':
  141.     a = wx.PySimpleApp()
  142.     f = SupportFrame.MakeOrShow()
  143.     a.MainLoop()
  144.  
  145.