示例#1
0
def handleCommand(event):
    """Handle the About command and display the About Snowberry
    dialog.

    @param event  An events.Command event.
    """

    if event.hasId('about'):
        # Create the About dialog and show it.
        dialog, area = sb.util.dialog.createButtonDialog(
            'about-dialog', ['show-credits', '', 'ok'], 'ok', resizable=False)

        content = area.createArea(alignment=ui.ALIGN_VERTICAL, border=0)
        content.setWeight(0)

        # Big logo.
        content.setBorder(16, ui.BORDER_BOTTOM)
        content.createImage('about')

        content.setBorder(6, ui.BORDER_BOTTOM)
        versionText = content.createText('', align=wt.Text.MIDDLE)
        versionText.setBoldStyle()
        versionText.setText(
            language.translate('about-version') + ' ' +
            st.getSystemString('snowberry-version'))

        content.createText('about-subtitle', align=wt.Text.MIDDLE)
        content.createText('about-license', align=wt.Text.MIDDLE)
        content.createText('about-website',
                           align=wt.Text.MIDDLE).setSmallStyle()

        #content.setBorder(6)
        #content.setWeight(1)
        #box = content.createArea(boxedWithTitle='about-credits')
        #info = box.createFormattedText()
        #info.setMinSize(300, 280)
        #info.setText(language.translate('about-info'))

        dialog.focusWidget('ok')
        dialog.run()

    elif event.hasId('show-credits'):
        dialog, area = sb.util.dialog.createButtonDialog(
            'about-credits', ['close'], 'close')
        info = area.createFormattedText()
        info.setMinSize(290, 230)
        info.setText(language.translate('credits'))
        dialog.addEndCommand('close')
        dialog.run()
示例#2
0
def handleCommand(event):
    """Handle the About command and display the About Snowberry
    dialog.

    @param event  An events.Command event.
    """

    if event.hasId('about'):
        # Create the About dialog and show it.
        dialog, area = sb.util.dialog.createButtonDialog(
            'about-dialog', ['show-credits', '', 'ok'], 'ok', resizable=False)

        content = area.createArea(alignment=ui.ALIGN_VERTICAL, border=0)
        content.setWeight(0)

        # Big logo.
        content.setBorder(16, ui.BORDER_BOTTOM)
        content.createImage('about')

        content.setBorder(6, ui.BORDER_BOTTOM)
        versionText = content.createText('', align=wt.Text.MIDDLE)
        versionText.setBoldStyle()
        versionText.setText(
            language.translate('about-version') + ' ' +
            st.getSystemString('snowberry-version'))
            
        content.createText('about-subtitle', align=wt.Text.MIDDLE)
        content.createText('about-license', align=wt.Text.MIDDLE)
        content.createText('about-website', align=wt.Text.MIDDLE).setSmallStyle()

        #content.setBorder(6)
        #content.setWeight(1)
        #box = content.createArea(boxedWithTitle='about-credits')
        #info = box.createFormattedText()
        #info.setMinSize(300, 280)
        #info.setText(language.translate('about-info'))
    
        dialog.focusWidget('ok')
        dialog.run()
        
    elif event.hasId('show-credits'):
        dialog, area = sb.util.dialog.createButtonDialog(
            'about-credits', ['close'], 'close')
        info = area.createFormattedText()
        info.setMinSize(290, 230)
        info.setText(language.translate('credits'))
        dialog.addEndCommand('close')
        dialog.run()
示例#3
0
def run(profile):
    """Open the load order dialog.

    @param profile The profile whose order is being edited.
    """

    dialog, area = sb.util.dialog.createButtonDialog(
        'load-order-dialog',
        ['reset', '', 'cancel', 'ok'], 'ok')

    dialog.focusWidget('cancel')
    area.setWeight(0)
    area.createText('load-order-message')

    # Create the widgets that will be used to edit the order.
    area.setWeight(1)
    top = area.createArea(alignment=ui.ALIGN_HORIZONTAL, border=0)

    top.setWeight(3)
    listArea = top.createArea(border=3)
    listArea.setWeight(1)
    orderList = listArea.createList('')
    orderList.setMinSize(200, 200)

    top.setWeight(1)
    controlArea = top.createArea(border=3)
    controlArea.setWeight(0)
    controlArea.setExpanding(False)
    upButton = controlArea.createButton('load-order-move-up')
    downButton = controlArea.createButton('load-order-move-down')
    controlArea.addSpacer()
    firstButton = controlArea.createButton('load-order-move-top')
    lastButton = controlArea.createButton('load-order-move-bottom')

    def moveSelFirst():
        orderList.moveItem(orderList.getSelectedItem(), -65535)

    def moveSelLast():
        orderList.moveItem(orderList.getSelectedItem(), +65535)

    def moveSelUp():
        orderList.moveItem(orderList.getSelectedItem(), -1)

    def moveSelDown():
        orderList.moveItem(orderList.getSelectedItem(), +1)

    firstButton.addReaction(moveSelFirst)
    upButton.addReaction(moveSelUp)
    downButton.addReaction(moveSelDown)
    lastButton.addReaction(moveSelLast)

    # The final addons are automatically sorted according to the
    # profile's load order.
    finalAddons = profile.getFinalAddons()
    
    # Put all the finalized list of loaded addons into the list.
    for ident in finalAddons:
        orderList.addItem(ident)

    if len(finalAddons):
        orderList.selectItem(finalAddons[0])

    # We'll accept 'reset' as a dialog end command as well.
    dialog.addEndCommand('reset')

    # Run the dialog and handle the closing command.
    result = dialog.run()

    if result == 'ok':
        # This is the new load order for the profile.
        profile.setLoadOrder(orderList.getItems())

    elif result == 'reset':
        # Clear the profile's load order.
        profile.setLoadOrder([])

    else:
        # Nothing is done on cancel.
        pass
示例#4
0
def run(profile):
    """Open the load order dialog.

    @param profile The profile whose order is being edited.
    """

    dialog, area = sb.util.dialog.createButtonDialog(
        'load-order-dialog', ['reset', '', 'cancel', 'ok'], 'ok')

    dialog.focusWidget('cancel')
    area.setWeight(0)
    area.createText('load-order-message')

    # Create the widgets that will be used to edit the order.
    area.setWeight(1)
    top = area.createArea(alignment=ui.ALIGN_HORIZONTAL, border=0)

    top.setWeight(3)
    listArea = top.createArea(border=3)
    listArea.setWeight(1)
    orderList = listArea.createList('')
    orderList.setMinSize(200, 200)

    top.setWeight(1)
    controlArea = top.createArea(border=3)
    controlArea.setWeight(0)
    controlArea.setExpanding(False)
    upButton = controlArea.createButton('load-order-move-up')
    downButton = controlArea.createButton('load-order-move-down')
    controlArea.addSpacer()
    firstButton = controlArea.createButton('load-order-move-top')
    lastButton = controlArea.createButton('load-order-move-bottom')

    def moveSelFirst():
        orderList.moveItem(orderList.getSelectedItem(), -65535)

    def moveSelLast():
        orderList.moveItem(orderList.getSelectedItem(), +65535)

    def moveSelUp():
        orderList.moveItem(orderList.getSelectedItem(), -1)

    def moveSelDown():
        orderList.moveItem(orderList.getSelectedItem(), +1)

    firstButton.addReaction(moveSelFirst)
    upButton.addReaction(moveSelUp)
    downButton.addReaction(moveSelDown)
    lastButton.addReaction(moveSelLast)

    # The final addons are automatically sorted according to the
    # profile's load order.
    finalAddons = profile.getFinalAddons()

    # Put all the finalized list of loaded addons into the list.
    for ident in finalAddons:
        orderList.addItem(ident)

    if len(finalAddons):
        orderList.selectItem(finalAddons[0])

    # We'll accept 'reset' as a dialog end command as well.
    dialog.addEndCommand('reset')

    # Run the dialog and handle the closing command.
    result = dialog.run()

    if result == 'ok':
        # This is the new load order for the profile.
        profile.setLoadOrder(orderList.getItems())

    elif result == 'reset':
        # Clear the profile's load order.
        profile.setLoadOrder([])

    else:
        # Nothing is done on cancel.
        pass