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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import wx
  5. from wx import EXPAND, BOTTOM, LEFT
  6. from common import profile
  7. from gui.uberwidgets.formattedinput2.formatprefsmixin import PrefInput
  8. from gui.uberwidgets.formattedinput2.fromattedinputevents import EVT_TEXT_FORMAT_CHANGED
  9. import operator
  10. from gui.pref.prefcontrols import Check, Choice, CheckChoice, get_pref, HSizer, Label
  11. from gui.uberwidgets.PrefPanel import PrefCollection, PrefPanel
  12. from config import platformName
  13. from common import pref, delpref
  14. timestamp_options = (('%#I:%M', '5:43'), ('%#I:%M %p', '5:43 PM'), ('%#I:%M:%S', '5:43:20'), ('%#I:%M:%S %p', '5:43:20 PM'), ('%H:%M', '17:43'), ('%H:%M:%S', '17:43:20'))
  15. new_im_choices = [
  16.     ('stealfocus', _('automatically take focus')),
  17.     ('minimize', _('start minimized in taskbar')),
  18.     ('hide', _('start hidden (tray icon blinks)'))]
  19. ad_position_options = (('bottom', _('bottom')), ('top', _('top')), ('left', _('left')), ('right', _('right')))
  20.  
  21. def checkbox_enabled_when_pref(cb, prefname):
  22.     cb.Enabled = get_pref(prefname)
  23.     profile.prefs.link((prefname,), (lambda val: wx.CallAfter(cb.Enable, val)), obj = cb)
  24.  
  25.  
  26. def panel(panel, sizer, newgroup, exithooks):
  27.     warncheck = Check('messaging.tabs.warn_on_close', 'Warn me when I attempt to close multiple conversations')(panel)
  28.     checkbox_enabled_when_pref(warncheck, 'messaging.tabs.enabled')
  29.     window_options = [
  30.         Check('conversation_window.always_on_top', _('&Keep on top of other applications'))]
  31.     window_options.extend([
  32.         Check('messaging.tabs.enabled', _('Group multiple conversations into one tabbed window')),
  33.         warncheck])
  34.     if platformName != 'mac':
  35.         window_options.append((Choice('conversation_window.new_action', new_im_choices, caption = _('New conversation windows: ')), 0, wx.EXPAND | wx.BOTTOM, 3))
  36.     
  37.     window_options.append(Choice('messaging.tabs.icon', (('buddy', _('buddy icon')), ('service', _('service icon')), ('status', _('status icon'))), _("Identify conversations with the contact's: ")))
  38.     winops = PrefPanel(panel, PrefCollection(*window_options), _('Window Options'))
  39.     conops = PrefPanel(panel, get_conversation_entries(panel, exithooks), _('Conversation Options'))
  40.     disable_flash = Check('imwin.ads_disable_flash', _("Don't show flash ads"))(panel)
  41.     checkbox_enabled_when_pref(disable_flash, 'imwin.ads')
  42.     ad_options = PrefPanel(panel, PrefCollection(Label(_('Help keep Digsby free by showing an\nadvertisement in the IM window.')), Check('imwin.ads', _('Support Digsby development with an ad')), disable_flash, Choice('imwin.ads_position', ad_position_options, _('Location of ad in IM window: ')), layout = wx.BoxSizer(wx.VERTICAL), itemoptions = (0, wx.EXPAND | wx.BOTTOM, 8)), _('Ad Options'))
  43.     hsizer = HSizer()
  44.     hsizer.AddMany([
  45.         (conops, 1, wx.EXPAND | wx.ALL, 3),
  46.         (ad_options, 0, wx.EXPAND | wx.ALL, 3)])
  47.     textform = PrefPanel(panel, build_format_preview(panel, exithooks), _('Text Formatting'))
  48.     panel._conops = conops
  49.     sizer.AddMany([
  50.         (winops, 0, EXPAND | BOTTOM, 6),
  51.         (hsizer, 0, EXPAND | BOTTOM, 6),
  52.         (textform, 1, EXPAND | BOTTOM, 6)])
  53.     return panel
  54.  
  55.  
  56. def AspellMenuEntries(spellchecker):
  57.     dicts = spellchecker.dict_info
  58.     langs = (lambda .0: for key in .0:
  59. None if 'name_native' in dicts[key] else (key, dicts[key]['name_english']))(dicts)
  60.     return sorted(langs, key = (lambda x: x[1].upper()))
  61.  
  62.  
  63. def build_format_preview(parent, exithooks):
  64.     p = wx.Panel(parent)
  65.     s = p.Sizer = wx.BoxSizer(wx.VERTICAL)
  66.     input = PrefInput(p, value = _('Your messages will look like this.'), autosize = False, multiFormat = False, showFormattingBar = platformName != 'mac', skin = 'AppDefaults.FormattingBar', formatpref = 'messaging.default_style')
  67.     
  68.     def OnFormatChanged(event):
  69.         input.SaveStyle('messaging.default_style')
  70.  
  71.     input.Bind(EVT_TEXT_FORMAT_CHANGED, OnFormatChanged)
  72.     input.SetMinSize((300, 77))
  73.     s.Add(input, 1, wx.EXPAND | wx.ALL, 1)
  74.     if platformName == 'mac':
  75.         h = wx.BoxSizer(wx.HORIZONTAL)
  76.         h.AddStretchSpacer(1)
  77.         h.Add(input.CreateFontButton(p), 0, EXPAND | wx.ALL, 5)
  78.         s.Add(h, 0, wx.EXPAND)
  79.     
  80.     
  81.     def OnPaintWithOutline(event):
  82.         dc = wx.AutoBufferedPaintDC(p)
  83.         rect = wx.RectS(p.Size)
  84.         irect = wx.Rect(input.Rect)
  85.         irect.Inflate(1, 1)
  86.         dc.Brush = wx.WHITE_BRUSH
  87.         dc.Pen = wx.TRANSPARENT_PEN
  88.         dc.DrawRectangleRect(rect)
  89.         dc.Pen = wx.Pen(wx.Color(213, 213, 213))
  90.         dc.DrawRectangleRect(irect)
  91.  
  92.     p.Bind(wx.EVT_PAINT, OnPaintWithOutline)
  93.     return p
  94.  
  95.  
  96. def get_conversation_entries(panel, exithooks):
  97.     p = wx.Panel(panel)
  98.     spellchecker = spellchecker
  99.     import common.spelling
  100.     history = Check('conversation_window.show_history', _('Show last %2(conversation_window.num_lines)d lines in IM window'))(p)
  101.     conversation_entries = [
  102.         Check('conversation_window.timestamp', _('&Display timestamp:'))(p),
  103.         Choice('conversation_window.timestamp_format', timestamp_options, allow_custom = True)(p)]
  104.     if 'wxMac' not in wx.PlatformInfo:
  105.         conversation_entries.extend([
  106.             Check('messaging.spellcheck.enabled', _('Spell check:'))(p),
  107.             Choice('messaging.spellcheck.engineoptions.lang', AspellMenuEntries(spellchecker))(p)])
  108.     
  109.     conversation_entries.extend(emoticon_choice(p))
  110.     s = wx.FlexGridSizer(len(conversation_entries), 2, 3, 6)
  111.     s.AddGrowableCol(1, 1)
  112.     for i, entry in enumerate(conversation_entries):
  113.         s.Add(entry, i % 2, wx.EXPAND)
  114.     
  115.     v = wx.BoxSizer(wx.VERTICAL)
  116.     v.Add(s, 1, wx.EXPAND)
  117.     v.AddMany([
  118.         (1, 7),
  119.         (Check('log.ims', _('Log IM conversations to hard drive'), callback = history.Enable)(p), 0, wx.EXPAND),
  120.         (1, 4),
  121.         (history, 0, LEFT, 18)])
  122.     history.Enable(pref('log.ims', type = bool, default = True))
  123.     if 'wxMac' not in wx.PlatformInfo:
  124.         exithooks += spellchecker.DownloadDict
  125.     
  126.     p.Sizer = v
  127.     return p
  128.  
  129.  
  130. def emoticon_choice(panel):
  131.     emoticons = emoticons
  132.     import gui.imwin
  133.     emoticonchoices = _[1]
  134.     current_pack = pref('appearance.conversations.emoticons.pack', None)
  135.     return [
  136.         Check('appearance.conversations.emoticons.enabled', _('Show &emoticons:'))(panel),
  137.         Choice('appearance.conversations.emoticons.pack', emoticonchoices)(panel)]
  138.  
  139.