Exemplo n.º 1
0
def choices_sizer(panel, exithooks):
    p = wx.Panel(panel)
    sz = p.Sizer = VSizer()

    model_addon = AccountLocationModels(common.profile())
    model_addon.setup()

    location_models = model_addon.location_models

    import gui.lattice #@UnusedImport: side effect registering interfaces
    choices = list(yield_choices(location_models, p))
    exithooks.append(lambda:release_syncs(choices))

    labels = [_('Show email accounts in:'),
              _('Show social networks in:'),]

    to_add = [[(SText(p, label), 0, wx.ALIGN_CENTER_VERTICAL),
                   (choice, 1, 0)]
                  for label,choice in zip(labels, choices)]

    s = wx.FlexGridSizer(len(location_models), 2, 7,7)
    s.AddMany(sum(to_add,[]))
    s.AddGrowableCol(1,1)
    sz.Add(s, 0, EXPAND)

    return p
Exemplo n.º 2
0
def contact_layout_panel(panel, pre, exithooks):
    container_panel = wx.Panel(panel)
    container_panel.Sizer = VSizer()
    container_panel.ez_panel = None
    container_panel.adv_panel = None

    prefix = 'buddylist.layout.'

    service = get_pref(prefix + 'service_icon_pos')
    se_enabled = get_pref(prefix + 'show_service_icon')
    status = get_pref(prefix + 'status_icon_pos')
    st_enabled = get_pref(prefix + 'show_status_icon')
    icon = get_pref(prefix + 'buddy_icon_pos')
    icon_enabled = get_pref(prefix + 'show_buddy_icon')

    #heal some conflicting states
    if not icon_enabled:
        if status.startswith('b'): status = icon
        if service.startswith('b'): service = icon
    #service will be shown farther left if they're the same, so fix status first
    #technically, these next two would be ok as long as they're both enabled,
    #but let's get them to a consistent state ASAP
    if status.startswith('f') and service != status[1:]: status = status[1:]
    if service.startswith('f') and status != service[1:]: service = service[1:]
    #other states may be conflicting, but do not cause problems, only those where
    #the BUMP/VACUUM rules come into play need to be fixed

    container_panel.layout_model = LayoutModel(
        service=service,
        se_enabled=se_enabled,
        status=status,
        st_enabled=st_enabled,
        icon=icon,
        icon_enabled=icon_enabled,
    )
    Cells = trellis.Cells
    #hook up helper models
    cells = Cells(container_panel.layout_model)

    #Trellis will keep the rest alive
    container_panel.links = dict(
        service_icon_pos=PrefLink(prefname=prefix + 'service_icon_pos',
                                  value=cells['service']),
        show_service_icon=PrefLink(prefname=prefix + 'show_service_icon',
                                   value=cells['se_enabled']),
        status_icon_pos=PrefLink(prefname=prefix + 'status_icon_pos',
                                 value=cells['status']),
        show_status_icon=PrefLink(prefname=prefix + 'show_status_icon',
                                  value=cells['st_enabled']),
        buddy_icon_pos=PrefLink(prefname=prefix + 'buddy_icon_pos',
                                value=cells['icon']),
        show_buddy_icon=PrefLink(prefname=prefix + 'show_buddy_icon',
                                 value=cells['icon_enabled']),
    )

    if pref('buddylist.layout.ez_layout', True):
        easy_layout_panel(container_panel, pre)
    else:
        advanced_layout_panel(container_panel, pre, exithooks)
    return container_panel
Exemplo n.º 3
0
def panel(panel, sizer, addgroup, exithooks):
    collection = PrefCollection(Check(
        None, _('&Allow Digsby to conduct research during idle itme')),
                                layout=VSizer(),
                                itemoptions=(0, wx.BOTTOM, 6))

    help_group = PrefPanel(panel, collection, _('Help Digsby'))
    sizer.Add(help_group)
    return panel
Exemplo n.º 4
0
def sorting_sizer(panel, exithooks):
    p = wx.Panel(panel)
    sz = p.Sizer = VSizer()

    #get models
    sort_models = profile.blist.sort_models

    import gui.lattice  #@UnusedImport: side effect registering interfaces
    choices = list(yield_choices(sort_models, p))
    exithooks.append(lambda: release_syncs(choices))

    labels = [_('Group by:'),
              _('Sort by:')] + \
             [_('Then by:')]*(len(sort_models)-2)

    to_add = [[(SText(p, label), 0, wx.ALIGN_CENTER_VERTICAL),
               (choice, 1, EXPAND)] for label, choice in zip(labels, choices)]

    s = wx.FlexGridSizer(len(sort_models), 2, 7, 7)
    s.AddMany(sum(to_add, []))
    s.AddGrowableCol(1, 1)
    sz.Add(s, 0, EXPAND)

    return p
Exemplo n.º 5
0
 def LayoutMore(self, sizer):
     #checkboxes
     check_sizer = VSizer()
     check_sizer.AddStretchSpacer(3)
     for check in self.checks:
         if isinstance(check, tuple):
             check, text = check
             h = HSizer()
             h.Add(check)
             h.Add(text)
             check_sizer.Add(h)
         else:
             check_sizer.Add(check)
         check_sizer.AddStretchSpacer()
     check_sizer.AddStretchSpacer(2)
     #add checkboxes
     sizer.Add(check_sizer, 1, wx.LEFT | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, self.padding.x*2)
     #right side
     right_sizer = VSizer()
     self._place_text = right_sizer.Add(self.text_name, 3, wx.ALIGN_RIGHT | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, self.padding.y)
     #right bottom
     link_sizer = HSizer()
     link_sizer.Add(self.edit, 0, wx.LEFT, self.padding.x)
     link_sizer.Add(self.remove, 0, wx.LEFT, self.padding.x)
     right_sizer.AddStretchSpacer()
     #add right bottom to right
     right_sizer.Add(link_sizer, 3, wx.ALIGN_RIGHT | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, self.padding.y)
     #add right side
     sizer.Add(right_sizer, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, 0)
Exemplo n.º 6
0
def panel(panel, sizer, addgroup, exithooks):
    top = HSizer()
    top_right = VSizer()

    debug = PrefPanel(panel,
            PrefCollection(Check('advanced_prefs',  _('Advanced Prefs')),
                           Check('console',         _('Enable Debug Console')),
                           Check('reenable_online', _('Allow Reconnect if --start-offline')),
                           layout = VSizer(),
                           itemoptions = (0, BOTTOM | TOP, 3)),
            _('Debug'),
            prefix = 'debug',
    )

    digsby = PrefPanel(panel,
            PrefCollection(Check('allow_add', _('Allow Adding\n Digsby Buddies')),
                           layout = VSizer(),
                           itemoptions = (0, BOTTOM | TOP, 3)),
            _('Digsby Protocol'),
            prefix = 'digsby',
    )

    top.Add(debug,          1, EXPAND | ALL, 3)
    top_right.Add(digsby,   1, EXPAND | ALL, 3)
    top.Add(top_right,      1, EXPAND | ALL, 0)

    email_value_text = Text(panel, 'email.signature.value',
                            style = wx.TE_MULTILINE | wx.TE_AUTO_SCROLL )#| wx.TE_PROCESS_ENTER)
    email_value_text.Enable(pref('email.signature.enabled', type = bool))
    email_value_text.SetMinSize((-1, 60))

    email = PrefPanel(panel,
                      PrefCollection(Check('email.signature.enabled', _('Append signature'),
                                           callback = email_value_text.Enable),
                                     (email_value_text, 1, wx.LEFT | wx.EXPAND, 18),
                                     layout = VSizer()),
                      _('Email'),
                      )

    bottom = VSizer()

    bottom.Add(email, -1, EXPAND | ALL, 3)
    #TODO: defaults for text fields.
    try:
        pref('research.percent')
    except KeyError:
        setpref('research.percent', 75)
    try:
        pref('research.revive_interval_seconds')
    except KeyError:
        setpref('research.revive_interval_seconds', 60*60)

    plura = PrefPanel(panel,
            PrefCollection(
                           PrefCollection(
                                          Check('local.research.enabled', _('Enabled'), default = True),
                                           Check('research.debug_output', _("Print debug output to console. (don't use pipes)"), default = False),
                                           Check('research.always_on',    _('Always On'), default = False),
                                           Check('research.battery_override', _('Run when on battery'), default = False),
                           layout = VSizer(),
                           itemoptions = (0, ALL, 3)),
                           PrefCollection(
                           Label('Percent:'),
                           lambda parent, prefix: Text(parent, pname(prefix, 'research.percent'),
                                                validator=NumericLimit(2, 100), _type=int),
                           Label('Revive in x seconds:'),
                           lambda parent, prefix: Text(parent, pname(prefix, 'research.revive_interval_seconds'), _type=int),
                           layout = VSizer(),
                           itemoptions = (0, ALL, 3)),
                           layout = HSizer(),
                           itemoptions = (0, BOTTOM | TOP, 3)),
            _('Plura'),
            prefix = '',
    )

    social = PrefPanel(panel,
                       PrefCollection(Check('social.use_global_status', _('Use Global Status Dialog (may require restart)'), default = False),
                                      Check('twitter.scan_urls', _('Scan tweets for URLs (for popup click action)'), default = False),
                                      layout = VSizer(),
                                      itemoptions = (0, BOTTOM | TOP, 3)
                                      ),
                       _('Social accounts'),
                       prefix = '',
                       )

    bottom.Add(top, 0, EXPAND | ALL, 0)
    bottom.Add(plura, 0, EXPAND | ALL, 3)
    bottom.Add(social, 0, EXPAND | ALL, 3)
    sizer.Add(bottom, 0, EXPAND | BOTTOM)

    return panel
Exemplo n.º 7
0
def panel(p, sizer, addgroup, exithooks):
    widgetlist = WidgetList(p, profile.widgets)

    browser = Browser(p)
    browser.SetMinSize((235, -1))

    preview = PrefPanel(p, browser, _('Widget Preview'))
    preview.SetMinSize((235, -1))

    embedpanel = wx.Panel(p)
    es = embedpanel.Sizer = VSizer()
    embedtext = wx.TextCtrl(embedpanel,
                            -1,
                            '',
                            style=wx.TE_MULTILINE | wx.TE_READONLY)
    embedtext.SetMinSize((-1, 60))

    copybutton = wx.Button(
        embedpanel,
        -1,
        _('&Copy To Clipboard'),
        style=wx.BU_EXACTFIT if platformName == 'mac' else 0)

    if platformName == 'mac':
        copybutton.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
        button_flags = 0, wx.ALIGN_RIGHT | RIGHT | TOP | BOTTOM, 3
    else:
        button_flags = 0, EXPAND | TOP, 3

    es.Add(embedtext, 1, EXPAND)
    es.Add(copybutton, *button_flags)

    def docopy(e):
        clip = wx.TheClipboard
        if clip.Open():
            clip.SetData(wx.TextDataObject(embedtext.Value))
            clip.Close()

    copybutton.Bind(wx.EVT_BUTTON, docopy)
    copybutton.Enable(False)

    def show_widget(widget_embed_text):
        browser.SetPage(widget_embed_text)

    def on_widget_selection(e):
        i = e.Int
        log.info('widget %d selected', i)
        if i != -1:
            widget = widgetlist.GetDataObject(i)
            embedtext.Value = widget.embed_tag
            copybutton.Enable(bool(embedtext.Value))

            wx.CallLater(150, show_widget, widget.embed_creator(*browser.Size))
        else:
            copybutton.Enable(False)

    widgetlist.Bind(wx.EVT_LIST_ITEM_SELECTED, on_widget_selection)

    widgets = PrefPanel(p, widgetlist, _('Widgets'), _('New Widget'),
                        lambda b: widgetlist.OnNew())

    embed = PrefPanel(p, embedpanel, _('Embed Tag'))

    top = HSizer()
    top.Add(widgets, 1, EXPAND)
    top.Add(preview, 0, EXPAND | LEFT, 6)

    sizer.Add(top, 1, EXPAND)
    sizer.Add(embed, 0, EXPAND | TOP, 6)

    p.on_close = widgetlist.on_close
    wx.CallLater(
        10, lambda: browser.SetPage(preview_placeholder % tuple(browser.Size)))
    return p
Exemplo n.º 8
0
def advanced_layout_panel(container_panel, pre, exithooks):
    cp_sizer = container_panel.Sizer
    adv_panel = container_panel.adv_panel = wx.Panel(container_panel)

    adv_panel.Sizer = VSizer()

    v = VSizer()
    #========================================================================================
    #HAX: This should be done differently
    #========================================================================================
    cb = wx.CheckBox(adv_panel, -1, '')
    adv_panel.Sizer.Add(v, 0, wx.ALIGN_CENTER_HORIZONTAL | RIGHT,
                        cb.Size.width * 1.5)
    cb.Destroy()
    #========================================================================================
    old_spacing, PrefGroup.SPACING = PrefGroup.SPACING, 0
    #===============================================================================================================
    s = adv_panel.Sizer
    prefix = 'buddylist.layout.'
    Cells = trellis.Cells
    cells = Cells(container_panel.layout_model)

    se_selection = Selection(value=cells['service'],
                             choices=cells['service_choices'],
                             enabled=cells['se_enabled'])
    st_selection = Selection(value=cells['status'],
                             choices=cells['status_choices'],
                             enabled=cells['st_enabled'])
    bi_selection = Selection(value=cells['icon'],
                             choices=['left', 'right'],
                             enabled=cells['icon_enabled'])
    #adapt for GUI models
    translated = dict(fleft=_('Far Left'),
                      left=_('Left'),
                      bleft=_('Badge (Lower Left)'),
                      bright=_('Badge (Lower Right)'),
                      right=_('Right'),
                      fright=_('Far Right'))
    se_choices = TranslatableChoices(keys=cells['service_choices'],
                                     translations=translated)
    st_choices = TranslatableChoices(keys=cells['status_choices'],
                                     translations=translated)
    bi_choices = TranslatableChoices(keys=['left', 'right'],
                                     translations=translated)

    #share a bunch of cells
    service_model = ChoiceModel(values=Cells(se_choices)['values'],
                                selection=Cells(se_selection)['selection'],
                                enabled=cells['se_enabled'])
    service_enabled = CheckModel(checked=Cells(service_model)['enabled'])
    status_model = ChoiceModel(values=Cells(st_choices)['values'],
                               selection=Cells(st_selection)['selection'],
                               enabled=cells['st_enabled'])
    status_enabled = CheckModel(checked=status_model.__cells__['enabled'])
    icon_model = ChoiceModel(values=Cells(bi_choices)['values'],
                             selection=Cells(bi_selection)['selection'],
                             enabled=cells['icon_enabled'])
    icon_enabled = CheckModel(checked=Cells(icon_model)['enabled'])

    service_check = SyncingCheck(service_enabled,
                                 adv_panel,
                                 label=_('Show service icon on:'))
    service_choice = SyncingChoice(service_model, adv_panel)
    status_check = SyncingCheck(status_enabled,
                                adv_panel,
                                label=_('Show status icon on:'))
    status_choice = SyncingChoice(status_model, adv_panel)
    icon_check = SyncingCheck(icon_enabled,
                              adv_panel,
                              label=_('Show buddy icon on the:'))
    icon_choice = SyncingChoice(icon_model, adv_panel)

    need_del = [
        locals()[cat + '_' + typ] for cat in ['service', 'status', 'icon']
        for typ in ['check', 'choice']
    ]
    exithooks.append(lambda: release_syncs(need_del))

    # Slider returns sizer, control
    bicon_slide, s = Slider('buddy_icon_size',
                            _('Buddy icon size:'),
                            start=12,
                            stop=65,
                            step=4,
                            value=get_pref('buddylist.layout.buddy_icon_size'),
                            fireonslide=True)(adv_panel, pre)

    buddypadding_slider, s2 = Slider(
        'padding',
        _('Buddy padding:'),
        start=0,
        stop=12,
        step=1,
        value=get_pref('buddylist.layout.padding'),
        fireonslide=True)(adv_panel, pre)

    v.Add(
        FontFaceAndSize('name_font', _('Contact name:'))(adv_panel, pre), 0,
        EXPAND)
    extra_info = EnabledGroup(
        ('', pre), Check('buddylist.layout.show_extra',
                         _('&Show extra info:')),
        Choice('buddylist.layout.extra_info',
               (('status', _('Status')), ('idle', _('Idle Time')),
                ('both', _('Idle Time + Status')))),
        FontFaceAndSize('extra_font'))(adv_panel)
    bsizer = VSizer()
    sssizer = VSizer()

    bsizer.AddMany([(extra_info, 0, EXPAND),
                    (OffsetGroup(('', pre), icon_check, icon_choice,
                                 bicon_slide)(adv_panel), 0, EXPAND)])

    sssizer.AddMany([
        (OffsetGroup(('', pre), status_check,
                     status_choice)(adv_panel), 0, EXPAND),
        (OffsetGroup(('', pre), service_check,
                     service_choice)(adv_panel), 0, EXPAND | TOP, 7),
        (buddypadding_slider, 0, EXPAND | TOP, 22),
    ])

    h = HSizer()
    h.AddMany([(bsizer, 1), (sssizer, 0, LEFT, 48)])
    v.Add(h, 1, EXPAND)

    #    cb(None)

    PrefGroup.SPACING = old_spacing

    cp_sizer.Add(adv_panel, 0, EXPAND)
Exemplo n.º 9
0
def panel(panel, sizer, addgroup, exithooks):
    two = PrefPanel(panel, sorting_sizer(panel, exithooks),
                    _('Sorting and Groups'))

    autohide_panel = wx.Panel(panel)
    aps = autohide_panel.Sizer = HSizer()

    if config.platform == 'win':
        # Setting autohide has to modify taskbar settings, so focus jumps to
        # the buddylist. This meant you wouldn't immediately see the effect
        # of checking the box if the blist was already docked, though.
        #
        # Now 50ms after checking it, the checkbox gets focus again, and the
        # buddylist will then slide away.
        def on_autohide_check(v):
            if v: wx.CallLater(50, autohide.SetFocus)
    else:

        def on_autohide_check(v):
            pass

    autohide = Check('local.buddylist.dock.autohide',
                     _('Autohide when not in &focus'),
                     callback=on_autohide_check)(autohide_panel)

    aps.Add(autohide, 0, LEFT, 18)

    dock = Check('local.buddylist.dock.enabled',
                 _('Automatically &dock when near edge of screen'),
                 callback=lambda v: autohide.Enable(v))(panel)
    autohide.Enable(dock.IsChecked())

    three = PrefPanel(
        panel,
        PrefCollection(Check('buddylist.always_on_top',
                             _('&Keep on top of other applications')),
                       Check('buddylist.show_in_taskbar',
                             _('Show in taskbar')),
                       dock,
                       autohide_panel,
                       layout=VSizer(),
                       itemoptions=(0, BOTTOM, 6)), _('Window Options'))

    # The autohide checkbox is slightly indented, and disabled when the "dock"
    # checkbox is unhecked.

    h = HSizer()
    h.Add(two, 1, EXPAND | RIGHT, 3)
    h.Add(three, 0, EXPAND | LEFT, 3)

    v = VSizer()
    v.Add(h, 0, EXPAND)

    from functools import partial
    four = PrefPanel(panel,
                     partial(contact_layout_panel, exithooks=exithooks),
                     _('Contact Layout'),
                     prefix='buddylist.layout')

    def AdvancedToggleCB(button):
        val = not pref('buddylist.layout.ez_layout', False)
        mark_pref('buddylist.layout.ez_layout', val)
        ezmode = val

        ez = four.content.ez_panel
        adv = four.content.adv_panel

        four.content.Sizer.Clear()

        four.content.Show(False)
        if ezmode:
            adv.Destroy()
            adv = None
            easy_layout_panel(four.content, 'buddylist.layout')
        else:
            ez.Destroy()
            ez = None
            advanced_layout_panel(four.content,
                                  'buddylist.layout',
                                  exithooks=exithooks)

        button.SetLabel(_('Advanced') if ezmode else _('Basic'))

        four.content.Layout()
        four.content.Show(True)
        panel.Layout()

    four.SetButton(
        _('Advanced') if four.content.ez_panel else _('Basic'),
        lambda button: wx.CallAfter(AdvancedToggleCB, button))

    v.Add(four, 0, EXPAND | TOP, 5)

    sizer.Add(v, 1, EXPAND)

    return panel
Exemplo n.º 10
0
def panel(panel, sizer, addgroup, exithooks):
    from gui.pref.pg_contact_list import SyncingCheck, SyncingChoice
    p = wx.Panel(panel)
    sz = p.Sizer = VSizer()

    s = wx.FlexGridSizer(6, 1, 7,7)
    prefix = 'buddylist.layout.'
    Cells = trellis.Cells

    layout_model = LayoutModel(
                               service      = get_pref(prefix+'service_icon_pos'),
                               se_enabled   = get_pref(prefix+'show_service_icon'),
                               status       = get_pref(prefix+'status_icon_pos'),
                               st_enabled   = get_pref(prefix+'show_status_icon'),
                               icon         = get_pref(prefix+'buddy_icon_pos'),
                               icon_enabled = get_pref(prefix+'show_buddy_icon'),
                               )
    #hook up helper models
    cells = Cells(layout_model)

    service_icon_pos  = PrefLink(prefname=prefix+'service_icon_pos',  value = cells['service'])
    show_service_icon = PrefLink(prefname=prefix+'show_service_icon', value = cells['se_enabled'])
    status_icon_pos   = PrefLink(prefname=prefix+'status_icon_pos',   value = cells['status'])
    show_status_icon  = PrefLink(prefname=prefix+'show_status_icon',  value = cells['st_enabled'])
    buddy_icon_pos    = PrefLink(prefname=prefix+'buddy_icon_pos',    value = cells['icon'])
    show_buddy_icon   = PrefLink(prefname=prefix+'show_buddy_icon',   value = cells['icon_enabled'])

    se_selection = Selection(value   = cells['service'],
                             choices = cells['service_choices'],
                             enabled = cells['se_enabled'])
    st_selection = Selection(value   = cells['status'],
                             choices = cells['status_choices'],
                             enabled = cells['st_enabled'])
    bi_selection = Selection(value   = cells['icon'],
                             choices = ['left','right'],
                             enabled = cells['icon_enabled'])
    #adapt for GUI models
    translated = dict(fleft  = _('Far Left'),
                      left   = _('Left'),
                      bleft  = _('Badge (Lower Left)'),
                      bright = _('Badge (Lower Right)'),
                      right  = _('Right'),
                      fright = _('Far Right'))
    se_choices = TranslatableChoices(keys=cells['service_choices'], translations = translated)
    st_choices = TranslatableChoices(keys=cells['status_choices'], translations = translated)
    bi_choices = TranslatableChoices(keys=['left','right'], translations = translated)

    #share a bunch of cells
    service_model   = ChoiceModel(values = Cells(se_choices)['values'],
                                  selection = Cells(se_selection)['selection'],
                                  enabled = cells['se_enabled'])
    service_enabled = CheckModel( checked = Cells(service_model)['enabled'])
    status_model    = ChoiceModel(values = Cells(st_choices)['values'],
                                  selection = Cells(st_selection)['selection'],
                                  enabled = cells['st_enabled'])
    status_enabled  = CheckModel( checked = status_model.__cells__['enabled'])
    icon_model      = ChoiceModel(values = Cells(bi_choices)['values'],
                                  selection = Cells(bi_selection)['selection'],
                                  enabled = cells['icon_enabled'])
    icon_enabled    = CheckModel( checked = Cells(icon_model)['enabled'])

    #Trellis will keep the rest alive
    s.links = [layout_model, service_icon_pos, show_service_icon, status_icon_pos, show_status_icon, buddy_icon_pos, show_buddy_icon]

    service_check   = SyncingCheck(service_enabled, p)
    service_choice  = SyncingChoice(service_model, p)
    status_check    = SyncingCheck(status_enabled, p)
    status_choice   = SyncingChoice(status_model, p)
    icon_check      = SyncingCheck(icon_enabled, p)
    icon_choice     = SyncingChoice(icon_model, p)

    s.Add(service_check)
    s.Add(service_choice)
    s.Add(status_check)
    s.Add(status_choice)
    s.Add(icon_check)
    s.Add(icon_choice)

    s.AddGrowableCol(1,1)
    sz.Add(s, 0, EXPAND)

    sizer.Add(p)

    return panel