コード例 #1
0
def show_confirmation(message, proceed_handler=None, cancel_handler=None,
                               proceed_text=None, cancel_text=None, type=None):
    """
    Helper function to show a message that requires confirmation to proceed
    (ie an OK/Cancel).

    @param message: Message to display.
    @param proceed_handler: Function to call if OK is selected.
    @param cancel_handler: Function to call if Cancel is selected.
    @param proceed_text: Text to use for the proceed button (defaults to OK if this is None).
    @param cancel_text: Text to use for the cancel button (defaults to Cancel if this is None).
    @param type: Type of the dialog box being display, can be one of the standard ButtonDialog types.
    """
    if not is_dialog_supported():
        raise DialogsNotSupportedError()

    if proceed_text is None:
        proceed_text = _('OK')

    if cancel_text is None:
        cancel_text = _('Cancel')

    from dialog.dialogs import ButtonDialog
    dialog = ButtonDialog(((proceed_text, proceed_handler),
                           (cancel_text, cancel_handler, True)),
                           message,
                           type=type)
    dialog.show()
コード例 #2
0
 def confirm_system_restart(self, arg=None, menuw=None):
     """
     Pops up a ConfirmBox.
     """
     logger.log( 9, 'confirm_system_restart(arg=%r, menuw=%r)', arg, menuw)
     self.menuw = menuw
     what = _('Do you really want to restart the system?')
     dialog = ButtonDialog(((_('Restart'), self.shutdown_system_restart), (_('Cancel'), None, True)),
                            what, ButtonDialog.QUESTION_TYPE)
     dialog.show()
コード例 #3
0
    def confirm_freevo(self, arg=None, menuw=None):
        """
        Pops up a ConfirmBox.
        """
        logger.log( 9, 'confirm_freevo(arg=%r, menuw=%r)', arg, menuw)
        self.menuw = menuw

        what = _('Do you really want to shut down Freevo?')
        dialog = ButtonDialog(((_('Shutdown'), self.shutdown_freevo), (_('Cancel'), None, True)),
                               what, ButtonDialog.QUESTION_TYPE)
        dialog.show()
コード例 #4
0
def show_alert(message, type=None, handler=None):
    """
    Helper function to show a message that requires user input to close.

    @param message: Message to display.
    @param type: The type of the alert to show either None, 'warning' or 'error'.
    @param handler: Function to call when dialog is closed.
    """
    if not is_dialog_supported():
        raise DialogsNotSupportedError()

    from dialog.dialogs import ButtonDialog
    dialog = ButtonDialog(((_('Close'), handler),), message, type=type)
    dialog.show()