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

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import cgui
  5. import sys
  6. import wx
  7. import common
  8. import traceback
  9. from common import profile
  10. from digsbyipcaction.funcs import funccall
  11. from main import APP_ID
  12. TOP_BUDDIES_ENABLED = False
  13. SHOW_STATUS_ITEMS = True
  14.  
  15. def buddylist_sorted(view):
  16.     _update_jumplist()
  17.  
  18.  
  19. def status_set(status):
  20.     if SHOW_STATUS_ITEMS:
  21.         _set_jumplist_now()
  22.     
  23.  
  24. if getattr(sys, 'DEV', False):
  25.     script = u'Digsby.py '
  26. else:
  27.     script = u''
  28.  
  29. def action(name, desc, label, icon = None):
  30.     return (script + '--action=' + name, desc, label, icon)
  31.  
  32.  
  33. def get_status(name, service):
  34.     return profile.blist.get_status(name, service)
  35.  
  36.  
  37. def buddy_item(buddy):
  38.     status_icon = None
  39.     ipc_call = funccall('chat', idstr = buddy.idstr())
  40.     name = unicode(buddy.alias)
  41.     desc = _('Chat with ') + name
  42.     return action(ipc_call, desc, name, status_icon)
  43.  
  44.  
  45. def logging_enabled():
  46.     if not getattr(logging_enabled, 'linked', False):
  47.         logging_enabled.linked = True
  48.         
  49.         def on_log_ims_pref(val):
  50.             _update_jumplist()
  51.  
  52.         common.profile.prefs.link('log.ims', on_log_ims_pref, callnow = False, obj = logging_enabled)
  53.     
  54.     return common.pref('log.ims')
  55.  
  56. MAX_BUDDIES_IN_LOGSIZE_LIST = 7
  57.  
  58. def _set_jumplist_now():
  59.     popular_buddies = []
  60.     if TOP_BUDDIES_ENABLED:
  61.         
  62.         try:
  63.             popular_buddies = profile.blist.online_popular_buddies()
  64.         except Exception:
  65.             traceback.print_exc()
  66.         except:
  67.             None<EXCEPTION MATCH>Exception
  68.         
  69.  
  70.     None<EXCEPTION MATCH>Exception
  71.     set_app_jumplist(popular_buddies)
  72.  
  73.  
  74. def _update_jumplist():
  75.     if not cgui.isWin7OrHigher():
  76.         return None
  77.     
  78.     def on_timer():
  79.         _set_jumplist_now()
  80.  
  81.     
  82.     def after():
  83.         
  84.         try:
  85.             t = buddylist_sorted.timer
  86.         except AttributeError:
  87.             t = buddylist_sorted.timer = wx.PyTimer(on_timer)
  88.             on_timer()
  89.  
  90.         if not t.IsRunning():
  91.             t.StartOneShot(6000)
  92.         
  93.  
  94.     after = (wx.CallAfter,)(after)
  95.  
  96.  
  97. def _status_icons_for_status(status):
  98.     skin = skin
  99.     import gui
  100.     status_icons = dict.fromkeys(('available', 'away', 'invisible'), None)
  101.     checked = skin.get('appdefaults.icons.taskbarcheck', None)
  102.     if checked is not None:
  103.         checked = checked.PIL.Resized(16).WXB
  104.     
  105.     if status.invisible:
  106.         status_icons['invisible'] = checked
  107.     elif status.away:
  108.         status_icons['away'] = checked
  109.     elif status.available:
  110.         status_icons['available'] = checked
  111.     
  112.     return status_icons
  113.  
  114.  
  115. def jumplist_status_items(current_status):
  116.     status_icons = _status_icons_for_status(current_status)
  117.     
  118.     def status_action(name, label):
  119.         tooltip = _('Change IM Status to %s') % label
  120.         ipc = funccall('status', status = name)
  121.         return action(ipc, tooltip, label, status_icons[name])
  122.  
  123.     return [
  124.         status_action('available', _('Available')),
  125.         status_action('away', _('Away')),
  126.         status_action('invisible', _('Invisible'))]
  127.  
  128.  
  129. def set_app_jumplist(log_sizes = None):
  130.     
  131.     def after():
  132.         skin = skin
  133.         import gui
  134.         TASKS = [
  135.             action('globalstatus', _('Set your status on multiple networks'), _('Set Global Status'), skin.get('icons.globalstatus', None)),
  136.             action('newim', _('Open the New IM window'), _('New IM...'), skin.get('AppDefaults.UnreadMessageIcon', None)),
  137.             action('prefsdialog', _('Open the Digsby Preferences window'), _('Preferences...'))]
  138.         if SHOW_STATUS_ITEMS:
  139.             TASKS.append(None)
  140.             TASKS.extend(jumplist_status_items(profile.status))
  141.         
  142.         TASKS.append(None)
  143.         TASKS.append(action('exit', _('Close all windows and exit'), _('Exit Digsby'), skin.get('AppDefaults.JumpListCloseIcon', None)))
  144.         jumplist = [
  145.             (u'', TASKS)]
  146.         if TOP_BUDDIES_ENABLED:
  147.             logging = logging_enabled()
  148.             jumplist.append((u'Top Buddies (by log size)', buddies))
  149.         
  150.         success = cgui.SetUpJumpList(APP_ID, jumplist)
  151.         register_shutdown_hook()
  152.  
  153.     after = (wx.CallAfter,)(after)
  154.  
  155. _did_register_shutdown_hook = False
  156.  
  157. def register_shutdown_hook():
  158.     global _did_register_shutdown_hook
  159.     if _did_register_shutdown_hook:
  160.         return None
  161.     _did_register_shutdown_hook = True
  162.     wx.GetApp().PreShutdown.append((lambda : cgui.SetUpJumpList(APP_ID, [])))
  163.  
  164.