Esempio n. 1
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
Esempio 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
Esempio n. 3
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.links = parent.links
        self.Sizer = wx.BoxSizer(wx.VERTICAL)
        self.grid = wx.FlexGridSizer(2, 3)
        self.grid.AddGrowableRow(1, 1)
        self.Sizer.Add(self.grid, 0,
                       wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)

        from gui import skin
        g = skin.get

        icons = g('AppDefaults.ez.icons')

        items = self.items = [
            LayoutItem(
                self, icons.one,
                dict(show_extra=True,
                     extra_info='both',
                     show_buddy_icon=True,
                     buddy_icon_pos='left',
                     buddy_icon_size=32,
                     show_status_icon=True,
                     status_icon_pos='bleft',
                     show_service_icon=True,
                     service_icon_pos='bright')),
            LayoutItem(
                self, icons.two,
                dict(show_extra=True,
                     extra_info='both',
                     show_buddy_icon=True,
                     buddy_icon_pos='right',
                     buddy_icon_size=32,
                     show_status_icon=True,
                     status_icon_pos='bleft',
                     show_service_icon=True,
                     service_icon_pos='bright')),
            LayoutItem(
                self, icons.three,
                dict(show_extra=True,
                     extra_info='both',
                     show_buddy_icon=True,
                     buddy_icon_pos='right',
                     buddy_icon_size=32,
                     show_status_icon=True,
                     status_icon_pos='left',
                     show_service_icon=True,
                     service_icon_pos='bright')),
            LayoutItem(
                self, icons.four,
                dict(show_extra=True,
                     extra_info='idle',
                     show_buddy_icon=False,
                     show_status_icon=True,
                     status_icon_pos='right',
                     show_service_icon=True,
                     service_icon_pos='left')),
            LayoutItem(
                self, icons.five,
                dict(show_extra=True,
                     extra_info='idle',
                     show_buddy_icon=False,
                     show_status_icon=True,
                     status_icon_pos='left',
                     show_service_icon=True,
                     service_icon_pos='right')),
            LayoutItem(
                self, icons.six,
                dict(
                    show_extra=True,
                    extra_info='idle',
                    show_buddy_icon=False,
                    show_status_icon=True,
                    status_icon_pos='left',
                    show_service_icon=False,
                ))
        ]

        self.grid.AddMany([(item, 0) for item in items])
        self.selection = None

        for item in items:
            for key in item.prefdict:
                if item.prefdict[key] != get_pref('buddylist.layout.%s' % key):
                    break
            else:
                self.SetSelection(item)
                break
Esempio n. 4
0
def checkbox_enabled_when_pref(cb, prefname):
    cb.Enabled = get_pref(prefname)
    profile.prefs.link(prefname,
                       lambda val: wx.CallAfter(cb.Enable, val),
                       obj=cb)
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.links = parent.links
        self.Sizer = wx.BoxSizer(wx.VERTICAL)
        self.grid = wx.FlexGridSizer(2, 3)
        self.grid.AddGrowableRow(1, 1)
        self.Sizer.Add(self.grid, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)

        from gui import skin

        g = skin.get

        icons = g("AppDefaults.ez.icons")

        items = self.items = [
            LayoutItem(
                self,
                icons.one,
                dict(
                    show_extra=True,
                    extra_info="both",
                    show_buddy_icon=True,
                    buddy_icon_pos="left",
                    buddy_icon_size=32,
                    show_status_icon=True,
                    status_icon_pos="bleft",
                    show_service_icon=True,
                    service_icon_pos="bright",
                ),
            ),
            LayoutItem(
                self,
                icons.two,
                dict(
                    show_extra=True,
                    extra_info="both",
                    show_buddy_icon=True,
                    buddy_icon_pos="right",
                    buddy_icon_size=32,
                    show_status_icon=True,
                    status_icon_pos="bleft",
                    show_service_icon=True,
                    service_icon_pos="bright",
                ),
            ),
            LayoutItem(
                self,
                icons.three,
                dict(
                    show_extra=True,
                    extra_info="both",
                    show_buddy_icon=True,
                    buddy_icon_pos="right",
                    buddy_icon_size=32,
                    show_status_icon=True,
                    status_icon_pos="left",
                    show_service_icon=True,
                    service_icon_pos="bright",
                ),
            ),
            LayoutItem(
                self,
                icons.four,
                dict(
                    show_extra=True,
                    extra_info="idle",
                    show_buddy_icon=False,
                    show_status_icon=True,
                    status_icon_pos="right",
                    show_service_icon=True,
                    service_icon_pos="left",
                ),
            ),
            LayoutItem(
                self,
                icons.five,
                dict(
                    show_extra=True,
                    extra_info="idle",
                    show_buddy_icon=False,
                    show_status_icon=True,
                    status_icon_pos="left",
                    show_service_icon=True,
                    service_icon_pos="right",
                ),
            ),
            LayoutItem(
                self,
                icons.six,
                dict(
                    show_extra=True,
                    extra_info="idle",
                    show_buddy_icon=False,
                    show_status_icon=True,
                    status_icon_pos="left",
                    show_service_icon=False,
                ),
            ),
        ]

        self.grid.AddMany([(item, 0) for item in items])
        self.selection = None

        for item in items:
            for key in item.prefdict:
                if item.prefdict[key] != get_pref("buddylist.layout.%s" % key):
                    break
            else:
                self.SetSelection(item)
                break
Esempio n. 6
0
def panel(panel, sizer, addgroup, exithooks):

    try:
        import researchdriver.driver
    except ImportError:
        default_cpu_num = 75
        default_bandwidth_num = 90
    else:
        default_cpu_num = int(researchdriver.driver.get_cpu_percent())
        default_bandwidth_num = int(researchdriver.driver.get_bandwidth_percent())

    description = PrefPanel(
        panel,
        build_description_webview,
        _('Research Module'),
        prefix = '',
    )
    options = PrefPanel(panel,
            PrefCollection(
                           PrefCollection(
                                          PC.Check('local.research.enabled',
                                                   _('Allow Digsby to use CPU time to conduct research after %2(research.idle_time_min)d minutes of idle time')),
                                          layout = PC.VSizer(),
                                          itemoptions = (0, wx.ALL, 3),
                                          ),
                           PrefCollection(
                                          lambda parent, prefix: PC.Slider(PC.pname(prefix, 'local.research.cpu_percent'),
                                                                           _('Maximum CPU Usage:'),
                                                                           start = 1, stop = 101, step = 1,
                                                                           value   = int(PC.get_pref('local.research.cpu_percent', default=default_cpu_num)),
                                                                           default = int(PC.get_pref('local.research.cpu_percent', default=default_cpu_num)),
                                                                           fireonslide = True,
                                                                           unit = _('{val}%'))(parent)[0], # Slider returns the sizer and the control, we just want the sizer
                                          lambda parent, prefix: PC.Slider(PC.pname(prefix, 'local.research.bandwidth_percent'),
                                                                           _('Maximum Bandwidth Usage:'),
                                                                           start = 1, stop = 101, step = 1,
                                                                           value   = int(PC.get_pref('local.research.bandwidth_percent', default=default_bandwidth_num)),
                                                                           default = int(PC.get_pref('local.research.bandwidth_percent', default=default_bandwidth_num)),
                                                                           fireonslide = True,
                                                                           unit = _('{val}%'))(parent)[0], # Slider returns the sizer and the control, we just want the sizer
                                          layout = PC.HSizer(),
                                          itemoptions = (0, wx.ALL, 3),
                                          ),
                           layout = PC.VSizer(),
                           itemoptions = (0, wx.BOTTOM | wx.TOP, 3)),
            _('Options'),
            prefix = '',
    )

    sizer.Add(description, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)
    sizer.Add(options, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)

    return panel
Esempio n. 7
0
def panel(panel, sizer, addgroup, exithooks):

    try:
        import researchdriver.driver
    except ImportError:
        default_cpu_num = 75
        default_bandwidth_num = 90
    else:
        default_cpu_num = int(researchdriver.driver.get_cpu_percent())
        default_bandwidth_num = int(
            researchdriver.driver.get_bandwidth_percent())

    description = PrefPanel(
        panel,
        build_description_webview,
        _('Research Module'),
        prefix='',
    )
    options = PrefPanel(
        panel,
        PrefCollection(
            PrefCollection(
                PC.Check(
                    'local.research.enabled',
                    _('Allow Digsby to use CPU time to conduct research after %2(research.idle_time_min)d minutes of idle time'
                      )),
                layout=PC.VSizer(),
                itemoptions=(0, wx.ALL, 3),
            ),
            PrefCollection(
                lambda parent, prefix: PC.Slider(
                    PC.pname(prefix, 'local.research.cpu_percent'),
                    _('Maximum CPU Usage:'),
                    start=1,
                    stop=101,
                    step=1,
                    value=int(
                        PC.get_pref('local.research.cpu_percent',
                                    default=default_cpu_num)),
                    default=int(
                        PC.get_pref('local.research.cpu_percent',
                                    default=default_cpu_num)),
                    fireonslide=True,
                    unit=_('{val}%'))
                (parent)[
                    0
                ],  # Slider returns the sizer and the control, we just want the sizer
                lambda parent, prefix: PC.Slider(
                    PC.pname(prefix, 'local.research.bandwidth_percent'),
                    _('Maximum Bandwidth Usage:'),
                    start=1,
                    stop=101,
                    step=1,
                    value=int(
                        PC.get_pref('local.research.bandwidth_percent',
                                    default=default_bandwidth_num)),
                    default=int(
                        PC.get_pref('local.research.bandwidth_percent',
                                    default=default_bandwidth_num)),
                    fireonslide=True,
                    unit=_('{val}%'))
                (parent)[
                    0
                ],  # Slider returns the sizer and the control, we just want the sizer
                layout=PC.HSizer(),
                itemoptions=(0, wx.ALL, 3),
            ),
            layout=PC.VSizer(),
            itemoptions=(0, wx.BOTTOM | wx.TOP, 3)),
        _('Options'),
        prefix='',
    )

    sizer.Add(description, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)
    sizer.Add(options, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)

    return panel
Esempio 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)
Esempio n. 9
0
def checkbox_enabled_when_pref(cb, prefname):
    cb.Enabled = get_pref(prefname)
    profile.prefs.link(prefname, lambda val: wx.CallAfter(cb.Enable, val), obj = cb)
Esempio n. 10
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)
Esempio n. 11
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
Esempio n. 12
0
 def output_pref(self):
     if self.go:
         from gui.pref.prefcontrols import mark_pref
         if get_pref(self.prefname) != self.value:
             mark_pref(self.prefname, self.value)